コード例 #1
0
        /// <summary>
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            DateTime startTime  = DateTime.Now;
            string   _requestID = Guid.NewGuid().ToString("N");

            string[] _arrayReponseDeployWebMethod = null;

            SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.INFORMATION, _requestID, context.Request.Url.ToString());

            try
            {
                _arrayReponseDeployWebMethod = _callDeployService(_requestID, processServerVariables(_requestID, context));
                SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.INFORMATION, _requestID, "[" + _arrayReponseDeployWebMethod[0].Trim() + "] " + "data recivied from deploy service");

                switch (_arrayReponseDeployWebMethod[0].Trim())
                {
                case "text/html":
                    context.Response.ContentType = _arrayReponseDeployWebMethod[0];
                    context.Response.Write(_arrayReponseDeployWebMethod[1]);
                    break;

                case "application/java-archive":
                    context.Response.ContentType = _arrayReponseDeployWebMethod[0];
                    context.Response.AppendHeader("content-disposition", "attachment;filename=token.jar");
                    context.Response.BinaryWrite(Convert.FromBase64String(_arrayReponseDeployWebMethod[1]));
                    break;

                case "application/vnd.ms-cab-compressed":
                    context.Response.ContentType = _arrayReponseDeployWebMethod[0];
                    context.Response.AppendHeader("content-disposition", "attachment;filename=token.cab");
                    context.Response.BinaryWrite(Convert.FromBase64String(_arrayReponseDeployWebMethod[1]));
                    break;

                default:
                    SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.ERROR, _requestID, "Invalid data returned from deployment server");
                    throw new Exception("Não foi possivel precessar o pedido");
                }
            }
            catch (Exception ex)
            {
                string _errMsg = ex.Message;
                context.Response.ContentType = "text/html";
                context.Response.Write(string.Format(cFRENDLY_ERRORMSG_TEMPLATE, (object)_baseName, (object)_errMsg));
                SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.ERROR, _requestID, _errMsg);
            }
            finally
            {
                _arrayReponseDeployWebMethod = null;
                SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.INFORMATION, _requestID, "::Deployment Terminate [" + ((TimeSpan)(DateTime.Now - startTime)).TotalSeconds.ToString() + " sec]::");
                context.Response.End();
            }
        }
コード例 #2
0
        /// <summary>
        /// </summary>
        /// <param name="serverrUrl"></param>
        /// <param name="serverTimeout"></param>
        /// <returns></returns>
        private string[] _callDeployService(string _requestID, string deployServiceParams)
        {
            SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.INFORMATION, _requestID, deployServiceParams);

            int    _serverTimeout = int.Parse(ConfigurationManager.AppSettings.Get(cTOKENDEPLOY_URLSERVICE_TIMEOUT));
            String _serverrUrl    = ConfigurationManager.AppSettings.Get(cTOKENDEPLOY_URLSERVICE);

            SAFBusinessSrv.SAFBusinessServices proxy = new SAFBusinessSrv.SAFBusinessServices();
            proxy.Url         = _serverrUrl;
            proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            proxy.Timeout     = _serverTimeout > 15000 ? _serverTimeout : 15000;
            proxy.SoapVersion = SoapProtocolVersion.Soap11;

            SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.INFORMATION, _requestID, "[" + proxy.Timeout.ToString() + "Sec] " + _serverrUrl);

            try
            {
                string _responseDeployWebMethod = proxy.loadDeploymentInfo(deployServiceParams);
                if (_responseDeployWebMethod == null)
                {
                    SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.ERROR, _requestID, "Error on deploy service>>null value return");
                    _responseDeployWebMethod = "text/html|" + string.Format(cFRENDLY_ERRORMSG_TEMPLATE, "Ocorreu um na descarga do seu token móvel", "Contacte os nossos serviços de apoio: 800 999 999");
                }
                return(_responseDeployWebMethod.Split('|'));
            }
            catch (Exception ex)
            {
                SAFTokenDeployLogger.write(_DeployHandlerName, SAFTokenDeployLogger.HandlerLoggerCategory.ERROR, _requestID, ex.Message);
                return(null);
            }
            finally
            {
                if (proxy != null)
                {
                    proxy.Dispose();
                }
            }
        }