public IActionResult SelectDiv_Index() { string applibaryid = Request.Querys("applibaryid"); if (!applibaryid.IsGuid(out Guid appId)) { return(new ContentResult() { Content = "参数错误!" }); } var app = new Business.AppLibrary().Get(appId); if (app != null && !app.Address.IsNullOrEmpty()) { var query = Request.UrlQuery(); string url = app.Address + (app.Address.Contains("?") ? "&" + query.TrimStart('?') : query); return(Redirect(url)); } else { return(new ContentResult() { Content = "参数错误!" }); } }
public string Delete() { string ids = Request.Forms("ids"); var models = new Business.AppLibrary().Delete(ids); Business.Log.Add("删除了应用程序库", Newtonsoft.Json.JsonConvert.SerializeObject(models), Business.Log.Type.系统管理); return("删除成功!"); }
public void Export() { string json = new Business.AppLibrary().GetExportString(Request.Querys("ids")); byte[] contents = Encoding.UTF8.GetBytes(json); Response.Headers.Add("Server-FileName", "dictionary.json"); Response.ContentType = "application/octet-stream"; Response.Headers.Add("Content-Disposition", "attachment; filename=applibrary.json"); Response.Headers.Add("Content-Length", contents.Length.ToString()); Response.Body.Write(contents); Response.Body.Flush(); }
/// <summary> /// 得到一个类别的应用下拉选项 /// </summary> /// <returns></returns> public string GetOptionsByAppType() { string type = Request.Forms("type"); string value = Request.Forms("value"); var childs = new Business.AppLibrary().GetListByType(type.ToGuid()); StringBuilder stringBuilder = new StringBuilder(); foreach (var child in childs) { stringBuilder.Append("<option value=\"" + child.Id + "\""); if (child.Id == value.ToGuid()) { stringBuilder.Append(" selected=\"selected\""); } stringBuilder.Append(">"); stringBuilder.Append(child.Title); stringBuilder.Append("</option>"); } return(stringBuilder.ToString()); }
public string SelectDiv_GetTitle() { string applibaryid = Request.Querys("applibaryid"); if (!applibaryid.IsGuid(out Guid appId)) { return(""); } var app = new Business.AppLibrary().Get(appId); if (null == app || app.Code.IsNullOrWhiteSpace() || !app.Code.IsGuid(out Guid pId)) { return(""); } string titlefield = Request.Querys("titlefield"); string pkfield = Request.Querys("pkfield"); string values = Request.Querys("values"); return(new Business.Program().GetTitles(values, pkfield, titlefield, pId)); }
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 string UnInstall() { string[] flowIds = Request.Forms("flowid").Split(','); int thoroughDelete = Request.Forms("thoroughdelete").ToInt(0);//是否彻底删除 string status = Request.Forms("status"); Business.Flow flow = new Business.Flow(); foreach (var flowId in flowIds) { var flowModel = flow.Get(flowId.ToGuid()); if (null == flowModel) { continue; } if (0 == thoroughDelete)//作删除标记或卸载标记 { int status1 = status.ToInt(3); Business.Log.Add(("2".Equals(status) ? "卸载" : "删除") + "了流程-" + flowModel.Name, flowModel.ToString(), Business.Log.Type.流程管理); flowModel.Status = status1; flow.Update(flowModel); } else//彻底删除 { flow.Delete(flowModel); //删除应用程序库 Business.AppLibrary appLibrary = new Business.AppLibrary(); var appModel = appLibrary.GetByCode(flowModel.Id.ToString()); if (null != appModel) { new Business.AppLibrary().Delete(appModel.Id); } //删除流程实例 new Business.FlowTask().DeleteByFlowId(flowModel.Id); Business.Log.Add("彻底删除了流程-" + flowModel.Name, flowModel.ToString(), Business.Log.Type.流程管理); } flow.ClearCache(flowModel.Id); } return("1"); }
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)); }
public string Query() { string Title = Request.Forms("Title"); string Address = Request.Forms("Address"); string typeid = Request.Forms("typeid"); string sidx = Request.Forms("sidx"); string sord = Request.Forms("sord"); int size = Tools.GetPageSize(); int number = Tools.GetPageNumber(); string order = (sidx.IsNullOrEmpty() ? "Type,Title" : sidx) + " " + (sord.IsNullOrEmpty() ? "ASC" : sord); Business.Dictionary dictionary = new Business.Dictionary(); if (typeid.IsGuid(out Guid typeId)) { var childsId = dictionary.GetAllChildsId(typeId); typeid = childsId.JoinSqlIn(); } var appLibraries = new Business.AppLibrary().GetPagerList(out int count, size, number, Title, Address, typeid, order); Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray(); foreach (System.Data.DataRow dr in appLibraries.Rows) { Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject { { "id", dr["Id"].ToString() }, { "Title", dr["Title"].ToString() }, { "Address", dr["Address"].ToString() }, { "TypeTitle", dictionary.GetTitle(dr["Type"].ToString().ToGuid()) }, { "Opation", "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"edit('" + dr["Id"].ToString() + "');return false;\"><i class=\"fa fa-edit (alias)\"></i>编辑</a>" + "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"editButton('" + dr["Id"].ToString() + "');return false;\"><i class=\"fa fa-square-o\"></i>按钮</a>" } }; jArray.Add(jObject); } return("{\"userdata\":{\"total\":" + count + ",\"pagesize\":" + size + ",\"pagenumber\":" + number + "},\"rows\":" + jArray.ToString() + "}"); }
public IActionResult ImportSave() { var files = Request.Form.Files; if (files.Count == 0) { ViewData["errmsg"] = "您没有选择要导入的文件!"; return(View()); } Business.AppLibrary appLibrary = new Business.AppLibrary(); StringBuilder stringBuilder = new StringBuilder(); foreach (var file in files) { var stream = file.OpenReadStream(); int count = (int)stream.Length; byte[] b = new byte[count]; int readCount = 0; while (readCount < count) { readCount += stream.Read(b, readCount, 1024); } string json = Encoding.UTF8.GetString(b); string msg = appLibrary.Import(json); if (!"1".Equals(msg)) { stringBuilder.Append(msg + ","); } } if (stringBuilder.Length > 0) { ViewData["errmsg"] = stringBuilder.ToString().TrimEnd(','); } ViewData["queryString"] = Request.UrlQuery(); return(View()); }
/// <summary> /// 作废任务 /// </summary> /// <returns></returns> public string DeleteTask() { string deltaskid = Request.Querys("deltaskid"); if (!deltaskid.IsGuid(out Guid taskId)) { return("Id错误!"); } Business.FlowTask flowTask = new Business.FlowTask(); var taskModel = flowTask.Get(taskId); if (null == taskModel) { return("作废成功!"); } flowTask.DeleteByGroupId(taskModel.GroupId); var flowrunModel = new Business.Flow().GetFlowRunModel(taskModel.FlowId); if (null == flowrunModel) { return("作废成功!"); } var stepModel = flowrunModel.Steps.Find(p => p.Id == taskModel.StepId); if (null == stepModel) { return("作废成功!"); } var applibrary = new Business.AppLibrary().Get(stepModel.StepForm.Id); if (null != applibrary && applibrary.Code.IsGuid(out Guid formId)) { new Business.Form().DeleteFormData(formId, taskModel.InstanceId); } return("作废成功!"); }
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("发布成功!"); }