public string Save(Model.AppLibrary appLibraryModel) { if (!ModelState.IsValid) { return(Tools.GetValidateErrorMessag(ModelState)); } Business.AppLibrary appLibrary = new Business.AppLibrary(); if (Request.Querys("id").IsGuid(out Guid guid)) { var oldModel = appLibrary.Get(guid); string oldJSON = null == oldModel ? "" : oldModel.ToString(); appLibrary.Update(appLibraryModel); Business.Log.Add("修改了应用程序库-" + appLibraryModel.Title, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: appLibraryModel.ToString()); } else { appLibrary.Add(appLibraryModel); Business.Log.Add("添加了应用程序库-" + appLibraryModel.Title, appLibraryModel.ToString(), Business.Log.Type.系统管理); } return("保存成功!"); }
public IActionResult Edit() { string id = Request.Querys("id"); string appId = Request.Querys("appid"); string tabId = Request.Querys("tabid"); string typeId = Request.Querys("typeid"); string pageSize = Request.Querys("pagesize"); string pageNumber = Request.Querys("pagenumber"); Business.AppLibrary appLibrary = new Business.AppLibrary(); Model.AppLibrary appLibraryModel = null; if (id.IsGuid(out Guid guid)) { appLibraryModel = appLibrary.Get(guid); } if (null == appLibraryModel) { appLibraryModel = new Model.AppLibrary() { Id = Guid.NewGuid(), }; if (typeId.IsGuid(out Guid type)) { appLibraryModel.Type = type; } } ViewData["typeOptions"] = new Business.Dictionary().GetOptionsByCode("system_applibrarytype", value: appLibraryModel.Type.ToString()); ViewData["openModelOptions"] = new Business.Dictionary().GetOptionsByCode("system_appopenmodel", Business.Dictionary.ValueField.Value, appLibraryModel.OpenMode.ToString()); ViewData["appId"] = appId; ViewData["tabId"] = appId; ViewData["typeId"] = typeId; ViewData["pageSize"] = pageSize; ViewData["pageNumber"] = pageNumber; ViewData["queryString"] = Request.UrlQuery(); return(View(appLibraryModel)); }
/// <summary> /// 导入 /// </summary> /// <param name="json"></param> /// <returns>返回"1"表示成功,其它为错误信息</returns> public string Import(string json) { if (json.IsNullOrWhiteSpace()) { return("要导入的json为空!"); } Newtonsoft.Json.Linq.JArray jArray = null; try { jArray = Newtonsoft.Json.Linq.JArray.Parse(json); } catch { jArray = null; } if (null == jArray) { return("json解析错误!"); } foreach (Newtonsoft.Json.Linq.JObject jObject in jArray) { Model.AppLibrary appLibraryModel = jObject.ToObject <Model.AppLibrary>(); if (null == appLibraryModel) { continue; } if (Get(appLibraryModel.Id) != null) { Update(appLibraryModel); } else { Add(appLibraryModel); } } return("1"); }
/// <summary> /// 发布一个程序设计 /// </summary> /// <param name="id"></param> /// <param name="localizer">语言包</param> /// <returns></returns> public string Publish(Guid id, IStringLocalizer localizer = null) { string key = "ProgramRun_" + id.ToString("N"); Cache.IO.Remove(key); Model.Program programModel = Get(id); if (null == programModel) { return(localizer == null ? "没有找到要发布的程序!" : localizer["NotFoundModel"]); } //更新状态 programModel.Status = 1; Update(programModel); Model.ProgramRun programRunModel = GetRunModel(id); if (null == programRunModel) { return(localizer == null ? "没有找到要发布的程序!" : localizer["NotFoundModel"]); } #region 加入应用程序库 AppLibrary appLibrary = new AppLibrary(); var appModel = appLibrary.GetByCode(id.ToString()); bool isAdd = false; if (null == appModel) { isAdd = true; appModel = new Model.AppLibrary { Id = Guid.NewGuid(), Code = id.ToString() }; } appModel.Address = "/RoadFlowCore/ProgramDesigner/Run?programid=" + id.ToString(); appModel.OpenMode = 0; appModel.Title = programRunModel.Name; appModel.Type = programRunModel.Type; //多语言要写入不同语言的标题,这里只写一种 appModel.Title_en = programRunModel.Name; appModel.Title_zh = programRunModel.Name; if (isAdd) { appLibrary.Add(appModel); } else { appLibrary.Update(appModel); } #endregion #region 加按钮到应用程序库 AppLibraryButton appLibraryButton = new AppLibraryButton(); var buttons = appLibraryButton.GetListByApplibraryId(appModel.Id); var programButtons = new ProgramButton().GetAll(id); foreach (var button in programButtons) { var model = buttons.Find(p => p.Id == button.Id); bool isAddButton = false; if (null == model) { isAddButton = true; model = new Model.AppLibraryButton { Id = button.Id }; } model.AppLibraryId = appModel.Id; model.ButtonId = button.ButtonId; model.Events = button.ClientScript; model.Ico = button.Ico; model.IsValidateShow = button.IsValidateShow; model.Name = button.ButtonName; model.ShowType = button.ShowType; model.Sort = button.Sort; if (isAddButton) { appLibraryButton.Add(model); } else { appLibraryButton.Update(model); } } foreach (var button in buttons) { if (!programButtons.Exists(p => p.Id == button.Id)) { appLibraryButton.Delete(button.Id); } } #endregion return("1"); }
public string PublishForm() { string attr = Request.Forms("attr"); string events = Request.Forms("event"); string subtable = Request.Forms("subtable"); string html = Request.Forms("html"); string formHtml = Request.Forms("formHtml"); JObject jObject = null; try { jObject = JObject.Parse(attr); } catch { return("属性JSON解析错误!"); } string id = jObject.Value <string>("id"); string name = jObject.Value <string>("name"); string formType = jObject.Value <string>("formType"); string manageUser = jObject.Value <string>("manageUser"); if (!id.IsGuid(out Guid guid)) { return("表单ID不能为空!"); } if (name.IsNullOrWhiteSpace()) { return("表单名称为空,请在表单属性中填写名称!"); } if (!formType.IsGuid(out Guid typeId)) { return("表单分类不能为空,请在表单属性中选择分类!"); } if (manageUser.IsNullOrWhiteSpace())//如果没有指定管理者,则默认为创建人员 { manageUser = Business.Organize.PREFIX_USER + Current.UserId.ToString(); } #region 保存数据表 Business.Form form = new Business.Form(); Model.Form formModel = form.Get(guid); bool isAdd = false; if (null == formModel) { formModel = new Model.Form { Id = guid, Status = 0, CreateDate = DateExtensions.Now, CreateUserId = Current.UserId, CreateUserName = Current.UserName }; isAdd = true; } formModel.Name = name.Trim(); formModel.FormType = typeId; formModel.EventJSON = events; formModel.SubtableJSON = subtable; formModel.attribute = attr; formModel.Html = html; formModel.EditDate = DateExtensions.Now; formModel.Status = 1; formModel.RunHtml = formHtml; formModel.ManageUser = manageUser.ToLower(); int i = isAdd ? form.Add(formModel) : form.Update(formModel); #endregion #region 写入文件 string webRootPath = Current.WebRootPath; string path = webRootPath + "/RoadFlowResources/scripts/formDesigner/form/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string file = path + formModel.Id + ".rfhtml"; Stream stream = System.IO.File.Open(file, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); stream.SetLength(0); StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8); sw.Write(formHtml); sw.Close(); stream.Close(); #endregion #region 写入应用程序库 Business.AppLibrary appLibrary = new Business.AppLibrary(); var appModel = appLibrary.GetByCode(formModel.Id.ToString()); bool add = false; if (null == appModel) { add = true; appModel = new Model.AppLibrary { Id = Guid.NewGuid(), Code = formModel.Id.ToString() }; } appModel.Title = formModel.Name; appModel.Title_en = formModel.Name; appModel.Title_zh = formModel.Name; appModel.Type = formModel.FormType; appModel.Address = formModel.Id.ToString() + ".rfhtml"; int j = add ? appLibrary.Add(appModel) : appLibrary.Update(appModel); #endregion Business.Log.Add("发布了表单-" + name, formModel.ToString(), Business.Log.Type.流程管理, others: formHtml); return("发布成功!"); }
/// <summary> /// 更新应用 /// </summary> /// <param name="appLibrary"></param> /// <returns></returns> public int Update(Model.AppLibrary appLibrary) { return(appLibraryData.Update(appLibrary)); }
/// <summary> /// 添加应用 /// </summary> /// <param name="appLibrary"></param> /// <returns></returns> public int Add(Model.AppLibrary appLibrary) { return(appLibraryData.Add(appLibrary)); }