123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050 |
- using ClickOnceSetup.Common;
- using ClickOnceSetup.Common.ChainResponsibility;
- using ClickOnceSetup.MiniServer.Database;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Threading;
- using Vinno.vCloud.Protocol.Initializers;
- namespace ClickOnceSetup
- {
- /// <summary>
- /// InfomationTabs.xaml 的交互逻辑
- /// </summary>
- public partial class InfomationTabs
- {
- private InstallProcess _installProcess;
- SettingJsonGet _jObject = new SettingJsonGet(AppDomain.CurrentDomain.BaseDirectory + "\\InstallPackage\\SystemPackage\\Server\\Settings\\Server\\Setting.conf");
- SettingJsonGet _jObjectManagement = new SettingJsonGet(AppDomain.CurrentDomain.BaseDirectory + "\\InstallPackage\\SystemPackage\\Management\\appsettings.json");
- SettingJsonGet _jObjectSystemConfig = new SettingJsonGet(AppDomain.CurrentDomain.BaseDirectory + "\\SystemConfig.json");
- SettingJsonGet _jObjectVideoConfig = new SettingJsonGet(AppDomain.CurrentDomain.BaseDirectory + "\\InstallPackage\\SystemPackage\\VideoServer\\appsettings.json");
- List<string> _iPWhiteList = new List<string>();
- public InfomationTabs()
- {
- ClientTagsInitializer.Initialize();
- InitializeComponent();
- try
- {
- if (TranslateHelper.CurrentLanguage.ToUpper() == "ENGLISH")
- {
- cb_ChooseLanguage.SelectedIndex = 0;
- }
- else
- {
- cb_ChooseLanguage.SelectedIndex = 1;
- }
- FuncInOutHelper.AddDelegate(CloseWindow);
- FuncInOutHelper.AddDelegate(CopyFiles);
- FuncInOutHelper.AddDelegate(OpenHintShow);
- FuncInOutHelper.AddDelegate(GetInstallPath);
- FuncInOutHelper.AddDelegate(GetTagValue);
- FuncInOutHelper.AddDelegate(GetUpgradePath);
- FuncInOutHelper.AddDelegate(GetIsBak);
- FuncInOutHelper.AddDelegate(GetUseTestServer);
- FuncInOutHelper.AddDelegate(JumpToFinish);
- FuncInOutHelper.AddDelegate(GetLiveVideoTypeSelectIndex);
- FuncInOutHelper.AddDelegate(MessageBox);
- if (IsInitialized)
- {
- FirstSetting();
- LoadSetting(_jObject.GetJsonRoot());
- LoadManagementSetting(_jObjectManagement.GetJsonRoot());
- LoadOldSettingFile(txt_Systeminstallationpath.Text);
- }
- }
- catch (Exception ex)
- {
- FileHelper.AppendWriteFile("InstallLog.txt", ex.Message + "|" + ex.StackTrace);
- }
- }
- /// <summary>
- /// 加载管理站配置
- /// </summary>
- /// <param name="jObjectManagement"></param>
- private void LoadManagementSetting(JToken jObjectManagement)
- {
- if (jObjectManagement == null || !jObjectManagement.HasValues)
- {
- return;
- }
- jObjectManagement.GetJPropertyStringAction($"$.AppSettings.ServerConfig.Host",v=> txt_ServerHost.Text = v);
- jObjectManagement.GetJPropertyStringAction($"$.AppSettings.ServerConfig.Port",v=> txt_ServerPort.Text = v);
- jObjectManagement.GetJPropertyStringAction($"$.AppSettings.GetReportApiUrl",v=> txt_GetReportApiUrl.Text = v);
- jObjectManagement.GetJPropertyStringAction($"$.AppSettings.ApiCacheFolder", v=> txt_ApiCacheFolder.Text = v);
- }
- private void LoadVideoServerSetting(JToken videoServerRoot)
- {
- if (videoServerRoot == null || !videoServerRoot.HasValues) { return; }
- videoServerRoot.GetJPropertyStringAction($"$.AppSettings.StoageVideoFolder",v=> txt_StoageVideoFolder.Text = v);
- videoServerRoot.GetJPropertyStringAction($"$.AppSettings.ServerUrl",v=> txt_ServerUrl.Text = v);
- //txt_AppKey.Text = "9c96274f5eca47f181bf24b6b737e43e";
- //txt_AppSecret.Text = "ac60a9a87d5f4f8c9fa1a55cfeb0826f";
- }
- /// <summary>
- /// 保存管理站配置
- /// </summary>
- /// <param name="jObjectManagement"></param>
- private void SaveManagementSettings(JToken jObjectManagement)
- {
- if (jObjectManagement == null || !jObjectManagement.HasValues) { return; }
- jObjectManagement.SetPropertyValue("Host", txt_ServerHost.Text, $"$.AppSettings.ServerConfig");
- jObjectManagement.SetPropertyValue("Port", txt_ServerPort.Text.ToInt(), $"$.AppSettings.ServerConfig");
- jObjectManagement.SetPropertyValue("GetReportApiUrl", txt_GetReportApiUrl.Text, $"$.AppSettings");
- jObjectManagement.SetPropertyValue("ApiCacheFolder", txt_ApiCacheFolder.Text, $"$.AppSettings");
- _jObjectManagement.SaveJson();
- ((JObject)_jObjectSystemConfig.GetJsonRoot()).AddChild("ManagementConfig", _jObjectManagement.GetJsonRoot());
- }
- private void FirstSetting()
- {
- if (string.IsNullOrWhiteSpace(txt_Serverdomainname.Text))
- {
- txt_Serverdomainname.Text = IpInfoGet.GetLocalIpByManagementClass().FirstOrDefault() ?? string.Empty;
- }
- var jObjectSystemConfig = _jObjectSystemConfig.GetJsonRoot();
- if (jObjectSystemConfig == null || !jObjectSystemConfig.HasValues) { return; }
- string installationPath = jObjectSystemConfig.GetJPropertyString($"$.SystemInstallationPath");
- if (!string.IsNullOrWhiteSpace(installationPath) && string.IsNullOrWhiteSpace(txt_Systeminstallationpath.Text))
- {
- _systeminstallationpath = installationPath;
- txt_Systeminstallationpath.Text = installationPath;
- }
- string serverdomainname = jObjectSystemConfig.GetJPropertyString($"$.ServerDomainName");
- if (!string.IsNullOrWhiteSpace(serverdomainname) && string.IsNullOrWhiteSpace(txt_Serverdomainname.Text))
- {
- txt_Serverdomainname.Text = serverdomainname;
- }
- var dependpacks = jObjectSystemConfig.GetAllChildren("$.DependpackConfig");
- if (dependpacks != null)
- {
- foreach (var jToken in dependpacks)
- {
- var dependpack = (JProperty) jToken;
- string elementName = dependpack.Name;
- int elementValue = dependpack.Value.Value<int>();
- var element = grid_dependPack.FindName(elementName);
- if (element != null)
- {
- ((CheckBox)element).IsChecked = elementValue == 1;
- }
- }
- }
- var managementStartPort = jObjectSystemConfig.GetJPropertyString("$.ManagementStartPort");
- if (!string.IsNullOrWhiteSpace(managementStartPort))
- {
- txt_ManagementStartPort.Text = managementStartPort;
- }
- int isBak = jObjectSystemConfig.GetJPropertyInt($"$.IsBak");
- int useTestServer = jObjectSystemConfig.GetJPropertyInt($"$.UseTestServer");
- cb_isBak.IsChecked = isBak == 1;
- cb_useTestServer.IsChecked = useTestServer == 1;
- var iPWhiteListData = jObjectSystemConfig.GetJPropertyCollectionsValueByPath<string>("$.IPWhiteList")?.ToList();
- if (iPWhiteListData !=null && iPWhiteListData.Any())
- {
- _iPWhiteList.AddRange(iPWhiteListData);
- dtgIpWhiteList.ItemsSource = null;
- dtgIpWhiteList.ItemsSource = _iPWhiteList.Select(x => new { IP = x });
- }
- }
- /// <summary>
- /// 加载配置
- /// </summary>
- /// <param name="jObject"></param>
- private void LoadSetting(JToken jObject)
- {
- if (jObject == null || !jObject.HasValues)
- {
- return;
- }
- #region 加载主要配置
- jObject.GetJPropertyStringAction($"$.LiveVideo.ChannelProvider",v=> cb_LiveVideoType.SelectedIndex = (v == "Common" ? 1 : 0)) ;
- jObject.GetJPropertyStringAction($"$.LiveVideo.CommonBaseUrl",v=> txt_LiveVideoAddress.Text = v);
- PageBags.SetData("LiveNeteaseAppKey", jObject.GetJPropertyString($"$.LiveVideo.NeteaseAppKey"));
- PageBags.SetData("LiveNeteaseAppSecret", jObject.GetJPropertyString($"$.LiveVideo.NeteaseAppSecret"));
- PageBags.SetData("LiveChannelCount", jObject.GetJPropertyInt($"$.LiveVideo.ChannelCount"));
- jObject.GetJPropertyStringAction($"$.Video.StorageProvider", v=> cb_StorageProvider.SelectedIndex = (v == "Netease" ? 0 : 1));
- if (jObject.GetJPropertyInt($"$.Video.Port") > 0)
- {
- jObject.GetJPropertyIntAction($"$.Video.Port",v=> txt_VideoPort.Text = v.ToString());
- }
-
- #endregion
- #region 加载开关
- serviceCheckBoxGrid.Children.Clear();
- var jTokenChildren = jObject.GetAllChildren("$.Service");
- if (jTokenChildren != null)
- {
- foreach (var jToken in jTokenChildren)
- {
- var jPropertyChild = (JProperty) jToken;
- string elementName = jPropertyChild.Name;
- int elementValue = jPropertyChild.Value.Value<int>();
- CheckBox ck = new CheckBox();
- ck.Name = elementName;
- ck.Content = elementName;
- ck.IsChecked = elementValue == 1;
- serviceCheckBoxGrid.Children.Add(ck);
- }
- }
- CheckBox enableIpLocationCk = new CheckBox();
- enableIpLocationCk.Name = "EnableIpLocation";
- enableIpLocationCk.Content = "EnableIpLocation";
- jObject.GetJPropertyIntAction($"$.Gateway.EnableIpLocation", v => enableIpLocationCk.IsChecked = (v == 1));
- serviceCheckBoxGrid.Children.Add(enableIpLocationCk);
- #endregion
- #region 加载端口
- jObject.GetJPropertyIntAction($"$.Statistics.Port",v=> txt_StatisticsPort.Text = v.ToString());
- jObject.GetJPropertyIntAction($"$.Gateway.GatewayPort",v=> txt_GatewayPort.Text = v.ToString());
- jObject.GetJPropertyIntAction($"$.Management.Port", v => txt_ManagementPort.Text = v.ToString());
- jObject.GetJPropertyIntAction($"$.Database.Port",v=> txt_DatabasePort.Text = v.ToString());
- jObject.GetJPropertyIntAction($"$.UnifyLog.LogDbPort",v=> txt_LogDbPort.Text = v.ToString());
- jObject.GetJPropertyIntAction($"$.UnifyLog.LogViewerPort",v=> txt_LogViewerPort.Text = v.ToString());
- if (string.IsNullOrWhiteSpace(txt_LogDbPort.Text) || txt_LogDbPort.Text == "0")
- {
- jObject.GetJPropertyIntAction($"$.Log.LogDbPort", v=> txt_LogDbPort.Text = v.ToString());
- }
- if (string.IsNullOrWhiteSpace(txt_LogViewerPort.Text) || txt_LogViewerPort.Text == "0")
- {
- jObject.GetJPropertyIntAction($"$.Log.LogViewerPort",v=> txt_LogViewerPort.Text = v.ToString());
- }
- #endregion
- #region 加载文件夹
- jObject.GetJPropertyStringAction($"$.Storage.StorageFolder",v=> txt_StorageFolder.Text = v);
- jObject.GetJPropertyStringAction($"$.Upgrade.UpgradeFolder",v=> txt_UpgradeFolder.Text = v);
- jObject.GetJPropertyStringAction($"$.Display.CacheFolder",v=> txt_CacheFolder.Text = v);
- jObject.GetJPropertyStringAction($"$.Report.ReportPostFolder",v=> txt_ReportPostFolder.Text = v);
- jObject.GetJPropertyStringAction($"$.Management.ApiCacheFolder", v => txt_MApiCacheFolder.Text = v);
- #endregion
- #region 加载服务Api
- jObject.GetJPropertyStringAction($"$.API.Url",v=> txt_ApiUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.Report.ReportUrl",v=> txt_ReportUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.Storage.Url",v=> txt_DefaultStorageServer.Text = v);
- jObject.GetJPropertyStringAction($"$.Upgrade.DefaultUpgradeServer",v=> txt_DefaultUpgradeServer.Text = v);
- jObject.GetJPropertyStringAction($"$.Remedical.DefaultDisplayServer",v=> txt_DefaultDisplayServer.Text = v);
- jObject.GetJPropertyStringAction($"$.LiveTalking.Url",v=> txt_LiveTalkingServer.Text = v);
- jObject.GetJPropertyStringAction($"$.Management.GetReportApiUrl", v => txt_MGetReportApiUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.Management.DownloadApiUrl", v => txt_MDownloadApiUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.OrderForm.GetUnityPayLink", v => txt_GetUnityPayLink.Text = v);
- #endregion
- #region 邮箱配置
- jObject.GetJPropertyStringAction($"$.RegisterAccount.MailHost",v=> txt_MailHost.Text = v);
- jObject.GetJPropertyStringAction($"$.RegisterAccount.EmailUserName",v=> txt_EmailUserName.Text = v);
- jObject.GetJPropertyStringAction($"$.RegisterAccount.EmailUserPassword",v=> txt_EmailUserPassword.Text = v);
- jObject.GetJPropertyIntAction($"$.RegisterAccount.SmtpPort",v=> txt_SmtpPort.Text = v.ToString());
- jObject.GetJPropertyStringAction($"$.RegisterAccount.UseSSL",v=> ck_isssl.IsChecked = (v.ToUpper() == "TRUE"));
- #endregion
- #region 支付配置
- jObject.GetJPropertyStringAction($"$.Payment.ServiceUrl",v=> txt_PayServiceUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.Payment.ServicePort",v=> txt_PayServicePort.Text = v);
- jObject.GetJPropertyStringAction($"$.Payment.PaySuccessNotifyUrl",v=> txt_PaySuccessNotifyUrl.Text = v);
- jObject.GetJPropertyStringAction($"$.Payment.RefundSuccessNotifyUrl",v=> txt_RefundSuccessNotifyUrl.Text = v);
- string alipayJson = jObject.GetJPropertyString($"$.Payment.Alipay").TrimEnd(',');
- if (!string.IsNullOrWhiteSpace(alipayJson))
- {
- dynamic alipayJsonDynamic = JObject.Parse(alipayJson);
- txt_Alipay_Gatewayurl.Text = (string)alipayJsonDynamic.Gatewayurl;
- txt_Alipay_AppId.Text = (string)alipayJsonDynamic.AppId;
- txt_Alipay_CharSet.Text = (string)alipayJsonDynamic.CharSet;
- txt_Alipay_SignType.Text = (string)alipayJsonDynamic.SignType;
- txt_Alipay_PrivateKey.Text = (string)alipayJsonDynamic.PrivateKey;
- txt_Alipay_PublicKey.Text = (string)alipayJsonDynamic.PublicKey;
- }
- string paypalJson = jObject.GetJPropertyString($"$.Payment.Paypal").TrimEnd(',');
- if (!string.IsNullOrWhiteSpace(paypalJson))
- {
- dynamic paypalJsonDynamic = JObject.Parse(paypalJson);
- txt_Paypal_ClientId.Text = (string)paypalJsonDynamic.ClientId;
- txt_Paypal_ClientSecret.Text = (string)paypalJsonDynamic.ClientSecret;
- ck_UseSandBox.IsChecked = (string)paypalJsonDynamic.UseSandBox == "1";
- }
- string wechatJson = jObject.GetJPropertyString($"$.Payment.Wechat").TrimEnd(',');
- if (!string.IsNullOrWhiteSpace(wechatJson))
- {
- dynamic wechatJsonDynamic = JObject.Parse(wechatJson);
- txt_Wechat_AppID.Text = (string)wechatJsonDynamic.AppID;
- txt_Wechat_MchID.Text = (string)wechatJsonDynamic.MchID;
- txt_Wechat_Key.Text = (string)wechatJsonDynamic.Key;
- txt_Wechat_AppSecret.Text = (string)wechatJsonDynamic.AppSecret;
- txt_Wechat_SSlCertPassword.Text = (string)wechatJsonDynamic.SSlCertPassword;
- }
- ShowUploadState();
- #endregion
- }
- /// <summary>
- /// 保存Management配置
- /// </summary>
- private void SaveVideoServerSettings(JToken jObjectVideoServer)
- {
- if (jObjectVideoServer == null || !jObjectVideoServer.HasValues) { return; }
- jObjectVideoServer.SetPropertyValue("StoageVideoFolder", txt_StoageVideoFolder.Text, $"$.AppSettings");
- jObjectVideoServer.SetPropertyValue("ServerUrl", txt_ServerUrl.Text, $"$.AppSettings");
- _jObjectVideoConfig.SaveJson();
- ((JObject)_jObjectSystemConfig.GetJsonRoot()).AddChild("VideoServerConfig", _jObjectVideoConfig.GetJsonRoot());
- }
- /// <summary>
- /// 保存配置
- /// </summary>
- /// <param name="jObject"></param>
- private void SaveSettings(JToken jObject)
- {
- if (jObject == null || !jObject.HasValues) { return; }
- #region 保存主要配置
- jObject.SetPropertyValue("ChannelProvider", cb_LiveVideoType.SelectedIndex == 1 ? "Common" : "Netease", $"$.LiveVideo");
- jObject.SetPropertyValue("CommonBaseUrl", txt_LiveVideoAddress.Text, $"$.LiveVideo");
- jObject.SetPropertyValue("NeteaseAppKey", PageBags.GetData<string>("LiveNeteaseAppKey"), $"$.LiveVideo");
- jObject.SetPropertyValue("NeteaseAppSecret", PageBags.GetData<string>("LiveNeteaseAppSecret"), $"$.LiveVideo");
- jObject.SetPropertyValue("ChannelCount", PageBags.GetData<int>("LiveChannelCount"), $"$.LiveVideo");
- jObject.SetPropertyValue("StorageProvider", cb_StorageProvider.SelectedIndex == 1 ? "Common" : "Netease", $"$.Video");
- PageBags.SetData("VideoStorageProvider", cb_StorageProvider.SelectedIndex);
- if (cb_StorageProvider.SelectedIndex == 1)
- {
- jObject.SetPropertyValue("Url", txt_ServerUrl.Text, $"$.Video");
- }
- else
- {
- jObject.SetPropertyValue("Url", "https://vcloud.163.com", $"$.Video");
- }
- if (!string.IsNullOrWhiteSpace(txt_VideoPort.Text))
- {
- jObject.SetPropertyValue("Port", txt_VideoPort.Text.ToInt(), $"$.Video");
- }
- else
- {
- jObject.SetPropertyValue("Port", RegexHelper.MatchSub(txt_ServerUrl.Text, ".*:([\\d]*)").ToInt(), $"$.Video");
- }
- #endregion
- #region 保存开关
- foreach (UIElement checkBox in serviceCheckBoxGrid.Children)
- {
- if (checkBox.GetType().Name == "CheckBox")
- {
- var checkBoxElement = (CheckBox)checkBox;
- var checkBoxName = checkBoxElement.Name;
- if (checkBoxName == "EnableIpLocation")
- {
- jObject.SetPropertyValue("EnableIpLocation", checkBoxElement.IsChecked != null && checkBoxElement.IsChecked.Value ? 1 : 0, $"$.Gateway");
- }
- else
- {
- jObject.SetPropertyValue(checkBoxName, checkBoxElement.IsChecked != null && checkBoxElement.IsChecked.Value ? 1 : 0, $"$.Service");
- }
- }
- }
- #endregion
- #region 保存端口
- jObject.SetPropertyValue("Port", txt_StatisticsPort.Text.ToInt(), $"$.Statistics");
- jObject.SetPropertyValue("GatewayPort", txt_GatewayPort.Text.ToInt(), $"$.Gateway");
- jObject.SetPropertyValue("Port", txt_ManagementPort.Text.ToInt(), $"$.Management");
- txt_ServerPort.Text = txt_GatewayPort.Text;
- jObject.SetPropertyValue("Port", txt_DatabasePort.Text.ToInt(), $"$.Database");
- jObject.SetPropertyValue("LogDbPort", txt_LogDbPort.Text.ToInt(), $"$.UnifyLog");
- jObject.SetPropertyValue("LogViewerPort", txt_LogViewerPort.Text.ToInt(), $"$.UnifyLog");
- jObject.SetPropertyValue("LogDbPort", txt_LogDbPort.Text.ToInt(), $"$.Log");
- jObject.SetPropertyValue("LogViewerPort", txt_LogViewerPort.Text.ToInt(), $"$.Log");
- jObject.SetPropertyValue("ListenPort", txt_DefaultStorageServer.Text.SubWithToEnd(":").ToInt(), $"$.Storage");
- var hostMatchStr = RegexHelper.MatchSub(txt_DefaultStorageServer.Text, "(.*[//]?[\\w.]*)[:][0-9]*");
- if (!string.IsNullOrWhiteSpace(hostMatchStr))
- {
- var shareListenPort = jObject.GetJPropertyInt($"$.Share.ListenPort", 9103);
- jObject.SetPropertyValue("Url", $"http://{hostMatchStr.Replace("storage.","www.").Replace("cloud.", "www.")}:{shareListenPort}", $"$.Share");
- }
- var match = RegexHelper.MatchSub(txt_DefaultStorageServer.Text, "[//]?[\\w.]*[:]([0-9]*)");
- if (!string.IsNullOrWhiteSpace(match))
- {
- jObject.SetPropertyValue("InternalUrl", $"127.0.0.1:{match}", $"$.Storage");
- }
- jObject.SetPropertyValue("ListenPort", txt_DefaultUpgradeServer.Text.SubWithToEnd(":").ToInt(), $"$.Upgrade");
- jObject.SetPropertyValue("ListenPort", txt_DefaultDisplayServer.Text.SubWithToEnd(":").ToInt(), $"$.Display");
- jObject.SetPropertyValue("ListenPort", txt_LiveTalkingServer.Text.SubWithToEnd(":").ToInt(), $"$.LiveTalking");
- #endregion
- #region 保存文件夹
- jObject.SetPropertyValue("StorageFolder", txt_StorageFolder.Text, $"$.Storage");
- jObject.SetPropertyValue("UpgradeFolder", txt_UpgradeFolder.Text, $"$.Upgrade");
- jObject.SetPropertyValue("CacheFolder", txt_CacheFolder.Text, $"$.Display");
- jObject.SetPropertyValue("ReportPostFolder", txt_ReportPostFolder.Text, $"$.Report");
- jObject.SetPropertyValue("ApiCacheFolder", txt_MApiCacheFolder.Text, $"$.Management");
- #endregion
- #region 保存服务Api
- jObject.SetPropertyValue("Url", txt_ApiUrl.Text, $"$.API");
- jObject.SetPropertyValue("ReportUrl", txt_ReportUrl.Text, $"$.Report");
- jObject.SetPropertyValue("Url", txt_DefaultStorageServer.Text, $"$.Storage");
- jObject.SetPropertyValue("DefaultUpgradeServer", txt_DefaultUpgradeServer.Text, $"$.Upgrade");
- jObject.SetPropertyValue("DefaultDisplayServer", txt_DefaultDisplayServer.Text, $"$.Remedical");
- jObject.SetPropertyValue("Url", txt_LiveTalkingServer.Text, $"$.LiveTalking");
- jObject.SetPropertyValue("GetReportApiUrl", txt_MGetReportApiUrl.Text, $"$.Management");
- jObject.SetPropertyValue("DownloadApiUrl", txt_MDownloadApiUrl.Text, $"$.Management");
- jObject.SetPropertyValue("GetUnityPayLink", txt_GetUnityPayLink.Text, $"$.OrderForm");
- //DefaultStorageServer
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Chat");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Display");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.AssignTerminal");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Remedical");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Report");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.AfterSales");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.API");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Training");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Admin");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Carotid");
- jObject.SetPropertyValue("DefaultStorageServer", txt_DefaultStorageServer.Text, $"$.Teaching");
- #endregion
- #region 保存配置
- jObject.SetPropertyValue("MailHost", txt_MailHost.Text, $"$.RegisterAccount");
- jObject.SetPropertyValue("EmailUserName", txt_EmailUserName.Text, $"$.RegisterAccount");
- jObject.SetPropertyValue("EmailUserPassword", txt_EmailUserPassword.Text, $"$.RegisterAccount");
- jObject.SetPropertyValue("SmtpPort", txt_SmtpPort.Text, $"$.RegisterAccount");
- jObject.SetPropertyValue("UseSSL", ck_isssl.IsChecked != null && ck_isssl.IsChecked.Value ? "true" : "false", $"$.RegisterAccount");
- #endregion
- #region 保存支付配置
- jObject.SetPropertyValue("ServiceUrl", txt_PayServiceUrl.Text, $"$.Payment");
- jObject.SetPropertyValue("ServicePort", txt_PayServicePort.Text, $"$.Payment");
- jObject.SetPropertyValue("PaySuccessNotifyUrl", txt_PaySuccessNotifyUrl.Text, $"$.Payment");
- jObject.SetPropertyValue("RefundSuccessNotifyUrl", txt_RefundSuccessNotifyUrl.Text, $"$.Payment");
- string alipayJson = JsonConvert.SerializeObject(new
- {
- AppId = txt_Alipay_AppId.Text,
- CharSet = txt_Alipay_CharSet.Text,
- SignType = txt_Alipay_SignType.Text,
- PrivateKey = txt_Alipay_PrivateKey.Text,
- PublicKey = txt_Alipay_PublicKey.Text,
- Gatewayurl = txt_Alipay_Gatewayurl.Text
- });
- jObject.SetPropertyValue("Alipay", alipayJson, $"$.Payment");
- string paypalJson = JsonConvert.SerializeObject(new
- {
- ClientId = txt_Paypal_ClientId.Text,
- ClientSecret = txt_Paypal_ClientSecret.Text,
- UseSandBox = ck_UseSandBox.IsChecked != null && ck_UseSandBox.IsChecked.Value ? "1":"0"
- });
- jObject.SetPropertyValue("Paypal", paypalJson, $"$.Payment");
- string wechatJson = JsonConvert.SerializeObject(new
- {
- AppID = txt_Wechat_AppID.Text,
- MchID = txt_Wechat_MchID.Text,
- Key = txt_Wechat_Key.Text,
- AppSecret = txt_Wechat_AppSecret.Text,
- SSlCertPassword = txt_Wechat_SSlCertPassword.Text
- });
- jObject.SetPropertyValue("Wechat", wechatJson, $"$.Payment");
- #endregion
- _jObject.SaveJson();
- ((JObject)_jObjectSystemConfig.GetJsonRoot()).AddChild("ServerConfig", _jObject.GetJsonRoot());
- }
- /// <summary>
- /// 系统配置
- /// </summary>
- private void SaveSystemConfig(JObject jObjectSystemConfig)
- {
- if (jObjectSystemConfig == null) { return; }
- jObjectSystemConfig.AddChild("ManagementStartPort", txt_ManagementStartPort.Text);
- PageBags.SetData("ManagementPort", txt_ManagementStartPort.Text);
- PageBags.SetData("VideoPort", txt_VideoPort.Text);
- jObjectSystemConfig.AddChild("SystemInstallationPath", txt_Systeminstallationpath.Text);
- PageBags.SetData("txt_Systeminstallationpath", txt_Systeminstallationpath.Text);
- jObjectSystemConfig.AddChild("ServerDomainName", txt_Serverdomainname.Text);
- jObjectSystemConfig.AddChild("IsBak", cb_isBak.IsChecked != null && cb_isBak.IsChecked.Value ? 1 : 0);
- PageBags.SetData("isBak", cb_isBak.IsChecked != null && cb_isBak.IsChecked.Value ? 1 : 0);
- jObjectSystemConfig.AddChild("UseTestServer", cb_useTestServer.IsChecked != null && cb_useTestServer.IsChecked.Value ? 1 : 0);
- PageBags.SetData("UseTestServer", cb_useTestServer.IsChecked != null && cb_useTestServer.IsChecked.Value ? 1 : 0);
- if (grid_dependPack.Children.Count > 0)
- {
- JObject childNode = JObject.Parse("{}");
- foreach (UIElement child in grid_dependPack.Children)
- {
- var cbChild = (CheckBox) child;
- var childName = cbChild.Name;
- var isChecked = cbChild.IsChecked;
- var childValue = (isChecked != null && isChecked.Value) ? 1 : 0;
- childNode.AddChild(childName, childValue);
- }
- jObjectSystemConfig.AddChild("DependpackConfig", childNode);
- }
- _jObjectSystemConfig.SaveJson();
- }
- #region 文件夹创建及检查
- private bool CreateAndCheckDir()
- {
- try
- {
- PageBags.SetData("txt_ApiCacheFolder", txt_ApiCacheFolder.Text);
- PageBags.SetData("txt_Systeminstallationpath", txt_Systeminstallationpath.Text);
- PageBags.SetData("txt_StorageFolder", txt_StorageFolder.Text);
- PageBags.SetData("txt_UpgradeFolder", txt_UpgradeFolder.Text);
- PageBags.SetData("txt_CacheFolder", txt_CacheFolder.Text);
- PageBags.SetData("txt_ReportPostFolder", txt_ReportPostFolder.Text);
- PageBags.SetData("txt_MApiCacheFolder", txt_MApiCacheFolder.Text);
- MakeDirHandler makeDirHandler = new MakeDirHandler();
- makeDirHandler.HandleRequestAsyn();
- return true;
- }
- catch
- {
- return false;
- }
- }
- #endregion
- private bool CheckRequiredFields()
- {
- List<bool> isRequiredFields = new List<bool>();
- isRequiredFields.Add(txt_Systeminstallationpath.Text.VerifyField(this, $"{lb_Systeminstallationpath.Content} is Empty!"));
- isRequiredFields.Add(!txt_LiveVideoAddress.IsEnabled || txt_LiveVideoAddress.Text.VerifyField(this, $"{lb_LiveVideoAddressLabel.Content} is Empty!"));
- isRequiredFields.Add(txt_StatisticsPort.Text.VerifyField(this, $"{lb_StatisticsPort.Content} is Empty!"));
- isRequiredFields.Add(txt_GatewayPort.Text.VerifyField(this, $"{lb_ManagementPort.Content} is Empty!"));
- isRequiredFields.Add(txt_ManagementPort.Text.VerifyField(this, $"{lb_LiveVideoAddressLabel.Content} is Empty!"));
- isRequiredFields.Add(txt_DatabasePort.Text.VerifyField(this, $"{lb_DatabasePort.Content} is Empty!"));
- isRequiredFields.Add(txt_LogDbPort.Text.VerifyField(this, $"{lb_LogDbPort.Content} is Empty!"));
- isRequiredFields.Add(txt_LogViewerPort.Text.VerifyField(this, $"{lb_LogViewerPort.Content} is Empty!"));
- isRequiredFields.Add(txt_StorageFolder.Text.VerifyField(this, $"{lb_StorageFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_CacheFolder.Text.VerifyField(this, $"{lb_CacheFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_UpgradeFolder.Text.VerifyField(this, $"{lb_UpgradeFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_ReportPostFolder.Text.VerifyField(this, $"{lb_ReportPostFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_MApiCacheFolder.Text.VerifyField(this, $"{lb_MApiCacheFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_ApiUrl.Text.VerifyField(this, $"{lb_ApiUrl.Content} is Empty!"));
- isRequiredFields.Add(txt_ReportUrl.Text.VerifyField(this, $"{lb_ReportUrl.Content} is Empty!"));
- isRequiredFields.Add(txt_DefaultStorageServer.Text.VerifyField(this, $"{lb_DefaultStorageServer.Content} is Empty!"));
- isRequiredFields.Add(txt_DefaultUpgradeServer.Text.VerifyField(this, $"{lb_DefaultUpgradeServer.Content} is Empty!"));
- isRequiredFields.Add(txt_DefaultDisplayServer.Text.VerifyField(this, $"{lb_DefaultDisplayServer.Content} is Empty!"));
- isRequiredFields.Add(txt_LiveTalkingServer.Text.VerifyField(this, $"{lb_LiveTalkingServer.Content} is Empty!"));
- isRequiredFields.Add(txt_ManagementStartPort.Text.VerifyField(this, $"{lb_ManagementStartPort.Content} is Empty!"));
- isRequiredFields.Add(txt_ServerHost.Text.VerifyField(this, $"{lb_ServerHost.Content} is Empty!"));
- isRequiredFields.Add(txt_ServerPort.Text.VerifyField(this, $"{lb_ServerPort.Content} is Empty!"));
- isRequiredFields.Add(txt_GetReportApiUrl.Text.VerifyField(this, $"{lb_GetReportApiUrl.Content} is Empty!"));
- isRequiredFields.Add(txt_ApiCacheFolder.Text.VerifyField(this, $"{lb_ApiCacheFolder.Content} is Empty!"));
- isRequiredFields.Add(txt_MGetReportApiUrl.Text.VerifyField(this, $"{lb_MGetReportApiUrl.Content} is Empty!"));
- isRequiredFields.Add(txt_MApiCacheFolder.Text.VerifyField(this, $"{lb_MApiCacheFolder.Content} is Empty!"));
- if (isRequiredFields.Any(req => req == false))
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 文件复制操作
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- private object CopyFiles(object obj = null)
- {
- string installAddress = FuncInOutHelper.RunDelegate("GetInstallPath") as string;
- PageBags.SetData("installAddress", installAddress);
- bool isBak = (string)FuncInOutHelper.RunDelegate("GetIsBak") == "1";
- PageBags.SetData("isBak", isBak ? 1 : 0);
- bool useTestServer = (string)FuncInOutHelper.RunDelegate("GetUseTestServer") == "1";
- PageBags.SetData("UseTestServer", useTestServer ? 1 : 0);
- string upgradePath = FuncInOutHelper.RunDelegate("GetUpgradePath") as string;
- PageBags.SetData("upgradePath", upgradePath);
- int liveVideoType = (int)FuncInOutHelper.RunDelegate("GetLiveVideoTypeSelectIndex");
- PageBags.SetData("liveVideoType", liveVideoType);
- CopyFileHandler copyFileHandler = new CopyFileHandler();
- copyFileHandler.SetSuccessor(
- () => //success
- {
- FuncInOutHelper.RunDelegate("JumpToFinish");
- },
- ex => //fail
- {
- FuncInOutHelper.RunDelegate("OpenHintShow");
- }
- );
- copyFileHandler.HandleRequestAsyn();
- return null;
- }
- private void SaveAllSettings()
- {
- SaveSettings(_jObject.GetJsonRoot());
- SaveManagementSettings(_jObjectManagement.GetJsonRoot());
- SaveVideoServerSettings(_jObjectVideoConfig.GetJsonRoot());
- SaveSystemConfig((JObject)_jObjectSystemConfig.GetJsonRoot());
- }
- /// <summary>
- /// 安装依赖包
- /// </summary>
- private void RunScript()
- {
- PageBags.SetData("DependNetCore",FuncInOutHelper.RunDelegate("GetTagValue", "tb_netcore") as string);
- PageBags.SetData("DependNodeJs", FuncInOutHelper.RunDelegate("GetTagValue", "tb_nodejs") as string);
- DependPackageHandler dependPackageHandler = new DependPackageHandler();
- dependPackageHandler.SetSuccessor(
- () => //success
- {
- CopyFiles();
- },
- ex => //fail
- {
- FuncInOutHelper.RunDelegate("MessageBox", ex.Message);
- FuncInOutHelper.RunDelegate("ApplicationExit");
- }
- );
- dependPackageHandler.HandleRequestAsyn();
- }
- #region 事件
- /// <summary>
- /// 选择LiveVideo
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (IsInitialized)
- {
- if (((ComboBox)sender).SelectedIndex == 1)
- {
- txt_LiveVideoAddress.IsEnabled = true;
- lb_LiveVideoAddressLabel.IsEnabled = true;
- }
- else
- {
- txt_LiveVideoAddress.IsEnabled = false;
- lb_LiveVideoAddressLabel.IsEnabled = false;
- }
- }
- }
- private void BtnStorageFolder_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_StorageFolder.Text = folderAddress;
- }
- }
- private void BtnUpgradeFolder_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_UpgradeFolder.Text = folderAddress;
- }
- }
- private void BtnCacheFolder_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_CacheFolder.Text = folderAddress;
- }
- }
- private void BtnReportPostFolder_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_ReportPostFolder.Text = folderAddress;
- }
- }
- private void BtnMApiCacheFolder_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_MApiCacheFolder.Text = folderAddress;
- }
- }
- /// <summary>
- /// 安装操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Install_Click(object sender, RoutedEventArgs e)
- {
- InstallProcess installProcess = new InstallProcess();
- installProcess.Show();
- Task.Run(() =>
- {
- try
- {
- var systemPackageName = "SystemPackage.zip";
- RemoteDeploymentBuilder.RunBuilder(systemPackageName, "VinnoAdmin");
- Dispatcher.Invoke(() =>
- {
- installProcess.Close();
- Finish finish = new Finish();
- finish.Show();
- });
- SqlExecute.ExecuteSql("insert into PublishLog(UserName,PublishTime,PublishContent) values(?,?,?)", "VinnoAdmin", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), systemPackageName);
- }
- finally {
- Dispatcher.Invoke(() =>
- {
- if (installProcess.IsActive)
- {
- installProcess.Close();
- }
- });
- }
- });
- }
- private void Exit_Click(object sender, RoutedEventArgs e)
- {
- Close();
- Application.Current.Shutdown();
- }
- private void Btn_Setdomain_Click(object sender, RoutedEventArgs e)
- {
- if (!string.IsNullOrWhiteSpace(txt_Serverdomainname.Text))
- {
- txt_ServerUrl.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_ApiUrl.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_ReportUrl.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_DefaultStorageServer.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_DefaultUpgradeServer.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_DefaultDisplayServer.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_LiveTalkingServer.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_LiveVideoAddress.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_GetReportApiUrl.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_MGetReportApiUrl.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_GetUnityPayLink.ReplaceTextBoxValue("[//]?([\\w.]*)[:][0-9]", txt_Serverdomainname.Text);
- txt_ServerHost.Text = txt_Serverdomainname.Text;
- }
- }
- private void Btn_Chose_Click(object sender, RoutedEventArgs e)
- {
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- txt_Systeminstallationpath.Text = folderAddress;
- }
- string installDir = txt_Systeminstallationpath.Text;
- LoadOldSettingFile(installDir);
- }
- private void Cb_ChooseLanguage_DropDownClosed(object sender, EventArgs e)
- {
- var language = (string)((TextBlock)((ComboBox)sender).SelectedValue).Tag;
- InitializeLanguage(language);
- var systemConfig = (JObject)_jObjectSystemConfig.GetJsonRoot();
- systemConfig.AddChild("Language", language);
- _jObjectSystemConfig.SaveJson();
- InfomationTabs infomationTabs = new InfomationTabs();
- infomationTabs.Show();
- Close();
- }
- private string _systeminstallationpath = "D:\\Vinno\\System\\";
- private void Txt_Systeminstallationpath_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (IsInit && _systeminstallationpath != txt_Systeminstallationpath.Text)
- {
- if (!string.IsNullOrWhiteSpace(txt_Systeminstallationpath.Text))
- {
- string installDir = txt_Systeminstallationpath.Text;
- LoadOldSettingFile(installDir);
- _systeminstallationpath = txt_Systeminstallationpath.Text;
- }
- }
- }
- private void Export_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- SaveAllSettings();
- string folderAddress;
- if (!string.IsNullOrWhiteSpace(folderAddress = FolderBrowserDialogHelper.OpenFolderBrowserDialog()))
- {
- _jObject.OtherSaveJson(folderAddress + "\\Setting.conf");
- _jObjectSystemConfig.OtherSaveJson(folderAddress + "\\SystemConfig.json");
- }
- }
- catch
- {
- this.ShowMessageBox($"{TranslateHelper.Translate("SettingsError")}!");
- }
- }
- private void Sel_StoreDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- var drive = ((TextBlock)sel_StoreDrive.SelectedValue).Text;
- txt_StorageFolder.ReplaceTextBoxValue("[a-zA-Z]{1}[:]{1}\\\\", $"{drive}:\\");
- txt_CacheFolder.ReplaceTextBoxValue("[a-zA-Z]{1}[:]{1}\\\\", $"{drive}:\\");
- txt_UpgradeFolder.ReplaceTextBoxValue("[a-zA-Z]{1}[:]{1}\\\\", $"{drive}:\\");
- txt_ReportPostFolder.ReplaceTextBoxValue("[a-zA-Z]{1}[:]{1}\\\\", $"{drive}:\\");
- txt_MApiCacheFolder.ReplaceTextBoxValue("[a-zA-Z]{1}[:]{1}\\\\", $"{drive}:\\");
- }
- private void Cb_StorageProvider_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (IsInitialized)
- {
- if (((ComboBox)sender).SelectedIndex == 1)
- {
- txt_StoageVideoFolder.IsEnabled = true;
- txt_ServerUrl.IsEnabled = true;
- //txt_AppKey.IsEnabled = true;
- //txt_AppSecret.IsEnabled = true;
- txt_VideoPort.IsEnabled = true;
- }
- else
- {
- txt_StoageVideoFolder.IsEnabled = false;
- txt_ServerUrl.IsEnabled = false;
- //txt_AppKey.IsEnabled = false;
- //txt_AppSecret.IsEnabled = false;
- txt_VideoPort.IsEnabled = false;
- }
- }
- }
- private void Cb_StorageProvider_Loaded(object sender, RoutedEventArgs e)
- {
- if (IsInitialized)
- {
- if (((ComboBox)sender).SelectedIndex == 1)
- {
- txt_StoageVideoFolder.IsEnabled = true;
- txt_ServerUrl.IsEnabled = true;
- //txt_AppKey.IsEnabled = true;
- //txt_AppSecret.IsEnabled = true;
- txt_VideoPort.IsEnabled = true;
- }
- else
- {
- txt_StoageVideoFolder.IsEnabled = false;
- txt_ServerUrl.IsEnabled = false;
- //txt_AppKey.IsEnabled = false;
- //txt_AppSecret.IsEnabled = false;
- txt_VideoPort.IsEnabled = false;
- }
- }
- }
- /// <summary>
- /// 上传证书
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Btn_UploadCert_Click(object sender, RoutedEventArgs e)
- {
- using (var stream = FolderBrowserDialogHelper.OpenFileBrowserDialog("p12"))
- {
- if (stream != Stream.Null)
- {
- using (FileStream fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\apiclient_cert.p12", FileMode.Create))
- {
- byte[] readBytes = new byte[4096];
- int readCount;
- do
- {
- readCount = stream.Read(readBytes, 0, readBytes.Length);
- fileStream.Write(readBytes, 0, readCount);
- } while (readCount > 0);
- ShowUploadState();
- this.ShowMessageBox($"{TranslateHelper.Translate("UploadSuccess")}");
- }
- }
- }
- }
- private void ShowUploadState()
- {
- if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\apiclient_cert.p12"))
- {
- txt_Wechat_SSlCertData.Content = "apiclient_cert.p12";
- }
- else
- {
- txt_Wechat_SSlCertData.Content = "";
- }
- }
- #endregion
- #region ui线程调用方法
- private object CloseWindow(object obj = null)
- {
- Close();
- return null;
- }
- private string GetIsBak(object obj = null)
- {
- return cb_isBak.IsChecked != null && cb_isBak.IsChecked.Value ? "1" : "0";
- }
- private string GetUseTestServer(object obj = null)
- {
- return cb_useTestServer.IsChecked != null && cb_useTestServer.IsChecked.Value ? "1" : "0";
- }
- private object GetTagValue(object controlName)
- {
- var control = FindName((string)controlName);
- if (control is CheckBox)
- {
- var checkBox = (CheckBox)control;
- if (checkBox.IsChecked != null && checkBox.IsChecked.Value)
- {
- return (string)checkBox.Tag;
- }
- }
- return "";
- }
- private object OpenHintShow(object obj = null)
- {
- HintShow hint = new HintShow(CopyFiles, CloseShowInstallProcess);
- hint.Show();
- return null;
- }
- private object CloseShowInstallProcess(object obj = null)
- {
- _installProcess?.Close();
- return null;
- }
- private string GetUpgradePath(object obj = null)
- {
- return txt_UpgradeFolder.Text;
- }
- private string GetInstallPath(object obj = null)
- {
- return txt_Systeminstallationpath.Text.Trim('\\') + "\\";
- }
- private object JumpToFinish(object obj = null)
- {
- Finish finish = new Finish();
- finish.Show();
- _installProcess.Close();
- Close();
- return null;
- }
- private object GetLiveVideoTypeSelectIndex(object obj = null)
- {
- return cb_LiveVideoType.SelectedIndex;
- }
- private object MessageBox(object obj = null)
- {
- this.ShowMessageBox(obj as string);
- return null;
- }
- #endregion
- /// <summary>
- /// 初始化语言包
- /// </summary>
- /// <param name="currentLanguage"></param>
- private void InitializeLanguage(string currentLanguage)
- {
- var assemblyName = GetType().Assembly.GetName().Name;
- foreach (var supportedLanguage in TranslateHelper.SupportedLanguages)
- {
- var resourceName = $"{assemblyName}.Common.Languages.{supportedLanguage}.json";
- using (var languageStream = GetType().Assembly.GetManifestResourceStream(resourceName))
- {
- if (languageStream != null)
- {
- var reader = new StreamReader(languageStream);
- var content = reader.ReadToEnd();
- TranslateHelper.AddLanguageResource(supportedLanguage, content);
- }
- }
- }
- if (TranslateHelper.SupportedLanguages.FirstOrDefault(v => v == currentLanguage) != null)
- {
- TranslateHelper.CurrentLanguage = currentLanguage;
- }
- else
- {
- TranslateHelper.CurrentLanguage = TranslateHelper.SupportedLanguages.FirstOrDefault();
- }
- }
- /// <summary>
- /// 加载安装目录配置
- /// </summary>
- /// <param name="installDir"></param>
- private void LoadOldSettingFile(string installDir)
- {
- if (!string.IsNullOrWhiteSpace(installDir) && Directory.Exists(installDir))
- {
- txt_Systeminstallationpath.Text = installDir.Trim('\\') + "\\";
- SettingJsonGet oldJObject = new SettingJsonGet($"{txt_Systeminstallationpath.Text}Server\\Settings\\Server\\Setting.conf");
- LoadSetting(oldJObject.GetJsonRoot());
- SettingJsonGet oldJObjectManagement = new SettingJsonGet($"{txt_Systeminstallationpath.Text}Management\\appsettings.json");
- LoadManagementSetting(oldJObjectManagement.GetJsonRoot());
- SettingJsonGet oldJObjectVideoServer = new SettingJsonGet($"{txt_Systeminstallationpath.Text}VideoServer\\appsettings.json");
- LoadVideoServerSetting(oldJObjectVideoServer.GetJsonRoot());
- if (!_jObject.GetJsonRoot().HasValues)
- {
- _jObject.LoadJson(oldJObject.ToJson());
- }
- if (!_jObjectManagement.GetJsonRoot().HasValues)
- {
- _jObjectManagement.LoadJson(oldJObjectManagement.ToJson());
- }
- if (!_jObjectVideoConfig.GetJsonRoot().HasValues)
- {
- _jObjectVideoConfig.LoadJson(oldJObjectVideoServer.ToJson());
- }
- SaveAllSettings();
- }
- }
- private void Btn_Add_Click(object sender, RoutedEventArgs e)
- {
- if (!string.IsNullOrWhiteSpace(txt_IpAddress.Text) && !_iPWhiteList.Contains(txt_IpAddress.Text) && Regex.IsMatch(txt_IpAddress.Text, "^(2(5[0-5]{1}|[0-4]\\d{1})|[0-1]?\\d{1,2})(\\.(2(5[0-5]{1}|[0-4]\\d{1})|[0-1]?\\d{1,2})){3}$"))
- {
- _iPWhiteList.Add(txt_IpAddress.Text);
- BindIpWhiteList();
- }
- }
- private void DeleteIP_Click(object sender, RoutedEventArgs e)
- {
- var value = (dynamic)dtgIpWhiteList.SelectedItem;
- _iPWhiteList = _iPWhiteList.Where(f => f != value.IP).ToList();
- BindIpWhiteList();
- }
- private void BindIpWhiteList()
- {
- var systemConfig = (JObject)_jObjectSystemConfig.GetJsonRoot();
- systemConfig.AddChild("IPWhiteList", _iPWhiteList);
- _jObjectSystemConfig.SaveJson();
- dtgIpWhiteList.ItemsSource = null;
- dtgIpWhiteList.ItemsSource = _iPWhiteList.Select(x => new { IP = x });
- }
- }
- }
|