Ejemplo n.º 1
0
        public static List <SelectListItem> GetNoticeTypeList()
        {
            List <SelectListItem> items = new List <SelectListItem>();

            SelectListItem item0 = new SelectListItem()
            {
                Text  = "公告类型",
                Value = "0",
            };

            SelectListItem item1 = new SelectListItem()
            {
                Value = ((int)NoticeType.Register).ToString(),
                Text  = CustomerEnumDesc.GetNoticeType(NoticeType.Register),
            };

            SelectListItem item2 = new SelectListItem()
            {
                Value = ((int)NoticeType.Update).ToString(),
                Text  = CustomerEnumDesc.GetNoticeType(NoticeType.Update),
            };

            SelectListItem item3 = new SelectListItem()
            {
                Value = ((int)NoticeType.Other).ToString(),
                Text  = CustomerEnumDesc.GetNoticeType(NoticeType.Other),
            };

            items.Add(item0);
            items.Add(item1);
            items.Add(item2);
            items.Add(item3);

            return(items);
        }
Ejemplo n.º 2
0
        public ActionResult Add(UserEditInfo user)
        {
            try
            {
                string       partialPath = CustomerEnumDesc.GetResxTypePath(ResxType.UserHeadImage);
                ImageHandler resx        = new ImageHandler
                {
                    ResxTypes          = ResxConfigManager.IMAGE_FILE_TYPES,
                    ResxSize           = ResxConfigManager.IMAGE_MAX_SIZE,
                    IsThumbnail        = false,
                    SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath),
                    AccessUrl          = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath)
                };
                ResxImageResult result = resx.Upload(Request.Form.Files.FirstOrDefault());
                if (!result.Success)
                {
                    return(Json(new { state = -1, error = result.Message }));
                }
                else
                {
                    user.HeadImage = result.ResxAccessUrl;
                }

                int userId = userService.AddUser(user);
                if (userId <= 0)
                {
                    return(Json(new { state = -1, error = "Create user failed." }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { state = -1, error = ex.Message }));
            }
            return(Json(new { state = 1 }));
        }
Ejemplo n.º 3
0
        private void AddNearCircle()
        {
            var           db    = HWLDBContext.GetDBContext(ShareConfiguration.DBConnectionString);
            t_near_circle model = new t_near_circle()
            {
                user_id       = this.userId,
                content_info  = this.messageModel.Content,
                content_type  = CustomerEnumDesc.GetCircleContentType(this.messageModel.Content, null, null, this.messageModel.ImageUrls?.Count ?? 0),
                lat           = this.positionModel.Lat,
                lon           = this.positionModel.Lon,
                pos_desc      = this.positionModel.PosDetails,
                pos_id        = 0,
                image_urls    = CircleImageParser.GetImageString(this.messageModel.ImageUrls),
                comment_count = 0,
                image_count   = 0,
                like_count    = 0,
                publish_time  = DateTime.Now,
                update_time   = DateTime.Now
            };

            db.t_near_circle.Add(model);
            db.SaveChanges();

            NearCircleStore.CreateNearCirclePos(model.id, model.lon, model.lat);

            //send im message to near users
            //... ...
        }
Ejemplo n.º 4
0
        public override ResxUploadResponseBody ExecuteCore()
        {
            string      partialPath = CustomerEnumDesc.GetResxTypePath(request.ResxType, request.UserId);
            ResxHandler resx        = new ResxHandler
            {
                SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath),
                AccessUrl          = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath)
            };
            ResxResult result = resx.Upload(request.Files.FirstOrDefault());

            return(new ResxUploadResponseBody()
            {
                ResxResult = result
            });
        }
Ejemplo n.º 5
0
        public override VideoUploadResponseBody ExecuteCore()
        {
            string       partialPath = CustomerEnumDesc.GetResxTypePath(request.ResxType, request.UserId);
            VideoHandler resx        = new VideoHandler
            {
                ResxTypes          = ResxConfigManager.VIDEO_FILE_TYPES,
                ResxSize           = ResxConfigManager.VIDEO_MAX_SIZE,
                IsThumbnail        = true,
                SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath),
                AccessUrl          = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath)
            };
            ResxVideoResult result = resx.Upload(request.Files.FirstOrDefault());

            return(new VideoUploadResponseBody()
            {
                ResxVideoResult = result
            });
        }
Ejemplo n.º 6
0
        private void Init()
        {
            if (this.resxModel == null)
            {
                throw new Exception("资源属性不能为空");
            }

            if (this.resxModel.ResxTypes == null || this.resxModel.ResxTypes.Length <= 0)
            {
                throw new Exception("需要指定上传资源的类型");
            }

            string dir = ResxConfigManager.UploadDirectory + CustomerEnumDesc.GetResxTypePath(this.resxModel.ResxType, this.resxModel.UserId);

            rootDir   = AppDomain.CurrentDomain.BaseDirectory + dir;
            accessDir = ResxConfigManager.FileAccessUrl + dir;

            if (!Directory.Exists(rootDir))
            {
                Directory.CreateDirectory(rootDir);
            }
        }
Ejemplo n.º 7
0
        public List <AppExt> GetAppVersionList(int topCount = 0)
        {
            IQueryable <AppExt> query = db.t_app_version.Select(v => new AppExt
            {
                Id          = v.id,
                DownloadUrl = v.download_url,
                Name        = v.app_name,
                Size        = v.app_size ?? 0,
                PublishTime = v.publish_time,
                Version     = v.app_version,
                VersionType = v.app_version_type,
            });

            if (topCount > 0)
            {
                query = query.Take(topCount).OrderByDescending(o => o.Id);
            }

            List <AppExt> list = query.ToList();

            list.ForEach(f => f.VersionTypeString = CustomerEnumDesc.GetAppVersionTypeDesc(f.VersionType));
            return(list);
        }
Ejemplo n.º 8
0
        public override AddNearCircleInfoResponseBody ExecuteCore()
        {
            AddNearCircleInfoResponseBody res = new AddNearCircleInfoResponseBody();
            t_near_circle model = new t_near_circle()
            {
                user_id       = this.request.UserId,
                content_info  = this.request.Content,
                content_type  = CustomerEnumDesc.GetCircleContentType(this.request.Content, this.request.LinkUrl, this.request.LinkTitle, this.request.Images?.Count ?? 0),
                link_image    = this.request.LinkImage,
                link_title    = this.request.LinkTitle,
                link_url      = this.request.LinkUrl,
                lat           = this.request.Lat,
                lon           = this.request.Lon,
                id            = 0,
                pos_id        = this.request.PosId,
                pos_desc      = this.request.PosDesc,
                comment_count = 0,
                image_count   = this.request.Images != null ? this.request.Images.Count : 0,
                image_urls    = CircleImageParser.GetImageString(this.request.Images),
                like_count    = 0,
                publish_time  = DateTime.Now,
                update_time   = DateTime.Now
            };

            db.t_near_circle.Add(model);
            db.SaveChanges();

            res.NearCircleId = model.id;
            res.ContentType  = model.content_type;
            res.PublishTime  = model.publish_time;

            //向redis中添加信息的位置数据
            if (res.NearCircleId > 0)
            {
                bool succ = Redis.NearCircleStore.CreateNearCirclePos(res.NearCircleId, this.request.Lon, this.request.Lat);
                if (!succ)//如果添加失败,则将数据库中已经添加的数据删除
                {
                    db.t_near_circle.Remove(model);
                    db.SaveChanges();
                    throw new Exception("发布附近信息失败");
                }
                //else
                //{
                //    if (this.request.Images != null && this.request.Images.Count > 0)
                //    {
                //        List<t_near_circle_image> imgModels = new List<t_near_circle_image>();
                //        this.request.Images.ForEach((i) =>
                //        {
                //            if (string.IsNullOrEmpty(i.Url)) return;
                //            imgModels.Add(new t_near_circle_image()
                //            {
                //                near_circle_id = model.id,
                //                near_circle_user_id = model.user_id,
                //                image_url = i.Url,
                //                height = i.Height,
                //                width = i.Width
                //            });
                //        });

                //        if (imgModels == null || imgModels.Count <= 0) return res;

                //        try
                //        {
                //            db.t_near_circle_image.AddRange(imgModels);
                //            db.SaveChanges();
                //        }
                //        catch (Exception)
                //        {
                //            //可以忽略这个错误
                //        }
                //    }
                //}
            }
            return(res);
        }
Ejemplo n.º 9
0
        private void BindInfo(List <NearCircleInfo> infos)
        {
            if (infos == null || infos.Count <= 0)
            {
                return;
            }

            List <int> imageCircleIds            = infos.Where(n => CustomerEnumDesc.ImageContentTypes().Contains(n.ContentType)).Select(n => n.NearCircleId).ToList();
            List <t_near_circle_image> imageList = null;

            if (imageCircleIds != null && imageCircleIds.Count > 0)
            {
                imageList = db.t_near_circle_image.Where(i => imageCircleIds.Contains(i.near_circle_id)).ToList();
            }
            List <int> circleIds   = infos.Select(n => n.NearCircleId).ToList();
            var        likeList    = db.t_near_circle_like.Where(l => circleIds.Contains(l.near_circle_id) && l.is_delete == false).ToList();
            var        commentList = db.t_near_circle_comment.Where(c => circleIds.Contains(c.near_circle_id)).ToList();

            List <int> userIds = infos.Select(u => u.PublishUserId).ToList();

            if (likeList != null && likeList.Count > 0)
            {
                userIds.AddRange(likeList.Select(u => u.like_user_id).ToList());
            }
            if (commentList != null && commentList.Count > 0)
            {
                userIds.AddRange(commentList.Select(u => u.comment_user_id).ToList());
                userIds.AddRange(commentList.Select(c => c.reply_user_id).ToList());
            }
            var userList   = db.t_user.Where(i => userIds.Contains(i.id)).Select(i => new { i.id, i.name, i.head_image }).ToList();
            var friendList = db.t_user_friend.Where(f => f.user_id == this.request.UserId && userIds.Contains(f.friend_user_id)).Select(f => new { f.friend_user_id, f.friend_user_remark }).ToList();

            foreach (var item in infos)
            {
                if (imageList != null && imageList.Count > 0)
                {
                    item.Images = imageList.Where(i => i.near_circle_id == item.NearCircleId).Select(i => new ImageInfo()
                    {
                        Url    = i.image_url,
                        Height = i.height,
                        Width  = i.width
                    }).ToList();
                }

                if (userList != null && userList.Count > 0)
                {
                    var user = userList.Where(u => u.id == item.PublishUserId).FirstOrDefault();
                    if (user != null)
                    {
                        string friendRemark = friendList != null?friendList.Where(f => f.friend_user_id == item.PublishUserId).Select(f => f.friend_user_remark).FirstOrDefault() : null;

                        item.PublishUserName  = UserUtility.GetShowName(friendRemark, user.name);
                        item.PublishUserImage = user.head_image;
                    }
                }

                if (likeList != null && likeList.Count > 0)
                {
                    item.IsLiked   = likeList.Where(l => l.near_circle_id == item.NearCircleId && l.like_user_id == this.request.UserId).Select(l => l.id).FirstOrDefault() > 0 ? true : false;
                    item.LikeInfos = likeList.Where(l => l.near_circle_id == item.NearCircleId)
                                     .Select(l =>
                    {
                        NearCircleLikeInfo model = new NearCircleLikeInfo()
                        {
                            LikeId       = l.id,
                            LikeUserId   = l.like_user_id,
                            NearCircleId = l.near_circle_id,
                            LikeTime     = l.like_time.ToString("yyyy-MM-dd HH:mm:ss"),
                        };
                        if (userList != null && userList.Count > 0)
                        {
                            var likeUser = userList.Where(u => u.id == l.like_user_id).FirstOrDefault();
                            if (likeUser != null)
                            {
                                string friendRemark = friendList != null ? friendList.Where(f => f.friend_user_id == l.like_user_id).Select(f => f.friend_user_remark).FirstOrDefault() : null;
                                model.LikeUserName  = UserUtility.GetShowName(friendRemark, likeUser.name);
                                model.LikeUserImage = likeUser.head_image;
                            }
                        }
                        return(model);
                    }).ToList();
                }

                if (commentList != null && commentList.Count > 0)
                {
                    item.CommentInfos = commentList.Where(c => c.near_circle_id == item.NearCircleId)
                                        .Select(c =>
                    {
                        NearCircleCommentInfo model = new NearCircleCommentInfo()
                        {
                            CommentId        = c.id,
                            Content          = c.content_info,
                            NearCircleId     = c.near_circle_id,
                            CommentTime      = c.comment_time.ToString("yyyy-MM-dd HH:mm:ss"),
                            CommentUserId    = c.comment_user_id,
                            CommentUserImage = null,
                            CommentUserName  = null,
                            ReplyUserId      = c.reply_user_id,
                            ReplyUserName    = null,
                            ReplyUserImage   = null,
                        };
                        if (userList != null && userList.Count > 0)
                        {
                            if (c.comment_user_id > 0)
                            {
                                var comUser = userList.Where(u => u.id == c.comment_user_id).FirstOrDefault();
                                if (comUser != null)
                                {
                                    string friendRemark    = friendList != null ? friendList.Where(f => f.friend_user_id == c.comment_user_id).Select(f => f.friend_user_remark).FirstOrDefault() : null;
                                    model.CommentUserName  = UserUtility.GetShowName(friendRemark, comUser.name);
                                    model.CommentUserImage = comUser.head_image;
                                }
                            }

                            if (c.reply_user_id > 0)
                            {
                                var repUser = userList.Where(u => u.id == c.reply_user_id).FirstOrDefault();
                                if (repUser != null)
                                {
                                    string friendRemark  = friendList != null ? friendList.Where(f => f.friend_user_id == c.reply_user_id).Select(f => f.friend_user_remark).FirstOrDefault() : null;
                                    model.ReplyUserName  = UserUtility.GetShowName(friendRemark, repUser.name);
                                    model.ReplyUserImage = repUser.head_image;
                                }
                            }
                        }
                        return(model);
                    }).ToList();
                }

                //item.LikeInfos = NearUtility.GetNearLikes(item.NearCircleId);
                //item.CommentInfos = NearUtility.GetNearComments(item.NearCircleId, 20);
            }
        }