예제 #1
0
        /// <summary>
        /// 从数据库获取所有意见列表
        /// </summary>
        /// <returns></returns>
        private List <Tuple <Guid, string, int, int, List <Guid> > > getAllListByDb()
        {
            var      comments  = GetAll();
            Organize borganize = new Organize();
            List <Tuple <Guid, string, int, int, List <Guid> > > list = new List <Tuple <Guid, string, int, int, List <Guid> > >();

            foreach (var comment in comments)
            {
                List <Guid> userList = new List <Guid>();
                if (!comment.MemberID.IsNullOrEmpty())
                {
                    var users = borganize.GetAllUsers(comment.MemberID);
                    foreach (var user in users)
                    {
                        userList.Add(user.ID);
                    }
                }

                Tuple <Guid, string, int, int, List <Guid> > tuple = new Tuple <Guid, string, int, int, List <Guid> >(
                    comment.ID,
                    comment.Comment,
                    comment.Type,
                    comment.Sort,
                    userList
                    );
                list.Add(tuple);
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// 得到一个人员的分管领导
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public string GetChargeLeader(Guid userID)
        {
            var mainStation = GetMainStation(userID);

            if (mainStation == null)
            {
                return("");
            }
            FoWoSoft.Platform.Organize borg = new Organize();
            var station = borg.Get(mainStation);

            if (station == null)
            {
                return("");
            }
            if (!station.ChargeLeader.IsNullOrEmpty())
            {
                return(station.ChargeLeader);
            }
            var parents = borg.GetAllParent(station.Number);

            foreach (var parent in parents)
            {
                if (!parent.ChargeLeader.IsNullOrEmpty())
                {
                    return(parent.ChargeLeader);
                }
            }
            return("");
        }
예제 #3
0
        /// <summary>
        /// 更新一个人员的所属角色
        /// </summary>
        /// <param name="userID"></param>
        public void UpdateByUserID(Guid userID)
        {
            Organize  borg       = new Organize();
            UsersRole busersRole = new UsersRole();
            var       roles      = new Role().GetAll();

            busersRole.DeleteByUserID(userID);
            foreach (var role in roles)
            {
                if (role.UseMember.IsNullOrEmpty())
                {
                    continue;
                }
                var users = borg.GetAllUsers(role.UseMember);
                if (users.Exists(p => p.ID == userID))
                {
                    busersRole.Add(new FoWoSoft.Data.Model.UsersRole()
                    {
                        IsDefault = true,
                        MemberID  = userID,
                        RoleID    = role.ID
                    });
                }
            }
            ClearCache();
        }
예제 #4
0
        /// <summary>
        /// 判断一个人员是否在一个组织机构字符串里
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="memberString"></param>
        /// <returns></returns>
        public bool IsContains(Guid userID, string memberString)
        {
            if (memberString.IsNullOrEmpty())
            {
                return(false);
            }
            var user = new Organize().GetAllUsers(memberString).Find(p => p.ID == userID);

            return(user != null);
        }
예제 #5
0
        /// <summary>
        /// 更新应用程序库使用人员缓存
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="userIdString"></param>
        public List <Guid> UpdateUseMemberCache(Guid appid)
        {
            string key = FoWoSoft.Utility.Keys.CacheKeys.AppLibraryUseMember.ToString();
            var    obj = FoWoSoft.Cache.IO.Opation.Get(key);
            Dictionary <Guid, List <Guid> > dict;

            if (obj != null && obj is Dictionary <Guid, List <Guid> > )
            {
                dict = obj as Dictionary <Guid, List <Guid> >;
            }
            else
            {
                dict = new Dictionary <Guid, List <Guid> >();
            }
            var app = new AppLibrary().Get(appid);

            if (app == null)
            {
                return(new List <Guid>());
            }
            if (dict.ContainsKey(appid))
            {
                if (app.UseMember.IsNullOrEmpty())
                {
                    dict.Remove(appid);
                    return(new List <Guid>());
                }
                else
                {
                    var userIDs = new Organize().GetAllUsersIdList(app.UseMember);
                    dict[appid] = userIDs;
                    return(userIDs);
                }
            }
            else if (!app.UseMember.IsNullOrEmpty())
            {
                var userIDs = new Organize().GetAllUsersIdList(app.UseMember);
                dict.Add(appid, userIDs);
                return(userIDs);
            }
            return(new List <Guid>());
        }
예제 #6
0
        /// <summary>
        /// 根据显示方式得到显示的字符串
        /// </summary>
        /// <param name="value"></param>
        /// <param name="displayModel"></param>
        /// <returns></returns>
        public string GetDisplayString(string value, string displayModel, string format = "", string dbconnID = "", string sql = "")
        {
            string value1 = string.Empty;

            switch ((displayModel ?? "").ToLower())
            {
            case "normal":
            default:
                value1 = value;
                break;

            case "dict_id_title":
                var dict = new Dictionary().Get(value.ToGuid());
                value1 = dict == null ? "" : dict.Title;
                break;

            case "dict_id_code":
                var dict1 = new Dictionary().Get(value.ToGuid());
                value1 = dict1 == null ? "" : dict1.Code;
                break;

            case "dict_id_value":
                var dict2 = new Dictionary().Get(value.ToGuid());
                value1 = dict2 == null ? "" : dict2.Value;
                break;

            case "dict_id_note":
                var dict3 = new Dictionary().Get(value.ToGuid());
                value1 = dict3 == null ? "" : dict3.Note;
                break;

            case "dict_id_other":
                var dict4 = new Dictionary().Get(value.ToGuid());
                value1 = dict4 == null ? "" : dict4.Other;
                break;

            case "dict_code_title":
                var dict5 = new Dictionary().GetByCode(value);
                value1 = dict5 == null ? "" : dict5.Title;
                break;

            case "dict_code_id":
                var dict6 = new Dictionary().GetByCode(value);
                value1 = dict6 == null ? "" : dict6.ID.ToString();
                break;

            case "dict_code_value":
                var dict7 = new Dictionary().GetByCode(value);
                value1 = dict7 == null ? "" : dict7.Value;
                break;

            case "dict_code_note":
                var dict8 = new Dictionary().GetByCode(value);
                value1 = dict8 == null ? "" : dict8.Note;
                break;

            case "dict_code_other":
                var dict9 = new Dictionary().GetByCode(value);
                value1 = dict9 == null ? "" : dict9.Other;
                break;

            case "organize_id_name":
                value1 = new Organize().GetNames(value);
                break;

            case "files_link":
                string[]      files = value.Split('|');
                StringBuilder links = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files)
                {
                    links.AppendFormat("<a target=\"_blank\" class=\"blue\" href=\"{0}\">{1}</a><br/>", file, System.IO.Path.GetFileName(file));
                }
                //links.Append("</div>");
                value1 = links.ToString();
                break;

            case "files_img":
                string[]      files1 = value.Split('|');
                StringBuilder links1 = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files1)
                {
                    links1.AppendFormat("<img src=\"{0}\" />", file);
                }
                //links.Append("</div>");
                value1 = links1.ToString();
                break;

            case "datetime_format":
                value1 = value.ToDateTime().ToString(format ?? Utility.Config.DateFormat);
                break;

            case "number_format":
                value1 = value.ToDecimal().ToString(format);
                break;

            case "table_fieldvalue":
                DBConnection dbconn = new DBConnection();
                DataTable    dt     = dbconn.GetDataTable(dbconn.Get(dbconnID.ToGuid()), sql + "'" + value + "'");
                value1 = dt.Rows.Count > 0 && dt.Columns.Count > 0 ? dt.Rows[0][0].ToString() : "";
                break;
            }
            return(value1);
        }