コード例 #1
0
        void executor_SaveApplicationData(WfExecutorDataContext dataContext)
        {
            if (Scene.Current.SceneID == "First_Default")
            {
                var process    = dataContext.CurrentProcess;
                var properties = this.propertyForm.Properties;

                var imgProStr = properties.GetValue("Image", "");
                if (imgProStr != "")
                {
                    ImageProperty imgPro = JSONSerializerExecute.Deserialize <ImageProperty>(imgProStr);
                    if (imgPro.Changed)
                    {
                        ImagePropertyAdapter.Instance.UpdateWithContent(imgPro);
                        properties.SetValue("Image", JSONSerializerExecute.Serialize(imgPro));
                    }
                }

                var deltaData = MaterialControl.GetCommonDeltaMaterials();
                MaterialAdapter.Instance.SaveCommonDeltaMaterials(deltaData);

                //DynamicFormDataAdapter.Instance.Update(this.ViewData.Data);
                this.ViewData.Data.Properties          = properties;
                process.RootProcess.Context["appData"] = SerializationHelper.SerializeObjectToString(this.ViewData.Data, SerializationFormatterType.Binary);
            }
        }
コード例 #2
0
        /// <summary>
        /// 将ClientState字符串的信息加载到ClientState中
        /// </summary>
        /// <remarks>
        /// 将ClientState字符串的信息加载到ClientState中
        /// </remarks>
        /// <param name="clientState">ClientState字符串</param>
        protected override void LoadClientState(string clientState)
        {
            if (clientState == null || clientState == "null")
            {
                return;
            }

            object[] foArray = JSONSerializerExecute.Deserialize <object[]>(clientState);

            if (null != foArray && foArray.Length > 0)
            {
                OguDataCollection <IOguObject> objs =
                    (OguDataCollection <IOguObject>)JSONSerializerExecute.DeserializeObject(foArray[0], typeof(OguDataCollection <IOguObject>));

                this._selectedOuUserData = objs;

                if (foArray.Length > 1 && null != foArray[1])
                {
                    this.Text = foArray[1].ToString();
                }
                else
                {
                    this.Text = "";
                }
            }
            else
            {
                this.SelectedOuUserData = new OguDataCollection <IOguObject>();
            }
        }
コード例 #3
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            EditorParamsDefine paDefine = new EditorParamsDefine();

            foreach (KeyValuePair <string, object> item in dictionary)
            {
                if (string.Compare(item.Key, "serverControlProperties", true) == 0)
                {
                    string strServerControlProperties = DictionaryHelper.GetValue(dictionary, "serverControlProperties", string.Empty);
                    if (strServerControlProperties.IsNotEmpty())
                    {
                        List <ControlPropertyDefine> desControlProperties = JSONSerializerExecute.Deserialize <List <ControlPropertyDefine> >(strServerControlProperties);
                        desControlProperties.ForEach(pcd =>
                        {
                            paDefine.ServerControlProperties.Add(pcd);
                        });
                    }
                }
                else
                {
                    paDefine.Add(item.Key, item.Value != null ? item.Value.ToString() : string.Empty);
                }
            }

            return(paDefine);
        }
コード例 #4
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            ClientGridColumn column = new ClientGridColumn();

            column.DataField       = DictionaryHelper.GetValue(dictionary, "dataField", string.Empty);
            column.HeaderText      = DictionaryHelper.GetValue(dictionary, "headerText", string.Empty);
            column.HeaderTips      = DictionaryHelper.GetValue(dictionary, "headerTips", string.Empty);
            column.HeaderTipsStyle = DictionaryHelper.GetValue(dictionary, "headerTipsStyle", "{color:Red}");
            column.SortExpression  = DictionaryHelper.GetValue(dictionary, "sortExpression", string.Empty);
            column.SelectColumn    = DictionaryHelper.GetValue(dictionary, "selectColumn", false);
            column.ShowSelectAll   = DictionaryHelper.GetValue(dictionary, "showSelectAll", false);

            column.DataType              = DictionaryHelper.GetValue(dictionary, "dataType", DataType.String);
            column.MaxLength             = DictionaryHelper.GetValue(dictionary, "maxLength", 0);
            column.FormatString          = DictionaryHelper.GetValue(dictionary, "formatString", string.Empty);
            column.EditorStyle           = DictionaryHelper.GetValue(dictionary, "editorStyle", string.Empty);
            column.EditorTooltips        = DictionaryHelper.GetValue(dictionary, "editorTooltips", string.Empty);
            column.EditorReadOnly        = DictionaryHelper.GetValue(dictionary, "editorReadOnly", false);
            column.EditorEnabled         = DictionaryHelper.GetValue(dictionary, "editorEnabled", true);
            column.Visible               = DictionaryHelper.GetValue(dictionary, "visible", true);
            column.IsDynamicColumn       = DictionaryHelper.GetValue(dictionary, "isDynamicColumn", false);
            column.AutoBindingValidation = DictionaryHelper.GetValue(dictionary, "autoBindingValidation", false);
            column.IsFixedLine           = DictionaryHelper.GetValue(dictionary, "isFixedLine", false);
            column.IsStatistic           = DictionaryHelper.GetValue(dictionary, "isStatistic", false);

            if (dictionary.ContainsKey("editTemplate"))
            {
                column.EditTemplate = JSONSerializerExecute.Deserialize <ClientGridColumnEditTemplate>(dictionary["editTemplate"]);
            }

            return(column);
        }
コード例 #5
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientUserOperationLog log = new WfClientUserOperationLog();

            log.ID = dictionary.GetValue("id", 0);

            log.ResourceID   = dictionary.GetValue("resourceID", string.Empty);
            log.ProcessID    = dictionary.GetValue("processID", string.Empty);
            log.ActivityID   = dictionary.GetValue("activityID", string.Empty);
            log.ActivityName = dictionary.GetValue("activityName", string.Empty);

            log.Subject = dictionary.GetValue("subject", string.Empty);

            log.ApplicationName = dictionary.GetValue("applicationName", string.Empty);
            log.ProgramName     = dictionary.GetValue("programName", string.Empty);

            log.OperationName        = dictionary.GetValue("operationName", string.Empty);
            log.OperationDescription = dictionary.GetValue("operationDescription", string.Empty);
            log.OperationType        = dictionary.GetValue("operationType", WfClientOperationType.Update);
            log.OperationDateTime    = dictionary.GetValue("operationDateTime", new Nullable <DateTime>());

            log.CorrelationID     = dictionary.GetValue("correlationID", string.Empty);
            log.HttpContextString = dictionary.GetValue("httpContextString", string.Empty);

            log.Operator      = JSONSerializerExecute.Deserialize <WfClientUser>(dictionary.GetValue("operator", (object)null));
            log.RealUser      = JSONSerializerExecute.Deserialize <WfClientUser>(dictionary.GetValue("realUser", (object)null));
            log.TopDepartment = JSONSerializerExecute.Deserialize <WfClientOrganization>(dictionary.GetValue("topDepartment", (object)null));

            return(log);
        }
コード例 #6
0
        protected void bT_Click(object sender, EventArgs e)
        {
            var imgProStr = propertyGrid.Properties.GetValue("Image1", "");

            if (imgProStr != "")
            {
                ImageProperty imgPro = JSONSerializerExecute.Deserialize <ImageProperty>(imgProStr);
                if (imgPro.Changed)
                {
                    ImagePropertyAdapter.Instance.UpdateWithContent(imgPro);
                    propertyGrid.Properties.SetValue("Image1", JSONSerializerExecute.Serialize(imgPro));
                }
            }

            imgProStr = propertyGrid.Properties.GetValue("Image2", "");
            if (imgProStr != "")
            {
                ImageProperty imgPro = JSONSerializerExecute.Deserialize <ImageProperty>(imgProStr);
                if (imgPro.Changed)
                {
                    ImagePropertyAdapter.Instance.UpdateWithContent(imgPro);
                    propertyGrid.Properties.SetValue("Image2", JSONSerializerExecute.Serialize(imgPro));
                }
            }
        }
コード例 #7
0
        public void ClientProcessWithWithActivityMatrixResourceDescriptorSerializationTest()
        {
            WfClientJsonConverterHelper.Instance.RegisterConverters();

            WfClientProcessDescriptor processDesp = ProcessDescriptorHelper.CreateClientProcessWithActivityMatrixResourceDescriptor();
            string data = JSONSerializerExecute.Serialize(processDesp);

            Console.WriteLine(data);

            WfClientProcessDescriptor deserialized = JSONSerializerExecute.Deserialize <WfClientProcessDescriptor>(data);

            Assert.AreEqual(processDesp.Key, deserialized.Key);
            Assert.AreEqual(processDesp.Activities.Count, deserialized.Activities.Count);
            Assert.AreEqual(processDesp.InitialActivity.Key, deserialized.InitialActivity.Key);
            Assert.AreEqual(processDesp.CompletedActivity.Key, deserialized.CompletedActivity.Key);
            Assert.AreEqual(processDesp.InitialActivity.ToTransitions.Count, deserialized.InitialActivity.ToTransitions.Count);
            Assert.AreEqual(processDesp.CancelEventReceivers.Count, deserialized.CancelEventReceivers.Count);
            Assert.AreEqual(processDesp.CompletedActivity.GetFromTransitions().Count, deserialized.CompletedActivity.GetFromTransitions().Count);

            Assert.IsNotNull(deserialized.Activities["N1"]);
            Assert.IsTrue(deserialized.Activities["N1"].Resources.Count > 0);
            Assert.IsTrue(deserialized.Activities["N1"].Resources[0] is WfClientActivityMatrixResourceDescriptor);

            ((WfClientActivityMatrixResourceDescriptor)processDesp.Activities["N1"].Resources[0]).AreSame((WfClientActivityMatrixResourceDescriptor)deserialized.Activities["N1"].Resources[0]);
        }
コード例 #8
0
        public void WfGroupResourceDescriptorConverterTest()
        {
            WfConverterHelper.RegisterConverters();

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            OguObjectCollection <IGroup> groupColl = user.MemberOf;

            foreach (var group in groupColl)
            {
                WfGroupResourceDescriptor groupDesp = new WfGroupResourceDescriptor(group);

                string result = JSONSerializerExecute.Serialize(groupDesp);

                Console.WriteLine(result);

                WfGroupResourceDescriptor deserializedGroupDesp = JSONSerializerExecute.Deserialize <WfGroupResourceDescriptor>(result);

                string reSerialized = JSONSerializerExecute.Serialize(deserializedGroupDesp);

                Assert.AreEqual(result, reSerialized);

                ResourceConverterTest(groupDesp);
            }
        }
コード例 #9
0
        public void WfBranchProcessTemplateDescriptorConverterTest()
        {
            WfConverterHelper.RegisterConverters();

            WfBranchProcessTemplateDescriptor branchProcessTempDesp = new WfBranchProcessTemplateDescriptor(Guid.NewGuid().ToString());

            branchProcessTempDesp.BlockingType    = WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete;
            branchProcessTempDesp.ExecuteSequence = WfBranchProcessExecuteSequence.Serial;


            string result = JSONSerializerExecute.Serialize(branchProcessTempDesp);

            Console.WriteLine(result);

            WfBranchProcessTemplateDescriptor deserializedBranchProcTempDesp = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateDescriptor>(result);
            string reSerialized = JSONSerializerExecute.Serialize(deserializedBranchProcTempDesp);

            Assert.AreEqual(result, reSerialized);

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

            processDesp.InitialActivity.BranchProcessTemplates.Add(branchProcessTempDesp);

            string procResult = JSONSerializerExecute.Serialize(processDesp);

            Console.WriteLine(procResult);

            WfProcessDescriptor deserializedProcDesp = JSONSerializerExecute.Deserialize <WfProcessDescriptor>(procResult);
            string procReSerialized = JSONSerializerExecute.Serialize(deserializedProcDesp);

            Assert.AreEqual(procResult, procReSerialized);
        }
コード例 #10
0
        /// <summary>
        /// 加载ClientState
        /// </summary>
        /// <param name="clientState">序列化后的clientState</param>
        /// <remarks>加载ClientState</remarks>
        protected override void LoadClientState(string clientState)
        {
            base.LoadClientState(clientState);

            object[] foArray = JSONSerializerExecute.Deserialize <object[]>(clientState);

            if (foArray != null && foArray.Length > 0)
            {
                //已选择列表的Items
                if (foArray[0] != null && foArray.Length > 0)
                {
                    this.selectedItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[0], typeof(SelectItemCollection));
                }
                //待选择列表的Items
                if (foArray[1] != null && foArray.Length > 1)
                {
                    this.candidateItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[1], typeof(SelectItemCollection));
                }
                //按钮的Items
                if (foArray[2] != null && foArray.Length > 2)
                {
                    this.buttonItems = (ButtonItemCollection)JSONSerializerExecute.DeserializeObject(foArray[2], typeof(ButtonItemCollection));
                }

                //deltaItems
                if (foArray[3] != null && foArray.Length > 3)
                {
                    this.deltaItems = (DeltaItemCollection)JSONSerializerExecute.DeserializeObject(foArray[3], typeof(DeltaItemCollection));
                }
            }
        }
コード例 #11
0
        public void WfVariabledOfPrecessDescriptorConverterTest()
        {
            WfConverterHelper.RegisterConverters();

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

            //给流程中变量描述赋值
            string guid = Guid.NewGuid().ToString();
            WfVariableDescriptor variDesc = new WfVariableDescriptor(guid);

            variDesc.Name          = "yo";
            variDesc.Description   = "流程中变量的赋值";
            variDesc.Enabled       = true;
            variDesc.OriginalType  = DataType.String;
            variDesc.OriginalValue = "原来的变量值";
            processDesp.Variables.Add(variDesc);

            string result = JSONSerializerExecute.Serialize(processDesp);

            Console.WriteLine(result);

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

            string reSerialized = JSONSerializerExecute.Serialize(reProcessDesp);

            Assert.AreEqual(result, reSerialized);

            Assert.AreEqual(processDesp.Variables[0].Name, reProcessDesp.Variables[0].Name);
            Assert.AreEqual("流程中变量的赋值", reProcessDesp.Variables[0].Description);
            Assert.AreEqual(true, reProcessDesp.Variables[0].Enabled);
            Assert.AreEqual(processDesp.Variables[0].OriginalType, reProcessDesp.Variables[0].OriginalType);
        }
コード例 #12
0
ファイル: PropertyGrid.cs プロジェクト: wooln/AK47Source
 protected override void LoadClientState(string clientState)
 {
     if (string.IsNullOrEmpty(clientState) == false)
     {
         this.Properties.CopyFrom(JSONSerializerExecute.Deserialize <PropertyValueCollection>(clientState));
     }
 }
コード例 #13
0
        public override void Write(T currentProperty, PersisterContext <T> context)
        {
            string             value      = currentProperty.StringValue;
            EditorParamsDefine paraDefine = null;

            if (currentProperty.Definition.EditorParams.IsNotEmpty())
            {
                base.Register();
                paraDefine = JSONSerializerExecute.Deserialize <EditorParamsDefine>(currentProperty.Definition.EditorParams);
            }

            if (value.IsNotEmpty())
            {
                if (string.Compare(currentProperty.StringValue, currentProperty.Definition.DefaultValue, true) != 0)
                {
                    if (paraDefine.ContainsKey("TagPropertyName") == true)
                    {
                        currentProperty.StringValue = PwdCalculate("", string.Format("{0},{1}", context.Properties[paraDefine["TagPropertyName"]].StringValue, value));
                    }
                    else
                    {
                        currentProperty.StringValue = PwdCalculate("", value);
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        ///反序列化MultiMaterialList
        /// </summary>
        /// <param name="dictionary">对象类型</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化出的对象</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            MultiMaterialList multiMaterialList = new MultiMaterialList();

            object materialList;

            if (dictionary.TryGetValue("materials", out materialList))
            {
                ArrayList materials = (ArrayList)materialList;

                for (int i = 0; i < materials.Count; i++)
                {
                    multiMaterialList.Materials.Add(JSONSerializerExecute.Deserialize <Material>(materials[i]));
                }
            }

            object deltaMaterialList;

            if (dictionary.TryGetValue("deltaMaterials", out deltaMaterialList))
            {
                multiMaterialList.DeltaMaterials = JSONSerializerExecute.Deserialize <DeltaMaterialList>(deltaMaterialList);
            }

            return(multiMaterialList);
        }
コード例 #15
0
        protected void DoOverridePostData(object sender, MCS.Web.WebControls.PostProgressDoPostedDataEventArgs e)
        {
            // 先保存当前数据
            try
            {
                ProcessProgress pg = ProcessProgress.Current;
                pg.CurrentStep = pg.MaxStep = 1;
                pg.MinStep     = 0;
                var  aclMembers   = JSONSerializerExecute.Deserialize <SCAclMemberCollection>(e.Steps[0]);
                bool all          = e.Steps[1].Equals("all");
                bool inheritRight = e.Steps[2].Equals("inherit");
                var  obj          = DbUtil.GetEffectiveObject(e.ClientExtraPostedData, null);

                InnerDoSave(aclMembers, obj, inheritRight);

                AU.Operations.Facade.InstanceWithPermissions.ReplaceAclRecursively((ISCAclContainer)obj, all);

                pg.Output.WriteLine("完毕");
            }
            catch (Exception ex)
            {
                ProcessProgress.Current.Output.WriteLine(ex.ToString());
                ProcessProgress.Current.StatusText = "错误";
                ProcessProgress.Current.Response();
            }

            e.Result.CloseWindow = false;
            e.Result.ProcessLog  = ProcessProgress.Current.GetDefaultOutput();
        }
コード例 #16
0
        public void WfExternalUserTest()
        {
            WfConverterHelper.RegisterConverters();

            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";

            string         result           = JSONSerializerExecute.Serialize(externalUser);
            WfExternalUser deserializedUser = JSONSerializerExecute.Deserialize <WfExternalUser>(result);
            string         reSerialized     = JSONSerializerExecute.Serialize(deserializedUser);

            Assert.AreEqual(result, reSerialized);


            //创建流程描述
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.ExternalUsers.Add(externalUser);                 //作用于流程
            processDesp.InitialActivity.ExternalUsers.Add(externalUser); //作用于节点

            string procDesp = JSONSerializerExecute.Serialize(processDesp);
            WfProcessDescriptor reProcessDesp = JSONSerializerExecute.Deserialize <WfProcessDescriptor>(procDesp);
            string reuslt = JSONSerializerExecute.Serialize(reProcessDesp);

            Assert.AreEqual(procDesp, reuslt);
            Assert.AreEqual(processDesp.ExternalUsers[0].Name, processDesp.InitialActivity.ExternalUsers[0].Name);
        }
コード例 #17
0
        private void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext)
        {
            ServiceBrokerContext.Current.SaveContextStates();
            try
            {
                InnerTreeContext context = JSONSerializerExecute.Deserialize <InnerTreeContext>(callBackContext);

                if (context.ShowDeletedObjects)
                {
                    ServiceBrokerContext.Current.UseLocalCache       = false;
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
                }
                else
                {
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.Common;
                }

                OguObjectCollection <IOguObject> parents = UserOUControlSettings.GetConfig().UserOUControlQuery.GetObjects(((IOguObject)parentNode.ExtendedData).ID);
                //; OguMechanismFactory.GetMechanism().GetObjects<IOguObject>(
                //    SearchOUIDType.Guid, ((IOguObject)parentNode.ExtendedData).ID);

                BindChildren(result, OnGetChildren(parents[0]), context.MultiSelect, context.ListMask, context.SelectMask);
            }
            finally
            {
                ServiceBrokerContext.Current.RestoreSavedStates();
            }
        }
コード例 #18
0
        public void WfActivitySerilizeConverterTest()
        {
            WfConverterHelper.RegisterConverters();

            WfActivityDescriptor normalAct = new WfActivityDescriptor("NormalActivity", WfActivityType.NormalActivity);

            normalAct.Name     = "Normal";
            normalAct.CodeName = "Normal Activity";

            WfServiceOperationDefinition enterSvcDef = new WfServiceInvokerFactory().SvcOpDef;

            enterSvcDef.AddressDef.RequestMethod = WfServiceRequestMethod.Get;
            enterSvcDef.OperationName            = "StringTypeService";
            enterSvcDef.RtnXmlStoreParamName     = "EnterServiceRtnXml";

            enterSvcDef.Params.Add(new WfServiceOperationParameter()
            {
                Name  = "input",
                Type  = WfSvcOperationParameterType.String,
                Value = "this is a get action!"
            });

            normalAct.EnterEventExecuteServices.Add(enterSvcDef);

            string result = JSONSerializerExecute.Serialize(normalAct);

            Console.WriteLine(result);

            WfActivityDescriptor deserializedActDesp = JSONSerializerExecute.Deserialize <WfActivityDescriptor>(result);

            string reSerialized = JSONSerializerExecute.Serialize(deserializedActDesp);

            Assert.AreEqual(result, reSerialized);
        }
コード例 #19
0
        public void SimpleProcessWithMainStreamSerializationTest()
        {
            WfClientJsonConverterHelper.Instance.RegisterConverters();

            WfClientUser[] users = new WfClientUser[] { Consts.Users["Requestor"] };

            IWfProcess process = ProcessHelper.CreateFreeStepsProcessInstance(users.ToOguObjects <WfClientUser, IUser>().ToArray());

            WfClientProcess client = null;

            WfClientProcessConverter.InstanceAllInfo.ServerToClient(process, ref client);

            Assert.IsNotNull(client.InitialActivity);
            Assert.IsNotNull(client.CompletedActivity);
            Assert.IsNotNull(client.MainStream);
            Assert.IsTrue(client.ApplicationRuntimeParameters.Count > 0);

            string data = JSONSerializerExecute.Serialize(client);

            Console.WriteLine(data);

            WfClientProcess deserializedProcess = JSONSerializerExecute.Deserialize <WfClientProcess>(data);

            Assert.IsNotNull(deserializedProcess.InitialActivity);
            Assert.IsNotNull(deserializedProcess.CompletedActivity);
            Assert.IsNotNull(deserializedProcess.MainStream);
            Assert.IsTrue(deserializedProcess.ApplicationRuntimeParameters.Count > 0);

            Assert.AreEqual(deserializedProcess.InitialActivity.ID, deserializedProcess.CurrentActivity.ID);
        }
コード例 #20
0
        public void WfBranchProcessTransferParamsJsonTest()
        {
            WfConverterHelper.RegisterConverters();

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.requestor.ToString()].Object;

            IWfBranchProcessTemplateDescriptor template = WfProcessTestCommon.CreateTemplate("Consign", user);

            WfBranchProcessTransferParams data = new WfBranchProcessTransferParams(template);

            data.BranchParams.Clear();

            WfBranchProcessStartupParams bpsp = new WfBranchProcessStartupParams(user);

            bpsp.Department           = user.Parent;
            bpsp.RelativeParams["RP"] = UuidHelper.NewUuidString();
            bpsp.ApplicationRuntimeParameters["context"] = UuidHelper.NewUuidString();
            bpsp.ResourceID       = UuidHelper.NewUuidString();
            bpsp.DefaultTaskTitle = UuidHelper.NewUuidString();
            bpsp.StartupContext   = UuidHelper.NewUuidString();

            data.BranchParams.Add(bpsp);

            string serilizedData = JSONSerializerExecute.Serialize(data);

            Console.WriteLine(serilizedData);

            WfBranchProcessTransferParams deserilizedData = JSONSerializerExecute.Deserialize <WfBranchProcessTransferParams>(serilizedData);

            Assert.AreEqual(data.Template.Key, deserilizedData.Template.Key);
            Assert.AreEqual(data.Template.BranchProcessKey, deserilizedData.Template.BranchProcessKey);

            AssertBranchProcessStartupParams(data.BranchParams[0], deserilizedData.BranchParams[0]);
        }
コード例 #21
0
ファイル: SchemaUserAccess.cs プロジェクト: wooln/AK47Source
        public void UpdateUserImage()
        {
            var userImagePropName = "PhotoKey";

            SCUser user = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user, SCOrganization.GetRoot());

            ImageProperty image = ImageGenerator.PrepareImage();

            image.ResourceID = user.ID;

            Assert.IsTrue(CanSerialize(image));

            SCObjectOperations.Instance.UpdateObjectImageProperty(user, userImagePropName, image);

            SCUser userLoad = (SCUser)SchemaObjectAdapter.Instance.Load(user.ID);

            Assert.IsNotNull(userLoad);

            var imageLoad = JSONSerializerExecute.Deserialize <ImageProperty>(userLoad.Properties[userImagePropName].StringValue);
            MaterialContentCollection mcc = MaterialContentAdapter.Instance.Load(builder => builder.AppendItem("CONTENT_ID", imageLoad.ID));

            Assert.AreEqual(image.Name, imageLoad.Name);
            Assert.IsNotNull(mcc);
            Assert.AreEqual(1, mcc.Count);
            Assert.AreEqual(image.Content.ContentData.Length, mcc[0].ContentData.Length);

            SCObjectOperations.Instance.UpdateObjectImageProperty(user, userImagePropName, null);
            userLoad = (SCUser)SchemaObjectAdapter.Instance.Load(user.ID);

            Assert.AreEqual("", userLoad.Properties[userImagePropName].StringValue);
        }
コード例 #22
0
        /// <summary>
        /// 将所提供的字典转换为<see cref="SchemaDefine"/>类型的对象。
        /// </summary>
        /// <param name="dictionary">作为名称/值对存储的属性数据的 <see cref="T:System.Collections.Generic.IDictionary^2"/>  实例。</param>
        /// <param name="type">所生成对象的类型。</param>
        /// <param name="serializer"><see cref="System.Web.Script.Serialization.JavaScriptSerializer"/>实例。</param>
        /// <returns>反序列化的对象。</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SchemaDefine schemaDefine = new SchemaDefine();

            schemaDefine.Name          = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            schemaDefine.SnapshotTable = DictionaryHelper.GetValue(dictionary, "snapshotTable", string.Empty);
            schemaDefine.Category      = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
            schemaDefine.SortOrder     = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);

            if (dictionary.ContainsKey("properties"))
            {
                SchemaPropertyDefineCollection properties = JSONSerializerExecute.Deserialize <SchemaPropertyDefineCollection>(dictionary["properties"]);
                schemaDefine.Properties.Clear();
                schemaDefine.Properties.CopyFrom(properties);
            }

            if (dictionary.ContainsKey("tabs"))
            {
                SchemaTabDefineColleciton tabs = JSONSerializerExecute.Deserialize <SchemaTabDefineColleciton>(dictionary["Tabs"]);
                schemaDefine.Tabs.Clear();
                schemaDefine.Tabs.CopyFrom(tabs);
            }

            return(schemaDefine);
        }
コード例 #23
0
ファイル: ImageUploader.cs プロジェクト: wooln/AK47Source
 protected override void LoadClientState(string clientState)
 {
     if (string.IsNullOrEmpty(clientState) == false)
     {
         this.imgProp = JSONSerializerExecute.Deserialize <ImageProperty>(clientState);
     }
 }
コード例 #24
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientProcessStartupParams startupParams = new WfClientProcessStartupParams();

            startupParams.AutoStartInitialActivity = dictionary.GetValue("autoStartInitialActivity", true);
            startupParams.AutoCommit = dictionary.GetValue("autoCommit", false);
            startupParams.CheckStartProcessUserPermission = dictionary.GetValue("checkStartProcessUserPermission", true);
            startupParams.DefaultTaskTitle     = dictionary.GetValue("defaultTaskTitle", string.Empty);
            startupParams.DefaultUrl           = dictionary.GetValue("defaultUrl", string.Empty);
            startupParams.ProcessDescriptorKey = dictionary.GetValue("processDescriptorKey", string.Empty);
            startupParams.RelativeID           = dictionary.GetValue("relativeID", string.Empty);
            startupParams.RelativeURL          = dictionary.GetValue("relativeURL", string.Empty);
            startupParams.ResourceID           = dictionary.GetValue("resourceID", string.Empty);
            startupParams.RuntimeProcessName   = dictionary.GetValue("runtimeProcessName", string.Empty);
            startupParams.AutoPersist          = dictionary.GetValue("autoPersist", true);

            startupParams.Creator    = JSONSerializerExecute.Deserialize <WfClientUser>(dictionary.GetValue("creator", (object)null));
            startupParams.Department = JSONSerializerExecute.Deserialize <WfClientOrganization>(dictionary.GetValue("department", (object)null));

            startupParams.Opinion = JSONSerializerExecute.Deserialize <WfClientOpinion>(dictionary.GetValue("opinion", (object)null));

            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("assignees", (object)null), startupParams.Assignees);
            JSONSerializerExecute.FillDeserializedDictionary(dictionary, "applicationRuntimeParameters", startupParams.ApplicationRuntimeParameters);
            JSONSerializerExecute.FillDeserializedDictionary(dictionary, "processContext", startupParams.ProcessContext);

            return(startupParams);
        }
コード例 #25
0
        /// <summary>
        /// 从数据库得到对象的图片
        /// </summary>
        /// <param name="id"></param>
        /// <param name="propertyName"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SchemaObjectPhoto LoadObjectPhoto(string id, string propertyName, DateTime timePoint)
        {
            SchemaObjectPhoto result = null;
            SchemaObjectBase  obj    = SchemaObjectAdapter.Instance.Load(id, timePoint);

            if (obj != null)
            {
                if (obj.Properties.ContainsKey(propertyName))
                {
                    ImageProperty imgInfo = JSONSerializerExecute.Deserialize <ImageProperty>(obj.Properties[propertyName].StringValue);

                    if (imgInfo != null)
                    {
                        MaterialContent mc = MaterialContentAdapter.Instance.Load(builder => builder.AppendItem("CONTENT_ID", imgInfo.ID)).FirstOrDefault();

                        if (mc != null)
                        {
                            result = new SchemaObjectPhoto()
                            {
                                ImageInfo = imgInfo, ContentData = mc.ContentData
                            }
                        }
                        ;
                    }
                }
            }

            return(result);
        }
コード例 #26
0
        public bool ValidateInstance(string jsonData, out string errorMsg)
        {
            errorMsg = "";
            bool result = false;
            ValidationResults validateResult = new ValidationResults();

            try
            {
                //反序列化
                DEEntityInstance resultInstance = JSONSerializerExecute.Deserialize <DEEntityInstanceBase>(jsonData) as DEEntityInstance;
                validateResult = resultInstance.Validate();

                if (validateResult.IsValid())
                {
                    result = true;
                }
                else
                {
                    //错误信息格式 json格式
                    errorMsg = "[";
                    foreach (var rst in validateResult)
                    {
                        errorMsg += string.Format("{{{0}}},", rst.Message.ToString());
                    }
                    errorMsg = errorMsg.TrimEnd(',') + "]";
                }
            }
            catch (Exception e)
            {
                errorMsg = string.Format("[{{'ErrorMsg':'{0}'}}]", e.Message);
            }

            return(result);
        }
コード例 #27
0
        private static void DoInsert(HttpContext context)
        {
            string id       = context.Request["id"];
            string category = context.Request["category"];
            string content  = context.Request["content"];

            if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(content))
            {
                return;
            }

            WfConverterHelper.RegisterConverters();
            WfActivityDescriptor activityDesc = JSONSerializerExecute.Deserialize <WfActivityDescriptor>(content);

            activityDesc.Key = id;
            activityDesc.FromTransitions.Clear();
            activityDesc.ToTransitions.Clear();

            WfActivityTemplate template = new WfActivityTemplate()
            {
                ID          = id,
                Name        = activityDesc.Name,
                Category    = activityDesc.ActivityType.ToString(),
                CreateTime  = DateTime.Now,
                Content     = JSONSerializerExecute.Serialize(activityDesc),
                Available   = true,
                CreatorID   = DeluxeIdentity.CurrentUser.ID,
                CreatorName = DeluxeIdentity.CurrentUser.Name
            };

            WfActivityTemplateAdpter.Instance.Update(template);

            OutputResult(context, true, activityDesc.Key);
        }
コード例 #28
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            PropertyDefine pd = new PropertyDefine();

            pd.Name                    = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            pd.DisplayName             = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty);
            pd.Category                = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
            pd.DefaultValue            = DictionaryHelper.GetValue(dictionary, "defaultValue", string.Empty);
            pd.DataType                = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String);
            pd.Description             = DictionaryHelper.GetValue(dictionary, "description", string.Empty);
            pd.ReadOnly                = DictionaryHelper.GetValue(dictionary, "readOnly", false);
            pd.Visible                 = DictionaryHelper.GetValue(dictionary, "visible", true);
            pd.EditorKey               = DictionaryHelper.GetValue(dictionary, "editorKey", string.Empty);
            pd.PersisterKey            = DictionaryHelper.GetValue(dictionary, "persisterKey", string.Empty);
            pd.EditorParamsSettingsKey = DictionaryHelper.GetValue(dictionary, "editorParamsSettingsKey", string.Empty);
            pd.EditorParams            = DictionaryHelper.GetValue(dictionary, "editorParams", string.Empty);
            pd.SortOrder               = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);
            pd.MaxLength               = DictionaryHelper.GetValue(dictionary, "maxLength", 0xFFFF);
            pd.IsRequired              = DictionaryHelper.GetValue(dictionary, "isRequired", false);
            pd.ShowTitle               = DictionaryHelper.GetValue(dictionary, "showTitle", true);

            if (dictionary.ContainsKey("validators") == true)
            {
                PropertyValidatorDescriptorCollection validators = JSONSerializerExecute.Deserialize <PropertyValidatorDescriptorCollection>(dictionary["validators"]);
                pd.Validators.Clear();
                pd.Validators.CopyFrom(validators);
            }

            PropertyValue pv = new PropertyValue(pd);

            pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null);

            return(pv);
        }
コード例 #29
0
        public void OguApplicationCollectionSerializationTest()
        {
            JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter));

            ApplicationCollection    originalApps = PermissionMechanismFactory.GetMechanism().GetAllApplications();
            OguApplicationCollection apps         = new OguApplicationCollection(originalApps);

            CheckOguApplicationCollectionItems(apps);

            //测试Set操作
            for (int i = 0; i < apps.Count; i++)
            {
                apps[i] = originalApps[i];
            }

            CheckOguApplicationCollectionItems(apps);

            string serializedData = JSONSerializerExecute.Serialize(apps);

            Console.WriteLine(serializedData);

            OguApplicationCollection deserializedData = JSONSerializerExecute.Deserialize <OguApplicationCollection>(serializedData);

            for (int i = 0; i < apps.Count; i++)
            {
                ValidatePermissionObject(apps[i], deserializedData[i]);
            }
        }
コード例 #30
0
        //---------------------------------我就素那无耻的分割线---------------------------------//

        #region ClientState
        /// <summary>
        /// 加载ClientState
        /// </summary>
        /// <remarks>
        /// 加载ClientState
        ///     ClientState中保存的是一个长度为3的一维数组
        ///         第一个为选中项目的索引值,如果没有选中则为-1
        ///         第二个为选中项目的文本,或者输入的文本
        ///         第三个是Items
        /// </remarks>
        /// <param name="clientState">序列化后的clientState</param>
        protected override void LoadClientState(string clientState)
        {
            base.LoadClientState(clientState);

            object[] foArray = JSONSerializerExecute.Deserialize <object[]>(clientState);

            if (null != foArray && foArray.Length > 0)
            {
                this.SelectedIndex = Convert.ToInt32(foArray[0]);
                if (foArray.Length > 1 && null != foArray[1])
                {
                    this.Text = foArray[1].ToString();
                }
                else
                {
                    this.Text = "";
                }


                if (foArray.Length > 2 && null != foArray[2])
                {
                    this.items = (ListItemCollection)JSONSerializerExecute.DeserializeObject(foArray[2], typeof(ListItemCollection));
                }
                else
                {
                    this.items = new ListItemCollection();
                }
            }
            else
            {
                this.SelectedIndex = -1;
                this.Text          = "";
                this.items         = new ListItemCollection();
            }
        }