private void RemoveTaskCallback(IAsyncResult result) { TransportClass oTransportClass = result.AsyncState as TransportClass; try { ITaskResultInterface oTaskResult = oTransportClass.m_oTaskResult; if (null != oTaskResult) { oTaskResult.RemoveEnd(result); } Storage oStorage = oTransportClass.m_oStorage; if (null != oStorage) { oStorage.RemovePathBegin(oTransportClass.m_sDeletePath, RemoveFileCallback, oTransportClass); } } catch (Exception e) { _log.Error("Exception catched in RemoveTaskCallback:", e); oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass)); } }
private void DeletePath(IAsyncResult result) { TransportClass oTransportClass = result.AsyncState as TransportClass; try { if (null != oTransportClass.m_sDeletePath && false == string.IsNullOrEmpty(oTransportClass.m_sDeletePath)) { ITaskResultInterface oTaskResult = oTransportClass.m_oTaskResult; string sKey = oTransportClass.m_sDeletePath; oTaskResult.RemoveBegin(sKey, RemoveTaskCallback, oTransportClass); } else { oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass)); } } catch (Exception e) { _log.Error("Exception catched in DeletePath:", e); oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass)); } }
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 TransportClass(HttpContext oContext, AsyncCallback oCallback, Storage oStorage, ITaskResultInterface oTaskResult, string sPath, string sDeletePath) { m_oContext = oContext; m_oCallback = oCallback; m_oStorage = oStorage; m_oTaskResult = oTaskResult; m_sPath = sPath; m_sDeletePath = sDeletePath; }
public TaskResult() { string sTaskResultImpl = ConfigurationManager.AppSettings["utils.taskresult.impl"]; switch (sTaskResultImpl) { case "cacheddb": piTaskResult = new TaskResultCachedDB(); break; case "db": default: piTaskResult = new TaskResultDataBase(); break; } }
public static ITaskResultInterface NewTaskResult() { ITaskResultInterface piTaskResult = null; string sTaskResultImpl = ConfigurationManager.AppSettings["utils.taskresult.impl"]; switch (sTaskResultImpl) { case "cacheddb": piTaskResult = new TaskResultCachedDB(); break; case "db": default: piTaskResult = new TaskResultDataBase(); break; } return(piTaskResult); }
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 IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) { bool bStartAsync = false; try { _log.Info("Starting process request..."); _log.Info(context.Request.QueryString.ToString()); Storage oStorage = new Storage(); ITaskResultInterface oTaskResult = TaskResult.NewTaskResult(); string sPathOriginal = context.Request.QueryString["path"]; string sPath = null; if (null != sPathOriginal) { sPath = sPathOriginal.Replace("../", "").Replace("..\\", ""); if (sPathOriginal != sPath) { _log.Error("Possible XSS attack:" + sPathOriginal); } } string sOutputFilename = context.Request.QueryString["filename"]; string sDeletePathOriginal = context.Request.QueryString["deletepath"]; string sDeletePath = null; if (null != sDeletePathOriginal) { sDeletePath = sDeletePathOriginal.Replace("../", "").Replace("..\\", ""); if (sDeletePathOriginal != sDeletePath) { _log.Error("Possible XSS attack:" + sDeletePathOriginal); } } string sNoCache = context.Request.QueryString["nocache"]; if (string.IsNullOrEmpty(sOutputFilename)) { if (null != sPath) { int nIndex1 = sPath.LastIndexOf('/'); int nIndex2 = sPath.LastIndexOf('\\'); if (-1 != nIndex1 || -1 != nIndex2) { int nIndex = Math.Max(nIndex1, nIndex2); sOutputFilename = sPath.Substring(nIndex + 1); } else { sOutputFilename = "resource"; } } } context.Response.Clear(); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.ContentType = Utils.GetMimeType(sOutputFilename); string contentDisposition = Utils.GetContentDisposition(context.Request.UserAgent, context.Request.Browser.Browser, context.Request.Browser.Version, sOutputFilename); context.Response.AppendHeader("Content-Disposition", contentDisposition); if (null != sPath) { TransportClass oTransportClass = new TransportClass(context, cb, oStorage, oTaskResult, sPath, sDeletePath); oStorage.GetFileInfoBegin(sPath, GetFileInfoCallback, oTransportClass); bStartAsync = true; } else { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } catch (Exception e) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; _log.Error(context.Request.QueryString.ToString()); _log.Error("Exeption catched in BeginProcessRequest:", e); } TransportClass oTempTransportClass = new TransportClass(context, cb, null, null, null, null); if (false == bStartAsync) { cb(new AsyncOperationData(oTempTransportClass)); } return(new AsyncOperationData(oTempTransportClass)); }
public TransportClassInfo(TransportClassMainAshx oTransportClassMainAshx, string[] aKeys, ITaskResultInterface oTaskResult) : base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback) { m_aKeys = aKeys; m_oTaskResult = oTaskResult; }
public TransportClassTaskResult(TransportClassMainAshx oTransportClassMainAshx, InputCommand oInputCommand, ITaskResultInterface oTaskResult) : base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback) { m_oInputCommand = oInputCommand; m_oTaskResult = oTaskResult; }