public void WfControlNextStepJsonSerilizationTest() { IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); process.InitialActivity.Descriptor.ToTransitions[0].ToActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object)); WfConverterHelper.RegisterConverters(); WfControlNextStep nextStep = new WfControlNextStep(process.InitialActivity.Descriptor.ToTransitions[0], process.CurrentActivity); string serializedData = JSONSerializerExecute.Serialize(nextStep); Console.WriteLine(serializedData); WfControlNextStep deserializedNextStep = JSONSerializerExecute.Deserialize <WfControlNextStep>(serializedData); string reserializedData = JSONSerializerExecute.Serialize(deserializedNextStep); Assert.AreEqual(serializedData, reserializedData); }
private void ChangeTransitionButton_Click(object sender, EventArgs e) { try { WfControlNextStep nextStep = null; if (_EnabledNextStepSelectorControl != null) { nextStep = _EnabledNextStepSelectorControl.SelectedNextStep; if (nextStep != null) { IWfActivityDescriptor originalDesp = WfClientContext.Current.OriginalActivity.Descriptor; /* YDZ 2012/11/23 为了记录克隆前线的状态 * foreach (IWfTransitionDescriptor t in originalDesp.ToTransitions) * { * t.Properties.SetValue("DefineDefaultSelect", t.DefaultSelect); //记录改变值前的记录 * * t.DefaultSelect = false; * * t.DefaultSelect = t.Key == nextStep.TransitionDescriptor.Key; * * if (t.DefaultSelect) * { * if (t.AffectProcessReturnValue) * WfClientContext.Current.OriginalActivity.Descriptor.Process.DefaultReturnValue = t.AffectedProcessReturnValue; * } * } */ //originalDesp.ToTransitions.ForEach(t => t.DefaultSelect = false); originalDesp.ToTransitions.ForEach(t => { t.DefaultSelect = false; t.DefaultSelect = t.Key == nextStep.TransitionDescriptor.Key; if (t.DefaultSelect) { if (t.AffectProcessReturnValue) { WfClientContext.Current.OriginalActivity.Descriptor.Process.DefaultReturnValue = t.AffectedProcessReturnValue; } } }); } } WfControlNextStepCollection nextSteps = WfMoveToControl.Current.NextSteps; if (nextStep != null) { nextSteps = new WfControlNextStepCollection(); nextSteps.Add(nextStep); } WfMoveToControl.Current.OnProcessChanged(WfClientContext.Current.CurrentActivity.OpinionRootActivity.Process); WfClientContext.Current.CurrentActivity.OpinionRootActivity.Process.GenerateCandidatesFromResources(); RecreateProcesses(nextSteps, true, false); WfMoveToControl.Current.OnAfterProcessChanged(WfClientContext.Current.CurrentActivity.OpinionRootActivity.Process); } catch (System.Exception ex) { RegisterPostBackException(ex); } }