1.What is the hierarchy of SP Object modal?
2.What is the difference between SP Site and SP Web?
3.What is the difference between Sp Site and SP Web?
4.There are 2 departments i.e Finance and HR. If you want to create a site for them what you would be prefer, either a Site or a web?
5.What are the methods/process to increase the performance of SP Object modal?
6.If want to insert 100 list items into a list, instead of calling list.update() for each list item , is there any other way is there?
7.How to create a site columns using STSADM command?
8.Apart from creating a Site column at designer level, any other way is there?
9.If you customize a page in Development environment, how you can carry those changes to Production environment?
10.What is the content type?
11.Can we have more than one content types associated with the document library?
12.What is the default content type?
13.What is meant by customization?
14.We can access the list either with the SP Object modal or Web services .which one is preferable and why?
15.Where and all places we can create a workflow?
16.If you want to create work flow application, will you choose SharePoint designer or Visual Studio, and why?
17.What are the factors you will consider while choosing a workflow?
18.Can I insert/update into SQL server from workflow at the end of the workflow?
19.I have a Save and Submit button. By clicking Save , I want to save the document into document library and by clicking Submit I want to activate the workflow.How can I achieve it?
20.Can I implement Statemachine workflow in Sequential workflow ?
21.What are custom Timer jobs?
22.What are steps to create a custom master page?
Saturday, April 24, 2010
Top 10 SharePoint Server 2010 features
Top 10 SharePoint Server 2010 features
Here are my personal favorite SharePoint 2010 new features and enhancements:
• Access Services & Visio Services
Building on the successful Excel Services pattern, SPS 2010 allows users to publish Access and Visio applications to SharePoint which other users can access through their browsers. As can be expected, Access and Visio Services will be somewhat limited in functionality(when compared to their respective desktop versions), but on the flip side, the customers would benefit from the server-side capabilities such as scalability, one centralized version of the document (rendered in a browser friendly format), access to multiple users and security control.
Access Services will allow customers to publish their Access 2010 applications to SharePoint. For example, consider a departmental application such as a travel planner built using Access. Using Access Services it will be possible to bring such an application to Sharepoint, thereby reducing the total cost of ownership through one common user experience, development and deployment strategy.
Similarly, Visio Services will allow customers to render Visio diagrams within the browser. An application of Visio Services would be a visualization of a SharePoint workflow that is rendered inside a browser as a Visio flowchart. Note that no client-side Visio software would be needed in this scenario.
• Business Connectivity Services (BCS)
In MOSS 2007, Business Data Connector (BDC) was the tool of choice for integrating external data sources into Sharepoint. BDC was available only to customers who purchased the enterprise version of MOSS 2007. Furthermore, BDC was limited to only reading data from the external data sources. Busincess Connectivity Services (BCS), which replaces the BDC functionality in SPS 2010, goes much further. Not only is BCS going to be available with the free, base version of SPS 2010 (renamed to Windows SharePoint Foundation from Windows SharePoint Services), it now supports updating, deletion and insertion of data into an external data source. Another key advantage of BCS is that it will enable SharePoint Lists to be created directly based on a database table.
• Developer Productivity Enhancements
First and foremost and unlike previous versions, it will now be possible to conduct SharePoint development on a client OS such as Windows 7. In earlier versions SharePoint development had to be undertaken on a server OS. This inevitably created overhead as the development had to be undertaken in a virtualized environment. Secondly, developer enhancements go beyond the support for client operating systems. Developers can now utilize familiar .NET patterns and practices such as LINQ (Language Integrated Query) to query data from a SharePoint List, XSLT for customizing a SharePoint list and Silverlight for creating richer visualizations. There are also a number of enhancements to the SharePoint programming model that offer greater flexibility in extending the out-of-the-box SharePoint behavior. For example, SharePoint developers commonly extend the SharePoint behavior using small segments of code commonly referred to as event handlers. A common issue with event handlers in MOSS 2007 is that the event handler is not finished executing before the control is returned back to the user. This can lead to a confusing behavior for the users. SPS 2010 seeks to alleviate this by introducing “After-Synchronous” events which are guaranteed to complete execution before the control is returned to the user.
Finally, Visual Studio 2010 contains extended capabilities for developers to create rich applications on the SPS 2010 platform. Many improvements have also been made in Visual Studio 2010 to increase developer productivity as well as take advantage of SPS 2010 functionality. These improvements help make it easier for .NET developers to create and deploy SharePoint solutions.
• SharePoint Designer Enhancements
SharePoint Designer is a tool targeted towards business users and designers who have used it to quickly and easily perform actions such as customizing lists, changing layouts and creating simple workflows. The one area of improvement often requested is the ability to package and reuse the changes made using SharePoint Designer. Fortunately, SharePoint Designer 2010 not only addresses this request, it also comes with major improvements with regard to designing workflows, editing SharePoint pages and setting up BCS ( discussed above). SharePoint administrators also have greater control over how SharePoint Designer 2010 is used within their environment. For instance, administrators can block the ability to perform certain actions such as modifying certain SharePoint pages and restricting access to certain areas with the Sharepoint setup.
One other key feature provided by SharePoint Designer 2010 is the improved interaction between the business users and the IT department. Since SharePoint Designer 2010 uses the same packing and deployment format (commonly referred to as WSP solution package) as the rest of the SharePoint platform, it is now possible to take the work done by a business user within the SharePoint Designer 2010 and import it within Visual Studio 2010. This will allow the IT department to build upon and extend the work done by the business users.
• Business Intelligence Enhancements
Business Intelligence is another area with significant improvements. To begin, there are a number of scalability improvements to the desktop version of Excel 2010, including the support for the numbers of rows within a workbook that goes far beyond the 64K limit in the current version. The new version of Excel effectively utilizes enhancements in the OS such as the 64-bit support for access to large memory pools and enhancement in hardware such as the multi-core computers.
Microsoft has made a strategic decision to leverage Excel as the primary BI analyst tool. As part of the self-service BI initiative, Excel users can import large amounts of data from various data sources and quickly generate pivot tables. Once the data is imported into Excel 2010, using a feature called “Slicers”, users will be able to easily filter the data. In other words, Excel users can extract, transform and load (ETL) data from multiple sources directly into Excel without requiring IT to build a formal data import setup. The pivot table generated from imported data can later be shared with other users by publishing it to SharePoint 2010. Under the covers, the publishing process creates an SQL Server Analysis Services instance that can be monitored by IT, using tools such as usage dashboard and resource quota.
Excel Services, the server-side Excel functionality provided by SharePoint Server, has seen a number of improvements as well. First off, it directly benefits from the scalability improvements to the underlying calculation engine mentioned earlier. Secondly, it enables additional programmability enhancements. For example it, using a JavScript based program, it will be possible
• In-Place Records Management
Records management relates to the process of marking a document as a record or “laminating” them for legal and compliance reasons. A records repository is a library of such records. SPS 2010 dramatically improves upon the capabilities for managing records by extending where and how the records are managed. Unlike MOSS 2007, SPS 2010 will support multiple records repositories within a single SharePoint installation.. This means that users can route records to multiple record repositories. Records managers can also define routing rules to aid in the classification of records. Records repositories now also support the use of hierarchical structures (commonly referred to as File Plan) for storing records in a manner that matches the customer’s organizational hierarchy.
SharePoint 2010 also provides the flexibility for defining and applying retention rules. For instance, it is now possible to apply a recurring retention rule that specifies several stages of record retention. This will be very helpful when a records manager wants to specify a retention rule such as “Maintain this document for three years after project completion then transfer it to the archive for the next five years”.
In addition to using a records repository, SPS 2010 has the ability to declare records in-place, i.e., allow any document inside a document library to be marked as a record without the need to explicitly move it to a records repository. The new in-place record management capability exemplifies Microsoft’s mantra of “compliance everywhere”
• Enhancements related to Large List Handling
Microsoft has placed a lot of emphasis on performance of lists with large numbers of items in them. This has resulted in the addition of the new SPS 2010 features known as : Query Throttling, Batch Query Support, Remote Blob Storage, and External Lists.
Query Throttling allows IT administrators to limit -or “throttle” – queries that are executed against large lists from consuming too many resources. For example, SharePoint will now block queries that will return more than 5000 rows by default – and this is of course, a configurable setting. Rather than iterating over each item, SharePoint also includes the capability to process multiple items in a list simultaneously, as a single batch operation. If there is content that is more suitable for storage outside SharePoint (for instance large media files), the Remote Blob Storage feature will provide a mechanism to store it on file shares (SANS, NAS, RAID arrays, File Servers).
Finally, External Lists is another mechanism by which large lists can be incorporated in SharePoint. As stated earlier, database-backed lists that are a part of BCS allow content to be stored in separate data stores – such as SQL Server – outside of the Content Database. The benefit of course is that this feature allows for providing supporting large lists without burdening the SharePoint 2010 content database.
• Workflow Improvements
Workflow is a very useful feature of SharePoint 2007. In addition to the out-of-the box workflows that were included with SharePoint 2007, it is possible to use the SharePoint designer to build declarative (no-code) workflows. For more advanced scenarios, developers created custom workflows in Visual Studio. Two of the main challenges in building workflows with SharePoint 2007 relate to the limitations in SharePoint Designer 2007 and the workflow host that is part of SharePoint 2007. While SharePoint Designer allows business users to develop simple workflows, it requires a direct connection to the site for which the workflow is being developed, thus limiting the ability to reuse the workflow in different locations. Furthermore, there is no easy way to leverage code components developed by IT. The workflow host within SharePoint 2007 comes pre-configured with a set of services such as persistence, eventing and tracing. There is no way to add custom services to the runtime host. For instance, there is no direct way to allow SharePoint-based workflows to interact with events other than the list item events.
SharePoint 2010 alleviates these challenges by allowing the workflows created using SharePoint Designer to be saved as templates for reuse. SharePoint Designer 2010 has also been enhanced significantly to allow business users to leverage tools such as Visio for workflow modeling and visualization. Another major improvement is the ability to modify out-of-the-box SharePoint workflows (e.g. approval workflow, three-state workflow).
The workflow host within SharePoint 2010 now provides the extensibility option to inject custom services. It is also now possible to kickoff workflows without explicitly associating it to a list item.
Finally, and from an overall scalability perspective, it is also going to be possible to designate application server nodes as workflow participants. In other words, unlike SharePoint 2007 where each application server node participated in executing the workflows, there will be a way to throttle the workflow execution to a limited set of machines. This allows isolation of services within the farm so system administrators can better manage resources and troubleshoot issues.
• Social Networking Capabilities
One can debate the impact and applicability of social networking tools such as Facebook in the workplace, but there is no doubt that information workers today are demanding similar capabilities from the tools they use inside the workplace. This is why the SPS 2010 enhancements in this arena are so noteworthy. In SPS 2010, just about every element such as sites, documents, videos, blog posts are taggable. There is out-of-the-box support for navigating the tag clouds and lists. Users will be able to rate artifacts and recommend it to others. Co-workers can keep up with the latest by tracking the activity data available as a new feed. Individual users will be able to setup profiles, write to a common or personal board, indicate their presence/location and be able to take advantage of micro-blogging capabilities.
• Deployment Advancements
Unlike the previous versions, SPS 2010 uses a solution package-based single, consistent scheme for packaging and deploying any customizations. The solution package is a compressed file containing all of the necessary components such as features, web parts, list definitions, assemblies, customized ASPX pages and workflows. Additionally, the previous versions required an extensive amount of manual modification of XML files. In SharePoint 2010, these modifications can be done through point and click configuration with SharePoint Designer 2010.
SharePoint 2010 also introduces a notion of sandbox solution packages that are designed to improve security and manageability. Sandbox solution packages restrict the scope to which a customization can be applied (For example, restricting the scope for a list customization to site collection). Sandbox solutions are also restricted to a subset of SharePoint programmability options. Finally, administrators can enforce quote limits on resources consumed by sandbox solutions to prevent abuse.
For a more detail review of the SPS 2010, I encourage you to download the white paper we released recently at http://tinyurl.com/sps2010 ( note – this link takes you directly to the PDF ~1 MB)
Here are my personal favorite SharePoint 2010 new features and enhancements:
• Access Services & Visio Services
Building on the successful Excel Services pattern, SPS 2010 allows users to publish Access and Visio applications to SharePoint which other users can access through their browsers. As can be expected, Access and Visio Services will be somewhat limited in functionality(when compared to their respective desktop versions), but on the flip side, the customers would benefit from the server-side capabilities such as scalability, one centralized version of the document (rendered in a browser friendly format), access to multiple users and security control.
Access Services will allow customers to publish their Access 2010 applications to SharePoint. For example, consider a departmental application such as a travel planner built using Access. Using Access Services it will be possible to bring such an application to Sharepoint, thereby reducing the total cost of ownership through one common user experience, development and deployment strategy.
Similarly, Visio Services will allow customers to render Visio diagrams within the browser. An application of Visio Services would be a visualization of a SharePoint workflow that is rendered inside a browser as a Visio flowchart. Note that no client-side Visio software would be needed in this scenario.
• Business Connectivity Services (BCS)
In MOSS 2007, Business Data Connector (BDC) was the tool of choice for integrating external data sources into Sharepoint. BDC was available only to customers who purchased the enterprise version of MOSS 2007. Furthermore, BDC was limited to only reading data from the external data sources. Busincess Connectivity Services (BCS), which replaces the BDC functionality in SPS 2010, goes much further. Not only is BCS going to be available with the free, base version of SPS 2010 (renamed to Windows SharePoint Foundation from Windows SharePoint Services), it now supports updating, deletion and insertion of data into an external data source. Another key advantage of BCS is that it will enable SharePoint Lists to be created directly based on a database table.
• Developer Productivity Enhancements
First and foremost and unlike previous versions, it will now be possible to conduct SharePoint development on a client OS such as Windows 7. In earlier versions SharePoint development had to be undertaken on a server OS. This inevitably created overhead as the development had to be undertaken in a virtualized environment. Secondly, developer enhancements go beyond the support for client operating systems. Developers can now utilize familiar .NET patterns and practices such as LINQ (Language Integrated Query) to query data from a SharePoint List, XSLT for customizing a SharePoint list and Silverlight for creating richer visualizations. There are also a number of enhancements to the SharePoint programming model that offer greater flexibility in extending the out-of-the-box SharePoint behavior. For example, SharePoint developers commonly extend the SharePoint behavior using small segments of code commonly referred to as event handlers. A common issue with event handlers in MOSS 2007 is that the event handler is not finished executing before the control is returned back to the user. This can lead to a confusing behavior for the users. SPS 2010 seeks to alleviate this by introducing “After-Synchronous” events which are guaranteed to complete execution before the control is returned to the user.
Finally, Visual Studio 2010 contains extended capabilities for developers to create rich applications on the SPS 2010 platform. Many improvements have also been made in Visual Studio 2010 to increase developer productivity as well as take advantage of SPS 2010 functionality. These improvements help make it easier for .NET developers to create and deploy SharePoint solutions.
• SharePoint Designer Enhancements
SharePoint Designer is a tool targeted towards business users and designers who have used it to quickly and easily perform actions such as customizing lists, changing layouts and creating simple workflows. The one area of improvement often requested is the ability to package and reuse the changes made using SharePoint Designer. Fortunately, SharePoint Designer 2010 not only addresses this request, it also comes with major improvements with regard to designing workflows, editing SharePoint pages and setting up BCS ( discussed above). SharePoint administrators also have greater control over how SharePoint Designer 2010 is used within their environment. For instance, administrators can block the ability to perform certain actions such as modifying certain SharePoint pages and restricting access to certain areas with the Sharepoint setup.
One other key feature provided by SharePoint Designer 2010 is the improved interaction between the business users and the IT department. Since SharePoint Designer 2010 uses the same packing and deployment format (commonly referred to as WSP solution package) as the rest of the SharePoint platform, it is now possible to take the work done by a business user within the SharePoint Designer 2010 and import it within Visual Studio 2010. This will allow the IT department to build upon and extend the work done by the business users.
• Business Intelligence Enhancements
Business Intelligence is another area with significant improvements. To begin, there are a number of scalability improvements to the desktop version of Excel 2010, including the support for the numbers of rows within a workbook that goes far beyond the 64K limit in the current version. The new version of Excel effectively utilizes enhancements in the OS such as the 64-bit support for access to large memory pools and enhancement in hardware such as the multi-core computers.
Microsoft has made a strategic decision to leverage Excel as the primary BI analyst tool. As part of the self-service BI initiative, Excel users can import large amounts of data from various data sources and quickly generate pivot tables. Once the data is imported into Excel 2010, using a feature called “Slicers”, users will be able to easily filter the data. In other words, Excel users can extract, transform and load (ETL) data from multiple sources directly into Excel without requiring IT to build a formal data import setup. The pivot table generated from imported data can later be shared with other users by publishing it to SharePoint 2010. Under the covers, the publishing process creates an SQL Server Analysis Services instance that can be monitored by IT, using tools such as usage dashboard and resource quota.
Excel Services, the server-side Excel functionality provided by SharePoint Server, has seen a number of improvements as well. First off, it directly benefits from the scalability improvements to the underlying calculation engine mentioned earlier. Secondly, it enables additional programmability enhancements. For example it, using a JavScript based program, it will be possible
• In-Place Records Management
Records management relates to the process of marking a document as a record or “laminating” them for legal and compliance reasons. A records repository is a library of such records. SPS 2010 dramatically improves upon the capabilities for managing records by extending where and how the records are managed. Unlike MOSS 2007, SPS 2010 will support multiple records repositories within a single SharePoint installation.. This means that users can route records to multiple record repositories. Records managers can also define routing rules to aid in the classification of records. Records repositories now also support the use of hierarchical structures (commonly referred to as File Plan) for storing records in a manner that matches the customer’s organizational hierarchy.
SharePoint 2010 also provides the flexibility for defining and applying retention rules. For instance, it is now possible to apply a recurring retention rule that specifies several stages of record retention. This will be very helpful when a records manager wants to specify a retention rule such as “Maintain this document for three years after project completion then transfer it to the archive for the next five years”.
In addition to using a records repository, SPS 2010 has the ability to declare records in-place, i.e., allow any document inside a document library to be marked as a record without the need to explicitly move it to a records repository. The new in-place record management capability exemplifies Microsoft’s mantra of “compliance everywhere”
• Enhancements related to Large List Handling
Microsoft has placed a lot of emphasis on performance of lists with large numbers of items in them. This has resulted in the addition of the new SPS 2010 features known as : Query Throttling, Batch Query Support, Remote Blob Storage, and External Lists.
Query Throttling allows IT administrators to limit -or “throttle” – queries that are executed against large lists from consuming too many resources. For example, SharePoint will now block queries that will return more than 5000 rows by default – and this is of course, a configurable setting. Rather than iterating over each item, SharePoint also includes the capability to process multiple items in a list simultaneously, as a single batch operation. If there is content that is more suitable for storage outside SharePoint (for instance large media files), the Remote Blob Storage feature will provide a mechanism to store it on file shares (SANS, NAS, RAID arrays, File Servers).
Finally, External Lists is another mechanism by which large lists can be incorporated in SharePoint. As stated earlier, database-backed lists that are a part of BCS allow content to be stored in separate data stores – such as SQL Server – outside of the Content Database. The benefit of course is that this feature allows for providing supporting large lists without burdening the SharePoint 2010 content database.
• Workflow Improvements
Workflow is a very useful feature of SharePoint 2007. In addition to the out-of-the box workflows that were included with SharePoint 2007, it is possible to use the SharePoint designer to build declarative (no-code) workflows. For more advanced scenarios, developers created custom workflows in Visual Studio. Two of the main challenges in building workflows with SharePoint 2007 relate to the limitations in SharePoint Designer 2007 and the workflow host that is part of SharePoint 2007. While SharePoint Designer allows business users to develop simple workflows, it requires a direct connection to the site for which the workflow is being developed, thus limiting the ability to reuse the workflow in different locations. Furthermore, there is no easy way to leverage code components developed by IT. The workflow host within SharePoint 2007 comes pre-configured with a set of services such as persistence, eventing and tracing. There is no way to add custom services to the runtime host. For instance, there is no direct way to allow SharePoint-based workflows to interact with events other than the list item events.
SharePoint 2010 alleviates these challenges by allowing the workflows created using SharePoint Designer to be saved as templates for reuse. SharePoint Designer 2010 has also been enhanced significantly to allow business users to leverage tools such as Visio for workflow modeling and visualization. Another major improvement is the ability to modify out-of-the-box SharePoint workflows (e.g. approval workflow, three-state workflow).
The workflow host within SharePoint 2010 now provides the extensibility option to inject custom services. It is also now possible to kickoff workflows without explicitly associating it to a list item.
Finally, and from an overall scalability perspective, it is also going to be possible to designate application server nodes as workflow participants. In other words, unlike SharePoint 2007 where each application server node participated in executing the workflows, there will be a way to throttle the workflow execution to a limited set of machines. This allows isolation of services within the farm so system administrators can better manage resources and troubleshoot issues.
• Social Networking Capabilities
One can debate the impact and applicability of social networking tools such as Facebook in the workplace, but there is no doubt that information workers today are demanding similar capabilities from the tools they use inside the workplace. This is why the SPS 2010 enhancements in this arena are so noteworthy. In SPS 2010, just about every element such as sites, documents, videos, blog posts are taggable. There is out-of-the-box support for navigating the tag clouds and lists. Users will be able to rate artifacts and recommend it to others. Co-workers can keep up with the latest by tracking the activity data available as a new feed. Individual users will be able to setup profiles, write to a common or personal board, indicate their presence/location and be able to take advantage of micro-blogging capabilities.
• Deployment Advancements
Unlike the previous versions, SPS 2010 uses a solution package-based single, consistent scheme for packaging and deploying any customizations. The solution package is a compressed file containing all of the necessary components such as features, web parts, list definitions, assemblies, customized ASPX pages and workflows. Additionally, the previous versions required an extensive amount of manual modification of XML files. In SharePoint 2010, these modifications can be done through point and click configuration with SharePoint Designer 2010.
SharePoint 2010 also introduces a notion of sandbox solution packages that are designed to improve security and manageability. Sandbox solution packages restrict the scope to which a customization can be applied (For example, restricting the scope for a list customization to site collection). Sandbox solutions are also restricted to a subset of SharePoint programmability options. Finally, administrators can enforce quote limits on resources consumed by sandbox solutions to prevent abuse.
For a more detail review of the SPS 2010, I encourage you to download the white paper we released recently at http://tinyurl.com/sps2010 ( note – this link takes you directly to the PDF ~1 MB)
Sunday, January 24, 2010
Statemachine Workflow
https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=16
Feature.xml
Title="WSS StateMachine Workflow"
Description="This feature is a StateMachine workflow ..."
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
__________________________________________________________________
Workflow.xml
Name="Claims DMS StateMachine Workflow"
Description="This StateMachine workflow rocks..."
Id="8173FAC7-690E-4d1e-8CFC-DF6B492A7E8C"
CodeBesideClass="StateMachineDemo.DemoWorkflow"
CodeBesideAssembly="StateMachineDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca4da04b1f46772a"
>
_____________________________________________________________________
StatemachineWorkflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
using System.Web.UI;
using System.Web;
namespace StateMachineDemo
{
#region DemoWorkflow
public sealed partial class DemoWorkflow : StateMachineWorkflowActivity
{
public DemoWorkflow()
{
InitializeComponent();
}
#region Declaration
public string _approver;
private bool _approved = false;
private bool _approvedFinal = false;
public string LastComments;
string taskStatus = string.Empty;
string workflowCurrentStatus = string.Empty;
string taskTitle = string.Empty;
string strHistoryURL = string.Empty;
string taskhiddenStatus = string.Empty;
List workflowTaskItems = new List();
Hashtable htTaskItems = new Hashtable();
DateTime dt = DateTime.Now;
string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy");
public int DocitemId;
public int taskitemId;
public string taskPreviousState = string.Empty;
public string taskPreviousComments = string.Empty;
public string taskPreComments = string.Empty;
public String WorkFlowActivated_logToHistoryListActivity_HistoryDescription1 = default(System.String);
public Guid CreateTask_ReviewTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_ReviewTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnReviewTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnReviewTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnReviewTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid CompleteReviewTask_TaskId1 = default(System.Guid);
public Guid CreateTask_CustReviewTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_CustReviewTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnCustReviewTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnCustReviewTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnCustReviewTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid CompleteCustReviewTask_TaskId1 = default(System.Guid);
public Guid CreateTask_InProgressTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_InProgressTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnInProgressTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnInProgressTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnInProgressTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public String OnReviewTaskChanged_Executor1 = default(System.String);
public Int32 logToHistoryListActivity3_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity4_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity5_UserId2 = default(System.Int32);
public Int32 logToHistoryListActivity1_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity2_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity7_UserId1 = default(System.Int32);
public String OnCustReviewTaskChanged_Executor1 = default(System.String);
public Int32 logToHistoryListActivity9_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity10_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity11_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity6_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity8_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity12_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity14_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity15_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity13_UserId1 = default(System.Int32);
public String OnInProgressTaskChanged_Executor1 = default(System.String);
public Int32 WorkFlowActivated_logToHistoryListActivity_UserId1 = default(System.Int32);
public Guid completeTask1_TaskId1 = default(System.Guid);
private const int TaskType_InProgress = 0;
private const int TaskType_Review = 1;
private const int TaskType_Customer = 2;
public SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
#endregion
#region OnWorkflowActivated_Invoked
///
/// On Work Flow Activated Task will be created to GOSSPL Technical Team
///
///
///
private void OnWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
_approver = @"GOSSPL Technician Team";
workflowCurrentStatus = "In Progress";
taskPreviousState = "";
LastComments = "Claims Work Flow has Initiated by Claims Team!";
SPWeb thisWeb = new SPSite(workflowProperties.SiteId).OpenWeb(workflowProperties.WebId);
SPListItem thisDocitemId = thisWeb.Lists[workflowProperties.ListId].GetItemById(workflowProperties.ItemId);
DocitemId = thisDocitemId.ID;
//taskitemId = 0;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnWorkflowActivated_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To GOSSPL Technical Team
private void CreateTask_ReviewTask_Invoked(object sender, EventArgs e)
{
string strTemp = string.Empty;
try
{
CreateTask_ReviewTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "In Progress")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("R", "In Progress");
}
else if (taskPreviousState == "Rejected")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("A", "Rejected");
}
else if (taskPreviousState == "Quality Check")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("R", "In Progress");
}
else
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("A", "In Progress");
}
if (htTaskItems.Count != 0)
{
CopyTaskProperties(CreateTask_ReviewTask_TaskProperties1);
}
CreateTask_ReviewTask_TaskProperties1.AssignedTo = @"GOSSPL Technician Team";
//************************************
//CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Task Groups"] = @"GOSSPL Technician Team";
//SPGroup group = SPWeb.UserGroups[];
//SPGroup group = SPWeb.
//SPFieldUserValue groupvalue = new SPFIeldUserValue(group.ParentWeb, group.ID, group.Name);
//SPWorkflowTaskProperties taskProperties = new SPWorkflowTaskProperties();
//taskProperties.AssignedTo = groupvalue.LookupValue;
SPSite siteCollection = new SPSite("http://igtewfl2018/claims");
SPWeb rootWeb = siteCollection.OpenWeb();
SPGroup spGroup = rootWeb.Groups["GOSSPL Technician Team"];
SPFieldUserValue groupvalue = new SPFieldUserValue(spGroup.ParentWeb, spGroup.ID, spGroup.Name);
//SPFieldUserValue groupvalue = new SPFIeldUserValue(spGroup.ParentWeb, spGroup.ID, spGroup.Name);
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Task Groups"] = groupvalue.LookupValue; ;
//********************************************
CreateTask_ReviewTask_TaskProperties1.Description = LastComments;
CreateTask_ReviewTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_ReviewTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
SetProperties(workflowProperties, CreateTask_ReviewTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_ReviewTask_Invoked Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GOSSPL Technical Team Task Change
private void OnReviewTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnReviewTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnReviewTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnReviewTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved")
{
_approved = false;
workflowProperties.Item["Processing Status"] = "Quality Check";
workflowProperties.Item.Update();
workflowCurrentStatus = "Quality Check";
taskPreviousState = "In Progress";
}
else if (taskStatus == "Rejected")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Rejected";
workflowProperties.Item.Update();
workflowCurrentStatus = "Rejected";
taskPreviousState = "In Progress";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnReviewTaskChanged_Invoked Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To GOSSPL Quality Check Team
private void CreateTask_CustReviewTask_MethodInvoking(object sender, EventArgs e)
{
try
{
CreateTask_CustReviewTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "In Progress")
{
CreateTask_CustReviewTask_TaskProperties1.Title = TaskTitle("A", "Quality Check");
}
else
{
CreateTask_CustReviewTask_TaskProperties1.Title = TaskTitle("R", "Quality Check");
}
CopyTaskProperties(CreateTask_CustReviewTask_TaskProperties1);
CreateTask_CustReviewTask_TaskProperties1.AssignedTo = @"GOSSPL Quality Check Team";
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
CreateTask_CustReviewTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_CustReviewTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_CustReviewTask_TaskProperties1.TaskType = TaskType_Customer;
SetProperties(workflowProperties, CreateTask_CustReviewTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_CustReviewTask_MethodInvoking Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GOSSPL Quality Check Team Task Change
private void OnCustReviewTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnCustReviewTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnCustReviewTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnCustReviewTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Completed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Completed";
taskPreviousState = "Quality Check";
}
else if (taskStatus == "Rejected")
{
_approved = false;
workflowProperties.Item["Processing Status"] = "In Progress";
workflowProperties.Item.Update();
workflowCurrentStatus = "In Progress";
taskPreviousState = "Quality Check";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnCustReviewTaskChanged_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To Claims Team
private void CreateTask_InProgressTask_MethodInvoking(object sender, EventArgs e)
{
try
{
CreateTask_InProgressTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "Quality Check")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("A", "Completed");
}
if (taskPreviousState == "In Progress")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("R", "Rejected");
}
if (taskPreviousState == "Completed")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("A", "Closed");
}
CopyTaskProperties(CreateTask_InProgressTask_TaskProperties1);
CreateTask_InProgressTask_TaskProperties1.AssignedTo = workflowProperties.OriginatorUser.LoginName.ToString();
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
CreateTask_InProgressTask_TaskProperties1.Description = LastComments;
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_InProgressTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl; // TaskItemId not fecthing
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_InProgressTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_InProgressTask_TaskProperties1.TaskType = TaskType_Review;
SetProperties(workflowProperties, CreateTask_InProgressTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_InProgressTask_MethodInvoking Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Claims Team Task Change
private void OnInProgressTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskhiddenStatus = string.Empty;
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnInProgressTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnInProgressTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnInProgressTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved" & workflowCurrentStatus == "Completed")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Closed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Closed";
taskPreviousState = "Completed";
_approvedFinal = true;
}
else if (taskStatus == "Rejected" & workflowCurrentStatus == "Completed")
{
_approved = false;
_approvedFinal = true;
workflowProperties.Item["Processing Status"] = "Quality Check";
workflowProperties.Item.Update();
workflowCurrentStatus = "Quality Check";
taskPreviousState = "Completed";
}
if (taskStatus == "Approved" & workflowCurrentStatus == "Rejected")
{
_approved = true;
_approvedFinal = false;
workflowProperties.Item["Processing Status"] = "In Progress";
workflowProperties.Item.Update();
workflowCurrentStatus = "In Progress";
taskPreviousState = "Rejected";
}
if (taskStatus == "Rejected" & workflowCurrentStatus == "Rejected")
{
_approved = false;
_approvedFinal = false;
workflowProperties.Item["Processing Status"] = "Closed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Closed";
taskPreviousState = "Rejected";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnInProgressTaskChanged_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region SetProperties
public void SetProperties(SPWorkflowActivationProperties wfProperties, SPWorkflowTaskProperties taskProperties)
{
try
{
string strTemp = string.Empty;
if (wfProperties.Item["UCR Number"] != null)
{
taskProperties.ExtendedProperties["UCR Number"] = wfProperties.Item["UCR Number"].ToString();
}
if (wfProperties.Item["Risk Number"] != null)
{
taskProperties.ExtendedProperties["Risk Number"] = wfProperties.Item["Risk Number"].ToString();
}
if (wfProperties.Item["Urgent"] != null)
{
if (wfProperties.Item["Urgent"].ToString().ToUpper() == "TRUE")
{
taskProperties.ExtendedProperties["Priority"] = "High";
}
}
if (wfProperties.Item["Standard Narrative"] != null)
{
strTemp = wfProperties.Item["Standard Narrative"].ToString();
if (strTemp == "First Advice - Regular" || strTemp == "First Advice and authority to appoint expert" || strTemp == "First Advice, expert appointed, await report")
{
taskProperties.ExtendedProperties["First Advice"] = "True";
}
if (strTemp == "First Advice - Regular" || strTemp == "First Advice and authority to appoint expert" || strTemp == "First Advice, expert appointed, await report" || strTemp == "Interim Settlement" || strTemp == "Final Settlement and Closure")
{
taskProperties.ExtendedProperties["Further Advice"] = "True";
}
if (strTemp == "Interim Settlement" || strTemp == "Final Settlement and Closure")
{
taskProperties.ExtendedProperties["Settlement"] = "True";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow SetProperties Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserObject
private SPUser GetUserObject(string accountID)
{
try
{
if (accountID.IndexOf(@"\") > 0)
{
SPUser user = this.workflowProperties.Web.SiteUsers[accountID];
return user;
}
else
{
//replace DOMAIN
SPUser user = this.workflowProperties.Web.SiteUsers[@"DOMAIN\" + accountID];
return user;
}
}
catch
{
//replace DOMAIN and administrator
SPUser adminUser = this.workflowProperties.Web.SiteUsers[@"DOMAIN\administrator"];
return adminUser;
}
}
#endregion
#region UpdateTaskProperties
public void UpdateTaskProperties(SPWorkflowActivationProperties wfProperties, SPWorkflowTaskProperties taskProperties)
{
try
{
htTaskItems.Add("UK Rejection Reason", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["UK Rejection Reason"].Id]);
htTaskItems.Add(" Date Post Received", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields[" Date Post Received"].Id]);
htTaskItems.Add("Business Unit", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Business Unit"].Id]);
//htTaskItems.Add("ECF", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["ECF"].Id]);
htTaskItems.Add("File Track Number", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["File Track Number"].Id]);
htTaskItems.Add("Insured/Reinsured/Coverholder", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Insured/Reinsured/Coverholder"].Id]);
//GOSSPL rejection reason
htTaskItems.Add("GOSSPL Rejection Reason", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["GOSSPL Rejection Reason"].Id]);
htTaskItems.Add("UK Technician", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["UK Technician"].Id]);
htTaskItems.Add("Settlement", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Settlement"].Id]);
htTaskItems.Add("Start Date", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Start Date"].Id]);
//htTaskItems.Add("Due Date", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Due Date"].Id]);
//htTaskItems.Add("% Complete", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["% Complete"].Id]);
htTaskItems.Add("Further Advice", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Further Advice"].Id]);
htTaskItems.Add("First Advice", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["First Advice"].Id]);
//htTaskItems.Add("Priority", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Priority"].Id]);
if (taskPreviousComments.Replace("
{
taskPreComments = taskProperties.AssignedTo.ToString() + " " + DateTime.Now.ToString("dd/MM/yyyy") + " " + DateTime.Now.ToShortTimeString().ToString() + " : " + taskPreviousComments + "\n" + taskPreComments;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow UpdateTaskProperties Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region CopyTaskProperties
public void CopyTaskProperties(SPWorkflowTaskProperties taskProperties)
{
try
{
taskProperties.ExtendedProperties["UK Rejection Reason"] = htTaskItems["UK Rejection Reason"];
taskProperties.ExtendedProperties[" Date Post Received"] = htTaskItems[" Date Post Received"];
taskProperties.ExtendedProperties["Business Unit"] = htTaskItems["Business Unit"];
//taskProperties.ExtendedProperties["ECF"] = htTaskItems["ECF"];
taskProperties.ExtendedProperties["File Track Number"] = htTaskItems["File Track Number"];
taskProperties.ExtendedProperties["Insured/Reinsured/Coverholder"] = htTaskItems["Insured/Reinsured/Coverholder"];
taskProperties.ExtendedProperties["GOSSPL Rejection Reason"] = htTaskItems["GOSSPL Rejection Reason"];
taskProperties.ExtendedProperties["UK Technician"] = htTaskItems["UK Technician"];
//taskProperties.ExtendedProperties["Rejection Reason"] = htTaskItems["Rejection Reason"];
taskProperties.ExtendedProperties["Settlement"] = htTaskItems["Settlement"];
taskProperties.ExtendedProperties["Start Date"] = htTaskItems["Start Date"];
//taskProperties.ExtendedProperties["Due Date"] = htTaskItems["Due Date"];
//taskProperties.ExtendedProperties["% Complete"] = htTaskItems["% Complete"];
taskProperties.ExtendedProperties["Further Advice"] = htTaskItems["Further Advice"];
taskProperties.ExtendedProperties["First Advice"] = htTaskItems["First Advice"];
//taskProperties.ExtendedProperties["Priority"] = htTaskItems["Priority"];
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CopyTaskProperties Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region ProposalApproved
private void ProposalApproved(object sender, ConditionalEventArgs e)
{
try
{
if (taskStatus != string.Empty && taskStatus != "" && taskStatus != null)
{
e.Result = _approved;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow ProposalApproved Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region CompleteTask
private void CompleteTask(object sender, EventArgs e)
{
_approved = false;
}
#endregion
#region HandleException
public void HandleException(string strTrace, string strMessage, string strLocation)
{
try
{
SPWeb MyWeb = workflowProperties.Web;
MyWeb.AllowUnsafeUpdates = true;
SPList listException = MyWeb.Lists["N__CL_Exception"];
SPListItemCollection itemColException = listException.Items;
SPListItem itemException = itemColException.Add();
itemException["Title"] = strMessage;
itemException["Location"] = strLocation;
itemException["Description"] = strTrace;
itemException.Update();
}
catch (Exception)
{
}
}
#endregion
#region MyException
public class MyException : Exception
{
public MyException()
{
Console.WriteLine("User Defined Exception");
}
}
#endregion
#region Task Updates
public string TaskTitle(string taskType, string taskStatus)
{
string taskTitleDescription = string.Empty;
if (taskType == "A") // Title New or Approved case
{
switch (taskStatus)
{
case "In Progress":
taskTitleDescription = "A new claims is Initatied:" + workflowProperties.Item.File.Name.ToString();
break;
case "Rejected":
taskTitleDescription = "Claims is sent for Technician:" + workflowProperties.Item.File.Name.ToString();
break;
case "Quality Check":
taskTitleDescription = "Claims is sent for Quality Check:" + workflowProperties.Item.File.Name.ToString();
break;
case "Completed":
//taskTitleDescription = "Claims is sent for Completed:" + workflowProperties.Item.File.Name.ToString();
taskTitleDescription = "Task Ready for Closing assigned to you:" + workflowProperties.Item.File.Name.ToString();
break;
case "Closed":
taskTitleDescription = "Claims is Closed:" + workflowProperties.Item.File.Name.ToString();
break;
}
}
if (taskType == "R") // Title Old or Rejected case
{
switch (taskStatus)
{
case "In Progress":
//taskTitleDescription = "Claims Rejected by Technical Team!:" + workflowProperties.Item.File.Name.ToString();
taskTitleDescription = "Rejected Task assigned to you by Quality check Team!:" + workflowProperties.Item.File.Name.ToString();
break;
case "Quality Check":
taskTitleDescription = "Rejected Task assigned to you by Claims Team!:" + workflowProperties.Item.File.Name.ToString();
break;
case "Rejected":
taskTitleDescription = "Rejected Task assigned to you by Technician Team!:" + workflowProperties.Item.File.Name.ToString();
break;
}
}
return taskTitleDescription;
}
#endregion
#region Claims Approval Condition
private void Proposal2(object sender, ConditionalEventArgs e)
{
try
{
e.Result = _approvedFinal;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow ProposalApproved Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginator
private void GetOriginator(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(workflowProperties.Originator);
WorkFlowActivated_logToHistoryListActivity_UserId1 = executor.ID;
logToHistoryListActivity14_UserId1 = executor.ID;
logToHistoryListActivity15_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginator Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForTechTeam
private void GetOriginatorForTechTeam(object sender, EventArgs e)
{
try
{
if ((taskStatus == "Approved") || (taskStatus == string.Empty))
{
SPUser executor = GetUserObject(workflowProperties.Originator);
logToHistoryListActivity1_UserId1 = executor.ID;
logToHistoryListActivity2_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity1_UserId1 = executor.ID;
logToHistoryListActivity2_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForTechTeam Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIDForTechChange
private void GetUserIDForTechChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity3_UserId1 = executor.ID;
logToHistoryListActivity4_UserId1 = executor.ID;
logToHistoryListActivity5_UserId2 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetUserID Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForQualityTeam
private void GetOriginatorForQualityTeam(object sender, EventArgs e)
{
try
{
if (taskStatus == "Approved")
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity7_UserId1 = executor.ID;
logToHistoryListActivity12_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnInProgressTaskChanged_Executor1);
logToHistoryListActivity7_UserId1 = executor.ID;
logToHistoryListActivity12_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForQualityTeam Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIdForQualityChange
private void GetUserIdForQualityChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity9_UserId1 = executor.ID;
logToHistoryListActivity10_UserId1 = executor.ID;
logToHistoryListActivity11_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForQualityTeam Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForClaims
private void GetOriginatorForClaims(object sender, EventArgs e)
{
try
{
if (taskStatus == "Approved")
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity6_UserId1 = executor.ID;
logToHistoryListActivity8_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity6_UserId1 = executor.ID;
logToHistoryListActivity8_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForClaims Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIdForClaimsChange
private void GetUserIdForClaimsChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnInProgressTaskChanged_Executor1);
logToHistoryListActivity13_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForClaims Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
}
#endregion
}
______________________________________________________________________________
Install.bat
:: Before running this file, sign the assembly in Project properties
::
:: To customize this file, find and replace
:: a) "StateMachineDemo" with your own feature names
:: b) "feature.xml" with the name of your feature.xml file
:: c) "workflow.xml" with the name of your workflow.xml file
:: d) "http://localhost" with the name of the site you wish to publish to
echo Copying the feature...
rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo"
copy /Y feature.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo\"
copy /Y workflow.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo\"
xcopy /s /Y *.aspx "%programfiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS"
echo Adding assemblies to the GAC...
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -uf StateMachineDemo
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if bin\Debug\StateMachineDemo.dll
echo Activating the feature...
pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin
::Note: Uncomment these lines if you've modified your deployment xml files or IP forms
stsadm -o deactivatefeature -filename StateMachineDemo\feature.xml -url http://igtewfl2018
stsadm -o uninstallfeature -filename StateMachineDemo\feature.xml
stsadm -o installfeature -filename StateMachineDemo\feature.xml -force
stsadm -o activatefeature -filename StateMachineDemo\feature.xml -url http://igtewfl2018
echo Doing an iisreset...
popd
iisreset
Feature.xml
Description="This feature is a StateMachine workflow ..."
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
__________________________________________________________________
Workflow.xml
Description="This StateMachine workflow rocks..."
Id="8173FAC7-690E-4d1e-8CFC-DF6B492A7E8C"
CodeBesideClass="StateMachineDemo.DemoWorkflow"
CodeBesideAssembly="StateMachineDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca4da04b1f46772a"
>
_____________________________________________________________________
StatemachineWorkflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
using System.Web.UI;
using System.Web;
namespace StateMachineDemo
{
#region DemoWorkflow
public sealed partial class DemoWorkflow : StateMachineWorkflowActivity
{
public DemoWorkflow()
{
InitializeComponent();
}
#region Declaration
public string _approver;
private bool _approved = false;
private bool _approvedFinal = false;
public string LastComments;
string taskStatus = string.Empty;
string workflowCurrentStatus = string.Empty;
string taskTitle = string.Empty;
string strHistoryURL = string.Empty;
string taskhiddenStatus = string.Empty;
List
Hashtable htTaskItems = new Hashtable();
DateTime dt = DateTime.Now;
string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy");
public int DocitemId;
public int taskitemId;
public string taskPreviousState = string.Empty;
public string taskPreviousComments = string.Empty;
public string taskPreComments = string.Empty;
public String WorkFlowActivated_logToHistoryListActivity_HistoryDescription1 = default(System.String);
public Guid CreateTask_ReviewTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_ReviewTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnReviewTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnReviewTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnReviewTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid CompleteReviewTask_TaskId1 = default(System.Guid);
public Guid CreateTask_CustReviewTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_CustReviewTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnCustReviewTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnCustReviewTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnCustReviewTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid CompleteCustReviewTask_TaskId1 = default(System.Guid);
public Guid CreateTask_InProgressTask_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties CreateTask_InProgressTask_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public Guid OnInProgressTaskChanged_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties OnInProgressTaskChanged_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties OnInProgressTaskChanged_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public String OnReviewTaskChanged_Executor1 = default(System.String);
public Int32 logToHistoryListActivity3_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity4_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity5_UserId2 = default(System.Int32);
public Int32 logToHistoryListActivity1_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity2_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity7_UserId1 = default(System.Int32);
public String OnCustReviewTaskChanged_Executor1 = default(System.String);
public Int32 logToHistoryListActivity9_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity10_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity11_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity6_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity8_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity12_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity14_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity15_UserId1 = default(System.Int32);
public Int32 logToHistoryListActivity13_UserId1 = default(System.Int32);
public String OnInProgressTaskChanged_Executor1 = default(System.String);
public Int32 WorkFlowActivated_logToHistoryListActivity_UserId1 = default(System.Int32);
public Guid completeTask1_TaskId1 = default(System.Guid);
private const int TaskType_InProgress = 0;
private const int TaskType_Review = 1;
private const int TaskType_Customer = 2;
public SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
#endregion
#region OnWorkflowActivated_Invoked
///
/// On Work Flow Activated Task will be created to GOSSPL Technical Team
///
///
///
private void OnWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
_approver = @"GOSSPL Technician Team";
workflowCurrentStatus = "In Progress";
taskPreviousState = "";
LastComments = "Claims Work Flow has Initiated by Claims Team!";
SPWeb thisWeb = new SPSite(workflowProperties.SiteId).OpenWeb(workflowProperties.WebId);
SPListItem thisDocitemId = thisWeb.Lists[workflowProperties.ListId].GetItemById(workflowProperties.ItemId);
DocitemId = thisDocitemId.ID;
//taskitemId = 0;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnWorkflowActivated_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To GOSSPL Technical Team
private void CreateTask_ReviewTask_Invoked(object sender, EventArgs e)
{
string strTemp = string.Empty;
try
{
CreateTask_ReviewTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "In Progress")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("R", "In Progress");
}
else if (taskPreviousState == "Rejected")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("A", "Rejected");
}
else if (taskPreviousState == "Quality Check")
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("R", "In Progress");
}
else
{
CreateTask_ReviewTask_TaskProperties1.Title = TaskTitle("A", "In Progress");
}
if (htTaskItems.Count != 0)
{
CopyTaskProperties(CreateTask_ReviewTask_TaskProperties1);
}
CreateTask_ReviewTask_TaskProperties1.AssignedTo = @"GOSSPL Technician Team";
//************************************
//CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Task Groups"] = @"GOSSPL Technician Team";
//SPGroup group = SPWeb.UserGroups[];
//SPGroup group = SPWeb.
//SPFieldUserValue groupvalue = new SPFIeldUserValue(group.ParentWeb, group.ID, group.Name);
//SPWorkflowTaskProperties taskProperties = new SPWorkflowTaskProperties();
//taskProperties.AssignedTo = groupvalue.LookupValue;
SPSite siteCollection = new SPSite("http://igtewfl2018/claims");
SPWeb rootWeb = siteCollection.OpenWeb();
SPGroup spGroup = rootWeb.Groups["GOSSPL Technician Team"];
SPFieldUserValue groupvalue = new SPFieldUserValue(spGroup.ParentWeb, spGroup.ID, spGroup.Name);
//SPFieldUserValue groupvalue = new SPFIeldUserValue(spGroup.ParentWeb, spGroup.ID, spGroup.Name);
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Task Groups"] = groupvalue.LookupValue; ;
//********************************************
CreateTask_ReviewTask_TaskProperties1.Description = LastComments;
CreateTask_ReviewTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_ReviewTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_ReviewTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
SetProperties(workflowProperties, CreateTask_ReviewTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_ReviewTask_Invoked Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GOSSPL Technical Team Task Change
private void OnReviewTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnReviewTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnReviewTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnReviewTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved")
{
_approved = false;
workflowProperties.Item["Processing Status"] = "Quality Check";
workflowProperties.Item.Update();
workflowCurrentStatus = "Quality Check";
taskPreviousState = "In Progress";
}
else if (taskStatus == "Rejected")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Rejected";
workflowProperties.Item.Update();
workflowCurrentStatus = "Rejected";
taskPreviousState = "In Progress";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnReviewTaskChanged_Invoked Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To GOSSPL Quality Check Team
private void CreateTask_CustReviewTask_MethodInvoking(object sender, EventArgs e)
{
try
{
CreateTask_CustReviewTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "In Progress")
{
CreateTask_CustReviewTask_TaskProperties1.Title = TaskTitle("A", "Quality Check");
}
else
{
CreateTask_CustReviewTask_TaskProperties1.Title = TaskTitle("R", "Quality Check");
}
CopyTaskProperties(CreateTask_CustReviewTask_TaskProperties1);
CreateTask_CustReviewTask_TaskProperties1.AssignedTo = @"GOSSPL Quality Check Team";
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
CreateTask_CustReviewTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_CustReviewTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl;
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_CustReviewTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_CustReviewTask_TaskProperties1.TaskType = TaskType_Customer;
SetProperties(workflowProperties, CreateTask_CustReviewTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_CustReviewTask_MethodInvoking Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GOSSPL Quality Check Team Task Change
private void OnCustReviewTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnCustReviewTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnCustReviewTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnCustReviewTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Completed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Completed";
taskPreviousState = "Quality Check";
}
else if (taskStatus == "Rejected")
{
_approved = false;
workflowProperties.Item["Processing Status"] = "In Progress";
workflowProperties.Item.Update();
workflowCurrentStatus = "In Progress";
taskPreviousState = "Quality Check";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnCustReviewTaskChanged_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Creating Task To Claims Team
private void CreateTask_InProgressTask_MethodInvoking(object sender, EventArgs e)
{
try
{
CreateTask_InProgressTask_TaskId1 = Guid.NewGuid();
if (taskPreviousState == "Quality Check")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("A", "Completed");
}
if (taskPreviousState == "In Progress")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("R", "Rejected");
}
if (taskPreviousState == "Completed")
{
CreateTask_InProgressTask_TaskProperties1.Title = TaskTitle("A", "Closed");
}
CopyTaskProperties(CreateTask_InProgressTask_TaskProperties1);
CreateTask_InProgressTask_TaskProperties1.AssignedTo = workflowProperties.OriginatorUser.LoginName.ToString();
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Processing Status"] = workflowCurrentStatus;
CreateTask_InProgressTask_TaskProperties1.Description = LastComments;
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["DocumentId"] = DocitemId;
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/TaskHistory.aspx?DocId=" + DocitemId;
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["History View"] = strHistoryURL + ", View History";
strHistoryURL = workflowProperties.WebUrl + "/Lists/Tasks/EditForm.aspx?ID=" + CreateTask_InProgressTask_TaskProperties1.TaskItemId + "&DocId=" + DocitemId + "&&Source=" + workflowProperties.WebUrl; // TaskItemId not fecthing
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Task Edit"] = strHistoryURL + ", Edit";
CreateTask_InProgressTask_TaskProperties1.DueDate = DateTime.Today.AddDays(2);
CreateTask_InProgressTask_TaskProperties1.ExtendedProperties["Previous Comments"] = taskPreComments;
CreateTask_InProgressTask_TaskProperties1.TaskType = TaskType_Review;
SetProperties(workflowProperties, CreateTask_InProgressTask_TaskProperties1);
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CreateTask_InProgressTask_MethodInvoking Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region Claims Team Task Change
private void OnInProgressTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
taskhiddenStatus = string.Empty;
taskStatus = string.Empty;
string OverallStatus = workflowProperties.Item["Processing Status"].ToString();
Guid ststusFieldId = workflowProperties.TaskList.Fields["Task Status"].Id;
Guid assignedToId = workflowProperties.TaskList.Fields["Assigned To"].Id;
taskStatus = OnInProgressTaskChanged_AfterProperties1.ExtendedProperties[ststusFieldId].ToString();
Guid approverComment = workflowProperties.TaskList.Fields["Comment"].Id;
taskPreviousComments = OnInProgressTaskChanged_AfterProperties1.ExtendedProperties[approverComment].ToString();
if (htTaskItems.Count > 0) htTaskItems.Clear();
UpdateTaskProperties(workflowProperties, OnInProgressTaskChanged_AfterProperties1);
if (taskStatus != null)
{
if (taskStatus == "Approved" & workflowCurrentStatus == "Completed")
{
_approved = true;
workflowProperties.Item["Processing Status"] = "Closed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Closed";
taskPreviousState = "Completed";
_approvedFinal = true;
}
else if (taskStatus == "Rejected" & workflowCurrentStatus == "Completed")
{
_approved = false;
_approvedFinal = true;
workflowProperties.Item["Processing Status"] = "Quality Check";
workflowProperties.Item.Update();
workflowCurrentStatus = "Quality Check";
taskPreviousState = "Completed";
}
if (taskStatus == "Approved" & workflowCurrentStatus == "Rejected")
{
_approved = true;
_approvedFinal = false;
workflowProperties.Item["Processing Status"] = "In Progress";
workflowProperties.Item.Update();
workflowCurrentStatus = "In Progress";
taskPreviousState = "Rejected";
}
if (taskStatus == "Rejected" & workflowCurrentStatus == "Rejected")
{
_approved = false;
_approvedFinal = false;
workflowProperties.Item["Processing Status"] = "Closed";
workflowProperties.Item.Update();
workflowCurrentStatus = "Closed";
taskPreviousState = "Rejected";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow OnInProgressTaskChanged_Invoked Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region SetProperties
public void SetProperties(SPWorkflowActivationProperties wfProperties, SPWorkflowTaskProperties taskProperties)
{
try
{
string strTemp = string.Empty;
if (wfProperties.Item["UCR Number"] != null)
{
taskProperties.ExtendedProperties["UCR Number"] = wfProperties.Item["UCR Number"].ToString();
}
if (wfProperties.Item["Risk Number"] != null)
{
taskProperties.ExtendedProperties["Risk Number"] = wfProperties.Item["Risk Number"].ToString();
}
if (wfProperties.Item["Urgent"] != null)
{
if (wfProperties.Item["Urgent"].ToString().ToUpper() == "TRUE")
{
taskProperties.ExtendedProperties["Priority"] = "High";
}
}
if (wfProperties.Item["Standard Narrative"] != null)
{
strTemp = wfProperties.Item["Standard Narrative"].ToString();
if (strTemp == "First Advice - Regular" || strTemp == "First Advice and authority to appoint expert" || strTemp == "First Advice, expert appointed, await report")
{
taskProperties.ExtendedProperties["First Advice"] = "True";
}
if (strTemp == "First Advice - Regular" || strTemp == "First Advice and authority to appoint expert" || strTemp == "First Advice, expert appointed, await report" || strTemp == "Interim Settlement" || strTemp == "Final Settlement and Closure")
{
taskProperties.ExtendedProperties["Further Advice"] = "True";
}
if (strTemp == "Interim Settlement" || strTemp == "Final Settlement and Closure")
{
taskProperties.ExtendedProperties["Settlement"] = "True";
}
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow SetProperties Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserObject
private SPUser GetUserObject(string accountID)
{
try
{
if (accountID.IndexOf(@"\") > 0)
{
SPUser user = this.workflowProperties.Web.SiteUsers[accountID];
return user;
}
else
{
//replace DOMAIN
SPUser user = this.workflowProperties.Web.SiteUsers[@"DOMAIN\" + accountID];
return user;
}
}
catch
{
//replace DOMAIN and administrator
SPUser adminUser = this.workflowProperties.Web.SiteUsers[@"DOMAIN\administrator"];
return adminUser;
}
}
#endregion
#region UpdateTaskProperties
public void UpdateTaskProperties(SPWorkflowActivationProperties wfProperties, SPWorkflowTaskProperties taskProperties)
{
try
{
htTaskItems.Add("UK Rejection Reason", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["UK Rejection Reason"].Id]);
htTaskItems.Add(" Date Post Received", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields[" Date Post Received"].Id]);
htTaskItems.Add("Business Unit", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Business Unit"].Id]);
//htTaskItems.Add("ECF", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["ECF"].Id]);
htTaskItems.Add("File Track Number", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["File Track Number"].Id]);
htTaskItems.Add("Insured/Reinsured/Coverholder", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Insured/Reinsured/Coverholder"].Id]);
//GOSSPL rejection reason
htTaskItems.Add("GOSSPL Rejection Reason", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["GOSSPL Rejection Reason"].Id]);
htTaskItems.Add("UK Technician", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["UK Technician"].Id]);
htTaskItems.Add("Settlement", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Settlement"].Id]);
htTaskItems.Add("Start Date", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Start Date"].Id]);
//htTaskItems.Add("Due Date", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Due Date"].Id]);
//htTaskItems.Add("% Complete", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["% Complete"].Id]);
htTaskItems.Add("Further Advice", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Further Advice"].Id]);
htTaskItems.Add("First Advice", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["First Advice"].Id]);
//htTaskItems.Add("Priority", taskProperties.ExtendedProperties[wfProperties.TaskList.Fields["Priority"].Id]);
if (taskPreviousComments.Replace("
", "").Replace("
", "") != ""){
taskPreComments = taskProperties.AssignedTo.ToString() + " " + DateTime.Now.ToString("dd/MM/yyyy") + " " + DateTime.Now.ToShortTimeString().ToString() + " : " + taskPreviousComments + "\n" + taskPreComments;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow UpdateTaskProperties Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region CopyTaskProperties
public void CopyTaskProperties(SPWorkflowTaskProperties taskProperties)
{
try
{
taskProperties.ExtendedProperties["UK Rejection Reason"] = htTaskItems["UK Rejection Reason"];
taskProperties.ExtendedProperties[" Date Post Received"] = htTaskItems[" Date Post Received"];
taskProperties.ExtendedProperties["Business Unit"] = htTaskItems["Business Unit"];
//taskProperties.ExtendedProperties["ECF"] = htTaskItems["ECF"];
taskProperties.ExtendedProperties["File Track Number"] = htTaskItems["File Track Number"];
taskProperties.ExtendedProperties["Insured/Reinsured/Coverholder"] = htTaskItems["Insured/Reinsured/Coverholder"];
taskProperties.ExtendedProperties["GOSSPL Rejection Reason"] = htTaskItems["GOSSPL Rejection Reason"];
taskProperties.ExtendedProperties["UK Technician"] = htTaskItems["UK Technician"];
//taskProperties.ExtendedProperties["Rejection Reason"] = htTaskItems["Rejection Reason"];
taskProperties.ExtendedProperties["Settlement"] = htTaskItems["Settlement"];
taskProperties.ExtendedProperties["Start Date"] = htTaskItems["Start Date"];
//taskProperties.ExtendedProperties["Due Date"] = htTaskItems["Due Date"];
//taskProperties.ExtendedProperties["% Complete"] = htTaskItems["% Complete"];
taskProperties.ExtendedProperties["Further Advice"] = htTaskItems["Further Advice"];
taskProperties.ExtendedProperties["First Advice"] = htTaskItems["First Advice"];
//taskProperties.ExtendedProperties["Priority"] = htTaskItems["Priority"];
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow CopyTaskProperties Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region ProposalApproved
private void ProposalApproved(object sender, ConditionalEventArgs e)
{
try
{
if (taskStatus != string.Empty && taskStatus != "" && taskStatus != null)
{
e.Result = _approved;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow ProposalApproved Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region CompleteTask
private void CompleteTask(object sender, EventArgs e)
{
_approved = false;
}
#endregion
#region HandleException
public void HandleException(string strTrace, string strMessage, string strLocation)
{
try
{
SPWeb MyWeb = workflowProperties.Web;
MyWeb.AllowUnsafeUpdates = true;
SPList listException = MyWeb.Lists["N__CL_Exception"];
SPListItemCollection itemColException = listException.Items;
SPListItem itemException = itemColException.Add();
itemException["Title"] = strMessage;
itemException["Location"] = strLocation;
itemException["Description"] = strTrace;
itemException.Update();
}
catch (Exception)
{
}
}
#endregion
#region MyException
public class MyException : Exception
{
public MyException()
{
Console.WriteLine("User Defined Exception");
}
}
#endregion
#region Task Updates
public string TaskTitle(string taskType, string taskStatus)
{
string taskTitleDescription = string.Empty;
if (taskType == "A") // Title New or Approved case
{
switch (taskStatus)
{
case "In Progress":
taskTitleDescription = "A new claims is Initatied:" + workflowProperties.Item.File.Name.ToString();
break;
case "Rejected":
taskTitleDescription = "Claims is sent for Technician:" + workflowProperties.Item.File.Name.ToString();
break;
case "Quality Check":
taskTitleDescription = "Claims is sent for Quality Check:" + workflowProperties.Item.File.Name.ToString();
break;
case "Completed":
//taskTitleDescription = "Claims is sent for Completed:" + workflowProperties.Item.File.Name.ToString();
taskTitleDescription = "Task Ready for Closing assigned to you:" + workflowProperties.Item.File.Name.ToString();
break;
case "Closed":
taskTitleDescription = "Claims is Closed:" + workflowProperties.Item.File.Name.ToString();
break;
}
}
if (taskType == "R") // Title Old or Rejected case
{
switch (taskStatus)
{
case "In Progress":
//taskTitleDescription = "Claims Rejected by Technical Team!:" + workflowProperties.Item.File.Name.ToString();
taskTitleDescription = "Rejected Task assigned to you by Quality check Team!:" + workflowProperties.Item.File.Name.ToString();
break;
case "Quality Check":
taskTitleDescription = "Rejected Task assigned to you by Claims Team!:" + workflowProperties.Item.File.Name.ToString();
break;
case "Rejected":
taskTitleDescription = "Rejected Task assigned to you by Technician Team!:" + workflowProperties.Item.File.Name.ToString();
break;
}
}
return taskTitleDescription;
}
#endregion
#region Claims Approval Condition
private void Proposal2(object sender, ConditionalEventArgs e)
{
try
{
e.Result = _approvedFinal;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow ProposalApproved Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginator
private void GetOriginator(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(workflowProperties.Originator);
WorkFlowActivated_logToHistoryListActivity_UserId1 = executor.ID;
logToHistoryListActivity14_UserId1 = executor.ID;
logToHistoryListActivity15_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginator Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForTechTeam
private void GetOriginatorForTechTeam(object sender, EventArgs e)
{
try
{
if ((taskStatus == "Approved") || (taskStatus == string.Empty))
{
SPUser executor = GetUserObject(workflowProperties.Originator);
logToHistoryListActivity1_UserId1 = executor.ID;
logToHistoryListActivity2_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity1_UserId1 = executor.ID;
logToHistoryListActivity2_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForTechTeam Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIDForTechChange
private void GetUserIDForTechChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity3_UserId1 = executor.ID;
logToHistoryListActivity4_UserId1 = executor.ID;
logToHistoryListActivity5_UserId2 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetUserID Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForQualityTeam
private void GetOriginatorForQualityTeam(object sender, EventArgs e)
{
try
{
if (taskStatus == "Approved")
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity7_UserId1 = executor.ID;
logToHistoryListActivity12_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnInProgressTaskChanged_Executor1);
logToHistoryListActivity7_UserId1 = executor.ID;
logToHistoryListActivity12_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForQualityTeam Method";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIdForQualityChange
private void GetUserIdForQualityChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity9_UserId1 = executor.ID;
logToHistoryListActivity10_UserId1 = executor.ID;
logToHistoryListActivity11_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForQualityTeam Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetOriginatorForClaims
private void GetOriginatorForClaims(object sender, EventArgs e)
{
try
{
if (taskStatus == "Approved")
{
SPUser executor = GetUserObject(OnCustReviewTaskChanged_Executor1);
logToHistoryListActivity6_UserId1 = executor.ID;
logToHistoryListActivity8_UserId1 = executor.ID;
}
if (taskStatus == "Rejected")
{
SPUser executor = GetUserObject(OnReviewTaskChanged_Executor1);
logToHistoryListActivity6_UserId1 = executor.ID;
logToHistoryListActivity8_UserId1 = executor.ID;
}
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForClaims Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
#region GetUserIdForClaimsChange
private void GetUserIdForClaimsChange(object sender, EventArgs e)
{
try
{
SPUser executor = GetUserObject(OnInProgressTaskChanged_Executor1);
logToHistoryListActivity13_UserId1 = executor.ID;
}
catch (Exception ex)
{
string strTrace = ex.StackTrace.ToString();
string strMessage = ex.Message.ToString();
string strLocation = "Statemachine Workflow GetOriginatorForClaims Method ";
HandleException(strTrace, strMessage, strLocation);
throw new MyException();
}
}
#endregion
}
#endregion
}
______________________________________________________________________________
Install.bat
:: Before running this file, sign the assembly in Project properties
::
:: To customize this file, find and replace
:: a) "StateMachineDemo" with your own feature names
:: b) "feature.xml" with the name of your feature.xml file
:: c) "workflow.xml" with the name of your workflow.xml file
:: d) "http://localhost" with the name of the site you wish to publish to
echo Copying the feature...
rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo"
copy /Y feature.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo\"
copy /Y workflow.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\StateMachineDemo\"
xcopy /s /Y *.aspx "%programfiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS"
echo Adding assemblies to the GAC...
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -uf StateMachineDemo
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if bin\Debug\StateMachineDemo.dll
echo Activating the feature...
pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin
::Note: Uncomment these lines if you've modified your deployment xml files or IP forms
stsadm -o deactivatefeature -filename StateMachineDemo\feature.xml -url http://igtewfl2018
stsadm -o uninstallfeature -filename StateMachineDemo\feature.xml
stsadm -o installfeature -filename StateMachineDemo\feature.xml -force
stsadm -o activatefeature -filename StateMachineDemo\feature.xml -url http://igtewfl2018
echo Doing an iisreset...
popd
iisreset
Wednesday, January 6, 2010
Check Usergroups of Sharepoint
//Check whether the currently logged in user is in a specific role
public bool IsCurrentUserInRole(string role)
{
bool inRole = false;
using (SPSite site = new SPSite(strSiteCollectionURL))
{
using (SPWeb rootWeb = site.OpenWeb())
{
SPRole spRole = rootWeb.Roles[role];
SPUser currentUser = rootWeb.CurrentUser;
foreach (SPUser roleUser in spRole.Users)
{
if (roleUser.ID.Equals(currentUser.ID))
{
inRole = true;
break;
}
}
return inRole;
}
}
}
//Check whether the currently logged in user is a member of a specific group
public bool IsCurrentUserInGroup(string group)
{
bool inGroup = false;
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb rootWeb = siteCollection.OpenWeb())
{
SPUser currentUser = rootWeb.CurrentUser;
SPGroup spGroup = rootWeb.Groups[group];
foreach (SPUser groupUser in spGroup.Users)
{
if (groupUser.ID.Equals(currentUser.ID))
{
inGroup = true;
break;
}
}
siteCollection.Dispose();
rootWeb.Dispose();
return inGroup;
}
}
}
public Hashtable GetUserGroupsForCurrentUser()
{
using (SPSite site = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = site.OpenWeb(strCurrentSiteURL))
{
SPUser user = web.CurrentUser;
SPGroupCollection grpColl = user.Groups;
Hashtable htgetusergroups = new Hashtable();
int igroup = 0;
//Iterate through the SPGroupCollection to see which group(s)
//the user belongs to and add the group names to the hashtable accordingly.
foreach (SPGroup group in grpColl)
{
htgetusergroups.Add(igroup, group.Name);
igroup = igroup + 1;
}
return htgetusergroups;
}
}
}
//Returns a hashtable, if the currently logged in user is a
//member of more than one group
public Hashtable GetUserGroups(SPUser user)
{
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = siteCollection.OpenWeb())
{
Hashtable htgetusergroups = new Hashtable();
user = web.CurrentUser;
SPGroupCollection grpColl = user.Groups;
int igroup = 0;
//Iterate through the SPGroupCollection to see which group(s)
//the user belongs to and add the group names to the hashtable accordingly.
foreach (SPGroup group in grpColl)
{
htgetusergroups.Add(igroup, group.Name);
igroup = igroup + 1;
}
// BDX-798 start
if (htgetusergroups.Count == 0)
{
htgetusergroups.Add(igroup, strBDXVistor);
}
// BDX-798 End
return htgetusergroups;
}
}
}
//Returns the current user
public SPUser GetCurrentUser()
{
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = siteCollection.OpenWeb())
{
SPUser currentUser = web.CurrentUser;
siteCollection.Dispose();
return currentUser;
}
}
}
public bool IsCurrentUserInRole(string role)
{
bool inRole = false;
using (SPSite site = new SPSite(strSiteCollectionURL))
{
using (SPWeb rootWeb = site.OpenWeb())
{
SPRole spRole = rootWeb.Roles[role];
SPUser currentUser = rootWeb.CurrentUser;
foreach (SPUser roleUser in spRole.Users)
{
if (roleUser.ID.Equals(currentUser.ID))
{
inRole = true;
break;
}
}
return inRole;
}
}
}
//Check whether the currently logged in user is a member of a specific group
public bool IsCurrentUserInGroup(string group)
{
bool inGroup = false;
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb rootWeb = siteCollection.OpenWeb())
{
SPUser currentUser = rootWeb.CurrentUser;
SPGroup spGroup = rootWeb.Groups[group];
foreach (SPUser groupUser in spGroup.Users)
{
if (groupUser.ID.Equals(currentUser.ID))
{
inGroup = true;
break;
}
}
siteCollection.Dispose();
rootWeb.Dispose();
return inGroup;
}
}
}
public Hashtable GetUserGroupsForCurrentUser()
{
using (SPSite site = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = site.OpenWeb(strCurrentSiteURL))
{
SPUser user = web.CurrentUser;
SPGroupCollection grpColl = user.Groups;
Hashtable htgetusergroups = new Hashtable();
int igroup = 0;
//Iterate through the SPGroupCollection to see which group(s)
//the user belongs to and add the group names to the hashtable accordingly.
foreach (SPGroup group in grpColl)
{
htgetusergroups.Add(igroup, group.Name);
igroup = igroup + 1;
}
return htgetusergroups;
}
}
}
//Returns a hashtable, if the currently logged in user is a
//member of more than one group
public Hashtable GetUserGroups(SPUser user)
{
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = siteCollection.OpenWeb())
{
Hashtable htgetusergroups = new Hashtable();
user = web.CurrentUser;
SPGroupCollection grpColl = user.Groups;
int igroup = 0;
//Iterate through the SPGroupCollection to see which group(s)
//the user belongs to and add the group names to the hashtable accordingly.
foreach (SPGroup group in grpColl)
{
htgetusergroups.Add(igroup, group.Name);
igroup = igroup + 1;
}
// BDX-798 start
if (htgetusergroups.Count == 0)
{
htgetusergroups.Add(igroup, strBDXVistor);
}
// BDX-798 End
return htgetusergroups;
}
}
}
//Returns the current user
public SPUser GetCurrentUser()
{
using (SPSite siteCollection = new SPSite(strSiteCollectionURL))
{
using (SPWeb web = siteCollection.OpenWeb())
{
SPUser currentUser = web.CurrentUser;
siteCollection.Dispose();
return currentUser;
}
}
}
Subscribe to:
Posts (Atom)