Exemple #1
0
        public static bool EndEvent(string name, string scriptend, string msgend, AdminClientServicePeer peer)
        {
            EventDataContext.StartProcessing();
            Event @event = EventDataContext.GetEvent(name);

            if (@event == null)
            {
                if (peer != null)
                {
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event is Not Registered ! - \"{0}\"", name))));
                }
                return(false);
            }
            if (scriptend != null)
            {
                @event.EndScript = scriptend;
            }
            if (msgend != null)
            {
                @event.EndMessage = msgend;
            }
            EventDataContext.EndEvent(name);
            EventDataContext.RemoveEvent(name);
            if (peer != null)
            {
                string msg = EventDataContext.SendEventListAndDetail(name, "Event is Ended !", false);
                peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg)));
            }
            return(true);
        }
Exemple #2
0
 public static void Watcher()
 {
     if (!EventDataContext.processing)
     {
         if (ServiceCore.FeatureMatrix.IsEnable("FeatureMatrixSyncService"))
         {
             EventDataContext.ProcessEvent();
             EventDataContext.processing = true;
             return;
         }
         if (AdminClientService.IsAllServiceReady())
         {
             EventDataContext.StartProcessing();
             return;
         }
         Scheduler.Schedule(EventDataContext.Thread, Job.Create(new Action(EventDataContext.Watcher)), 10000);
     }
 }
Exemple #3
0
        public static bool RegisterEvent(string name, string template, string feature, string scriptstart, string scriptend, DateTime?startTime, DateTime?endTime, TimeSpan?periodBegin, TimeSpan?periodEnd, string msgstart, string msgnotify, string msgend, int msginterval, int startCont, string username, AdminClientServicePeer peer)
        {
            EventDataContext.StartProcessing();
            EventTemplate eventTemplate = null;
            bool          flag          = false;

            if (EventDataContext.IsRunning(name))
            {
                if (peer != null)
                {
                    string msg = EventDataContext.SendEventListAndDetail(name, "Event is Already Running !", true);
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, msg)));
                }
                return(false);
            }
            if (template != null)
            {
                eventTemplate = AdminContents.GetTemplate(template);
                if (eventTemplate == null)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Cannot Find Event Template ! - \"{0}\"", template))));
                    }
                    return(false);
                }
            }
            Event @event = EventDataContext.GetEvent(name);

            if (@event == null)
            {
                @event      = new Event();
                @event.Name = name;
                flag        = true;
            }
            if (eventTemplate != null)
            {
                @event.Feature     = eventTemplate.Feature;
                @event.StartScript = eventTemplate.StartScript;
                @event.EndScript   = eventTemplate.EndScript;
            }
            if (feature != null)
            {
                @event.Feature = feature;
            }
            if (scriptstart != null)
            {
                @event.StartScript = scriptstart;
            }
            if (scriptend != null)
            {
                @event.EndScript = scriptend;
            }
            if (startTime != null)
            {
                if (startTime < DateTime.Now)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Reservation Time Error - \"{0}\"", startTime))));
                    }
                    return(false);
                }
                @event.StartTime = startTime;
            }
            if (endTime != null)
            {
                if (endTime < DateTime.Now)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Reservation Time Error - \"{0}\"", endTime))));
                    }
                    return(false);
                }
                @event.EndTime = endTime;
            }
            if (periodBegin != null)
            {
                @event.PeriodBegin = periodBegin;
            }
            if (periodEnd != null)
            {
                @event.PeriodEnd = periodEnd;
            }
            if (msgstart != null)
            {
                @event.StartMessage = msgstart;
            }
            if (msgnotify != null)
            {
                @event.NotifyMessage = msgnotify;
            }
            if (msgend != null)
            {
                @event.EndMessage = msgend;
            }
            @event.NotifyInterval = new int?(msginterval);
            @event.StartCount     = new int?(startCont);
            @event.UserName       = username;
            if (flag)
            {
                if (feature != null)
                {
                    string text = EventDataContext.IsExistFeature(feature);
                    if (text != null)
                    {
                        if (peer != null)
                        {
                            peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("That feature is already exist ! - \"{0}\"", text))));
                        }
                        return(false);
                    }
                }
                if (!EventDataContext.AddEvent(@event))
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event Register Failed ! - \"{0}\"", name))));
                    }
                    return(false);
                }
            }
            else if (!EventDataContext.ModifyEvent(@event))
            {
                if (peer != null)
                {
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event Update Failed ! - \"{0}\"", name))));
                }
                return(false);
            }
            if (@event.StartTime == null && !(@event.StartCount > 0))
            {
                EventDataContext.StartEvent(name, @event);
                if (peer != null)
                {
                    string msg2 = EventDataContext.SendEventListAndDetail(name, "Event is Started !", true);
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg2)));
                }
            }
            else if (peer != null)
            {
                string msg3 = EventDataContext.SendEventListAndDetail(name, "Event is Reserved !", true);
                peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg3)));
            }
            return(true);
        }
        private bool ProcessEventCommand(string args, AdminClientServicePeer peer, int targetServiceID)
        {
            if (args == "goal")
            {
                this.ProcessMicroPlayCommand("monster_kill", "", targetServiceID);
                this.ProcessMicroPlayCommand("autofish_item", "capsule_ap100", targetServiceID);
                return(true);
            }
            CmdTokenizer cmdTokenizer = new CmdTokenizer(args);
            string       next         = cmdTokenizer.GetNext();
            string       next2        = cmdTokenizer.GetNext();
            string       template     = null;
            string       msgstart     = null;
            string       msgnotify    = null;
            string       msgend       = null;
            string       feature      = null;
            string       scriptstart  = null;
            string       scriptend    = null;
            int          msginterval  = 1800;
            int          num          = 0;
            string       username     = "******";
            DateTime?    startTime    = null;
            DateTime?    endTime      = null;
            TimeSpan?    periodBegin  = null;
            TimeSpan?    periodEnd    = null;
            string       text;

            while (cmdTokenizer.GetNext(out text))
            {
                if (text == "template")
                {
                    template = cmdTokenizer.GetNext();
                }
                else if (text == "feature")
                {
                    feature = cmdTokenizer.GetNext();
                }
                else if (text == "scriptstart")
                {
                    scriptstart = cmdTokenizer.GetNext();
                }
                else
                {
                    if (!(text == "scriptend"))
                    {
                        if (text == "starttime")
                        {
                            if (num > 0)
                            {
                                Log <AdminClientService> .Logger.Error("starttime은 startcount와 함께 사용될 수 없습니다.");

                                return(false);
                            }
                            try
                            {
                                string next3 = cmdTokenizer.GetNext();
                                if (next3.Length > 0)
                                {
                                    startTime = new DateTime?(DateTime.Parse(next3));
                                }
                                continue;
                            }
                            catch (Exception ex)
                            {
                                Log <AdminClientService> .Logger.Error("starttime 파싱 도중 에러가 발생했습니다", ex);

                                return(false);
                            }
                        }
                        if (text == "endtime")
                        {
                            try
                            {
                                string next4 = cmdTokenizer.GetNext();
                                if (next4.Length > 0)
                                {
                                    endTime = new DateTime?(DateTime.Parse(next4));
                                }
                                continue;
                            }
                            catch (Exception ex2)
                            {
                                Log <AdminClientService> .Logger.Error("endtime 파싱 도중 에러가 발생했습니다", ex2);

                                return(false);
                            }
                        }
                        if (text == "periodbegin")
                        {
                            try
                            {
                                string next5 = cmdTokenizer.GetNext();
                                if (next5.Length > 0)
                                {
                                    periodBegin = new TimeSpan?(TimeSpan.Parse(next5));
                                }
                                continue;
                            }
                            catch (Exception ex3)
                            {
                                Log <AdminClientService> .Logger.Error("periodbegin 파싱 도중 에러가 발생했습니다", ex3);

                                return(false);
                            }
                        }
                        if (text == "periodend")
                        {
                            try
                            {
                                string next6 = cmdTokenizer.GetNext();
                                if (next6.Length > 0)
                                {
                                    periodEnd = new TimeSpan?(TimeSpan.Parse(next6));
                                }
                                continue;
                            }
                            catch (Exception ex4)
                            {
                                Log <AdminClientService> .Logger.Error("periodend 파싱 도중 에러가 발생했습니다", ex4);

                                return(false);
                            }
                        }
                        if (text == "msgstart")
                        {
                            msgstart = cmdTokenizer.GetNext();
                            continue;
                        }
                        if (text == "msgnotify")
                        {
                            msgnotify = cmdTokenizer.GetNext();
                            continue;
                        }
                        if (text == "msgend")
                        {
                            msgend = cmdTokenizer.GetNext();
                            continue;
                        }
                        if (text == "msginterval")
                        {
                            try
                            {
                                string next7 = cmdTokenizer.GetNext();
                                if (next7.Length > 0)
                                {
                                    msginterval = int.Parse(next7);
                                }
                                continue;
                            }
                            catch (Exception ex5)
                            {
                                Log <AdminClientService> .Logger.Error("msginterval 파싱 도중 에러가 발생했습니다", ex5);

                                return(false);
                            }
                        }
                        if (text == "startcount")
                        {
                            if (startTime != null)
                            {
                                Log <AdminClientService> .Logger.Error("startcount는 starttime과 함께 사용될 수 없습니다.");

                                return(false);
                            }
                            try
                            {
                                string next8 = cmdTokenizer.GetNext();
                                if (next8.Length > 0)
                                {
                                    num = int.Parse(next8);
                                }
                                continue;
                            }
                            catch (Exception ex6)
                            {
                                Log <AdminClientService> .Logger.Error("startcount 파싱 도중 에러가 발생했습니다", ex6);

                                return(false);
                            }
                        }
                        if (text == "username")
                        {
                            username = cmdTokenizer.GetNext();
                            continue;
                        }
                        Log <AdminClientService> .Logger.ErrorFormat("알수 없는 옵션입니다. [{0}]", text);

                        return(false);
                    }
                    scriptend = cmdTokenizer.GetNext();
                }
            }
            if (next == "reg")
            {
                if (next2.Length > 0)
                {
                    return(EventDataContext.RegisterEvent(next2, template, feature, scriptstart, scriptend, startTime, endTime, periodBegin, periodEnd, msgstart, msgnotify, msgend, msginterval, num, username, peer));
                }
            }
            else if (next == "end")
            {
                if (next2.Length > 0)
                {
                    return(EventDataContext.EndEvent(next2, scriptend, msgend, peer));
                }
            }
            else
            {
                if (next == "list")
                {
                    return(EventDataContext.ListEvent(peer));
                }
                if (next == "show")
                {
                    if (next2.Length > 0)
                    {
                        return(EventDataContext.ShowEvent(next2, peer));
                    }
                }
                else if (next == "resume")
                {
                    EventDataContext.StartProcessing();
                }
            }
            return(false);
        }