Ejemplo n.º 1
0
        /// <summary>
        /// 获取某一教研组下面的老师
        /// </summary>
        /// <param name="schoolId">学校Id</param>
        /// <param name="scope">教研组Id</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <TeacherListModel> GetTeacherListByScope(int schoolId, int scope, int pageIndex, int pageSize, out int totalCount)
        {
            var list = new List <TeacherListModel>();

            try
            {
                var apiUrl = Config.UpocManagerUserUrl + "Teacher/Index";
                Dictionary <string, string> param = new Dictionary <string, string>();
                param.Add("appid", Config.AppId);
                param.Add("method", "GetTeacherListByScope");
                param.Add("schoolId", schoolId.ToString());
                param.Add("scope", scope.ToString());
                param.Add("pageIndex", pageIndex.ToString());
                param.Add("pageSize", pageSize.ToString());
                string sign = Helper.GetSign(param);
                param.Add("sign", sign);
                var resultStr = Helper.DoPost(apiUrl, param);                 //提交post请求
                resultStr = resultStr.Replace("\r\n", "").Replace("\\", "");
                var resultData = Helper.FromJsonTo <Result <List <TeacherListModel> > >(resultStr);
                if (resultData.State == 1 && resultData.Data != null)
                {
                    totalCount = resultData.DataCount;
                    list       = resultData.Data;
                    #region 遍历头像

                    var keys = "";
                    list.ForEach(p =>
                    {
                        keys += p.UserId + ",";
                    });
                    keys = keys.TrimEnd(',');
                    var avatarList = UserService.GetUserAvatar(keys);
                    list.ForEach(p =>
                    {
                        var key    = p.UserId;
                        var avatar = avatarList.FirstOrDefault(a => a.UserId == key);
                        p.Avatar   = avatar == null ? "" : avatar.Avatar;
                    });
                    #endregion

                    return(list);
                }
                totalCount = 0;
                return(list);
            }
            catch (Exception)
            {
                totalCount = 0;
                return(list);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取店长列表
        /// </summary>
        /// <returns>The shop manager list.</returns>
        /// <param name="schoolId">School identifier.</param>
        /// <param name="districtCode">District code.</param>
        public List <ShopManagerList> GetShopManagerList(int schoolId, string districtCode)
        {
            try
            {
                var apiUrl = Config.UpocManagerUserUrl + "Assistant/Index";
                var dic    = new Dictionary <string, string>();
                var method = "GetShopManagerList";                 //方法名称,固定值

                dic.Add("appId", Config.AppId);
                dic.Add("method", method);
                dic.Add("schoolId", schoolId.ToString());
                dic.Add("districtCode", districtCode);
                var sign = Helper.GetSign(dic);
                dic.Add("sign", sign);
                var resultStr = Helper.DoPost(apiUrl, dic);                 //提交post请求
                resultStr = resultStr.Replace("\r\n", "").Replace("\\", "");
                var resultData = Helper.FromJsonTo <Result <List <ShopManagerList> > >(resultStr);
                if (resultData.State == 1 && resultData.Data != null)
                {
                    var list = resultData.Data;
                    #region 遍历头像

                    var keys = "";
                    list.ForEach(p =>
                    {
                        keys += p.UserId + ",";
                    });
                    keys = keys.TrimEnd(',');
                    var avatarList = UserService.GetUserAvatar(keys);
                    list.ForEach(p =>
                    {
                        var key    = p.UserId;
                        var avatar = avatarList.FirstOrDefault(a => a.UserId == key);
                        p.Avatar   = avatar == null ? "" : avatar.Avatar;
                    });
                    #endregion

                    return(list);
                }
                return(new List <ShopManagerList>());
            }
            catch (Exception)
            {
                return(new List <ShopManagerList>());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        ///<param name="schoolId">学校Id</param>
        /// <param name="classCode">班级编号</param>
        /// <returns></returns>
        public static ClassRenewEntity GetStudentRenewInfoListByClassCode(int schoolId, string classCode)
        {
            var classRenewEntity = new ClassRenewEntity();

            try
            {
                var apiUrl = Config.RenewApiUrl;
                var dict   = new Dictionary <string, string>();
                var method = "GetStudentRenewInfoListByClassCode";                 //方法名称,固定值
                dict.Add("appId", Config.AppId);
                dict.Add("method", method);
                dict.Add("schoolId", schoolId.ToString());
                dict.Add("classCode", classCode);
                var sign = Helper.GetSign(dict);
                dict.Add("sign", sign);
                var result = Helper.DoPost(apiUrl, dict);                 //提交post请求
                result = result.Replace("\r\n", "").Replace("\\", "");
                var resultData = Helper.FromJsonTo <Result <List <StudentRenewModel> > >(result);
                if (resultData.State == 1 && resultData.Data != null)
                {
                    var data             = resultData.Data;
                    var renewStudents    = data.Where(t => t.isRenew == 1).ToList();
                    var notRenewStudents = data.Where(t => t.isRenew != 1).ToList();
                    classRenewEntity.RenewStudents    = renewStudents;
                    classRenewEntity.NotRenewStudents = notRenewStudents;
                    #region 已续班学员头像
                    if (renewStudents != null && renewStudents.Count > 0)
                    {
                        var userIds = string.Join(",", renewStudents.Where(t => t.userId != "").Select(t => t.userId).ToArray());
                        userIds = userIds.TrimEnd(',');
                        var avatars = UserService.GetUserAvatar(userIds);
                        for (int i = 0; i < renewStudents.Count; i++)
                        {
                            var student = renewStudents[i] as StudentRenewModel;
                            if (string.IsNullOrWhiteSpace(student.userId))
                            {
                                continue;
                            }

                            var avatar = avatars.Where(t => t.UserId == student.userId).FirstOrDefault();
                            if (avatar != null && !(string.IsNullOrWhiteSpace(avatar.Avatar)))
                            {
                                student.avatar = avatar.Avatar;
                            }
                            else
                            {
                                student.avatar = "";
                            }
                        }
                    }
                    #endregion
                    #region 未续班学员头像
                    if (notRenewStudents != null && notRenewStudents.Count > 0)
                    {
                        var userIds = string.Join(",", notRenewStudents.Where(t => t.userId != "").Select(t => t.userId).ToArray());
                        userIds = userIds.TrimEnd(',');
                        var avatars = UserService.GetUserAvatar(userIds);
                        for (int i = 0; i < notRenewStudents.Count; i++)
                        {
                            var student = notRenewStudents[i] as StudentRenewModel;
                            if (string.IsNullOrWhiteSpace(student.userId))
                            {
                                continue;
                            }
                            var avatar = avatars.Where(t => t.UserId == student.userId).FirstOrDefault();
                            if (avatar != null && !(string.IsNullOrWhiteSpace(avatar.Avatar)))
                            {
                                student.avatar = avatar.Avatar;
                            }
                            else
                            {
                                student.avatar = "";
                            }
                        }
                    }
                    #endregion
                    return(classRenewEntity);
                }
                return(classRenewEntity);
            }
            catch (Exception ex)
            {
                return(classRenewEntity);
            }
        }