コード例 #1
0
        public string GetDataFromServer(string pstrServlet, Hashtable pobjParameters, bool pblnSecure = false)
        {
            string[] lstrLoginKey     = new string[2];
            string[] lstrThickClient  = new string[2];
            string   lstrReturnString = null;
            HTTPHlpr lobjHTTPHelper   = new HTTPHlpr();

            if (ForceDoEvent != null)
            {
                ForceDoEvent();
            }
            //lobjHTTPHelper = new HTTPHelper();
            lobjHTTPHelper.Method = "Post";
            if ((mobjUtilityConnParameters.PROXYSERVER != null))
            {
                lobjHTTPHelper.ProxyServer = mobjUtilityConnParameters.PROXYSERVER;
                lobjHTTPHelper.ProxyPort   = mobjUtilityConnParameters.PROXYPORT;
            }
            if ((mobjUtilityConnParameters.PROXYUSER != null) && !string.IsNullOrEmpty(mobjUtilityConnParameters.PROXYUSER))
            {
                lobjHTTPHelper.ProxyUserId       = mobjUtilityConnParameters.PROXYUSER;
                lobjHTTPHelper.ProxyUserPassword = mobjUtilityConnParameters.PROXYPASSWORD;
            }
            //: Determines whethere to call servlet Securely or not
            pblnSecure = IsServletInSecureList(pstrServlet);
            if (pblnSecure == true || mblnUSESecureConnection == true)
            {
                lobjHTTPHelper.Protocol = "https://";
            }
            else
            {
                lobjHTTPHelper.Protocol = "http://";
            }
            lobjHTTPHelper.Server  = mobjUtilityConnParameters.SERVER;
            lobjHTTPHelper.Servlet = pstrServlet;
            lstrThickClient[0]     = mobjUtilityConnParameters.ThickClientValue;
            pobjParameters.Add(mobjUtilityConnParameters.ThickClientParameter, lstrThickClient);
            if ((mobjUtilityConnParameters.LoginKeyValue == null))
            {
                lstrLoginKey[0] = "";
            }
            else
            {
                lstrLoginKey[0] = mobjUtilityConnParameters.LoginKeyValue;
            }
            //: For Data to be received in Compressed form or not
            lobjHTTPHelper.CompressData = mobjUtilityConnParameters.CompressData;

            pobjParameters.Add(mobjUtilityConnParameters.LoginKeyName, lstrLoginKey);
            lobjHTTPHelper.setValues(pobjParameters);
            try
            {
                lstrReturnString = lobjHTTPHelper.send();
            }
            catch (Exception lobjException)
            {
                lstrReturnString = "1|" + lobjException.Message + "|";
            }
            return(lstrReturnString);
        }
コード例 #2
0
        public static string GetDataFromServer(string pstrServlet, string[] pstrParameters, string[] pstrValues, bool pblnSecure = false, ResponseReturned pobjDelegate = null)
        {
            mobjUtilityConnParameters = UtilityConnParameters.GetInstance;
            //TODO: Need to Remove hardocded value
            mobjUtilityConnParameters.SERVER = "10.1.101.6:6080/stocks";
            //TODO: Need to Remove hardocded value

            if (ForceDoEvent != null)
            {
                ForceDoEvent();
            }
            if ((pstrParameters.Length != pstrValues.Length))
            {
                return("1|Parameter size mismatch|0");
            }
            //HTTPHlpr lobjHTTPHelper = default(HTTPHelper);
            HTTPHlpr lobjHTTPHelper = new HTTPHlpr();

            lobjHTTPHelper.Method  = "Post";
            lobjHTTPHelper.TimeOut = mintHttpTimeOut;
            if ((mobjUtilityConnParameters.PROXYSERVER != null))
            {
                lobjHTTPHelper.ProxyServer = mobjUtilityConnParameters.PROXYSERVER;
                lobjHTTPHelper.ProxyPort   = mobjUtilityConnParameters.PROXYPORT;
                if ((mobjUtilityConnParameters.PROXYUSER != null))
                {
                    lobjHTTPHelper.ProxyUserId       = mobjUtilityConnParameters.PROXYUSER;
                    lobjHTTPHelper.ProxyUserPassword = mobjUtilityConnParameters.PROXYPASSWORD;
                }
            }
            //: Determines whethere to call servlet Securely or not
            pblnSecure = IsServletInSecureList(pstrServlet);
            if (pblnSecure == true || mblnUSESecureConnection == true)
            {
                lobjHTTPHelper.Protocol = "https://";
            }
            else
            {
                lobjHTTPHelper.Protocol = "http://";
            }
            lobjHTTPHelper.Server  = mobjUtilityConnParameters.SERVER;
            lobjHTTPHelper.Servlet = pstrServlet;

            //: For Data to be received in Compressed form or not
            lobjHTTPHelper.CompressData = mobjUtilityConnParameters.CompressData;
            pstrParameters[pstrParameters.Length - 1] = mobjUtilityConnParameters.ThickClientParameter;
            pstrValues[pstrValues.Length - 1]         = mobjUtilityConnParameters.ThickClientValue;
            pstrParameters[pstrParameters.Length - 2] = mobjUtilityConnParameters.LoginKeyName;
            if ((mobjUtilityConnParameters.LoginKeyValue == null))
            {
                pstrValues[pstrValues.Length - 2] = "";
            }
            else
            {
                pstrValues[pstrValues.Length - 2] = mobjUtilityConnParameters.LoginKeyValue;
            }
            lobjHTTPHelper.setValues(pstrParameters, pstrValues);
            try
            {
                if ((pobjDelegate != null))
                {
                    lobjHTTPHelper.OnHTTPResponseCompleted += pobjDelegate;
                    lobjHTTPHelper.sendThread();
                    return("");
                }
                return(lobjHTTPHelper.send());
            }
            catch (Exception ex)
            {
                return("1|" + ex.Message + "|0");
            }
        }
コード例 #3
0
        public string SendMessageOverHTTP(string pstrMessages, string pstrBroadCastServletName, ResponseReturned pobjDelegate = null, bool pblnSecure = false)
        {
            string lstrLoginKey        = null;
            string lstrThickClient     = "Y";
            string MESSAGE_STRING      = "MESSAGE";
            string MESSAGECOUNT_STRING = "MESSAGECOUNT";
            string lstrReturnString    = "";

            System.Collections.ArrayList lstrParameters = new System.Collections.ArrayList();
            System.Collections.ArrayList lstrValues     = new System.Collections.ArrayList();
            int      lintCount      = 0;
            HTTPHlpr lobjHTTPHelper = new HTTPHlpr();

            //: Determines whethere to call servlet Securely or not
            pblnSecure = IsServletInSecureList(pstrBroadCastServletName);
            if (pblnSecure == true || mblnUSESecureConnection == true)
            {
                lobjHTTPHelper.Protocol = "https://";
            }
            else
            {
                lobjHTTPHelper.Protocol = "http://";
            }
            lobjHTTPHelper.Method  = "Post";
            lobjHTTPHelper.Server  = mobjUtilityConnParameters.SERVER;
            lobjHTTPHelper.Servlet = pstrBroadCastServletName;
            //: For Data to be received in Compressed form or not
            lobjHTTPHelper.CompressData = mobjUtilityConnParameters.CompressData;

            if ((mobjUtilityConnParameters.PROXYSERVER != null))
            {
                lobjHTTPHelper.ProxyServer = mobjUtilityConnParameters.PROXYSERVER;
                lobjHTTPHelper.ProxyPort   = mobjUtilityConnParameters.PROXYPORT;
            }
            if ((mobjUtilityConnParameters.PROXYUSER != null) && !string.IsNullOrEmpty(mobjUtilityConnParameters.PROXYUSER))
            {
                lobjHTTPHelper.ProxyUserId       = mobjUtilityConnParameters.PROXYUSER;
                lobjHTTPHelper.ProxyUserPassword = mobjUtilityConnParameters.PROXYPASSWORD;
            }

            lstrThickClient = mobjUtilityConnParameters.ThickClientValue;
            //: Parameters are LK,USID,MWDET
            //: LK = LoginKey
            //: USID = mobjUtilityConnParameters.UserID()
            if ((mobjUtilityConnParameters.LoginKeyValue == null))
            {
                lstrLoginKey = "";
            }
            else
            {
                lstrLoginKey = mobjUtilityConnParameters.LoginKeyValue;
            }
            //: USID Added
            lstrParameters.Add("USID");
            lstrValues.Add(Convert.ToString(mobjUtilityConnParameters.UserId));
            //: MODE Proxy
            lstrParameters.Add("MODE");
            lstrValues.Add("PROXY");

            //For lintTemp As Integer = 0 To pstrMessages.Length - 1
            lstrParameters.Add(MESSAGE_STRING + lintCount);
            //lstrValues.Add(pstrMessages(lintTemp))
            lstrValues.Add(pstrMessages);
            lintCount += 1;
            //Next

            //: Add MESSAGE COUNT
            lstrParameters.Add(MESSAGECOUNT_STRING);
            lstrValues.Add(lintCount.ToString());
            //: LK Added
            lstrParameters.Add(mobjUtilityConnParameters.LoginKeyName);
            lstrValues.Add(lstrLoginKey);
            //: Thick Client
            lstrParameters.Add(mobjUtilityConnParameters.ThickClientParameter);
            lstrValues.Add(mobjUtilityConnParameters.ThickClientValue);
            //:
            lobjHTTPHelper.setValues(lstrParameters, lstrValues);

            try
            {
                if ((pobjDelegate != null))
                {
                    lobjHTTPHelper.OnHTTPResponseCompleted += pobjDelegate;
                    lobjHTTPHelper.sendThread();
                    return("");
                }
                lobjHTTPHelper.send();
            }
            catch (Exception lobjException)
            {
                lstrReturnString = "1|" + lobjException.Message + "|";
            }
            return(lstrReturnString);
        }
コード例 #4
0
        public string GetDataFromServer(string pstrServlet, ArrayList pParamNamesList = null, ArrayList pParamValuesList = null, bool pblnSecure = false, ResponseReturned pobjDelegate = null)
        {
            if (ForceDoEvent != null)
            {
                ForceDoEvent();
            }
            if ((pParamNamesList != null) & (pParamValuesList != null))
            {
                if ((pParamNamesList.Count != pParamValuesList.Count))
                {
                    return("1|Parameter size mismatch|0");
                }
            }
            else
            {
                pParamNamesList  = new ArrayList();
                pParamValuesList = new ArrayList();
            }
            HTTPHlpr lobjHTTPHelper = new HTTPHlpr();

            lobjHTTPHelper.Method = "Post";
            if ((mobjUtilityConnParameters.PROXYSERVER != null))
            {
                lobjHTTPHelper.ProxyServer = mobjUtilityConnParameters.PROXYSERVER;
                lobjHTTPHelper.ProxyPort   = mobjUtilityConnParameters.PROXYPORT;
                if ((mobjUtilityConnParameters.PROXYUSER != null))
                {
                    lobjHTTPHelper.ProxyUserId       = mobjUtilityConnParameters.PROXYUSER;
                    lobjHTTPHelper.ProxyUserPassword = mobjUtilityConnParameters.PROXYPASSWORD;
                }
            }
            //: Determines whethere to call servlet Securely or not
            pblnSecure = IsServletInSecureList(pstrServlet);
            if (pblnSecure == true || mblnUSESecureConnection == true)
            {
                lobjHTTPHelper.Protocol = "https://";
            }
            else
            {
                lobjHTTPHelper.Protocol = "http://";
            }
            lobjHTTPHelper.Server  = mobjUtilityConnParameters.SERVER;
            lobjHTTPHelper.Servlet = pstrServlet;

            //: For Data to be received in Compressed form or not
            lobjHTTPHelper.CompressData = mobjUtilityConnParameters.CompressData;

            pParamNamesList.Add(mobjUtilityConnParameters.ThickClientParameter);
            pParamValuesList.Add(mobjUtilityConnParameters.ThickClientValue);
            pParamNamesList.Add(mobjUtilityConnParameters.LoginKeyName);
            if ((mobjUtilityConnParameters.LoginKeyValue == null))
            {
                pParamValuesList.Add("");
            }
            else
            {
                pParamValuesList.Add(mobjUtilityConnParameters.LoginKeyValue);
            }
            lobjHTTPHelper.setValues(pParamNamesList, pParamValuesList);
            try
            {
                if ((pobjDelegate != null))
                {
                    lobjHTTPHelper.OnHTTPResponseCompleted += pobjDelegate;
                    lobjHTTPHelper.sendThread();
                    return("");
                }
                return(lobjHTTPHelper.send());
            }
            catch (Exception ex)
            {
                return("1|" + ex.Message + "|0");
            }
        }