diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config
index fe6aaf88..9f3e75be 100644
--- a/.vs/config/applicationhost.config
+++ b/.vs/config/applicationhost.config
@@ -163,7 +163,7 @@
-
+
@@ -187,7 +187,7 @@
-
+
@@ -195,7 +195,7 @@
-
+
diff --git a/DigitalPlatform.MessageServer/ServerInfo.cs b/DigitalPlatform.MessageServer/ServerInfo.cs
index 9ab6798e..0dba4ed2 100644
--- a/DigitalPlatform.MessageServer/ServerInfo.cs
+++ b/DigitalPlatform.MessageServer/ServerInfo.cs
@@ -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("");
+
+ 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;
diff --git a/dp2MServer/Program.cs b/dp2MServer/Program.cs
index e30cf48c..a67d6c3c 100644
--- a/dp2MServer/Program.cs
+++ b/dp2MServer/Program.cs
@@ -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
{
@@ -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 + ")");