示例#1
0
        /// <summary>
        /// 添加节点审核
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="id"></param>
        /// <param name="activityName"></param>
        /// <param name="tableName"></param>
        /// <param name="AuditStr"></param>
        public static void AddActivityAudit(Innovator inn, string id, string activityName, string tableName, List <string> AuditStr)
        {
            List <string> activityNames = new List <string> {
                activityName
            };
            List <string> ids = new List <string>();

            if (AuditStr != null && AuditStr.Count > 0)
            {
                foreach (var item in AuditStr)
                {
                    Item identity = IdentityDA.GetIdentityByKeyedName(inn, item);
                    if (!identity.isError() && identity.getItemCount() > 0)
                    {
                        string identityId = identity.getProperty("id");
                        ids.Add(identityId);
                    }
                }
            }
            ids = ids.Distinct().ToList();
            if (ids.Count > 0)
            {
                foreach (var identityId in ids)
                {
                    ActivityBll.AddActivityAuth(inn, id, identityId, activityNames, tableName);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 判断CEO是否审核过
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="b_LineLeader">直属领导</param>
        /// <param name="b_DepartmentLeader">部门领导</param>
        /// <param name="b_DivisionVP">VP</param>
        /// <returns></returns>
        public static bool CeoBeforeIsAudit(Innovator inn, string b_LineLeader, string b_DepartmentLeader, string b_DivisionVP, string b_Employee)
        {
            USER            employeeInfo = UserDA.GetUserByFirstName(b_Employee);
            List <IDENTITY> identityList = new List <IDENTITY>();

            if (employeeInfo != null)
            {
                if (employeeInfo.B_CENTRE == "盛和")
                {
                    identityList = IdentityDA.GetMemberByIdentityName("GMSH");
                }
                else if (employeeInfo.B_CENTRE == "骏盛")
                {
                    identityList = IdentityDA.GetMemberByIdentityName("GMJS");
                }
                else
                {
                    identityList = IdentityDA.GetMemberByIdentityName("CEO");
                }
            }

            //判断CEO在之前是否审核过
            if (identityList != null && identityList.Count > 0 && (identityList.Where(x => x.KEYED_NAME.Trim() == b_LineLeader).Count() > 0 || identityList.Where(x => x.KEYED_NAME.Trim() == b_DepartmentLeader).Count() > 0 || identityList.Where(x => x.KEYED_NAME.Trim() == b_DivisionVP).Count() > 0))
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        /// <summary>
        /// 自动完成任务
        /// </summary>
        public static void AutomaticCompletionTask(Innovator inn, string id, UserInfo userInfo, ref WORKFLOW_PROCESS_PATH ChoicePath)
        {
            Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.B_PRMANAGE");

            if (!activityItem.isError() && activityItem.getItemCount() > 0)
            {
                string activityId = activityItem.getItemByIndex(0).getProperty("activityid");
                string keyedName  = activityItem.getItemByIndex(0).getProperty("keyed_name");
                //获取当前任务的操作权限
                bool isOperate = false;
                Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId);
                if (!identitys.isError() && identitys.getItemCount() > 0)
                {
                    for (int i = 0; i < identitys.getItemCount(); i++)
                    {
                        string dentityId = identitys.getItemByIndex(i).getProperty("id");
                        if (userInfo.Roles.Contains(dentityId))
                        {
                            isOperate = true;
                        }
                    }
                }
                if ((keyedName == "Dept.Director" || keyedName == "Dept.VP" || keyedName == "GM" || keyedName == "PMT/PAT Leader" || keyedName == "Project Manager" || keyedName == "Project Director") && isOperate)
                {
                    WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.B_PRMANAGE");
                    if (newChoicePath != null)
                    {
                        ChoicePath = newChoicePath;
                        AutomaticCompletionTask(inn, id, userInfo, ref ChoicePath);
                    }
                }
            }
        }
        /// <summary>
        /// 保存行政代订
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SaveBookingStaffing(BookingStaffingModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                //验证输入的员工名称是否存在
                //验证高级经理
                if (!string.IsNullOrEmpty(model.b_UserName))
                {
                    Item UserNameObj = IdentityDA.GetIdentityByKeyedName(inn, model.b_UserName);
                    if (UserNameObj.isError())
                    {
                        retModel.AddError("errorMessage", "找不到对应的员工名称!");
                        return(Json(retModel, JsonRequestBehavior.AllowGet));
                    }
                }

                var BookingStaffing = inn.newItem("b_BookingStaffing", "add");
                BookingStaffing.setProperty("b_username", model.b_UserName);
                var result = BookingStaffing.apply();
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 管理员重发凭证邮件
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="b_Employee"></param>
        /// <param name="recordNo"></param>
        public static void ExpenseAccountantCheckSendEmail(Innovator inn, string b_Employee, string recordNo)
        {
            //邮箱列表
            List <string> listEmail = new List <string>();
            List <string> names     = new List <string>();
            string        subject   = "";
            string        body      = "";
            //获取申请人邮箱
            Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Employee);

            if (!applicantIdentity.isError())
            {
                UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names);
            }
            subject = "您单号为[" + recordNo + "]的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。——如已打印并交到财务部,请忽略此邮件。";

            body  = "您单号为[" + recordNo + "]的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。——如已打印并交到财务部,请忽略此邮件。<br/>";
            body += "打印方式:进入 https://oa.bordrin.com ,打开菜单 报销管理->查询费用报销,找到对应申请单,单击单号后面的打印按钮打印申请单。";

            listEmail = new List <string>();
            listEmail.Add("*****@*****.**");
            listEmail.Add("*****@*****.**");
            listEmail.Add("Kai.Feng @bordrin.com");
            //异步执行
            new Task(() =>
            {
                MailOperator.SendMail(listEmail, subject, body);
            }).Start();
        }
示例#6
0
        /// <summary>
        /// 获取菜单权限根据帐号
        /// </summary>
        /// <returns></returns>
        public JsonResult GetMenuAuthByIdentity(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                List <string> list = new List <string>();

                MenuAuthManageModel model = new MenuAuthManageModel();
                Item Identity             = IdentityDA.GetIdentityById(inn, id);
                if (Identity.getItemCount() > 0)
                {
                    model.Id         = Identity.getProperty("id");
                    model.Is_Alias   = Identity.getProperty("is_alias");
                    model.KEYED_NAME = Identity.getProperty("keyed_name");
                    Item result = ItemTypeDA.GetMenuAuthByIdentity(inn, id);
                    if (result.getItemCount() > 0)
                    {
                        for (int index = 0; index < result.getItemCount(); index++)
                        {
                            Item   item       = result.getItemByIndex(index);
                            string keyed_name = item.getProperty("keyed_name");
                            list.Add(keyed_name);
                        }
                    }
                    model.AuthList = list;
                }
                retModel.data = model;
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 当财务总监审核通过后,发送邮件
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="proposer"></param>
        /// <param name="recordNo"></param>
        public static void SendEmailToProposer(Innovator inn, string proposer, string recordNo)
        {
            //邮箱列表
            List <string> listEmail = new List <string>();
            List <string> names     = new List <string>();
            string        subject   = "";
            string        body      = "";

            //获取申请人邮箱
            Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, proposer);

            if (!applicantIdentity.isError())
            {
                UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names);
            }

            subject = "Your expense reimbursement application <" + recordNo + "> has been approved by financial analyst, Please hand in your application and receipts to finance department.";

            body  = "您单号为< " + recordNo + " >的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。<br/>";
            body += "Your expense reimbursement application < " + recordNo + " > has been approved by financial analyst, Please hand in your application and receipts to finance department.";

            listEmail = new List <string>();
            listEmail.Add("*****@*****.**");
            listEmail.Add("*****@*****.**");
            //listEmail.Add("*****@*****.**");

            //异步执行
            new Task(() =>
            {
                MailOperator.SendMail(listEmail, subject, body);
            }).Start();
        }
        /// <summary>
        /// 自动完成任务
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="id"></param>
        /// <param name="ChoicePath"></param>
        public void AutomaticCompletionTask(Innovator inn, string id, decimal totalAmount, bool b_IsBudgetary, string b_Type, string lineLeader, string departmentLeader, ref WORKFLOW_PROCESS_PATH ChoicePath)
        {
            //获取当前活动
            Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.b_ExpenseReimbursement");

            if (!activityItem.isError() && activityItem.getItemCount() > 0)
            {
                string activityId = activityItem.getItemByIndex(0).getProperty("activityid");
                string keyedName  = activityItem.getItemByIndex(0).getProperty("keyed_name");
                //获取当前任务的操作权限
                bool isOperate = false;
                Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId);
                if (!identitys.isError() && identitys.getItemCount() == 1)
                {
                    isOperate = true;
                }
                if (isOperate)
                {
                    string lineName = GetLineNameByActivityName(inn, activityId, keyedName, totalAmount, b_IsBudgetary);
                    WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.b_ExpenseReimbursement", lineName);
                    if (newChoicePath != null)
                    {
                        ChoicePath = newChoicePath;
                        AutomaticCompletionTask(inn, id, totalAmount, b_IsBudgetary, b_Type, lineLeader, departmentLeader, ref ChoicePath);
                    }
                }
            }
        }
示例#9
0
        /// <summary>
        /// 自动完成任务
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="id"></param>
        /// <param name="ChoicePath"></param>
        public void AutomaticCompletionTask(Innovator inn, string id, string b_PrType, string versionNo, ref WORKFLOW_PROCESS_PATH ChoicePath)
        {
            //获取当前活动
            Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.B_PRMANAGE");

            if (!activityItem.isError() && activityItem.getItemCount() > 0)
            {
                string activityId = activityItem.getItemByIndex(0).getProperty("activityid");
                string keyedName  = activityItem.getItemByIndex(0).getProperty("keyed_name");
                //获取当前任务的操作权限
                bool isOperate = false;
                Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId);
                if (!identitys.isError() && identitys.getItemCount() == 1)
                {
                    isOperate = true;
                }
                if (isOperate)
                {
                    string lineName = GetLineNameByActivityName(inn, id, activityId, keyedName, b_PrType, versionNo);
                    WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.B_PRMANAGE", lineName);
                    if (newChoicePath != null)
                    {
                        ChoicePath = newChoicePath;
                        AutomaticCompletionTask(inn, id, b_PrType, versionNo, ref ChoicePath);
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// Pr单驳回通知预算分析员
        /// </summary>
        public static void SendReturnFinancialAnalystMail(Innovator inn, string keyedName, WORKFLOW_PROCESS_PATH choicePath, List <string> listEmail, string itemId)
        {
            Item   activity         = ActivityDA.GetActivityById(inn, choicePath.SOURCE_ID);
            string currentKeyedName = activity.getProperty("keyed_name").Trim();

            if (itemId == "")
            {
                return;
            }

            if (currentKeyedName == "Financial Manager" || currentKeyedName == "Financial Director" || currentKeyedName == "CFO" ||
                currentKeyedName == "Receive PR" || currentKeyedName == "Buyer Inquiry" || currentKeyedName == "Contract Registration" ||
                currentKeyedName == "Contract Management" || currentKeyedName == "Purchase Manager" || currentKeyedName == "Purchase Director")
            {
                if (keyedName == "Start")
                {
                    List <string> financialAnalyst = new List <string> {
                        "Financial Analyst"
                    };
                    Item activityObj = ActivityDA.GetActivityByNames(inn, financialAnalyst, itemId, "B_PrManage", "Closed");
                    if (!activityObj.isError() && activityObj.getItemCount() > 0)
                    {
                        string activityId = activityObj.getItemByIndex(0).getProperty("id");

                        //获取邮件需要发送的人员信息
                        Item          identitys = IdentityDA.GetIdentityByActivityId(inn, activityId);
                        List <string> names     = new List <string>();
                        //获取邮箱信息
                        UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names);
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// 根据用户名判断角色是否为CEO
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="b_Employee">用户名称</param>
        /// <returns></returns>
        public static bool IsCEObyUserName(Innovator inn, string b_Employee)
        {
            List <IDENTITY> identityList = new List <IDENTITY>();

            identityList.AddRange(IdentityDA.GetMemberByIdentityName("CEO"));
            int ncount = identityList.Where(x => x.KEYED_NAME.Trim() == b_Employee.Trim()).Count();

            if (ncount > 0 || b_Employee == "Zhiwei Zhang (张志伟)")
            {
                return(true);
            }
            return(false);
        }
示例#12
0
        // GET: SearchTripReimbursement
        public ActionResult Index()
        {
            List <string> listRoleName = IdentityDA.GetIdentityByUserName(Userinfo.UserName);

            if (listRoleName.Contains("SAP导出"))
            {
                ViewBag.CanExport = true;
            }
            else
            {
                ViewBag.CanExport = false;
            }

            ViewBag.CurrentName = Common.GetLanguageValueByParam("查询差旅报销", "TRCommon", "TRItemType", ViewBag.language);
            return(View("~/Views/TripReimbursement/SearchTripReimbursement.cshtml"));
        }
示例#13
0
        /// <summary>
        ///  登陆获取用户信息
        /// </summary>
        /// <param name="loginName"></param>
        public static void LogIn(string loginName, UserInfo user)
        {
            string url    = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName = ConfigurationManager.AppSettings["ArasDB"];

            //获取用户信息
            USER userObJ = UserDA.GetUserByLoginName(loginName);

            if (userObJ != null)
            {
                user.UserId      = userObJ.ID;
                user.UserName    = userObJ.KEYED_NAME;
                user.LoginName   = userObJ.LOGIN_NAME;
                user.Password    = userObJ.PASSWORD;
                user.b_JobNumber = userObJ.B_JOBNUMBER;
                user.Email       = userObJ.EMAIL;
                HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, user.LoginName, user.Password);
                Item login_result         = conn.Login();
                if (login_result.isError())
                {
                    if (conn != null)
                    {
                        conn.Logout();
                    }
                }
                else
                {
                    var inn = login_result.getInnovator();
                    if (inn != null)
                    {
                        //获取当前角色身份
                        List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.UserId);
                        user.Roles = listRoles;

                        if ((user.AgentAuth == null && user.AgentCreateTime == null) || (user.AgentCreateTime != null))
                        {
                            List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(user.UserName);
                            if (AgentSetList.Count > 0)
                            {
                                AgentSetBll.GetAgentRoles(inn, user, AgentSetList);
                            }
                        }
                        user.inn = inn;
                    }
                }
            }
        }
示例#14
0
        /// <summary>
        /// 获取角色列表数据
        /// </summary>
        /// <returns></returns>
        public JsonResult GetRoleManageList(DataTableParameter para, string searchValue)
        {
            int total = 0;
            List <RoleManageModel> list = new List <RoleManageModel>();
            var dataList = IdentityDA.GetRoleManageList(out total, para, searchValue);

            if (dataList.Count() > 0)
            {
                for (int index = 0; index < dataList.Count(); index++)
                {
                    RoleManageModel model   = new RoleManageModel();
                    IDENTITY        item    = dataList[index];
                    string          strHtml = "<div class='row'><div class='col-md-8'>{0}</div><div class='col-md-4' style='text-align:right'>{1}</div></div>";

                    string linkAList = "<a class='glyphicon glyphicon-cog configRole' title='配置'  RoleId='" + item.ID + "'></a>";
                    if (Userinfo.LoginName == "admin")
                    {
                        linkAList += "&nbsp;&nbsp;&nbsp;&nbsp;<a class='glyphicon glyphicon-trash deleteRole' title='删除' RoleId='" + item.ID + "'></a>";
                    }
                    strHtml          = string.Format(strHtml, item.KEYED_NAME, linkAList);
                    model.KEYED_NAME = strHtml;
                    model.Id         = item.ID;
                    if (item.DESCRIPTION.Contains(";"))
                    {
                        List <string> listStr = item.DESCRIPTION.Split(';').ToList();
                        if (listStr.Count >= 2)
                        {
                            model.Region = listStr[1];
                        }
                    }
                    //获取成员列表
                    List <IDENTITY> memberList = IdentityDA.GetMemberById(model.Id);
                    foreach (var member in memberList)
                    {
                        model.PersonList = model.PersonList + member.NAME + ";";
                    }
                    list.Add(model);
                }
            }
            return(Json(new
            {
                sEcho = para.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = total,
                aaData = list
            }, JsonRequestBehavior.AllowGet));
        }
示例#15
0
        /// <summary>
        /// 刪除角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DeleteRoleManage(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                Item result = IdentityDA.DeleteRoleManage(inn, id);
                if (!string.IsNullOrEmpty(result.getErrorString()))
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="para"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        public JsonResult GetSearchPrManageList(DataTableParameter para, string searchValue, DateTime?startTime, DateTime?endTime, string status)
        {
            int total    = 0;
            var dataList = GetSearchPrManageList(inn, Userinfo.Roles, out total, para, searchValue, startTime, endTime, status);
            //获取当前人员角色信息
            List <string> listRoleName = IdentityDA.GetIdentityByUserName(Userinfo.UserName);

            if (dataList != null)
            {
                foreach (var item in dataList)
                {
                    item.status       = Common.GetItemStatus(item.id);
                    item.b_RaisedDate = item.nb_RaisedDate.ToString("yyyy-MM-dd");
                    if (item.status != "End")
                    {
                        var result = ActivityDA.GetActivityByItemId(inn, item.id, "innovator.B_PRMANAGE");
                        if (!result.isError())
                        {
                            item.activityId = result.getItemByIndex(0).getProperty("activityid");
                            item.AuditorStr = ActivityDA.GetActivityOperator(inn, item.activityId);
                            item.AuditorStr = "<div style='width:180px;word-wrap:break-word;'>" + item.AuditorStr + "</div>";
                        }
                    }
                    string strHtml   = "<div class='row'><div class='col-md-6'>{0}</div><div class='col-md-6' style='text-align:right'>{1}</div></div>";
                    string linkAList = "<a class='glyphicon glyphicon-eye-open detail' title='详情' id='" + item.id + "' ></a>";
                    linkAList += "&nbsp;&nbsp;<a class='glyphicon glyphicon-list-alt history' title='日志' id='" + item.id + "' ></a>";
                    linkAList += "&nbsp;&nbsp;<a class='glyphicon glyphicon-asterisk workflow' title='流程' id='" + item.id + "' ItemStatus='" + item.status + "' b_VersionNo='" + item.b_VersionNo + "'></a>";
                    if (item.b_Buyer == Userinfo.UserName || listRoleName.Contains("采购员") || listRoleName.Contains("PRReader") || listRoleName.Contains("采购部接收PR") || listRoleName.Contains("财务分析员") || listRoleName.Contains("财务经理") || listRoleName.Contains("财务总监") || listRoleName.Contains("CFO") || Userinfo.LoginName == "admin" || item.b_Applicant == Userinfo.UserName)
                    {
                        linkAList += "&nbsp;&nbsp;<a class='glyphicon glyphicon-print Print' title='打印' id='" + item.id + "'></a>";
                    }
                    strHtml           = string.Format(strHtml, item.b_PrRecordNo, linkAList);
                    item.b_PrRecordNo = strHtml;
                    item.status       = Common.GetChineseValueByParam(item.status, "PrManageWorkFlow", "WorkFlow", Userinfo.language);
                }
            }
            return(Json(new
            {
                sEcho = para.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = total,
                aaData = dataList
            }, JsonRequestBehavior.AllowGet));
        }
示例#17
0
        /// <summary>
        /// 获取角色根据ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult GetRoleManageById(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                RoleManageModel model  = new RoleManageModel();
                Item            result = IdentityDA.GetRoleManageById(inn, id);
                if (string.IsNullOrEmpty(result.getErrorString()))
                {
                    model.KEYED_NAME = result.getProperty("name");
                    model.Id         = result.getProperty("id");
                    string description = result.getProperty("description");
                    if (description.Contains(";"))
                    {
                        List <string> listStr = description.Split(';').ToList();
                        if (listStr.Count >= 2)
                        {
                            model.Region = listStr[1];
                        }
                    }

                    Item Relation = result.getRelationships();
                    if (Relation.getItemCount() > 0)
                    {
                        for (int i = 0; i < Relation.getItemCount(); i++)
                        {
                            Item relationObJ = Relation.getItemByIndex(i);
                            model.PersonList = model.PersonList + relationObJ.getRelatedItem().getProperty("name") + ";";
                        }
                    }
                    retModel.data = model;
                }
                else
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
示例#18
0
        /// <summary>
        /// 添加工作流节点的角色审核权限
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="id"></param>
        /// <param name="roleName"></param>
        /// <param name="region"></param>
        /// <param name="activityName"></param>
        /// <param name="tableName"></param>
        public static void AddWorkFlowRoleAuditByRegion(Innovator inn, string id, string roleName, string region, string activityName, string tableName)
        {
            List <string> activityNames = new List <string> {
                activityName
            };

            if (!string.IsNullOrEmpty(region))
            {
                region = "OASystem;" + region;
            }
            //获取财务分析员
            Item identity = IdentityDA.GetIdentityByParam(inn, roleName, region);

            if (!identity.isError() && identity.getItemCount() > 0)
            {
                string identityid = identity.getProperty("id");
                ActivityBll.AddActivityAuth(inn, id, identityid, activityNames, tableName);
            }
        }
示例#19
0
        /// <summary>
        /// 获取列表信息
        /// </summary>
        /// <returns></returns>
        public JsonResult GetIdentityList(DataTableParameter para, string searchValue)
        {
            int total = 0;
            List <MenuAuthManageModel> list = new List <MenuAuthManageModel>();
            var dataList = IdentityDA.GetIdentityList(out total, para, searchValue);

            if (dataList != null)
            {
                for (int index = 0; index < dataList.Count(); index++)
                {
                    MenuAuthManageModel model = new MenuAuthManageModel();
                    var    item      = dataList[index];
                    string strHtml   = "<div class='row'><div class='col-md-8'>{0}</div><div class='col-md-4' style='text-align:right'>{1}</div></div>";
                    string linkAList = "<a class='glyphicon glyphicon-cog configMemuAuth' title='配置'  Id='" + item.ID + "' ></a>";
                    strHtml          = string.Format(strHtml, item.KEYED_NAME, linkAList);
                    model.Id         = item.ID;
                    model.KEYED_NAME = strHtml;
                    model.AuthStr    = "";
                    Item Items = ItemTypeDA.GetMenuAuthByIdentity(inn, item.ID);
                    if (Items.getItemCount() > 0)
                    {
                        for (int i = 0; i < Items.getItemCount(); i++)
                        {
                            Item   obj   = Items.getItemByIndex(i);
                            string lable = obj.getProperty("name");
                            model.AuthStr += lable + ";";
                        }
                    }
                    list.Add(model);
                }
            }


            return(Json(new
            {
                sEcho = para.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = total,
                aaData = list
            }, JsonRequestBehavior.AllowGet));
        }
示例#20
0
        /// <summary>
        /// 保存转办
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveWorkflowTurnToDo(CompleteActivityModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                var user = UserDA.GetUserByFirstName(model.delegateToName);
                if (user == null)
                {
                    retModel.AddError("errorMessage", "选择的转办不存在!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                if (model.delegateToName == Userinfo.UserName)
                {
                    retModel.AddError("errorMessage", "转办人不能选择自己!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                IDENTITY dentity      = IdentityDA.GetIdentityByActivityAssignmentId(model.activityAssignmentId);
                string   identityName = dentity.KEYED_NAME;
                if (identityName.Trim() != Userinfo.UserName)
                {
                    retModel.AddError("errorMessage", "代理权限不能进行转办!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                string errorString = ActivityDA.CompleteActivity(inn, model.activityId, model.activityAssignmentId, "", "Delegate", model.delegateToName, Userinfo.UserName + "转办到:" + model.delegateToName, Userinfo);
                if (string.IsNullOrEmpty(errorString))
                {
                    WorkFlowBll.TurnToDoSendEmail(Userinfo.UserName, model.delegateToName, model.recordNo, model.linkStr, user.EMAIL);
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
示例#21
0
        /// <summary>
        /// 获取委托的权限信息
        /// </summary>
        /// <param name="UserName">用户名称</param>
        /// <param name="moduleName">模块名称</param>
        public static void GetAgentRoles(Innovator inn, UserInfo Userinfo, List <AgentSetEntity> list, string moduleName = "")
        {
            //判断当前该模块的委托信息是否已经获取
            //List<string> agentRoles = new List<string>();
            List <AgentAuthEntity> AgentAuthList = new List <AgentAuthEntity>();

            //var list = GetAgentSetByUserName(Userinfo.UserName, moduleName);
            if (list != null && list.Count > 0)
            {
                foreach (var item in list)
                {
                    AgentAuthEntity agentAuth = new AgentAuthEntity();
                    //根据名称查询用户
                    USER          user      = UserDA.GetUserByFirstName(item.b_DelegateName);
                    List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.ID);
                    //agentRoles.AddRange(listRoles);
                    agentAuth.delegateName = item.b_DelegateName;
                    agentAuth.agentRoles   = listRoles;
                    if (!string.IsNullOrEmpty(item.b_AgentContent))
                    {
                        agentAuth.moduleNames = item.b_AgentContent.Split(';').Where(x => x != "").ToList();
                    }
                    if (AgentAuthList.Where(x => x.delegateName == agentAuth.delegateName).ToList().Count == 0)
                    {
                        AgentAuthList.Add(agentAuth);
                    }
                }
                //将数据插入缓存
                Userinfo.AgentAuth       = AgentAuthList;
                Userinfo.AgentCreateTime = DateTime.Now;
                //MemoryCacheUtils.Clear(Userinfo.LoginName);
                //CacheItemPolicy policy = new CacheItemPolicy();
                //policy.Priority = CacheItemPriority.NotRemovable;
                //MemoryCacheUtils.Set(Userinfo.LoginName, Userinfo, policy);
            }
            //return agentRoles;
        }
        // GET: SearchPrManage
        public ActionResult Index()
        {
            List <string> listRoleName = IdentityDA.GetIdentityByUserName(Userinfo.UserName);

            //if (listRoleName.Contains("采购员") || listRoleName.Contains("PRReader") || listRoleName.Contains("采购部接收PR") || Userinfo.LoginName == "admin")
            //{
            //    ViewBag.CanExport = true;
            //}
            //else
            //{
            //    ViewBag.CanExport = false;
            //}

            if (listRoleName.Contains("Purchaser Export"))
            {
                ViewBag.CanExport = true;
            }
            else
            {
                ViewBag.CanExport = false;
            }
            ViewBag.CurrentName = Common.GetLanguageValueByParam("查询", "CommonName", "Common", ViewBag.language);
            return(View("~/Views/PrManage/SearchPrManage.cshtml"));
        }
示例#23
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveAgentSet(AgentSetModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                //限制输入的代理人不能为自己
                if (model.b_AgentName == Userinfo.UserName)
                {
                    retModel.AddError("errorMessage", "代理人选择不能为自己!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                var b_AgentName = IdentityDA.GetIdentityByKeyedName(inn, model.b_AgentName);
                if (b_AgentName.isError())
                {
                    retModel.AddError("errorMessage", "找不到对应的代理人!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                if (model.AgentModuleList == null || model.AgentModuleList.Count == 0)
                {
                    retModel.AddError("errorMessage", "请您选择授权模块!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                string value = string.Join(";", model.AgentModuleList.ToArray()) + ";";
                model.b_AgentContent = value;

                //验证输入的时间是否正确
                string b_StartDate = !string.IsNullOrEmpty(model.b_StartDateMinute) ? model.b_StartDate + " " + model.b_StartDateMinute : model.b_StartDate;
                string b_EndDate   = !string.IsNullOrEmpty(model.b_EndDateMinute) ? model.b_EndDate + " " + model.b_EndDateMinute : model.b_EndDate;

                DateTime StartDate;
                if (!DateTime.TryParse(b_StartDate, out StartDate))
                {
                    retModel.AddError("errorMessage", "输入的生效时间错误!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                DateTime EndDate;
                if (!DateTime.TryParse(b_EndDate, out EndDate))
                {
                    retModel.AddError("errorMessage", "输入的终止时间错误!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                Item item = null;
                if (string.IsNullOrEmpty(model.id))
                {
                    item = inn.newItem("b_AgentSet", "add");
                }
                else
                {
                    item = inn.newItem("b_AgentSet", "edit");
                    item.setAttribute("id", model.id);
                }
                item.setProperty("b_delegatename", model.b_DelegateName);
                item.setProperty("b_agentname", model.b_AgentName);
                item.setProperty("b_startdate", model.b_StartDate);
                item.setProperty("b_startdateminute", model.b_StartDateMinute);
                item.setProperty("b_enddate", model.b_EndDate);
                item.setProperty("b_enddateminute", model.b_EndDateMinute);
                item.setProperty("b_agentcontent", model.b_AgentContent);
                item.setProperty("b_isvalid", model.b_IsValid);
                item.setProperty("b_agentreason", model.b_AgentReason);
                var result = item.apply();
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
                else
                {
                    if (model.b_IsValid == "1")
                    {
                        string agentContext = "";
                        if (model.AgentModuleList.Count > 0)
                        {
                            foreach (var agentModule in model.AgentModuleList)
                            {
                                string moduleStr = EnumDescription.GetFieldText(EnumDescription.GetEnumByTextUseDefault <AgentModule>(agentModule));
                                agentContext = agentContext + moduleStr + ";";
                            }
                        }
                        WorkFlowBll.SendAgentEmail(inn, model.b_DelegateName, model.b_AgentName, StartDate, EndDate, agentContext);
                    }
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
示例#24
0
        /// <summary>
        /// 保存角色管理
        /// </summary>
        public JsonResult SaveRoleManage(string id, string KEYED_NAME, string personList, string region)
        {
            var retModel = new JsonReturnModel();

            try
            {
                string description = "OASystem;";
                if (!string.IsNullOrEmpty(region))
                {
                    //判断地区是否在数据中存在
                    if (!RegionDA.isExistRegionByName(inn, region))
                    {
                        retModel.AddError("errorMessage", "选择的地区不存在!");
                        return(Json(retModel, JsonRequestBehavior.AllowGet));
                    }
                    //根据角色名称和地区判断是否已经存在该角色
                    description = description + region;
                }

                if (string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(region))
                {
                    KEYED_NAME = KEYED_NAME + "(" + region + ")";
                }

                //////判断Keyed_Name是否存在
                //if (IdentityDA.ValidIsExistByKeyed_Name(KEYED_NAME,id))
                //{
                //    retModel.AddError("errorMessage", "输入的角色已经存在!");
                //    return Json(retModel, JsonRequestBehavior.AllowGet);
                //}

                Item identity = IdentityDA.GetIdentityByCondition(inn, id, KEYED_NAME);
                int  count    = int.Parse(identity.getProperty("ncount"));
                if (count > 0)
                {
                    retModel.AddError("errorMessage", "输入的角色和地区已经存在!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                Item result;
                if (string.IsNullOrEmpty(id))
                {
                    //拼写Insert语句
                    string        amlStr = "<AML><Item type='IDENTITY' action='add'><name>" + KEYED_NAME + "</name><description>" + description + "</description>";
                    List <string> list   = personList.Split(';').Where(x => x != "" && x != null).Select(x => x.Trim()).Distinct().ToList();
                    if (list.Count() > 0)
                    {
                        amlStr += "<Relationships>";
                        for (int i = 0; i < list.Count; i++)
                        {
                            amlStr += "<Item type='MEMBER' action='add'>";
                            amlStr += "<related_id> ";
                            string textValue = list[i];
                            //验证用户在数据库中是否存在
                            if (UserDA.ValidUserIsExist(inn, textValue))
                            {
                                amlStr += "<Item type='IDENTITY' action='get'><name>" + list[i] + "</name></Item>";
                            }
                            else
                            {
                                retModel.AddError("errorMessage", "输入的人员在系统中不存在!");
                                return(Json(retModel, JsonRequestBehavior.AllowGet));
                            }
                            amlStr += "</related_id></Item>";
                        }
                        amlStr += "</Relationships>";
                    }
                    amlStr += "</Item></AML>";
                    result  = IdentityDA.InsertRoleManage(inn, amlStr);
                }
                else
                {
                    string amlStr = "<AML><Item type='IDENTITY' action='edit' id='" + id + "'>";
                    amlStr += "<name>" + KEYED_NAME + "</name>";
                    amlStr += "<description>" + description + "</description>";
                    Item item = IdentityDA.GetRoleManageById(inn, id);
                    if (!string.IsNullOrEmpty(item.getErrorString()))
                    {
                        retModel.AddError("errorMessage", item.getErrorString());
                        return(Json(retModel, JsonRequestBehavior.AllowGet));
                    }
                    List <string> list     = personList.Split(';').Where(x => x != "" && x != null).Select(x => x.Trim()).Distinct().ToList();
                    Item          Relation = item.getRelationships();
                    List <string> oldList  = new List <string>();
                    if (Relation.getItemCount() > 0 || list.Count() > 0)
                    {
                        amlStr += "<Relationships>";
                    }
                    if (Relation.getItemCount() > 0)
                    {
                        //删除不存在的
                        for (int i = 0; i < Relation.getItemCount(); i++)
                        {
                            Item   relationObJ = Relation.getItemByIndex(i);
                            string name        = relationObJ.getRelatedItem().getProperty("name");
                            oldList.Add(name);
                            string strValue = list.Where(x => x == name).FirstOrDefault();
                            if (string.IsNullOrEmpty(strValue))
                            {
                                string memberId = relationObJ.getProperty("id");
                                amlStr += "<Item type='MEMBER' action='delete' id='" + memberId + "'></Item>";
                            }
                        }
                    }
                    if (list.Count() > 0)
                    {
                        //添加新的
                        for (int index = 0; index < list.Count(); index++)
                        {
                            string value = list[index];
                            var    obj   = oldList.Where(x => x == value).FirstOrDefault();
                            //验证用户在数据库中是否存在
                            if (UserDA.ValidUserIsExist(inn, value))
                            {
                                if (string.IsNullOrEmpty(obj))
                                {
                                    amlStr += "<Item type='MEMBER' action='add'>";
                                    amlStr += "<related_id> ";
                                    amlStr += "<Item type='IDENTITY' action='get'><name>" + value + "</name></Item>";
                                    amlStr += "</related_id></Item>";
                                }
                            }
                            else
                            {
                                retModel.AddError("errorMessage", "输入的人员在系统中不存在!");
                                return(Json(retModel, JsonRequestBehavior.AllowGet));
                            }
                        }
                    }
                    if (Relation.getItemCount() > 0 || list.Count() > 0)
                    {
                        amlStr += "</Relationships>";
                    }
                    amlStr += "</Item></AML>";
                    result  = inn.applyAML(amlStr);
                }
                if (!string.IsNullOrEmpty(result.getErrorString()))
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
示例#25
0
        /// <summary>
        /// 保存加签
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SaveWorkflowActivitySign(CompleteActivityModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                List <string> authIds    = new List <string>();
                List <string> oldAuthIds = new List <string>();
                List <string> addAuthIds = new List <string>();

                List <string> listEmail = new List <string>();

                //验证输入的加签用户是否存在!并且获取IdentityId;
                List <string> listName = model.PersonList.Split(';').Where(x => x != "" && x != null).Select(x => x.Trim()).Distinct().ToList();
                if (listName != null && listName.Count() > 0)
                {
                    for (int i = 0; i < listName.Count; i++)
                    {
                        string textValue = listName[i];
                        USER   user      = UserDA.GetUserByFirstName(textValue);
                        if (user == null)
                        {
                            retModel.AddError("errorMessage", "输入的人员在系统中不存在!");
                            return(Json(retModel, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            listEmail.Add(user.EMAIL);

                            Item identity = IdentityDA.GetIdentityByKeyedName(inn, textValue);
                            if (!identity.isError() && identity.getItemCount() > 0)
                            {
                                string identityId = identity.getProperty("id");
                                authIds.Add(identityId);
                            }
                        }
                    }
                }
                //获取当前活动的名称
                Item          activity      = ActivityDA.GetActivityById(inn, model.activityId);
                string        keyedName     = activity.getProperty("keyed_name").Trim();
                List <string> activityNames = new List <string> {
                    keyedName
                };


                //获取现有的审核权限
                Item activityAssignments = ActivityAssignmentDA.GetActivityAssignment(inn, model.activityId);
                if (!activityAssignments.isError() && activityAssignments.getItemCount() > 0)
                {
                    for (int i = 0; i < activityAssignments.getItemCount(); i++)
                    {
                        Item   activityAssignmentItem = activityAssignments.getItemByIndex(i);
                        string id         = activityAssignmentItem.getProperty("id");
                        string related_id = activityAssignmentItem.getProperty("related_id");
                        oldAuthIds.Add(related_id);
                        //删除现有审核权限
                        ActivityAssignmentDA.deleteActivityAssignment(inn, id);
                    }
                }

                //添加该活动的审核权限
                addAuthIds.AddRange(authIds);
                addAuthIds.AddRange(oldAuthIds);
                addAuthIds = addAuthIds.Distinct().ToList();
                if (addAuthIds.Count > 0)
                {
                    int voting_weight = Common.CalculationWeight(addAuthIds.Count);
                    foreach (var id in addAuthIds)
                    {
                        ActivityBll.AddActivityAuth(inn, model.itemId, id, activityNames, model.operateTable, voting_weight, "Active");
                    }
                }

                //加签成功发送邮件
                string nameStr = "";
                listEmail = listEmail.Distinct().ToList();
                if (listName != null && listName.Count > 0)
                {
                    for (int i = 0; i < listName.Count; i++)
                    {
                        if (i != listName.Count - 1)
                        {
                            nameStr += listName[i] + "、";
                        }
                        else
                        {
                            nameStr += listName[i];
                        }
                    }
                }
                WorkFlowBll.WorkflowActivitySignSendEmail(Userinfo.UserName, nameStr, model.recordNo, model.linkStr, listEmail);
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
示例#26
0
        /// <summary>
        /// 单据状态
        /// </summary>
        /// <param name="status"></param>
        public static void SendEmailByOperation(Innovator inn, string b_prRecordNo, string b_Applicant, string b_Buyer, WORKFLOW_PROCESS_PATH choicePath, string itemId = "")
        {
            //邮箱列表
            List <string> listEmail = new List <string>();
            List <string> names     = new List <string>();

            string nameStr = "";

            string subject = "";
            string body    = "";

            Item   activity  = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID);
            string keyedName = activity.getProperty("keyed_name").Trim();

            //获取邮件需要发送的人员信息
            Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID);

            //获取邮箱信息
            UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names);

            if (choicePath.NAME.Contains("Return"))
            {
                SendReturnFinancialAnalystMail(inn, keyedName, choicePath, listEmail, itemId);
            }

            if (names != null && names.Count > 0)
            {
                for (int i = 0; i < names.Count; i++)
                {
                    if (i != names.Count - 1)
                    {
                        nameStr += names[i] + "、";
                    }
                    else
                    {
                        nameStr += names[i];
                    }
                }
            }

            if (choicePath.NAME.Contains("Return"))
            {
                subject = "Your purchase request [" + b_prRecordNo + "] has been rejected.";
                body    = "Dear " + nameStr + ",<br/><br/>";
                body   += "Your purchase request [" + b_prRecordNo + "] has been rejected.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index";
            }
            else if (keyedName == "End")
            {
                //获取申请人邮箱
                Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Applicant);
                if (!applicantIdentity.isError())
                {
                    UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names);
                }
                //获取采购人员邮箱
                Item buyerIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Buyer);
                if (!buyerIdentity.isError())
                {
                    UserDA.GetEmailByIdentitys(inn, buyerIdentity, listEmail, names);
                }
                if (names != null && names.Count > 0)
                {
                    for (int i = 0; i < names.Count; i++)
                    {
                        if (i != names.Count - 1)
                        {
                            nameStr += names[i] + "、";
                        }
                        else
                        {
                            nameStr += names[i];
                        }
                    }
                }
                subject = "Your purchase request [" + b_prRecordNo + "] has been approved.";
                body    = "Dear " + nameStr + ",<br/><br/>";
                body   += " Your purchase request [" + b_prRecordNo + "] has been approved.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index";
            }
            else
            {
                subject = b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "] for your approval.";
                body   += "Dear " + nameStr + ",<br/><br/>";
                body   += b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "]" + " for your approval.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index";
            }

            listEmail = new List <string>();
            listEmail.Add("*****@*****.**");
            listEmail.Add("*****@*****.**");
            //listEmail.Add("*****@*****.**");
            //异步执行
            new Task(() =>
            {
                MailOperator.SendMail(listEmail, subject, body);
            }).Start();
        }
示例#27
0
        private static List <TripReimbursementModel> GetSearchTripReimbursementList(Innovator inn, List <string> roles, out int total, DataTableParameter para, DateTime?startTime, DateTime?endTime, string searchValue, string status, string employee)
        {
            //获取的权限TRReader
            Item   identityItem = IdentityDA.GetIdentityByKeyedName(inn, "TRReader");
            string TRReaderId   = "";

            if (identityItem != null && identityItem.getItemCount() > 0)
            {
                TRReaderId = identityItem.getProperty("id");
            }

            using (InnovatorSolutionsEntities db = new InnovatorSolutionsEntities())
            {
                IQueryable <TripReimbursementModel> datas = (from g in db.B_TRIPREIMBURSEMENTFORM
                                                             join t in db.WORKFLOW on g.id equals t.SOURCE_ID
                                                             join y in db.WORKFLOW_PROCESS on t.RELATED_ID equals y.ID
                                                             join u in db.WORKFLOW_PROCESS_ACTIVITY on y.ID equals u.SOURCE_ID
                                                             join i in db.ACTIVITY on u.RELATED_ID equals i.ID
                                                             join o in db.ACTIVITY_ASSIGNMENT on i.ID equals o.SOURCE_ID
                                                             join p in db.IDENTITY on o.RELATED_ID equals p.ID
                                                             where (roles.Contains(p.ID) || g.B_EMPLOYEE == employee || roles.Contains(TRReaderId)) && (g.B_RECORDNO.Contains(searchValue) || g.B_DEPT.Contains(searchValue) || g.B_EMPLOYEE.Contains(searchValue))
                                                             select new TripReimbursementModel
                {
                    id = g.id,
                    b_RecordNo = g.B_RECORDNO,
                    nb_ApplicationDate = g.CREATED_ON,
                    b_Dept = g.B_DEPT,
                    b_Employee = g.B_EMPLOYEE,
                    b_AmountInTotal = g.B_AMOUNTINTOTAL,
                    status = (from z in db.B_TRIPREIMBURSEMENTFORM
                              join x in db.WORKFLOW on z.id equals x.SOURCE_ID
                              join c in db.WORKFLOW_PROCESS on x.RELATED_ID equals c.ID
                              join v in db.WORKFLOW_PROCESS_ACTIVITY on c.ID equals v.SOURCE_ID
                              join b in db.ACTIVITY on v.RELATED_ID equals b.ID
                              join n in db.ACTIVITY_ASSIGNMENT on b.ID equals n.SOURCE_ID
                              join m in db.IDENTITY on n.RELATED_ID equals m.ID
                              where b.STATE == "active" && z.id == g.id
                              select b).FirstOrDefault().KEYED_NAME
                }).Distinct();
                //时间查询
                if (startTime != null)
                {
                    datas = datas.Where(x => x.nb_ApplicationDate >= startTime);
                }
                if (endTime != null)
                {
                    datas = datas.Where(x => x.nb_ApplicationDate <= endTime);
                }

                if (!string.IsNullOrEmpty(status))
                {
                    if (status != "End")
                    {
                        datas = datas.Where(x => x.status == status);
                    }
                    else
                    {
                        datas = datas.Where(x => x.status == null);
                    }
                }
                //总条数
                total = datas.Count();
                if (para != null)
                {
                    //排序
                    if (para.sSortType == "asc")
                    {
                        datas = Common.OrderBy(datas, para.iSortTitle, false);
                    }
                    else
                    {
                        datas = Common.OrderBy(datas, para.iSortTitle, true);
                    }
                    //分页
                    datas = datas.Skip(para.iDisplayStart).Take(para.iDisplayLength);
                }
                return(datas.ToList());
            }
        }
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <returns></returns>
        private static List <PrManageModel> GetSearchPrManageList(Innovator inn, List <string> roles, out int total, DataTableParameter para, string searchValue, DateTime?startTime, DateTime?endTime, string status)
        {
            //获取的权限PRReader
            Item   identityItem = IdentityDA.GetIdentityByKeyedName(inn, "PRReader");
            string PRReaderId   = "";

            if (identityItem != null && identityItem.getItemCount() > 0)
            {
                PRReaderId = identityItem.getProperty("id");
            }

            using (InnovatorSolutionsEntities db = new InnovatorSolutionsEntities())
            {
                IQueryable <PrManageModel> datas = (from g in db.B_PRMANAGE
                                                    join t in db.WORKFLOW on g.id equals t.SOURCE_ID
                                                    join y in db.WORKFLOW_PROCESS on t.RELATED_ID equals y.ID
                                                    join u in db.WORKFLOW_PROCESS_ACTIVITY on y.ID equals u.SOURCE_ID
                                                    join i in db.ACTIVITY on u.RELATED_ID equals i.ID
                                                    join o in db.ACTIVITY_ASSIGNMENT on i.ID equals o.SOURCE_ID
                                                    join p in db.IDENTITY on o.RELATED_ID equals p.ID
                                                    where (roles.Contains(p.ID) || roles.Contains(PRReaderId)) && (g.B_PRRECORDNO.Contains(searchValue) || g.B_PROJECTNAME.Contains(searchValue) || g.B_BUSINESSDEPARTMENT.Contains(searchValue) || g.B_APPLICANT.Contains(searchValue) || g.B_BUYER.Contains(searchValue) || g.B_PURCHASECONTENT.Contains(searchValue))
                                                    select new PrManageModel
                {
                    id = g.id,
                    b_PrRecordNo = g.B_PRRECORDNO,
                    b_ProjectName = g.B_PROJECTNAME,
                    b_PurchaseContent = g.B_PURCHASECONTENT,
                    b_BusinessDepartment = g.B_BUSINESSDEPARTMENT,
                    nb_RaisedDate = g.CREATED_ON,
                    b_Applicant = g.B_APPLICANT,
                    b_Buyer = g.B_BUYER,
                    b_Budget = g.B_BUDGET,
                    b_BudgetCode = g.B_BUDGETCODE,
                    b_VersionNo = g.B_VERSIONNO,
                    status = (from z in db.B_PRMANAGE
                              join x in db.WORKFLOW on z.id equals x.SOURCE_ID
                              join c in db.WORKFLOW_PROCESS on x.RELATED_ID equals c.ID
                              join v in db.WORKFLOW_PROCESS_ACTIVITY on c.ID equals v.SOURCE_ID
                              join b in db.ACTIVITY on v.RELATED_ID equals b.ID
                              join n in db.ACTIVITY_ASSIGNMENT on b.ID equals n.SOURCE_ID
                              join m in db.IDENTITY on n.RELATED_ID equals m.ID
                              where b.STATE == "active" && z.id == g.id
                              select b).FirstOrDefault().KEYED_NAME
                }).Distinct();

                if (!string.IsNullOrEmpty(status))
                {
                    if (status != "End")
                    {
                        datas = datas.Where(x => x.status == status);
                    }
                    else
                    {
                        datas = datas.Where(x => x.status == null);
                    }
                }

                // 时间查询
                if (startTime != null)
                {
                    datas = datas.Where(x => x.nb_RaisedDate >= startTime);
                }

                if (endTime != null)
                {
                    datas = datas.Where(x => x.nb_RaisedDate <= endTime);
                }

                total = datas.Count();
                if (para != null)
                {
                    //排序
                    if (para.sSortType == "asc")
                    {
                        datas = Common.OrderBy(datas, para.iSortTitle, false);
                    }
                    else
                    {
                        datas = Common.OrderBy(datas, para.iSortTitle, true);
                    }
                    //分页
                    datas = datas.Skip(para.iDisplayStart).Take(para.iDisplayLength);
                }
                return(datas.ToList());
            }
        }
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ViewResult Print(string id)
        {
            Item result = PrManageBll.GetPrManageObjById(inn, id);
            //拆解数据
            PrManageModel model = new PrManageModel();

            model.id                   = result.getProperty("id");
            model.b_PrRecordNo         = result.getProperty("b_prrecordno");
            model.b_PrType             = result.getProperty("b_prtype");
            model.b_BusinessDepartment = result.getProperty("b_businessdepartment");
            model.b_Budget             = decimal.Parse(result.getProperty("b_budget"));
            model.b_ApplicantId        = result.getProperty("b_applicantid");
            model.b_Applicant          = result.getProperty("b_applicant");
            model.b_RaisedDate         = DateTime.Parse(result.getProperty("b_raiseddate")).ToString("yyyy-MM-dd");
            model.b_EmailAddress       = result.getProperty("b_emailaddress");
            model.b_PhoneNo            = result.getProperty("b_phoneno");
            model.b_ProjectName        = result.getProperty("b_projectname");
            model.b_BudgetCode         = result.getProperty("b_budgetcode");
            model.b_ProjectLeader      = result.getProperty("b_projectleader");
            model.b_ProjectManager     = result.getProperty("b_projectmanager");
            model.b_ProjectDirector    = result.getProperty("b_projectdirector");
            model.b_BudgetStatus       = result.getProperty("b_budgetstatus");
            model.b_BuyerId            = result.getProperty("b_buyerid");
            model.b_Buyer              = result.getProperty("b_buyer");
            model.b_UrgentPurchase     = result.getProperty("b_urgentpurchase") == "0" ? false : true;
            model.b_RepetitivePurchase = result.getProperty("b_repetitivepurchase") == "0" ? false : true;
            model.b_AuthorizedPurchase = result.getProperty("b_authorizedpurchase") == "0" ? false : true;
            //model.b_SourcedSupplier = result.getProperty("b_sourcedsupplier");
            //model.b_ContractPrice = result.getProperty("b_contractprice");
            //model.b_PoNo = result.getProperty("b_pono");
            //model.b_ContractProperty = result.getProperty("b_contractproperty");
            model.b_PurchaseContent  = result.getProperty("b_purchasecontent");
            model.b_ContractParty    = result.getProperty("b_contractparty");
            model.b_ApplicantAddress = result.getProperty("b_applicantaddress");
            model.b_IsSingleSupplier = result.getProperty("b_issinglesupplier") == "0" ? false : true;
            model.b_ContractType     = result.getProperty("b_contracttype");
            model.b_DeptManager      = result.getProperty("b_deptmanager");
            model.b_DeptDirector     = result.getProperty("b_deptdirector");
            model.b_CostCenter       = result.getProperty("b_costcenter");
            model.b_PurchasingReason = result.getProperty("b_purchasingreason");
            model.b_AdditionalBudget = result.getProperty("b_additionalbudget");
            model.b_DeptVP           = result.getProperty("b_deptvp");
            model.UserName           = Userinfo.UserName;
            model.status             = Common.GetItemStatus(id);
            Item Relation = result.getRelationships("b_RequestInfo");

            if (Relation.getItemCount() > 0)
            {
                model.PrManageItems = new List <PrManageItem>();
                for (int i = 0; i < Relation.getItemCount(); i++)
                {
                    Item         ItemObJ   = Relation.getItemByIndex(i).getRelatedItem();
                    PrManageItem itemModel = new PrManageItem();
                    itemModel.id                      = ItemObJ.getProperty("id");
                    itemModel.b_No                    = ItemObJ.getProperty("b_no");
                    itemModel.b_RequestList           = ItemObJ.getProperty("b_requestlist");
                    itemModel.b_SpecificationQuantity = ItemObJ.getProperty("b_specificationquantity");
                    itemModel.b_ProjectNo             = ItemObJ.getProperty("b_projectno");
                    itemModel.b_TaskNo                = ItemObJ.getProperty("b_taskno");
                    itemModel.b_Qty                   = int.Parse(ItemObJ.getProperty("b_qty"));
                    itemModel.b_Unit                  = ItemObJ.getProperty("b_unit");
                    model.PrManageItems.Add(itemModel);
                }
            }
            List <string> listRoleName = IdentityDA.GetIdentityByUserName(Userinfo.UserName);

            model.IsPurchasingAuth = false;

            if (model.UserName == model.b_Buyer || listRoleName.Contains("采购员") || listRoleName.Contains("采购部接收PR") || listRoleName.Contains("PRReader") || Userinfo.LoginName == "admin")
            {
                model.IsPurchasingAuth = true;
                //询价信息
                Item quotationRelation = result.getRelationships("b_QuotationItem");
                if (quotationRelation.getItemCount() > 0)
                {
                    model.PrQuotationItems = new List <PrQuotationItem>();
                    for (int i = 0; i < quotationRelation.getItemCount(); i++)
                    {
                        Item            itemObj   = quotationRelation.getItemByIndex(i).getRelatedItem();
                        PrQuotationItem itemModel = new PrQuotationItem();
                        itemModel.id          = itemObj.getProperty("id");
                        itemModel.b_Supplier  = itemObj.getProperty("b_supplier");
                        itemModel.b_Quotation = itemObj.getProperty("b_quotation");
                        itemModel.b_Remarks   = itemObj.getProperty("b_remarks");
                        model.PrQuotationItems.Add(itemModel);
                    }
                }

                //获取重复信息
                Item repeatedPurchasing = result.getRelationships("b_RepeatedPurchasing");
                if (repeatedPurchasing.getItemCount() > 0)
                {
                    model.PrRepeateItems = new List <PrRepeateItem>();
                    for (int i = 0; i < repeatedPurchasing.getItemCount(); i++)
                    {
                        Item          itemObj   = repeatedPurchasing.getItemByIndex(i).getRelatedItem();
                        PrRepeateItem itemModel = new PrRepeateItem();
                        itemModel.id                 = itemObj.getProperty("id");
                        itemModel.b_PrRecordNo       = itemObj.getProperty("b_prrecordno");
                        itemModel.b_PreviousSupplier = itemObj.getProperty("b_previoussupplier");
                        itemModel.b_ContractNo       = itemObj.getProperty("b_contractno");
                        //itemModel.b_ContractPrice = itemObj.getProperty("b_contractprice");
                        itemModel.b_PreviousBuyer = itemObj.getProperty("b_previousbuyer");
                        model.PrRepeateItems.Add(itemModel);
                    }
                }

                //获取挑选的供应商
                Item b_ChoiceSuppliers = result.getRelationships("b_ChoiceSuppliers");
                if (b_ChoiceSuppliers.getItemCount() > 0)
                {
                    model.PrChoiceSupplierItems = new List <PrChoiceSupplierItem>();
                    for (int i = 0; i < b_ChoiceSuppliers.getItemCount(); i++)
                    {
                        Item itemObj = b_ChoiceSuppliers.getItemByIndex(i).getRelatedItem();
                        PrChoiceSupplierItem itemModel = new PrChoiceSupplierItem();
                        itemModel.id                 = itemObj.getProperty("id");
                        itemModel.b_Supplier         = itemObj.getProperty("b_supplier");
                        itemModel.b_ContractPrice    = itemObj.getProperty("b_contractprice");
                        itemModel.b_PoNo             = itemObj.getProperty("b_pono");
                        itemModel.b_ContractProperty = itemObj.getProperty("b_contractproperty");
                        itemModel.b_PaymentClause    = itemObj.getProperty("b_paymentclause");
                        model.PrChoiceSupplierItems.Add(itemModel);
                    }
                }
            }
            model.HistoryList = GetPrManageHistoryList(model.id);
            foreach (var item in model.HistoryList)
            {
                item.Created_on = item.Create_onStr.GetValueOrDefault().ToString("yyyy-MM-dd HH:mm:ss");
                item.ItemStatus = Common.GetChineseValueByParam(item.ItemStatus, "PrManageWorkFlow", "WorkFlow", Userinfo.language);
                item.OperateStr = Common.GetChineseValueByParam(item.OperateStr, "PrManageWorkFlow", "WorkFlow", Userinfo.language);
            }
            return(View("~/Views/PrManage/PrintPrManage.cshtml", model));
        }
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="inn"></param>
        /// <param name="emailEntity"></param>
        public static void SendEmailByOperation(Innovator inn, EmailEntity emailEntity, WORKFLOW_PROCESS_PATH choicePath)
        {
            //邮箱列表
            List <string> listEmail = new List <string>();
            List <string> names     = new List <string>();
            string        nameStr   = "";
            string        subject   = "";
            string        body      = "";

            Item   activity  = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID);
            string keyedName = activity.getProperty("keyed_name").Trim();
            //获取邮件需要发送的人员信息
            Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID);

            //获取邮箱信息
            UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names);

            if (names != null && names.Count > 0)
            {
                for (int i = 0; i < names.Count; i++)
                {
                    if (i != names.Count - 1)
                    {
                        nameStr += names[i] + "、";
                    }
                    else
                    {
                        nameStr += names[i];
                    }
                }
            }
            if (choicePath.NAME.Contains("Return"))
            {
                subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected.";
                body    = "Dear " + nameStr + ",<br/><br/>";
                body   += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index";
            }
            else if (keyedName == "End")
            {
                //获取申请人邮箱
                Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, emailEntity.ApplicantName);
                if (!applicantIdentity.isError())
                {
                    UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names);
                }
                if (names != null && names.Count > 0)
                {
                    for (int i = 0; i < names.Count; i++)
                    {
                        if (i != names.Count - 1)
                        {
                            nameStr += names[i] + "、";
                        }
                        else
                        {
                            nameStr += names[i];
                        }
                    }
                }
                subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved.";
                body    = "Dear " + nameStr + ",<br/><br/>";
                body   += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index";
            }
            else
            {
                subject = "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval.";
                body   += "Dear " + nameStr + ",<br/><br/>";
                body   += "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval.<br/>";
                body   += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index";
            }
            listEmail = new List <string>();
            listEmail.Add("*****@*****.**");
            listEmail.Add("*****@*****.**");
            //listEmail.Add("*****@*****.**");
            //异步执行
            new Task(() =>
            {
                MailOperator.SendMail(listEmail, subject, body);
            }).Start();
        }