Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Code Sample - Files for File Watcher Event Binding Page

Code Sample - Files for File Watcher Event Binding Page

  • Last UpdatedSep 11, 2024
  • 9 minute read

When creating a custom event provider, there should be an interface from which we should be able to associate to the event and set the properties.

For any custom Event Provider we are creating, we should design a similar page which can accept the settings for that provider and should be able to update into the database (SKEventBindings, SKEEventAssociations)

Here, we have given the sample page for creating FileWatcher event association page, which can be used as a reference to create a new aspx file with similar functionality.

The newly created code files for filewatcher is added in the folder.

Default\Plugins\FileWatcher\EventProvider 

and Images in

Default\Plugins\FileWatcher\Images folder

In the class Library for Custom event provider, under the implementation of EventClientServiceProvider in function GetProvisionForms() we have to set the details of the page url that we have created above(for event binding) for the  EventProvisionFormDetail object created.

The following aspx file is the interface from where association can be set for the file watcher event:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="Skelta.Repository.Web.CodeBehind.AssociateFileWatcher" %>

<%@ Register Assembly="RadTabStrip.Net2" Namespace="Telerik.WebControls" TagPrefix="radTS" %>

<%@ Register TagPrefix="radCln" Namespace="Telerik.WebControls" Assembly="RadCalendar.Net2" %>

<%@ Register Assembly="Skelta.Repository.Web" Namespace="Skelta.Repository.Web.Lookup"

TagPrefix="cc1" %>

<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>

<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %>

<link href="<%=cssPath%>Common/StyleSheet/Global.css" rel="stylesheet" type="text/css" />

<html >

<head runat="server" id="Head1">

<title>Associate to File Watcher</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="1" border="0" width="98%" align="center">

<tr>

<td class="pagetitle ">

<img src="../Images/filewatcher-icon.png" hspace="1" align="absmiddle" /><%=GetLangSpecText("ec_filewatcher_titlename")%>

</td>

</tr>

<tr>

<br />

<td width="100%"  colspan="2">

<span class="description">

<%=GetLangSpecText("ec_filewatcher_helptext")%>

</span>

</td>

</tr>

</table>

<br />

<table cellpadding="7" cellspacing="1" border="0" class="tablebg" width="98%" align="center">

<tr>

<td class="lefttdbg" style="width: 50%;">

<span class="subtitle">

<%=GetLangSpecText("ec_filewatcher_eventtype")%>

</span>

</td>

<td class="righttdbg" style="width: 50%;">

<asp:DropDownList ID="ListTypes" runat="server" AutoPostBack="false"  CssClass ="inputselect">

</asp:DropDownList>

</td>

</tr>

<tr>

<td class="lefttdbg" style="width: 50%;">

<span class="subtitle">

<%=GetLangSpecText("ec_filewatcher_eventport")%>

<img runat="server" id="imgMandatory" src="<%$ReplaceTemplateExpn:Skeltaforms/Images/mandatoryicon.PNG%>"

visible="true" hspace="2" align="top" />

<img id="imgsiteUrlerror" alt="Select Folder" runat="server" src="<%$ ReplaceTemplateExpn:Skeltaforms/Images/erroricon.png%>"

hspace="2" align="top" visible="false" />

</span>

</td>

<td class="righttdbg" style="width: 50%;">

<radC:RadComboBox ID="EventsPort" runat="server" Skin="SkeltaCombobox" RadControlsDir="<%$ReplaceTemplateExpn:telerik/radcontrols/%>"

MaxLength="100" DropDownWidth="303px" Height="150px" NoWrap="True" AutoPostBack="false">

</radC:RadComboBox>

</td>

</tr>

<tr>

<td class="lefttdbg" style="width: 50%;">

<span class="subtitle">

<%=GetLangSpecText("ec_filewatcher_filefullpath")%>

</span>

<br />

<span class="description">

<%=GetLangSpecText("ec_filewatcher_Pattern")%>

</span>

</td>

<td class="righttdbg" style="width: 50%;">

<asp:TextBox ID="txtFilePattern" runat="server" CssClass="inputtext" Width="150px"></asp:TextBox>

</td>

</tr>

<tr>

<td class="lefttdbg" style="width: 50%;">

<span class="subtitle">

<%=GetLangSpecText("ecm_view_assn_alertver")%>

</span>

</td>

<td class="righttdbg" style="width: 50%;">

<asp:Panel ID="VersionPanel" runat="server">

</asp:Panel>

</td>

</tr>

</table>

<div id="footerdiv">

<table width="100%" align="center" border="0" height="100px">

<tr align="right">

<td width="50%">

</td>

<td width="50%">

<asp:Button ID="AttachEvent" runat="server" CssClass="inputbutton" CausesValidation="False" />

<asp:Button ID="CancelEvent" runat="server" CssClass="inputbutton" CausesValidation="False" />

</td>

</tr>

</table>

</div>

</div>

</form>

</body>

</html>

The below code behind file is responsible for associating a workflow with a File Watcher event.

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Xml;

using System.Xml.Schema;

using System.Text;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Collections.Generic;

using Workflow.NET.PropertyTypes;

using Skelta.Events;

using Workflow.NET;

using Skelta.Forms.Core.Controls;

using Skelta.Repository.Web.List;

using Skelta.Repository.Web;

using Skelta.Repository.List;

using Skelta.Repository.List.Action;

using Skelta.Entity;

using Skelta.Core;

using Workflow.NET.Web.Designer;

using System.IO;

using Skelta.Events.Interfaces;

using Workflow.NET.Interfaces;

using Workflow.NET.Storage;

using System.Xml.Serialization;

namespace Skelta.Repository.Web.CodeBehind

{

public partial class AssociateFileWatcher : System.Web.UI.Page

{

protected string applicationName;

protected ProcessDesigner _designerControl;

protected ProcessDesignerAdapter designerAdapter;

public string error = string.Empty;

protected Guid skListId;

protected Guid workflowId;

protected Guid skListItemId;

protected Guid stPort;

protected string workflowName;

protected string spScripts;

protected Skelta.Repository.List.ListItem item;

protected Skelta.Repository.Web.Lookup.VersionLookup WorkflowVersionLookUp;

protected string mode;

protected Guid eventBindId;

protected string eventListType;

protected string workflowVersion;

protected string effectiveFromDate = "";

protected string effectiveToDate = "";

protected string listName = "Workflow";

protected string eventType;

protected string FileName;

protected string FullPath;

protected string alertMessage;

protected Skelta.Repository.List.ListDefinition associationList;

protected Skelta.Repository.List.ListItem associationItem;

protected string Loggeduser;

protected System.Web.UI.WebControls.TextBox txtFilePattern;

protected System.Web.UI.HtmlControls.HtmlImage imgsiteUrlerror;

protected System.Web.UI.WebControls.DropDownList ListTypes;

protected Telerik.WebControls.RadComboBox EventsPort;

protected System.Web.UI.WebControls.Panel VersionPanel;

protected Button AttachEvent;

protected Button CancelEvent;

ListDefinition _List;

//Themes Implementation changes

protected string cssPath = "";

protected string imgPath1 = "";

protected string imgPath2 = "";

protected object styleUrl = Workflow.NET.TemplateExpressionBuilder.GetUrl("");

protected object imgUrl1 = Workflow.NET.TemplateExpressionBuilder.GetUrl("Plugins/FileWatcher/Images");

protected object imgUrl2 = Workflow.NET.TemplateExpressionBuilder.GetUrl("Images");

#region "Event enums"

public enum FileEventType

{

Created = 0,

Changed = 1,

Renamed = 2,

Deleted = 3

}

#endregion

protected void Page_Load(object sender, EventArgs e)

{

cssPath = styleUrl.ToString();

imgPath1 = imgUrl1.ToString();

imgPath2 = imgUrl2.ToString();

ListPageParameters listParams = new ListPageParameters();

listParams.ResolveCurrentUri();

applicationName = listParams.ApplicationName;

if (listParams.ListName.ToLower() == "workflow")

workflowId = listParams.ListItemId;

else

skListItemId = listParams.ListItemId;

ViewState["workflowId"] = workflowId;

ViewState["skListItemId"] = skListItemId;

ViewState["skListId"] = skListId;

ViewState["applicationName"] = applicationName;

ViewState["PageMode"] = mode;

ViewState["UserId"] = listParams.LoggedInUserId;

 

Loggeduser = listParams.LoggedInUserId;

 

 

EventsPort.Width = 320;

{

if (ViewState["workflowId"] != null)

workflowId = (Guid)ViewState["workflowId"];

if (ViewState["skListItemId"] != null)

skListItemId = (Guid)ViewState["skListItemId"];

if (ViewState["skListId"] != null)

skListId = (Guid)ViewState["skListId"];

if (ViewState["applicationName"] != null)

applicationName = ViewState["applicationName"].ToString();

if (ViewState["PageMode"] != null)

mode = ViewState["PageMode"].ToString();

AttachEvent.Click += new EventHandler(AttachEvent_Click);

CancelEvent.Click += new EventHandler(CancelEvent_Click);

AttachEvent.Text = GetLangSpecText("ecm_filewatcher_save");

CancelEvent.Text = GetLangSpecText("ecm_filewatcher_cancel");

 

}

if (!string.IsNullOrEmpty(applicationName))

{

this.LoadEvents(ListTypes.Text);

}

PopulateWorkflowVersion();

if (!IsPostBack)

{

this.LoadListTypes();

if (!string.IsNullOrEmpty(applicationName))

{

_List = ListDefinition.GetList(new Skelta.Core.ApplicationObject(applicationName), "FileWatcher List");

LoadSecurityEnblePorts();

}

}

}

protected void AttachEvent_Click(object sender, EventArgs e)

{

CreateXMLVaribale();

SaveEventBinding();

}

private void SaveEventBinding()

{

string filename;

string filepath;

String eventtype;

string EventType;

FullPath = txtFilePattern.Text;

EventType = ListTypes.SelectedItem.Text;

ListDataHandler wfhandler = new ListDataHandler(applicationName, "Workflow");

Skelta.Repository.List.ListItem wfitem;

wfitem = wfhandler.GetListItem(workflowId);

workflowName = wfitem.Title;

EventBinding eventBind;

eventBind = new EventBinding(new Skelta.Core.ApplicationObject(applicationName));

eventBind.BindingType = EventBindingType.Workflow;

eventBind.Disabled = false;

eventBind.Disable_After_Expiry = false;

eventBind.NoofEvents = 0;

eventBind.EventName = "FileWatcher";

eventBind.Alert_ApplicationName = applicationName;

eventBind.Alert_Workflow = workflowName;//the current list item

eventBind.Alert_Version = wfitem.CurrentVersion.VersionStamp.ToString();

eventBind.Alert_UserId = ViewState["UserId"];

int flag = 0;

if (EventsPort.Items.Count != 0)

{

//

bool chkFolder = true;

string strPort = EventsPort.SelectedItem.Text;

 if (chkFolder == true)

{

 

stPort = new Guid(EventsPort.SelectedValue);

eventBind.PortGuid = stPort;

flag = 1;

}

else

{

error = GetLangSpecText("ec_filewatcher_portRemoved");

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "regJs", "<script>alert(\"" + error + "\");</script>");

}

}

else

{

imgsiteUrlerror.Visible = true;

}

if (flag == 1)

{

string[] strFileType = txtFilePattern.Text.Split('.');

if (strFileType.Length > 1)

{

if (strFileType[0] == string.Empty && strFileType[1] != string.Empty)

{

eventBind.str2 = strFileType[1].ToString();

}

if (strFileType[0] != string.Empty && strFileType[1] != string.Empty)

{

if (strFileType[0] == "*" && strFileType[1] == "*")

{

}

else if (strFileType[0] == "*" && strFileType[1] != string.Empty)

{

eventBind.str2 = strFileType[1];

}

else

{

eventBind.str1 = txtFilePattern.Text;

}

}

}

else if (strFileType[0] != string.Empty)

{

eventBind.str1 = strFileType[0];

}

eventBind.str3 = EventType;

//New code

string SqlQuery = "";

//stPort

if (eventBind.str1 == "" && eventBind.str2 == "")

{

SqlQuery = "select * from SKEventBindings ";

SqlQuery += "where str1 is null ";

SqlQuery += "and str2 is null ";

SqlQuery += "and str3='" + EventType + "'";

SqlQuery += "and PortGuid=@PortGuid ";

SqlQuery += "and Alert_Workflow='" + workflowName + "' ";

}

else if (eventBind.str1 != "" && eventBind.str2 == "")

{

SqlQuery = "select * from SKEventBindings ";

SqlQuery += "where str1='" + eventBind.str1 + "' ";

SqlQuery += "and str2 is null ";

SqlQuery += "and str3='" + EventType + "' ";

SqlQuery += "and PortGuid=@PortGuid ";

SqlQuery += "and Alert_Workflow='" + workflowName + "' ";

}

else if (eventBind.str1 == "" && eventBind.str2 != "")

{

SqlQuery = "select * from SKEventBindings ";

SqlQuery += "where str1 is null ";

SqlQuery += "and str2='" + eventBind.str2 + "'";

SqlQuery += "and str3='" + EventType + "' ";

SqlQuery += "and PortGuid=@PortGuid ";

SqlQuery += "and Alert_Workflow='" + workflowName + "' ";

}

else

{

SqlQuery = "select * from SKEventBindings ";

SqlQuery += "where str1='" + eventBind.str1 + "' ";

SqlQuery += "and str2='" + eventBind.str2 + "'";

SqlQuery += "and str3='" + EventType + "' ";

SqlQuery += "and PortGuid=@PortGuid ";

SqlQuery += "and Alert_Workflow='" + workflowName + "' ";

 }

Guid portGuid = Guid.Empty;

portGuid = stPort;

DataTable temp = null;

IDataHandler dbhandler = DataHandlerFactory.GetDataHandler(wfitem.List.Configuration);

IDataParameter Param = dbhandler.GetParameter("@PortGuid", portGuid);

try

{

using (dbhandler)

{

temp = dbhandler.ReadData(SqlQuery, Param);

}

}

catch { }

if (temp == null)

return;

if (temp.Rows.Count != 0)

{

error = GetLangSpecText("ecm_assn_multiplebindings");

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "regJs", "<script>alert(\"" + error + "\");</script>");

return;

}

eventBind.Save();

eventBindId = eventBind.Id;

filename = txtFilePattern.Text;

filepath = EventsPort.SelectedValue;

eventtype = EventType;

alertMessage = EventsPort.SelectedItem.Text  + "  " + filename + "  " + eventtype;

StringBuilder eventXml = new StringBuilder();

eventXml.Append("<EventBind id=\"" + eventBindId + "\">");

eventXml.Append("<ApplicationName>" + applicationName + "</ApplicationName>");

eventXml.Append("<Workflow>");

eventXml.Append("<WorkflowName>" + workflowName + "</WorkflowName>");

eventXml.Append("<WorkflowAlert>" + alertMessage + "</WorkflowAlert>");

eventXml.Append("<WorkflowEffectiveFrom>" + effectiveFromDate + "</WorkflowEffectiveFrom>");

eventXml.Append("<WorkflowEffectiveTo>" + effectiveToDate + "</WorkflowEffectiveTo>");

eventXml.Append("</Workflow>");

eventXml.Append("<Parameters>");

eventXml.Append("<File FileName=\"" + filename + "\" name=\"" + listName + "\"></File>");

eventXml.Append("<File FilePath=\"" + filepath + "\" name=\"" + listName + "\"></File>");

eventXml.Append("<File EventType=\"" + eventtype + "\" name=\"" + listName + "\"></File>");

eventXml.Append("</Parameters>");

eventXml.Append("</EventBind>");

SaveAssociationList(eventXml.ToString());

}

}

private void SaveAssociationList(string eventXml)

{

if (associationList == null)

{

associationList = ListDefinition.GetList(new Skelta.Core.ApplicationObject(applicationName), "Event Associations");

}

if (associationList != null)

{

Guid webApplicationItemReferenceId = Guid.Empty;

ListDefinition webApplicationList = ListDefinition.GetList(new Skelta.Core.ApplicationObject(applicationName), "Event Associations");

Skelta.Repository.List.ListItemCollection webApplicationListItems = new Skelta.Repository.List.ListItemCollection(webApplicationList);

Hashtable webApplicationTableColumnNames = new Hashtable();

SortedDictionary<string, Skelta.Forms.Core.Controls.BaseDataControl> fields = webApplicationListItems.GetRecordsFieldMapping();

foreach (KeyValuePair<string, Skelta.Forms.Core.Controls.BaseDataControl> info in fields)

{

webApplicationTableColumnNames.Add(info.Value.Name, info.Key);

}

Skelta.Repository.List.ListItem webApplicationListItem = null;

if (webApplicationItemReferenceId == Guid.Empty)

webApplicationListItem = new Skelta.Repository.List.ListItem(webApplicationList);

else

webApplicationListItem = new Skelta.Repository.List.ListItem(webApplicationList, webApplicationItemReferenceId);

if (webApplicationListItem != null)

{

if (associationItem == null)

{

associationItem = new Skelta.Repository.List.ListItem(associationList);

}

ListMainForm associationMainForm = (ListMainForm)associationItem.ListForm.Records[0];

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_evntbndxml")).Value = eventXml;

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_wrkflwname")).Value = workflowName;

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_evntprvdrname")).Value = "FileWatcher";

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_evnttype")).Value = "FileWatcher";

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_evntstatus")).Value = "New";

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_desc")).Value = alertMessage;

((ListTextDataItem)associationMainForm.FindControlByID("_sys_sk_evntass_title")).Value = ListTypes.Text;

((ListGuidDataItem)associationMainForm.FindControlByID("_sys_sk_evntassbnd_id")).Value = eventBindId;

associationItem.LoggedInUserId = Loggeduser;

associationItem.Save(ListItemVersionStatus.Published);

error = string.Empty;

string strSuccessText = GetLangSpecText("ecm_filewatcher_savesuccess");

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "regJs", "<script>alert(\""+strSuccessText+"\");</script>");

}

else

{

throw new Exception("Not able to fetch main Reference Id");

}

}

}

private void LoadListTypes()

{

string listTypesSelectedValue = ListTypes.SelectedValue;

this.ListTypes.DataSource = Enum.GetNames(typeof(FileEventType));

this.ListTypes.DataBind();

 

if (listTypesSelectedValue != null && listTypesSelectedValue != "")

this.ListTypes.SelectedValue = listTypesSelectedValue;

}

private void LoadEvents(string listType)

{

}

private void PopulateWorkflowVersion()

{

if (!string.IsNullOrEmpty(applicationName) && workflowId != Guid.Empty)

{

if (WorkflowVersionLookUp == null)

{

WorkflowVersionLookUp = new Skelta.Repository.Web.Lookup.VersionLookup();

WorkflowVersionLookUp.ApplicationName = applicationName;

WorkflowVersionLookUp.ID = "WorkflowVersionLookUp";

WorkflowVersionLookUp.ListName = "Workflow";

WorkflowVersionLookUp.ListItemId = workflowId;// set the listitem id of the workflow..

WorkflowVersionLookUp.IsLatestVisible = true;

VersionPanel.Controls.Clear();

VersionPanel.Controls.Add(WorkflowVersionLookUp);

}

}

}

protected string GetLangSpecText(string keyName)

{

SkeltaResourceSetManager resManager = new SkeltaResourceSetManager();

return resManager.GlobalResourceSet.GetString(keyName);

}

protected void CancelEvent_Click(object sender, EventArgs e)

{

txtFilePattern.Text = string.Empty;

}

private void LoadPorts()

{

Dictionary<string, IEventPort> eventPorts = GetAllEventPorts(applicationName, "FileWatcher");

foreach (string portGuid in eventPorts.Keys)

{

Telerik.WebControls.RadComboBoxItem lst = new Telerik.WebControls.RadComboBoxItem();

lst.Text = eventPorts[portGuid].PortName;

lst.Value = eventPorts[portGuid].PortGuid.ToString();

EventsPort.Items.Add(lst);

}

}

private void LoadSecurityEnblePorts()

{  

DataTable dtTable = null;

Skelta.Repository.List.ListItemCollection objSecPorts = new Skelta.Repository.List.ListItemCollection(_List);

dtTable = objSecPorts.GetRecordsForConsume(Loggeduser, Skelta.Repository.Display.AllItems);

if (dtTable.Rows.Count > 0)

 LoadPorts();

}

private Dictionary<string, IEventPort> GetAllEventPorts(string applicationName, string eventProviderName)

{

//If it is not given here, for every serviceprovider class, geteventports method should be implemented.

// it will be duplication of code everywhere.

Dictionary<string, IEventPort> colEventPorts = new Dictionary<string, IEventPort>();

 

if (applicationName != "")

{

FILEWATCHER myObject;

EventServicePortCollection colEventServicePorts = new EventServicePortCollection(new ApplicationObject(applicationName), eventProviderName);

foreach (EventServicePort evntPort in colEventServicePorts.Items)

{

myObject = new FILEWATCHER();

System.IO.StringReader read = new StringReader(evntPort.PortXml);

System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(myObject.GetType());

System.Xml.XmlReader reader = new XmlTextReader(read);

myObject = (FILEWATCHER)serializer.Deserialize(reader);

if (myObject.REPOSITORY.Trim() == applicationName)  

colEventPorts.Add(evntPort.Name, evntPort.EventPort);

}

}

return colEventPorts;

}

private void CreateXMLVaribale()

{

try

{

ListDataHandler wfhandler = new ListDataHandler(applicationName, "Workflow");

Skelta.Repository.List.ListItem wfitem;

wfitem = wfhandler.GetListItem(workflowId);

workflowName = wfitem.Title;

Skelta.Core.AddInProvider provider = new Skelta.Core.AddInProvider(new Skelta.Core.ApplicationObject(applicationName), GetProviderId("XmlDocument", applicationName));

Workflow.NET.Interfaces.IXmlStorageType storageHandler = (Workflow.NET.Interfaces.IXmlStorageType)provider.CreateInstance(true);

Workflow.NET.Diagram _diagram = Workflow.NET.Diagram.GetDiagramCreateIfNotFound(applicationName, workflowName, wfitem.CurrentVersion.VersionStamp.ToString());

Skelta.Enterprise.CommonFunctions commonFunctions = new Skelta.Enterprise.CommonFunctions();

_diagram.PreProcessDiagaram();

bool flag = true;

foreach (XmlVariable var in _diagram.XmlVariables.Values)

{

if (var.Name.Equals("FileWatcherXMLData"))

{

flag = false;

}

}

if (flag)

{

Workflow.NET.XmlVariable XVariable = new Workflow.NET.XmlVariable();

XVariable.Name = "FileWatcherXMLData";

XVariable.Description = "File watcher XML Data";

XVariable.StorageType = "XmlDocument";

string eventdataFilePath = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath + "/" + Workflow.NET.Config.GetTemplateDirectoryFromWebConfig() + "Default/XMLSchemas/FileWatcherEventData.xml");

XVariable.Schema = ParseXMLForData(eventdataFilePath);

XVariable.StorageHandler = storageHandler;

((Workflow.NET.XmlStorageType.XmlDocument)(XVariable.StorageHandler)).StorageData = "variables";

_diagram.XmlVariables.Add(XVariable.Name, XVariable);

commonFunctions.WriteDiagram(_diagram, applicationName, workflowName, wfitem.CurrentVersion.VersionStamp.ToString());

_diagram.Dispose();

}

}

catch (Exception)

{

}

}

private Guid GetProviderId(string storageType, string applicationName)

{

Skelta.Core.AddInProviderCollection _Provider = new Skelta.Core.AddInProviderCollection(new Skelta.Core.ApplicationObject(applicationName));

string FilterExp = "where Type =@Type and Name=@Name";

Skelta.Core.DS.SkeltaParameter param1 = new Skelta.Core.DS.SkeltaParameter("@Type", "XmlStorageType");

Skelta.Core.DS.SkeltaParameter param2 = new Skelta.Core.DS.SkeltaParameter("@Name", storageType);

System.Data.DataSet DsProvider = _Provider.GetMatchingRecords(FilterExp, param1, param2);

string s = "";

if (DsProvider.Tables[0].Rows.Count > 0)

{

s = DsProvider.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

}

return new Guid(s);

}

private string ParseXMLForData(string file)

{

TextWriter txt = new StringWriter();

StreamReader sReader = new System.IO.StreamReader(file);

System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sReader);

XmlDocument XDoc = new XmlDocument();

XDoc.Load(reader);

reader.Close();

sReader.Close();

StringReader stringReader1 = new StringReader(this.AddNameSpacePrefixIntoHolder(XDoc));

XmlTextReader xmlTextReader1 = new XmlTextReader(((TextReader)stringReader1));

XmlSchemaSet schemaSet = new XmlSchemaSet();

XmlSchemaInference schema = new XmlSchemaInference();

schemaSet = schema.InferSchema(xmlTextReader1);

foreach (XmlSchema s in schemaSet.Schemas())

{

s.Write(txt);

}

string xsdstring = txt.ToString();

return xsdstring;

}

private string AddNameSpacePrefixIntoHolder(XmlDocument oxmlDoc)

{

foreach (XmlNode xmlNode1 in oxmlDoc.ChildNodes)

{

if (xmlNode1.NamespaceURI.Length > 0)

this.AddNameSpaceHolder(xmlNode1.NamespaceURI, xmlNode1.Prefix);

if (xmlNode1.ChildNodes.Count > 0)

{

string string2 = this.FindNextNode(oxmlDoc, xmlNode1);

}

}

 return oxmlDoc.OuterXml;

}

private string FindNextNode(XmlDocument oxmlDoc, XmlNode oNode)

{

string string1 = null;

foreach (XmlNode xmlNode1 in oNode.ChildNodes)

{

if (xmlNode1.NamespaceURI.Length > 0)

{

this.AddNameSpaceHolder(xmlNode1.NamespaceURI, xmlNode1.Prefix);

if (xmlNode1.ChildNodes.Count > 0)

{

string string2 = this.FindNextNode(oxmlDoc, xmlNode1);

}

}

else

{

if (xmlNode1.ChildNodes.Count > 0)

{

string string3 = this.FindNextNode(oxmlDoc, xmlNode1);

}

continue;

}

}

return string1;

}

public void AddNameSpaceHolder(string NameSpaceURI, string Prefix)

{

Hashtable nameSpaceHolder = new Hashtable();

bool b1 = false;

NameSpaceInfo nameSpacePrefix1 = null;

Exception exception1 = null;

IEnumerator iEnumerator1 = null;

try

{

b1 = false;

if (nameSpaceHolder.Count <= 0)

{

nameSpacePrefix1 = new NameSpaceInfo();

nameSpacePrefix1.NameSpaceURI = NameSpaceURI;

nameSpacePrefix1.NameSpacePrefix = Prefix;

nameSpaceHolder.Add(Prefix, nameSpacePrefix1);

goto L_00DA;

}

try

{

iEnumerator1 = nameSpaceHolder.Values.GetEnumerator();

while (iEnumerator1.MoveNext())

{

nameSpacePrefix1 = ((NameSpaceInfo)iEnumerator1.Current);

}

}

finally

{

if (iEnumerator1 is IDisposable)

{

((IDisposable)iEnumerator1).Dispose();

}

}

L_0093:

{

}

if (b1)

{

return;

}

nameSpacePrefix1 = new NameSpaceInfo();

nameSpacePrefix1.NameSpaceURI = NameSpaceURI;

nameSpacePrefix1.NameSpacePrefix = Prefix;

if (!nameSpaceHolder.Contains(Prefix))

nameSpaceHolder.Add(Prefix, nameSpacePrefix1);

return;

L_00DA:

{

}

}

catch (Exception exception2)

{

exception1 = exception2;

throw new Exception(exception1.Message);

}

}

}

public class FILEWATCHER

{

public string PORTNAME;

public string REPOSITORY;

}

}

TitleResults for “How to create a CRG?”Also Available in