Beispiel #1
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="mailOutBox"></param>
        /// <param name="mailContent"></param>
        /// <param name="isAdd">是否新增</param>
        /// <returns></returns>
        public int Send(Model.MailOutBox mailOutBox, Model.MailContent mailContent, bool isAdd)
        {
            Organize organize = new Organize();

            return(mailOutBoxData.Send(mailOutBox, mailContent, organize.GetAllUsers(mailOutBox.ReceiveUsers),
                                       organize.GetAllUsers(mailOutBox.CarbonCopy), organize.GetAllUsers(mailOutBox.SecretCopy), isAdd));
        }
Beispiel #2
0
        /// <summary>
        /// 查询一个用户可以使用的设置
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <Model.HomeSet> GetListByUserId(Guid userId)
        {
            Organize organize = new Organize();
            var      all      = GetAll();

            return(all.FindAll(p => p.UseOrganizes.IsNullOrWhiteSpace() ||
                               p.UseUsers.ContainsIgnoreCase(userId.ToString())).OrderBy(p => p.Sort).ToList());
        }
Beispiel #3
0
        /// <summary>
        /// 得到一批人员所在部门所有人员
        /// </summary>
        /// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param>
        /// <returns></returns>
        public List <Model.User> GetOrganizeUsers(List <string> userIds)
        {
            List <Model.User> users    = new List <Model.User>();
            Organize          organize = new Organize();

            foreach (string userId in userIds)
            {
                Guid organzieId = GetOrganizeId(userId);
                users.AddRange(organize.GetAllUsers(organzieId));
            }
            return(users);
        }
Beispiel #4
0
        /// <summary>
        /// 更新所有菜单使用人员
        /// </summary>
        public void UpdateAllUseUser(List <Model.MenuUser> menuUsers = null)
        {
            if (null == menuUsers)
            {
                menuUsers = menuUserData.GetAll(out bool isCache);
            }
            Organize organize = new Organize();

            foreach (var menuUser in menuUsers)
            {
                menuUser.Users = organize.GetAllUsersId(menuUser.Organizes);
            }
            Cache.IO.Insert(Data.MenuUser.CACHEKEY, menuUsers);
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个人员的主要组织显示
        /// </summary>
        /// <param name="id">人员ID</param>
        /// <param name="isShowRoot">是否显示根</param>
        /// <returns></returns>
        public string GetOrganizeMainShowHtml(Guid id, bool isShowRoot = true)
        {
            var organizeUser = new OrganizeUser().GetMainByUserId(id);

            if (null == organizeUser)
            {
                return("");
            }
            else
            {
                Organize organize    = new Organize();
                string   parentsName = organize.GetParentsName(organizeUser.OrganizeId, isShowRoot);
                return((parentsName.IsNullOrWhiteSpace() ? "" : parentsName + " \\ ") + organize.GetName(organizeUser.OrganizeId));
            }
        }
Beispiel #6
0
        /// <summary>
        /// 得到一个人员所在的单位
        /// </summary>
        /// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param>
        /// <returns></returns>
        public Model.Organize GetUnit(string userId)
        {
            Guid organizeId = GetOrganizeId(userId);

            if (organizeId.IsEmptyGuid())
            {
                return(null);
            }
            var org = new Organize().Get(organizeId);

            if (org.Type == 1)
            {
                return(org);
            }
            var parents = new Organize().GetAllParents(organizeId, false);

            return(parents.Find(p => p.Type == 1));
        }
Beispiel #7
0
        /// <summary>
        /// 得到一个人员的所有上级部门领导
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public (string leader, string chargeLeader) GetAllParentLeader(string userId)
        {
            var parentId = GetOrganizeId(userId);

            if (parentId.IsEmptyGuid())
            {
                return(string.Empty, string.Empty);
            }
            var           allParents   = new Organize().GetAllParents(parentId);
            StringBuilder leader       = new StringBuilder();
            StringBuilder charegLeader = new StringBuilder();

            foreach (var parent in allParents)
            {
                leader.Append(parent.Leader);
                leader.Append(",");
                charegLeader.Append(parent.ChargeLeader);
                charegLeader.Append(",");
            }
            return(leader.ToString().TrimEnd(','), charegLeader.ToString().TrimEnd(','));
        }
Beispiel #8
0
        /// <summary>
        /// 分享目录
        /// </summary>
        /// <param name="dirs">分享的目录或文件</param>
        /// <param name="members">分享给谁</param>
        /// <param name="shareUerId">分享人员ID</param>
        /// <param name="expireDate">过期时间</param>
        /// <returns></returns>
        public int Share(string dirs, string members, Guid shareUerId, DateTime expireDate)
        {
            if (dirs.IsNullOrWhiteSpace())
            {
                return(0);
            }
            string[] dirArray      = dirs.Split(',');
            var      users         = new Organize().GetAllUsers(members);
            DateTime shareDateTime = DateExtensions.Now;
            int      i             = 0;

            foreach (string dir in dirArray)
            {
                if (dir.IsNullOrWhiteSpace())
                {
                    continue;
                }
                List <Model.UserFileShare> userFileShares = new List <Model.UserFileShare>();
                foreach (var user in users)
                {
                    if (user.Id == shareUerId)
                    {
                        continue;//自己分享给自己不加记录
                    }
                    Model.UserFileShare userFileShare = new Model.UserFileShare
                    {
                        FileId      = dir,
                        ShareDate   = shareDateTime,
                        FileName    = System.IO.Path.GetFileName(dir.DESDecrypt()),
                        ShareUserId = shareUerId,
                        UserId      = user.Id,
                        ExpireDate  = expireDate,
                        IsView      = 0
                    };
                    userFileShares.Add(userFileShare);
                }
                i += userFileShareData.Share(userFileShares, dir);
            }
            return(i);
        }
Beispiel #9
0
        /// <summary>
        /// 判断一个用户是否被冻结(所在岗位部门被冻结也算)
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool IsFrozen(Model.User user)
        {
            if (user.Status != 0)
            {
                return(true);
            }
            var      organzieUsers = new OrganizeUser().GetListByUserId(user.Id);
            Organize organize      = new Organize();

            foreach (var organizeUser in organzieUsers)
            {
                var organizeModel = organize.Get(organizeUser.OrganizeId);
                if (null != organizeModel)
                {
                    if (organizeModel.Status != 0 || organize.GetAllParents(organizeModel.Id, false).Exists(p => p.Status != 0))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #10
0
        /// <summary>
        /// 判断一个人员是否在一个组织架构字符串里
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="memberIds"></param>
        /// <returns></returns>
        public bool IsIn(string userId, string memberIds)
        {
            var  users    = new Organize().GetAllUsers(memberIds);
            Guid userGuid = Guid.Empty;

            if (userId.IsGuid(out Guid uid))
            {
                userGuid = uid;
            }
            else if (userId.StartsWith(Organize.PREFIX_USER))
            {
                userGuid = userId.RemoveUserPrefix().ToGuid();
            }
            else if (userId.StartsWith(Organize.PREFIX_RELATION))
            {
                userGuid = userId.RemoveUserRelationPrefix().ToGuid();
            }
            if (userGuid.IsEmptyGuid())
            {
                return(false);
            }
            return(users.Exists(p => p.Id == userGuid));
        }
Beispiel #11
0
        /// <summary>
        /// 得到一个人员的所在组织显示
        /// </summary>
        /// <param name="id">人员ID</param>
        /// <param name="isShowRoot">是否显示根</param>
        /// <returns></returns>
        public string GetOrganizesShowHtml(Guid id, bool isShowRoot = true)
        {
            var           organizeUsers = new OrganizeUser().GetListByUserId(id);
            StringBuilder stringBuilder = new StringBuilder();
            Organize      organize      = new Organize();

            foreach (var organizeUser in organizeUsers)
            {
                var parentsName = organize.GetParentsName(organizeUser.OrganizeId, isShowRoot);
                stringBuilder.Append("<div>");
                if (!parentsName.IsNullOrWhiteSpace())
                {
                    stringBuilder.Append(parentsName + " \\ ");
                }
                stringBuilder.Append(organize.GetName(organizeUser.OrganizeId));
                if (organizeUser.IsMain == 0)
                {
                    stringBuilder.Append("<span style='color:#999;'>[兼任]</span>");
                }
                stringBuilder.Append("</div>");
            }
            return(stringBuilder.ToString());
        }
Beispiel #12
0
        /// <summary>
        /// 得到所有设置
        /// </summary>
        /// <returns></returns>
        public List <Model.HomeSet> GetAll()
        {
            object obj = Cache.IO.Get("roadflow_cache_homeset");

            if (null == obj)
            {
                Organize organize = new Organize();
                var      homeSets = homeSetData.GetAll();
                foreach (var model in homeSets)
                {
                    if (!model.UseOrganizes.IsNullOrWhiteSpace())
                    {
                        model.UseUsers = organize.GetAllUsersId(model.UseOrganizes);
                    }
                }
                Cache.IO.Insert("roadflow_cache_homeset", homeSets);
                return(homeSets);
            }
            else
            {
                return((List <Model.HomeSet>)obj);
            }
        }
Beispiel #13
0
        /// <summary>
        /// 判断一个人员是否有权限使用该菜单
        /// </summary>
        /// <param name="menuId"></param>
        /// <param name="userId"></param>
        /// <param name="menuusers"></param>
        /// <param name="source"></param>
        /// <param name="params1">地址参数</param>
        /// <param name="showSource">是否显示菜单来源</param>
        /// <returns></returns>
        public bool HasUse(Guid menuId, Guid userId, List <Model.MenuUser> menuusers, out string source, out string params1, bool showSource = false)
        {
            source  = string.Empty;
            params1 = string.Empty;
            var menus = menuusers.FindAll(p => p.MenuId == menuId && p.Users.ContainsIgnoreCase(userId.ToString()));

            if (menus.Count > 0)
            {
                if (showSource)//是否显示菜单来源
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var menu in menus)
                    {
                        sb.Append(menu.Organizes);
                        sb.Append(",");
                        if (!menu.Params.IsNullOrEmpty())
                        {
                            params1 = menu.Params;
                        }
                    }
                    source = new Organize().GetNames(sb.ToString().TrimEnd(','));
                }
                StringBuilder psb = new StringBuilder();//组织单独对菜单使用人员设置的URL参数
                foreach (var m in menus.FindAll(p => !p.Params.IsNullOrEmpty()).GroupBy(p => p.Params))
                {
                    psb.Append(m.Key.Trim());
                    psb.Append("&");
                }
                params1 = psb.ToString().TrimEnd('&');
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 得到查询HTML
        /// </summary>
        /// <param name="programQueries"></param>
        /// <param name="localizer">语言包</param>
        /// <returns></returns>
        private string GetQueryHtml(List <Model.ProgramQuery> programQueries, IStringLocalizer localizer = null)
        {
            StringBuilder query_controls = new StringBuilder();

            if (null == programQueries)
            {
                return("");
            }
            foreach (var query in programQueries)
            {
                string title       = query.ShowTitle.IsNullOrWhiteSpace() ? query.Field : query.ShowTitle;
                string controlName = query.ControlName.IsNullOrWhiteSpace() ? "ctl_" + query.Id.ToString("N") : query.ControlName;
                query_controls.Append("<span style=\"margin-right:8px;\">");
                query_controls.Append("<span>" + title + ":</span>");
                switch (query.InputType)
                {
                case 0:     //文本框
                    query_controls.Append("<input type='text' class='mytext'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;

                case 1:    //日期
                    query_controls.Append("<input type='text' class='mycalendar'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;

                case 2:    //日期范围
                    query_controls.Append("<input type='text' class='mycalendar'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    query_controls.Append(localizer == null ? (localizer == null ? " 至 " : localizer["To"]) : localizer["To"]);
                    query_controls.Append("<input type='text' class='mycalendar'");
                    query_controls.Append(" id='" + controlName + "1'");
                    query_controls.Append(" name='" + controlName + "1'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;

                case 3:    //日期时间
                    query_controls.Append("<input type='text' class='mycalendar' istime='1'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;

                case 4:    //日期时间范围
                    query_controls.Append("<input type='text' class='mycalendar' istime='1'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    query_controls.Append(localizer == null ? (localizer == null ? " 至 " : localizer["To"]) : localizer["To"]);
                    query_controls.Append("<input type='text' class='mycalendar' istime='1'");
                    query_controls.Append(" id='" + controlName + "1'");
                    query_controls.Append(" name='" + controlName + "1'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;

                case 5:    //下拉选项
                    query_controls.Append("<select class='myselect'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append(">");
                    query_controls.Append("<option value=\"\"></option>");
                    switch (query.DataSource.Value)
                    {
                    case 0:        //字符串表达式
                        query_controls.Append(new Form().GetOptionsByStringExpression(query.DataSourceString, ""));
                        break;

                    case 1:        //数据字典
                        Dictionary.ValueField valueField = Dictionary.ValueField.Id;
                        switch (query.OrgAttribute.ToInt(0))
                        {
                        case 1:
                            valueField = Dictionary.ValueField.Title;
                            break;

                        case 2:
                            valueField = Dictionary.ValueField.Code;
                            break;

                        case 3:
                            valueField = Dictionary.ValueField.Value;
                            break;

                        case 4:
                            valueField = Dictionary.ValueField.Note;
                            break;

                        case 5:
                            valueField = Dictionary.ValueField.Other;
                            break;

                        default:
                            valueField = Dictionary.ValueField.Id;
                            break;
                        }
                        query_controls.Append(new Dictionary().GetOptionsByID(query.DictValue.ToGuid(), valueField));
                        break;

                    case 2:        //SQL
                        query_controls.Append(new Form().GetOptionsBySQL(query.ConnId, query.DataSourceString, ""));
                        break;
                    }
                    query_controls.Append("</select>");
                    break;

                case 6:    //组织机构选择
                    query_controls.Append("<input type='text' class='mymember'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    string orgOptions = new Organize().GetOrganizeAttrString(query.OrgAttribute);
                    query_controls.Append(orgOptions);
                    query_controls.Append("/>");
                    break;

                case 7:    //数据字典选择
                    query_controls.Append("<input type='text' class='mydict'");
                    query_controls.Append(" id='" + controlName + "'");
                    query_controls.Append(" name='" + controlName + "'");
                    query_controls.Append(" rootid='" + query.DictValue + "'");
                    if (!query.ShowStyle.IsNullOrWhiteSpace())
                    {
                        query_controls.Append(" style=\"" + query.ShowStyle + "\"");
                    }
                    query_controls.Append("/>");
                    break;
                }
                query_controls.Append("</span>");
            }
            return(query_controls.ToString());
        }
Beispiel #15
0
        /// <summary>
        /// 得到导出excel数据(不分页的数据)
        /// </summary>
        /// <param name="programRunModel"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public DataTable GetExportData(Model.ProgramRun programRunModel, HttpRequest request)
        {
            DataTable exportDt = new DataTable();

            if (null == programRunModel || programRunModel.ProgramExports.Count == 0)
            {
                return(exportDt);
            }
            string sql = request.HttpContext.Session.GetString("program_querysql_" + programRunModel.Id.ToString("N"));

            if (sql.IsNullOrWhiteSpace())
            {
                return(exportDt);
            }
            object obj = Cache.IO.Get("program_queryparameter_" + programRunModel.Id.ToString("N") + "_" + request.HttpContext.Session.Id);

            DbParameter[] parameters = null;
            if (null != obj)
            {
                parameters = ((List <DbParameter>)obj).ToArray();
            }
            DbConnection dbConnection = new DbConnection();
            DataTable    dt           = dbConnection.GetDataTable(programRunModel.ConnId, sql, parameters);

            if (dt.Rows.Count == 0)
            {
                return(exportDt);
            }
            foreach (var field in programRunModel.ProgramExports)
            {
                exportDt.Columns.Add(field.ShowTitle.IsNullOrEmpty() ? field.Field : field.ShowTitle, Type.GetType("System.String"));
            }
            foreach (DataRow dr in dt.Rows)
            {
                DataRow dr1 = exportDt.NewRow();
                foreach (var field in programRunModel.ProgramExports)
                {
                    string value = dt.Columns.Contains(field.Field) ? dr[field.Field].ToString() : string.Empty;
                    if (!value.IsNullOrWhiteSpace())
                    {
                        switch (field.ShowType)
                        {
                        case 1:    //序号

                            break;

                        case 2:    //日期时间
                            if (value.IsDateTime(out DateTime d))
                            {
                                value = d.ToString(field.ShowFormat.IsNullOrWhiteSpace() ? "yyyy-MM-dd HH:mm:ss" : field.ShowFormat);
                            }
                            break;

                        case 3:    //数字
                            if (!field.ShowFormat.IsNullOrWhiteSpace())
                            {
                                value = value.ToDecimal().ToString(field.ShowFormat);
                            }
                            break;

                        case 4:    //数据字典ID显示为标题
                            value = new Dictionary().GetTitles(value);
                            break;

                        case 5:    //组织架构显示为名称
                            value = new Organize().GetNames(value);
                            break;

                        case 6:    //自定义
                            value = Wildcard.Filter(field.CustomString, null, dr);
                            break;

                        case 7:    //人员ID显示为姓名
                            value = new User().GetNames(value);
                            break;
                        }
                    }
                    dr1[field.ShowTitle.IsNullOrEmpty() ? field.Field : field.ShowTitle] = value;
                }
                exportDt.Rows.Add(dr1);
            }
            return(exportDt);
        }
Beispiel #16
0
        /// <summary>
        /// 发送一条消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="receiveUsers">接收人员,如果为空则从message.ReceiverIdString中取</param>
        /// <param name="localizer">语言包</param>
        /// <returns>返回1表示成功,其它为错误信息</returns>
        public string Send(Model.Message message, List <Model.User> receiveUsers = null, IStringLocalizer localizer = null)
        {
            if (null == message)
            {
                return(localizer == null ? "消息为空!" : localizer["MessageEmpty"]);
            }
            if (receiveUsers == null)
            {
                receiveUsers = new Organize().GetAllUsers(message.ReceiverIdString);
            }
            if (!receiveUsers.Any())
            {
                return(localizer == null ? "消息没有接收人!" : localizer["MessageNotReceiver"]);
            }
            if (message.ReceiverIdString.IsNullOrEmpty())
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (var u in receiveUsers)
                {
                    stringBuilder.Append(Organize.PREFIX_USER);
                    stringBuilder.Append(u.Id);
                    stringBuilder.Append(",");
                }
                message.ReceiverIdString = stringBuilder.ToString().TrimEnd(',');
            }
            List <Model.MessageUser> messageUsers = new List <Model.MessageUser>();
            List <string>            userIDList   = new List <string>();//记录用户ID,用于发送singalr消息

            string[] sendTypes = message.SendType.Split(',');
            foreach (string sendType in sendTypes)
            {
                if (!sendType.IsInt(out int t))
                {
                    continue;
                }
                switch (t)
                {
                case 0:    //站内短信
                    foreach (var user in receiveUsers)
                    {
                        messageUsers.Add(new Model.MessageUser()
                        {
                            MessageId = message.Id,
                            UserId    = user.Id,
                            IsRead    = 0
                        });
                        userIDList.Add(user.Id.ToString().ToLower());
                    }
                    break;

                case 1:    //手机短信
                    StringBuilder mobiles = new StringBuilder();
                    foreach (var user in receiveUsers)
                    {
                        if (!user.Mobile.IsNullOrWhiteSpace())
                        {
                            mobiles.Append(user.Mobile);
                            mobiles.Append(",");
                        }
                    }
                    SMS.SendSMS(message.Contents.RemoveHTML(), mobiles.ToString().TrimEnd(','));
                    break;

                case 2:    //微信
                    if (Config.Enterprise_WeiXin_IsUse)
                    {
                        JObject msgJson = new JObject
                        {
                            { "content", message.Contents + (message.SenderName.IsNullOrWhiteSpace() ? "" : "  " + (localizer == null ? "发送人:" : localizer["Sender"]) + message.SenderName) },
                        };
                        EnterpriseWeiXin.Common.SendMessage(receiveUsers, msgJson);
                    }
                    break;
                }
            }
            if (userIDList.Any())//发送singalr消息
            {
                JObject jObject = new JObject
                {
                    { "id", message.Id.ToString() },
                    { "title", localizer == null ? "消息" : localizer["Message"] },
                    { "contents", message.Contents },
                    { "count", 1 }
                };
                new SignalR.SignalRHub().SendMessage(jObject.ToString(Newtonsoft.Json.Formatting.None), userIDList);
            }
            return(Add(message, messageUsers.ToArray()) > 0 ? "1" : (localizer == null ? "发送失败!" : localizer["SendFail"]));
        }
Beispiel #17
0
        public static string GetWildcardValue(string wildcard, Model.User userModel, object obj)
        {
            Organize organize = new Organize();
            User     user     = new User();

            Microsoft.AspNetCore.Http.HttpRequest request = Tools.HttpContext.Request;
            switch (wildcard.ToLower())
            {
            case "{<userid>}":    //当前用户ID
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : userModel.Id.ToUpperString());

            case "{<username>}":    //当前用户姓名
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : userModel.Name);

            case "{<userdeptid>}":    //当前用户部门ID
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var dept = user.GetDept(userModel.Id.ToString());
                return(dept == null ? "" : dept.Id.ToUpperString());

            case "{<userdeptname>}":    //当前用户部门名称
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var dept1 = user.GetDept(userModel.Id.ToString());
                return(dept1 == null ? "" : dept1.Name);

            case "{<userstationid>}":    //当前用户岗位ID
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var station = user.GetStation(userModel.Id.ToString());
                return(station == null ? "" : station.Id.ToUpperString());

            case "{<userstationname>}":    //当前用户岗位名称
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var station1 = user.GetStation(userModel.Id.ToString());
                return(station1 == null ? "" : station1.Name);

            case "{<userworkgroupid>}":    //当前用户工作组ID
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetWorkGroupsId(userModel.Id));

            case "{<userworkgroupname>}":    //当前用户工作组名称
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetWorkGroupsName(userModel.Id));

            case "{<userdeptleaderid>}":    //当前用户部门领导ID
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetLeader(userModel.Id.ToString()).leader);

            case "{<userdeptleadername>}":    //当前用户部门领导姓名
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetNames(user.GetLeader(userModel.Id.ToString()).leader));

            case "{<usercharegleaderid>}":    //当前用户分管领导ID
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetLeader(userModel.Id.ToString()).chargeLeader);

            case "{<usercharegleadername>}":    //当前用户分管领导姓名
                userModel = userModel ?? User.CurrentUser;
                return(userModel == null ? "" : user.GetNames(user.GetLeader(userModel.Id.ToString()).chargeLeader));

            case "{<userunitid>}":    //当前用户单位ID
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var unit = user.GetUnit(userModel.Id.ToString());
                return(unit == null ? "" : unit.Id.ToUpperString());

            case "{<userunitname>}":    //当前用户单位名称
                userModel = userModel ?? User.CurrentUser;
                if (userModel == null)
                {
                    return("");
                }
                var unit1 = user.GetUnit(userModel.Id.ToString());
                return(unit1 == null ? "" : unit1.Name);

            case "{<initiatorid>}":    //发起者ID
                userModel = userModel ?? User.CurrentUser;
                var firstId = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                return(firstId.IsEmptyGuid() && userModel != null?userModel.Id.ToString() : firstId.ToString());

            case "{<initiatorname>}":    //发起者姓名
                userModel = userModel ?? User.CurrentUser;
                var firstId1 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                return(firstId1.IsEmptyGuid() && userModel != null ? userModel.Name : user.GetName(firstId1));

            case "{<initiatordeptid>}":    //发起者部门ID
                userModel = userModel ?? User.CurrentUser;
                var firstId2 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                if (firstId2.IsEmptyGuid() && null != userModel)
                {
                    firstId2 = userModel.Id;
                }
                var dept2 = user.GetDept(firstId2.ToString());
                return(null == dept2 ? "" : dept2.Id.ToString());

            case "{<initiatordeptname>}":    //发起者部门名称
                userModel = userModel ?? User.CurrentUser;
                var firstId3 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                if (firstId3.IsEmptyGuid() && null != userModel)
                {
                    firstId3 = userModel.Id;
                }
                var dept3 = user.GetDept(firstId3.ToString());
                return(dept3 == null ? "" : dept3.Name);

            case "{<initiatorstationid>}":    //发起者岗位ID
                userModel = userModel ?? User.CurrentUser;
                var firstId4 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                if (firstId4.IsEmptyGuid() && null != userModel)
                {
                    firstId4 = userModel.Id;
                }
                var station4 = user.GetStation(firstId4.ToString());
                return(station4 == null ? "" : station4.Id.ToString());

            case "{<initiatorstationname>}":    //发起者岗位名称
                var firstId5 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId5.IsEmptyGuid() && null != userModel)
                {
                    firstId5 = userModel.Id;
                }
                var station5 = user.GetStation(firstId5.ToString());
                return(station5 == null ? "" : station5.Name);

            case "{<initiatorworkgroupid>}":    //发起者角色组ID
                var firstId6 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId6.IsEmptyGuid() && null != userModel)
                {
                    firstId6 = userModel.Id;
                }
                return(user.GetWorkGroupsId(firstId6));

            case "{<initiatorworkgroupname>}":    //发起者角色组名称
                var firstId7 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToString().ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId7.IsEmptyGuid() && null != userModel)
                {
                    firstId7 = userModel.Id;
                }
                return(user.GetWorkGroupsName(firstId7));

            case "{<initiatorunitid>}":    //发起者单位ID
                var firstId8 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId8.IsEmptyGuid() && null != userModel)
                {
                    firstId8 = userModel.Id;
                }
                var unit8 = user.GetUnit(firstId8.ToString());
                return(unit8 == null ? "" : unit8.Id.ToString());

            case "{<initiatorunitname>}":    //发起者单位名称
                var firstId9 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId9.IsEmptyGuid() && null != userModel)
                {
                    firstId9 = userModel.Id;
                }
                var unit9 = user.GetUnit(firstId9.ToString());
                return(unit9 == null ? "" : unit9.Name);

            case "{<initiatorleaderid>}":    //发起者部门领导ID
                var firstId10 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId10.IsEmptyGuid() && null != userModel)
                {
                    firstId10 = userModel.Id;
                }
                return(user.GetLeader(firstId10.ToString()).leader);

            case "{<initiatorleadername>}":    //发起者部门领导姓名
                var firstId11 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId11.IsEmptyGuid() && null != userModel)
                {
                    firstId11 = userModel.Id;
                }
                return(user.GetNames(user.GetLeader(firstId11.ToString()).leader));

            case "{<initiatorcharegid>}":    //发起者分管领导ID
                var firstId12 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId12.IsEmptyGuid() && null != userModel)
                {
                    firstId12 = userModel.Id;
                }
                return(user.GetLeader(firstId12.ToString()).chargeLeader);

            case "{<initiatorcharegname>}":    //发起者分管领导姓名
                var firstId13 = new FlowTask().GetFirstSenderId(request.Querys("groupid").ToGuid());
                userModel = userModel ?? User.CurrentUser;
                if (firstId13.IsEmptyGuid() && null != userModel)
                {
                    firstId13 = userModel.Id;
                }
                return(user.GetNames(user.GetLeader(firstId13.ToString()).chargeLeader));

            case "{<shortdate>}":    //短日期格式(yyyy-MM-dd)
                return(DateExtensions.Now.ToString("yyyy-MM-dd"));

            case "{<longdate>}":    //长日期格式(yyyy年MM月dd日)
                return(DateExtensions.Now.ToString("yyyy年MM月dd日"));

            case "{<shortdatetime>}":    //短日期时间(yyyy-MM-dd HH:mm)
                return(DateExtensions.Now.ToString("yyyy-MM-dd HH:mm"));

            case "{<longdatetime>}":    //长日期格式(yyyy年MM月dd日 HH时mm分)
                return(DateExtensions.Now.ToString("yyyy年MM月dd日 HH时mm分"));

            case "{<shortdatetimesecond>}":    //短日期时间(yyyy-MM-dd HH:mm:ss)
                return(DateExtensions.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            case "{<longdatetimesecond>}":    //长日期格式(yyyy年MM月dd日 HH时mm分ss秒)
                return(DateExtensions.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒"));

            case "{<flowid>}":    //流程ID
                return(request.Querys("flowid"));

            case "{<flowname>}":    //流程名称
                string flowId = request.Querys("flowid");
                return(!flowId.IsGuid(out Guid fid) ? "" : new Flow().GetName(fid));

            case "{<stepid>}":    //流程步骤ID
                return(request.Querys("stepid"));

            case "{<stepname>}":    //流程步骤名称
                string flowId1 = request.Querys("flowid");
                string stepId  = request.Querys("stepid");
                return(flowId1.IsGuid(out Guid fid1) && stepId.IsGuid(out Guid sid) ? new Flow().GetStepName(fid1, sid) : string.Empty);

            case "{<taskid>}":    //任务ID
                return(request.Querys("taskid"));

            case "{<instanceid>}":    //实例ID
                return(request.Querys("instanceid"));

            case "{<groupid>}":    //组ID
                return(request.Querys("groupid"));

            case "{<previnstanceid>}":    //前一步实例ID
                return(new FlowTask().GetPrevInstanceID(request.Querys("taskid")));

            case "{<prevflowtitle>}":    //前一步流程任务标题
                return(new FlowTask().GetPrevTitle(request.Querys("taskid")));

            case "{<guid>}":    //随机生成UUID
                return(Guid.NewGuid().ToString());

            case "{<emptyguid>}":    //空UUID
                return(Guid.Empty.ToString());
            }
            return("");
        }
Beispiel #18
0
        /// <summary>
        /// 发布一个问卷
        /// </summary>
        /// <param name="voteId"></param>
        /// <param name="localizer">语言包</param>
        /// <returns>返回“1”发布成功,其它为错误信息</returns>
        public string Publish(Guid voteId, IStringLocalizer localizer = null)
        {
            var voteModel = GetVote(voteId);

            if (null == voteModel)
            {
                return(localizer == null ? "未找到要发布的问卷!" : localizer["NotFoundPublishVote"]);
            }
            if (voteModel.Status != 0)
            {
                return(localizer == null ? "该问卷已发布!" : localizer["VoteIsPublish"]);
            }
            if (voteModel.PartakeUsers.IsNullOrWhiteSpace())
            {
                return(localizer == null ? "该问卷没有设置要参与的人员!" : localizer["VoteNotSetUser"]);
            }
            Organize organize = new Organize();
            var      users    = organize.GetAllUsers(voteModel.PartakeUsers);

            if (users.Count == 0)
            {
                return(localizer == null ? "该问卷没有要参与的人员!" : localizer["VoteNotSetUser"]);
            }
            if (GetVoteItems(voteId).Count == 0)
            {
                return(localizer == null ? "该问卷未设置选题!" : localizer["VoteNotTopic"]);
            }
            if (voteModel.ResultViewUsers.IsNullOrWhiteSpace())
            {
                return(localizer == null ? "该问卷没有设置结果查看人员!" : localizer["VoteNotSetResustViewUser"]);
            }
            var resultUsers = organize.GetAllUsers(voteModel.ResultViewUsers);

            if (resultUsers.Count == 0)
            {
                return(localizer == null ? "该问卷没有结果查看人员!" : localizer["VoteNotSetResustViewUser"]);
            }
            User buser = new User();
            List <Model.VotePartakeUser> votePartakeUsers = new List <Model.VotePartakeUser>();

            foreach (var user in users)
            {
                votePartakeUsers.Add(new Model.VotePartakeUser()
                {
                    Id           = Guid.NewGuid(),
                    UserId       = user.Id,
                    UserName     = user.Name,
                    UserOrganize = buser.GetOrganizeMainShowHtml(user.Id, false),
                    VoteId       = voteId,
                    Status       = 0
                });
            }
            List <Model.VoteResultUser> voteResultUsers = new List <Model.VoteResultUser>();

            foreach (var user in resultUsers)
            {
                voteResultUsers.Add(new Model.VoteResultUser()
                {
                    Id     = Guid.NewGuid(),
                    UserId = user.Id,
                    VoteId = voteId
                });
            }
            //if (!voteResultUsers.Exists(p => p.Id == voteModel.CreateUserId))//如果结果查询人员没有选择自己加上自己
            //{
            //    voteResultUsers.Add(new Model.VoteResultUser()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = voteModel.CreateUserId,
            //        VoteId = voteId
            //    });
            //}
            return(votePartakeUserData.Add(votePartakeUsers, voteResultUsers) > 0 ? "1" : (localizer == null ? "发布失败!" : localizer["PublishFail"]));
        }