예제 #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Motto.Length != 0)
            {
                hash ^= Motto.GetHashCode();
            }
            if (YearOfBirth != 0)
            {
                hash ^= YearOfBirth.GetHashCode();
            }
            if (CareerStartYear != 0)
            {
                hash ^= CareerStartYear.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #2
0
        private Motto ConvertFromHashEntries(HashEntry[] entries)
        {
            var motto = new Motto();

            foreach (var item in entries)
            {
                switch (item.Name)
                {
                case F_ADDTIME: motto.AddTime = Convert.ToDateTime((string)item.Value); break;

                case F_CONTENT: motto.Content = item.Value; break;

                case F_DOWN: motto.Down = (int)item.Value; break;

                case F_LOVES: motto.Loves = (int)item.Value; break;

                case F_RECRUIT_ID: motto.RecruitID = (int)item.Value; break;

                case F_RECRUIT_TITLE: motto.RecruitTitle = (string)item.Value; break;

                case F_REVIEWS: motto.Reviews = (int)item.Value; break;

                case F_SCORE: motto.Score = (double)item.Value; break;

                case F_UID: motto.UID = (string)item.Value; break;

                case F_UP: motto.Up = (int)item.Value; break;

                default: break;
                }
            }

            return(motto);
        }
예제 #3
0
        public Motto FindMotto(int theDay, long mid)
        {
            var entries = _redisHelper.HashGetAll(string.Format(KEY_EVAL_MOTTO_FMT, theDay, mid));

            if (entries != null && entries.Length > 0)
            {
                Motto motto = ConvertFromHashEntries(entries);
                motto.ID = mid;
                return(motto);
            }

            return(null);
        }
        public ActionResult EditSave(Motto motto)
        {
            //should operate by method
            var mottoDb = _unitOfWork.Motto.GetMotto(motto.Id);

            mottoDb.Teller = motto.Teller;
            mottoDb.Text   = motto.Text;
            mottoDb.Title  = motto.Title;

            _unitOfWork.Complete();

            return(RedirectToAction("Index"));
        }
예제 #5
0
        protected async override Task <HandleResult> HandleCoreAsync(AddMottoRequest reqObj)
        {
            if (reqObj.Content.Length > 500)
            {
                return(new HandleResult
                {
                    State = HandleStates.InvalidData,
                    Msg = "作品内容不能超过500个字符"
                });
            }

            if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Content))
            {
                return(new HandleResult
                {
                    State = HandleStates.InvalidData,
                    Msg = "作品中包含敏感词语,请修正"
                });
            }

            var motto = new Motto
            {
                AddTime      = DateTime.Now,
                Content      = reqObj.Content,
                RecruitID    = 0,
                RecruitTitle = "",
                UID          = reqObj.UserId
            };

            var rowAffected = await _mottoRepo.AddMottoAsync(motto);

            if (rowAffected > 0)
            {
                _eventPublisher.Publish <CreateMottoEvent>(new CreateMottoEvent
                {
                    Motto = motto
                });

                return(new AddMottoResult
                {
                    State = HandleStates.Success,
                    Msg = "添加作品成功"
                });
            }

            return(new AddMottoResult
            {
                State = HandleStates.UnkownError,
                Msg = "发生错误,请稍后重试。"
            });
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Motto motto = _unitOfWork.Motto.GetMotto(id);

            if (motto == null)
            {
                return(HttpNotFound());
            }
            return(View(motto));
        }
        public ActionResult Create(Motto motto)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", motto));
            }

            if (motto != null)
            {
                _unitOfWork.Motto.Add(motto);
                _unitOfWork.Complete();
            }

            return(RedirectToAction("Index"));
        }
예제 #8
0
        private static HashEntry[] ConvertToHashEntries(Motto motto)
        {
            HashEntry[] entries = new HashEntry[10];

            entries[0] = new HashEntry(F_ADDTIME, motto.AddTime.ToString());
            entries[1] = new HashEntry(F_CONTENT, motto.Content.ToString());
            entries[2] = new HashEntry(F_DOWN, motto.Down.ToString());
            entries[3] = new HashEntry(F_LOVES, motto.Loves.ToString());
            entries[4] = new HashEntry(F_RECRUIT_ID, motto.RecruitID.ToString());
            entries[5] = new HashEntry(F_RECRUIT_TITLE, motto.RecruitTitle.ToString());
            entries[6] = new HashEntry(F_REVIEWS, motto.Reviews.ToString());
            entries[7] = new HashEntry(F_SCORE, motto.Score.ToString());
            entries[8] = new HashEntry(F_UID, motto.UID.ToString());
            entries[9] = new HashEntry(F_UP, motto.Up.ToString());

            return(entries);
        }
예제 #9
0
        private Motto GetMottoFromReader(SqlDataReader reader)
        {
            var motto = new Motto();

            motto.ID           = reader.GetInt64(0);
            motto.Score        = reader.GetDouble(1);
            motto.UID          = reader.GetString(2);
            motto.Up           = reader.GetInt32(3);
            motto.Down         = reader.GetInt32(4);
            motto.Reviews      = reader.GetInt32(5);
            motto.Loves        = reader.GetInt32(6);
            motto.RecruitID    = reader.GetInt32(7);
            motto.RecruitTitle = reader.GetString(8);
            motto.Content      = reader.GetString(9);
            motto.AddTime      = reader.GetDateTime(10);

            return(motto);
        }
예제 #10
0
        public MainPage()
        {
            this.InitializeComponent();

            using (var client = new HttpClient())
            {
                try
                {
                    client.BaseAddress = new Uri(Utility.HOST);
                    var result = client.GetAsync("/motto").Result.Content.ReadAsStringAsync().Result;
                    moto = JsonConvert.DeserializeObject <Motto>(result);
                    mottoTextBlock.Text = moto.motto;
                }
                catch (Exception e)
                {
                    mottoTextBlock.Text = "No Connection. Try again later.";
                    Connection          = false;
                }
            }
        }
예제 #11
0
 public void Update(Motto Motto) => BaseRepository.Update <Motto> (Motto);
예제 #12
0
 public void Delete(Motto Motto) => BaseRepository.Delete <Motto> (Motto);
예제 #13
0
 //Motto
 public void Save(Motto Motto) => BaseRepository.Insert <Motto> (Motto);
예제 #14
0
        public bool Equals(GroupV2 input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     GroupId == input.GroupId ||
                     (GroupId.Equals(input.GroupId))
                     ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ) &&
                 (
                     GroupType == input.GroupType ||
                     (GroupType != null && GroupType.Equals(input.GroupType))
                 ) &&
                 (
                     MembershipIdCreated == input.MembershipIdCreated ||
                     (MembershipIdCreated.Equals(input.MembershipIdCreated))
                 ) &&
                 (
                     CreationDate == input.CreationDate ||
                     (CreationDate != null && CreationDate.Equals(input.CreationDate))
                 ) &&
                 (
                     ModificationDate == input.ModificationDate ||
                     (ModificationDate != null && ModificationDate.Equals(input.ModificationDate))
                 ) &&
                 (
                     About == input.About ||
                     (About != null && About.Equals(input.About))
                 ) &&
                 (
                     Tags == input.Tags ||
                     (Tags != null && Tags.SequenceEqual(input.Tags))
                 ) &&
                 (
                     MemberCount == input.MemberCount ||
                     (MemberCount.Equals(input.MemberCount))
                 ) &&
                 (
                     IsPublic == input.IsPublic ||
                     (IsPublic != null && IsPublic.Equals(input.IsPublic))
                 ) &&
                 (
                     IsPublicTopicAdminOnly == input.IsPublicTopicAdminOnly ||
                     (IsPublicTopicAdminOnly != null && IsPublicTopicAdminOnly.Equals(input.IsPublicTopicAdminOnly))
                 ) &&
                 (
                     Motto == input.Motto ||
                     (Motto != null && Motto.Equals(input.Motto))
                 ) &&
                 (
                     AllowChat == input.AllowChat ||
                     (AllowChat != null && AllowChat.Equals(input.AllowChat))
                 ) &&
                 (
                     IsDefaultPostPublic == input.IsDefaultPostPublic ||
                     (IsDefaultPostPublic != null && IsDefaultPostPublic.Equals(input.IsDefaultPostPublic))
                 ) &&
                 (
                     ChatSecurity == input.ChatSecurity ||
                     (ChatSecurity != null && ChatSecurity.Equals(input.ChatSecurity))
                 ) &&
                 (
                     Locale == input.Locale ||
                     (Locale != null && Locale.Equals(input.Locale))
                 ) &&
                 (
                     AvatarImageIndex == input.AvatarImageIndex ||
                     (AvatarImageIndex.Equals(input.AvatarImageIndex))
                 ) &&
                 (
                     Homepage == input.Homepage ||
                     (Homepage != null && Homepage.Equals(input.Homepage))
                 ) &&
                 (
                     MembershipOption == input.MembershipOption ||
                     (MembershipOption != null && MembershipOption.Equals(input.MembershipOption))
                 ) &&
                 (
                     DefaultPublicity == input.DefaultPublicity ||
                     (DefaultPublicity != null && DefaultPublicity.Equals(input.DefaultPublicity))
                 ) &&
                 (
                     Theme == input.Theme ||
                     (Theme != null && Theme.Equals(input.Theme))
                 ) &&
                 (
                     BannerPath == input.BannerPath ||
                     (BannerPath != null && BannerPath.Equals(input.BannerPath))
                 ) &&
                 (
                     AvatarPath == input.AvatarPath ||
                     (AvatarPath != null && AvatarPath.Equals(input.AvatarPath))
                 ) &&
                 (
                     ConversationId == input.ConversationId ||
                     (ConversationId.Equals(input.ConversationId))
                 ) &&
                 (
                     EnableInvitationMessagingForAdmins == input.EnableInvitationMessagingForAdmins ||
                     (EnableInvitationMessagingForAdmins != null && EnableInvitationMessagingForAdmins.Equals(input.EnableInvitationMessagingForAdmins))
                 ) &&
                 (
                     BanExpireDate == input.BanExpireDate ||
                     (BanExpireDate != null && BanExpireDate.Equals(input.BanExpireDate))
                 ) &&
                 (
                     Features == input.Features ||
                     (Features != null && Features.Equals(input.Features))
                 ) &&
                 (
                     ClanInfo == input.ClanInfo ||
                     (ClanInfo != null && ClanInfo.Equals(input.ClanInfo))
                 ));
        }
예제 #15
0
        public async Task <int> AddMottoAsync(Motto m)
        {
            int rowAffected = 0;

            using (var conn = _connProvider.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    var id = await conn.QueryFirstOrDefaultAsync <long>("insert into Mottos(UID,TheDay, Score, Content,RecruitID,RecruitTitle,AddTime) " +
                                                                        "values(@UID,@TheDay,@Score,@Content,@RID,@RTitle,@AddTime); select @@IDENTITY;", new {
                        UID     = m.UID,
                        TheDay  = Utils.GetTheDay(m.AddTime),
                        Score   = 0f,
                        Content = m.Content,
                        RID     = m.RecruitID,
                        RTitle  = m.RecruitTitle,
                        AddTime = m.AddTime
                    }, tran);


                    if (id != 0)
                    {
                        m.ID = id;

                        rowAffected = 1;
                        //var theday = m.AddTime.Year * 10000 + m.AddTime.Month * 100 + m.AddTime.Day;
                        //await conn.ExecuteAsync("update T_DayStatistics set Mottos=Mottos+1 where ID=@theday",
                        //    new
                        //    {
                        //        TheDay = theday
                        //    }, tran);

                        await conn.ExecuteAsync("update UserStatistics set Mottos = Mottos+1 where UID=@uid",
                                                new
                        {
                            UID = m.UID
                        },
                                                tran);

                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }
                catch
                {
                    try
                    {
                        tran.Rollback();
                    }
                    catch {
                    };

                    throw;
                }
            }

            return(rowAffected);
        }
 public void Add(Motto motto)
 {
     _context.Mottoes.Add(motto);
 }
예제 #17
0
        public bool Equals(GroupEditAction input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                     ) &&
                 (
                     About == input.About ||
                     (About != null && About.Equals(input.About))
                 ) &&
                 (
                     Motto == input.Motto ||
                     (Motto != null && Motto.Equals(input.Motto))
                 ) &&
                 (
                     Theme == input.Theme ||
                     (Theme != null && Theme.Equals(input.Theme))
                 ) &&
                 (
                     AvatarImageIndex == input.AvatarImageIndex ||
                     (AvatarImageIndex.Equals(input.AvatarImageIndex))
                 ) &&
                 (
                     Tags == input.Tags ||
                     (Tags != null && Tags.Equals(input.Tags))
                 ) &&
                 (
                     IsPublic == input.IsPublic ||
                     (IsPublic != null && IsPublic.Equals(input.IsPublic))
                 ) &&
                 (
                     MembershipOption == input.MembershipOption ||
                     (MembershipOption.Equals(input.MembershipOption))
                 ) &&
                 (
                     IsPublicTopicAdminOnly == input.IsPublicTopicAdminOnly ||
                     (IsPublicTopicAdminOnly != null && IsPublicTopicAdminOnly.Equals(input.IsPublicTopicAdminOnly))
                 ) &&
                 (
                     AllowChat == input.AllowChat ||
                     (AllowChat != null && AllowChat.Equals(input.AllowChat))
                 ) &&
                 (
                     ChatSecurity == input.ChatSecurity ||
                     (ChatSecurity.Equals(input.ChatSecurity))
                 ) &&
                 (
                     Callsign == input.Callsign ||
                     (Callsign != null && Callsign.Equals(input.Callsign))
                 ) &&
                 (
                     Locale == input.Locale ||
                     (Locale != null && Locale.Equals(input.Locale))
                 ) &&
                 (
                     Homepage == input.Homepage ||
                     (Homepage.Equals(input.Homepage))
                 ) &&
                 (
                     EnableInvitationMessagingForAdmins == input.EnableInvitationMessagingForAdmins ||
                     (EnableInvitationMessagingForAdmins != null && EnableInvitationMessagingForAdmins.Equals(input.EnableInvitationMessagingForAdmins))
                 ) &&
                 (
                     DefaultPublicity == input.DefaultPublicity ||
                     (DefaultPublicity.Equals(input.DefaultPublicity))
                 ));
        }
예제 #18
0
        public bool Equals(GroupV2Card input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     GroupId == input.GroupId ||
                     (GroupId.Equals(input.GroupId))
                     ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ) &&
                 (
                     GroupType == input.GroupType ||
                     (GroupType != null && GroupType.Equals(input.GroupType))
                 ) &&
                 (
                     CreationDate == input.CreationDate ||
                     (CreationDate != null && CreationDate.Equals(input.CreationDate))
                 ) &&
                 (
                     About == input.About ||
                     (About != null && About.Equals(input.About))
                 ) &&
                 (
                     Motto == input.Motto ||
                     (Motto != null && Motto.Equals(input.Motto))
                 ) &&
                 (
                     MemberCount == input.MemberCount ||
                     (MemberCount.Equals(input.MemberCount))
                 ) &&
                 (
                     Locale == input.Locale ||
                     (Locale != null && Locale.Equals(input.Locale))
                 ) &&
                 (
                     MembershipOption == input.MembershipOption ||
                     (MembershipOption != null && MembershipOption.Equals(input.MembershipOption))
                 ) &&
                 (
                     Capabilities == input.Capabilities ||
                     (Capabilities != null && Capabilities.Equals(input.Capabilities))
                 ) &&
                 (
                     ClanInfo == input.ClanInfo ||
                     (ClanInfo != null && ClanInfo.Equals(input.ClanInfo))
                 ) &&
                 (
                     AvatarPath == input.AvatarPath ||
                     (AvatarPath != null && AvatarPath.Equals(input.AvatarPath))
                 ) &&
                 (
                     Theme == input.Theme ||
                     (Theme != null && Theme.Equals(input.Theme))
                 ));
        }