| Sidhartha 的个人资料Inherited from System.Ob...日志列表 | 帮助 |
|
4月28日 Speeding up your CCF WorkflowCCF Workflows takes several seconds to start for the first time. This is to do with the fundamental .Net feature called JIT. When you first launch the workflow, CCF creates the workflow engine for the first time and starts the engine before working on your request. This eats up so much of processor... remember the JIT compiler compiles the IL instructions only when required? One workaround for this problem would be warm up your workflow before the user actually uses this. This will help in faster response time from CCF as the required last minute compilations are already done for you and all you will do is to use the cached binary instructions instead of IL. As always, below is the sample code that does exactly what is mentioned in the above sentence: Find the line in your desktop.cs file customerWorkflowManager = (IWorkflowManager)this.GetHostedApp("Customer Workflow Manager"); add the following lines below that statement. //Modified for warming up the workflow ThreadStart ts = new ThreadStart(ExecuteAsyncWorkflow); Thread wfThread = new Thread(ts); wfThread.Start(data); //end of modifications Finally, add this method. private void ExecuteAsyncWorkflow() { System.Reflection.MethodInfo method = customerWorkflowManager.GetType().GetMethod( string data = @"<Workflow><StepName>NAME HERE</StepName><HostedApplicationId>ID FROM DATABASE HERE</HostedApplicationId> This is fairly simple code could save you up to 20 seconds. The tradeoff with this approach (of course all good things have an asterix) you are adding more load during the start up, though the time your solution loads will not change as this is a background thread, but the CPU is now split with one additional thread. 4月27日 Adding CCF Agents ProgrammaticallyOne of the most annoying features for admins with managing CCF is adding Agents. Updating/Deleting are less annoying as they are not in bulk most of the times. Even manually adding Agents using CCF Admin Console is not productive when adding more than few users. CCF Admin Console, internally uses WCF web services (in CCF 2008) to perform database related activities. You can write a custom program consuming these web services to ease your configuration. This is much faster way of handling the agents in the database. Warning: You should not get carried away with this approach and communicate to the database directly bypassing the webservices or if there is no web service for a desired database operation. This might cause long term problem when the CCF team changes their database. In worst case, it might even void your support. Now that we know what we should and shouldn't do, let me show some sample code to do the same. Every installation of CCF 2008 (server) installs several web services and the one we are interested here is AgentWS. Since we know the web service now, it is a simple WCF webmethod invokation. Following code illustrates how to add user to the database. AgentWSClient agentService = new AgentWSClient("BasicHttpBinding_AgentWS"); try { AgentDetails agentDetail = new AgentDetails(); agentDetail.FirstName = "John"; agentDetail.LastName = "Smith"; agentDetail.DomainId = "contoso\\jsmith"; agentDetail.AgentType = 1; //1 - Agent, 2 - Admin agentService.Add(agentDetail); } finally { agentService.Close(); } As simple as this... You can probably write a small application that will fetch the user information from the Active Directory or any other list of users and add them all into the CCF database. |
|
|