[HttpPost] // load file xamlx in server public ActionResult LoadWorkflow(string fname) { if (ModelState.IsValid) { var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.Saved, SketchStatusType.SentToSketch } }); if (sketches.Sketches.Count > 0) { string path = "/SketchWorkFlows/"; string fileName = fname + ".xamlx"; DocsDocument.DownloadDocument(new DocumentInfo { OidDocument = sketches.Sketches[0].XamlxOid, DocumentName = fileName, Path = path }, ConfigHelper.DownloadLocation, DocumentDownloadMode.LastVersion); XmlDocument xamlx = new XmlDocument(); xamlx.Load(Path.Combine(ConfigHelper.DownloadLocation, fileName)); //convert xml to json String json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(xamlx); return(Json(json)); } return(Json("Error")); } return(Json("Error")); }
public string Get(string fname) { try { //return "loading: " + fname; if (fname.Equals("_empty_")) { string path = HostingEnvironment.MapPath("~/WorkFlows/template/" + FDEFAULT); if (File.Exists(path)) { XmlDocument form = new XmlDocument(); form.Load(path); string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(form); return(json); } } else { var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.Saved, SketchStatusType.SentToSketch } }); if (sketches.Sketches.Count > 0) { string path = "/SketchWorkFlows/"; string fileName = fname + ".xamlx"; DocsDocument.DownloadDocument( new DocumentInfo { OidDocument = sketches.Sketches[0].XamlxOid, DocumentName = fileName, Path = path }, ConfigHelper.DownloadLocation, DocumentDownloadMode.LastVersion); XmlDocument xamlx = new XmlDocument(); xamlx.Load(Path.Combine(ConfigHelper.DownloadLocation, fileName)); //convert xml to json string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(xamlx); return(json); } } var result = Request.CreateResponse(HttpStatusCode.NotFound); throw new HttpResponseException(result); } catch (Exception ex) { var result = Request.CreateResponse(HttpStatusCode.InternalServerError, ex); throw new HttpResponseException(result); } }
public HttpResponseMessage Deploy(string fname) { try { //return new HttpResponseMessage(HttpStatusCode.Created); var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.Saved } }); if (sketches.Sketches.Any()) { var startWorkflowRequest = new StartWorkflowRequest { Domain = ConfigHelper.WorkflowDomain, WorkflowCode = ConfigHelper.WorkflowCodeSketch, WfRuntimeValues = new[] { new WfProperty { Name = ConfigHelper.WorkflowPropertyDocumentOid, Type = PropertyType.FlowDoc.ToString(), Value = sketches.Sketches[0].XamlxOid.ToString() }, new WfProperty { Name = ConfigHelper.WorkflowPropertyCode, Type = PropertyType.String.ToString(), Value = fname } } }; TasksService.StartWorkflow(startWorkflowRequest); } TasksService.SketchWorkflow(new SketchWorkflowRequest { Name = fname, ChangedBy = User.Identity.Name, Status = SketchStatusType.DeployedDev }); return(new HttpResponseMessage(HttpStatusCode.Created)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } }
[HttpPost] // public ActionResult DeployWorkflow(string fname, string content) { if (ModelState.IsValid) { var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.Saved } }); if (sketches.Sketches.Any()) { var startWorkflowRequest = new StartWorkflowRequest { Domain = ConfigHelper.WorkflowDomain, WorkflowCode = ConfigHelper.WorkflowCodeSketch, WfRuntimeValues = new[] { new WfProperty { Name = ConfigHelper.WorkflowPropertyDocumentOid, Type = PropertyType.FlowDoc.ToString(), Value = sketches.Sketches[0].XamlxOid.ToString() }, new WfProperty { Name = ConfigHelper.WorkflowPropertyCode, Type = PropertyType.String.ToString(), Value = fname } } }; TasksService.StartWorkflow(startWorkflowRequest); } TasksService.SketchWorkflow(new SketchWorkflowRequest { Name = fname, ChangedBy = User.Identity.Name, Status = SketchStatusType.DeployedDev }); return(Json("WorkFlow Deployed!")); } return(Json("Error")); }
public ActionResult CompleteFixTask(string completeTask, FormCollection values, TaskModel task) { // Custom computation var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = values["SketchWorkflowCode"], Statuses = new[] { SketchStatusType.DeployedDev, SketchStatusType.SentToSketch } }); var newOid = string.Empty; if (sketches.Sketches.Count() > 0) { newOid = sketches.Sketches.First().XamlxOid.ToString(); } if (completeTask == DEPLOY) { // Update docsDocument oid with the new one TasksService.UpdateWorkflowParameters(new UpdateWorkflowParametersRequest { WorkflowOid = values["WorkflowOid"], WfRuntimeValues = new[] { new WfProperty { Name = ConfigHelper.WorkflowPropertyDocumentOid, Type = PropertyType.FlowDoc.ToString(), Value = newOid } } }); } if (completeTask == ABORT) { TasksService.SketchWorkflow(new SketchWorkflowRequest { Name = values["SketchWorkflowCode"], ChangedBy = User.Identity.Name, Status = SketchStatusType.Aborted }); } // Exit from this area and go back to main control return(RedirectFromArea(completeTask, values)); }
public HttpResponseMessage Save(string fname, [FromBody] string content) { try { //return new HttpResponseMessage(HttpStatusCode.Created); content = content.Replace("\\n", "
").Replace("< ", "<").Replace(" >", ">"); var newOid = DocsDocument.UploadDocument(new DocumentInfo { Owner = User.Identity.Name, DocumentName = fname + ".xamlx", Description = "Sketch Workflow", Path = "/SketchWorkFlows/" }, Encoding.ASCII.GetBytes(content), DocumentUploadMode.Overwrite ); var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.SentToSketch } }); SketchStatusType sketchStatus = sketches.Sketches.Count() > 0 ? SketchStatusType.SentToSketch : SketchStatusType.Saved; TasksService.SketchWorkflow(new SketchWorkflowRequest { Name = fname, ChangedBy = User.Identity.Name, Status = sketchStatus, XamlxOid = newOid.ToString() }); return(new HttpResponseMessage(HttpStatusCode.Created)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } }
[HttpPost] // get workflow codes public ActionResult GetWorkflowCodes() { if (ModelState.IsValid) { var fnames = new List <string>(); var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Statuses = new[] { SketchStatusType.Saved, SketchStatusType.SentToSketch } }); foreach (var s in sketches.Sketches) { fnames.Add(s.Name); } return(Json(fnames)); } return(Json("Error")); }
[HttpPost] // public ActionResult SaveWorkflow(string fname, string content) { if (ModelState.IsValid) { content = content.Replace("\\n", "
").Replace("< ", "<").Replace(" >", ">"); var newOid = DocsDocument.UploadDocument(new DocumentInfo { Owner = User.Identity.Name, DocumentName = fname + ".xamlx", Description = "Sketch Workflow", Path = "/SketchWorkFlows/" }, Encoding.ASCII.GetBytes(content), DocumentUploadMode.Overwrite ); var sketches = TasksService.GetSketchForFilter(new GetSketchForFilterRequest { Name = fname, Statuses = new[] { SketchStatusType.SentToSketch } }); SketchStatusType sketchStatus = sketches.Sketches.Count() > 0 ? SketchStatusType.SentToSketch : SketchStatusType.Saved; TasksService.SketchWorkflow(new SketchWorkflowRequest { Name = fname, ChangedBy = User.Identity.Name, Status = sketchStatus, XamlxOid = newOid.ToString() }); return(Json("WorkFlow Saved!")); } return(Json("Error")); }