コード例 #1
0
        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");
        }
コード例 #2
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("发布成功!");
        }