コード例 #1
0
        public string QueryDeleteList()
        {
            string form_name = Request.Forms("form_name");
            string typeid    = Request.Querys("typeid");
            string sidx      = Request.Forms("sidx");
            string sord      = Request.Forms("sord");

            int    size   = Tools.GetPageSize();
            int    number = Tools.GetPageNumber();
            string order  = (sidx.IsNullOrEmpty() ? "CreateDate" : sidx) + " " + (sord.IsNullOrEmpty() ? "DESC" : sord);

            Business.Form form  = new Business.Form();
            var           forms = form.GetPagerList(out int count, size, number, Current.UserId, form_name, "", order, 2);

            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
            Business.User user = new Business.User();
            foreach (System.Data.DataRow dr in forms.Rows)
            {
                Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject
                {
                    { "id", dr["Id"].ToString() },
                    { "Name", dr["Name"].ToString() },
                    { "CreateUserName", dr["CreateUserName"].ToString() },
                    { "CreateTime", dr["CreateDate"].ToString().ToDateTime().ToDateTimeString() },
                    { "LastModifyTime", dr["EditDate"].ToString().ToDateTime().ToDateTimeString() },
                    { "Edit", "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"reply('" + dr["Id"].ToString() + "', '" + dr["Name"].ToString() + "');return false;\"><i class=\"fa fa-reply\"></i>还原</a>" }
                };
                jArray.Add(jObject);
            }
            return("{\"userdata\":{\"total\":" + count + ",\"pagesize\":" + size + ",\"pagenumber\":" + number + "},\"rows\":" + jArray.ToString() + "}");
        }
コード例 #2
0
        public IActionResult Index1()
        {
            string formid = Request.Querys("formid");
            string attr = "{}", subtable = "[]", events = "[]", html = string.Empty;

            if (formid.IsGuid(out Guid fid))
            {
                var formModel = new Business.Form().Get(fid);
                if (null != formModel)
                {
                    if (!formModel.ManageUser.ContainsIgnoreCase(Current.UserId.ToLowerString()))
                    {
                        return(new ContentResult()
                        {
                            Content = "您不能管理当前表单"
                        });
                    }
                    attr     = formModel.attribute;
                    subtable = formModel.SubtableJSON;
                    events   = formModel.EventJSON;
                    html     = formModel.Html;
                }
            }
            ViewData["attr"]      = attr;
            ViewData["subtable"]  = subtable;
            ViewData["events"]    = events;
            ViewData["html"]      = html;
            ViewData["isNewForm"] = Request.Querys("isnewform");
            ViewData["typeId"]    = Request.Querys("typeid");
            ViewData["query"]     = "typeid=" + Request.Querys("typeid") + "&appid=" + Request.Querys("appid")
                                    + "&iframeid=" + Request.Querys("iframeid") + "&openerid=" + Request.Querys("openerid");
            ViewData["dbconnOptions"] = new Business.DbConnection().GetOptions();
            return(View());
        }
コード例 #3
0
        public IActionResult ImportSave()
        {
            var files = Request.Form.Files;

            if (files.Count == 0)
            {
                ViewData["errmsg"] = "您没有选择要导入的文件!";
                return(View());
            }
            Business.Form             form          = new Business.Form();
            System.Text.StringBuilder stringBuilder = new System.Text.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 = System.Text.Encoding.UTF8.GetString(b);
                string msg  = form.ImportForm(json);
                if (!"1".Equals(msg))
                {
                    stringBuilder.Append(msg + ",");
                }
            }
            if (stringBuilder.Length > 0)
            {
                ViewData["errmsg"] = stringBuilder.ToString().TrimEnd(',');
            }
            ViewData["queryString"] = Request.UrlQuery();
            return(View());
        }
コード例 #4
0
        public void Export()
        {
            string json = new Business.Form().GetExportFormString(Request.Querys("formid"));

            byte[] contents = System.Text.Encoding.UTF8.GetBytes(json);
            Response.Headers.Add("Server-FileName", "exportform.json");
            Response.ContentType = "application/octet-stream";
            Response.Headers.Add("Content-Disposition", "attachment; filename=exportform.json");
            Response.Headers.Add("Content-Length", contents.Length.ToString());
            Response.Body.Write(contents);
            Response.Body.Flush();
        }
コード例 #5
0
        public string Reply()
        {
            string formid = Request.Forms("formid");

            if (!formid.IsGuid(out Guid fid))
            {
                return("表单ID错误!");
            }
            Business.Form form      = new Business.Form();
            var           formModel = form.Get(fid);

            if (null == formModel)
            {
                return("没有找到要还原的表单!");
            }
            formModel.Status = 0;
            form.Update(formModel);
            return("还原成功!");
        }
コード例 #6
0
        public string Delete()
        {
            string[] formids        = Request.Forms("formid").Split(',');
            int      thoroughDelete = Request.Forms("thoroughdelete").ToInt(0);//是否彻底删除

            foreach (string formid in formids)
            {
                if (!formid.IsGuid(out Guid fid))
                {
                    return("表单ID为空!");
                }
                Business.Form form      = new Business.Form();
                var           formModel = form.Get(fid);
                if (null == formModel)
                {
                    return("没有找到要删除的表单!");
                }
                int i = new Business.Form().DeleteAndApplibrary(formModel, thoroughDelete);
                Business.Log.Add((0 != thoroughDelete ? "彻底" : "") + "删除了表单-" + formModel.Name, formModel.ToString(), Business.Log.Type.流程管理);
            }
            return("删除成功!");
        }
コード例 #7
0
        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("发布成功!");
        }
コード例 #8
0
        public string SaveForm()
        {
            string attr     = Request.Forms("attr");
            string events   = Request.Forms("event");
            string subtable = Request.Forms("subtable");
            string html     = Request.Forms("html");

            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();
            }
            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.ManageUser   = manageUser.ToLower();
            int i = isAdd ? form.Add(formModel) : form.Update(formModel);

            Business.Log.Add("保存了表单-" + name, formModel.ToString(), Business.Log.Type.流程管理);
            return("保存成功!");
        }