public string UserAuthentication(string login_mail, string login_password, string devid, string sk)
    {
        string[,] p = new string[2, 3];
        p[0, 0]     = "login_mail";
        p[1, 0]     = login_mail;
        p[0, 1]     = "login_password";
        p[1, 1]     = login_password;
        p[0, 2]     = "devid";
        p[1, 2]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);

        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }



        login_mail = SEC.SECURITY_ContentDecrypt(login_mail);


        string query = "select HCCU_ID from HCCU_FACT WHERE HCCU_UID='" + login_mail + "' AND SUBSTRING(HCCU_PSW,4,LEN(HCCU_PSW)-7)=SUBSTRING('" + login_password + "',4,LEN('" + login_password + "')-7)";


        try
        {
            string ret0 = DataHelperForDevService.Query_ExecuteScalar(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

            return(SEC.SECURITY_ContentEncrypt(ret0)); // return -2 if the input para equals null.
        }
        catch {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }
    }
Exemple #2
0
    public string GetHCCUNetworkInfo(string devid, string sk)
    {
        string[,] p = new string[2, 1];
        p[0, 0]     = "devid";
        p[1, 0]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }


        string    query = "select * from hccu_mac_fact where hccu_id='" + devid + "'";
        DataTable dt    = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

        if (dt.Rows.Count == 0)
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }
        else
        {
            string returns = "";
            for (int x = 0; x < dt.Rows.Count; x++)
            {
                returns += dt.Rows[0]["IP"].ToString() + "," + dt.Rows[0]["PORT"].ToString() + "|";
            }
            return(SEC.SECURITY_ContentEncrypt(returns));
        }
    }
    public string UserAuthenticationWithLocalIPVarify(string login_id, string login_password, string devid, string sk)
    {
        string[,] p = new string[2, 3];
        p[0, 0]     = "login_id";
        p[1, 0]     = login_id;
        p[0, 1]     = "login_password";
        p[1, 1]     = login_password;
        p[0, 2]     = "devid";
        p[1, 2]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        login_id = SEC.SECURITY_ContentDecrypt(login_id);

        string query = "select HCCU_ID from HCCU_FACT WHERE HCCU_UID='" + login_id + "' AND HCCU_PSW = '" + login_password + "'";

        try
        {
            string ret0   = DataHelperForDevService.Query_ExecuteScalar(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);
            string query2 = "select ip from v_hccu where hccu_id='" + ret0 + "'";
            string ret1   = DataHelperForDevService.Query_ExecuteScalar(DataHelperForDevService.DataBaseFact.CENTRAL, query2, null);

            return(SEC.SECURITY_ContentEncrypt(ret0 + "|" + ret1));
        }
        catch
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }
    }
Exemple #4
0
    public string GetEPCategory(string para, string devid, string sk)
    {
        string[,] p = new string[2, 2];
        p[0, 0]     = "para";
        p[1, 0]     = para;
        p[0, 1]     = "devid";
        p[1, 1]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        para = SEC.SECURITY_ContentDecrypt(para);

        if (para != "0")
        {
            string    query = "select * from endpoint_type_fact where HCCU_ID='" + devid + "' and EP_TYPE_ID='" + para + "'";
            DataTable dt    = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

            if (dt.Rows.Count == 0)
            {
                return(SEC.SECURITY_ContentEncrypt("0"));
            }

            string ret = "";
            for (int x = 0; x < dt.Rows.Count; x++)
            {
                ret += dt.Rows[x]["EP_TYPE_ID"].ToString() + "," + dt.Rows[x]["EP_TYPE_NAME"].ToString() + "," + dt.Rows[x]["EP_TYPE_DESCRIPTION"].ToString() + "|";
            }

            return(ret);
        }
        else
        {
            COS_WEBSERVICE_EPTYPE c  = new COS_WEBSERVICE_EPTYPE();
            ArrayList             al = c.EPTYPE_GetList(devid);
            string ret = "";

            if (al.Count == 0)
            {
                return(SEC.SECURITY_ContentEncrypt("0"));
            }

            for (int x = 0; x < al.Count; x++)
            {
                if (al[x].ToString().Trim() == "-1" || al[x].ToString().Trim() == "-2")
                {
                    return(SEC.SECURITY_ContentEncrypt("-3"));
                }
                ret += al[x].ToString() + "|";
            }

            return(ret);
        }
    }
    public string GetCurrentExecOrder(string para, string cosid, string devid, string sk)
    {
        string[,] p = new string[2, 3];
        p[0, 0]     = "para";
        p[1, 0]     = para;
        p[0, 1]     = "cosid";
        p[1, 1]     = cosid;
        p[0, 2]     = "devid";
        p[1, 2]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        para  = SEC.SECURITY_ContentDecrypt(para);
        cosid = SEC.SECURITY_ContentDecrypt(cosid);

        string query0 = "select count(*) from endpoint_fact where hccu_id='" + cosid + "'";
        string ret0   = DataHelperForDevService.Query_ExecuteScalar(DataHelperForDevService.DataBaseFact.CENTRAL, query0, null);

        if (ret0 == "0")
        {
            return(SEC.SECURITY_ContentEncrypt("-3"));
        }

        string query = "select * from exec_order where ep_id = '" + para + "'";

        DataTable dt = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.PROPERTY, query, null);

        if (dt.Rows.Count == 0)
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }
        else
        {
            string ret = "";
            for (int x = 0; x < dt.Rows.Count; x++)
            {
                ret += dt.Rows[x]["PROP"].ToString().Trim() + "," + dt.Rows[x]["VALUE"].ToString().Trim() + "," + dt.Rows[x]["ORDER_DATE"].ToString().Trim() + "," + dt.Rows[x]["IFSENT"].ToString().Trim()
                       + "," + dt.Rows[x]["EXPIRE"].ToString().Trim() + "|";
            }

            return(SEC.SECURITY_ContentEncrypt(ret));
        }
    }
    public string DeleteEndPoint(string para, string cosid, string devid, string sk)
    {
        string[,] p = new string[2, 3];
        p[0, 0]     = "para";
        p[1, 0]     = para;
        p[0, 1]     = "cosid";
        p[1, 1]     = cosid;
        p[0, 2]     = "devid";
        p[1, 2]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        para  = SEC.SECURITY_ContentDecrypt(para);
        cosid = SEC.SECURITY_ContentDecrypt(cosid);


        string query = "select count(*) from ENDPOINT_FACT WHERE EP_ID='" + para + "' AND HCCU_ID = '" + cosid + "'";
        string ret0  = DataHelperForDevService.Query_ExecuteScalar(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

        if (ret0 == "0")
        {
            return(SEC.SECURITY_ContentEncrypt("-2"));
        }

        string[,] pa = new string[2, 1];
        pa[0, 0]     = "EP_ID";
        pa[1, 0]     = para;

        string[,] op = new string[2, 1];
        op[0, 0]     = "RET";
        op[1, 0]     = DataHelperForDevService.OUTPUT_PARA_INT16;

        List <SqlParameter> ret = DataHelperForDevService.QueryWithSP_OUTPUT(DataHelperForDevService.DataBaseFact.CENTRAL, "EP_DELETE_SP", pa, op);

        if (((SqlParameter)ret[0]).Value.ToString().Trim() != "1")
        {
            return(SEC.SECURITY_ContentEncrypt("-3"));
        }

        return(SEC.SECURITY_ContentEncrypt("1"));
    }
Exemple #7
0
    public string DeleteEPCategory(string para, string devid, string sk)
    {
        string[,] p = new string[2, 2];
        p[0, 0]     = "para";
        p[1, 0]     = para;
        p[0, 1]     = "devid";
        p[1, 1]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        para = SEC.SECURITY_ContentDecrypt(para);

        string[,] pa = new string[2, 1];
        pa[0, 0]     = "EP_TYPEID";
        pa[1, 0]     = para;

        string[,] op = new string[2, 1];
        op[0, 0]     = "RET";
        op[1, 0]     = DataHelperForDevService.OUTPUT_PARA_INT16;

        List <SqlParameter> ret = DataHelperForDevService.QueryWithSP_OUTPUT(DataHelperForDevService.DataBaseFact.CENTRAL, "EPTYPE_DELETE_SP", pa, op);

        string retvalue = ((SqlParameter)ret[0]).Value.ToString().Trim();

        if (retvalue == "1")
        {
            return(SEC.SECURITY_ContentEncrypt("1"));
        }
        else
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }
    }
Exemple #8
0
    public string invoke(string epid, string method, string para, string devid, string sk)
    {
        string[,] p = new string[2, 4];
        p[0, 0]     = "epid";
        p[1, 0]     = epid;
        p[0, 1]     = "method";
        p[1, 1]     = method;
        p[0, 2]     = "para";
        p[1, 2]     = para;
        p[0, 3]     = "devid";
        p[1, 3]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        epid   = SEC.SECURITY_ContentDecrypt(epid);
        method = SEC.SECURITY_ContentDecrypt(method);
        para   = SEC.SECURITY_ContentDecrypt(para);


        string query = "SELECT * FROM EP_PRODUCT_METHODS_FACT"
                       + " WHERE EP_PRODUCT_ID"
                       + " IN"
                       + " (SELECT EP_PRODUCTID FROM ENDPOINT_FACT WHERE EP_ID = '" + epid + "') AND METHODNAME='" + method + "'";

        DataTable dt = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

        if (dt.Rows.Count == 0)
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }

        string methodname     = dt.Rows[0]["MethodName"].ToString();
        string returnType     = dt.Rows[0]["returntype"].ToString();
        string paracollection = dt.Rows[0]["paracollection"].ToString();
        string id             = dt.Rows[0]["id"].ToString();

        string sp_para = "";

        string procedurename = "invokMethod_" + id;

        #region 确定双方参数数量

        int paracollection_number = 0;
        int para_number           = 0;

        try
        {
            if (paracollection.Trim() == "")
            {
                paracollection_number = 0;
            }

            if (paracollection.IndexOf(',') == -1)
            {
                paracollection_number = 1;
            }
            else
            {
                string[] s = paracollection.Split(',');
                paracollection_number = s.Length;
            }

            if (para.Trim() == "")
            {
                para_number = 0;
            }
            if (para.IndexOf(',') == -1)
            {
                para_number = 1;
            }
            else
            {
                string[] s = para.Split(',');
                para_number = s.Length;
            }
        }
        catch { }


        #endregion

        if (paracollection_number + 1 != para_number)
        {
            return(SEC.SECURITY_ContentEncrypt("-1"));
        }

        if (paracollection_number == 0)
        {
            sp_para += " @SESSIONINEPID = N'" + para + "' ";
        }
        else if (paracollection_number == 1)
        {
            sp_para += paracollection + "=N'" + para.Split(',')[0].ToString().Trim() + "', @SESSIONINEPID = N'" + para.Split(',')[1].ToString().Trim() + "' ";
        }
        else
        {
            string[] x = paracollection.Split(',');
            string[] y = para.Split(',');

            for (int j = 0; j < x.Length; j++)
            {
                sp_para += x[j].ToString().Trim() + "=" + y[j].ToString().Trim() + ", ";
            }

            sp_para += " @SESSIONINEPID = N'" + y[x.Length].ToString().Trim() + "' ";
        }


        if (returnType == "1")
        {
            sp_para += " ,@INVOKERETURN = @INVOKERETURN OUTPUT;  SELECT @INVOKERETURN AS 'RET','1' AS 'STA'";
        }
        else
        {
            sp_para += "; SELECT '0' AS 'RET', '1' AS 'STA'";
        }

        string execquery = "DECLARE @INVOKERETURN NVARCHAR(500); EXEC " + procedurename + " " + sp_para;

        try
        {
            DataTable dts = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.PROPERTY, execquery, null);
            if (dts == null)
            {
                return(SEC.SECURITY_ContentEncrypt("-3"));
            }

            if (dts.Rows.Count == 0)
            {
                return(SEC.SECURITY_ContentEncrypt("-3"));
            }
            else
            {
                return(SEC.SECURITY_ContentEncrypt(dts.Rows[0]["RET"].ToString() + "," + dts.Rows[0]["STA"].ToString()));
            }
        }
        catch
        {
            return(SEC.SECURITY_ContentEncrypt("-3"));
        }
    }
Exemple #9
0
    public string GetEndPoint(string para, string getendpointlistmode, string devid, string sk)
    {
        string[,] p = new string[2, 3];
        p[0, 0]     = "para";
        p[1, 0]     = para;
        p[0, 1]     = "getendpointlistmode";
        p[1, 1]     = getendpointlistmode;
        p[0, 2]     = "devid";
        p[1, 2]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        para = SEC.SECURITY_ContentDecrypt(para);
        getendpointlistmode = SEC.SECURITY_ContentDecrypt(getendpointlistmode);

        if (para.IndexOf('^') != -1 && para.IndexOf('#') != -1)
        {
            para = Decode_hc(para);
        }

        string query = "";
        string ret   = "";

        if (getendpointlistmode == getendpointlistmodeenum.devid.ToString())
        {
            query = "select * from endpoint_Fact where hccu_id='" + para + "'";
        }
        else if (getendpointlistmode == getendpointlistmodeenum.epid.ToString())
        {
            query = "select * from endpoint_Fact where ep_id='" + para + "'";
        }
        else if (getendpointlistmode == getendpointlistmodeenum.epmodeid.ToString())
        {
            query = "select * from endpoint_Fact where ep_productid='" + para + "'";
        }
        else if (getendpointlistmode == getendpointlistmodeenum.epmodename.ToString())
        {
            query = "select * from endpoint_Fact where ep_productid"
                    + " in"
                    + " (select ep_product_id from endpoint_product_fact where ep_product_name='" + para + "' and dev_id='" + devid + "')";
        }
        else if (getendpointlistmode == getendpointlistmodeenum.epname.ToString())
        {
            query = "select * from endpoint_Fact where ep_userdefined_alias='" + para + "' and hccu_id='" + devid + "'";
        }

        DataTable dt = DataHelperForDevService.Query_SqlDataAdapter(DataHelperForDevService.DataBaseFact.CENTRAL, query, null);

        if (dt.Rows.Count == 0)
        {
            return(SEC.SECURITY_ContentEncrypt("0"));
        }

        for (int s = 0; s < dt.Rows.Count; s++)
        {
            ret += dt.Rows[0]["EP_ID"].ToString().Trim() + "," + dt.Rows[0]["EP_TYPEID"].ToString().Trim() + "," + Encode(dt.Rows[0]["EP_USERDEFINED_ALIAS"].ToString().Trim()) + ","
                   + dt.Rows[0]["EP_PRODUCTID"].ToString().Trim() + "," + dt.Rows[0]["HCCU_ID"].ToString().Trim() + "," + dt.Rows[0]["EP_MAC_ID"].ToString().Trim() + "|";
        }

        return(SEC.SECURITY_ContentEncrypt(ret));
    }