protected void parseBtn_Click(object sender, EventArgs e)
		{
			try
			{
				PrepareUploadedFile();
				this.processDespText.Text.IsNotEmpty().FalseThrow("没有提供流程描述信息");

				XElement root = XElement.Parse(this.processDespText.Text);

				XElementFormatter formatter = new XElementFormatter();

				IWfProcess process = (IWfProcess)formatter.Deserialize(root);

				StringBuilder strB = new StringBuilder();

				using (StringWriter writer = new StringWriter(strB))
				{
					OutputProcessInfo(process, writer);
				}

				ShowMessage(strB.ToString());
			}
			catch (System.Exception ex)
			{
				ShowError(ex);
			}
			finally
			{
				NormalResultText();
			}
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			string sProcessKeys = Request["wfProcessKeys"].ToString();
			string[] arrProcessKeys = sProcessKeys.Split(',');

			var xDoc = new XDocument(
				new XDeclaration("1.0", "utf-8", "true"),
				new XElement("WorkflowProcesses")
				);

			for (int i = 0; i < arrProcessKeys.Length; i++)
			{
				XElementFormatter formatter = new XElementFormatter();

				formatter.OutputShortType = false;
				WfProcessDescriptor processDesc = (WfProcessDescriptor)WfProcessDescriptorManager.LoadDescriptor(arrProcessKeys[i]);
				XElement xeWfProcess = formatter.Serialize(processDesc);

				xDoc.Element("WorkflowProcesses").Add(xeWfProcess);
			}

			Response.ContentType = "text/xml";
			Response.ContentEncoding = Encoding.UTF8;
			if (arrProcessKeys.Count() > 1)
				Response.AppendHeader("content-disposition", "attachment;fileName=ExportedProcess.xml");
			else
				Response.AppendHeader("content-disposition",  string.Format("attachment;fileName={0}.xml", HttpUtility.UrlEncode(arrProcessKeys[0])));
			//"attachment;fileName=ExportedProcess.xml");

			xDoc.Save(Response.OutputStream);
		}
		protected void confirmButton_Click(object sender, EventArgs e)
		{
			string sWfProcess = ttaWfProcess.Value;
			ExceptionHelper.CheckStringIsNullOrEmpty(sWfProcess, "流程模板的XML描述信息");

			XElementFormatter formatter = new XElementFormatter();
			try
			{
				var xmlDoc = XDocument.Load(new StringReader(sWfProcess));
				var wfProcesses = xmlDoc.Descendants("Root");
				foreach (var wfProcess in wfProcesses)
				{
					IWfProcessDescriptor wfProcessDesc = (IWfProcessDescriptor)formatter.Deserialize(wfProcess);
					saveWfProcess(wfProcessDesc);
				}
				//Page.ClientScript.RegisterStartupScript(this.GetType(), "returnRole",
				//string.Format("window.returnValue = 'resultData'; top.close();"),
				//true);

				WebUtility.ResponseShowClientMessageScriptBlock("保存成功!", string.Empty, "提示");
				WebUtility.ResponseCloseWindowScriptBlock();

			}
			catch (Exception ex)
			{
				WebUtility.ResponseShowClientErrorScriptBlock(ex.Message, ex.StackTrace, "错误");
			}
			finally
			{
				Response.End();
			}
		}
		public void PropertyValidatorCollectionSerializeTest()
		{
			PropertyValidatorDescriptorCollection pvDespCollection = PreparePropertyValidatorDescriptorCollection();

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(pvDespCollection);

			Console.WriteLine(root.ToString());

			PropertyValidatorDescriptorCollection newpvDespCollection = (PropertyValidatorDescriptorCollection)formatter.Deserialize(root);

			XElement rootReserialized = formatter.Serialize(newpvDespCollection);

			Assert.AreEqual(root.ToString(), rootReserialized.ToString());
			Assert.AreEqual(pvDespCollection.Count, newpvDespCollection.Count);
		}
		public void PropertyValueCollectionSerializeTest()
		{
			PropertyValueCollection pvc = new PropertyValueCollection();

			pvc.Add(PreparePropertyValue());

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(pvc);

			Console.WriteLine(root.ToString());

			PropertyValueCollection newPvc = (PropertyValueCollection)formatter.Deserialize(root);

			Assert.AreEqual(pvc.Count, newPvc.Count);
			Assert.AreEqual(pvc[0].StringValue, newPvc[pvc[0].Definition.Name].StringValue);
		}
		public void SimpleProcessDescriptorSerializeTest()
		{
			IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(processDesp);

			Console.WriteLine(root.ToString());

			IWfProcessDescriptor clonedProcessDesp = (IWfProcessDescriptor)formatter.Deserialize(root);

			Assert.IsTrue(clonedProcessDesp.InitialActivity.CanReachTo(clonedProcessDesp.CompletedActivity));
			Assert.AreEqual(clonedProcessDesp, clonedProcessDesp.InitialActivity.Process);
			Assert.AreEqual(clonedProcessDesp, clonedProcessDesp.CompletedActivity.Process);
			//因增加了一个活动点,此处这样比较断言肯定失败.故此将其注销掉
			//Assert.AreEqual(clonedProcessDesp.InitialActivity.ToTransitions[0], clonedProcessDesp.CompletedActivity.FromTransitions[0]);
		}
		public void DateTimePropertyValueSerializeTest()
		{
			PropertyValue pv = PrepareDateTimePropertyValue();

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(pv);

			Console.WriteLine(root.ToString());

			PropertyValue newPropertyValue = (PropertyValue)formatter.Deserialize(root);

			XElement rootReserialized = formatter.Serialize(newPropertyValue);

			Assert.AreEqual(root.ToString(), rootReserialized.ToString());
			Assert.AreEqual(pv.StringValue, newPropertyValue.StringValue);
			Assert.AreEqual(pv.Definition.Name, newPropertyValue.Definition.Name);
		}
		public void PropertyValueSerializeTest()
		{
			PropertyValue pv = PreparePropertyValue();

			XElementFormatter formatter = new XElementFormatter();
			XmlSerializeContext context = new XmlSerializeContext();
			XElement root = new XElement("root");
			pv.Serialize(root, context);

			Console.WriteLine(root.ToString());

			XmlDeserializeContext dcontext = new XmlDeserializeContext();
			PropertyValue newPropertyValue = new PropertyValue(new PropertyDefine());
			newPropertyValue.Deserialize(root, dcontext);

			//Assert.AreEqual(root.ToString(), rootReserialized.ToString());
			Assert.AreEqual(pv.StringValue, newPropertyValue.StringValue);
			Assert.AreEqual(pv.Definition.Name, newPropertyValue.Definition.Name);
		}
		public void PropertyValidatorParameterDescriptorSerializeTest()
		{
			PropertyValidatorParameterDescriptor pvpd = PreparePropertyValidatorParameterDateTimeDescriptor();

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(pvpd);

			Console.WriteLine(root.ToString());

			PropertyValidatorParameterDescriptor newPropertyValue = (PropertyValidatorParameterDescriptor)formatter.Deserialize(root);

			XElement rootReserialized = formatter.Serialize(newPropertyValue);

			Assert.AreEqual(root.ToString(), rootReserialized.ToString());
			Assert.AreEqual(pvpd.ParamValue, newPropertyValue.ParamValue);
			Assert.AreEqual(pvpd.ParamName, newPropertyValue.ParamName);
			Assert.AreEqual(pvpd.DataType, newPropertyValue.DataType);
		}
		public void PropertyValidatorSerializeTest()
		{
			PropertyValidatorDescriptor pv = PreparePropertyValidatorDescriptor();

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(pv);

			Console.WriteLine(root.ToString());

			PropertyValidatorDescriptor newPropertyValue = (PropertyValidatorDescriptor)formatter.Deserialize(root);

			XElement rootReserialized = formatter.Serialize(newPropertyValue);

			Assert.AreEqual(root.ToString(), rootReserialized.ToString());
			Assert.AreEqual(pv.Tag, newPropertyValue.Tag);
			Assert.AreEqual(pv.TypeDescription, newPropertyValue.TypeDescription);
			Assert.AreEqual(pv.Name, newPropertyValue.Name);
			Assert.AreEqual(pv.Parameters.Count, newPropertyValue.Parameters.Count);
		}
		public void LruCollectionSerializationText()
		{
			TestLruCollection list = new TestLruCollection(4);

			for (int i = 0; i < 5; i++)
				list.Add("S" + i);

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(list);

			Console.WriteLine(root.ToString());

			TestLruCollection deserializedList = (TestLruCollection)formatter.Deserialize(root);

			Assert.AreEqual(list.Count, deserializedList.Count);

			for (int i = 0; i < list.Count; i++)
				Assert.AreEqual(list[i], deserializedList[i]);
		}
		public void ProcessRequest(HttpContext context)
		{
			string roleID = context.Request["roleID"];
			if (string.IsNullOrEmpty(context.Request["roleID"]) == false)
			{
				SOARole role = new SOARole() { ID = roleID };

				SOARolePropertyDefinitionCollection rowsColl = SOARolePropertyDefinitionAdapter.Instance.LoadByRole(role);

				XDocument rolePropertiesDoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"), new XElement("SOARoleProperties"));

				XElementFormatter formatter = new XElementFormatter();

				formatter.OutputShortType = false;

				XElement xeRoleProperties = formatter.Serialize(rowsColl);

				rolePropertiesDoc.Element("SOARoleProperties").Add(xeRoleProperties);

				context.Response.Clear();
				context.Response.ContentType = "text/xml";
				context.Response.ContentEncoding = Encoding.UTF8;

				string fileName = string.Empty;

				if (context.Request["roleName"].IsNotEmpty())
					fileName = string.Format("{0}", context.Request["roleName"]);

				if (fileName.IsNullOrEmpty() && context.Request["roleCode"].IsNotEmpty())
					fileName = string.Format("{0}", context.Request["roleCode"]);

				if (fileName.IsNullOrEmpty())
					fileName = roleID;

				fileName += "_Properties";

				context.Response.AppendHeader("content-disposition", string.Format("attachment;fileName={0}.xml", context.Response.EncodeFileNameInContentDisposition(fileName)));
				rolePropertiesDoc.Save(context.Response.OutputStream);
				context.Response.End();
			}
		}
        private void InitMatrixDefinitions(IEnumerable<PackagePart> matrixDefParts)
        {
            XElementFormatter formatter = new XElementFormatter();
            formatter.OutputShortType = false;

            foreach (PackagePart part in matrixDefParts)
            {
                XDocument xDoc = XDocument.Load(part.GetStream());
                WfMatrixDefinition matrixDef = (WfMatrixDefinition)formatter.Deserialize(xDoc.Root);

                this.MatrixDefinitions.Add(matrixDef.Key, matrixDef);
            }
        }
		public void ProcessSerializeTest()
		{
			IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

			WfProcessStartupParams startupParams = new WfProcessStartupParams();
			startupParams.ProcessDescriptor = processDesc;
			IWfProcess process = WfRuntime.StartWorkflow(startupParams);
			((WfProcess)process).ResourceID = UuidHelper.NewUuidString();

			WfProcessContext context = process.Context;
			context.Add("UCC", "the same");

			XElementFormatter formatter = new XElementFormatter();

			//formatter.OutputShortType = false;

			XElement root = formatter.Serialize(process);

			Console.WriteLine(root.ToString());

			IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root);

			Assert.IsNotNull(clonedProcess.Context["UCC"]);
			Assert.AreEqual(process.Context.Count, clonedProcess.Context.Count);
			Assert.AreEqual(process.Context["UCC"], clonedProcess.Context["UCC"]);
		}
		public void ActivitySerializeTest()
		{
			IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

			WfProcessStartupParams startupParams = new WfProcessStartupParams();
			startupParams.ProcessDescriptor = processDesc;
			IWfProcess process = WfRuntime.StartWorkflow(startupParams);

			Sky sky = new Sky();
			sky.air = "清新";
			sky.Cloud = 1;
			Sky space = new Sky();
			space.air = "干净";
			space.Cloud = 1;

			process.InitialActivity.Context.Add("DDO", sky);
			process.InitialActivity.Context.Add("DFO", space);

			XElementFormatter formatter = new XElementFormatter();
			XElement root = formatter.Serialize(process);

			Console.WriteLine(root.ToString());

			IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root);

			Assert.IsNotNull(clonedProcess.InitialActivity.Context["DDO"]);
			Assert.AreEqual(process.InitialActivity.Context.Count, clonedProcess.InitialActivity.Context.Count);
			Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).air);
			Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).Cloud);
			Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).air);
			Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).Cloud);
		}
		public void WfExternalUserTest()
		{
			WfExternalUser externalUser = new WfExternalUser();
			externalUser.Key = "user0";
			externalUser.Name = "zLing";
			externalUser.Gender = Gender.Female;
			externalUser.Email = "*****@*****.**";
			externalUser.MobilePhone = "13552630000";
			externalUser.Phone = "0409987";
			externalUser.Title = "programer";

			IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

			processDesc.ExternalUsers.Add(externalUser);

			WfProcessStartupParams startupParams = new WfProcessStartupParams();
			startupParams.ProcessDescriptor = processDesc;
			IWfProcess process = WfRuntime.StartWorkflow(startupParams);

			XElementFormatter formatter = new XElementFormatter();

			XElement rootProc = formatter.Serialize(process);
			IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(rootProc);

			XElement resultProc = formatter.Serialize(clonedProcess);

			Assert.AreEqual(processDesc.ExternalUsers[0].Name, clonedProcess.Descriptor.ExternalUsers[0].Name);
			Assert.AreEqual(processDesc.ExternalUsers[0].Gender, clonedProcess.Descriptor.ExternalUsers[0].Gender);

			Assert.AreEqual(rootProc.ToString(), resultProc.ToString());
		}
        /// <summary>
        /// 上传属性定义
        /// </summary>
        /// <param name="file"></param>
        /// <param name="result"></param>
        protected void ImportSOARole_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (string.Compare(fileType, ".xml", true) == 0)
            {
                StringBuilder logger = new StringBuilder();
                try
                {
                    CheckEditMode();

                    var xmlDoc = XDocument.Load(file.InputStream);
                    var wfProcesses = xmlDoc.Descendants("Root");
                    XElementFormatter formatter = new XElementFormatter();
                    UploadProgressStatus status = new UploadProgressStatus();

                    status.CurrentStep = 1;
                    status.MinStep = 0;
                    status.MaxStep = wfProcesses.Count() + 1;
                    logger.AppendFormat("开始导入角色属性定义...\n", file.FileName, status.MaxStep);

                    SOARole role = new SOARole { ID = this.DefinitionID };

                    SOARolePropertyDefinitionAdapter.Instance.Delete(role);

                    foreach (var wfProcess in wfProcesses)
                    {
                        SOARolePropertyDefinitionCollection rowsColl = (SOARolePropertyDefinitionCollection)formatter.Deserialize(wfProcess);

                        SOARolePropertyDefinitionAdapter.Instance.Update(role, rowsColl);

                        logger.Append("保存成功...\n");

                        status.CurrentStep++;
                        status.Response();
                    }
                    logger.AppendFormat("导入完成!", file.FileName);
                }
                catch (Exception ex)
                {
                    logger.AppendFormat("导入错误,{0},错误堆栈:{1}", ex.Message, ex.StackTrace);
                }

                result.DataChanged = true;
                result.CloseWindow = false;
                result.ProcessLog = logger.ToString();
            }
        }
        /// <summary>
        /// 从数据库中加载
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private static UserRecentDataCategory LoadFromDB(string userID, string category)
        {
            userID.CheckStringIsNullOrEmpty("userID");
            category.CheckStringIsNullOrEmpty("category");

            string sql = string.Format("SELECT DATA FROM USER_RECENT_DATA WHERE USER_ID = {0} AND CATEGORY = {1}",
                TSqlBuilder.Instance.CheckQuotationMark(userID, true),
                TSqlBuilder.Instance.CheckQuotationMark(category, true)
                );

            UserRecentDataCategory result = null;

            string settings = (string)DbHelper.RunSqlReturnScalar(sql, ConnectionDefine.UserRelativeInfoConnectionName);

            if (settings.IsNotEmpty())
            {
                XElementFormatter formatter = new XElementFormatter();

                formatter.OutputShortType = false;

                XElement root = XElement.Parse(settings);

                result = (UserRecentDataCategory)formatter.Deserialize(root);
            }

            return result;
        }
        internal static XElementFormatter CreateFormatter()
        {
            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType = WorkflowSettings.GetConfig().OutputShortType;

            return formatter;
        }
        public void ProcessWithReturnLineSerializationTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithReturnLine();

            XElementFormatter formatter = new XElementFormatter();

            XElement root = formatter.Serialize(processDesp);

            Console.WriteLine(root.ToString());
            processDesp = (IWfProcessDescriptor)formatter.Deserialize(root);

            IWfActivityDescriptor normalActDesp = processDesp.Activities["NormalActivity"];

            ToTransitionsDescriptorCollection transitions = normalActDesp.ToTransitions;

            foreach (string key in transitions.GetAllKeys())
            {
                Assert.IsTrue(key.IsNotEmpty());

                IWfTransitionDescriptor transition = transitions[key];

                Assert.AreEqual(key, transition.Key);
            }
        }
		public void SimpleProcessDescriptorWithResourceSerializeTest()
		{
			IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

			processDesp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object));

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(processDesp);

			Console.WriteLine(root.ToString());

			IWfProcessDescriptor clonedProcessDesp = (IWfProcessDescriptor)formatter.Deserialize(root);

			Assert.IsTrue(clonedProcessDesp.InitialActivity.CanReachTo(clonedProcessDesp.CompletedActivity));
			Assert.AreEqual(processDesp.InitialActivity.Resources.Count, clonedProcessDesp.InitialActivity.Resources.Count);

			Assert.AreEqual(clonedProcessDesp, clonedProcessDesp.InitialActivity.Process);
			Assert.AreEqual(clonedProcessDesp, clonedProcessDesp.CompletedActivity.Process);
		}
		private static WfServiceOperationDefinitionCollection GetDeserilizedServiceDefs(string data)
		{
			WfServiceOperationDefinitionCollection result = null;

			if (data.IsNotEmpty())
			{
				XElement root = XElement.Parse(data);

				XElementFormatter formatter = new XElementFormatter();

				result = (WfServiceOperationDefinitionCollection)formatter.Deserialize(root);
			}

			return result;
		}
Exemple #23
0
        private static IWfProcess DeserializeProcess(XElement data)
        {
            XElementFormatter formatter = new XElementFormatter();

            return (IWfProcess)formatter.Deserialize(data);
        }
Exemple #24
0
        private static XElement SerializeProcess(IWfProcess process)
        {
            XElementFormatter formatter = new XElementFormatter();

            return formatter.Serialize(process);
        }
		public void SimpleProcessDescriptorWithDeptResSerializeTest()
		{
			WfConverterHelper.RegisterConverters();

			WfProcessDescriptor processDesp = (WfProcessDescriptor)WfProcessTestCommon.CreateSimpleProcessDescriptor();

			IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;
			IOrganization orga = user.Parent;
			WfDepartmentResourceDescriptor deptResuDesp = new WfDepartmentResourceDescriptor(orga);

			processDesp.InitialActivity.Resources.Add(deptResuDesp);

			string result = JSONSerializerExecute.Serialize(processDesp);

			processDesp = JSONSerializerExecute.Deserialize<WfProcessDescriptor>(result);

			XElementFormatter formatter = new XElementFormatter();

			XElement root = formatter.Serialize(processDesp);

			Console.WriteLine(root.ToString());

			IWfProcessDescriptor clonedProcessDesp = (IWfProcessDescriptor)formatter.Deserialize(root);

		}
		public void WfActivityMatrixResourceSerializationTest()
		{
			IWfProcessDescriptor processDesp = WfProcessTestCommon.GetDynamicProcessDesp();

			XElementFormatter formatter = new XElementFormatter();

			XElement rootProc = formatter.Serialize(processDesp);
			IWfProcessDescriptor clonedProcessDesp = (IWfProcessDescriptor)formatter.Deserialize(rootProc);

			IWfActivityDescriptor normalActDesp = processDesp.Activities["NormalActivity"];
			IWfActivityDescriptor clonedNormalActDesp = clonedProcessDesp.Activities["NormalActivity"];

			Assert.IsNotNull(normalActDesp);
			Assert.IsNotNull(clonedNormalActDesp);

			WfActivityMatrixResourceDescriptor matrixResource = (WfActivityMatrixResourceDescriptor)normalActDesp.Resources[0];
			WfActivityMatrixResourceDescriptor clonedMatrixResource = (WfActivityMatrixResourceDescriptor)clonedNormalActDesp.Resources[0];

			Assert.AreEqual(matrixResource.PropertyDefinitions.Count, clonedMatrixResource.PropertyDefinitions.Count);
			Assert.AreEqual(matrixResource.Rows.Count, clonedMatrixResource.Rows.Count);
		}
		private static string GetSerilizedServiceDefs(WfServiceOperationDefinitionCollection svcOperationDefs)
		{
			XElementFormatter formatter = new XElementFormatter();

			return formatter.Serialize(svcOperationDefs).ToString();
		}
        /// <summary>
        /// 从数据库中加载
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private static UserRecentData LoadFromDB(string userID)
        {
            string sql = string.Format("SELECT CATEGORY,DATA FROM USER_RECENT_DATA WHERE USER_ID = {0}",
                TSqlBuilder.Instance.CheckQuotationMark(userID, true));

            UserRecentData result = new UserRecentData() { UserID = userID };
            result.InitFromConfiguration();

            using (DbContext dbi = DbContext.GetContext(ConnectionDefine.UserRelativeInfoConnectionName))
            {
                Database db = DatabaseFactory.Create(dbi);

                using (var dr = db.ExecuteReader(System.Data.CommandType.Text, sql))
                {
                    while (dr.Read())
                    {
                        var catDataString = dr.GetString(1);

                        if (catDataString != null)
                        {
                            XElementFormatter formatter = new XElementFormatter();

                            formatter.OutputShortType = false;

                            XElement root = XElement.Parse(catDataString);

                            var loadedCatData = (UserRecentDataCategory)formatter.Deserialize(root);

                            result.Categories[(string)dr.GetString(0)].ImportValues(loadedCatData);
                        }
                    }
                }
            }

            return result;
        }
		private static Dictionary<string, object> GetDeserilizedContextData(string contextData)
		{
			Dictionary<string, object> result = new Dictionary<string, object>();

			if (contextData.IsNotEmpty())
			{
				XElement root = null;

				if (TryParseXElement(contextData, out root))
				{
					XElementFormatter formatter = new XElementFormatter();
					result = (Dictionary<string, object>)formatter.Deserialize(root);
				}
				else
					result = JSONSerializerExecute.Deserialize<Dictionary<string, object>>(contextData);
			}

			return result;
		}
        /// <summary>
        /// 解析上传的xml文件,返回解析日志
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private StringBuilder ParseXmlFile(HttpPostedFile file)
        {
            StringBuilder logger = new StringBuilder();
            try
            {
                var xmlDoc = XDocument.Load(file.InputStream);
                var wfProcesses = xmlDoc.Descendants("Root");
                XElementFormatter formatter = new XElementFormatter();
                UploadProgressStatus status = new UploadProgressStatus();

                status.CurrentStep = 1;
                status.MinStep = 1;
                status.MaxStep = wfProcesses.Count() + 1;
                logger.AppendFormat("开始导入,共发现{1}个流程模板...\n", file.FileName, status.MaxStep);

                foreach (var wfProcess in wfProcesses)
                {
                    IWfProcessDescriptor wfProcessDesc = (IWfProcessDescriptor)formatter.Deserialize(wfProcess);

                    using (TransactionScope tran = TransactionScopeFactory.Create())
                    {
                        WfProcessDescHelper.SaveWfProcess(wfProcessDesc);
                        tran.Complete();
                    }

                    logger.AppendFormat("	{0}保存成功...\n", wfProcessDesc.Key);

                    status.CurrentStep++;
                    status.Response();
                }
                logger.AppendFormat("导入完成!", file.FileName);
            }
            catch (Exception ex)
            {
                logger.AppendFormat("导入错误,{0},错误堆栈:{1}", ex.Message, ex.StackTrace);
            }

            return logger;
        }