Example #1
0
        private void Startup1()
        {
            mClount++;
            NotificationContainer MyNotificationContainer = new NotificationContainer();

            StartupNotification MyStartupNotification = new StartupNotification();

            MyStartupNotification.serverTask_ID   = 0;
            MyStartupNotification.customer_ID     = CounterID;// "C11200987654321";
            MyStartupNotification.ip_address      = "168.223.110.101";
            MyStartupNotification.notification_ID = mClount;
            MyStartupNotification.mac_address     = "AB-09-23-ED-F0-88";

            MyStartupNotification.timestamp = DateTime.Now;
            MyNotificationContainer.Item    = MyStartupNotification;
            AnswerContainer MyAnswerContainer;

            LGJCloudAPIHelper MyLGJCloudAPIHelper = new LGJCloudAPIHelper();

            MyAnswerContainer = MyLGJCloudAPIHelper.Notification(MyNotificationContainer);

            if (MyAnswerContainer.Items != null)
            {
                ServerTaskID = MyAnswerContainer.Items[0].serverTask_ID;
            }


            OutPutXMLInfor(MyAnswerContainer.Items);

            OutMessage(null, 2);
        }
Example #2
0
        private void Preprocessing(NotificationContainer notification, Task[] Mytasks)
        {
            LGJSynchTcpClient MyLGJSynchTcpClient = new LGJSynchTcpClient(null, null, null, "8000");
            //Type MyType = notification.Item.GetType();
            //MyLGJSynchTcpClient.SendMessage("xxxx#"+MyType..FullName+"  Tasks:"+ Mytasks.Length.ToString());
            string MessageTypeStr = notification.Item.ToString();

            MessageTypeStr = MessageTypeStr.Substring(MessageTypeStr.IndexOf(".") + 1);
            MyLGJSynchTcpClient.SendMessage("Types#" + MessageTypeStr + "  Tasks:" + Mytasks.Length.ToString());

            string NotificationStr = null;

            if (notification.Item is CountNotification)
            {
                CountNotification MyCountNotifi = notification.Item as CountNotification;
                NotificationStr = "count#" + MyCountNotifi.customer_ID + ",IN:" + MyCountNotifi.count_in.ToString() + ";OUT:" + MyCountNotifi.count_out.ToString() + ",TaskID:" + MyCountNotifi.serverTask_ID.ToString() + ",GateID:" + MyCountNotifi.counting_gate_id.id;

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                CountingHelper      MyCountingHelper     = new CountingHelper(MyCountNotifi.customer_ID, MyCountNotifi.serverTask_ID, (int)MyCountNotifi.count_in, (int)MyCountNotifi.count_out);
                //CountingMannager MyCountingMannager = new CountingMannager("ABC987654321", 1000, 1, 1);
                CountingHelper.DoUpdateWork(MyHellaAPCECOManager, MyCountingHelper);
            }

            if (notification.Item is StartupNotification)
            {
                StartupNotification MyStartNotifi = notification.Item as StartupNotification;
                NotificationStr = "start#" + MyStartNotifi.customer_ID + ",TaskID:" + MyStartNotifi.serverTask_ID.ToString() + "," + MyStartNotifi.ip_address + "," + MyStartNotifi.mac_address;
            }

            if (notification.Item is AliveNotification)
            {
                AliveNotification MyAliveNotifi = notification.Item as AliveNotification;
                NotificationStr = "keepalive#" + MyAliveNotifi.customer_ID + ",TaskID:" + MyAliveNotifi.serverTask_ID.ToString() + "," + MyAliveNotifi.ip_address + "," + MyAliveNotifi.mac_address;
            }

            if (NotificationStr != null)
            {
                MyLGJSynchTcpClient.SendMessage(NotificationStr);

                //SoapMessageLogExtension MySoapMessageLogExtension = new SoapMessageLogExtension();
                //MySoapMessageLogExtension.LGJLogTextMessage(NotificationStr, notification.Item.GetType());
            }
        }
Example #3
0
        private Task[] CreateCounterTaskList2(NotificationBase notification)
        {
            List <Task> tasks = new List <Task>();

            if (notification is StartupNotification)
            {
                //2.--关于计数任务------------------------------------------------------------
                StartupNotification MyStartNotifi        = notification as StartupNotification;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "startup");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);

                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;
                tasks.Add(MyTaskCount);

                //2.--关于心跳任务------------------------------------------------------------
                TaskSubscribeAlive MyTaskAlive = new TaskSubscribeAlive();
                MyTaskAlive.task_type           = TaskType.TASK_ALIVE;
                MyTaskAlive.serverTask_ID       = 100;// GetTaskID;
                MyTaskAlive.activity_state      = true;
                MyTaskAlive.store_taskSpecified = true;
                MyTaskAlive.store_task          = true;

                Date MyDate = new Date();
                MyDate.kind = DateType.DATE_DONT_CARE;
                MyDate.day_of_monthSpecified = false;
                MyDate.day_of_weekSpecified  = false;

                ClockTime MyStartTime = new ClockTime();
                MyStartTime.hours   = 0;
                MyStartTime.minutes = 0;
                MyStartTime.seconds = 20;

                TimeTrigger MyTimeTrigger = new TimeTrigger();
                MyTimeTrigger.date          = MyDate;
                MyTimeTrigger.cycle         = "PT10M";
                MyTimeTrigger.random_offset = "PT0S";
                MyTimeTrigger.start         = MyStartTime;

                Trigger MyTrigger2 = new Trigger();
                MyTrigger2.Item     = MyTimeTrigger;
                MyTaskAlive.trigger = MyTrigger2;

                tasks.Add(MyTaskAlive);

                //-----------------------------------------------------------------------------
            }

            if (notification is AliveNotification)
            {
                StartupNotification MyStartNotifi = notification as StartupNotification;

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "keepalive");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);


                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;

                tasks.Add(MyTaskCount);
            }

            return(tasks.ToArray());
        }
Example #4
0
        private Task[] PreprocessingEx(NotificationContainer notification)
        {
            LGJSynchTcpClient MyLGJSynchTcpClient = new LGJSynchTcpClient(null, null, null, "8000");
            string            MessageTypeStr      = notification.Item.ToString();

            MessageTypeStr = MessageTypeStr.Substring(MessageTypeStr.IndexOf(".") + 1);
            MyLGJSynchTcpClient.SendMessage("APC-Types#" + MessageTypeStr);

            string NotificationStr = null;

            uint GetTaskID = 0;
            uint OldTaskID = 0;

            if (notification.Item is CountNotification)
            {
                CountNotification MyCountNotifi = notification.Item as CountNotification;
                NotificationStr = "APC-count#" + MyCountNotifi.customer_ID + ",IN:" + MyCountNotifi.count_in.ToString() + ";OUT:" + MyCountNotifi.count_out.ToString() + ",TaskID:" + MyCountNotifi.serverTask_ID.ToString() + ",GateID:" + MyCountNotifi.counting_gate_id.id;
                MyLGJSynchTcpClient.SendMessage(NotificationStr);

                OldTaskID = MyCountNotifi.serverTask_ID;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                CountingHelper      MyCountingHelper     = new CountingHelper(MyCountNotifi.customer_ID, MyCountNotifi.serverTask_ID, (int)MyCountNotifi.count_in, (int)MyCountNotifi.count_out);
                GetTaskID = (uint)CountingHelper.DoUpdateWork(MyHellaAPCECOManager, MyCountingHelper);

                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList4(OldTaskID, GetTaskID));
                }
                else
                {
                    return(null);
                }
            }

            if (notification.Item is StartupNotification)
            {
                StartupNotification MyStartNotifi = notification.Item as StartupNotification;
                NotificationStr = "APC-start#" + MyStartNotifi.customer_ID + ",TaskID:" + MyStartNotifi.serverTask_ID.ToString() + "," + MyStartNotifi.ip_address + "," + MyStartNotifi.mac_address;
                MyLGJSynchTcpClient.SendMessage(NotificationStr);

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "startup");
                GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);
                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList3(GetTaskID));
                }
                else
                {
                    return(null);
                }
            }

            if (notification.Item is AliveNotification)
            {
                AliveNotification MyAliveNotifi = notification.Item as AliveNotification;
                NotificationStr = "APC-keepalive#" + MyAliveNotifi.customer_ID + ",TaskID:" + MyAliveNotifi.serverTask_ID.ToString() + "," + MyAliveNotifi.ip_address + "," + MyAliveNotifi.mac_address;
                MyLGJSynchTcpClient.SendMessage(NotificationStr);


                OldTaskID = MyAliveNotifi.serverTask_ID;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyAliveNotifi.customer_ID, "keepalive");
                GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);

                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList4(OldTaskID, GetTaskID));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }


            /*
             * if (NotificationStr != null)
             * {
             *  MyLGJSynchTcpClient.SendMessage(NotificationStr);
             *
             *  //SoapMessageLogExtension MySoapMessageLogExtension = new SoapMessageLogExtension();
             *  //MySoapMessageLogExtension.LGJLogTextMessage(NotificationStr, notification.Item.GetType());
             *
             * }
             */
            //------最后返回数据库-------------------------------------------------------------

            /*
             * if (GetTaskID > 0)
             *  return CreateCounterTaskList3(GetTaskID);
             * else
             *  return null;
             */
        }
Example #5
0
        private Task[] Preprocessing(NotificationBase notification)
        {
            string MessageTypeStr = notification.ToString();

            MessageTypeStr = MessageTypeStr.Substring(MessageTypeStr.LastIndexOf(".") + 1);
            OutPut(MessageTypeStr);
            string NotificationStr = null;

            uint GetTaskID = 0;
            uint OldTaskID = 0;

            if (notification is CountNotification)
            {
                CountNotification MyCountNotifi = notification as CountNotification;
                NotificationStr = "count#" + MyCountNotifi.customer_ID + ",IN:" + string.Format("{0:D3}", MyCountNotifi.count_in) + ";OUT:" + string.Format("{0:D3}", MyCountNotifi.count_out) + ",TaskID:" + string.Format("{0:D8}", MyCountNotifi.serverTask_ID) + ",NotificationID:" + MyCountNotifi.notification_ID.ToString() + ",Date:" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", MyCountNotifi.timestamp);
                OutPut(NotificationStr);

                OldTaskID = MyCountNotifi.serverTask_ID;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                CountingHelper      MyCountingHelper     = new CountingHelper(MyCountNotifi.customer_ID, MyCountNotifi.serverTask_ID, (int)MyCountNotifi.count_in, (int)MyCountNotifi.count_out);
                GetTaskID = (uint)CountingHelper.DoUpdateWork(MyHellaAPCECOManager, MyCountingHelper);

                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList4(OldTaskID, GetTaskID));
                }
                else
                {
                    return(null);
                }
            }

            if (notification is StartupNotification)
            {
                StartupNotification MyStartNotifi = notification as StartupNotification;
                NotificationStr = "start#" + MyStartNotifi.customer_ID + ",TaskID:" + MyStartNotifi.serverTask_ID.ToString() + ",NotificationID:" + MyStartNotifi.notification_ID.ToString() + ",IP:" + MyStartNotifi.ip_address + ",MAC:" + MyStartNotifi.mac_address + ",[Date:" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", MyStartNotifi.timestamp) + ":" + string.Format("{0:D3}]", MyStartNotifi.timestamp.Millisecond);
                OutPut(NotificationStr);

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "startup");
                GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);
                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList3(GetTaskID));
                }
                else
                {
                    return(null);
                }
            }

            if (notification is AliveNotification)
            {
                AliveNotification MyAliveNotifi = notification as AliveNotification;
                NotificationStr = "keepalive#" + MyAliveNotifi.customer_ID + ",TaskID:" + MyAliveNotifi.serverTask_ID.ToString() + ",NotificationID:" + MyAliveNotifi.notification_ID.ToString() + "," + MyAliveNotifi.ip_address + "," + MyAliveNotifi.mac_address + ",Date:" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", MyAliveNotifi.timestamp);
                OutPut(NotificationStr);


                OldTaskID = MyAliveNotifi.serverTask_ID;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyAliveNotifi.customer_ID, "keepalive");
                GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);

                if (GetTaskID > 0)
                {
                    return(CreateCounterTaskList4(OldTaskID, GetTaskID));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }