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)); } }
/// <summary> /// Sketch Workflow /// </summary> /// <param name="name">Name</param> /// <param name="xamlxOid">XamlxOid</param> /// <param name="changedBy">ChangedBy</param> /// <param name="status">Status</param> public void SketchWorkflow(string name, Guid xamlxOid, string changedBy, SketchStatusType status) { var sketchStatusStr = status.ToString(); using (var uofw = new FlowTasksUnitOfWork()) { var sketchStatus = uofw.SketchStatuses.FirstOrDefault(ss => ss.Status == sketchStatusStr); var sc = uofw.SketchConfigurations.FirstOrDefault(s => s.Name == name); if (sc == null) { sc = new SketchConfiguration { Name = name, XamlxOid = xamlxOid, ChangedBy = changedBy, LastSavedOn = DateTime.Now }; if (sketchStatus != null) { sc.SketchStatus = sketchStatus; } uofw.SketchConfigurations.Insert(sc); } else { if (sketchStatus != null) { sc.SketchStatus = sketchStatus; } sc.LastSavedOn = DateTime.Now; if (xamlxOid != Guid.Empty) { sc.XamlxOid = xamlxOid; } sc.ChangedBy = changedBy; } uofw.Commit(); } }
[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")); }