public ActionResult BusinessObject(int id, int taskId) { bool userhasboright = false; JobsHelper jhelper = new JobsHelper(); var task = _inFlowDb.T_Tasks.Find(taskId); var boi = _db.BusinessObjectInstances.Find(id); bool readOnly = true; bool usercanaccessTask = jhelper.CanUserAccessTask(taskId, User.Identity.Name); if (usercanaccessTask) { if (task.EditableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhasboright = true; if (task.Done == false) { readOnly = false; } } else if (task.ReadableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhasboright = true; } } if (userhasboright) { BORender bor = new BORender(); ViewBOModel model = new ViewBOModel(); // dynamic model = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(boi.Data); model.BObjectIdentifier = id; //model.BObjectSchema = JObject.Parse(boi.BusinessObject.JsonSchema); //model.BObjectErrors = null; model.ViewData = bor.createHTML(boi.Data, boi.BusinessObject.JsonSchema, boi.BusinessObject.ViewData); model.ReadOnly = readOnly; ViewBag.TaskId = taskId; return(PartialView(model)); } else { return(PartialView("Accessdenied")); } }
public ActionResult SubmitBusinessObject(int id) { var schemastring = _BOdb.BusinessObjects.Find(id).JsonSchema; // string flat = Request.Form.ToString().Replace("%5b", "[").Replace("%5d", "]"); // string jsonstring = FlatJson.FlatJsonToJsonTree(flat, schemastring); string jsonstring = FlatJson.RequestFormToJsonTree(Request.Form, schemastring); JObject data = JObject.Parse(jsonstring); JsonSchema schema = JsonSchema.Parse(schemastring); IList <string> messages; bool valid = data.IsValid(schema, out messages); if (valid) { ViewBag.BObjectIdentifier = id; ViewBag.Json = jsonstring; Dictionary <string, string> model = new Dictionary <string, string>(); model.Add("json", jsonstring); return(PartialView(model)); } else { BORender bor = new BORender(); string boview = _BOdb.BusinessObjects.Find(id).ViewData; ViewBOModel model = new ViewBOModel(); //dynamic model = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(jsonstring); model.BObjectIdentifier = id; // model.BObjectSchema = JObject.Parse(schemastring); model.BObjectErrors = new List <string>(messages); model.ViewData = bor.createHTML(jsonstring, schemastring, boview); return(PartialView("PreviewBO", model)); } }
public ActionResult PreviewBO(int id) { var bo = _BOdb.BusinessObjects.Find(id); BORender bor = new BORender(); ViewBOModel model = new ViewBOModel(); //dynamic model = new dynamic();// Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(bo.DefaultData); model.BObjectIdentifier = id; //model.BObjectSchema = JObject.Parse(bo.JsonSchema); //model.BObjectErrors = null; model.ViewData = bor.createHTML(bo.DefaultData, bo.JsonSchema, bo.ViewData); //return View("~/Views/BusinessObject/BusinessObject.cshtml", "~/Views/BusinessObject/_BOLayout.cshtml", model); return(PartialView(model)); }
public ActionResult SubmitBusinessObject(int id, int taskId) { bool userhaseditrights = false; JobsHelper jhelper = new JobsHelper(); var task = _inFlowDb.T_Tasks.Find(taskId); var boi = _db.BusinessObjectInstances.Find(id); if (!task.Done) { bool usercanaccessTask = jhelper.CanUserAccessTask(taskId, User.Identity.Name); if (usercanaccessTask) { if (task.EditableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhaseditrights = true; } } } if (userhaseditrights) { var schemastring = _db.BusinessObjectInstances.Find(id).BusinessObject.JsonSchema; string jsonstring = FlatJson.RequestFormToJsonTree(Request.Form, schemastring); JObject data = JObject.Parse(jsonstring); JsonSchema schema = JsonSchema.Parse(schemastring); IList <string> messages; bool valid = data.IsValid(schema, out messages); if (valid) { ViewBag.BObjectIdentifier = id; ViewBag.Json = jsonstring; boi = _db.BusinessObjectInstances.Find(id); boi.Data = jsonstring; _db.SaveChanges(); Dictionary <string, string> model = new Dictionary <string, string>(); model.Add("json", jsonstring); return(PartialView(model)); } else { boi = _db.BusinessObjectInstances.Find(id); BORender bor = new BORender(); ViewBOModel model = new ViewBOModel(); //dynamic model = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(jsonstring); model.BObjectIdentifier = id; // model.BObjectSchema = JObject.Parse(schemastring); model.BObjectErrors = new List <string>(messages); model.ViewData = bor.createHTML(jsonstring, boi.BusinessObject.JsonSchema, boi.BusinessObject.ViewData); ViewBag.TaskId = taskId; return(PartialView("BusinessObject", model)); } } else { return(PartialView("Accessdenied")); } }