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 bool RemoveEvent(string name)
        {
            Event @event = EventDataContext.GetEvent(name);

            if (@event != null)
            {
                if (EventDataContext.IsRunning(name))
                {
                    EventDataContext.EndEvent(name);
                }
                return(EventDataContext.RemoveEvent(@event));
            }
            return(false);
        }
Exemple #3
0
 private static void ProcessEvent()
 {
     try
     {
         DateTime     now   = DateTime.Now;
         int          num   = (now.Hour * 60 + now.Minute) * 60;
         int          num2  = 0;
         List <Event> list  = new List <Event>();
         List <Event> list2 = new List <Event>();
         List <Event> list3 = new List <Event>();
         foreach (Event @event in EventDataContext.Instance.Event)
         {
             if (@event.StartTime == null && !(@event.StartCount > 0))
             {
                 if (@event.EndTime == null || now < @event.EndTime)
                 {
                     list.Add(@event);
                 }
                 else
                 {
                     list3.Add(@event);
                 }
             }
             else if (@event.StartTime != null)
             {
                 if (now >= @event.StartTime)
                 {
                     if (@event.EndTime == null || now < @event.EndTime)
                     {
                         if (@event.PeriodBegin == null)
                         {
                             list.Add(@event);
                         }
                         else if (now.TimeOfDay >= @event.PeriodBegin)
                         {
                             if (@event.PeriodEnd == null || now.TimeOfDay < @event.PeriodEnd)
                             {
                                 list.Add(@event);
                             }
                             else
                             {
                                 list2.Add(@event);
                             }
                         }
                         else
                         {
                             list2.Add(@event);
                         }
                     }
                     else
                     {
                         list3.Add(@event);
                     }
                 }
                 else
                 {
                     list2.Add(@event);
                 }
             }
             else if (@event.StartCount > 0)
             {
                 if (@event.StartCount <= EventDataContext.Instance.GetEventCount(@event.Name))
                 {
                     if (@event.EndTime == null || now < @event.EndTime)
                     {
                         if (@event.PeriodBegin == null)
                         {
                             list.Add(@event);
                         }
                         else if (now.TimeOfDay >= @event.PeriodBegin)
                         {
                             if (@event.PeriodEnd == null || now.TimeOfDay < @event.PeriodEnd)
                             {
                                 list.Add(@event);
                             }
                             else
                             {
                                 list2.Add(@event);
                             }
                         }
                         else
                         {
                             list2.Add(@event);
                         }
                     }
                     else
                     {
                         list3.Add(@event);
                     }
                 }
                 else
                 {
                     list2.Add(@event);
                 }
             }
         }
         foreach (Event event2 in list3)
         {
             EventDataContext.RemoveEvent(event2.Name);
         }
         foreach (Event event3 in list2)
         {
             EventDataContext.EndEvent(event3.Name);
         }
         foreach (KeyValuePair <string, Event> keyValuePair in EventDataContext.runnings)
         {
             Event value = keyValuePair.Value;
             if (value.NotifyMessage != null && value.NotifyMessage.Length > 0)
             {
                 int num3 = 1800;
                 if (value.NotifyInterval != null && value.NotifyInterval.Value >= 0)
                 {
                     num3 = value.NotifyInterval.Value;
                 }
                 num3 = num3 / 60 * 60;
                 if (num3 != 0 && num % num3 == 0)
                 {
                     Scheduler.Schedule(EventDataContext.Thread, Job.Create <string, int>(new Action <string, int>(EventDataContext.BroadcastMessage), value.NotifyMessage, -1), ++num2 * 1000);
                 }
             }
         }
         foreach (Event event4 in list)
         {
             EventDataContext.StartEvent(event4.Name, event4);
         }
         EventDataContext.processed = true;
         foreach (KeyValuePair <int, string> keyValuePair2 in EventDataContext.waitingServiceList)
         {
             Scheduler.Schedule(EventDataContext.Thread, Job.Create <int, string>(new Action <int, string>(EventDataContext.SendToFeatureMaxtrixUpdate), keyValuePair2.Key, keyValuePair2.Value), 10000);
         }
         EventDataContext.waitingServiceList.Clear();
     }
     finally
     {
         EventDataContext.ScheduleNextProcess();
     }
 }
        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);
        }