private void WriteOutputCommand(TransportClassMainAshx oTransportClassMainAshx, OutputCommand oOutputCommand) { HttpContext oHttpContext = oTransportClassMainAshx.m_oHttpContext; AsyncCallback fAsyncCallback = oTransportClassMainAshx.m_oAsyncCallback; oHttpContext.Response.ContentType = "text/xml"; oHttpContext.Response.Charset = "UTF-8"; string sXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><FileResult>"; if (null != oOutputCommand.m_sFileUrl) { sXml += string.Format("<FileUrl>{0}</FileUrl>", HttpUtility.HtmlEncode(oOutputCommand.m_sFileUrl)); } if (null != oOutputCommand.m_sPercent) { sXml += string.Format("<Percent>{0}</Percent>", oOutputCommand.m_sPercent); } if (true == oOutputCommand.m_bIsEndConvert.HasValue) { sXml += string.Format("<EndConvert>{0}</EndConvert>", oOutputCommand.m_bIsEndConvert.Value.ToString()); } if (ErrorTypes.NoError != oOutputCommand.m_eError) { sXml += string.Format("<Error>{0}</Error>", Utils.mapAscServerErrorToOldError(oOutputCommand.m_eError).ToString()); } sXml += "</FileResult>"; oHttpContext.Response.Write(sXml); fAsyncCallback.Invoke(new AsyncOperationData(null)); }
private void WriteToResponse(TransportClassMainAshx oTransportClassMainAshx, ErrorTypes eError, List <string> aUrls, NameValueCollection aNameValueCollection) { HttpContext oHttpContext = oTransportClassMainAshx.m_oHttpContext; AsyncCallback oAsyncCallback = oTransportClassMainAshx.m_oAsyncCallback; OutputCommand oOutputCommand = new OutputCommand(); if (null != aNameValueCollection) { for (int i = 0, length = aNameValueCollection.Count; i < length; ++i) { oOutputCommand.input.Add(aNameValueCollection.GetKey(i), aNameValueCollection.Get(i)); } } oOutputCommand.urls = aUrls; oOutputCommand.error = (int)eError; oOutputCommand.type = (int)PostMessageType.UploadImage; JavaScriptSerializer serializer = new JavaScriptSerializer(); StringBuilder sb = new StringBuilder(); serializer.Serialize(oOutputCommand, sb); string sJson = sb.ToString(); oHttpContext.Response.Write("<html><head><script type=\"text/javascript\">function load(){ parent.postMessage(\"" + sJson.Replace("\"", "\\\"") + "\", '*'); }</script></head><body onload='load()'></body></html>"); oAsyncCallback.Invoke(new AsyncOperationData(null)); }
public TransportClass1(TransportClassMainAshx oTransportClassMainAshx, ITaskResultInterface oTaskResult, CTaskQueue oTaskQueue, InputParams oInputParams) : base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback) { m_oTaskResult = oTaskResult; m_oInputParams = oInputParams; m_oTaskQueue = oTaskQueue; m_oTimer = null; }
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()); string sGuid = context.Request.QueryString["key"]; int nMaxBytes = Convert.ToInt32(ConfigurationSettings.AppSettings["limits.image.size"] ?? "25000000"); if (context.Request.ContentLength <= nMaxBytes) { if (context.Request.Files.Count > 0) { int nParamsCount = 0; string sInputParams = ""; for (int i = 0, length = context.Request.QueryString.Count; i < length; ++i) { sInputParams += context.Request.QueryString.Get(i) + ":" + context.Request.QueryString.GetKey(i); if (nParamsCount > 0) { sInputParams += ","; } nParamsCount++; } AsyncMediaXmlOperation oAsyncMediaXmlOperation = new AsyncMediaXmlOperation(); List <string> aUrls = new List <string>(); TransportClass1 oTransportClass1 = new TransportClass1(oTransportClassMainAshx, oAsyncMediaXmlOperation, context.Request.QueryString, aUrls, sGuid, Path.Combine(sGuid, @"media/media.xml"), context.Request.Files, context.Request.Files.GetEnumerator()); oAsyncMediaXmlOperation.GetMediaXmlBegin(oTransportClass1.m_sMediaXml, GetMediaXmlCallback, oTransportClass1); } else { eError = ErrorTypes.UploadCountFiles; } } else { eError = ErrorTypes.UploadContentLength; } } catch (Exception e) { eError = ErrorTypes.Upload; _log.Error(context.Request.QueryString.ToString()); _log.Error("Exeption: ", e); } if (ErrorTypes.NoError != eError) { WriteToResponse(oTransportClassMainAshx, eError, null, context.Request.QueryString); } return(new AsyncOperationData(extraData)); }
public TransportClass1(TransportClassMainAshx oTransportClassMainAshx, AsyncMediaXmlOperation oAsyncMediaXmlOperation, NameValueCollection aInputParams, List <string> aUrls, string sKey, string sMediaXml, HttpFileCollection oFiles, IEnumerator oFilesEnumerator) : base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback) { m_oAsyncMediaXmlOperation = oAsyncMediaXmlOperation; m_aInputParams = aInputParams; m_sKey = sKey; m_oFiles = oFiles; m_oFilesEnumerator = oFilesEnumerator; m_sMediaXml = sMediaXml; m_aUrls = aUrls; }
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)); }
public TransportClass2(TransportClassMainAshx oTransportClassMainAshx, AsyncClearCacheOperation oAsyncClearCacheOperation, ErrorTypes eError) : base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback) { m_oAsyncClearCacheOperation = oAsyncClearCacheOperation; m_eError = eError; }