コード例 #1
0
        public static string SendEventListAndDetail(string name, string comment, bool IsDetail = true)
        {
            int           num           = 0;
            StringBuilder stringBuilder = new StringBuilder("");

            stringBuilder.AppendFormat("\r\n========== {0} \"{1}\" ==========", comment, name);
            stringBuilder.Append("\r\n========== Event List ==========\r\n");
            foreach (Event @event in EventDataContext.Instance.Event)
            {
                stringBuilder.AppendFormat("{0} [{1}]\r\n", @event.Name, EventDataContext.IsRunning(@event.Name) ? "Running" : "Pending");
                num++;
            }
            stringBuilder.Append("========== Event List ==========");
            if (IsDetail)
            {
                Event event2 = EventDataContext.GetEvent(name);
                if (event2 != null)
                {
                    stringBuilder.AppendFormat("\r\n========== Event Detail ==========\r\nStatus [{0}]\r\n{1}\r\n========== Event Detail ==========", EventDataContext.IsRunning(name) ? "Running" : "Pending", event2.ToStringX());
                }
            }
            stringBuilder.AppendFormat("\r\n========== {0} \"{1}\" ==========", comment, name);
            if (num >= 15)
            {
                stringBuilder.AppendFormat("\r\n========== Warning! Event is more than 15! [Current Count : {0}] ==========", num);
            }
            return(stringBuilder.ToString());
        }
コード例 #2
0
 private static void SendToStartEvent(string name, Event instance, int targetServiceID)
 {
     if (EventDataContext.IsRunning(name))
     {
         if (instance.StartMessage != null && instance.StartMessage.Length > 0)
         {
             EventDataContext.BroadcastMessage(instance.StartMessage, targetServiceID);
         }
         AdminClientService.Instance.UpdateFeatureMatrix(instance.Feature, true, targetServiceID);
         AdminClientService.Instance.ProcessScript(instance.StartScript, targetServiceID);
         EventDataContext.RearrangeFirstIncomeMessage(targetServiceID);
     }
 }
コード例 #3
0
 public static bool ListEvent(AdminClientServicePeer peer)
 {
     if (peer != null)
     {
         string text = "";
         foreach (Event @event in EventDataContext.Instance.Event)
         {
             text += string.Format("{0} [{1}]\r\n", @event.Name, EventDataContext.IsRunning(@event.Name) ? "Running" : "Pending");
         }
         peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("\r\n========== Event List ==========\r\n{0}========== Event List ==========", text))));
         return(true);
     }
     return(false);
 }
コード例 #4
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);
        }
コード例 #5
0
 public static bool ShowEvent(string name, AdminClientServicePeer peer)
 {
     if (peer != null)
     {
         Event @event = EventDataContext.GetEvent(name);
         if (@event != null)
         {
             peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("\r\n========== Event Detail ==========\r\nStatus [{0}]\r\n{1}\r\n========== Event Detail ==========", EventDataContext.IsRunning(name) ? "Running" : "Pending", @event.ToStringX()))));
             return(true);
         }
     }
     return(false);
 }
コード例 #6
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);
        }