Ejemplo n.º 1
0
        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"]);
        }
Ejemplo n.º 2
0
        private static List <IWfProcessDescriptor> SaveProcessDescriptor(WfProcessImporterContext context)
        {
            List <IWfProcessDescriptor> result = new List <IWfProcessDescriptor>();

            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType = false;

            foreach (PackagePart part in context.ProcessDescParts)
            {
                XDocument            xmlDoc      = XDocument.Load(part.GetStream());
                IWfProcessDescriptor processDesp = (IWfProcessDescriptor)formatter.Deserialize(xmlDoc.Root);

                WfProcessDescriptorManager.SaveDescriptor(processDesp);

                IUser user = null;

                if (DeluxePrincipal.IsAuthenticated)
                {
                    user = DeluxeIdentity.CurrentUser;
                }

                WfProcessDescriptorInfoAdapter.Instance.UpdateImportTime(processDesp.Key, user);

                result.Add(processDesp);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType = false;

            string settings = formatter.Serialize(this).ToString();

            string updateSQL = string.Format("UPDATE USER_SETTINGS SET SETTINGS = {0} WHERE USER_ID = {1}",
                                             TSqlBuilder.Instance.CheckQuotationMark(settings, true),
                                             TSqlBuilder.Instance.CheckQuotationMark(this.UserID, true));

            using (DbContext context = DbContext.GetContext(ConnectionDefine.UserRelativeInfoConnectionName))
            {
                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    if (DbHelper.RunSql(updateSQL, ConnectionDefine.UserRelativeInfoConnectionName) == 0)
                    {
                        string insertSQL = string.Format("INSERT INTO USER_SETTINGS(USER_ID, SETTINGS) VALUES({0}, {1})",
                                                         TSqlBuilder.Instance.CheckQuotationMark(this.UserID, true),
                                                         TSqlBuilder.Instance.CheckQuotationMark(settings, true));

                        DbHelper.RunSql(insertSQL, ConnectionDefine.UserRelativeInfoConnectionName);
                    }

                    scope.Complete();
                }
            }

            CacheNotifyData notifyData = new CacheNotifyData(typeof(UserSettingsCache), this.UserID, CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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();
            }
        }
Ejemplo n.º 6
0
        public InvokeWebServiceJob LoadSingleData(IConnectiveSqlClause whereClause)
        {
            InvokeWebServiceJob result = null;

            if (whereClause.IsEmpty == false)
            {
                using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
                {
                    using (IDataReader dr = DbHelper.RunSqlReturnDR(string.Format(SingleData_InvokeWebService,
                                                                                  whereClause.ToSqlString(TSqlBuilder.Instance)), GetConnectionName()))
                    {
                        while (dr.Read())
                        {
                            result = new InvokeWebServiceJob();
                            ORMapping.DataReaderToObject(dr, result);
                            break;
                        }
                    }

                    if (result != null)
                    {
                        XElementFormatter formatter = new XElementFormatter();
                        formatter.OutputShortType = WorkflowSettings.GetConfig().OutputShortType;
                        XElement root = XElement.Parse(result.XmlData);
                        result.SvcOperationDefs = (WfServiceOperationDefinitionCollection)formatter.Deserialize(root);

                        result.InitJobBaseData(JobBaseAdapter.Instance.LoadSingleDataByJobID(whereClause));
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
        private static WfGlobalParameters LoadFromDB(string key)
        {
            string sql = string.Format("SELECT [PROPERTIES] FROM WF.GLOBAL_PARAMETERS WHERE {0}",
                                       GetWhereSqlClauseBuilder(key).ToSqlString(TSqlBuilder.Instance));

            WfGlobalParameters result = null;

            string properties = (string)DbHelper.RunSqlReturnScalar(sql, WorkflowSettings.GetConfig().ConnectionName);

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

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

                XElement root = XElement.Parse(properties);

                object deserializedData = formatter.Deserialize(root);

                if (deserializedData is PropertyValueCollection)
                {
                    result             = new WfGlobalParameters();
                    result.Key         = key;
                    result._Properties = (PropertyValueCollection)deserializedData;
                }
                else
                {
                    result = (WfGlobalParameters)deserializedData;
                }
            }

            return(result);
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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());
        }
Ejemplo n.º 11
0
        internal static XElementFormatter CreateFormatter()
        {
            XElementFormatter formatter = new XElementFormatter();

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

            return(formatter);
        }
Ejemplo n.º 12
0
        protected override void BeforeInnerUpdate(InvokeWebServiceJob data, Dictionary <string, object> context)
        {
            base.BeforeInnerUpdate(data, context);

            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType = WorkflowSettings.GetConfig().OutputShortType;
            data.XmlData = formatter.Serialize(data.SvcOperationDefs).ToString();
        }
Ejemplo n.º 13
0
        internal static IWfProcessDescriptor DeserializeXElementToProcessDescriptor(XElement root)
        {
            XElementFormatter formatter = CreateFormatter();

            WfProcessDescriptor procDesp = (WfProcessDescriptor)formatter.Deserialize(root);

            procDesp.MergeDefinedProperties();

            return(procDesp);
        }
Ejemplo n.º 14
0
        public static WfProcessDescriptorInfo FromProcessDescriptor(IWfProcessDescriptor processDesp)
        {
            XElementFormatter formatter = new XElementFormatter();

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

            XElement root = formatter.Serialize(processDesp);

            return(FromProcessDescriptor(processDesp, root));
        }
Ejemplo n.º 15
0
        public IWfProcessDescriptor Clone()
        {
            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType            = WorkflowSettings.GetConfig().OutputShortType;
            formatter.FieldCanXElementSerialize += new FieldCanXElementSerializeHandler(formatter_FieldCanXElementSerialize);

            XElement root = formatter.Serialize(this);

            return((IWfProcessDescriptor)formatter.Deserialize(root));
        }
Ejemplo n.º 16
0
        public void SaveDescriptor(IWfProcessDescriptor processDesp)
        {
            processDesp.NullCheck("processDesp");

            XElementFormatter formatter = WfProcessDescriptorManager.CreateFormatter();

            XElement xml = formatter.Serialize(processDesp);

            SaveXml(processDesp, xml);

            SendCacheNotifyByProcessKey(processDesp.Key);
        }
        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();
            }
        }
Ejemplo n.º 18
0
        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);
            }
        }
Ejemplo n.º 19
0
        /// <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();
            }
        }
Ejemplo n.º 20
0
        public void SimpleProcessRuntimeSerializeTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            if (process.Activities != null)
            {
                foreach (var activity in process.Activities)
                {
                    if (activity.Descriptor != process.Descriptor.InitialActivity)
                    {
                        Assert.IsTrue(activity.Status == WfActivityStatus.NotRunning);
                        WfTransferParams transferPara = new WfTransferParams(activity.Descriptor);
                        process.MoveTo(transferPara);
                    }
                }
            }

            XElementFormatter formatter = new XElementFormatter();

            XElement root = formatter.Serialize(process);

            Console.WriteLine(root.ToString());

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

            Assert.IsTrue(clonedProcess.Status == WfProcessStatus.Completed);

            for (int i = 0; i < clonedProcess.Activities.Count; i++)
            {
                Assert.IsTrue(clonedProcess.Activities[i].Status == WfActivityStatus.Completed);

                if (i < clonedProcess.Activities.Count - 1)
                {
                    Assert.AreEqual(clonedProcess.Activities[i].Descriptor.ToTransitions[0], clonedProcess.Activities[i + 1].Descriptor.FromTransitions[0]);
                }
            }

            Assert.IsNotNull(clonedProcess.Descriptor.Activities[process.Descriptor.InitialActivity.Key], "验证反序列化后集合字典的完整性");

            XElement reRoot = formatter.Serialize(clonedProcess);

            //31000是否允许被撤回默认值不同true false

            Assert.AreEqual(root.ToString(), reRoot.ToString());


            IWfProcess reClonedProcess = (IWfProcess)formatter.Deserialize(reRoot);

            Assert.AreEqual(clonedProcess.ToString(), reClonedProcess.ToString());
        }
Ejemplo n.º 21
0
        private static TxProcess GetDeserilizedProcess(string data)
        {
            TxProcess process = null;

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

                XElementFormatter formatter = new XElementFormatter();

                process = (TxProcess)formatter.Deserialize(root);
            }

            return(process);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        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]);
        }
Ejemplo n.º 27
0
        public void ProcessSerializeExecutionTimeTest()
        {
            IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            int totalProcesses = 40;

            //准备流程实例
            List <IWfProcess> processes = ProcessTestHelper.StartupMultiProcesses(processDesc, totalProcesses);

            ProcessTestHelper.OutputExecutionTime(() =>
            {
                foreach (IWfProcess process in processes)
                {
                    XElementFormatter formatter = new XElementFormatter();
                    XElement root = formatter.Serialize(process);
                }
            },
                                                  string.Format("序列化{0}个流程", totalProcesses));
        }
        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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
        }