93 lines
4.2 KiB
C#
93 lines
4.2 KiB
C#
using SuperMap.RealEstate.Launcher_WebSite;
|
||
using SuperMap.RealEstate.ServiceModel;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace SuperMap.RealEstate.SoftWare
|
||
{
|
||
public partial class Launcher : SuperMap.RealEstate.Web.UI.Page
|
||
{
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
this.Response.Clear();
|
||
this.Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
try
|
||
{
|
||
string _AppsPath = MapPath("/SoftWare") + "\\";
|
||
if (!Directory.Exists(_AppsPath))
|
||
Directory.CreateDirectory(_AppsPath);
|
||
if (Request["type"] == null)
|
||
throw new Exception("请从合法的渠道打开系统");
|
||
if (!File.Exists(_AppsPath + "Launcher.exe"))
|
||
throw new Exception("SoftWare目录中,未部署Launcher.exe,请检查配置。");
|
||
|
||
StringBuilder _StringBuilder = new StringBuilder();
|
||
_StringBuilder.AppendLine("[Launcher]");
|
||
_StringBuilder.AppendLine("Version:" + GetFileVersion(_AppsPath + "Launcher.exe"));
|
||
_StringBuilder.AppendLine("DateTime:" + (DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()).ToEncrypt());
|
||
this.Response.Write(_StringBuilder.ToString());
|
||
|
||
string _ResponseWriteFile = _AppsPath + "\\Core\\Version.ini.Deploy";
|
||
if (!File.Exists(_ResponseWriteFile))
|
||
throw new Exception("服务器部署文件不存在,请重新生成!\r\nSoftWare\\Core\\Version.ini.Deploy");
|
||
this.Response.WriteFile(_ResponseWriteFile);
|
||
LaunchType _LaunchType = (LaunchType)Enum.Parse(typeof(LaunchType), Request["type"], true);
|
||
switch (_LaunchType)
|
||
{
|
||
case LaunchType.Install:
|
||
_ResponseWriteFile = _AppsPath + _LaunchType.ToString() + "_Deploy\\Install.ini.Deploy";
|
||
if (!File.Exists(_ResponseWriteFile))
|
||
{
|
||
throw new Exception("服务器部署文件不存在,请重新生成!\r\nSoftWare\\" + _LaunchType.ToString() + "_Deploy\\Config.ini.Deploy");
|
||
}
|
||
this.Response.WriteFile(_ResponseWriteFile);
|
||
break;
|
||
case LaunchType.AppRuns:
|
||
if (Request["name"] == null)
|
||
{
|
||
throw new Exception("请从合法的渠道打开系统");
|
||
}
|
||
_ResponseWriteFile = _AppsPath + _LaunchType.ToString() + "_Deploy\\" + Request["name"] + ".ini.Deploy";
|
||
if (!File.Exists(_ResponseWriteFile))
|
||
{
|
||
throw new Exception("服务器部署文件不存在,请重新生成!\r\nSoftWare\\" + _LaunchType.ToString() + "_Deploy\\" + Request["name"] + ".ini.Deploy");
|
||
}
|
||
this.Response.WriteFile(_ResponseWriteFile);
|
||
break;
|
||
default:
|
||
throw new Exception("传递了错误的关键字!");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.Response.Clear();
|
||
StringBuilder _StringBuilder = new StringBuilder();
|
||
_StringBuilder.AppendLine("[Error]");
|
||
_StringBuilder.Append(ex.Message);
|
||
this.Response.Write(_StringBuilder.ToString());
|
||
}
|
||
this.Response.End();
|
||
}
|
||
|
||
private string GetFileVersion(string filePath)
|
||
{
|
||
if (!File.Exists(filePath))
|
||
return "不存在";
|
||
FileVersionInfo _FileVersionInfo = FileVersionInfo.GetVersionInfo(filePath);
|
||
if (String.IsNullOrEmpty(_FileVersionInfo.FileVersion))
|
||
return "无版本";
|
||
else
|
||
return _FileVersionInfo.FileVersion.Split(' ')[0];
|
||
}
|
||
}
|
||
}
|
||
|