Skip to content

Commit

Permalink
完善 dp2mserver 首次安装的功能,增加自动创建数据目录中 config.xml 的动作
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalPlatform committed Sep 12, 2016
1 parent ac0d426 commit e6fcb14
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .vs/config/applicationhost.config
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</site>
<site name="MessageWeb" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\jane\chord\MessageWeb" />
<virtualDirectory path="/" physicalPath="D:\chord\chord\MessageWeb" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:49870:localhost" />
Expand All @@ -187,15 +187,15 @@
</site>
<site name="ilovelibrary" id="5">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\jane\chord\ilovelibrary" />
<virtualDirectory path="/" physicalPath="D:\chord\chord\ilovelibrary" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:28413:localhost" />
</bindings>
</site>
<site name="dp2weixinP2P" id="6">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\jane\chord\dp2weixinP2P" />
<virtualDirectory path="/" physicalPath="D:\chord\chord\dp2weixinP2P" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:15794:localhost" />
Expand Down
22 changes: 22 additions & 0 deletions DigitalPlatform.MessageServer/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ static string AutoTriggerUrl
set;
}

public static void CreateCfgFile(string strCfgFileName,
string strMongoDbConnStr = "",
string strMongoDbInstancePrefix = "")
{
// 默认值
if (string.IsNullOrEmpty(strMongoDbConnStr))
strMongoDbConnStr = "mongodb://localhost";
if (string.IsNullOrEmpty(strMongoDbInstancePrefix))
strMongoDbInstancePrefix = "mserver";

XmlDocument dom = new XmlDocument();
dom.LoadXml("<root />");

XmlElement mongoDB = dom.CreateElement("mongoDB");
dom.DocumentElement.AppendChild(mongoDB);

mongoDB.SetAttribute("connectionString", strMongoDbConnStr);
mongoDB.SetAttribute("instancePrefix", strMongoDbInstancePrefix);

dom.Save(strCfgFileName);
}

public static void Initial(InitialParam param)
{
AutoTriggerUrl = param.AutoTriggerUrl;
Expand Down
25 changes: 13 additions & 12 deletions dp2MServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Threading.Tasks;
using System.Threading;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Security.Principal;
// using System.Configuration;
using System.IO;

using Owin;
using Microsoft.Owin.Cors;
using Microsoft.Owin.Hosting;
using Microsoft.AspNet.SignalR;

using dp2MServer.Properties;
using Microsoft.Owin;

using DigitalPlatform.MessageServer;
using DigitalPlatform.ServiceProcess;
using DigitalPlatform.Xml;
using Microsoft.Owin;
using System.IO;
using DigitalPlatform.IO;

namespace dp2MServer
{
Expand Down Expand Up @@ -116,7 +107,17 @@ static void Main(string[] args)
AutoTriggerUrl = strValue;
}

string strCfgFileName = Path.Combine(DataDir, "config.xml");

SaveConfig();

// 创建数据目录中的 config.xml 配置文件
if (File.Exists(strCfgFileName) == false)
{
PathUtil.CreateDirIfNeed(Path.GetDirectoryName(strCfgFileName));
ServerInfo.CreateCfgFile(strCfgFileName);
Console.WriteLine("首次创建配置文件 " + strCfgFileName);
}
#if NO
Console.WriteLine("(直接回车表示不修改当前值)");
Console.WriteLine("请输入服务器 URI: (当前值为 " + Settings.Default.ServerURI + ")");
Expand Down

0 comments on commit e6fcb14

Please sign in to comment.