Пример #1
0
        /// <summary>
        /// 准备初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInit_Click(object sender, EventArgs e)
        {
            var cityModel = cityName3.SelectedItem as CityModel;

            if (cityModel != null)
            {
                tempModel.CityId = cityModel.CId;
            }
            File.WriteAllText("App/DNT.json", tempModel.ObjectToJson(), Encoding.UTF8);
            ShowMainForm();
        }
Пример #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="model"></param>
 public static string Init(TempModel model)
 {
     if (!Directory.Exists("App"))
     {
         Directory.CreateDirectory("App");
     }
     if (!File.Exists("App/DNT.json"))
     {
         try
         {
             //throw new Exception("调试的时候手动抛出的异常~勿要慌");
             File.WriteAllText("App/DNT.json", model.ObjectToJson(), Encoding.UTF8);
         }
         catch
         {
             return("初始化失败,请重新打开或者在App文件夹创建DNT.json\n内容如下:{\"CityId\":\"城市ID\"ConnStr\":\"数据库连接语句\"}");
         }
     }
     return("初始化成功");
 }