private void SaveDocumentActivity(XomlDocument xomlDocument) { int sequenceactivityindex = 1; int parallelactivity = 1; foreach (List<string[]> lstring in alllist) { if (lstring.Count > 1) { DocumentActivity da2 = xomlDocument.CreateActivity(typeof(System.Workflow.Activities.ParallelActivity).Name); da2.Name = "ParallelActivity" + parallelactivity.ToString(); parallelactivity++; for (int i = 0; i < lstring.Count; i++) { DocumentActivity sa = xomlDocument.CreateActivity(typeof(System.Workflow.Activities.SequenceActivity).Name); sa.Name = "SequenceActivity" + sequenceactivityindex.ToString(); sequenceactivityindex++; Type t; if ((lstring[i] as string[])[6] == "FLStand") { t = typeof(FLTools.FLStand); } else { t = typeof(FLTools.FLNotify); } DocumentActivity da = xomlDocument.CreateFLActivity(t.Name); da.Name = (lstring[i] as string[])[1]; //da.Description = (lstring[i] as string[])[2]; if ((lstring[i] as string[])[6] == "FLStand") { da["PlusApprove"] = (lstring[i] as string[])[3]; } if ((lstring[i] as string[])[5] != "") { da["SendToKind"] = "User"; } else if ((lstring[i] as string[])[4] != "") { da["SendToKind"] = "Role"; } else da["SendToKind"] = ""; da["SendToRole"] = (lstring[i] as string[])[4]; da["SendToUser"] = (lstring[i] as string[])[5]; sa.AppendChildActivity(da); da2.AppendChildActivity(sa); } xomlDocument.RootActivity.AppendChildActivity(da2); } else { Type t; if ((lstring[0] as string[])[6] == "FLStand") { t = typeof(FLTools.FLStand); } else { t = typeof(FLTools.FLNotify); } DocumentActivity da = xomlDocument.CreateFLActivity(t.Name); da.Name = (lstring[0] as string[])[1]; //da.Description = (lstring[0] as string[])[2]; if ((lstring[0] as string[])[6] == "FLStand") { da["PlusApprove"] = (lstring[0] as string[])[3]; } if ((lstring[0] as string[])[5] != "") { da["SendToKind"] = "User"; } else if ((lstring[0] as string[])[4] != "") { da["SendToKind"] = "Role"; } else da["SendToKind"] = ""; da["SendToRole"] = (lstring[0] as string[])[4]; da["SendToUser"] = (lstring[0] as string[])[5]; xomlDocument.RootActivity.AppendChildActivity(da); } } }
/// <summary> /// save xoml /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btSave_Click(object sender, EventArgs e) { XomlDocument xomlDocument = new XomlDocument(); SaveDocumentActivity(xomlDocument); string filename = tbFileName.Text; if(!string.IsNullOrEmpty(filename)) { if (filename.Length <6 || filename.Substring(filename.Length - 5) != ".xoml") { filename = filename + ".xoml"; } string clientPath = GetClientPath(filename); string dir = Path.GetDirectoryName(clientPath); if(!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } xomlDocument.Save(clientPath); string serverPath = GetServerPath(filename); if (!string.IsNullOrEmpty(serverPath)) { byte[] bfile = File.ReadAllBytes(clientPath); object[] myRet = CliUtils.CallMethod("GLModule", "UpLoadFile", new object[] { serverPath, bfile }); if (myRet != null && (int)myRet[0] == 0) { if ((int)myRet[1] == 0) { this.selectedFileName = filename; this.ClientScript.RegisterStartupScript(typeof(string), "", "alert('保存成功')", true); GetXomlList(); ddlFiles.SelectedValue = selectedFileName; } else { this.ClientScript.RegisterStartupScript(typeof(string), "", "alert('文件已存在')", true); } } else { this.ClientScript.RegisterStartupScript(typeof(string), "", "alert('保存失敗')", true); } } } }
private void LoadDocumentActivityAndRender(XomlDocument xomlDocument) { foreach (DocumentActivity documentActivity in xomlDocument.RootActivity.ChildActivities) { if (documentActivity.Type == "FLStand") { List<string[]> list = new List<string[]>(); string id = Guid.NewGuid().ToString(); string name = documentActivity.Name; //string description = documentActivity.Description; string plusArrpove = documentActivity["PlusApprove"]; string sendToRole = documentActivity["SendToRole"]; string sendToUser = documentActivity["SendToUser"]; //0:id,1:name,2:description,3:selected or not,4:plusApprove,5:kind,6:role,7:user string[] sarray = new string[] { id, name, "0"/*是否选中,0表示false,1表示true*/, plusArrpove, sendToRole, sendToUser, "FLStand" }; list.Add(sarray); alllist.Add(list); } else if (documentActivity.Type == "FLNotify") { List<string[]> list = new List<string[]>(); string id = Guid.NewGuid().ToString(); string name = documentActivity.Name; //string description = documentActivity.Description; string sendToRole = documentActivity["SendToRole"]; string sendToUser = documentActivity["SendToUser"]; //0:id,1:name,2:description,3:selected or not,4:plusApprove,5:kind,6:role,7:user string[] sarray = new string[] { id, name, "0"/*是否选中,0表示false,1表示true*/, "False", sendToRole, sendToUser, "FLNotify" }; list.Add(sarray); alllist.Add(list); } else if (documentActivity.Type == "ParallelActivity") { List<string[]> list = new List<string[]>(); foreach (DocumentActivity sequenceActivity in documentActivity.ChildActivities) { if (sequenceActivity.ChildActivities.Count > 0) { DocumentActivity standActivity = sequenceActivity.ChildActivities[0]; string id = Guid.NewGuid().ToString(); string name = standActivity.Name; string type = standActivity.Type; //string description = standActivity.Description; string plusArrpove ="False"; if (type == "FLStand") plusArrpove = standActivity["PlusApprove"]; string sendToRole = standActivity["SendToRole"]; string sendToUser = standActivity["SendToUser"]; //0:id,1:name,2:description,3:selected or not,4:plusApprove,5:kind,6:role,7:user string[] sarray = new string[] { id, name, "0"/*是否选中,0表示false,1表示true*/, plusArrpove, sendToRole, sendToUser, type }; list.Add(sarray); } } alllist.Add(list); } renderPanel(true); } }
/// <summary> /// load xoml /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btLoad_Click(object sender, EventArgs e) { //CliUtils.DownLoad( alllist.Clear(); string filename = ddlFiles.SelectedItem.ToString(); string clientPath = GetClientPath(filename); string dir = Path.GetDirectoryName(clientPath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string serverPath = GetServerPath(filename); CliUtils.DownLoad(serverPath, clientPath); XomlDocument xomlDocument = new XomlDocument(); xomlDocument.Load(clientPath); this.selectedFileName = filename; LoadDocumentActivityAndRender(xomlDocument); }