void DownloadImages(IAsyncResult ar) { TransportClassImgUrl oTransportClassImgUrl = ar.AsyncState as TransportClassImgUrl; try { TransportClassMediaXml oTransportClassMediaXml = oTransportClassImgUrl.m_oTransportClassMediaXml; string sUrl = oTransportClassImgUrl.GetNextUrl(); if (null == sUrl) { oTransportClassMediaXml.m_oAsyncMediaXmlOperation.WriteMediaXmlBegin(Path.Combine(oTransportClassMediaXml.m_oInputCommand.id, @"media\media.xml"), oTransportClassMediaXml.m_aMediaXmlMapHash, WriteMediaXmlCallback, oTransportClassImgUrl); } else { int nMaxBytes = Convert.ToInt32(ConfigurationSettings.AppSettings["limits.image.size"] ?? "25000000"); if ("data:" == sUrl.Substring(0, "data:".Length)) { int nDelimiterIndex = sUrl.IndexOf(','); if (-1 != nDelimiterIndex) { byte[] aBuffer = System.Convert.FromBase64String(sUrl.Substring(nDelimiterIndex + 1)); if (aBuffer.Length <= nMaxBytes) ProcessImage(aBuffer, oTransportClassImgUrl); else oTransportClassImgUrl.SetErrorAndCallback(ErrorTypes.UploadContentLength); } else oTransportClassImgUrl.SetErrorAndCallback(ErrorTypes.UploadExtension); } else { AsyncWebRequestOperation oAsyncDownloadOperation = new AsyncWebRequestOperation(nMaxBytes); oTransportClassMediaXml.m_oDownloadOperation = oAsyncDownloadOperation; oTransportClassMediaXml.m_iAsyncResult = oAsyncDownloadOperation.RequestBegin(sUrl, "GET", null, null, DownloadDataCompleted, oTransportClassImgUrl); } } } catch { WriteOutputCommand(oTransportClassImgUrl, new OutputCommand(ErrorTypes.Upload)); } }
private void SendFileRequest(OutputSfc oOutputSfc, TransportClassSaveChanges2 oTransportClassSaveChanges2) { string sJson = new JavaScriptSerializer().Serialize(oOutputSfc); uint attempcount = uint.Parse(ConfigurationSettings.AppSettings["sfc.webrequest.attempcount"] ?? "1"); uint attempdelay = uint.Parse(ConfigurationSettings.AppSettings["sfc.webrequest.attempdelay"] ?? "0"); AsyncWebRequestOperation oAsyncWebRequestOperation = new AsyncWebRequestOperation(attempcount, attempdelay); oTransportClassSaveChanges2.m_oAsyncWebRequestOperation = oAsyncWebRequestOperation; _log.DebugFormat("TaskResultRemoveCallback4 url:{0}", oTransportClassSaveChanges2.m_sCallbackUrl); oTransportClassSaveChanges2.m_oAsyncWebRequestOperationResult = oAsyncWebRequestOperation.RequestBegin(oTransportClassSaveChanges2.m_sCallbackUrl, "POST", "application/json", Encoding.UTF8.GetBytes(sJson), RequestCallback2, oTransportClassSaveChanges2); }