Example #1
0
        public static List <Dictionary <string, object> > GetCustomerServiceCountGroupByUserStatus(int UserID, int Status, int ProjectID)
        {
            ResetCache();
            var results = new List <Dictionary <string, object> >();
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();
            var ProjectIDList = new List <int>()
            {
                ProjectID
            };
            List <int> EqualIDList = new List <int>();
            List <int> InIDList    = new List <int>();

            Project.GetMyProjectListByUserID(UserID, out EqualIDList, out InIDList, ProjectIDList: ProjectIDList);
            List <string> cmdlist = new List <string>();

            if (InIDList.Count > 0)
            {
                foreach (var InID in InIDList)
                {
                    cmdlist.Add("([Project].AllParentID like '%," + InID + ",%' or [ID]=" + InID + ")");
                }
            }
            if (EqualIDList.Count > 0)
            {
                foreach (var EqualID in EqualIDList)
                {
                    cmdlist.Add("([Project].ID=" + EqualID + ")");
                }
            }
            if (cmdlist.Count > 0)
            {
                conditions.Add("[ProjectID] in (select ID from [Project] where (" + string.Join(" or ", cmdlist.ToArray()) + "))");
            }
            conditions.Add("[ServiceStatus]=@Status");
            parameters.Add(new SqlParameter("@Status", Status));
            string cmdtext = "select * from [CustomerService] where " + string.Join(" and ", conditions.ToArray());

            Utility.LogHelper.WriteInfo("GetCustomerServiceCountGroupByUserStatus", cmdtext);
            var list     = GetList <CustomerServiceDetail>(cmdtext, parameters).ToArray();
            var UserList = User.GetAPPUserList();

            CustomerServiceDetail[] my_list = new CustomerServiceDetail[] { };
            var dic        = new Dictionary <string, object>();
            var UserIDList = UserList.Select(p => p.UserID).ToList();

            foreach (var user in UserList)
            {
                //conditions.Add("REPLACE(REPLACE([ServiceAccpetManID],'[',','),']',',') like '%," + UserID.ToString() + ",%'");
                my_list = list.Where(p => !string.IsNullOrEmpty(p.ServiceAccpetManID) && p.ServiceAccpetManID.Replace("[", ",").Replace("]", ",").Contains("," + user.UserID.ToString() + ",")).ToArray();
                if (my_list.Length > 0)
                {
                    dic               = new Dictionary <string, object>();
                    dic["UserID"]     = user.UserID;
                    dic["UserName"]   = string.IsNullOrEmpty(user.RealName) ? user.LoginName : user.RealName;
                    dic["TotalCount"] = my_list.Length;
                    results.Add(dic);
                }
            }
            my_list = list.Where(p =>
            {
                if (string.IsNullOrEmpty(p.ServiceAccpetManID))
                {
                    return(true);
                }
                string[] ServiceAccpetManIDArray = p.ServiceAccpetManID.Replace("[", ",").Replace("]", ",").Split(',');
                foreach (var MyUserID in UserIDList)
                {
                    foreach (var item in ServiceAccpetManIDArray)
                    {
                        if (MyUserID.ToString().Equals(item))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }).ToArray();
            if (my_list.Length > 0)
            {
                dic               = new Dictionary <string, object>();
                dic["UserID"]     = -1;
                dic["UserName"]   = "******";
                dic["TotalCount"] = my_list.Length;
                results.Add(dic);
            }
            results = results.OrderByDescending(p => Convert.ToInt32(p["TotalCount"])).ToList();
            return(results);
        }
Example #2
0
        public static ViewCustomerService[] GetViewCustomerServiceListByStatus(int status, int UserID, long startRowIndex, int pageSize, out long totalRows, bool onlybaoshi = false, List <int> ProjectIDList = null)
        {
            ResetCache();
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();
            string orderby = " order by [AddTime] desc";

            conditions.Add("1=1");
            if (ProjectIDList != null && ProjectIDList.Count > 0)
            {
                List <string> cmdlist = ViewRoomFeeHistory.GetProjectIDListConditions(ProjectIDList, IncludeRelation: false, RoomIDName: "[ProjectID]", UserID: UserID);
                if (UserID > -1)
                {
                    cmdlist.Add("[ProjectID]=0");
                }
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (status >= 0)
            {
                conditions.Add("[ServiceStatus]=@ServiceStatus");
                parameters.Add(new SqlParameter("@ServiceStatus", status));
                if (status == 1)
                {
                    orderby = " order by [BanJieTime] desc";
                }
            }
            if (UserID > 0)
            {
                conditions.Add("([DepartmentID] in (select DepartmentID from [UserDepartment] where [UserID]=@UserID) or DepartmentID is null or DepartmentID=0)");
                if (status != 3)
                {
                    conditions.Add("REPLACE(REPLACE([ServiceAccpetManID],'[',','),']',',') like '%," + UserID.ToString() + ",%'");
                }
                parameters.Add(new SqlParameter("@UserID", UserID));
            }
            if (onlybaoshi)
            {
                string cmdwhere = string.Empty;
                if (UserID > 0)
                {
                    cmdwhere += " and [AddUserID]=@AddUserID";
                    parameters.Add(new SqlParameter("@AddUserID", UserID));
                }
                conditions.Add("ID in (select ID from [CustomerService] where [WechatServiceID] in (select ID from [Wechat_Service] where 1=1 " + cmdwhere + "))");
            }
            string fieldList = "[ViewCustomerService].*";
            string Statement = " from [ViewCustomerService] where " + string.Join(" and ", conditions.ToArray());
            var    list      = GetList <ViewCustomerService>(fieldList, Statement, parameters, orderby, startRowIndex, pageSize, out totalRows).ToArray();

            if (UserID == -1)
            {
                var UserList   = User.GetAPPUserList();
                var UserIDList = UserList.Select(p => p.UserID).ToList();
                list = list.Where(p =>
                {
                    if (string.IsNullOrEmpty(p.ServiceAccpetManID))
                    {
                        return(true);
                    }
                    string[] ServiceAccpetManIDArray = p.ServiceAccpetManID.Replace("[", ",").Replace("]", ",").Split(',');
                    foreach (var MyUserID in UserIDList)
                    {
                        foreach (var item in ServiceAccpetManIDArray)
                        {
                            if (MyUserID.ToString().Equals(item))
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                }).ToArray();
            }
            return(list);
        }