Exemplo n.º 1
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
        {
            TransportClassMainAshx oTransportClassMainAshx = new TransportClassMainAshx(context, cb);
            ErrorTypes             eError = ErrorTypes.NoError;

            try
            {
                _log.Info("Starting process request...");
                _log.Info(context.Request.QueryString.ToString());

                InputParams oInputParams = new InputParams();
                oInputParams.m_sKey           = context.Request.QueryString["key"];
                oInputParams.m_svKey          = context.Request.QueryString["vkey"];
                oInputParams.m_sUrl           = context.Request.QueryString["url"];
                oInputParams.m_sEmbeddedfonts = context.Request.QueryString["embeddedfonts"];

                int nIndexSep = oInputParams.m_sUrl.IndexOf(',');
                if (-1 != nIndexSep)
                {
                    oInputParams.m_sUrl = oInputParams.m_sUrl.Substring(0, nIndexSep);
                }
                oInputParams.m_sTitle = context.Request.QueryString["title"];
                if (string.IsNullOrEmpty(oInputParams.m_sTitle))
                {
                    oInputParams.m_sTitle = "convert";
                }
                oInputParams.m_sFiletype     = context.Request.QueryString["filetype"];
                oInputParams.m_nOutputtype   = FileFormats.FromString(context.Request.QueryString["outputtype"]);
                oInputParams.m_bAsyncConvert = Convert.ToBoolean(context.Request.QueryString["async"]);
                oInputParams.m_sCodepage     = context.Request.QueryString["codePage"];
                oInputParams.m_sDelimiter    = context.Request.QueryString["delimiter"];

                if (ErrorTypes.NoError == eError)
                {
                    ITaskResultInterface oTaskResult = TaskResult.NewTaskResult();
                    TaskResultData       oToAdd      = new TaskResultData();

                    oInputParams.m_sKey = "conv_" + oInputParams.m_sKey;
                    oToAdd.sKey         = oInputParams.m_sKey;
                    oToAdd.sFormat      = oInputParams.m_sFiletype;
                    oToAdd.eStatus      = FileStatus.WaitQueue;
                    oToAdd.sTitle       = oInputParams.m_sTitle;
                    TransportClass1 oTransportClass1 = new TransportClass1(oTransportClassMainAshx, oTaskResult, new CTaskQueue(), oInputParams);
                    oTaskResult.GetOrCreateBegin(oInputParams.m_sKey, oToAdd, GetOrCreateCallback, oTransportClass1);
                }
            }
            catch (Exception e)
            {
                eError = ErrorTypes.Unknown;

                _log.Error(context.Request.QueryString.ToString());
                _log.Error("Exeption: ", e);
            }
            finally
            {
                if (ErrorTypes.NoError != eError)
                {
                    WriteOutputCommand(oTransportClassMainAshx, new OutputCommand(null, null, null, eError));
                }
            }
            return(new AsyncOperationData(extraData));
        }