Example #1
0
        /// <summary>管理员请求创建一个新公告的处理
        /// </summary>
        /// <returns>创建新公告的结果</returns>
        public ActionResult Create(BulletinItem bulletin)
        {
            string   content      = Request["content"];
            DateTime publish_time = DateTime.Now;
            DateTime end_time     = DateTime.Now;

            if (!DateTime.TryParse(Request["publishtime"], out publish_time))
            {
                return(Content("error"));
            }

            if (!DateTime.TryParse(Request["endtime"], out end_time))
            {
                return(Content("error"));
            }

            if (BulletinManager.CreateNewBulletin(bulletin))
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("error"));
            }
        }
Example #2
0
 public virtual void SetItem(BulletinItem item)
 {
     Item = item;
     if (item == null)
     {
         Visible = false;
     }
     else
     {
         Visible            = true;
         TitleLabel.Caption = item.Subject;
         Body.Caption       = item.Body;
         if (item.SenderID == 0)
         {
             PersonButton.Visible = false;
         }
         else
         {
             PersonButton.Visible  = true;
             PersonButton.AvatarId = item.SenderID;
         }
         if (item.Time == 0)
         {
             DateLabel.Caption = GameFacade.Strings.GetString("f120", "38");
         }
         else
         {
             DateLabel.Caption = ClientEpoch.ToDate((uint)item.Time).ToLocalTime().ToShortDateString();
         }
         PromotedStar.Visible = (item.Flags & BulletinFlags.PromotedByMayor) > 0;
     }
 }
Example #3
0
 public override void SetItem(BulletinItem item)
 {
     base.SetItem(item);
     if (item == null)
     {
         Visible = false;
     }
     else
     {
         if (item.LotID != 0)
         {
             Body.MaxLines         = 5;
             DateLabel.Alignment   = Framework.TextAlignment.Top | Framework.TextAlignment.Right;
             DateLabel.Position    = new Vector2(32 + 168, 165);
             PersonButton.Position = new Vector2(186, 142);
             LotThumb.LotId        = item.LotID;
             LotThumb.Visible      = true;
         }
         else
         {
             Body.MaxLines         = 9;
             DateLabel.Alignment   = Framework.TextAlignment.Top | Framework.TextAlignment.Left;
             DateLabel.Position    = new Vector2(32, 165);
             PersonButton.Position = new Vector2(186, 157);
             LotThumb.Visible      = false;
         }
     }
 }
Example #4
0
 /// <summary>
 /// Publish a new bulletin
 /// </summary>
 /// <param name="bulletin">The bulletin information</param>
 /// <returns></returns>
 public static bool CreateNewBulletin(BulletinItem bulletin)
 {
     using (SolemartDBContext context = new SolemartDBContext())
     {
         bulletin.PublishTime = DateTime.Now;
         context.BulletinItems.Add(bulletin);
         return(context.SaveChanges() > 0);
     }
 }
        private void Regulator_OnTransition(string state, object data)
        {
            var progress = 0;

            GameThread.InUpdate(() =>
            {
                switch (state)
                {
                case "Idle":
                    if (Callbacks.Count > 0)
                    {
                        ResolveCallbacks(BulletinResponseType.CANCEL);
                    }
                    if (BlockingDialog != null)
                    {
                        UIScreen.RemoveDialog(BlockingDialog);
                        BlockingDialog = null;
                    }
                    break;

                case "ActionInput":
                    //show blocking dialog for this action
                    //not used for bulletin right now
                    var req = ConnectionReg.CurrentRequest;
                    switch (req.Type)
                    {
                    case BulletinRequestType.CAN_POST_MESSAGE:
                    case BulletinRequestType.CAN_POST_SYSTEM_MESSAGE:
                        break;

                    default:
                        //something went terribly wrong - we don't have any dialog to handle this.
                        ConnectionReg.AsyncReset();
                        break;
                    }
                    break;

                case "ActionSuccess":
                    var packet = (BulletinResponse)data;
                    if (packet.Type == BulletinResponseType.SEND_SUCCESS)
                    {
                        CreatedMessage = packet.Messages[0];
                    }
                    else if (packet.Type == BulletinResponseType.MESSAGES)
                    {
                        BulletinBoard = packet.Messages;
                    }
                    ResolveCallbacks(BulletinResponseType.SUCCESS);
                    break;
                }
            });
        }
Example #6
0
        private void InitTestData()
        {
            var test1 = new BulletinItem()
            {
                Subject = "Test Post 1", Body = "you never seen it cooommiiiiiiiinnnnnnnggggggggg g g g g g gggg g g g  g g ggggg", Type = BulletinType.Mayor, Flags = BulletinFlags.PromotedByMayor
            };
            var test2 = new BulletinItem()
            {
                Subject = "Important Mayor Post", Body = "christmas is cancelled", Type = BulletinType.Mayor
            };
            var test3 = new BulletinItem()
            {
                Subject = "Lorem Hippopotamus", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu fringilla ipsum. Sed in odio at dui viverra posuere. Donec hendrerit mollis risus, eu molestie ante gravida ut. Aenean ut molestie leo. Aliquam id elit urna. Suspendisse accumsan ut orci et venenatis. Aliquam dictum leo lorem, nec volutpat sem finibus non. Aenean nec elit eu erat dictum fermentum ut id sem. Donec mollis, tellus nec sagittis bibendum, magna risus cursus augue, id lacinia sapien tortor at enim. Duis maximus massa risus, commodo venenatis lorem dictum in. Aenean sed condimentum justo. Quisque dictum mi eget libero auctor semper. Sed dapibus efficitur neque, a pellentesque ligula aliquet eu.", Type = BulletinType.Mayor
            };

            var test4 = new BulletinItem()
            {
                Subject = "Test Post 2", Body = "you are all banned", Type = BulletinType.System
            };
            var test5 = new BulletinItem()
            {
                Subject = "Important System Post", Body = "christmas is cancelled again", Type = BulletinType.System
            };
            var test6 = new BulletinItem()
            {
                Subject = "Lorem Sassafrass", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu fringilla ipsum. Sed in odio at dui viverra posuere. Donec hendrerit mollis risus, eu molestie ante gravida ut. Aenean ut molestie leo. Aliquam id elit urna. Suspendisse accumsan ut orci et venenatis. Aliquam dictum leo lorem, nec volutpat sem finibus non. Aenean nec elit eu erat dictum fermentum ut id sem. Donec mollis, tellus nec sagittis bibendum, magna risus cursus augue, id lacinia sapien tortor at enim. Duis maximus massa risus, commodo venenatis lorem dictum in. Aenean sed condimentum justo. Quisque dictum mi eget libero auctor semper. Sed dapibus efficitur neque, a pellentesque ligula aliquet eu.", Type = BulletinType.System
            };

            var test7 = new BulletinItem()
            {
                Subject = "Test Post 3", Body = "Hi there! We are reaching out to lot owners who are currently not located (to our knowledge) within neighbourhoods that are planning to be super active come the neighbourhood update. If you don’t know what this update is then you should check out freeso.org for info on mayors and more. Hi there! We are reaching out to lot owners who are currently not located (to our knowledge) within neighbourhoods that are planning to be super active come the neighbourhood update. If you don’t know what this update is then you should check out freeso.org for info on mayors and more. Hi there! We are reaching out to lot owners who are currently not located (to our knowledge) within neighbourhoods that are planning to be super active come the neighbourhood update. If you don’t know what this update is then you should check out freeso.org for info on mayors and more. \n\nYours truly,\nCaleb “steal yo residents” Carrazella",
                Type    = BulletinType.Community,
                Time    = ClientEpoch.Now,
            };
            var test8 = new BulletinItem()
            {
                Subject = "Important Community Post", Body = "i'm pretty bummed out that christmas has been cancelled.", Type = BulletinType.Community
            };
            var test9 = new BulletinItem()
            {
                Subject = "Lorem Community", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu fringilla ipsum. Sed in odio at dui viverra posuere. Donec hendrerit mollis risus, eu molestie ante gravida ut. Aenean ut molestie leo. Aliquam id elit urna. Suspendisse accumsan ut orci et venenatis. Aliquam dictum leo lorem, nec volutpat sem finibus non. Aenean nec elit eu erat dictum fermentum ut id sem. Donec mollis, tellus nec sagittis bibendum, magna risus cursus augue, id lacinia sapien tortor at enim. Duis maximus massa risus, commodo venenatis lorem dictum in. Aenean sed condimentum justo. Quisque dictum mi eget libero auctor semper. Sed dapibus efficitur neque, a pellentesque ligula aliquet eu.", Type = BulletinType.Community
            };


            InitBulletinItems(new BulletinItem[]
            {
                test1, test2, test3, test1, test2, test3, test1, test2, test3,
                test4, test5, test6, test4, test5, test6, test4,
                test7, test8, test9, test7, test8, test9, test7, test8, test9, test7, test8, test9, test7, test8, test9, test7, test8, test9, test7, test8, test9
            });
        }
Example #7
0
        public void SelectedPost(BulletinItem item)
        {
            ShowingSpecific        = true;
            Board.AcceptSelections = false;
            Board.Fade(0f);
            Post.AcceptSelections = true;
            Post.SetPost(item);
            Post.Fade(1f);

            OnModeChange?.Invoke((item == null) ? 2 : 1);

            GameFacade.Screens.Tween.To(this, 0.66f, new Dictionary <string, float>()
            {
                { "THeight", 550 }
            }, TweenQuad.EaseOut);
        }
        public override void Deserialize(IoBuffer input, ISerializationContext context)
        {
            Type = input.GetEnum <BulletinResponseType>();
            var numMessages = input.GetInt32();

            Messages = new BulletinItem[numMessages];
            for (int j = 0; j < numMessages; j++)
            {
                var length = input.GetInt32();
                var dat    = new byte[length];
                for (int i = 0; i < length; i++)
                {
                    dat[i] = input.Get();
                }

                using (var str = new MemoryStream(dat))
                {
                    Messages[j] = new BulletinItem(str);
                }
            }
            Message    = input.GetPascalVLCString();
            BanEndDate = input.GetUInt32();
        }
        public void SetPost(BulletinItem item)
        {
            ActiveItem = item;
            if (item == null)
            {
                EditorMode             = true;
                TitleEdit.CurrentText  = "";
                TitleEdit.Mode         = UITextEditMode.Editor;
                BodyText.BBCodeEnabled = false;
                BodyText.CurrentText   = "";
                BodyText.Mode          = UITextEditMode.Editor;
                TimeLabel.Caption      = "0/1000";
                TypeLabel.Caption      = "";
                RightButton.Caption    = GameFacade.Strings.GetString("f120", "12");
                RightButton.Visible    = true;

                LotThumbButton.Visible     = true;
                LotThumbButton.LotId       = 0;
                PropertyButtonName.Visible = true;
                PropertyButtonName.Caption = GameFacade.Strings.GetString("f120", "28");
                LotThumbButton.LotTooltip  = GameFacade.Strings.GetString("f120", "29");
                PropertyButtonBG.Visible   = true;

                PersonButton.Visible     = true;
                PersonButton.AvatarId    = FindController <CoreGameScreenController>()?.MyID() ?? 0;
                PersonButtonName.Visible = true;
                PersonButtonBG.Visible   = true;

                MiddleButton.Visible = false;
            }
            else
            {
                EditorMode             = false;
                TitleEdit.CurrentText  = item.Subject;
                TitleEdit.Mode         = UITextEditMode.ReadOnly;
                BodyText.BBCodeEnabled = true;
                BodyText.CurrentText   = GameFacade.Emojis.EmojiToBB(BBCodeParser.SanitizeBB(item.Body));
                BodyText.Mode          = UITextEditMode.ReadOnly;
                var time = ClientEpoch.ToDate((uint)item.Time).ToLocalTime();
                TimeLabel.Caption = time.ToShortTimeString() + " " + time.ToShortDateString();

                switch (item.Type)
                {
                case BulletinType.Community:
                    TypeLabel.Caption = GameFacade.Strings.GetString("f120", "24");
                    break;

                case BulletinType.System:
                    TypeLabel.Caption = GameFacade.Strings.GetString("f120", "25");
                    break;

                case BulletinType.Mayor:
                    if ((item.Flags & BulletinFlags.PromotedByMayor) > 0)
                    {
                        TypeLabel.Caption = GameFacade.Strings.GetString("f120", "27");
                    }
                    else
                    {
                        TypeLabel.Caption = GameFacade.Strings.GetString("f120", "26");
                    }
                    break;
                }

                var hasLot    = item.LotID != 0;
                var hasPerson = item.SenderID != 0 && item.SenderID != 0xFFFFFFFF;

                PropertyButtonBG.Visible   = hasLot;
                PropertyButtonName.Visible = hasLot;
                LotThumbButton.Visible     = hasLot;

                PersonButton.Visible     = hasPerson;
                PersonButtonBG.Visible   = hasPerson;
                PersonButtonName.Visible = hasPerson;

                LotThumbButton.LotId  = item.LotID;
                PersonButton.AvatarId = item.SenderID;

                var canPromote = IsMayor && item.Type == BulletinType.Community;
                var myPost     = FindController <CoreGameScreenController>()?.IsMe(item.SenderID) ?? false;
                var admin      = GameFacade.EnableMod;

                RightButton.Visible = true;
                if (canPromote)
                {
                    RightButton.Caption = GameFacade.Strings.GetString("f120", "14");
                }
                else
                {
                    if (myPost)
                    {
                        RightButton.Caption = GameFacade.Strings.GetString("f120", "35");
                    }
                    else
                    {
                        RightButton.Visible = false;
                    }
                }

                MiddleButton.Caption = GameFacade.Strings.GetString("f120", "35");
                MiddleButton.Visible = !myPost && GameFacade.EnableMod;
            }
        }