示例#1
0
        public string Delete(string id)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                SysParam sysParam = sysParamService.GetDomain(id);
                if (!string.IsNullOrWhiteSpace(id))
                {
                    sysParamService.Delete(id);
                    sysParamService.ClearCache();

                    doResult = DoResult.Success;

                    //获取提示信息
                    actionMessage = RemarkAttribute.GetEnumRemark(doResult);

                    ajaxResult.Result = doResult;
                    ajaxResult.RetValue = CurrentId;
                    ajaxResult.PromptMsg = actionMessage;
                }
                AddActionLog<SysParam>(string.Format("删除系统参数{0}={1}", sysParam.Name, sysParam.Value), doResult);
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);

            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string Delete(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                if (!string.IsNullOrWhiteSpace(argument))
                {
                    personalParamService.Delete(argument);
                    personalParamService.ClearCache();
                    doResult = DoResult.Success;

                    //获取提示信息
                    actionMessage = RemarkAttribute.GetEnumRemark(doResult);

                    ajaxResult.Result = doResult;
                    ajaxResult.RetValue = CurrentId;
                    ajaxResult.PromptMsg = actionMessage;

                }
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#3
0
        public ActionResult DeleteProcess(string processDefID)
        {
            AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed };
            string actionMessage = string.Format("删除流程定义{0}", processDefID);
            try
            {
                ProcessDef processDef = repository.GetDomain<ProcessDef>(processDefID);
                if (processDef != null)
                {
                    repository.Delete<ProcessDef>(processDef);
                    ajaxResult.Result = DoResult.Success;
                    ajaxResult.RetValue = processDefID;
                    actionMessage += "成功";
                    AddActionLog<ProcessDef>(processDef, ajaxResult.Result, actionMessage);
                }
            }
            catch (Exception ex)
            {
                actionMessage += "出错";
                log.Error(actionMessage, ex);
                AddActionLog<ProcessDef>(actionMessage, ajaxResult.Result);
            }

            ajaxResult.PromptMsg = actionMessage;
            return Json(ajaxResult);
        }
        public void Delete()
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                repository.Delete<ProcessDef>(CurrentId);
                actionResult = DoResult.Success;

                //获取提示信息
                actionMessage = "删除成功!";

                ajaxResult.RetValue = CurrentId;
                ajaxResult.PromptMsg = actionMessage;

                Refresh();
                ajaxResult.Result = actionResult;
            }
            catch (Exception ex)
            {
                actionMessage = "删除失败!";
                log.Error(actionMessage, ex);
            }

            WebUtil.PromptMsg(actionMessage);
        }
示例#5
0
        public ActionResult DeleteProcessInst(string processInstID)
        {
            AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed };
            string actionMessage = string.Format("删除流程实例{0}", processInstID);
            try
            {
                IWorkflowEngine engine = new WorkflowEngine();
                engine.DeleteProcessInst(processInstID);
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = AgileEAP.Workflow.Enums.ProcessInstStatus.Terminated.GetRemark();
                actionMessage += "成功";
            }
            catch (Exception ex)
            {
                actionMessage += "出错";
                log.Error(actionMessage, ex);
            }
            finally
            {
                AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
            }

            ajaxResult.PromptMsg = actionMessage;
            return Json(ajaxResult);
        }
示例#6
0
        public JsonResult DrawProcess()
        {
            AjaxResult ajaxResult = new AjaxResult()
            {
                Result = DoResult.Failed,
                PromptMsg = "操作失败"
            };
            string processDefID = Request.Form["processDefID"];
            string processDefContent = Request.Form["processDefContent"];
            ProcessDefine processDefine = new ProcessDefine(processDefContent, false);
            string processInstID = Request.Form["ProcessInstID"];
            try
            {
                var process = new { processDefID = processDefID, processInstID = processInstID, processDefine = processDefine };
                ajaxResult.RetValue = process;
                ajaxResult.Result = DoResult.Success;
                ajaxResult.PromptMsg = "操作成功";
            }
            catch (Exception ex)
            {
                log.Error("获取流程" + processInstID + "异常,原因:" + ex.Message);
            }

            return Json(ajaxResult, new Newtonsoft.Json.Converters.StringEnumConverter());
        }
示例#7
0
 public JsonResult GetprocessDefContent()
 {
     AjaxResult ajaxResult = new AjaxResult()
     {
         Result = DoResult.Failed,
         PromptMsg = "操作失败"
     };
     try
     {
         string json = Request.Form["processDefContent"];
         ProcessDefine processDefine = JsonConvert.DeserializeObject<ProcessDefine>(json, new ActivityConvert());
         string processDefContent = processDefine.ToXml();
         ajaxResult.RetValue = processDefContent;
         ajaxResult.Result = DoResult.Success;
         ajaxResult.PromptMsg = "操作成功";
     }
     catch (Exception ex)
     {
         log.Error("获取工作流定义失败" + ex.Message);
         ajaxResult.RetValue = false;
         ajaxResult.Result = DoResult.Failed;
         ajaxResult.PromptMsg = "操作失败";
     }
     return Json(ajaxResult);
 }
示例#8
0
        public string Rollback(string json)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string workItemID = Request.QueryString["workItemID"];
            string actionMessage = string.Format("退回工作流实例工作项{0}", workItemID);
            try
            {
                //回退工作项
                engine.RollbackWorkItem(User, workItemID);

                ajaxResult.Result = DoResult.Success;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                log.Error(actionMessage, ex);
            }
            finally
            {
                AddActionLog<WorkItem>(actionMessage, ajaxResult.Result);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#9
0
        public string Delete(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                DictItem item = dictItemService.GetDomain(argument);
                if (item != null)
                {
                    repository.Delete<DictItem>(item);
                    repository.ClearCache<DictItem>();
                    doResult = DoResult.Success;

                    //获取提示信息
                    actionMessage = RemarkAttribute.GetEnumRemark(doResult);

                    ajaxResult.Result = doResult;
                    ajaxResult.RetValue = CurrentId;
                    ajaxResult.PromptMsg = actionMessage;
                    AddActionLog<Dict>(string.Format("删除字典项{0}={1}", item.Value, item.Text), doResult);
                }
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string Save(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            try
            {
                IList<string> parameters = argument.Trim(',').Split(',').ToList();
                // IList<AjaxTreeNode> parameters = JsonConvert.DeserializeObject<IList<AjaxTreeNode>>(argument);
                string userID = Request.QueryString["UserID"];
                short authFlag = Request.QueryString["AuthFlag"].ToSafeString().ToShort(0);
                if (string.IsNullOrEmpty(userID))
                {
                    ajaxResult.Result = DoResult.Failed;
                    ajaxResult.PromptMsg = "用户对象为空!";
                    log.Error("用户对象为空");
                    return JsonConvert.SerializeObject(ajaxResult);
                }

                if (string.IsNullOrEmpty(userID))
                {
                    ajaxResult.Result = DoResult.Failed;
                    ajaxResult.PromptMsg = "角色ID为空!";
                    log.Error("角色ID为空");
                    return JsonConvert.SerializeObject(ajaxResult);
                }

                if (parameters == null || parameters.Count == 0)
                {
                    ajaxResult.PromptMsg = "您没有选择任何资源,请选择后再保存!";
                    return JsonConvert.SerializeObject(ajaxResult);
                }

                IList<SpecialPrivilege> specialPrivileges = parameters.Where(o => o != "tempAccess").Select(p => new SpecialPrivilege()
                {
                    ID = IdGenerator.NewComb().ToSafeString(),
                    AuthFlag = authFlag,
                    Authorizer = User.ID,
                    AuthTime = DateTime.Now,
                    OperatorID = userID,
                    OwnerOrg = GetOrgPath(),
                    PrivilegeID = p
                }).ToList();

                authService.SaveSpecialPrivilege(specialPrivileges);

                ajaxResult.RetValue = string.Empty;
                ajaxResult.Result = DoResult.Success;
                ajaxResult.PromptMsg = "保存成功!";
                WebUtil.CloseDialog();
            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                ajaxResult.PromptMsg = "保存角色出错,请联系管理员!";
                log.Error(ex);
            }
            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#11
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="argument"></param>
        public string DeleteTreeNode(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Catalog catalog = catalogService.GetDomain(argument);

                List<Catalog> childDict = catalogService.All().Where(o => o.ParentID == catalog.ID).ToList(); //删除的目录下的子目录

                List<UploadFile> uploadFile = new UploadFileService().All().Where(o => o.CatalogID == catalog.ID).ToList();//删除的目录下的文件

                if (childDict.Count > 0 || uploadFile.Count > 0)
                {
                    actionMessage = "该目录下存在子目录或文件,不允许删除!";
                    ajaxResult.PromptMsg = actionMessage;
                }
                else
                {
                    if (catalog != null)
                    {
                        catalogService.Delete(catalog);
                        doResult = DoResult.Success;
                    }
                    else
                    {
                        doResult = DoResult.Failed;
                    }
                    string directoryPath = Path.Combine(Server.MapPath("~"), catalog.Path);
                    if (Directory.Exists(directoryPath))
                        Directory.Delete(directoryPath);  //删除物理目录路径
                    //获取提示信息
                    actionMessage = string.Format("删除目录{0}成功", catalog.Path);
                }

                //记录操作日志
                AddActionLog(catalog, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = catalog.ParentID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#12
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="argument"></param>
        public string DeleteTreeNode(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Organization org = repository.GetDomain<Organization>(argument);
                if (org != null)
                {
                    IDictionary<string, object> parameters = new Dictionary<string, object>();
                    parameters.SafeAdd("OrgID", org.ID);
                    IList<EmployeeOrg> employeeOrgList = repository.FindAll<EmployeeOrg>(parameters);
                    if (employeeOrgList.Count == 0)
                    {
                        repository.Delete<Organization>(org.ID);
                        doResult = DoResult.Success;
                    }
                    else
                    {
                        doResult = DoResult.Failed;
                        actionMessage = "请先删除该部门下面的操作员!";
                    }
                }
                else
                {
                    doResult = DoResult.Failed;
                }

                //获取提示信息
                actionMessage = string.Format("删除组织{0}", org.Name);

                //记录操作日志
                AddActionLog(org, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = org.ParentID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                log.Error(actionMessage, ex);
                AddActionLog<Organization>(actionMessage, DoResult.Failed);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string Save(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            try
            {
                IList<string> parameters = argument.Trim(',').Split(',').ToList();

                string roleID = Request.QueryString["RoleID"];

                if (string.IsNullOrEmpty(roleID))
                {
                    ajaxResult.Result = DoResult.Failed;
                    ajaxResult.PromptMsg = "角色ID为空!";
                    log.Error("角色ID为空");
                    return JsonConvert.SerializeObject(ajaxResult);
                }

                if (parameters == null || parameters.Count == 0)
                {
                    ajaxResult.PromptMsg = "您没有选择任何资源,请选择后再保存!";
                    return JsonConvert.SerializeObject(ajaxResult);
                }

                IList<RolePrivilege> rolePrivileges = parameters.Where(o => o != "tempAccess").Select(p => new RolePrivilege()
                {
                    ID = IdGenerator.NewComb().ToSafeString(),
                    RoleID = roleID,
                    PrivilegeID = p
                }).ToList();

                authService.SaveRolePrivilege(rolePrivileges);

                ajaxResult.RetValue = string.Empty;
                ajaxResult.Result = DoResult.Success;
                ajaxResult.PromptMsg = "保存成功!";
                WebUtil.CloseDialog();
            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                ajaxResult.PromptMsg = "保存角色出错,请联系管理员!";
                log.Error(ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string Save(string json)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;
            string processDefID = Request.QueryString["ProcessDefID"];
            string srcActivity = Request.QueryString["SrcActivity"];
            string destActivity = Request.QueryString["DestActivity"];
            try
            {
                WorkflowEngine engine = new WorkflowEngine();
                ProcessDefine processDefine = engine.GetProcessDefine(processDefID);
                ProcessDef processDef = repository.GetDomain<ProcessDef>(processDefID);

                AgileEAP.Workflow.Definition.Transition transition = processDefine.Transitions.FirstOrDefault(t => t.SrcActivity == srcActivity && t.DestActivity == destActivity);
                IDictionary<string, object> values = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);

                transition.IsDefault = values.GetSafeValue<bool>("IsDefault", false);
                transition.Name = values.GetSafeValue<string>("Name", transition.Name);
                transition.Expression = values.GetSafeValue<string>("Expression", transition.Expression);
                processDef.Content = processDefine.ToXml();

                repository.SaveOrUpdate(processDef);

                actionResult = DoResult.Success;
                //获取提示信息
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);

                //记录操作日志
                AddActionLog(processDef, actionResult, string.Format("保存流程{0}迁移srcActivity={1},destActivity={2}信息", processDefID, srcActivity, destActivity));

                ajaxResult.Result = actionResult;
                ajaxResult.RetValue = srcActivity + ":" + destActivity;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                AddActionLog<ProcessDef>(string.Format("保存流程{0}迁移srcActivity={1},destActivity={2}信息", processDefID, srcActivity, destActivity), ajaxResult.Result);
                log.Error(string.Format("显示流程{0}迁移srcActivity={1},destActivity={2}信息出错", processDefID, srcActivity, destActivity), ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#15
0
        public string Delete(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                if (!string.IsNullOrWhiteSpace(argument))
                {
                    string roleID = argument;

                    IRepository<string> repository = new Repository<string>();
                    IDictionary<string, object> parameters = new Dictionary<string, object>();
                    parameters.SafeAdd("RoleID", roleID);
                    IList<ObjectRole> objectRoleList = repository.FindAll<ObjectRole>(parameters);
                    if (objectRoleList.Count == 0)
                    {
                        repository.Delete<Role>(roleID);
                        repository.ExecuteSql<RolePrivilege>(string.Format("Delete from AC_RolePrivilege where RoleID='{0}'", roleID));
                        doResult = DoResult.Success;
                        actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                    }
                    else
                    {
                        doResult = DoResult.Failed;
                        actionMessage = "请先解除该角色与操作员的关联!";
                    }

                    ajaxResult.RetValue = CurrentId;
                    ajaxResult.PromptMsg = actionMessage;
                }

                ajaxResult.Result = doResult;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#16
0
        public ActionResult UserManage(string LoginName, string OldPwd, string NewPwd)
        {
            AjaxResult ajaxResult = new AjaxResult()
            {
                Result = DoResult.Failed,
                PromptMsg = "操作失败"
            };

            string actionMessage = string.Empty;
            try
            {
                Operator loginModel = repository.Query<Operator>().Where(l => l.LoginName == LoginName && l.Password == CryptographyManager.EncodePassowrd(OldPwd)).FirstOrDefault();
                if (loginModel != null)
                {
                    repository.ExecuteSql<Operator>(string.Format("update AC_Operator set Password='******' where LoginName='{1}' and PassWord='******'", CryptographyManager.EncodePassowrd(NewPwd), LoginName, CryptographyManager.EncodePassowrd(OldPwd)));
                    ajaxResult.Result = DoResult.Success;
                    ////获取提示信息
                    actionMessage = string.Format("修改用户{0}密码成功", LoginName);

                    ////记录操作日志
                    AddActionLog<Operator>(actionMessage, ajaxResult.Result);
                }
                else
                {
                    actionMessage = string.Format("修改用户{0}密码失败", LoginName);
                }
                ajaxResult.RetValue = loginModel;
                ajaxResult.PromptMsg = actionMessage;

                //repository.SaveOrUpdate(applyInfo);

            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                //记录操作日志
                //AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
                log.Error(actionMessage, ex);
            }

            return Json(ajaxResult);
        }
示例#17
0
 public JsonResult CreateJSFile()
 {
     AjaxResult ajaxResult = new AjaxResult()
     {
         Result = DoResult.Failed,
         PromptMsg = "操作失败"
     };
     try
     {
         string ProcessDef = Request.Form["ProcessDefID"];
         string ActivityID = Request.Form["ActivityID"];
         string Content = Request.Form["jsContent"];
         string path = Request.MapPath("/Plugins/FormDesigner/Scripts/");
         string name = ProcessDef + ActivityID + ".js";
         if (!System.IO.File.Exists(path + name))
         {
             FileStream fs1 = new FileStream(path + name, FileMode.Create, FileAccess.Write);
             StreamWriter sw = new StreamWriter(fs1);
             sw.WriteLine(Content);//要写入的信息。
             sw.Close();
             fs1.Close();
         }
         else
         {
             FileStream fs = new FileStream(path + name, FileMode.Open, FileAccess.Write);
             StreamWriter sr = new StreamWriter(fs);
             sr.WriteLine(Content);//开始写入值
             sr.Close();
             fs.Close();
         }
         ajaxResult.Result = DoResult.Success;
         ajaxResult.RetValue = path + name;
         ajaxResult.PromptMsg = "操作成功";
     }
     catch (Exception ex)
     {
         ajaxResult.PromptMsg = "操作失败";
         log.Error(ex);
     }
     return Json(ajaxResult);
 }
        //获取组织或角色下的人员
        public string GetOrgOrRoleUsers(string argument)
        {
            string type = Request["Type"];
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                ParticipantorType participantorType = (ParticipantorType)Enum.Parse(typeof(ParticipantorType), type);
                var participantors = workflowEngine.GetPersonParticipantors(participantorType, argument);
                if (participantors == null)
                {
                    actionResult = DoResult.Other;
                    actionMessage = "返回数据为空";
                    ajaxResult.RetValue = null;
                }
                else
                {
                    actionResult = DoResult.Success;

                    //获取提示信息
                    actionMessage = RemarkAttribute.GetEnumRemark(actionResult);

                    ajaxResult.RetValue = participantors;
                }

                ajaxResult.Result = actionResult;
                ajaxResult.PromptMsg = actionMessage;

            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#19
0
        /// <summary>
        /// 删除目录下的文件
        /// </summary>
        public string Delete(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {

                if (!string.IsNullOrWhiteSpace(argument))
                {
                    UploadFile uploadFile = uploadFileService.GetDomain(argument);
                    string filePath = Server.MapPath("~") + uploadFile.FilePath;

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);  //删除文件物理路径
                    }

                    uploadFileService.Delete(argument);
                    uploadFileService.ClearCache();
                    doResult = DoResult.Success;
                    //获取提示信息
                    actionMessage = RemarkAttribute.GetEnumRemark(doResult);

                    ajaxResult.Result = doResult;
                    ajaxResult.RetValue = CurrentId;
                    ajaxResult.PromptMsg = actionMessage;

                }
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#20
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="argument"></param>
        public string DeleteTreeNode(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Resource resource = repository.GetDomain<Resource>(argument);

                if (resource != null)
                {

                    IAuthorizeService authService = new AuthorizeService();
                    authService.DeleteResource(resource);
                    doResult = DoResult.Success;
                }
                else
                {
                    doResult = DoResult.Failed;
                }

                //获取提示信息
                actionMessage = string.Format("删除菜单资源{0},URL={1}", resource.Name, resource.URL);

                //记录操作日志
                AddActionLog(resource, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = resource.ParentID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#21
0
        public string Save(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Resource resource = JsonConvert.DeserializeObject<Resource>(argument);
                resource.ID = string.IsNullOrEmpty(CurrentId) ? CurrentId = IdGenerator.NewComb().ToString() : CurrentId;

                foreach (var operate in resource.Operates)
                {
                    operate.ID = string.IsNullOrWhiteSpace(operate.ID) ? IdGenerator.NewComb().ToString() : operate.ID;
                }

                IAuthorizeService authService = new AuthorizeService();
                authService.SaveResource(resource);
                doResult = DoResult.Success;

                //获取提示信息
                actionMessage = string.Format("保存菜单资源{0}成功", resource.Name);

                //记录操作日志
                AddActionLog(resource, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = resource.ID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string GetprocessDefID(string processInstID)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string actionMessage = string.Format("恢复流程实例{0}", processInstID);
            try
            {
                string id=repository.Query<ProcessInst>().Where(p => p.ID == processInstID).FirstOrDefault().ProcessDefID;
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = id;
                ajaxResult.PromptMsg = actionMessage + "成功";
            }
            catch (Exception ex)
            {
                log.Error(actionMessage + "出错", ex);
            }
            finally
            {
                AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#23
0
        public string StartProcessInst(string processDefID)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;

            try
            {
                WorkflowEngine engine = new WorkflowEngine(); // TODO: Initialize to an appropriate value
                string processInstID = engine.CreateAProcess(processDefID);// string.Empty; // TODO: Initialize to an appropriate value
                engine.StartAProcess(processInstID, null);

                ProcessInst pi = repository.GetDomain<ProcessInst>(processInstID);
                IDictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("ProcessInstID", processInstID);

                WorkItem wi = repository.FindOne<WorkItem>(parameters);

                actionResult = DoResult.Success;
                //获取提示信息
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);

                //记录操作日志
                AddActionLog(pi, actionResult, actionMessage);

                ajaxResult.Result = actionResult;
                ajaxResult.RetValue = pi.ID + '$' + wi.ID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
        public string Delete(string processInstID)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string actionMessage = string.Format("删除流程实例{0}", processInstID);
            try
            {
                IWorkflowEngine engine = new WorkflowEngine();
                engine.DeleteProcessInst(processInstID);
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = AgileEAP.Workflow.Enums.ProcessInstStatus.Running.GetRemark();
                ajaxResult.PromptMsg = actionMessage + "成功";
            }
            catch (Exception ex)
            {
                log.Error(actionMessage + "出错", ex);
            }
            finally
            {
                AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#25
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="argument"></param>
        public string DeleteTreeNode(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Dict dict = dictService.GetDomain(argument);

                if (dict != null)
                {
                    dictService.Delete(dict);
                    doResult = DoResult.Success;
                }
                else
                {
                    doResult = DoResult.Failed;
                }

                //获取提示信息
                actionMessage = string.Format("删除字典{0}成功", dict.Name);

                //记录操作日志
                AddActionLog(dict, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = dict.ParentID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#26
0
        public string Save(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;
            string processInstID = Request.QueryString["processInstID"];
            ProcessForm processForm;
            try
            {
                Dictionary<string, object> formValues = JsonConvert.DeserializeObject<Dictionary<string, object>>(argument);

                string table = Request.Form["DataSource"];
                StringBuilder sbFields = new StringBuilder();
                StringBuilder sbValues = new StringBuilder();
                string cmdText = string.Empty;
                StringBuilder sbUpdateValues = new StringBuilder();

                IDictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.SafeAdd("ProcessInstID", processInstID);
                processForm = engine.Persistence.Repository.FindOne<ProcessForm>(parameters);
                if (processForm != null)
                {
                    foreach (var item in formValues)
                    {
                        if (sbUpdateValues.Length > 0)
                            sbUpdateValues.Append(",");
                        sbUpdateValues.AppendFormat("{0} = :{0}", item.Key);
                    }
                    cmdText = string.Format("update {0} set {1} where ID ='{2}'", table, sbUpdateValues.ToString(), processForm.BizID);
                }
                else
                {
                    string bizID = IdGenerator.NewComb().ToString();
                    formValues.SafeAdd("ID", bizID);
                    foreach (var item in formValues)
                    {
                        sbFields.Append(item.Key).Append(",");
                        sbValues.Append(":").Append(item.Key).Append(",");
                    }

                    processForm = new ProcessForm()
                    {
                        ID = IdGenerator.NewComb().ToString(),
                        BizID = bizID,
                        BizTable = table,
                        CreateTime = DateTime.Now,
                        Creator = User.ID,
                        ProcessInstID = processInstID,
                        KeyWord = sbValues.ToString()
                    };
                    cmdText = string.Format("insert into {0}({1}) values({2})", table, sbFields.ToString().TrimEnd(','), sbValues.ToString().TrimEnd(','));
                }

                string workItemID = Request.QueryString["workItemID"];
                UnitOfWork.ExecuteWithTrans<WorkItem>(() =>
                {
                    engine.Persistence.Repository.ExecuteSql<WorkItem>(cmdText, formValues);
                    engine.Persistence.Repository.SaveOrUpdate(processForm);
                    engine.CompleteWorkItem(workItemID, formValues);
                });

                actionResult = DoResult.Success;
                //获取提示信息
                actionMessage = string.Format("启动工作流实例{0}工作项{1}", processForm.ProcessInstID, workItemID);

                //记录操作日志
                AddActionLog(processForm, actionResult, actionMessage);

                ajaxResult.Result = actionResult;
                ajaxResult.RetValue = processForm.BizID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
示例#27
0
        public ActionResult DeleteForm(string formID)
        {
            AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed };
            string actionMessage = string.Format("删除流程定义{0}", formID);
            try
            {
                eForm form = repository.GetDomain<eForm>(formID);
                if (form != null)
                {
                    repository.Delete<eForm>(form);
                    ajaxResult.Result = DoResult.Success;
                    ajaxResult.RetValue = formID;
                    actionMessage += "成功";
                    AddActionLog<eForm>(form, ajaxResult.Result, actionMessage);
                }
            }
            catch (Exception ex)
            {
                actionMessage += "出错";
                log.Error(actionMessage, ex);
                AddActionLog<eForm>(actionMessage, ajaxResult.Result);
            }

            ajaxResult.PromptMsg = actionMessage;
            return Json(ajaxResult);
        }
示例#28
0
 public JsonResult saveForm()
 {
     AjaxResult ajaxResult = new AjaxResult()
     {
         Result = DoResult.Failed,
         PromptMsg = "操作失败"
     };
     string formInfo = Request.Form["Form"];
     string formName = Request.Form["FormName"];
     string eFormID = string.IsNullOrEmpty(Request.Form["EFormID"]) ? IdGenerator.NewGuid().ToSafeString() : Request.Form["EFormID"];
     string formApp = Request.Form["FormApp"];
     string formDescription = Request.Form["FormDescription"];
     try
     {
         eForm eform = new eForm()
          {
              ID = eFormID,
              Description = formDescription,
              AppID = formApp,
              Content = formInfo,
              CreateTime = DateTime.Now,
              Creator = workContext.User.ID,
              Name = formName
          };
         repository.SaveOrUpdate(eform);
         ajaxResult.Result = DoResult.Success;
         ajaxResult.RetValue = eform;
         ajaxResult.PromptMsg = "操作成功";
     }
     catch (Exception ex)
     {
         ajaxResult.PromptMsg = "操作失败";
         log.Error(ex);
     }
     return Json(ajaxResult);
 }
示例#29
0
        public JsonResult SaveEForm()
        {
            string formValueJson = Request.Form["FormValue"];
            string formDataSource = Request.Form["FormDataSource"];
            string entry = Request.Form["Entry"];
            string updateID = Request.Form["UpdateID"];
            string extend = Request.Form["Extend"];
            AjaxResult ajaxResult = new AjaxResult()
            {
                Result = DoResult.Failed,
                PromptMsg = "操作失败"
            };
            try
            {
                Dictionary<string, object> formValues = JsonConvert.DeserializeObject<Dictionary<string, object>>(formValueJson);
                if (!string.IsNullOrEmpty(extend))
                {
                    Dictionary<string, object> eFormExtend = JsonConvert.DeserializeObject<Dictionary<string, object>>(extend);
                    formValues.SafeAdd<string, object>(eFormExtend);
                }
                IList<SaveEFormModel> saveEForms = new List<SaveEFormModel>();
                string dataTable = formDataSource;
                SaveEFormModel formSourceTable = new SaveEFormModel();
                if (!string.IsNullOrEmpty(dataTable))
                {
                    formSourceTable.TableName = dataTable;

                }
                foreach (var formValue in formValues)
                {
                    if (formValue.Key.Contains("_"))
                    {
                        dataTable = formValue.Key.Substring(0, formValue.Key.LastIndexOf("_"));
                        string fieldKey = formValue.Key.Substring(formValue.Key.LastIndexOf("_") + 1);
                        string fieldValue = formValue.Value.ToSafeString();
                        bool sameDataTable = false;
                        foreach (SaveEFormModel saveEForm in saveEForms)
                        {
                            if (dataTable == saveEForm.TableName)
                            {
                                saveEForm.ColumnsName.Add(fieldKey);
                                saveEForm.ColumnsValue.Add(fieldValue);
                                sameDataTable = true;
                                break;
                            }
                        }
                        if (!sameDataTable)
                        {
                            IList<string> cloummsName = new List<string>();
                            IList<string> columnsValue = new List<string>();
                            cloummsName.Add(fieldKey);
                            columnsValue.Add(fieldValue);
                            saveEForms.Add(new SaveEFormModel()
                            {
                                TableName = dataTable,
                                ColumnsName = cloummsName,
                                ColumnsValue = columnsValue
                            });
                        }
                    }
                    else if (!string.IsNullOrEmpty(formValue.Key))
                    {
                        formSourceTable.ColumnsName.Add(formValue.Key);
                        formSourceTable.ColumnsValue.Add(formValue.Value.ToSafeString());
                    }
                }
                saveEForms.Add(formSourceTable);
                foreach (SaveEFormModel eForm in saveEForms)
                {
                    IList<string> tableColumns = repository.GetTableColumns(eForm.TableName);
                    if (tableColumns != null && tableColumns.Count() > 0)
                    {
                        if (entry == "add")
                        {
                            string cmdText = string.Join(",", eForm.ColumnsName);
                            string cmdValue = string.Join("','", eForm.ColumnsValue);
                            //if (!string.IsNullOrEmpty(extend))
                            //{
                            //  //  EFormExtendModel eFormExtend = JsonConvert.DeserializeObject<EFormExtendModel>(extend);
                            //    Dictionary<string, object> eFormExtend = JsonConvert.DeserializeObject<Dictionary<string, object>>(extend);
                            //    if (eFormExtend != null)
                            //    {
                            //     cmdText=cmdText+","+string.Join(",", eFormExtend.ColumnsName);
                            //     cmdValue = cmdValue + "','" + string.Join("','", eFormExtend.ColumnsValue);
                            //    }
                            //}
                            if (!cmdText.Contains(",ID"))
                            {
                                string ID = IdGenerator.NewComb().ToSafeString();
                                repository.ExecuteDataTable<eForm>("insert into " + eForm.TableName + "(ID," + cmdText + ") values ('" + ID + "','" + cmdValue + "')");
                            }
                            else
                            {
                                repository.ExecuteDataTable<eForm>("insert into " + eForm.TableName + "(" + cmdText + ") values ('" + cmdValue + "')");
                            }
                        }
                        else
                        {
                            string cmd = string.Empty;
                            for (int i = 0; i < eForm.ColumnsName.Count(); i++)
                            {
                                if (string.IsNullOrEmpty(cmd))
                                {
                                    cmd = string.Format("{0}='{1}'", eForm.ColumnsName[i], eForm.ColumnsValue[i]);
                                }
                                else
                                {
                                    cmd = cmd + "," + string.Format("{0}='{1}'", eForm.ColumnsName[i], eForm.ColumnsValue[i]);
                                }
                            }
                            if (!string.IsNullOrEmpty(updateID))
                                repository.ExecuteDataTable<eForm>("update  " + eForm.TableName + " set " + cmd + " where ID='" + updateID + "'");
                        }
                    }
                }
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = null;
                ajaxResult.PromptMsg = "操作成功";
            }
            catch (Exception ex)
            {
                log.Error(string.Format("保存eForm表单失败,eForm表单信息为{0}", formValueJson), ex);
            }
            return Json(ajaxResult);
        }
示例#30
0
 public JsonResult ManageStoredProcedure()
 {
     string dataSource = Request.Form["DataSource"];
     string mysqlDataSource = Request.Form["MySqlDataSource"];
     string oracleSource = Request.Form["OracleSource"];
     string msSQLDataSource = Request.Form["MsSQLDataSource"];
     AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed };
     string actionMessage = "操作";
     try
     {
         if (string.IsNullOrEmpty(dataSource))
         {
             DatabaseType databaseType = UnitOfWork.CurrentDatabaseType;
             if (databaseType == DatabaseType.MySQL)
             {
                 dataSource = mysqlDataSource;
             }
             else if (databaseType == DatabaseType.MsSQL2008)
             {
                 dataSource = msSQLDataSource;
             }
             else if (databaseType == DatabaseType.Oracle)
             {
                 dataSource = oracleSource;
             }
         }
         DataTable dt = repository.ExecuteDataTable<eForm>(dataSource);
         ajaxResult.Result = DoResult.Success;
         ajaxResult.RetValue = dt;
         actionMessage += "成功";
     }
     catch (Exception ex)
     {
         actionMessage += "出错";
         log.Error(actionMessage, ex);
     }
     ajaxResult.PromptMsg = actionMessage;
     return Json(ajaxResult);
 }