I found this web part for Exchange 2003, but in exchange 2007 even after user login, web part shows exchange 2007 owa login page (instead of current user inbox).
How I can show current user's exchange 2007 inbox in moss 2007? Any Idea?
The solution is to create a wrapper webpart around the out of the box OWA webpart and have that access the inbox by using the currently logged in user's emailaddress.
Here's the code
P.S. (note that the address of the webaccess is set in the appsettings here!)
using System;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Portal.WebControls;
namespace DCubed.SharePoint.WeParts
{
/// <summary>
/// Wrapper around the My Inbox WebPart
/// </summary>
public class MyInboxEx : WebPart
{
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
// Create the instance of My Inbox Web Part
var inbox = new OWAInboxPart
{
MailboxName = SPContext.Current.Web.CurrentUser.Email,
OWAServerAddressRoot = ConfigurationManager.AppSettings["MailServer"]
};
Controls.Add(inbox);
}
}
}
Related
I'am new in MVC. I'am currently working to transform a desktop to a web application.
I need to make an update to the user view when an event of an object occurred. I have an object that observe a humidity sensor. Let say This object will trigger an event when the humidity above 70%. The code might be like this:
Private Sub Humidity_Alert(sender As Object) Handles objSensor.Alert
'Update user chart
End Sub
In desktop application, I just make an update to the view as usual in realtime, but I don't have any idea yet how to return this event to the client in MVC, without using javascript timer to make an ajax call to request if there is any alert. How to solve my problem?
I would suggest using ASP.NET SignalR library: signalr.net
You can use it for real-time updates from server to client.
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
Some pseudo-code example:
SignalR Hub:
public class HumidityHub : Hub
{
public void RefreshChart(string data)
{
Clients.All.refreshChart(data);
}
}
ClientCode:
var hub = $.connection.humidityHub;
hub.client.refreshChart= function (data) {
//refresh your chart
};
$.connection.hub.start();
ServerCode:
var hubContext = GlobalHost.ConnectionManager.GetHubContext<HumidityHub >();
hubContext.Clients.All.refreshChart(data);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am currently looking into (ideally headless) integration testing frameworks for asp.net mvc 5 (potentially with webapi in the same project). I am aware of these 2:
SpecsFor.Mvc
MvcIntegrationTestFramework (there are several incarnation of this on github)
Are there any others? I am especially interested in any frameworks that work well with specflow.
I successfully integrated SpecsFor.Mvc with SpecFlow today. It's pretty cool.
Here's a set of classes that should get you started with integrating SpecsFor.Mvc with SpecFlow. Of course, these could be better abstracted and extended upon; but at a bare minimum, this is all you need:
namespace SpecsForMvc.SpecFlowIntegration
{
using Microsoft.VisualStudio.TestingTools.UnitTesting;
using SpecsFor.Mvc;
using TechTalk.SpecFlow;
[Binding]
public class SpecsForMvcSpecFlowHooks
{
private static SpecsForIntegrationHost integrationHost;
/// <summary>
/// <p>
/// This hook runs at the end of the entire test run.
/// It's analogous to an MSTest method decorated with the
/// <see cref="Microsoft.VisualStudio.TestingTools.UnitTesting.AssemblyCleanupAttribute" />
/// attribute.
/// </p>
/// <p>
/// NOTE: Not all test runners have the notion of a test run cleanup.
/// If using MSTest, this probably gets run in a method decorated with
/// the attribute mentioned above. For other test runners, this method
/// may not execute until the test DLL is unloaded. YMMV.
/// </p>
/// </summary>
[AfterTestRun]
public void CleanUpTestRun()
{
integrationHost.Shutdown();
}
/// <summary>
/// <p>
/// This hook runs at the beginning of an entire test run.
/// It's equivalent to an MSTest method decorated with the
/// <see cref="Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyInitializeAttribute />
/// attribute.
/// </p>
/// <p>
/// NOTE: Not all test runners have a notion of an assembly
/// initializer or test run initializer, YMMV.
/// </p>
/// </summary>
[BeforeTestRun]
public static void InitializeTestRun()
{
var config = new SpecsForMvcConfig();
config.UseIISExpress()
.With(Project.Named("Your Project Name Here"))
.ApplyWebConfigTransformForConfig("Debug");
config.BuildRoutesUsing(r => RouteConfig.RegisterRoutes(r));
// If you want to be authenticated for each request,
// implement IHandleAuthentication
config.AuthenticateBeforeEachTestUsing<SampleAuthenticator>();
// I originally tried to use Chrome, but the Selenium
// Chrome WebDriver, but it must be out of date because
// Chrome gave me an error and the tests didn't run (NOTE:
// I used the latest Selenium NuGet package as of
// 23-08-2014). However, Firefox worked fine, so I used that.
config.UseBrowser(BrowserDriver.Firefox);
integrationHost = new SpecsForMvcIntegrationHost(config);
integrationHost.Start();
}
/// <summary>
/// This hook runs once before any of the SpecFlow feature's
/// scenarios are run and stores a <see cref="SpecsFor.Mvc.MvcWebApp />
/// instance in the <see cref="TechTalk.SpecFlow.FeatureContext" />
/// for the feature.
/// </summary>
[BeforeFeature]
public static void CreateFeatureMvcWebApp()
{
MvcWebApp theApp;
if (!FeatureContext.Current.TryGetValue<MvcWebApp>(out theApp))
FeatureContext.Current.Set<MvcWebApp>(new MvcWebApp());
}
}
public class SpecsForMvcStepDefinitionBase
{
/// <summary>
/// Gets the instance of the <see cref="SpecsFor.Mvc.MvcWebApp" />
/// object stored in the <see cref="TechTalk.SpecFlow.FeatureContext" />
/// for the current feature.
/// </summary>
public static MvcWebApp WebApp
{
get { return FeatureContext.Current.Get<MvcWebApp>(); }
}
}
}
Then, let's say you have a SpecFlow feature file as per the below (this is a partial file):
Feature: Login
As a user of the website
I want to be able to log on the the site
in order to use the features available to site members.
# For the site I'm currently working with, even though it's MVC, it's more
# of a WebAPI before there was WebAPI--so the controllers accept JSON and return
# JsonResult objects--so that's what you're going to see.
Scenario: Using a valid username and password logs me on to the site
Given the valid username 'somebody#somewhere.com'
And the password 'my_super_secure_password'
When the username and password are submitted to the login form
Then the website will return a result
And it will contain an authentication token
And it will not contain any exception record.
And now the steps for the above scenario:
using Newtonsoft.Json;
using OpenQA.Selenium;
using MyWebSite.Controllers;
using Should;
using TechTalk.SpecFlow;
[Binding]
public class LoginSteps : SpecsForMvcStepDefinitionBase
{
// The base class gets me the WebApp property that allows easy
// access to the SpecsFor.Mvc.MvcWebApp object that drives a web browser
// via Selenium.
private string _username;
private string _password;
private string _portalSessionId;
private ServiceResponse<LoginSummary> _loginResponse;
[Given(#"the valid username '(.*)'")]
[Given(#"the invalid username '(.*)'")]
public void GivenAUsername(string username)
{
_username = username;
}
[Given(#"the valid password '(.*)'")]
[Given(#"the invalid password '(.*)'")]
public void GivenAPassword(string password)
{
_password = password;
}
[When(#"the username and password are submitted to the " +
#"LoginUser action method of the UserController")]
public void WhenTheUsernameAndPasswordAreSubmitted()
{
WebApp.NavigateTo<UserController>(
c => c.LoginUser(_username, _password)
);
}
[Then(#"the UserController will reply with a LoginSummary")]
public void ThenTheUserControllerWillReplyWithALoginSummary()
{
_loginResponse =
JsonConvert.DeserializeObject<ServiceResponse<LoginSummary>>(
WebApp.Browser.FindElement(By.TagName("pre")).Text
);
}
[Then(#"it will contain an authentication token")]
public void ThenItWillContainAnAuthenticationToken()
{
_loginSummary.Results.Count.ShouldBeGreaterThan(0);
_loginSummary.Results[0].AuthenticationToken.ShouldNotBeEmpty();
}
[Then(#"it will not contain an exception record")]
public void THenItWillNotContainAnExceptionRecord()
{
_loginSummary.Exception.ShouldBeNull();
}
}
Pretty cool.
About the methods decorated with BeforeTestRun and AfterTestRun, I found the information mentioned in the code comments at the following blog post: Advanced SpecFlow: Using Hooks to Run Additional Automation Code.
Of course, you may still want to construct classes that follow the Page Object pattern if you'll be testing presentation layout. As I stated in my code comments, the particular app I'm writing integration tests for pre-dates WebAPI but function like WebAPI but using ASP.Net MVC. We just haven't officially ported it to WebAPI yet.
Using ASP.NET Web API along with ASP.NET Identity 1.0, you can use this extension method to retrieve the currently signed in user:
var id = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity);
But in ASP.NET identity 2.0 alpha, you can override the type for the ID field. The example given by Microsoft shows setting this field to be an int. But this extension method seems to be hardcoded to return a string even in the alpha:
http://msdn.microsoft.com/en-us/library/microsoft.aspnet.identity.identityextensions.getuserid(v=vs.111).aspx
How can you retrieve the (int) identity of the currently logged in user from within a Web API controller when using ASP.NET Identity 2.0 alpha?
You have to do the conversion manually yourself currently, because Claims are intrinsically strings. We could provide some sort of generic extension like User.Identity.GetUserId which tries to do a conversion from string -> T and this is something we are considering improving in future releases.
I ended up using :
public static class IdentityExtensions {
public static T GetUserId<T>(this IIdentity identity) where T : IConvertible {
return (T)Convert.ChangeType(identity.GetUserId(), typeof(T));
}
}
and calling it as : GetUserId<int>()
I have QuickBooks 2010 pro edition, As the Title suggests I need to import Products & Invoices into Quickbooks.
Some Background...
we are an online company where we sell products online, my client wants to import all products into quickbooks and every online sale into quickbooks as well, our website is built using ASP.NET with SQL Server as backed.
I am new to quickbooks, so i am not sure what to do from here...
I have heard of IIF import & SDK, unfortunately I could not find and valuable documentation on them. can anyone please put me in right direction (maybe some sample code)? please do not give me SDK url of quickbooks website.
Thanks
If you're not willing to look at the QuickBooks SDK, you are doing yourself a huge disservice.
The easiest way to implement what you're trying to do is via the SDK and the Web Connector. There's a basic overview of the QuickBooks Web Connector on our wiki. It's specifically geared towards moving data from an online website, into QuickBooks for Windows (just like you're trying to do). The basic idea is that it polls your website, asking for stuff to do, and you can feed it XML requests to do stuff (add a customer, add an invoice, etc.).
Basic protocol looks like this:
// Web Connector asks your SOAP service to authenticate Web Connector
=> SOAP server: authenticate with the username "xyz" and the password "bla" (authenticate)
If authentication is successful, the SOAP server returns a ticket value and the process continues
// Web Connector asks for something to do Web Connector => SOAP
server: hey SOAP server, what do you have for me to do?
(sendRequestXML)
SOAP server generates and returns a qbXML request
// Web Connector relays that request to QuickBooks, and receives a
response from QuickBooks Web Connector => QuickBooks: hey
QuickBooks, the SOAP server gave me this request, can you please
process it?
QuickBooks processes the request, and returns a response to the Web Connector
// Web Connector relays the response from QuickBooks back to the SOAP
server Web Connector => SOAP server: hey SOAP server, here is the
response for that last request from QuickBooks (receiveResponseXML)
SOAP server processes the response, handling any errors and doing whatever with the response
SOAP server returns a percentage done, if it's less than 100%, this process continues...
// The process starts over, with the Web Connector asking the SOAP
server for the next request... Web Connector => SOAP server: hey
SOAP server, what else do you have for me to do? (sendRequestXML)
SOAP server generates and returns a qbXML request
... and so on and so forth ...
If you download the QuickBooks SDK (ouch, sorry!) you'll find that it contains some of the stuff you've asked for. Specifically, there is sample code it drops in this directory:
C:\Program Files (x86)\Intuit\IDN\QBSDK12.0\samples\qbdt\c-sharp\qbXML\WCWebService
Here's a cleaned up, stripped down version of what's in that sample code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Security.Cryptography;
using Microsoft.Win32;
using System.Xml;
using System.Text.RegularExpressions;
namespace WCWebService
{
/// <summary>
/// Web Service Namespace="http://developer.intuit.com/"
/// Web Service Name="WCWebService"
/// Web Service Description="Sample WebService in ASP.NET to
/// demonstrate QuickBooks WebConnector"
/// </summary>
[WebService(
Namespace="http://developer.intuit.com/",
Name="WCWebService",
Description="Sample WebService in ASP.NET to demonstrate " +
"QuickBooks WebConnector")]
// Important Note:
// You should keep the namespace as http://developer.intuit.com/ for all web
// services that communicates with QuickBooks Web Connector.
public class WCWebService : System.Web.Services.WebService
{
...
#region WebMethods
[WebMethod]
/// <summary>
/// WebMethod - authenticate()
/// To verify username and password for the web connector that is trying to connect
/// Signature: public string[] authenticate(string strUserName, string strPassword)
///
/// IN:
/// string strUserName
/// string strPassword
///
/// OUT:
/// string[] authReturn
/// Possible values:
/// string[0] = ticket
/// string[1]
/// - empty string = use current company file
/// - "none" = no further request/no further action required
/// - "nvu" = not valid user
/// - any other string value = use this company file
/// </summary>
public string[] authenticate(string strUserName, string strPassword)
{
string[] authReturn = new string[2];
// Code below uses a random GUID to use as session ticket
// An example of a GUID is {85B41BEE-5CD9-427a-A61B-83964F1EB426}
authReturn[0]= System.Guid.NewGuid().ToString();
// For simplicity of sample, a hardcoded username/password is used.
// In real world, you should handle authentication in using a standard way.
// For example, you could validate the username/password against an LDAP
// or a directory server
string pwd="password";
if (strUserName.Trim().Equals("username") && strPassword.Trim().Equals(pwd))
{
// An empty string for authReturn[1] means asking QBWebConnector
// to connect to the company file that is currently openned in QB
authReturn[1]="";
}
else
{
authReturn[1]="nvu";
}
// You could also return "none" to indicate there is no work to do
// or a company filename in the format C:\full\path\to\company.qbw
// based on your program logic and requirements.
return authReturn;
}
[ WebMethod(Description="This web method facilitates web service to send request XML to QuickBooks via QBWebConnector",EnableSession=true) ]
/// <summary>
/// WebMethod - sendRequestXML()
/// Signature: public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
/// string Country, int qbXMLMajorVers, int qbXMLMinorVers)
///
/// IN:
/// int qbXMLMajorVers
/// int qbXMLMinorVers
/// string ticket
/// string strHCPResponse
/// string strCompanyFileName
/// string Country
/// int qbXMLMajorVers
/// int qbXMLMinorVers
///
/// OUT:
/// string request
/// Possible values:
/// - “any_string” = Request XML for QBWebConnector to process
/// - "" = No more request XML
/// </summary>
public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers)
{
... build some qbXML request here and return it ...
return request;
}
[ WebMethod(Description="This web method facilitates web service to receive response XML from QuickBooks via QBWebConnector",EnableSession=true) ]
/// <summary>
/// WebMethod - receiveResponseXML()
/// Signature: public int receiveResponseXML(string ticket, string response, string hresult, string message)
///
/// IN:
/// string ticket
/// string response
/// string hresult
/// string message
///
/// OUT:
/// int retVal
/// Greater than zero = There are more request to send
/// 100 = Done. no more request to send
/// Less than zero = Custom Error codes
/// </summary>
public int receiveResponseXML(string ticket, string response, string hresult, string message)
{
... process the response from QuickBooks here, and return an integer ...
return retVal;
}
#endregion
} // class: WCWebService
} // namespace: WCWebService
The QuickBooks SDK also contains a 98 page Web Connector documentation PDF which describes implementation in detail, and 600 pages of general QuickBooks SDK documentation which might be helpful.
I'm using the ASP.NET 3.5 SP1 System.Web.Routing with classic WebForms, as described in http://chriscavanagh.wordpress.com/2008/04/25/systemwebrouting-with-webforms-sample/
All works fine, I have custom SEO urls and even the postback works. But there is a case where the postback always fails and I get a:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Here is the scenario to reproduce the error:
Create a standard webform mypage.aspx with a button
Create a Route that maps "a/b/{id}" to "~/mypage.aspx"
When you execute the site, you can navigate http://localhost:XXXX/a/b/something the page works. But when you press the button you get the error. The error doen't happen when the Route is just "a/{id}".
It seems to be related to the number of sub-paths in the url. If there are at least 2 sub-paths the viewstate validation fails.
You get the error even with EnableViewStateMac="false".
Any ideas? Is it a bug?
Thanks
I worked around this by having my view user control inherit from this class instead of ViewUserControl<T> (it's kind of a patch for RenderView). It did the trick for me, hopefully it works for you too.
public class ViewUserControlWithoutViewState<T> : ViewUserControl<T> where T : class {
protected override void LoadViewState(object savedState) {}
protected override object SaveControlState() {
return null;
}
protected override void LoadControlState(object savedState) {}
protected override object SaveViewState() {
return null;
}
/// <summary>
/// extracted from System.Web.Mvc.ViewUserControl
/// </summary>
/// <param name="viewContext"></param>
public override void RenderView(ViewContext viewContext) {
viewContext.HttpContext.Response.Cache.SetExpires(DateTime.Now);
var containerPage = new ViewUserControlContainerPage(this);
ID = Guid.NewGuid().ToString();
RenderViewAndRestoreContentType(containerPage, viewContext);
}
/// <summary>
/// extracted from System.Web.Mvc.ViewUserControl
/// </summary>
/// <param name="containerPage"></param>
/// <param name="viewContext"></param>
public static void RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext) {
string contentType = viewContext.HttpContext.Response.ContentType;
containerPage.RenderView(viewContext);
viewContext.HttpContext.Response.ContentType = contentType;
}
/// <summary>
/// Extracted from System.Web.Mvc.ViewUserControl+ViewUserControlContainerPage
/// </summary>
private sealed class ViewUserControlContainerPage : ViewPage {
// Methods
public ViewUserControlContainerPage(ViewUserControl userControl) {
Controls.Add(userControl);
EnableViewState = false;
}
protected override object LoadPageStateFromPersistenceMedium() {
return null;
}
protected override void SavePageStateToPersistenceMedium(object state) {}
}
}
I blogged about this some time ago.
I also found this bug in asp.net mvc beta. It can be very reproduced. After create asp.net mvc application using the default template, add a asp:button control to page home.aspx in design view, hit f5, the home page is displayed properly. click the button, this error will show up. After some debugging into the mvc source code, I found it is caused by the ViewUserControl in site.master page, just comment the <% Html.RenderPartial("LoginUserControl"); %>, then the click event can be handled properly.
I also found that setting like enableViewStateMac="false" enableEventValidation="false" viewStateEncryptionMode="Never" is not useful.
In the mvc source code the following section handle the ViewUserControl rendering
public virtual void RenderView(ViewContext viewContext) {
// TODO: Remove this hack. Without it, the browser appears to always load cached output
viewContext.HttpContext.Response.Cache.SetExpires(DateTime.Now);
**ViewUserControlContainerPage containerPage = new ViewUserControlContainerPage(this);**
// Tracing requires Page IDs to be unique.
ID = Guid.NewGuid().ToString();
containerPage.RenderView(viewContext);
}
private sealed class ViewUserControlContainerPage : ViewPage {
public ViewUserControlContainerPage(ViewUserControl userControl) {
Controls.Add(userControl);
}
}
the ViewUserControl always render in a newly created container page, this page will not pick your setting. In fact if step to this section, manually change the container.enableViewStateMac to false, does help to kill the error. So the only way to solve it is to ask Microsoft to change the mvc code.
This issue on Microsoft Connect:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=393619
I had this same issue,
I had some rogue
<form></form>
Tags, once I removed them from my page the error no longer came up.
Just try to clear cookies on your local machine. Had same issue and this helped.
Are you using safari as a browser? if so then this will probably be a problem with a large float. Remove that float and things will work fine.