Updated application.

This commit is contained in:
agolybev
2015-08-17 17:19:04 +03:00
parent cd34405d7e
commit a7b9b3a979
330 changed files with 81139 additions and 172701 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="ConvertService2" %>
<%@ WebHandler Language="C#" CodeBehind="ConvertService.ashx.cs" Class="DocService.ConvertService" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,329 +32,3 @@
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using System.Xml;
using System.Collections.Generic;
using System.Threading;
using FileConverterUtils2;
using log4net;
public class ConvertService2 : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(ConvertService2));
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 void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
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 GetOrCreateCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
TaskResultData oTaskResultData;
bool bCreate;
ErrorTypes eError = oTransportClass1.m_oTaskResult.GetOrCreateEnd(ar, out oTaskResultData, out bCreate);
if (ErrorTypes.NoError == eError)
{
if(bCreate)
{
InputParams oInputParams = oTransportClass1.m_oInputParams;
TaskQueueData oTaskQueueData = new TaskQueueData(oInputParams.m_sKey, oInputParams.m_nOutputtype, "output." + FileFormats.ToString(oInputParams.m_nOutputtype));
oTaskQueueData.m_sFromUrl = oInputParams.m_sUrl;
oTaskQueueData.m_sFromFormat = oInputParams.m_sFiletype;
if (null != oInputParams.m_sDelimiter && string.Empty != oInputParams.m_sDelimiter)
oTaskQueueData.m_nCsvDelimiter = int.Parse(oInputParams.m_sDelimiter);
else
oTaskQueueData.m_nCsvDelimiter = (int)CsvDelimiter.Comma;
if (null != oInputParams.m_sCodepage && string.Empty != oInputParams.m_sCodepage)
oTaskQueueData.m_nCsvTxtEncoding = int.Parse(oInputParams.m_sCodepage);
else
oTaskQueueData.m_nCsvTxtEncoding = Encoding.UTF8.CodePage;
if ("true" == oInputParams.m_sEmbeddedfonts)
oTaskQueueData.m_bEmbeddedFonts = true;
oTransportClass1.m_oTaskQueue.AddTaskBegin(oTaskQueueData, Priority.Low, AddTaskCallback, oTransportClass1);
}
else
CheckStatus(oTransportClass1, oTaskResultData);
}
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void AddTaskCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
ErrorTypes eError = oTransportClass1.m_oTaskQueue.AddTaskEnd(ar);
if (ErrorTypes.NoError == eError)
{
if (true == oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", "0", false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
}
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void CheckStatus(TransportClass1 oTransportClass1, TaskResultData oTaskResultData)
{
switch (oTaskResultData.eStatus)
{
case FileStatus.Ok:
string sFilename = HttpUtility.UrlEncode("output." + FileFormats.ToString(oTransportClass1.m_oInputParams.m_nOutputtype));
string sPath = HttpUtility.UrlEncode(Path.GetFileNameWithoutExtension(oTransportClass1.m_oInputParams.m_sKey) + "/output." + FileFormats.ToString(oTransportClass1.m_oInputParams.m_nOutputtype));
string sDeletePath = HttpUtility.UrlEncode(Path.GetFileNameWithoutExtension(oTransportClass1.m_oInputParams.m_sKey));
string sSiteUrl = UrlBuilder.UrlWithoutPath(oTransportClass1.m_oHttpContext.Request);
string strFileUrl = sSiteUrl + Constants.mc_sResourceServiceUrlRel + sPath + "&nocache=true" +"&deletepath=" + sDeletePath + "&filename=" + sFilename;
WriteOutputCommand(oTransportClass1, new OutputCommand(strFileUrl, "100", true, ErrorTypes.NoError));
break;
case FileStatus.WaitQueue:
if (oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", "0", false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
break;
case FileStatus.Convert:
if (oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", oTaskResultData.nStatusInfo.ToString(), false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
break;
case FileStatus.Err:
case FileStatus.ErrToReload:
AsyncClearCacheOperation oAsyncClearCacheOperation = new AsyncClearCacheOperation();
TransportClass2 oTransportClass2 = new TransportClass2(oTransportClass1, oAsyncClearCacheOperation, (ErrorTypes)oTaskResultData.nStatusInfo);
oAsyncClearCacheOperation.ClearCacheBegin(oTransportClass1.m_oInputParams.m_sKey, ClearCacheCallback, oTransportClass2);
break;
default:
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
break;
}
}
private void WaitEnd(TransportClass1 oTransportClass1)
{
try
{
Timer oTimer = new Timer(WaitEndTimerCallback, oTransportClass1, TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
oTransportClass1.m_oTimer = oTimer;
oTimer.Change(TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(-1));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void WaitEndTimerCallback(Object stateInfo)
{
TransportClass1 oTransportClass1 = stateInfo as TransportClass1;
try
{
if (null != oTransportClass1.m_oTimer)
oTransportClass1.m_oTimer.Dispose();
oTransportClass1.m_oTaskResult.GetBegin(oTransportClass1.m_oInputParams.m_sKey, WaitEndCallback, oTransportClass1);
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void WaitEndCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
TaskResultData oTaskResultData;
ErrorTypes eError = oTransportClass1.m_oTaskResult.GetEnd(ar, out oTaskResultData);
if (ErrorTypes.NoError == eError)
CheckStatus(oTransportClass1, oTaskResultData);
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void ClearCacheCallback(IAsyncResult ar)
{
TransportClass2 oTransportClass2 = ar.AsyncState as TransportClass2;
try
{
ErrorTypes eError = oTransportClass2.m_oAsyncClearCacheOperation.ClearCacheEnd(ar);
if (ErrorTypes.NoError == eError)
{
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, oTransportClass2.m_eError));
}
else
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private class TransportClass1 : TransportClassMainAshx
{
public ITaskResultInterface m_oTaskResult;
public CTaskQueue m_oTaskQueue;
public InputParams m_oInputParams;
public Timer m_oTimer;
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;
}
}
private class TransportClass2 : TransportClassMainAshx
{
public AsyncClearCacheOperation m_oAsyncClearCacheOperation;
public ErrorTypes m_eError;
public TransportClass2(TransportClassMainAshx oTransportClassMainAshx, AsyncClearCacheOperation oAsyncClearCacheOperation, ErrorTypes eError)
: base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback)
{
m_oAsyncClearCacheOperation = oAsyncClearCacheOperation;
m_eError = eError;
}
}
private class InputParams
{
public string m_sKey;
public string m_svKey;
public string m_sUrl;
public string m_sTitle;
public string m_sFiletype;
public int m_nOutputtype;
public bool m_bAsyncConvert;
public string m_sEmbeddedfonts;
public string m_sCodepage;
public string m_sDelimiter;
}
private class OutputCommand
{
public string m_sFileUrl;
public string m_sPercent;
public bool? m_bIsEndConvert;
public ErrorTypes m_eError;
public OutputCommand(string strFileUrl, string strPercent, bool? bIsEndConvert, ErrorTypes eError)
{
m_sFileUrl = strFileUrl;
m_sPercent = strPercent;
m_bIsEndConvert = bIsEndConvert;
m_eError = eError;
}
}
}

View File

@@ -0,0 +1,360 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using System.Xml;
using System.Collections.Generic;
using System.Threading;
using FileConverterUtils2;
using log4net;
namespace DocService
{
public class ConvertService : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(ConvertService));
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 void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
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 GetOrCreateCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
TaskResultData oTaskResultData;
bool bCreate;
ErrorTypes eError = oTransportClass1.m_oTaskResult.GetOrCreateEnd(ar, out oTaskResultData, out bCreate);
if (ErrorTypes.NoError == eError)
{
if(bCreate)
{
InputParams oInputParams = oTransportClass1.m_oInputParams;
TaskQueueData oTaskQueueData = new TaskQueueData(oInputParams.m_sKey, oInputParams.m_nOutputtype, "output." + FileFormats.ToString(oInputParams.m_nOutputtype));
oTaskQueueData.m_sFromUrl = oInputParams.m_sUrl;
oTaskQueueData.m_sFromFormat = oInputParams.m_sFiletype;
if (null != oInputParams.m_sDelimiter && string.Empty != oInputParams.m_sDelimiter)
oTaskQueueData.m_nCsvDelimiter = int.Parse(oInputParams.m_sDelimiter);
else
oTaskQueueData.m_nCsvDelimiter = (int)CsvDelimiter.Comma;
if (null != oInputParams.m_sCodepage && string.Empty != oInputParams.m_sCodepage)
oTaskQueueData.m_nCsvTxtEncoding = int.Parse(oInputParams.m_sCodepage);
else
oTaskQueueData.m_nCsvTxtEncoding = Encoding.UTF8.CodePage;
if ("true" == oInputParams.m_sEmbeddedfonts)
oTaskQueueData.m_bEmbeddedFonts = true;
oTransportClass1.m_oTaskQueue.AddTaskBegin(oTaskQueueData, Priority.Low, AddTaskCallback, oTransportClass1);
}
else
CheckStatus(oTransportClass1, oTaskResultData);
}
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void AddTaskCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
ErrorTypes eError = oTransportClass1.m_oTaskQueue.AddTaskEnd(ar);
if (ErrorTypes.NoError == eError)
{
if (true == oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", "0", false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
}
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void CheckStatus(TransportClass1 oTransportClass1, TaskResultData oTaskResultData)
{
switch (oTaskResultData.eStatus)
{
case FileStatus.Ok:
string sFilename = HttpUtility.UrlEncode("output." + FileFormats.ToString(oTransportClass1.m_oInputParams.m_nOutputtype));
string sPath = HttpUtility.UrlEncode(Path.GetFileNameWithoutExtension(oTransportClass1.m_oInputParams.m_sKey) + "/output." + FileFormats.ToString(oTransportClass1.m_oInputParams.m_nOutputtype));
string sDeletePath = HttpUtility.UrlEncode(Path.GetFileNameWithoutExtension(oTransportClass1.m_oInputParams.m_sKey));
string sSiteUrl = UrlBuilder.UrlWithoutPath(oTransportClass1.m_oHttpContext.Request);
string strFileUrl = sSiteUrl + Constants.mc_sResourceServiceUrlRel + sPath + "&nocache=true" +"&deletepath=" + sDeletePath + "&filename=" + sFilename;
WriteOutputCommand(oTransportClass1, new OutputCommand(strFileUrl, "100", true, ErrorTypes.NoError));
break;
case FileStatus.WaitQueue:
if (oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", "0", false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
break;
case FileStatus.Convert:
if (oTransportClass1.m_oInputParams.m_bAsyncConvert)
WriteOutputCommand(oTransportClass1, new OutputCommand("", oTaskResultData.nStatusInfo.ToString(), false, ErrorTypes.NoError));
else
WaitEnd(oTransportClass1);
break;
case FileStatus.Err:
case FileStatus.ErrToReload:
AsyncClearCacheOperation oAsyncClearCacheOperation = new AsyncClearCacheOperation();
TransportClass2 oTransportClass2 = new TransportClass2(oTransportClass1, oAsyncClearCacheOperation, (ErrorTypes)oTaskResultData.nStatusInfo);
oAsyncClearCacheOperation.ClearCacheBegin(oTransportClass1.m_oInputParams.m_sKey, ClearCacheCallback, oTransportClass2);
break;
default:
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
break;
}
}
private void WaitEnd(TransportClass1 oTransportClass1)
{
try
{
Timer oTimer = new Timer(WaitEndTimerCallback, oTransportClass1, TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
oTransportClass1.m_oTimer = oTimer;
oTimer.Change(TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(-1));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void WaitEndTimerCallback(Object stateInfo)
{
TransportClass1 oTransportClass1 = stateInfo as TransportClass1;
try
{
if (null != oTransportClass1.m_oTimer)
oTransportClass1.m_oTimer.Dispose();
oTransportClass1.m_oTaskResult.GetBegin(oTransportClass1.m_oInputParams.m_sKey, WaitEndCallback, oTransportClass1);
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void WaitEndCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
TaskResultData oTaskResultData;
ErrorTypes eError = oTransportClass1.m_oTaskResult.GetEnd(ar, out oTaskResultData);
if (ErrorTypes.NoError == eError)
CheckStatus(oTransportClass1, oTaskResultData);
else
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass1, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private void ClearCacheCallback(IAsyncResult ar)
{
TransportClass2 oTransportClass2 = ar.AsyncState as TransportClass2;
try
{
ErrorTypes eError = oTransportClass2.m_oAsyncClearCacheOperation.ClearCacheEnd(ar);
if (ErrorTypes.NoError == eError)
{
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, oTransportClass2.m_eError));
}
else
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, eError));
}
catch
{
WriteOutputCommand(oTransportClass2, new OutputCommand(null, null, null, ErrorTypes.Unknown));
}
}
private class TransportClass1 : TransportClassMainAshx
{
public ITaskResultInterface m_oTaskResult;
public CTaskQueue m_oTaskQueue;
public InputParams m_oInputParams;
public Timer m_oTimer;
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;
}
}
private class TransportClass2 : TransportClassMainAshx
{
public AsyncClearCacheOperation m_oAsyncClearCacheOperation;
public ErrorTypes m_eError;
public TransportClass2(TransportClassMainAshx oTransportClassMainAshx, AsyncClearCacheOperation oAsyncClearCacheOperation, ErrorTypes eError)
: base(oTransportClassMainAshx.m_oHttpContext, oTransportClassMainAshx.m_oAsyncCallback)
{
m_oAsyncClearCacheOperation = oAsyncClearCacheOperation;
m_eError = eError;
}
}
private class InputParams
{
public string m_sKey;
public string m_svKey;
public string m_sUrl;
public string m_sTitle;
public string m_sFiletype;
public int m_nOutputtype;
public bool m_bAsyncConvert;
public string m_sEmbeddedfonts;
public string m_sCodepage;
public string m_sDelimiter;
}
private class OutputCommand
{
public string m_sFileUrl;
public string m_sPercent;
public bool? m_bIsEndConvert;
public ErrorTypes m_eError;
public OutputCommand(string strFileUrl, string strPercent, bool? bIsEndConvert, ErrorTypes eError)
{
m_sFileUrl = strFileUrl;
m_sPercent = strPercent;
m_bIsEndConvert = bIsEndConvert;
m_eError = eError;
}
}
}
}

View File

@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6060D154-28A8-4E13-88A8-B82B02FDCA44}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DocService</RootNamespace>
<AssemblyName>DocService</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASC.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\ASC.Core.Common.dll</HintPath>
</Reference>
<Reference Include="AWSSDK, Version=1.5.2.2, Culture=neutral, PublicKeyToken=cd2d24cd2bace800, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\AWSSDK.dll</HintPath>
</Reference>
<Reference Include="Enyim.Caching, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\Enyim.Caching.dll</HintPath>
</Reference>
<Reference Include="FileConverterUtils2, Version=1.0.0.131, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\FileConverterUtils2.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip.Reduced, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\Ionic.Zip.Reduced.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="OpenMcdf, Version=1.5.4.22637, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin\OpenMcdf.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="Default.aspx" />
<Content Include="Global.asax" />
<None Include="Properties\PublishProfiles\Deploy.pubxml" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="App_Code\DocServiceUtils.cs" />
<Compile Include="App_Code\ZBase32Encoder.cs" />
<Compile Include="CanvasService.ashx.cs">
<DependentUpon>CanvasService.ashx</DependentUpon>
</Compile>
<Compile Include="ConvertService.ashx.cs">
<DependentUpon>ConvertService.ashx</DependentUpon>
</Compile>
<Compile Include="fileDownloader.ashx.cs">
<DependentUpon>fileDownloader.ashx</DependentUpon>
</Compile>
<Compile Include="FileUploader.ashx.cs">
<DependentUpon>FileUploader.ashx</DependentUpon>
</Compile>
<Compile Include="FontService.ashx.cs">
<DependentUpon>FontService.ashx</DependentUpon>
</Compile>
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceService.ashx.cs">
<DependentUpon>ResourceService.ashx</DependentUpon>
</Compile>
<Compile Include="TrackingService.ashx.cs">
<DependentUpon>TrackingService.ashx</DependentUpon>
</Compile>
<Compile Include="UploadService.ashx.cs">
<DependentUpon>UploadService.ashx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="CanvasService.ashx" />
<Content Include="ConvertService.ashx" />
<Content Include="fileDownloader.ashx" />
<Content Include="FileUploader.ashx" />
<Content Include="FontService.ashx" />
<Content Include="ResourceService.ashx" />
<Content Include="TrackingService.ashx" />
<Content Include="UploadService.ashx" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>54956</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:54956/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="FileUploader" %>
<%@ WebHandler Language="C#" CodeBehind="FileUploader.ashx.cs" Class="DocService.FileUploader" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,174 +32,3 @@
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Xml;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Collections.Specialized;
using FileConverterUtils2;
using log4net;
public class FileUploader : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(FileUploader));
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
{
bool bStartAsync = false;
ErrorTypes eError = ErrorTypes.Unknown;
try
{
_log.Info("Starting process request...");
_log.Info(context.Request.QueryString.ToString());
string vKey = context.Request.QueryString["vkey"];
string sKey = context.Request.QueryString["key"];
if (null != sKey && false == string.IsNullOrEmpty(sKey))
{
eError = ErrorTypes.NoError;
if (ErrorTypes.NoError == eError)
{
bStartAsync = true;
Storage oStorage = new Storage();
string sTempKey = "temp_" + sKey;
string sFilename = sKey + ".tmp";
string sPath = sTempKey + "/" + sFilename;
AsyncContextReadOperation asynch = new AsyncContextReadOperation();
TransportClass oTransportClass = new TransportClass(context, cb, oStorage, asynch, sPath, sTempKey, sFilename);
asynch.ReadContextBegin(context.Request.InputStream, ReadContextCallback, oTransportClass);
}
}
}
catch(Exception e)
{
eError = ErrorTypes.Unknown;
_log.Error(context.Request.QueryString.ToString());
_log.Error("Exeption: ", e);
}
finally
{
if (ErrorTypes.NoError != eError)
writeXml(context, null, null, null, eError);
}
TransportClass oTempTransportClass = new TransportClass(context, cb, null, null, null, null, null);
if (false == bStartAsync)
cb(new AsyncOperationData(oTempTransportClass));
return new AsyncOperationData(oTempTransportClass);
}
public void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable {
get {
return false;
}
}
private void ReadContextCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
try
{
oTransportClass.m_oAsyncContextRead.ReadContextEnd(result);
oTransportClass.m_oAsyncContextRead.m_aOutput.Position = 0;
oTransportClass.m_oStorage.WriteFileBegin(oTransportClass.m_sPath, oTransportClass.m_oAsyncContextRead.m_aOutput, WriteFileCallback, oTransportClass);
}
catch
{
writeXml(oTransportClass.m_oContext, null, null, null, ErrorTypes.StorageWrite);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
private void WriteFileCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
try
{
int nWriteBytes;
ErrorTypes eError = oTransportClass.m_oStorage.WriteFileEnd(result, out nWriteBytes);
if (ErrorTypes.NoError == eError)
{
string sSiteUrl = UrlBuilder.UrlWithoutPath(oTransportClass.m_oContext.Request);
string sFileUrl = sSiteUrl + Constants.mc_sResourceServiceUrlRel + HttpUtility.UrlEncode(oTransportClass.m_sPath) + "&nocache=true" + "&deletepath=" + HttpUtility.UrlEncode(oTransportClass.m_sDeletePath) + "&filename=" + HttpUtility.UrlEncode(oTransportClass.m_sFilename);
writeXml(oTransportClass.m_oContext, sFileUrl, "100", true, null);
}
else
writeXml(oTransportClass.m_oContext, null, null, null, eError);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
catch
{
writeXml(oTransportClass.m_oContext, null, null, null, ErrorTypes.StorageWrite);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
private void writeXml(HttpContext context, string strFileUrl, string strPercent, bool? bIsEndConvert, ErrorTypes? eError)
{
XmlDocument oDoc = new XmlDocument();
XmlElement oRootElem = oDoc.CreateElement("FileResult");
oDoc.AppendChild(oRootElem);
if (null != strFileUrl)
{
XmlElement oFileUrl = oDoc.CreateElement("FileUrl");
oFileUrl.InnerText = strFileUrl;
oRootElem.AppendChild(oFileUrl);
}
if (null != strPercent)
{
XmlElement oPercent = oDoc.CreateElement("Percent");
oPercent.InnerText = strPercent;
oRootElem.AppendChild(oPercent);
}
if (bIsEndConvert.HasValue)
{
XmlElement oEndConvert = oDoc.CreateElement("EndConvert");
oEndConvert.InnerText = bIsEndConvert.Value.ToString();
oRootElem.AppendChild(oEndConvert);
}
if (eError.HasValue)
{
XmlElement oError = oDoc.CreateElement("Error");
oError.InnerText = Utils.mapAscServerErrorToOldError(eError.Value).ToString();
oRootElem.AppendChild(oError);
}
oDoc.Save(context.Response.Output);
context.Response.ContentType = "text/xml";
}
private class TransportClass
{
public HttpContext m_oContext;
public AsyncCallback m_oCallback;
public Storage m_oStorage;
public AsyncContextReadOperation m_oAsyncContextRead;
public string m_sPath;
public string m_sDeletePath;
public string m_sFilename;
public TransportClass(HttpContext oContext, AsyncCallback oCallback, Storage oStorage, AsyncContextReadOperation oAsyncContextRead, string sPath, string sDeletePath, string sFilename)
{
m_oContext = oContext;
m_oCallback = oCallback;
m_oStorage = oStorage;
m_oAsyncContextRead = oAsyncContextRead;
m_sPath = sPath;
m_sDeletePath = sDeletePath;
m_sFilename = sFilename;
}
}
}

View File

@@ -0,0 +1,205 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Xml;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Collections.Specialized;
using FileConverterUtils2;
using log4net;
namespace DocService
{
public class FileUploader : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(FileUploader));
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
{
bool bStartAsync = false;
ErrorTypes eError = ErrorTypes.Unknown;
try
{
_log.Info("Starting process request...");
_log.Info(context.Request.QueryString.ToString());
string vKey = context.Request.QueryString["vkey"];
string sKey = context.Request.QueryString["key"];
if (null != sKey && false == string.IsNullOrEmpty(sKey))
{
eError = ErrorTypes.NoError;
if (ErrorTypes.NoError == eError)
{
bStartAsync = true;
Storage oStorage = new Storage();
string sTempKey = "temp_" + sKey;
string sFilename = sKey + ".tmp";
string sPath = sTempKey + "/" + sFilename;
AsyncContextReadOperation asynch = new AsyncContextReadOperation();
TransportClass oTransportClass = new TransportClass(context, cb, oStorage, asynch, sPath, sTempKey, sFilename);
asynch.ReadContextBegin(context.Request.InputStream, ReadContextCallback, oTransportClass);
}
}
}
catch(Exception e)
{
eError = ErrorTypes.Unknown;
_log.Error(context.Request.QueryString.ToString());
_log.Error("Exeption: ", e);
}
finally
{
if (ErrorTypes.NoError != eError)
writeXml(context, null, null, null, eError);
}
TransportClass oTempTransportClass = new TransportClass(context, cb, null, null, null, null, null);
if (false == bStartAsync)
cb(new AsyncOperationData(oTempTransportClass));
return new AsyncOperationData(oTempTransportClass);
}
public void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable {
get {
return false;
}
}
private void ReadContextCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
try
{
oTransportClass.m_oAsyncContextRead.ReadContextEnd(result);
oTransportClass.m_oAsyncContextRead.m_aOutput.Position = 0;
oTransportClass.m_oStorage.WriteFileBegin(oTransportClass.m_sPath, oTransportClass.m_oAsyncContextRead.m_aOutput, WriteFileCallback, oTransportClass);
}
catch
{
writeXml(oTransportClass.m_oContext, null, null, null, ErrorTypes.StorageWrite);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
private void WriteFileCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
try
{
int nWriteBytes;
ErrorTypes eError = oTransportClass.m_oStorage.WriteFileEnd(result, out nWriteBytes);
if (ErrorTypes.NoError == eError)
{
string sSiteUrl = UrlBuilder.UrlWithoutPath(oTransportClass.m_oContext.Request);
string sFileUrl = sSiteUrl + Constants.mc_sResourceServiceUrlRel + HttpUtility.UrlEncode(oTransportClass.m_sPath) + "&nocache=true" + "&deletepath=" + HttpUtility.UrlEncode(oTransportClass.m_sDeletePath) + "&filename=" + HttpUtility.UrlEncode(oTransportClass.m_sFilename);
writeXml(oTransportClass.m_oContext, sFileUrl, "100", true, null);
}
else
writeXml(oTransportClass.m_oContext, null, null, null, eError);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
catch
{
writeXml(oTransportClass.m_oContext, null, null, null, ErrorTypes.StorageWrite);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
private void writeXml(HttpContext context, string strFileUrl, string strPercent, bool? bIsEndConvert, ErrorTypes? eError)
{
XmlDocument oDoc = new XmlDocument();
XmlElement oRootElem = oDoc.CreateElement("FileResult");
oDoc.AppendChild(oRootElem);
if (null != strFileUrl)
{
XmlElement oFileUrl = oDoc.CreateElement("FileUrl");
oFileUrl.InnerText = strFileUrl;
oRootElem.AppendChild(oFileUrl);
}
if (null != strPercent)
{
XmlElement oPercent = oDoc.CreateElement("Percent");
oPercent.InnerText = strPercent;
oRootElem.AppendChild(oPercent);
}
if (bIsEndConvert.HasValue)
{
XmlElement oEndConvert = oDoc.CreateElement("EndConvert");
oEndConvert.InnerText = bIsEndConvert.Value.ToString();
oRootElem.AppendChild(oEndConvert);
}
if (eError.HasValue)
{
XmlElement oError = oDoc.CreateElement("Error");
oError.InnerText = Utils.mapAscServerErrorToOldError(eError.Value).ToString();
oRootElem.AppendChild(oError);
}
oDoc.Save(context.Response.Output);
context.Response.ContentType = "text/xml";
}
private class TransportClass
{
public HttpContext m_oContext;
public AsyncCallback m_oCallback;
public Storage m_oStorage;
public AsyncContextReadOperation m_oAsyncContextRead;
public string m_sPath;
public string m_sDeletePath;
public string m_sFilename;
public TransportClass(HttpContext oContext, AsyncCallback oCallback, Storage oStorage, AsyncContextReadOperation oAsyncContextRead, string sPath, string sDeletePath, string sFilename)
{
m_oContext = oContext;
m_oCallback = oCallback;
m_oStorage = oStorage;
m_oAsyncContextRead = oAsyncContextRead;
m_sPath = sPath;
m_sDeletePath = sDeletePath;
m_sFilename = sFilename;
}
}
}
}

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" CodeBehind="App_Code/FontService.ashx.cs" Class="FontService" %>
<%@ WebHandler Language="C#" CodeBehind="FontService.ashx.cs" Class="DocService.FontService" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -31,3 +31,4 @@
*
*/

View File

@@ -45,6 +45,8 @@ using FileConverterUtils2;
using log4net;
namespace DocService
{
public class FontServiceRoute : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
@@ -358,4 +360,5 @@ public class FontService : IHttpAsyncHandler
m_sFontNameDecoded = sFontNameDecoded;
}
}
}
}

View File

@@ -1,101 +1 @@
<%@ Application Language="C#" %>
<%@ Assembly Name="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading"%>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="log4net.Config" %>
<%@ Import Namespace="FileConverterUtils2" %>
<script runat="server">
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
static public Object lockThis = new Object();
public static void RegisterRoutes(RouteCollection routes)
{
string sRoute = ConfigurationSettings.AppSettings["fonts.route"] ?? "fonts/";
routes.Add(new Route(sRoute + "native/{fontname}", new FontServiceRoute()));
routes.Add(new Route(sRoute + "js/{fontname}", new FontServiceRoute()));
routes.Add(new Route(sRoute + "odttf/{fontname}", new FontServiceRoute()));
}
void Application_Start(object sender, EventArgs e)
{
System.Diagnostics.Debug.Print("Application_Start() fired!" + sender.ToString());
try
{
XmlConfigurator.Configure();
}
catch(Exception ex)
{
}
RegisterRoutes(RouteTable.Routes);
}
void Application_End(object sender, EventArgs e)
{
System.Diagnostics.Debug.Print("Application_End() fired!" + sender.ToString());
}
void Application_Error(object sender, EventArgs e)
{
}
void Session_Start(object sender, EventArgs e)
{
}
void Session_End(object sender, EventArgs e)
{
}
void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
}
void Application_BeginRequest(Object sender, EventArgs e)
{
}
</script>
<%@ Application Codebehind="Global.asax.cs" Inherits="DocService.Global" Language="C#" %>

103
DocService/Global.asax.cs Normal file
View File

@@ -0,0 +1,103 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.IO;
using System.Threading;
using System.Collections.Generic;
using System.Web.Routing;
using log4net.Config;
using FileConverterUtils2;
using System.Configuration;
using System.Web;
namespace DocService
{
public class Global : System.Web.HttpApplication
{
static public Object lockThis = new Object();
public static void RegisterRoutes(RouteCollection routes)
{
string sRoute = ConfigurationSettings.AppSettings["fonts.route"] ?? "fonts/";
routes.Add(new Route(sRoute + "native/{fontname}", new FontServiceRoute()));
routes.Add(new Route(sRoute + "js/{fontname}", new FontServiceRoute()));
routes.Add(new Route(sRoute + "odttf/{fontname}", new FontServiceRoute()));
}
void Application_Start(object sender, EventArgs e)
{
System.Diagnostics.Debug.Print("Application_Start() fired!" + sender.ToString());
try
{
XmlConfigurator.Configure();
}
catch(Exception ex)
{
}
RegisterRoutes(RouteTable.Routes);
}
void Application_End(object sender, EventArgs e)
{
System.Diagnostics.Debug.Print("Application_End() fired!" + sender.ToString());
}
void Application_Error(object sender, EventArgs e)
{
}
void Session_Start(object sender, EventArgs e)
{
}
void Session_End(object sender, EventArgs e)
{
}
void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
}
void Application_BeginRequest(Object sender, EventArgs e)
{
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("DocService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DocService")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("868e7a06-b2c6-4e64-b900-b63bc55098ba")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="ResourceService" %>
<%@ WebHandler Language="C#" CodeBehind="ResourceService.ashx.cs" Class="DocService.ResourceService" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,325 +32,3 @@
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using FileConverterUtils2;
using log4net;
public class ResourceService : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(ResourceService));
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 void EndProcessRequest(IAsyncResult result)
{
return;
}
private void GetFileInfoCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
bool bStartAsync = false;
try
{
string sPath = oTransportClass.m_sPath;
Storage oStorage = oTransportClass.m_oStorage;
StorageFileInfo oStorageFileInfo;
if (ErrorTypes.NoError == oStorage.GetFileInfoEnd(result, out oStorageFileInfo) && null != oStorageFileInfo)
{
string sETag = oStorageFileInfo.m_oLastModify.Ticks.ToString("x");
DateTime oLastModified = oStorageFileInfo.m_oLastModify;
DateTime oDateTimeUtcNow = DateTime.UtcNow;
_log.InfoFormat("oLastModified = {0}", oLastModified);
_log.InfoFormat("oDateTimeUtcNow = {0}", oDateTimeUtcNow);
if (oLastModified.CompareTo(oDateTimeUtcNow) > 0)
{
_log.DebugFormat("LastModifiedTimeStamp changed from {0} to {1}", oLastModified, oDateTimeUtcNow);
oLastModified = oDateTimeUtcNow;
}
string sRequestIfModifiedSince = context.Request.Headers["If-Modified-Since"];
string sRequestETag = context.Request.Headers["If-None-Match"];
bool bNoModify = false;
if (false == string.IsNullOrEmpty(sRequestETag) || false == string.IsNullOrEmpty(sRequestIfModifiedSince))
{
bool bRequestETag = true;
if (false == string.IsNullOrEmpty(sRequestETag) && sRequestETag != sETag)
bRequestETag = false;
bool bRequestIfModifiedSince = true;
if (false == string.IsNullOrEmpty(sRequestIfModifiedSince))
{
try
{
DateTime oRequestIfModifiedSince = DateTime.ParseExact(sRequestIfModifiedSince, "R", System.Globalization.CultureInfo.InvariantCulture);
if ((oRequestIfModifiedSince - oLastModified).TotalSeconds > 1)
bRequestIfModifiedSince = false;
}
catch
{
bRequestIfModifiedSince = false;
}
}
if (bRequestETag && bRequestIfModifiedSince)
{
context.Response.StatusCode = (int)HttpStatusCode.NotModified;
bNoModify = true;
}
}
if (false == bNoModify)
{
context.Response.Cache.SetETag(sETag);
context.Response.Cache.SetLastModified(oLastModified.ToLocalTime());
oStorage.ReadFileBegin(sPath, context.Response.OutputStream, ReadFileCallback, oTransportClass);
bStartAsync = true;
}
}
else
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
}
catch (Exception e)
{
_log.Error("Exception catched in GetFileInfoCallback:", e);
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
if (!bStartAsync)
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
private void ReadFileCallback(IAsyncResult result)
{
SendResponse(result);
DeletePath(result);
}
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));
}
}
private void SendResponse(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
try
{
Storage oStorage = oTransportClass.m_oStorage;
if (null == oStorage)
{
throw new NullReferenceException();
}
int nReadWriteBytes = 0;
ErrorTypes eResult = oStorage.ReadFileEnd(result, out nReadWriteBytes);
if (ErrorTypes.NoError == eResult)
{
context.Response.AppendHeader("Content-Length", nReadWriteBytes.ToString());
context.Response.StatusCode = (int)HttpStatusCode.OK;
}
}
catch (HttpException httpEx)
{
_log.Error("HttpException catched in SendResponse:", httpEx);
}
catch (Exception e)
{
_log.Error("Exception catched in SendResponse:", e);
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
try
{
if (context.Response.IsClientConnected)
{
context.Response.Flush();
}
}
catch (Exception e)
{
_log.Error("Exception catched in SendResponse, while response end:", e);
}
}
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 RemoveFileCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
try
{
Storage oStorage = oTransportClass.m_oStorage;
if (null != oStorage)
oStorage.RemovePathEnd(result);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
catch(Exception e)
{
_log.Error("Exception catched in RemoveFileCallback:", e);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
private class TransportClass
{
public HttpContext m_oContext;
public AsyncCallback m_oCallback;
public Storage m_oStorage;
public ITaskResultInterface m_oTaskResult;
public string m_sPath;
public string m_sDeletePath;
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;
}
}
}

View File

@@ -0,0 +1,355 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using FileConverterUtils2;
using log4net;
namespace DocService
{
public class ResourceService : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(ResourceService));
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 void EndProcessRequest(IAsyncResult result)
{
return;
}
private void GetFileInfoCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
bool bStartAsync = false;
try
{
string sPath = oTransportClass.m_sPath;
Storage oStorage = oTransportClass.m_oStorage;
StorageFileInfo oStorageFileInfo;
if (ErrorTypes.NoError == oStorage.GetFileInfoEnd(result, out oStorageFileInfo) && null != oStorageFileInfo)
{
string sETag = oStorageFileInfo.m_oLastModify.Ticks.ToString("x");
DateTime oLastModified = oStorageFileInfo.m_oLastModify;
DateTime oDateTimeUtcNow = DateTime.UtcNow;
_log.InfoFormat("oLastModified = {0}", oLastModified);
_log.InfoFormat("oDateTimeUtcNow = {0}", oDateTimeUtcNow);
if (oLastModified.CompareTo(oDateTimeUtcNow) > 0)
{
_log.DebugFormat("LastModifiedTimeStamp changed from {0} to {1}", oLastModified, oDateTimeUtcNow);
oLastModified = oDateTimeUtcNow;
}
string sRequestIfModifiedSince = context.Request.Headers["If-Modified-Since"];
string sRequestETag = context.Request.Headers["If-None-Match"];
bool bNoModify = false;
if (false == string.IsNullOrEmpty(sRequestETag) || false == string.IsNullOrEmpty(sRequestIfModifiedSince))
{
bool bRequestETag = true;
if (false == string.IsNullOrEmpty(sRequestETag) && sRequestETag != sETag)
bRequestETag = false;
bool bRequestIfModifiedSince = true;
if (false == string.IsNullOrEmpty(sRequestIfModifiedSince))
{
try
{
DateTime oRequestIfModifiedSince = DateTime.ParseExact(sRequestIfModifiedSince, "R", System.Globalization.CultureInfo.InvariantCulture);
if ((oRequestIfModifiedSince - oLastModified).TotalSeconds > 1)
bRequestIfModifiedSince = false;
}
catch
{
bRequestIfModifiedSince = false;
}
}
if (bRequestETag && bRequestIfModifiedSince)
{
context.Response.StatusCode = (int)HttpStatusCode.NotModified;
bNoModify = true;
}
}
if (false == bNoModify)
{
context.Response.Cache.SetETag(sETag);
context.Response.Cache.SetLastModified(oLastModified.ToLocalTime());
oStorage.ReadFileBegin(sPath, context.Response.OutputStream, ReadFileCallback, oTransportClass);
bStartAsync = true;
}
}
else
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
}
catch (Exception e)
{
_log.Error("Exception catched in GetFileInfoCallback:", e);
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
if (!bStartAsync)
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
private void ReadFileCallback(IAsyncResult result)
{
SendResponse(result);
DeletePath(result);
}
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));
}
}
private void SendResponse(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
try
{
Storage oStorage = oTransportClass.m_oStorage;
if (null == oStorage)
{
throw new NullReferenceException();
}
int nReadWriteBytes = 0;
ErrorTypes eResult = oStorage.ReadFileEnd(result, out nReadWriteBytes);
if (ErrorTypes.NoError == eResult)
{
context.Response.AppendHeader("Content-Length", nReadWriteBytes.ToString());
context.Response.StatusCode = (int)HttpStatusCode.OK;
}
}
catch (HttpException httpEx)
{
_log.Error("HttpException catched in SendResponse:", httpEx);
}
catch (Exception e)
{
_log.Error("Exception catched in SendResponse:", e);
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
try
{
if (context.Response.IsClientConnected)
{
context.Response.Flush();
}
}
catch (Exception e)
{
_log.Error("Exception catched in SendResponse, while response end:", e);
}
}
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 RemoveFileCallback(IAsyncResult result)
{
TransportClass oTransportClass = result.AsyncState as TransportClass;
HttpContext context = oTransportClass.m_oContext;
try
{
Storage oStorage = oTransportClass.m_oStorage;
if (null != oStorage)
oStorage.RemovePathEnd(result);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
catch(Exception e)
{
_log.Error("Exception catched in RemoveFileCallback:", e);
oTransportClass.m_oCallback(new AsyncOperationData(oTransportClass));
}
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
private class TransportClass
{
public HttpContext m_oContext;
public AsyncCallback m_oCallback;
public Storage m_oStorage;
public ITaskResultInterface m_oTaskResult;
public string m_sPath;
public string m_sDeletePath;
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;
}
}
}
}

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="TrackingService" %>
<%@ WebHandler Language="C#" CodeBehind="TrackingService.ashx.cs" Class="DocService.TrackingService" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,24 +32,3 @@
*/
using System;
using System.Web;
using System.Xml;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using FileConverterUtils2;
public class TrackingService : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
}
public bool IsReusable {
get {
return false;
}
}
}

View File

@@ -0,0 +1,55 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Web;
using System.Xml;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using FileConverterUtils2;
namespace DocService
{
public class TrackingService : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
}
public bool IsReusable {
get {
return false;
}
}
}
}

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="UploadService" %>
<%@ WebHandler Language="C#" CodeBehind="UploadService.ashx.cs" Class="DocService.UploadService" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,332 +32,3 @@
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Collections.Specialized;
using FileConverterUtils2;
using log4net;
public class UploadService : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(UploadService));
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 void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
#region HelpFunctions
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));
}
#endregion
#region Callbacks
private void GetMediaXmlCallbackProcess(TransportClass1 oTransportClass1, Dictionary<string, string> aMediaXmlMapHash, Dictionary<string, string> aMediaXmlMapFilename)
{
AsyncContextReadOperation oAsyncContextReadOperation = new AsyncContextReadOperation();
TransportClass2 oTransportClass2 = new TransportClass2(oTransportClass1, aMediaXmlMapHash, aMediaXmlMapFilename, oAsyncContextReadOperation);
HttpPostedFile oCurrentFile = (HttpPostedFile)oTransportClass1.m_oFiles[(string)oTransportClass1.m_oFilesEnumerator.Current];
oCurrentFile.InputStream.Position = 0;
oAsyncContextReadOperation.ReadContextBegin(oCurrentFile.InputStream, ReadContextCallback, oTransportClass2);
}
private void GetMediaXmlCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
Dictionary<string, string> aMediaXmlMapHash;
Dictionary<string, string> aMediaXmlMapFilename;
ErrorTypes eError = oTransportClass1.m_oAsyncMediaXmlOperation.GetMediaXmlEnd(ar, out aMediaXmlMapHash, out aMediaXmlMapFilename);
if (ErrorTypes.NoError == eError && oTransportClass1.m_oFilesEnumerator.MoveNext())
{
GetMediaXmlCallbackProcess(oTransportClass1, aMediaXmlMapHash, aMediaXmlMapFilename);
}
else
WriteToResponse(oTransportClass1, eError, null, oTransportClass1.m_aInputParams);
}
catch(Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass1, ErrorTypes.Upload, null, oTransportClass1.m_aInputParams);
}
}
private void ReadContextCallback(IAsyncResult ar)
{
TransportClass2 oTransportClass2 = ar.AsyncState as TransportClass2;
try
{
ErrorTypes eError = oTransportClass2.m_oAsyncContextReadOperation.ReadContextEnd(ar);
if (ErrorTypes.NoError == eError)
{
HttpPostedFile oCurrentFile = ((HttpPostedFile)oTransportClass2.m_oFiles[(string)oTransportClass2.m_oFilesEnumerator.Current]);
oCurrentFile.InputStream.Position = 0;
Stream oImageStream = oCurrentFile.InputStream;
byte[] aBuffer = oTransportClass2.m_oAsyncContextReadOperation.m_aOutput.ToArray();
int nImageFormat = FormatChecker.GetFileFormat(aBuffer);
string sSupportedFormats = ConfigurationSettings.AppSettings["limits.image.types.upload"] ?? "jpg";
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE & nImageFormat) && -1 != sSupportedFormats.IndexOf(FileFormats.ToString(nImageFormat)))
{
if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_GIF == nImageFormat || FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_ICO == nImageFormat)
{
byte[] aNewBuffer;
if (Utils.ConvertGifIcoToPng(aBuffer, nImageFormat, out aNewBuffer))
{
nImageFormat = FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
aBuffer = aNewBuffer;
oImageStream = new MemoryStream(aBuffer);
}
}
string sImageHash = null;
using (MemoryStream ms = new MemoryStream(aBuffer))
sImageHash = Utils.getMD5HexString(ms);
string sFileName;
if (oTransportClass2.m_oMediaXmlMapHash.TryGetValue(sImageHash, out sFileName))
{
ImageUrlProcess(oTransportClass2, Constants.mc_sResourceServiceUrlRel + Path.Combine(oTransportClass2.m_sKey, @"media\" + sFileName).Replace('\\', '/'));
}
else
{
string sSearchName = "image";
List<int> aIndexes = new List<int>();
foreach (KeyValuePair<string, string> kvp in oTransportClass2.m_oMediaXmlMapFilename)
{
string sFilename = Path.GetFileNameWithoutExtension(kvp.Key);
if (0 == sFilename.IndexOf(sSearchName))
{
int nCurIndex;
if (int.TryParse(sFilename.Substring(sSearchName.Length), out nCurIndex))
aIndexes.Add(nCurIndex);
}
}
int nMaxIndex = -1;
for (int i = 0, length = aIndexes.Count; i < length; ++i)
{
int nCurIndex = aIndexes[i];
if (nMaxIndex < nCurIndex)
nMaxIndex = nCurIndex;
}
int nNewIndex = 1;
if (nMaxIndex >= nNewIndex)
nNewIndex = nMaxIndex + 1;
string sNewName = sSearchName + nNewIndex + "." + FileFormats.ToString(nImageFormat);
string sNewPath = Path.Combine(oTransportClass2.m_sKey, @"media\" + sNewName).Replace('\\', '/');
Storage oStorage = new Storage();
TransportClass3 oTransportClass3 = new TransportClass3(oTransportClass2, sNewName, sImageHash, sNewPath, oStorage);
oTransportClass3.m_oStorage.WriteFileBegin(sNewPath, oImageStream, WriteUploadedFileCallback, oTransportClass3);
}
}
else
WriteToResponse(oTransportClass2, ErrorTypes.UploadExtension, null, oTransportClass2.m_aInputParams);
}
else
WriteToResponse(oTransportClass2, eError, null, oTransportClass2.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass2, ErrorTypes.Upload, null, oTransportClass2.m_aInputParams);
}
}
private void ImageUrlProcess(TransportClass2 oTransportClass2, string sUrl)
{
oTransportClass2.m_aUrls.Add(sUrl);
if (oTransportClass2.m_oFilesEnumerator.MoveNext())
GetMediaXmlCallbackProcess(oTransportClass2, oTransportClass2.m_oMediaXmlMapHash, oTransportClass2.m_oMediaXmlMapFilename);
else
oTransportClass2.m_oAsyncMediaXmlOperation.WriteMediaXmlBegin(oTransportClass2.m_sMediaXml, oTransportClass2.m_oMediaXmlMapHash, WriteMediaXmlCallback, oTransportClass2);
}
private void WriteUploadedFileCallback(IAsyncResult ar)
{
TransportClass3 oTransportClass3 = ar.AsyncState as TransportClass3;
try
{
int nReadWriteBytes;
ErrorTypes eError = oTransportClass3.m_oStorage.WriteFileEnd(ar, out nReadWriteBytes);
if (ErrorTypes.NoError == eError)
{
oTransportClass3.m_oMediaXmlMapHash.Add(oTransportClass3.m_sHash, oTransportClass3.m_sFilename);
oTransportClass3.m_oMediaXmlMapFilename.Add(oTransportClass3.m_sFilename, oTransportClass3.m_sHash);
ImageUrlProcess(oTransportClass3, Constants.mc_sResourceServiceUrlRel + oTransportClass3.m_sPath.Replace('\\', '/'));
}
else
WriteToResponse(oTransportClass3, eError, null, oTransportClass3.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass3, ErrorTypes.Upload, null, oTransportClass3.m_aInputParams);
}
}
private void WriteMediaXmlCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
ErrorTypes eError = oTransportClass1.m_oAsyncMediaXmlOperation.WriteMediaXmlEnd(ar);
if (ErrorTypes.NoError == eError)
WriteToResponse(oTransportClass1, ErrorTypes.NoError, oTransportClass1.m_aUrls, oTransportClass1.m_aInputParams);
else
WriteToResponse(oTransportClass1, eError, null, oTransportClass1.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass1, ErrorTypes.Upload, null, oTransportClass1.m_aInputParams);
}
}
#endregion
#region TransportClass
private class TransportClass1 : TransportClassMainAshx
{
public AsyncMediaXmlOperation m_oAsyncMediaXmlOperation;
public NameValueCollection m_aInputParams;
public List<string> m_aUrls = new List<string>();
public string m_sKey;
public string m_sMediaXml;
public HttpFileCollection m_oFiles;
public IEnumerator m_oFilesEnumerator;
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;
}
}
private class TransportClass2 : TransportClass1
{
public Dictionary<string, string> m_oMediaXmlMapHash = new Dictionary<string, string>();
public Dictionary<string, string> m_oMediaXmlMapFilename = new Dictionary<string, string>();
public AsyncContextReadOperation m_oAsyncContextReadOperation;
public TransportClass2(TransportClass1 oTransportClass1, Dictionary<string, string> oMediaXmlMapHash, Dictionary<string, string> oMediaXmlMapFilename, AsyncContextReadOperation oAsyncContextReadOperation)
: base(oTransportClass1, oTransportClass1.m_oAsyncMediaXmlOperation, oTransportClass1.m_aInputParams, oTransportClass1.m_aUrls, oTransportClass1.m_sKey, oTransportClass1.m_sMediaXml, oTransportClass1.m_oFiles, oTransportClass1.m_oFilesEnumerator)
{
m_oMediaXmlMapHash = oMediaXmlMapHash;
m_oMediaXmlMapFilename = oMediaXmlMapFilename;
m_oAsyncContextReadOperation = oAsyncContextReadOperation;
}
}
private class TransportClass3 : TransportClass2
{
public string m_sFilename;
public string m_sHash;
public string m_sPath;
public Storage m_oStorage;
public TransportClass3(TransportClass2 oTransportClass2, string sFilename, string sHash, string sPath, Storage oStorage)
: base(oTransportClass2, oTransportClass2.m_oMediaXmlMapHash, oTransportClass2.m_oMediaXmlMapFilename, oTransportClass2.m_oAsyncContextReadOperation)
{
m_sFilename = sFilename;
m_sHash = sHash;
m_sPath = sPath;
m_oStorage = oStorage;
}
}
public class OutputCommand
{
public int type;
public List<string> urls = new List<string>();
public int error;
public Dictionary<string, object> input = new Dictionary<string,object>();
}
#endregion
}

View File

@@ -0,0 +1,362 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Collections.Specialized;
using FileConverterUtils2;
using log4net;
namespace DocService
{
public class UploadService : IHttpAsyncHandler
{
private readonly ILog _log = LogManager.GetLogger(typeof(UploadService));
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 void EndProcessRequest(IAsyncResult result)
{
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
public bool IsReusable
{
get
{
return false;
}
}
#region HelpFunctions
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));
}
#endregion
#region Callbacks
private void GetMediaXmlCallbackProcess(TransportClass1 oTransportClass1, Dictionary<string, string> aMediaXmlMapHash, Dictionary<string, string> aMediaXmlMapFilename)
{
AsyncContextReadOperation oAsyncContextReadOperation = new AsyncContextReadOperation();
TransportClass2 oTransportClass2 = new TransportClass2(oTransportClass1, aMediaXmlMapHash, aMediaXmlMapFilename, oAsyncContextReadOperation);
HttpPostedFile oCurrentFile = (HttpPostedFile)oTransportClass1.m_oFiles[(string)oTransportClass1.m_oFilesEnumerator.Current];
oCurrentFile.InputStream.Position = 0;
oAsyncContextReadOperation.ReadContextBegin(oCurrentFile.InputStream, ReadContextCallback, oTransportClass2);
}
private void GetMediaXmlCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
Dictionary<string, string> aMediaXmlMapHash;
Dictionary<string, string> aMediaXmlMapFilename;
ErrorTypes eError = oTransportClass1.m_oAsyncMediaXmlOperation.GetMediaXmlEnd(ar, out aMediaXmlMapHash, out aMediaXmlMapFilename);
if (ErrorTypes.NoError == eError && oTransportClass1.m_oFilesEnumerator.MoveNext())
{
GetMediaXmlCallbackProcess(oTransportClass1, aMediaXmlMapHash, aMediaXmlMapFilename);
}
else
WriteToResponse(oTransportClass1, eError, null, oTransportClass1.m_aInputParams);
}
catch(Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass1, ErrorTypes.Upload, null, oTransportClass1.m_aInputParams);
}
}
private void ReadContextCallback(IAsyncResult ar)
{
TransportClass2 oTransportClass2 = ar.AsyncState as TransportClass2;
try
{
ErrorTypes eError = oTransportClass2.m_oAsyncContextReadOperation.ReadContextEnd(ar);
if (ErrorTypes.NoError == eError)
{
HttpPostedFile oCurrentFile = ((HttpPostedFile)oTransportClass2.m_oFiles[(string)oTransportClass2.m_oFilesEnumerator.Current]);
oCurrentFile.InputStream.Position = 0;
Stream oImageStream = oCurrentFile.InputStream;
byte[] aBuffer = oTransportClass2.m_oAsyncContextReadOperation.m_aOutput.ToArray();
int nImageFormat = FormatChecker.GetFileFormat(aBuffer);
string sSupportedFormats = ConfigurationSettings.AppSettings["limits.image.types.upload"] ?? "jpg";
if (0 != (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE & nImageFormat) && -1 != sSupportedFormats.IndexOf(FileFormats.ToString(nImageFormat)))
{
if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_GIF == nImageFormat || FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_ICO == nImageFormat)
{
byte[] aNewBuffer;
if (Utils.ConvertGifIcoToPng(aBuffer, nImageFormat, out aNewBuffer))
{
nImageFormat = FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
aBuffer = aNewBuffer;
oImageStream = new MemoryStream(aBuffer);
}
}
string sImageHash = null;
using (MemoryStream ms = new MemoryStream(aBuffer))
sImageHash = Utils.getMD5HexString(ms);
string sFileName;
if (oTransportClass2.m_oMediaXmlMapHash.TryGetValue(sImageHash, out sFileName))
{
ImageUrlProcess(oTransportClass2, Constants.mc_sResourceServiceUrlRel + Path.Combine(oTransportClass2.m_sKey, @"media\" + sFileName).Replace('\\', '/'));
}
else
{
string sSearchName = "image";
List<int> aIndexes = new List<int>();
foreach (KeyValuePair<string, string> kvp in oTransportClass2.m_oMediaXmlMapFilename)
{
string sFilename = Path.GetFileNameWithoutExtension(kvp.Key);
if (0 == sFilename.IndexOf(sSearchName))
{
int nCurIndex;
if (int.TryParse(sFilename.Substring(sSearchName.Length), out nCurIndex))
aIndexes.Add(nCurIndex);
}
}
int nMaxIndex = -1;
for (int i = 0, length = aIndexes.Count; i < length; ++i)
{
int nCurIndex = aIndexes[i];
if (nMaxIndex < nCurIndex)
nMaxIndex = nCurIndex;
}
int nNewIndex = 1;
if (nMaxIndex >= nNewIndex)
nNewIndex = nMaxIndex + 1;
string sNewName = sSearchName + nNewIndex + "." + FileFormats.ToString(nImageFormat);
string sNewPath = Path.Combine(oTransportClass2.m_sKey, @"media\" + sNewName).Replace('\\', '/');
Storage oStorage = new Storage();
TransportClass3 oTransportClass3 = new TransportClass3(oTransportClass2, sNewName, sImageHash, sNewPath, oStorage);
oTransportClass3.m_oStorage.WriteFileBegin(sNewPath, oImageStream, WriteUploadedFileCallback, oTransportClass3);
}
}
else
WriteToResponse(oTransportClass2, ErrorTypes.UploadExtension, null, oTransportClass2.m_aInputParams);
}
else
WriteToResponse(oTransportClass2, eError, null, oTransportClass2.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass2, ErrorTypes.Upload, null, oTransportClass2.m_aInputParams);
}
}
private void ImageUrlProcess(TransportClass2 oTransportClass2, string sUrl)
{
oTransportClass2.m_aUrls.Add(sUrl);
if (oTransportClass2.m_oFilesEnumerator.MoveNext())
GetMediaXmlCallbackProcess(oTransportClass2, oTransportClass2.m_oMediaXmlMapHash, oTransportClass2.m_oMediaXmlMapFilename);
else
oTransportClass2.m_oAsyncMediaXmlOperation.WriteMediaXmlBegin(oTransportClass2.m_sMediaXml, oTransportClass2.m_oMediaXmlMapHash, WriteMediaXmlCallback, oTransportClass2);
}
private void WriteUploadedFileCallback(IAsyncResult ar)
{
TransportClass3 oTransportClass3 = ar.AsyncState as TransportClass3;
try
{
int nReadWriteBytes;
ErrorTypes eError = oTransportClass3.m_oStorage.WriteFileEnd(ar, out nReadWriteBytes);
if (ErrorTypes.NoError == eError)
{
oTransportClass3.m_oMediaXmlMapHash.Add(oTransportClass3.m_sHash, oTransportClass3.m_sFilename);
oTransportClass3.m_oMediaXmlMapFilename.Add(oTransportClass3.m_sFilename, oTransportClass3.m_sHash);
ImageUrlProcess(oTransportClass3, Constants.mc_sResourceServiceUrlRel + oTransportClass3.m_sPath.Replace('\\', '/'));
}
else
WriteToResponse(oTransportClass3, eError, null, oTransportClass3.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass3, ErrorTypes.Upload, null, oTransportClass3.m_aInputParams);
}
}
private void WriteMediaXmlCallback(IAsyncResult ar)
{
TransportClass1 oTransportClass1 = ar.AsyncState as TransportClass1;
try
{
ErrorTypes eError = oTransportClass1.m_oAsyncMediaXmlOperation.WriteMediaXmlEnd(ar);
if (ErrorTypes.NoError == eError)
WriteToResponse(oTransportClass1, ErrorTypes.NoError, oTransportClass1.m_aUrls, oTransportClass1.m_aInputParams);
else
WriteToResponse(oTransportClass1, eError, null, oTransportClass1.m_aInputParams);
}
catch (Exception e)
{
_log.Error("Exeption: ", e);
WriteToResponse(oTransportClass1, ErrorTypes.Upload, null, oTransportClass1.m_aInputParams);
}
}
#endregion
#region TransportClass
private class TransportClass1 : TransportClassMainAshx
{
public AsyncMediaXmlOperation m_oAsyncMediaXmlOperation;
public NameValueCollection m_aInputParams;
public List<string> m_aUrls = new List<string>();
public string m_sKey;
public string m_sMediaXml;
public HttpFileCollection m_oFiles;
public IEnumerator m_oFilesEnumerator;
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;
}
}
private class TransportClass2 : TransportClass1
{
public Dictionary<string, string> m_oMediaXmlMapHash = new Dictionary<string, string>();
public Dictionary<string, string> m_oMediaXmlMapFilename = new Dictionary<string, string>();
public AsyncContextReadOperation m_oAsyncContextReadOperation;
public TransportClass2(TransportClass1 oTransportClass1, Dictionary<string, string> oMediaXmlMapHash, Dictionary<string, string> oMediaXmlMapFilename, AsyncContextReadOperation oAsyncContextReadOperation)
: base(oTransportClass1, oTransportClass1.m_oAsyncMediaXmlOperation, oTransportClass1.m_aInputParams, oTransportClass1.m_aUrls, oTransportClass1.m_sKey, oTransportClass1.m_sMediaXml, oTransportClass1.m_oFiles, oTransportClass1.m_oFilesEnumerator)
{
m_oMediaXmlMapHash = oMediaXmlMapHash;
m_oMediaXmlMapFilename = oMediaXmlMapFilename;
m_oAsyncContextReadOperation = oAsyncContextReadOperation;
}
}
private class TransportClass3 : TransportClass2
{
public string m_sFilename;
public string m_sHash;
public string m_sPath;
public Storage m_oStorage;
public TransportClass3(TransportClass2 oTransportClass2, string sFilename, string sHash, string sPath, Storage oStorage)
: base(oTransportClass2, oTransportClass2.m_oMediaXmlMapHash, oTransportClass2.m_oMediaXmlMapFilename, oTransportClass2.m_oAsyncContextReadOperation)
{
m_sFilename = sFilename;
m_sHash = sHash;
m_sPath = sPath;
m_oStorage = oStorage;
}
}
public class OutputCommand
{
public int type;
public List<string> urls = new List<string>();
public int error;
public Dictionary<string, object> input = new Dictionary<string,object>();
}
#endregion
}
}

View File

@@ -1,4 +1,4 @@
<%@ WebHandler Language="C#" Class="fileDownloader" %>
<%@ WebHandler Language="C#" CodeBehind="fileDownloader.ashx.cs" Class="DocService.fileDownloader" %>
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
@@ -32,75 +32,3 @@
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
public class fileDownloader : IHttpHandler {
public void ProcessRequest (HttpContext context) {
try
{
System.IO.FileInfo file = new System.IO.FileInfo(Convert.ToString(context.Server.MapPath(context.Server.UrlDecode("~" + context.Request.QueryString[0]))));
string sOutputFilename = null;
if (context.Request.QueryString.Count > 1)
sOutputFilename = context.Server.UrlDecode(context.Request.QueryString[1]);
if (string.IsNullOrEmpty(sOutputFilename))
sOutputFilename = file.Name;
if (!file.Exists)
return;
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
if (context.Request.ServerVariables.Get("HTTP_USER_AGENT").Contains("MSIE"))
context.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + context.Server.UrlEncode(sOutputFilename) + "\"");
else
context.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + sOutputFilename + "\"");
context.Response.AppendHeader("Content-Length", file.Length.ToString());
context.Response.TransmitFile(file.FullName);
context.Response.Flush();
context.ApplicationInstance.CompleteRequest();
}
catch(Exception){}
}
public bool IsReusable {
get {
return false;
}
}
public static string GetIP4Address()
{
string IP4Address = String.Empty;
foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
if (IP4Address != String.Empty)
{
return IP4Address;
}
foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
return IP4Address;
}
}

View File

@@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Net;
using System.Configuration;
using System.Web;
using System.IO;
using System.Text;
namespace DocService
{
public class fileDownloader : IHttpHandler {
public void ProcessRequest (HttpContext context) {
try
{
System.IO.FileInfo file = new System.IO.FileInfo(Convert.ToString(context.Server.MapPath(context.Server.UrlDecode("~" + context.Request.QueryString[0]))));
string sOutputFilename = null;
if (context.Request.QueryString.Count > 1)
sOutputFilename = context.Server.UrlDecode(context.Request.QueryString[1]);
if (string.IsNullOrEmpty(sOutputFilename))
sOutputFilename = file.Name;
if (!file.Exists)
return;
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
if (context.Request.ServerVariables.Get("HTTP_USER_AGENT").Contains("MSIE"))
context.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + context.Server.UrlEncode(sOutputFilename) + "\"");
else
context.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + sOutputFilename + "\"");
context.Response.AppendHeader("Content-Length", file.Length.ToString());
context.Response.TransmitFile(file.FullName);
context.Response.Flush();
context.ApplicationInstance.CompleteRequest();
}
catch(Exception){}
}
public bool IsReusable {
get {
return false;
}
}
public static string GetIP4Address()
{
string IP4Address = String.Empty;
foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
if (IP4Address != String.Empty)
{
return IP4Address;
}
foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}
return IP4Address;
}
}
}

View File

@@ -135,11 +135,11 @@
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/d:OPEN_SOURCE">
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="WarnAsError" value="false" />
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/d:OPEN_SOURCE">
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="OptionInfer" value="true" />
<providerOption name="WarnAsError" value="false" />