Example #1
0
        /// <summary>
        /// 删除附件
        /// </summary>
        /// <param name="attachIds">附件Id集合,多个以逗号分隔</param>
        /// <returns></returns>
        public ActionResult DeleteAttachment(string attachIds)
        {
            if (string.IsNullOrEmpty(attachIds))
            {
                return(Json(new ReturnResult {
                    Success = false, Message = "附件Id为空!"
                }));
            }
            if (_Request == null)
            {
                _Request = Request;
            }
            string[] token = attachIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (token.Length == 0)
            {
                return(Json(new ReturnResult {
                    Success = false, Message = "附件Id为空!"
                }));
            }
            List <Guid> delIds = token.Select(x => x.ObjToGuid()).Where(x => x != Guid.Empty).ToList();

            if (delIds == null || delIds.Count == 0)
            {
                return(Json(new ReturnResult {
                    Success = false, Message = "附件Id为空!"
                }));
            }
            string errMsg = string.Empty;
            List <Sys_Attachment> tempAttachments = CommonOperate.GetEntities <Sys_Attachment>(out errMsg, x => delIds.Contains(x.Id), null, false);

            errMsg = SystemOperate.DeleteAttachment(tempAttachments);
            return(Json(new ReturnResult {
                Success = string.IsNullOrEmpty(errMsg), Message = errMsg
            }));
        }
Example #2
0
 /// <summary>
 /// 网格数据处理
 /// </summary>
 /// <param name="data"></param>
 /// <param name="otherParams"></param>
 /// <param name="currUser"></param>
 public bool PageGridDataHandle(List <Bpm_WorkToDoList> data, object[] otherParams = null, UserInfo currUser = null)
 {
     if (data != null && data.Count > 0)
     {
         string errMsg = string.Empty;
         foreach (Bpm_WorkToDoList todo in data)
         {
             todo.ModuleName = SystemOperate.GetModuleNameById(todo.ModuleId);
             if (!todo.Bpm_WorkFlowInstanceId.HasValue)
             {
                 continue;
             }
             Bpm_WorkFlowInstance flowInst = BpmOperate.GetWorkflowInstanceById(todo.Bpm_WorkFlowInstanceId.Value);
             if (flowInst == null)
             {
                 continue;
             }
             todo.StatusOfEnum = flowInst.StatusOfEnum;
             int status = (int)flowInst.StatusOfEnum;
             Bpm_WorkToDoList tempTodo = CommonOperate.GetEntity <Bpm_WorkToDoList>(x => x.Bpm_WorkFlowInstanceId == todo.Bpm_WorkFlowInstanceId.Value && x.Status == status, null, out errMsg);
             if (tempTodo != null && !string.IsNullOrEmpty(todo.NextNodeHandler))
             {
                 List <Guid> tempEmpIds = tempTodo.NextNodeHandler.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(x => x.ObjToGuid()).Where(x => x != Guid.Empty).ToList();
                 if (tempEmpIds.Count > 0)
                 {
                     todo.OrgM_EmpName = string.Join(",", tempEmpIds.Select(x => OrgMOperate.GetEmpNameContainsQuit(x)).Where(x => !string.IsNullOrEmpty(x)));
                 }
             }
         }
     }
     return(false);
 }
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <returns></returns>
        public JsonResult AddDept()
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            string deptname = _Request.QueryEx("deptname").ObjToStr();

            if (string.IsNullOrWhiteSpace(deptname))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "部门名称不能为空"
                }));
            }
            string errMsg = string.Empty;
            long   num    = CommonOperate.Count <OrgM_Dept>(out errMsg, false, x => x.Name == deptname);

            if (num > 0)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "该部门已存在,请不要重复添加"
                }));
            }
            UserInfo  currUser = GetCurrentUser(_Request);
            Guid      moduleId = SystemOperate.GetModuleIdByTableName("OrgM_Dept");
            string    code     = SystemOperate.GetBillCode(moduleId);
            OrgM_Dept dept     = new OrgM_Dept()
            {
                Code           = code,
                Name           = deptname,
                Alias          = deptname,
                IsValid        = true,
                EffectiveDate  = DateTime.Now,
                CreateDate     = DateTime.Now,
                CreateUserId   = currUser.UserId,
                CreateUserName = currUser.EmpName,
                ModifyDate     = DateTime.Now,
                ModifyUserId   = currUser.UserId,
                ModifyUserName = currUser.EmpName
            };
            Guid deptId = CommonOperate.OperateRecord <OrgM_Dept>(dept, ModelRecordOperateType.Add, out errMsg, null, false);

            if (deptId != Guid.Empty)
            {
                SystemOperate.UpdateBillCode(moduleId, code);
                return(Json(new { Success = true, Message = string.Empty, DeptId = deptId, DeptName = deptname }));
            }
            else
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
        }
Example #4
0
        /// <summary>
        /// 从request中取moduleId
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static Guid GetModuleIdByRequest(HttpRequest request)
        {
            Sys_Module module = SystemOperate.GetModuleByRequest(request);

            if (module != null)
            {
                return(module.Id);
            }
            return(Guid.Empty);
        }
 /// <summary>
 /// 表单数据处理
 /// </summary>
 /// <param name="t">对象</param>
 /// <param name="formType">表单类型</param>
 /// <param name="currUser"></param>
 public void FormDataHandle(Sys_Field t, Model.EnumSpace.FormTypeEnum formType, UserInfo currUser = null)
 {
     if (t != null && t.Sys_ModuleId.HasValue)
     {
         string tableName = SystemOperate.GetModuleTableNameById(t.Sys_ModuleId.Value);
         Dictionary <string, string> dic = ToolOperate.GetDbColumnInfo(tableName, t.Name);
         t.DbType = dic["ColumnType"].ObjToStr();
         t.DbLen  = dic["Length"].ObjToInt();
     }
 }
        public IActionResult ExecCreateSwfTask()
        {
            Guid?  moduleId = Request.QueryEx("moduleId").ObjToGuidNull();
            Guid?  attachId = Request.QueryEx("attachId").ObjToGuidNull();
            string errMsg   = SystemOperate.ExecCreateSwfTask(moduleId, attachId);

            return(Json(new ReturnResult()
            {
                Success = string.IsNullOrEmpty(errMsg), Message = errMsg
            }));
        }
Example #7
0
 public void FormDataHandle(Sys_DbConfig t, Model.EnumSpace.FormTypeEnum formType, UserInfo currUser = null)
 {
     if (t != null)
     {
         TbIndexInfo tbIndexInfo = SystemOperate.GetTableIndexInfo(t.ModuleName);
         if (tbIndexInfo != null)
         {
             t.CurrPageDensity = tbIndexInfo.FragmentationPercent;
         }
     }
 }
Example #8
0
 /// <summary>
 /// 模块操作完成后
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="t"></param>
 /// <param name="result"></param>
 /// <param name="currUser"></param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, Sys_Module t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (operateType == ModelRecordOperateType.Del && result)
     {
         if (t.IsCustomerModule)
         {
             //自定义模块删除后要删除对应的字段、表单、表单字段、列表、列表字段、列表按钮、字典绑定等信息
             SystemOperate.DeleteModuleReferences(t);
         }
     }
 }
Example #9
0
        /// <summary>
        /// 获取modeljs的HTML
        /// </summary>
        /// <param name="module">模块</param>
        /// <param name="request">请求对象</param>
        /// <returns></returns>
        public static string GetModelJsHTML(Sys_Module module, HttpRequest request)
        {
            string html       = string.Empty;
            bool   isFullPath = request != null ? request.Query[CommonDefine.NoFrameFlag].ObjToInt() == 1 : false; //JS显示全路径
            string modelJs    = SystemOperate.GetModuleJsFilePath(module, isFullPath);

            if (!string.IsNullOrEmpty(modelJs))
            {
                //模块自定义js
                html = string.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", modelJs);
            }
            return(html);
        }
 public void PageGridDataHandle(List <Sys_DbConfig> data, object[] otherParams = null, UserInfo currUser = null)
 {
     if (data != null && data.Count > 0)
     {
         foreach (Sys_DbConfig t in data)
         {
             TbIndexInfo tbIndexInfo = SystemOperate.GetTableIndexInfo(t.ModuleName);
             if (tbIndexInfo != null)
             {
                 t.CurrPageDensity = tbIndexInfo.FragmentationPercent;
             }
         }
     }
 }
Example #11
0
 /// <summary>
 /// 模块集合操作完成后
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="ts"></param>
 /// <param name="result"></param>
 /// <param name="currUser"></param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandles(ModelRecordOperateType operateType, List <Sys_Module> ts, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (operateType == ModelRecordOperateType.Del && result)
     {
         List <Sys_Module> tempModules = ts.Where(x => x.IsCustomerModule).ToList();
         if (tempModules.Count > 0)
         {
             //自定义模块删除后要删除对应的字段、表单、表单字段、列表、列表字段、列表按钮、字典绑定等信息
             foreach (Sys_Module t in tempModules)
             {
                 SystemOperate.DeleteModuleReferences(t);
             }
         }
     }
 }
 /// <summary>
 /// 保存后
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="t"></param>
 /// <param name="result"></param>
 /// <param name="currUser"></param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, Sys_FormField t, bool result, Frame.Base.UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string        errMsg = string.Empty;
         Sys_FormField tempT  = CommonOperate.GetEntityById <Sys_FormField>(t.Id, out errMsg);
         bool          isFormEnableMemeryCache = ModelConfigHelper.IsModelEnableMemeryCache(typeof(Sys_Form)); //Sys_Form是否启动内存缓存
         if (tempT.Sys_FormId.HasValue && isFormEnableMemeryCache)
         {
             Sys_Form form = SystemOperate.GetForm(tempT.Sys_FormId.Value);
             if (form != null)
             {
                 form.FormFields = null;
             }
         }
     }
 }
Example #13
0
 /// <summary>
 /// 操作完成
 /// </summary>
 /// <param name="operateType"></param>
 /// <param name="t"></param>
 /// <param name="result"></param>
 /// <param name="currUser"></param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, Sys_GridField t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         Sys_GridField tempT = SystemOperate.GetAllGridFields(x => x.Id == t.Id).FirstOrDefault();
         bool          isGridEnableMemeryCache = ModelConfigHelper.IsModelEnableMemeryCache(typeof(Sys_Grid)); //Sys_Grid是否启动内存缓存
         if (tempT.Sys_GridId.HasValue && isGridEnableMemeryCache)
         {
             Sys_Grid grid = SystemOperate.GetGrid(tempT.Sys_GridId.Value);
             if (grid != null)
             {
                 grid.GridFields = null;
             }
         }
         //string errMsg = string.Empty;
         //CommonOperate.UpdateRecordsByExpression<Sys_GridField>(new { FieldFormatter = "", EditorFormatter = "" }, x => x.Id == t.Id, out errMsg);
     }
 }
Example #14
0
 /// <summary>
 /// 应用程序启动
 /// </summary>
 public static void Application_Start()
 {
     try
     {
         //异步处理异常处理,阻止程序崩溃
         TaskScheduler.UnobservedTaskException += (sender, args) =>
         {
             foreach (var ex in args.Exception.InnerExceptions)
             {
                 LogOperate.AddExceptionLog(ex, string.Empty);
             }
             args.SetObserved();
         };
     }
     catch { }
     try
     {
         //向各数据库注册存储过程
         SystemOperate.RegStoredProcedure();
         //在当前数据库中自动注册外部链接数据库服务器
         SystemOperate.RegCrossDbServer();
     }
     catch { }
     try
     {
         //加载所有启用缓存的模块数据
         if (GlobalSet.IsStartLoadCache)
         {
             SystemOperate.LoadAllModuleCache();
         }
     }
     catch { }
     //调用自定义应用程序启动方法
     try
     {
         InitFactory factory = InitFactory.GetInstance();
         if (factory != null)
         {
             factory.App_Start();
         }
     }
     catch { }
     //string msg = ToolOperate.CreateTempModelDLL();
 }
 /// <summary>
 /// 字段操作完成后
 /// </summary>
 /// <param name="operateType">操作类型</param>
 /// <param name="t">字段对象</param>
 /// <param name="result">操作结果</param>
 /// <param name="currUser">当前用户</param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, Sys_Field t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string errMsg = string.Empty;
         if (operateType == ModelRecordOperateType.Edit)
         {
             if (!string.IsNullOrEmpty(t.Display)) //修改了字段显示名称
             {
                 List <Sys_GridField> gridFields = SystemOperate.GetAllGridFields(x => x.Sys_FieldId == t.Id);
                 if (gridFields.Count > 0)
                 {
                     gridFields.ForEach(x => { x.Display = t.Display; });
                     CommonOperate.OperateRecords <Sys_GridField>(gridFields, ModelRecordOperateType.Edit, out errMsg, false);
                 }
                 List <Sys_FormField> formFields = CommonOperate.GetEntities <Sys_FormField>(out errMsg, x => x.Sys_FieldId == t.Id, null, false);
                 if (formFields != null && formFields.Count > 0)
                 {
                     formFields.ForEach(x => { x.Display = t.Display; });
                     CommonOperate.OperateRecords <Sys_FormField>(formFields, ModelRecordOperateType.Edit, out errMsg, false);
                 }
                 Sys_Field tempField = SystemOperate.GetFieldById(t.Id);
                 if (tempField.Sys_ModuleId.HasValue)
                 {
                     Sys_Module module = SystemOperate.GetModuleById(tempField.Sys_ModuleId.Value);
                     if (module != null && !string.IsNullOrEmpty(module.TitleKeyDisplay))
                     {
                         module.TitleKeyDisplay = tempField.Display;
                     }
                 }
             }
         }
         else if (operateType == ModelRecordOperateType.Del)
         {
             //字段信息删除后删除相应的表单字段和列表字段
             //删除列表字段
             Sys_Module gridFieldModule = SystemOperate.GetModuleByTableName(typeof(Sys_GridField).Name);
             CommonOperate.DeleteRecordsByExpression <Sys_GridField>(x => x.Sys_FieldId == t.Id, out errMsg, gridFieldModule.IsEnabledRecycle);
             //删除表单字段
             Sys_Module formFieldModule = SystemOperate.GetModuleByTableName(typeof(Sys_FormField).Name);
             CommonOperate.DeleteRecordsByExpression <Sys_FormField>(x => x.Sys_FieldId == t.Id, out errMsg, formFieldModule.IsEnabledRecycle);
         }
     }
 }
 /// <summary>
 /// 网格数据处理
 /// </summary>
 /// <param name="data"></param>
 /// <param name="otherParams"></param>
 /// <param name="currUser"></param>
 public void PageGridDataHandle(List <Sys_Menu> data, object[] otherParams = null, UserInfo currUser = null)
 {
     if (data != null)
     {
         List <Sys_Menu> list = new List <Sys_Menu>();
         foreach (Sys_Menu menu in data)
         {
             Sys_Menu temp = new Sys_Menu();
             ObjectHelper.CopyValue <Sys_Menu>(menu, temp);
             string url = SystemOperate.GetIconUrl(menu.Icon);
             if (!string.IsNullOrEmpty(url))
             {
                 temp.Icon = string.Format("<img src=\"{0}\" />", url);
             }
             list.Add(temp);
         }
         data = list;
     }
 }
 /// <summary>
 /// 操作执行前
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     try
     {
         base.OnActionExecuting(filterContext);
         Sys_Module module = SystemOperate.GetModuleByRequest(filterContext.HttpContext.Request);
         if (module == null)
         {
             string moduleName = filterContext.HttpContext.Request["moduleName"].ObjToStr();
             if (string.IsNullOrEmpty(moduleName))
             {
                 moduleName = filterContext.ActionParameters.ContainsKey("moduleName") ? filterContext.ActionParameters["moduleName"].ObjToStr() : string.Empty;
                 if (string.IsNullOrEmpty(moduleName))
                 {
                     Guid moduleId = filterContext.ActionParameters.ContainsKey("moduleId") ? filterContext.ActionParameters["moduleId"].ObjToGuid() : Guid.Empty;
                     opExecuteTime.ModuleName = moduleId != Guid.Empty ? SystemOperate.GetModuleNameById(moduleId) : string.Empty;
                 }
                 else
                 {
                     opExecuteTime.ModuleName = filterContext.HttpContext.Server.UrlDecode(moduleName);
                 }
             }
             else
             {
                 opExecuteTime.ModuleName = filterContext.HttpContext.Server.UrlDecode(moduleName);
             }
         }
         else
         {
             opExecuteTime.ModuleName = module.Name;
         }
         string controllerName = filterContext.RouteData.Values["controller"].ToString();
         string actionName     = filterContext.RouteData.Values["action"].ToString();
         opExecuteTime.ControllerName = controllerName;
         opExecuteTime.ActionName     = actionName;
         UserInfo currUser = UserInfo.GetCurretnUser(ApplicationObject.GetHttpContext(filterContext.HttpContext.Request));
         opExecuteTime.OpUserName = currUser.UserName;
         opExecuteTime.ClientIp   = WebHelper.GetClientIP(filterContext.HttpContext.Request);
         startTime = DateTime.Now;
     }
     catch { }
 }
 /// <summary>
 /// 网格数据处理
 /// </summary>
 /// <param name="data">数据集合</param>
 /// <param name="otherParams">其他参数</param>
 /// <param name="currUser">当前用户</param>
 public void PageGridDataHandle(List <Sys_Field> data, object[] otherParams = null, UserInfo currUser = null)
 {
     if (data != null && data.Count > 0)
     {
         foreach (Sys_Field field in data)
         {
             if (!field.Sys_ModuleId.HasValue)
             {
                 continue;
             }
             string tableName = SystemOperate.GetModuleTableNameById(field.Sys_ModuleId.Value);
             Dictionary <string, string> dic = ToolOperate.GetDbColumnInfo(tableName, field.Name);
             if (dic.ContainsKey("ColumnType"))
             {
                 field.DbType = dic["ColumnType"].ObjToStr();
             }
             if (dic.ContainsKey("Length"))
             {
                 field.DbLen = dic["Length"].ObjToInt();
             }
         }
     }
 }
        /// <summary>
        /// 添加职务
        /// </summary>
        /// <returns></returns>
        public JsonResult AddDuty()
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            Guid deptId = _Request.QueryEx("deptId").ObjToGuid();

            if (deptId == Guid.Empty)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "请先选择部门"
                }));
            }
            OrgM_Dept dept = OrgMOperate.GetDeptById(deptId);

            if (dept == null)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "选择的部门不存在"
                }));
            }
            string dutyname = _Request.QueryEx("dutyname").ObjToStr();

            if (string.IsNullOrWhiteSpace(dutyname))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "职务名称不能为空"
                }));
            }
            string errMsg = string.Empty;
            long   num    = CommonOperate.Count <OrgM_Dept>(out errMsg, false, x => x.Name == dutyname);

            if (num > 0)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "该职务已存在,请不要重复添加"
                }));
            }
            UserInfo  currUser = GetCurrentUser(_Request);
            Guid      moduleId = SystemOperate.GetModuleIdByTableName("OrgM_Duty");
            string    code     = SystemOperate.GetBillCode(moduleId);
            OrgM_Duty duty     = new OrgM_Duty()
            {
                Code           = code,
                Name           = dutyname,
                IsValid        = true,
                EffectiveDate  = DateTime.Now,
                CreateDate     = DateTime.Now,
                CreateUserId   = currUser.UserId,
                CreateUserName = currUser.EmpName,
                ModifyDate     = DateTime.Now,
                ModifyUserId   = currUser.UserId,
                ModifyUserName = currUser.EmpName
            };
            Guid dutyId = CommonOperate.OperateRecord <OrgM_Duty>(duty, ModelRecordOperateType.Add, out errMsg, null, false);

            if (dutyId != Guid.Empty)
            {
                SystemOperate.UpdateBillCode(moduleId, code);
                Guid?parentId = null;
                List <OrgM_DeptDuty> positions = OrgMOperate.GetDeptPositions(deptId);
                if (positions.Count > 0)
                {
                    OrgM_DeptDuty leaderPosition = positions.Where(x => x.IsDeptCharge).FirstOrDefault();
                    if (leaderPosition != null)
                    {
                        parentId = leaderPosition.Id;
                    }
                }
                Guid          gwModuleId   = SystemOperate.GetModuleIdByTableName("OrgM_DeptDuty");
                string        positionCode = SystemOperate.GetBillCode(gwModuleId);
                OrgM_DeptDuty position     = new OrgM_DeptDuty()
                {
                    Code        = positionCode,
                    Name        = string.Format("{0}-{1}", string.IsNullOrEmpty(dept.Alias) ? dept.Name : dept.Alias, dutyname),
                    OrgM_DeptId = deptId,
                    OrgM_DutyId = dutyId,
                    ParentId    = parentId,
                    IsValid     = true
                };
                Guid positionId = CommonOperate.OperateRecord <OrgM_DeptDuty>(position, ModelRecordOperateType.Add, out errMsg, null, false);
                if (positionId != Guid.Empty)
                {
                    SystemOperate.UpdateBillCode(gwModuleId, positionCode);
                }
                return(Json(new { Success = true, Message = string.Empty, DutyId = dutyId }));
            }
            else
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
        }
Example #20
0
 /// <summary>
 /// 添加后台系统任务
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="e"></param>
 public static void SysBackgroundTaskAdd(object obj, EventArgs e)
 {
     if (WebConfigHelper.GetAppSettingValue("IsRunBgTask") == "true")
     {
         try
         {
             #region 重建索引
             //重建索引任务
             BackgroundTask reBuildIndexTask = new BackgroundTask((args) =>
             {
                 if (DateTime.Now.Hour == 4 && DateTime.Now.Minute == 0)
                 {
                     SystemOperate.RebuildAllTableIndex();
                 }
                 return(true);
             }, null, false, 45, false);
             AutoProcessTask.AddTask(reBuildIndexTask);
             #endregion
             #region 迁移历史审批数据
             //审批完成后的数据迁移到待办历史数据表中,针对审批是迁移失败的处理
             BackgroundTask todoStatusHandleTask = new BackgroundTask((args) =>
             {
                 if ((DateTime.Now.Hour == 3 && DateTime.Now.Minute == 0) ||
                     (DateTime.Now.Hour == 12 && DateTime.Now.Minute == 40))
                 {
                     //审批完成数据迁移异常处理
                     try
                     {
                         string errMsg    = string.Empty;
                         int refuseStatus = (int)WorkFlowStatusEnum.Refused;
                         int overStatus   = (int)WorkFlowStatusEnum.Over;
                         int obsoStatus   = (int)WorkFlowStatusEnum.Obsoleted;
                         List <Bpm_WorkFlowInstance> flowInsts = CommonOperate.GetEntities <Bpm_WorkFlowInstance>(out errMsg, x => x.Status == refuseStatus || x.Status == overStatus || x.Status == obsoStatus, null, false);
                         if (flowInsts != null && flowInsts.Count > 0)
                         {
                             foreach (Bpm_WorkFlowInstance flowInst in flowInsts)
                             {
                                 BpmOperate.TransferWorkToDoHistory(flowInst, null);
                             }
                         }
                     }
                     catch { }
                 }
                 return(true);
             }, null, false, 45, false);
             AutoProcessTask.AddTask(todoStatusHandleTask);
             #endregion
             #region 附件在线预览生成
             BackgroundTask attachOnlineViewHandleTask = new BackgroundTask((args) =>
             {
                 if (DateTime.Now.Hour == 4 && DateTime.Now.Minute == 0)
                 {
                     string attachWeb = WebConfigHelper.GetAppSettingValue("AttachmentWeb");
                     if (!string.IsNullOrEmpty(attachWeb))
                     {
                         if (!attachWeb.EndsWith("/"))
                         {
                             attachWeb += "/";
                         }
                         string apiUrl        = attachWeb + "api/AnnexApi/ExecCreateSwfTask.html";
                         DataMutual dataMutal = new DataMutual(apiUrl);
                         dataMutal.Start(null);
                     }
                 }
                 return(true);
             }, null, false, 45, false);
             AutoProcessTask.AddTask(attachOnlineViewHandleTask);
             #endregion
             #region 基于DB的失效分布式锁释放
             BackgroundTask dbLockReleaseHandleTask = new BackgroundTask((args) =>
             {
                 if (WebConfigHelper.GetAppSettingValue("EnabledDistributeLock") == "true") //启用分布式锁
                 {
                     string errMsg      = string.Empty;
                     double nowTimesamp = Globals.GetTimestamp(DateTime.Now);//当前时间戳
                     CommonOperate.DeleteRecordsByExpression <Other_DistributedLock>(x => x.Invalid_Timesamp < nowTimesamp, out errMsg);
                 }
                 return(true);
             }, null, false, 60, false);
             AutoProcessTask.AddTask(dbLockReleaseHandleTask);
             #endregion
         }
         catch { }
     }
     try
     {
         InitFactory factory = InitFactory.GetInstance();
         if (factory != null)
         {
             factory.AddBackgroundTask();
         }
     }
     catch { }
 }
        /// <summary>
        /// 上传附件,兼容非表单附件
        /// </summary>
        /// <param name="file">文件</param>
        /// <returns></returns>
        public JsonResult UploadAttachment(IFormFileCollection file)
        {
            if (file == null || file.Count() == 0)
            {
                return(Json(new ReturnResult {
                    Success = false, Message = "请选择上传文件!"
                }));
            }
            if (_Request == null)
            {
                _Request = Request;
            }
            SetRequest(_Request);
            Guid?                 moduleId    = _Request.QueryEx("moduleId").ObjToGuidNull(); //模块Id,针对表单附件
            Guid?                 id          = _Request.QueryEx("id").ObjToGuidNull();       //记录Id,针对表单附件
            bool                  isCreateSwf = _Request.QueryEx("isCreateSwf").ObjToBool();  //是否创建SWF文件
            string                attachType  = _Request.QueryEx("attachType").ObjToStr();    //附件类型
            string                message     = string.Empty;
            StringBuilder         msg         = new StringBuilder();
            List <AttachFileInfo> fileMsg     = new List <AttachFileInfo>();

            foreach (var item in file)
            {
                try
                {
                    string fileSize = FileOperateHelper.FileSize(item.Length);
                    string fileType = Path.GetExtension(item.FileName);
                    string fileName = item.FileName;
                    string pathFlag = System.IO.Path.DirectorySeparatorChar.ToString();
                    int    s        = fileName.LastIndexOf(pathFlag);
                    if (s >= 0)
                    {
                        fileName = fileName.Substring(s + 1);
                    }
                    //保存文件
                    string filePath = string.Empty;
                    if (moduleId.HasValue) //表单附件
                    {
                        filePath = UploadFileManager.SaveAs(item, "Attachment", "Temp");
                    }
                    else
                    {
                        filePath = UploadFileManager.SaveAs(item, "Temp");
                    }
                    filePath = filePath.StartsWith("~/") ? filePath : filePath.StartsWith("/") ? "~" + filePath : "~/" + filePath;
                    //swf保存路径
                    string swfPath = string.Empty;
                    //pdf保存路径
                    string pdfPath = string.Empty;
                    if (isCreateSwf && !moduleId.HasValue)
                    {
                        //exe路径
                        string exePath = WebHelper.MapPath("~/bin/SWFTools/pdf2swf.exe");
                        //bin路径
                        string binPath = WebHelper.MapPath("~/bin/");
                        if (fileType.Equals(".doc") || fileType.Equals(".docx") ||
                            fileType.Equals(".xls") || fileType.Equals(".xlsx") ||
                            fileType.Equals(".ppt") || fileType.Equals(".pptx") ||
                            fileType.Equals(".pdf"))
                        {
                            //取pdf和swf路径
                            SystemOperate.GetSwfFilePath(out pdfPath, out swfPath);
                            //参数
                            string[] obj = new string[] { fileType, WebHelper.MapPath(filePath), WebHelper.MapPath(pdfPath), WebHelper.MapPath(swfPath), exePath, binPath };
                            SystemOperate.CreateSwfFile(obj);
                        }
                    }
                    fileMsg.Add(new AttachFileInfo()
                    {
                        AttachFile = filePath, PdfFile = pdfPath, SwfFile = swfPath, FileName = fileName, FileType = fileType, FileSize = fileSize, AttachType = attachType
                    });
                }
                catch (Exception ex)
                {
                    msg.AppendLine(item.FileName + "上传失败:" + ex.Message);
                    break;
                }
            }
            if (moduleId.HasValue && moduleId.Value != Guid.Empty && id.HasValue && id.Value != Guid.Empty) //查看页面,直接保存附件
            {
                return(SaveFormAttach(moduleId.Value, id.Value, JsonHelper.Serialize(fileMsg), true));
            }
            return(Json(new
            {
                Success = string.IsNullOrEmpty(msg.ToString()),
                Message = string.IsNullOrEmpty(msg.ToString()) ? "上传成功" : msg.ToString(),
                FileMsg = fileMsg.Count > 0 ? JsonHelper.Serialize(fileMsg) : string.Empty
            }));
        }
        /// <summary>
        /// 添加操作日志
        /// </summary>
        /// <param name="operateUser">操作用户</param>
        /// <param name="moduleId">模块Id</param>
        /// <param name="opType">操作类型,如新增、修改、删除等</param>
        /// <param name="opContent">操作内容</param>
        /// <param name="IsOpSuccess">是否成功</param>
        /// <param name="opErrMsg">操作异常信息</param>
        public static void AddOperateLog(UserInfo operateUser, Guid moduleId, string opType, string opContent, bool IsOpSuccess, string opErrMsg)
        {
            string moduleName = SystemOperate.GetModuleNameById(moduleId);

            AddOperateLog(operateUser, moduleName, opType, opContent, IsOpSuccess, opErrMsg);
        }
Example #23
0
 /// <summary>
 /// 员工操作完成
 /// </summary>
 /// <param name="operateType">操作类型</param>
 /// <param name="t">员工对象</param>
 /// <param name="result">操作结果</param>
 /// <param name="currUser">当前用户</param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, OrgM_Emp t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string errMsg      = string.Empty;
         string username    = OrgMOperate.GetUserNameByEmp(t);
         string userInitPwd = WebConfigHelper.GetAppSettingValue("UserInitPwd");
         if (string.IsNullOrEmpty(userInitPwd))
         {
             userInitPwd = "123456";
         }
         if (operateType == ModelRecordOperateType.Add)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.AddUser(out errMsg, username, userInitPwd, null, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Edit)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 Sys_User user = UserOperate.GetUser(username);
                 if (user != null) //用户已存在
                 {
                     UserOperate.UpdateUserAliasName(username, t.Name);
                 }
                 else //用户不存在
                 {
                     UserOperate.AddUser(out errMsg, username, userInitPwd, null, t.Name);
                 }
             }
         }
         else if (operateType == ModelRecordOperateType.Del)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.DelUser(username); //删除账号
             }
             //删除员工同时删除员工岗位
             CommonOperate.DeleteRecordsByExpression <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id, out errMsg, t.IsDeleted);
         }
         if (operateType == ModelRecordOperateType.Add || operateType == ModelRecordOperateType.Edit)
         {
             //新增编辑时同时设置员工主职岗位
             if (t.DeptId.HasValue && t.DeptId.Value != Guid.Empty && t.DutyId.HasValue && t.DutyId.Value != Guid.Empty)
             {
                 OrgM_EmpDeptDuty empPosition = null;
                 if (operateType == ModelRecordOperateType.Edit)
                 {
                     empPosition = CommonOperate.GetEntity <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id && x.IsMainDuty == true, null, out errMsg);
                     if (empPosition != null)
                     {
                         empPosition.OrgM_DeptId    = t.DeptId.Value;
                         empPosition.OrgM_DutyId    = t.DutyId.Value;
                         empPosition.IsValid        = true;
                         empPosition.ModifyDate     = DateTime.Now;
                         empPosition.ModifyUserId   = currUser.UserId;
                         empPosition.ModifyUserName = currUser.EmpName;
                         CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Edit, out errMsg, null, false);
                         return;
                     }
                 }
                 Guid   moduleId = SystemOperate.GetModuleIdByModelType(typeof(OrgM_EmpDeptDuty));
                 string code     = SystemOperate.GetBillCode(moduleId);
                 empPosition = new OrgM_EmpDeptDuty()
                 {
                     Code           = code,
                     OrgM_DeptId    = t.DeptId.Value,
                     OrgM_DutyId    = t.DutyId.Value,
                     OrgM_EmpId     = t.Id,
                     IsMainDuty     = true,
                     IsValid        = true,
                     EffectiveDate  = DateTime.Now,
                     CreateDate     = DateTime.Now,
                     CreateUserId   = currUser.UserId,
                     CreateUserName = currUser.EmpName,
                     ModifyDate     = DateTime.Now,
                     ModifyUserId   = currUser.UserId,
                     ModifyUserName = currUser.EmpName
                 };
                 Guid rs = CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Add, out errMsg, null, false);
                 if (rs != Guid.Empty)
                 {
                     SystemOperate.UpdateBillCode(moduleId, code);
                 }
             }
         }
     }
 }
        public JsonResult UserForgetPwd(string username)
        {
            string userTipDes = "用户名";

            if (GlobalSet.EmpUserNameConfigRule == UserNameAndEmpConfigRule.Email)
            {
                userTipDes = "邮箱";
            }
            else if (GlobalSet.EmpUserNameConfigRule == UserNameAndEmpConfigRule.Mobile)
            {
                userTipDes = "手机号";
            }
            if (string.IsNullOrEmpty(username))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = string.Format("{0}不能为空!", userTipDes)
                }));
            }
            if (GlobalSet.EmpUserNameConfigRule == UserNameAndEmpConfigRule.Email && !Validator.IsEmail(username))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "请输入正确的邮箱地址!"
                }));
            }
            if (GlobalSet.EmpUserNameConfigRule == UserNameAndEmpConfigRule.Mobile && !Validator.IsMobilePhoneNumber(username))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "请输入正确的手机号码!"
                }));
            }
            string errMsg = string.Empty;
            bool   rs     = UserOperate.UserIsValid(username, out errMsg);

            if (!rs)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = errMsg
                }));
            }
            string email = username;

            if (GlobalSet.EmpUserNameConfigRule != UserNameAndEmpConfigRule.Email)
            {
                OrgM_Emp emp = OrgMOperate.GetEmpByUserName(username);
                if (emp != null)
                {
                    email = OrgMOperate.GetEmployeeEmails(new List <Guid>()
                    {
                        emp.Id
                    }).Keys.FirstOrDefault();
                }
            }
            if (!email.Contains("@"))
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "获取用户邮箱失败!"
                }));
            }
            Dictionary <string, string> dicMail = new Dictionary <string, string>();

            dicMail.Add(email, email);
            string   subject = string.Format("重置您在{0}的密码", WebConfigHelper.GetCurrWebName());
            Sys_User user    = UserOperate.GetUser(username);
            string   content = GetForgetPwdSendContent(user);

            errMsg = SystemOperate.EmailSend(subject, content, dicMail, null, null, null, true);
            return(Json(new ReturnResult()
            {
                Success = string.IsNullOrEmpty(errMsg), Message = errMsg
            }));
        }
Example #25
0
        /// <summary>
        /// 获取modeljs的HTML
        /// </summary>
        /// <param name="moduleId">模块id</param>
        /// <param name="request">请求对象</param>
        /// <returns></returns>
        public static string GetModelJsHTML(Guid moduleId, HttpRequest request)
        {
            Sys_Module module = SystemOperate.GetModuleById(moduleId);

            return(GetModelJsHTML(module, request));
        }
Example #26
0
        /// <summary>
        /// 保存表单附件
        /// </summary>
        /// <param name="moduleId">模块Id</param>
        /// <param name="id">记录Id</param>
        /// <param name="fileMsg">文件信息</param>
        /// <param name="isAdd">是否只是添加</param>
        /// <returns></returns>
        public ActionResult SaveFormAttach(Guid moduleId, Guid id, string fileMsg, bool isAdd = false)
        {
            if (string.IsNullOrEmpty(fileMsg))
            {
                return(Json(new ReturnResult {
                    Success = true, Message = string.Empty
                }));
            }
            if (_Request == null)
            {
                _Request = Request;
            }
            SetRequest(_Request);
            string errMsg = string.Empty;
            List <AttachFileInfo> addAttachs = null;

            try
            {
                string pathFlag = "\\";
                if (WebConfigHelper.GetAppSettingValue("IsLinux") == "true")
                {
                    pathFlag = "/";
                }
                UserInfo              currUser   = GetCurrentUser(_Request);
                Guid?                 userId     = currUser != null ? currUser.UserId : (Guid?)null;
                string                userName   = currUser != null ? currUser.UserName : string.Empty;
                Sys_Module            module     = SystemOperate.GetModuleById(moduleId);
                List <AttachFileInfo> attachInfo = JsonHelper.Deserialize <List <AttachFileInfo> >(HttpUtility.UrlDecode(fileMsg, Encoding.UTF8));
                #region  除已经移除的附件
                if (!isAdd) //非新增状态
                {
                    List <Guid> existIds = new List <Guid>();
                    if (attachInfo != null && attachInfo.Count > 0)
                    {
                        existIds = attachInfo.Select(x => x.Id.ObjToGuid()).Where(x => x != Guid.Empty).ToList();
                    }
                    //对已删除的附件进行处理
                    List <Sys_Attachment> tempAttachments = CommonOperate.GetEntities <Sys_Attachment>(out errMsg, x => x.Sys_ModuleId == moduleId && x.RecordId == id, null, false);
                    if (tempAttachments != null)
                    {
                        tempAttachments = tempAttachments.Where(x => !existIds.Contains(x.Id)).ToList();
                    }
                    SystemOperate.DeleteAttachment(tempAttachments);
                }
                #endregion
                #region 添加附件
                if (attachInfo != null && attachInfo.Count > 0)
                {
                    addAttachs = new List <AttachFileInfo>();
                    //日期文件夹
                    string dateFolder = DateTime.Now.ToString("yyyyMM", DateTimeFormatInfo.InvariantInfo);
                    //记录对应的titleKey值
                    string titleKeyValue       = CommonOperate.GetModelTitleKeyValue(moduleId, id);
                    List <Sys_Attachment> list = new List <Sys_Attachment>();
                    foreach (AttachFileInfo info in attachInfo)
                    {
                        if (string.IsNullOrEmpty(info.AttachFile))
                        {
                            continue;
                        }
                        if (info.Id.ObjToGuid() != Guid.Empty)
                        {
                            continue;                                                                              //原来的附件
                        }
                        string oldAttchFile = _Request.RequestContext.HttpContext.Server.MapPath(info.AttachFile); //临时附件
                        string dir          = string.Format("{0}Upload{3}Attachment{3}{1}{3}{2}", Globals.GetWebDir(), module.TableName, dateFolder, pathFlag);
                        if (!Directory.Exists(dir))                                                                //目录不存在则创建
                        {
                            Directory.CreateDirectory(dir);
                        }
                        string newAttachFile = string.Format("{0}{4}{1}_{2}{3}", dir, Path.GetFileNameWithoutExtension(info.FileName), id, Path.GetExtension(info.FileName), pathFlag);
                        try
                        {
                            System.IO.File.Copy(oldAttchFile, newAttachFile, true); //复制文件
                        }
                        catch (Exception ex)
                        {
                            return(Json(new ReturnResult {
                                Success = false, Message = ex.Message
                            }, "text/plain"));
                        }
                        //文件复制完成后删除临时文件
                        try
                        {
                            System.IO.File.Delete(oldAttchFile);
                        }
                        catch { }
                        string newPdfFile = string.Empty; //pdf文件
                        string newSwfFile = string.Empty; //swf文件
                        //可以转换成swf的进行转换
                        if (info.FileType.Equals(".doc") || info.FileType.Equals(".docx") ||
                            info.FileType.Equals(".xls") || info.FileType.Equals(".xlsx") ||
                            info.FileType.Equals(".ppt") || info.FileType.Equals(".pptx") ||
                            info.FileType.Equals(".pdf"))
                        {
                            newPdfFile = string.Format("{0}{2}{1}.pdf", dir, Path.GetFileNameWithoutExtension(newAttachFile), pathFlag);
                            newSwfFile = string.Format("{0}{2}{1}.swf", dir, Path.GetFileNameWithoutExtension(newAttachFile), pathFlag);
                            string   exePath = _Request.RequestContext.HttpContext.Server.MapPath("~/bin/SWFTools/pdf2swf.exe");
                            string   binPath = _Request.RequestContext.HttpContext.Server.MapPath("~/bin/");
                            string[] obj     = new string[] { info.FileType, newAttachFile, newPdfFile, newSwfFile, exePath, binPath };
                            CreateSwfFile(obj);
                        }
                        //构造文件URL,保存为相对URL地址
                        string fileUrl   = string.Format("Upload/Attachment/{0}/{1}/{2}", module.TableName, dateFolder, Path.GetFileName(newAttachFile));
                        string pdfUrl    = string.IsNullOrEmpty(newPdfFile) ? string.Empty : newPdfFile.Replace(Globals.GetWebDir(), string.Empty).Replace("\\", "/");
                        string swfUrl    = string.IsNullOrEmpty(newSwfFile) ? string.Empty : newSwfFile.Replace(Globals.GetWebDir(), string.Empty).Replace("\\", "/");
                        Guid   attachiId = Guid.NewGuid();
                        info.Id = attachiId.ToString();
                        list.Add(new Sys_Attachment()
                        {
                            Id                  = attachiId,
                            Sys_ModuleId        = moduleId,
                            Sys_ModuleName      = module.Name,
                            RecordId            = id,
                            RecordTitleKeyValue = titleKeyValue,
                            FileName            = info.FileName,
                            FileType            = info.FileType,
                            FileSize            = info.FileSize,
                            FileUrl             = fileUrl,
                            PdfUrl              = pdfUrl,
                            SwfUrl              = swfUrl,
                            AttachType          = info.AttachType,
                            CreateDate          = DateTime.Now,
                            CreateUserId        = userId,
                            CreateUserName      = userName,
                            ModifyDate          = DateTime.Now,
                            ModifyUserId        = userId,
                            ModifyUserName      = userName
                        });
                        string tempUrl = "/" + fileUrl;
                        if (!string.IsNullOrEmpty(swfUrl))
                        {
                            tempUrl = string.Format("/Page/DocView.html?fn={0}&swfUrl={1}", HttpUtility.UrlEncode(info.FileName).Replace("+", "%20"), HttpUtility.UrlEncode(swfUrl).Replace("+", "%20"));
                        }
                        info.AttachFile = tempUrl;
                        info.PdfFile    = pdfUrl;
                        info.SwfFile    = swfUrl;
                        addAttachs.Add(info);
                    }
                    if (list.Count > 0)
                    {
                        Guid attachModuleId = SystemOperate.GetModuleIdByName("附件信息");
                        bool rs             = CommonOperate.OperateRecords(attachModuleId, list, ModelRecordOperateType.Add, out errMsg, false);
                        if (!rs)
                        {
                            addAttachs = null;
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            return(Json(new { Success = string.IsNullOrEmpty(errMsg), Message = errMsg, AddAttachs = addAttachs }, "text/plain"));
        }
        public string GetEditDetailHTML(Guid?id, out bool detailTopDisplay, Guid?copyId = null, HttpRequestBase request = null)
        {
            detailTopDisplay = false;
            StringBuilder sb            = new StringBuilder();
            Sys_Module    module        = id.HasValue ? SystemOperate.GetModuleById(id.Value) : null;
            bool          overwriteFlag = module != null ? module.IsCustomerModule : true;

            if (overwriteFlag) //新增页面或者自定义模块
            {
                detailTopDisplay = true;
                sb.Append("<div title=\"模块字段\">");
                sb.Append("<div id=\"regon_\">");
                sb.Append("<table id=\"grid_\" class=\"easyui-datagrid\" data-options=\"border:false,toolbar:'#toolbar',singleSelect:true,onClickCell:OnCellClick\">");
                sb.Append("<thead>");
                sb.Append("<tr>");
                sb.Append("<th data-options=\"title:'ID',field:'Id',checkbox:true\">ID</th>");
                StringBuilder fieldTypeData = new StringBuilder("[");
                fieldTypeData.Append("{id:'varchar',text:'字符串型'},");
                fieldTypeData.Append("{id:'int',text:'整型'},");
                fieldTypeData.Append("{id:'guid',text:'Guid型'},");
                fieldTypeData.Append("{id:'bit',text:'布尔型'},");
                fieldTypeData.Append("{id:'date',text:'日期型'},");
                fieldTypeData.Append("{id:'datetime',text:'时间型'},");
                fieldTypeData.Append("{id:'decimal',text:'数值型'}");
                fieldTypeData.Append("]");
                sb.Append("<th data-options=\"title:'字段类型',field:'FieldType',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'FieldType'," + fieldTypeData + ");},editor:{type:'combobox',options:{valueField:'id',editable:false,textField:'text',data:" + fieldTypeData.ToString() + ",required:true,onSelect:OnFieldTypeSelected}}\">字段类型</th>");
                sb.Append("<th data-options=\"title:'外键模块',field:'ForeignModuleName',width:100,align:'center',editor:{type:'combobox',options:{valueField:'Name',textField:'Name',editable:true,onSelect:OnSelectForeignModule}}\">外键模块</th>");
                sb.Append("<th data-options=\"title:'字段名',field:'FieldName',width:100,align:'center',editor:{type:'textbox',options:{required:true}}\">字段名</th>");
                sb.Append("<th data-options=\"title:'字段长度',field:'FieldLen',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">字段长度</th>");
                sb.Append("<th data-options=\"title:'显示名称',field:'Display',width:100,align:'center',editor:{type:'textbox',options:{required:true}}\">显示名称</th>");
                sb.Append("<th data-options=\"title:'是否表单显示',field:'IsEnableForm',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'IsEnableForm');},editor:{type:'checkbox',options:{on:'1',off:'0'}}\">是否表单显示</th>");
                sb.Append("<th data-options=\"title:'控件类型',field:'ControlType',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'ControlType');},editor:{type:'combobox',options:{valueField:'id',editable:false,textField:'text',required:true}}\">控件类型</th>");
                sb.Append("<th data-options=\"title:'控件宽度',field:'ControlWidth',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">控件宽度</th>");
                sb.Append("<th data-options=\"title:'是否必填',field:'IsRequired',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'IsRequired');},editor:{type:'checkbox',options:{on:'1',off:'0'}}\">是否必填</th>");
                sb.Append("<th data-options=\"title:'所在行',field:'RowNum',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">所在行</th>");
                sb.Append("<th data-options=\"title:'所在列',field:'ColNum',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">所在列</th>");
                sb.Append("<th data-options=\"title:'是否列表显示',field:'IsEnableGrid',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'IsEnableGrid');},editor:{type:'checkbox',options:{on:'1',off:'0'}}\">是否列表显示</th>");
                sb.Append("<th data-options=\"title:'列头宽度',field:'HeadWidth',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">列头宽度</th>");
                sb.Append("<th data-options=\"title:'列排序编号',field:'HeadSort',width:100,align:'center',editor:{type:'numberbox',options:{precision:0}}\">列排序编号</th>");
                sb.Append("<th data-options=\"title:'允许搜索',field:'IsAllowGridSearch',width:100,align:'center',formatter:function(value,row,index){return FormatField(value,row,index,'IsAllowGridSearch');},editor:{type:'checkbox',options:{on:'1',off:'0'}}\">允许搜索</th>");
                sb.Append("</tr>");
                sb.Append("</thead>");
                if (module != null)
                {
                    string              modelDll    = string.Format("{0}TempModel\\{1}.dll", Globals.GetBinPath(), module.TableName);
                    Assembly            dllAssembly = Assembly.LoadFrom(modelDll);
                    Type                modelType   = dllAssembly.GetTypes().Where(x => x.Name == module.TableName).FirstOrDefault();
                    List <PropertyInfo> ps          = modelType.GetProperties().ToList();
                    sb.Append("<tbody>");
                    foreach (PropertyInfo p in ps)
                    {
                        if (CommonDefine.BaseEntityFieldsContainId.Contains(p.Name))
                        {
                            continue;
                        }
                        FieldConfigAttribute fieldAttr = (FieldConfigAttribute)Attribute.GetCustomAttribute(p, typeof(FieldConfigAttribute));
                        if (fieldAttr == null)
                        {
                            continue;
                        }
                        Sys_Field sysField = SystemOperate.GetFieldInfo(module.Id, p.Name);
                        if (sysField == null)
                        {
                            continue;
                        }
                        int    fieldLen  = 0;
                        string fieldType = "varchar";
                        if (p.PropertyType == typeof(String))
                        {
                            StringLengthAttribute stringLenAttr = (StringLengthAttribute)Attribute.GetCustomAttribute(p, typeof(StringLengthAttribute));
                            if (stringLenAttr != null)
                            {
                                fieldLen = stringLenAttr.MaximumLength;
                            }
                            else
                            {
                                fieldLen = 8000;
                            }
                        }
                        else if (p.PropertyType == typeof(Boolean) || p.PropertyType == typeof(Boolean?))
                        {
                            fieldLen  = 1;
                            fieldType = "bit";
                        }
                        else if (p.PropertyType == typeof(Int32) || p.PropertyType == typeof(Int32?))
                        {
                            fieldLen  = 4;
                            fieldType = "int";
                        }
                        else if (p.PropertyType == typeof(Guid) || p.PropertyType == typeof(Guid?))
                        {
                            fieldLen  = 36;
                            fieldType = "guid";
                        }
                        else if (p.PropertyType == typeof(Decimal) || p.PropertyType == typeof(Decimal?))
                        {
                            fieldLen  = 20;
                            fieldType = "decimal";
                        }
                        else if (p.PropertyType == typeof(DateTime) || p.PropertyType == typeof(DateTime?))
                        {
                            if (fieldAttr.ControlType == (int)ControlTypeEnum.DateBox)
                            {
                                fieldType = "date";
                            }
                            else
                            {
                                fieldType = "datetime";
                            }
                            fieldLen = 20;
                        }
                        Sys_FormField field     = SystemOperate.GetNfDefaultFormSingleField(sysField);
                        Sys_Grid      grid      = SystemOperate.GetDefaultGrid(module.Id);
                        Sys_GridField gridField = SystemOperate.GetGridFields(grid.Id, false).Where(x => x.Sys_FieldId == sysField.Id).FirstOrDefault();
                        sb.Append("<tr>");
                        sb.AppendFormat("<td>{0}</td>", sysField.Id);                                                                              //字段Id
                        sb.AppendFormat("<td>{0}</td>", fieldType);                                                                                //字段类型
                        sb.AppendFormat("<td>{0}</td>", sysField.ForeignModuleName.ObjToStr());                                                    //外键模块
                        sb.AppendFormat("<td>{0}</td>", p.Name);                                                                                   //字段名
                        sb.AppendFormat("<td>{0}</td>", fieldLen);                                                                                 //字段长度
                        sb.AppendFormat("<td>{0}</td>", sysField.Display);                                                                         //显示名称
                        sb.AppendFormat("<td>{0}</td>", field != null ? "1" : "0");                                                                //是否表单显示
                        sb.AppendFormat("<td>{0}</td>", field != null ? field.ControlType.ToString() : string.Empty);                              //控件类型
                        sb.AppendFormat("<td>{0}</td>", field == null || field.Width == 0 ? 180 : field.Width);                                    //控件宽度
                        sb.AppendFormat("<td>{0}</td>", field == null ? string.Empty : (field.IsRequired == true ? "1" : "0"));                    //是否必填
                        sb.AppendFormat("<td>{0}</td>", field != null ? field.RowNo.ToString() : string.Empty);                                    //所在行
                        sb.AppendFormat("<td>{0}</td>", field != null ? field.ColNo.ToString() : string.Empty);                                    //所在列
                        sb.AppendFormat("<td>{0}</td>", gridField != null ? "1" : "0");                                                            //是否列表显示
                        sb.AppendFormat("<td>{0}</td>", gridField != null && gridField.Width.HasValue ? gridField.Width.Value.ToString() : "120"); //列头宽度
                        sb.AppendFormat("<td>{0}</td>", gridField != null ? gridField.Sort.ToString() : string.Empty);                             //列排序编号
                        sb.AppendFormat("<td>{0}</td>", gridField != null ? (gridField.IsAllowSearch ? "1" : "0") : string.Empty);                 //允许搜索
                        sb.Append("</tr>");
                    }
                    sb.Append("</tbody>");
                }
                sb.Append("</table>");
                //网格工具栏和搜索框
                sb.Append("<div id=\"toolbar\" class=\"toolbar datagrid-toolbar\" style=\"height:27px;\">");
                sb.Append("<a id=\"btnAdd\" href=\"#\" style=\"float:left;\" class=\"easyui-linkbutton\" data-options=\"plain:true,iconCls:'eu-icon-add'\" onclick=\"AddField()\">新增</a>");
                sb.Append("<a id=\"btnDel\" href=\"#\" style=\"float:left;\" class=\"easyui-linkbutton\" data-options=\"plain:true,iconCls:'eu-p2-icon-delete2'\" onclick=\"DelField()\">删除</a>");
                sb.Append("</div>");
                sb.Append("</div>");
                sb.Append("</div>");
                sb.Append("<script type=\"text/javascript\" src=\"/Scripts/common/Grid.js\"></script>");
            }
            return(sb.ToString());
        }