public void ExcelKeyChangeSaveDescriptorTest() { const string processKey = "c8d2a844-0002-bb51-4ab0-1563a40d2b587"; WfCreateClientDynamicProcessParams processParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); processParams.Key = processKey; WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(processParams); WfClientProcessDescriptor client = builder.Build(processParams.Key, processParams.Name); WfClientServiceBrokerContext.Current.Context[Consts.TenantCode] = "Test1"; // GetCurrentTenantCode(); WfClientProcessDescriptorServiceProxy.Instance.SaveDescriptor(client); //数据准备 #region 保存EXCEL后,修改EXCEL数据后再校验 //using (FileStream fs = File.OpenWrite(string.Format("E:\\work\\TMP\\{0}.xlsx", processKey))) //{ // WfClientProcessDescriptorServiceProxy.Instance.WfDynamicProcessToExcel(processKey).CopyTo(fs); //} //using (FileStream fs = File.OpenRead(string.Format("E:\\work\\TMP\\{0}.xlsx", processKey))) //{ // WfClientProcessDescriptorServiceProxy.Instance.ExcelToSaveDescriptor(processKey, fs); //} #endregion client = WfClientProcessDescriptorServiceProxy.Instance.GetDescriptor(processKey); Assert.AreEqual(client.Properties.GetValue("Key", string.Empty), processKey); Assert.AreEqual(client.Key, processKey); }
public void ExcelToSaveDescriptorTest() { const string processKey = "c8d2a844-3a3a-bb51-4ab0-1563a40d2b58"; WfCreateClientDynamicProcessParams processParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); processParams.Key = processKey; WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(processParams); WfClientProcessDescriptor client = builder.Build(processParams.Key, processParams.Name); WfClientProcessDescriptorServiceProxy.Instance.SaveDescriptor(client);//数据准备 WfClientProcessDescriptor server = null; using (Stream stream = WfClientProcessDescriptorServiceProxy.Instance.WfDynamicProcessToExcel(processKey)) //EXCEL文件流 { WfClientProcessDescriptorServiceProxy.Instance.DeleteDescriptor(processKey); //清理 //校验清理结果 try { server = WfClientProcessDescriptorServiceProxy.Instance.GetDescriptor(processKey); } catch (MCS.Library.WcfExtensions.WfClientChannelException ex) { Assert.IsTrue(true, ex.Message); } WfClientServiceBrokerContext.Current.Context[Consts.TenantCode] = "Test1";// GetCurrentTenantCode(); WfClientProcessDescriptorServiceProxy.Instance.ExcelToSaveDescriptor(processKey, stream); server = WfClientProcessDescriptorServiceProxy.Instance.GetDescriptor(processKey); Assert.AreEqual(processParams.ProgramName, server.ProgramName); // Assert.AreEqual("Test1", server.Properties)); } }
/// <summary> /// EXCEL转换为动态活动流程的参数 /// </summary> /// <param name="wb"></param> /// <param name="client"></param> /// <returns></returns> public WfCreateClientDynamicProcessParams ExcelToClient(string processKey, WorkBook wb, ref WfCreateClientDynamicProcessParams client) { processKey.NullCheck("processKey"); wb.NullCheck("wb"); DataTable processTable = DocumentHelper.GetRangeValuesAsTable(wb, "Process", "A3"); DataTable matrixTable = DocumentHelper.GetRangeValuesAsTable(wb, "Matrix", "A3"); if (client == null) { client = new WfCreateClientDynamicProcessParams(); } client.Key = processKey; foreach (DataRow row in processTable.Rows) { string propertyValue = row[0].ToString(); if (propertyValue.IsNullOrEmpty() || string.Equals(propertyValue, "Key", StringComparison.OrdinalIgnoreCase)) { continue; } string dataValue = row[1].ToString(); //dataValue 可以为空 client.Properties.AddOrSetValue(propertyValue, dataValue); } client.ActivityMatrix = new WfClientActivityMatrixResourceDescriptor(matrixTable); return(client); }
public void WfDynamicProcessToExcelTest() { string processKey = "c8d2a844-0003-bb51-4ab0-1563a40d2b58"; WfCreateClientDynamicProcessParams processParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); processParams.Key = processKey; WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(processParams); WfClientProcessDescriptor client = builder.Build(processParams.Key, processParams.Name); WfClientServiceBrokerContext.Current.Context[Consts.TenantCode] = "Test1";// GetCurrentTenantCode(); WfClientProcessDescriptorServiceProxy.Instance.SaveDescriptor(client); System.Data.DataTable processTable = null; System.Data.DataTable matrixTable = null; using (Stream stream = WfClientProcessDescriptorServiceProxy.Instance.WfDynamicProcessToExcel(processKey)) { processTable = DocumentHelper.GetRangeValuesAsTable(stream, "Process", "A3"); matrixTable = DocumentHelper.GetRangeValuesAsTable(stream, "Matrix", "A3"); } Assert.IsTrue(processTable.Rows.Count > 0); Assert.IsTrue(matrixTable.Rows.Count == 2); Assert.IsTrue(matrixTable.Rows[0]["CostCenter"].ToString() == "1001"); Assert.IsTrue(matrixTable.Rows[1]["Age"].ToString() == "40"); }
public void ExcelToWfCreateClientDynamicProcessParamsTest() { const string processKey = "c8d2a844-0000-bb51-4ab0-1563a40d2b58"; WfCreateClientDynamicProcessParams processParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); processParams.Key = processKey; WfCreateClientDynamicProcessParams result = null; WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(processParams); WfClientProcessDescriptor client = builder.Build(processParams.Key, processParams.Name); WfClientServiceBrokerContext.Current.Context[Consts.TenantCode] = "Test1"; // GetCurrentTenantCode(); WfClientProcessDescriptorServiceProxy.Instance.SaveDescriptor(client); //数据准备 using (Stream stream = WfClientProcessDescriptorServiceProxy.Instance.WfDynamicProcessToExcel(processKey)) //EXCEL文件流 { result = WfClientProcessDescriptorServiceProxy.Instance.ExcelToWfCreateClientDynamicProcessParams(processKey, stream); } processParams.ActivityMatrix.PropertyDefinitions.ForEach(action => { action.DataType = ColumnDataType.String; }); //EXCEL 无法存储类型信息,所有默认都为string类型 processParams.AreSame(result); }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { WfCreateClientDynamicProcessParams createParams = (WfCreateClientDynamicProcessParams)base.Deserialize(dictionary, type, serializer); createParams.ActivityMatrix = JSONSerializerExecute.Deserialize <WfClientActivityMatrixResourceDescriptor>(dictionary.GetValue("activityMatrix", (object)null)); return(createParams); }
public WfCreateClientDynamicProcessParams ExcelToWfCreateClientDynamicProcessParams(string processKey, Stream stream) { OperationContext.Current.FillContextToOguServiceContext(); WfCreateClientDynamicProcessParams processParams = null; WfCreateClientDynamicProcessParamsConverter.Instance.ExcelStreamToClient(processKey, stream, ref processParams); return(processParams); }
public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer) { Dictionary <string, object> dictionary = (Dictionary <string, object>)base.Serialize(obj, serializer); WfCreateClientDynamicProcessParams createParams = (WfCreateClientDynamicProcessParams)obj; dictionary["activityMatrix"] = createParams.ActivityMatrix; return(dictionary); }
public static WfCreateClientDynamicProcessParams CreateClientDynamicProcessParams() { WfCreateClientDynamicProcessParams createParams = new WfCreateClientDynamicProcessParams(); createParams.Key = UuidHelper.NewUuidString(); createParams.Name = "客户端测试流程参数"; createParams.ActivityMatrix = GetClientActivityMatrixResourceDescriptor(); return(createParams); }
public void WfClientDynamicProcessBuilderInstanceTest() { WfCreateClientDynamicProcessParams createParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(createParams); WfClientProcessDescriptor client = builder.Build(createParams.Key, createParams.Name); IWfProcess process = ProcessHelper.CreateProcessInstance(client); Assert.IsTrue(process.Activities.Count > client.Activities.Count); }
public void WfCreateClientDynamicProcessParamsSerializationTest() { WfClientJsonConverterHelper.Instance.RegisterConverters(); WfCreateClientDynamicProcessParams createParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); string data = JSONSerializerExecute.Serialize(createParams); Console.WriteLine(data); WfCreateClientDynamicProcessParams deserialized = JSONSerializerExecute.Deserialize <WfCreateClientDynamicProcessParams>(data); createParams.AreSame(deserialized); }
public void ExcelToSaveDescriptor(string processKey, Stream stream) { OperationContext.Current.FillContextToOguServiceContext(); WfCreateClientDynamicProcessParams processParams = ExcelToWfCreateClientDynamicProcessParams(processKey, stream); WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(processParams); WfClientProcessDescriptor client = builder.Build(processParams.Key, processParams.Name); WfProcessDescriptor processDesp = null; WfClientProcessDescriptorConverter.Instance.ClientToServer(client, ref processDesp); WfProcessDescriptorManager.SaveDescriptor(processDesp); }
public void WfClientDynamicProcessBuilderTest() { WfCreateClientDynamicProcessParams createParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(createParams); WfClientProcessDescriptor client = builder.Build(createParams.Key, createParams.Name); WfProcessDescriptor server = null; WfClientProcessDescriptorConverter.Instance.ClientToServer(client, ref server); Assert.IsTrue(server.Variables.GetValue("ClientDynamicProcess", false)); Assert.IsNotNull(server.Activities["N1"]); Assert.IsTrue(server.Activities["N1"].Resources.Count > 0); Assert.IsTrue(server.Activities["N1"].Resources[0] is WfActivityMatrixResourceDescriptor); }
public void ExcelStreamToClientTest() { WfCreateClientDynamicProcessParams createParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); WfCreateClientDynamicProcessParams outProcessParams = null; WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(createParams); WfClientProcessDescriptor client = builder.Build(createParams.Key, createParams.Name); string processKey = createParams.Key; using (Stream stream = WfClientProcessDescriptorConverter.Instance.ClientDynamicProcessToExcelStream(client)) { WfCreateClientDynamicProcessParamsConverter.Instance.ExcelStreamToClient(processKey, stream, ref outProcessParams); } createParams.ActivityMatrix.PropertyDefinitions.ForEach(action => { action.DataType = ColumnDataType.String; }); //EXCEL 无法存储类型信息,所有默认都为string类型 createParams.AreSame(outProcessParams); }
public void ClientDynamicProcessToExcelStreamTest() { WfCreateClientDynamicProcessParams createParams = ProcessDescriptorHelper.CreateClientDynamicProcessParams(); WfClientDynamicProcessBuilder builder = new WfClientDynamicProcessBuilder(createParams); WfClientProcessDescriptor client = builder.Build(createParams.Key, createParams.Name); string processKey = createParams.Key; System.Data.DataTable processTable = new System.Data.DataTable(); System.Data.DataTable matrixTable = new System.Data.DataTable(); using (Stream stream = WfClientProcessDescriptorConverter.Instance.ClientDynamicProcessToExcelStream(client)) { processTable = DocumentHelper.GetRangeValuesAsTable(stream, "Process", "A3"); matrixTable = DocumentHelper.GetRangeValuesAsTable(stream, "Matrix", "A3"); } Assert.IsTrue(processTable.Rows.Count > 0); Assert.IsTrue(matrixTable.Rows.Count == 2); Assert.IsTrue(matrixTable.Rows[0]["CostCenter"].ToString() == "1001"); Assert.IsTrue(matrixTable.Rows[1]["Age"].ToString() == "40"); }
public WfCreateClientDynamicProcessParams ExcelStreamToClient(string processKey, Stream stream, ref WfCreateClientDynamicProcessParams client) { stream.NullCheck("stream"); WorkBook workBook = WorkBook.Load(stream); return(ExcelToClient(processKey, workBook, ref client)); }
/// <summary> /// 构造方法 /// </summary> /// <param name="appName"></param> /// <param name="progName"></param> public WfClientDynamicProcessBuilder(WfCreateClientDynamicProcessParams createParams) : base(createParams.ApplicationName, createParams.ProgramName) { this._CreateParams = createParams; }
public static void AreSame(this WfCreateClientDynamicProcessParams expected, WfCreateClientDynamicProcessParams actual) { ((WfClientKeyedDescriptorBase)expected).AreSame((WfClientKeyedDescriptorBase)actual); expected.ActivityMatrix.AreSame(actual.ActivityMatrix); }