Example #1
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 #2
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;
             */
        }