Ejemplo n.º 1
0
    public string Sync(string HCCU_ID, string HCCU_MAC_ID, string EXECORDER_EP_ID_PAKG, string EVENT_ID_Collection, string TRANS_PAKG, string REQLOGS_PAKG, string SK)
    {
        string[,] p = new string[2, 6];
        p[0, 0]     = "HCCU_ID";
        p[1, 0]     = HCCU_ID;
        p[0, 1]     = "HCCU_MAC_ID";
        p[1, 1]     = HCCU_MAC_ID;
        p[0, 2]     = "EXECORDER_EP_ID_PAKG";
        p[1, 2]     = EXECORDER_EP_ID_PAKG;
        p[0, 3]     = "EVENT_ID_Collection";
        p[1, 3]     = EVENT_ID_Collection;
        p[0, 4]     = "TRANS_PAKG";
        p[1, 4]     = TRANS_PAKG;
        p[0, 5]     = "REQLOGS_PAKG";
        p[1, 5]     = REQLOGS_PAKG;

        if (!COS_SECURITY_TOOL.SECURITY_RequestDecrypt(p, SK))
        {
            return(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("-4"));
        }

        /*
         * SYNC_HCCU_EP_INFO
         *
         * */
        #region output:return_sync_hccu_ep_info
        HCCU _HCCU = new HCCU();

        string para = "HCCU_ID=" + HCCU_ID + "&HCCU_MAC=" + HCCU_MAC_ID;
        string sk   = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(para);

        string return_sync_hccu_ep_info = _HCCU.HCCU_EP_Get_Info(HCCU_ID, HCCU_MAC_ID, sk);
        return_sync_hccu_ep_info = "<SYNC_HCCU_EP_INFO>" + return_sync_hccu_ep_info + "</SYNC_HCCU_EP_INFO>";
        #endregion

        /*
         * SYNC_EXECORDER
         *
         * */
        #region output:return_sync_exec_order
        EXEC_ORDER _EXEC_ORDER            = new EXEC_ORDER();
        string     return_sync_exec_order = "";
        if (EXECORDER_EP_ID_PAKG != "")
        {
            string[] EXECORDER_EP_ID_PAKG_ARRAY = EXECORDER_EP_ID_PAKG.Split('|');
            for (int x = 0; x < EXECORDER_EP_ID_PAKG_ARRAY.Length; x++)
            {
                if (EXECORDER_EP_ID_PAKG_ARRAY[x] != "")
                {
                    string[] EXECORDER_EP_ID_PAKG_SINGLE_ARRAY = EXECORDER_EP_ID_PAKG_ARRAY[x].Split(',');
                    return_sync_exec_order += _EXEC_ORDER.EXEC_ORDER_Get(EXECORDER_EP_ID_PAKG_SINGLE_ARRAY[0], EXECORDER_EP_ID_PAKG_SINGLE_ARRAY[1]) + "^";
                }
            }

            return_sync_exec_order = "<SYNC_EXECORDER>" + return_sync_exec_order + "</SYNC_EXECORDER>";
        }
        else
        {
            return_sync_exec_order = "<SYNC_EXECORDER></SYNC_EXECORDER>";
        }

        #endregion


        /*
         * SYNC_EP_EVENTS
         *
         * */
        #region output:return_sync_events
        EVENTS _EVENTS = new EVENTS();

        string para3 = "HCCU_ID=" + HCCU_ID;
        string sk3   = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(para3);

        string return_sync_events = _EVENTS.EVENTS_Sync(HCCU_ID, sk3);
        return_sync_events = "<SYNC_EVENTS>" + return_sync_events + "</SYNC_EVENTS>";
        #endregion

        /*
         * UPLOAD: SYNC_NOTIFYEVENTUPDATE(1,-1,-2,-4)
         *
         *
         * */
        #region output:return_sync_notifyeventupdate
        string para35 = "EVENT_ID_Collection=" + EVENT_ID_Collection;
        string sk35   = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(para35);

        string return_sync_notifyeventupdate = _EVENTS.NotifyEventUpdate(EVENT_ID_Collection, sk35);
        return_sync_notifyeventupdate = "<SYNC_NOTIFYEVENTUPDATE>" + return_sync_notifyeventupdate + "</SYNC_NOTIFYEVENTUPDATE>";
        #endregion

        /*
         * SYNC_PROP
         *
         * */
        #region output:return_sync_prop
        PROP _PROP = new PROP();

        string para4 = "HCCU_ID=" + HCCU_ID;
        string sk4   = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(para4);

        string return_sync_prop = _PROP.EP_PROPERTYFACT_Sync(HCCU_ID, sk4);
        return_sync_prop = "<SYNC_PROP>" + return_sync_prop + "</SYNC_PROP>";
        #endregion

        /*
         * UPLOAD: SYNC_TRANS(1,-1,-2,-4)
         *
         * */
        #region output:return_sync_trans
        string return_sync_trans = "";
        TRANS  _TRANS            = new TRANS();

        if (TRANS_PAKG.Trim() != "")
        {
            string[] TRANS_PAKG_ARRAY = TRANS_PAKG.Split('|');
            for (int x = 0; x < TRANS_PAKG_ARRAY.Length; x++)
            {
                if (TRANS_PAKG_ARRAY[x] != "")
                {
                    string[] TRANS_PAKG_SINGLE_ARRAY = TRANS_PAKG_ARRAY[x].Split(',');
                    return_sync_trans += _TRANS.TRANS_Add(TRANS_PAKG_SINGLE_ARRAY[0], TRANS_PAKG_SINGLE_ARRAY[1], TRANS_PAKG_SINGLE_ARRAY[2], TRANS_PAKG_SINGLE_ARRAY[3], TRANS_PAKG_SINGLE_ARRAY[4]) + ",";
                }
            }
            return_sync_trans = "<SYNC_TRANS>" + return_sync_trans + "</SYNC_TRANS>";
        }
        else
        {
            return_sync_trans = "<SYNC_TRANS></SYNC_TRANS>";
        }
        #endregion


        /*
         * UPLOAD: SYNC_REQLOGS(1,-1,-2,-4)
         *
         * */
        #region output:return_sync_requestlogs
        string      return_sync_requestlogs = "";
        REQUESTLOGS _REQUESTLOGS            = new REQUESTLOGS();

        if (REQLOGS_PAKG.Trim() != "")
        {
            string[] REQLOGS_PAKG_ARRAY = REQLOGS_PAKG.Split('|');
            for (int x = 0; x < REQLOGS_PAKG_ARRAY.Length; x++)
            {
                if (REQLOGS_PAKG_ARRAY[x] != "")
                {
                    string[] REQLOGS_PAKG_SINGLE_ARRAY = REQLOGS_PAKG_ARRAY[x].Split(',');
                    return_sync_requestlogs += _REQUESTLOGS.REQUESTLOGS_Add(REQLOGS_PAKG_SINGLE_ARRAY[0],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[1],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[2],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[3],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[4],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[5],
                                                                            REQLOGS_PAKG_SINGLE_ARRAY[6]) + ",";
                }
            }

            return_sync_requestlogs = "<SYNC_REQLOGS>" + return_sync_requestlogs + "</SYNC_REQLOGS>";
        }
        else
        {
            return_sync_requestlogs = "<SYNC_REQLOGS></SYNC_REQLOGS>";
        }
        #endregion


        return(return_sync_hccu_ep_info + return_sync_exec_order + return_sync_events + return_sync_notifyeventupdate + return_sync_prop + return_sync_trans + return_sync_requestlogs);
    }
Ejemplo n.º 2
0
    public string SendCommand(string commandtype, string commandbody, string SK)
    {
        string[,] p = new string[2, 2];
        p[0, 0]     = "commandtype";
        p[1, 0]     = commandtype;
        p[0, 1]     = "commandbody";
        p[1, 1]     = commandbody;

        if (!COS_SECURITY_TOOL.SECURITY_RequestDecrypt(p, SK))
        {
            return(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("-4"));
        }

        commandtype = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandtype);
        commandbody = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandbody);

        if (commandtype.ToLower().Trim() == "i")
        {
            string[] body = commandbody.Split('|');

            string hccu_id = body[1];
            string mac     = body[2];
            string ip      = body[3];
            string prop    = body[4];

            EP ep = new EP();

            string skraw = "EP_TypeId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1")
                           + "&EP_UserDefined_Alias=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown")
                           + "&EP_ProductId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1")
                           + "&HCCU_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id)
                           + "&EP_MAC_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac)
                           + "&PROPFORMAT=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop)
                           + "&IP=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip);

            string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw);

            return(ep.EP_Add_20140320(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown"),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop),
                                      COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip),
                                      sk));
        }

        else if (commandtype.ToLower().Trim() == "d")
        {
            string[] body = commandbody.Split('|');

            if (body.Length < 5)
            {
                return("");
            }

            string hccu_id  = body[1];
            string mac      = body[2];
            string d_length = body[3];

            if (mac.Length != 16)
            {
                return("");
            }

            COS_WEBSERVICE_EP c    = new COS_WEBSERVICE_EP();
            string            epid = Get_EPID_From_MAC(mac);


            ParseDataCommand(commandbody, epid, d_length, hccu_id);


            string skraw = "EP_ID=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid);
            string sk    = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw);

            EXEC_ORDER e = new EXEC_ORDER();
            return(e.EXEC_ORDER_Get_WithIP(COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid), sk));
        }
        else
        {
            return("");
        }
    }
Ejemplo n.º 3
0
    public string SendCommand(string commandtype, string commandbody, string SK)
    {

        string[,] p = new string[2, 2];
        p[0, 0] = "commandtype";
        p[1, 0] = commandtype;
        p[0, 1] = "commandbody";
        p[1, 1] = commandbody;

        if (!COS_SECURITY_TOOL.SECURITY_RequestDecrypt(p, SK)) return COS_SECURITY_TOOL.SECURITY_ContentEncrypt("-4");

        commandtype = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandtype);
        commandbody = COS_SECURITY_TOOL.SECURITY_ContentDecrypt(commandbody);

        if (commandtype.ToLower().Trim() == "i")
        {

            string[] body = commandbody.Split('|');

            string hccu_id = body[1];
            string mac = body[2];
            string ip = body[3];
            string prop = body[4];

            EP ep = new EP();

            string skraw = "EP_TypeId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1")
                            + "&EP_UserDefined_Alias=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown")
                            + "&EP_ProductId=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1")
                            + "&HCCU_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id)
                            + "&EP_MAC_Id=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac)
                            + "&PROPFORMAT=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop)
                            + "&IP=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip);

            string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw);

            return ep.EP_Add_20140320(COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt("Unknown"),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt("1"),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt(hccu_id),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt(mac),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt(prop),
                COS_SECURITY_TOOL.SECURITY_ContentEncrypt(ip),
                sk);

        }

        else if (commandtype.ToLower().Trim() == "d")
        {

            string[] body = commandbody.Split('|');

            if (body.Length < 5) return "";

            string hccu_id = body[1];
            string mac = body[2];
            string d_length = body[3];

            if (mac.Length != 16) return "";

            COS_WEBSERVICE_EP c = new COS_WEBSERVICE_EP();
            string epid = Get_EPID_From_MAC(mac);


            ParseDataCommand(commandbody, epid, d_length, hccu_id);


            string skraw = "EP_ID=" + COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid);
            string sk = COS_SECURITY_TOOL.SECURITY_RequestEncrypt(skraw);

            EXEC_ORDER e = new EXEC_ORDER();
            return e.EXEC_ORDER_Get_WithIP(COS_SECURITY_TOOL.SECURITY_ContentEncrypt(epid), sk);


        }
        else
        {

            return "";
        }

    }