protected virtual void SaveGame(StreamWriter writer) { Debug.Assert(writer.BaseStream.Position == 0, "You need to call base.SaveGame() at the top of your override as it writes the header information."); writer.WriteLine(FileKey); writer.WriteLine(CurrentVersion.ToString()); writer.WriteLine(stateValues.Count); foreach (var pair in stateValues) { writer.Write(pair.Key); if (pair.Value is bool) { writer.Write(";BOOL;"); writer.WriteLine((bool)pair.Value); } else if (pair.Value is int) { writer.Write(";INT;"); writer.WriteLine((int)pair.Value); } else if (pair.Value is string) { writer.Write(";STRING;"); writer.WriteLine((pair.Value as string) ?? string.Empty); } } }
public void OnPackageLoad(IdeIntegration ideIntegration) { IdeIntegration = ideIntegration; if (IsDevBuild) { tracer.Trace("Running on 'dev' version on {0}", this, ideIntegration); } var today = DateTime.Today; var status = GetInstallStatus(); if (!status.IsInstalled) { // new user if (ShowNotification(GuidanceNotification.AfterInstall)) { status.InstallDate = today; status.InstalledVersion = CurrentVersion; status.LastUsedDate = today; UpdateStatus(status); CheckFileAssociation(); } } else if (status.InstalledVersion < CurrentVersion) { //upgrading user CheckFileAssociation(); } _analyticsTransmitter.TransmitExtensionLoadedEvent(CurrentVersion.ToString()); }
private void DoInit(bool isWork, Action callback) { this.ServerAppSettingSet = new ServerAppSettingSet(this); this.CalcConfigSet = new CalcConfigSet(this); ServerContextInit(isWork); this.GpuProfileSet = new GpuProfileSet(this); this.WorkerEventSet = new WorkerEventSet(this); this.UserSet = new UserSet(); this.KernelProfileSet = new KernelProfileSet(this); this.GpusSpeed = new GpusSpeed(this); this.CoinShareSet = new CoinShareSet(this); this.MineWorkSet = new MineWorkSet(this); this.MinerGroupSet = new MinerGroupSet(this); this.OverClockDataSet = new OverClockDataSet(this); this.ColumnsShowSet = new ColumnsShowSet(this); IsJsonLocal = isWork; this._minerProfile = new MinerProfile(this); // 这几个注册表内部区分挖矿端和群控客户端 NTMinerRegistry.SetLocation(VirtualRoot.AppFileFullName); NTMinerRegistry.SetArguments(string.Join(" ", CommandLineArgs.Args)); NTMinerRegistry.SetCurrentVersion(CurrentVersion.ToString()); NTMinerRegistry.SetCurrentVersionTag(CurrentVersionTag); if (VirtualRoot.IsMinerClient) { OfficialServer.GetTimeAsync((remoteTime) => { if (Math.Abs((DateTime.Now - remoteTime).TotalSeconds) < Timestamp.DesyncSeconds) { Logger.OkDebugLine("时间同步"); } else { Write.UserWarn($"本机时间和服务器时间不同步,请调整,本地:{DateTime.Now},服务器:{remoteTime}"); } }); Report.Init(this); Link(); // 当显卡温度变更时守卫温度防线 TempGruarder.Instance.Init(this); // 因为这里耗时500毫秒左右 Task.Factory.StartNew(() => { Windows.Error.DisableWindowsErrorUI(); if (NTMinerRegistry.GetIsAutoDisableWindowsFirewall()) { Windows.Firewall.DisableFirewall(); } Windows.UAC.DisableUAC(); Windows.WAU.DisableWAUAsync(); Windows.Defender.DisableAntiSpyware(); Windows.Power.PowerCfgOff(); Windows.BcdEdit.IgnoreAllFailures(); }); } callback?.Invoke(); }
private void DoInit(bool isWork, Action callback) { GpuProfileSet.Instance.Register(this); this.ServerAppSettingSet = new ServerAppSettingSet(this); this.CalcConfigSet = new CalcConfigSet(this); ServerContextInit(isWork); this.WorkerEventSet = new WorkerEventSet(this); this.UserSet = new UserSet(); this.KernelProfileSet = new KernelProfileSet(this); this.GpusSpeed = new GpusSpeed(this); this.CoinShareSet = new CoinShareSet(this); this.MineWorkSet = new MineWorkSet(this); this.MinerGroupSet = new MinerGroupSet(this); this.OverClockDataSet = new OverClockDataSet(this); this.ColumnsShowSet = new ColumnsShowSet(this); MineWorkData mineWorkData = null; if (isWork) { mineWorkData = LocalJson.MineWork; } this._minerProfile = new MinerProfile(this, mineWorkData); // 这几个注册表内部区分挖矿端和群控客户端 NTMinerRegistry.SetLocation(VirtualRoot.AppFileFullName); NTMinerRegistry.SetArguments(string.Join(" ", CommandLineArgs.Args)); NTMinerRegistry.SetCurrentVersion(CurrentVersion.ToString()); NTMinerRegistry.SetCurrentVersionTag(CurrentVersionTag); callback?.Invoke(); }
/// <summary> /// Сохраняет изменения, сделанные в модели. /// </summary> public void Save(XmlDocument document) { WriteProperty(document, VERSION_PROPERTY, CurrentVersion.ToString(CultureInfo.InvariantCulture)); if (!string.IsNullOrWhiteSpace(Environment)) { WriteProperty(document, ENV_PROPERTY, Environment); } }
protected virtual void SetupVersionSkipping() { using (var updateKey = Registry.CurrentUser.CreateSubKey(RegistryLocation)) if (updateKey != null) { updateKey.SetValue("version", CurrentVersion.ToString()); updateKey.SetValue("skip", 1); } }
/// <summary> /// Constructor with dependencies /// </summary> /// <param name="coreConfiguration">ICoreConfiguration</param> /// <param name="greenshotLanguage">IGreenshotLanguage</param> public UpdateService( ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage) { _coreConfiguration = coreConfiguration; _greenshotLanguage = greenshotLanguage; LatestVersion = CurrentVersion = GetType().Assembly.GetName().Version; _coreConfiguration.LastSaveWithVersion = CurrentVersion.ToString(); }
private void UpdateNotes_OnLoaded(object sender, RoutedEventArgs e) { _fullReleaseNotes = new List <GithubRelease> { new GithubRelease { Name = "Loading...", Body = "Loading...", TagName = CurrentVersion.ToString(true) } }; OnPropertyChanged(nameof(ReleaseNotes)); }
private static void ParseVersionString(string versionString) { try { string[] data = string.IsNullOrEmpty(versionString) ? null : versionString.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); string version = CurrentVersion.ToString(); // parse received data for version info: if (data != null) { foreach (string s in data) { if (s.StartsWith(ParamVersionName, StringComparison.CurrentCultureIgnoreCase)) { version = s.Substring(s.IndexOfAny(ParamValueSeparators) + 1).Trim(); break; } } } // remember the server version: lock (syncObject) { try { serverVersion = new Version(version); } catch (Exception ex) { Trace.WriteLine(string.Format("Invalid version info retrieved from the server: '{0}'", version)); Trace.WriteLine(ex.Message); serverVersion = InvalidVersion; } } // both version should be known here, so fire the proper notifications: lock (syncList) { foreach (VersionCheckHandler c in listeners) { c(currentVersion, serverVersion, ReleaseURL); } // and never call them again... listeners.Clear(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// Gets the mod info that is currently in the install log, indexed by mod key. /// </summary> /// <returns>The mod info that is currently in the install log, indexed by mod key.</returns> private IDictionary <string, IMod> GetInstallLogModInfo() { var loggedModInfo = new Dictionary <string, IMod>(); var log = XDocument.Load(LogPath); var logVersion = log.Element("installLog")?.Attribute("fileVersion")?.Value; if (!CurrentVersion.ToString().Equals(logVersion)) { throw new Exception($"Invalid Install Log version: \"{logVersion}\", expected \"{CurrentVersion}\"."); } var modList = log.Descendants("modList").FirstOrDefault(); if (modList != null) { foreach (var mod in modList.Elements("mod")) { var modPath = mod.Attribute("path")?.Value; if (!OriginalValueMod.Filename.Equals(modPath) && !ModManagerValueMod.Filename.Equals(modPath)) { if (string.IsNullOrEmpty(modPath)) { throw new Exception($"Could not determine path to mod \"{mod}\""); } modPath = Path.Combine(ModInstallDirectory, modPath); var version = mod.Element("version"); var humanReadableVersion = version?.Attribute("machineVersion")?.Value; var machineVersion = string.IsNullOrEmpty(humanReadableVersion) ? null : new Version(humanReadableVersion); humanReadableVersion = version?.Value; var modName = mod.Element("name")?.Value; var installDate = "<No Data>"; if (mod.Element("installDate") != null) { installDate = mod.Element("installDate")?.Value; } IMod dummyMod = new DummyMod(modName, modPath, machineVersion, humanReadableVersion, "", installDate); var loggedModInfoKey = mod.Attribute("key")?.Value; if (loggedModInfoKey != null) { loggedModInfo[loggedModInfoKey] = dummyMod; } } } } return(loggedModInfo); }
public ListViewItem GetPluginsStoreItem() { var packageVersion = new Version(Package.Version.Version.Major, Package.Version.Version.Minor, Package.Version.Version.Build, Package.Version.Version.Revision); var item = new ListViewItem(string.Empty); item.Tag = this; item.SubItems.Add(this.ToString()); item.SubItems.Add(packageVersion.ToString()); item.SubItems.Add(CurrentVersion?.ToString()); item.SubItems.Add(Package.Description); item.SubItems.Add(string.Join(", ", Package.Authors)); var actionItem = item.SubItems.Add("None"); item.SubItems.Add(Package.DownloadCount.ToString()); if (currentVersionDownloadsCount.ContainsKey(Package.Id.ToLower())) { item.SubItems.Add(currentVersionDownloadsCount[Package.Id.ToLowerInvariant()].ToString()); } else { item.SubItems.Add("N/A"); } switch (Action) { case PackageInstallAction.Unavailable: actionItem.Text = "Incompatible"; item.ForeColor = Color.Red; break; case PackageInstallAction.Update: actionItem.Text = "Update"; item.ForeColor = Color.Blue; break; case PackageInstallAction.Install: actionItem.Text = "Install"; item.ForeColor = Color.Black; break; case PackageInstallAction.None: default: actionItem.Text = "N/A"; item.ForeColor = Color.Gray; break; } return(item); }
public ListViewItem GetPluginsStoreItem() { var packageVersion = new Version(Version); var item = new ListViewItem(Name) { Tag = this }; item.SubItems.Add(Name); item.SubItems.Add(AverageFeedbackRating.ToString("N2")); item.SubItems.Add(packageVersion.ToString()); item.SubItems.Add(CurrentVersion?.ToString()); item.SubItems.Add(LatestReleaseDate?.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)); item.SubItems.Add(Description); item.SubItems.Add(Authors); var actionItem = item.SubItems.Add("None"); item.SubItems.Add(TotalDownloadCount.ToString("N0")); item.SubItems.Add(AverageDownloadCount.ToString("N2")); switch (Action) { case PackageInstallAction.Unavailable: actionItem.Text = "Incompatible"; item.ForeColor = Color.Red; break; case PackageInstallAction.Update: actionItem.Text = "Update"; item.ForeColor = Color.Blue; break; case PackageInstallAction.Install: actionItem.Text = "Install"; item.ForeColor = Color.Black; break; default: actionItem.Text = "N/A"; item.ForeColor = Color.Gray; break; } return(item); }
private void CheckUpdate() { using (CIV.CentralCenterClient.CentralCenterServiceReference.CentralCenterSoapClient client = new CIV.CentralCenterClient.CentralCenterServiceReference.CentralCenterSoapClient()) { if (client.IsCompatibleClient(App.VersionStr())) { if (client.IsLastVersion("CIV", CurrentVersion.ToString())) { DoUpdateNotAvailable(); } else { CIV.CentralCenterClient.CentralCenterServiceReference.ReleaseBO lastReleaseBO = client.GetLastVersion("CIV"); _lastVersion = new CIVVersion(lastReleaseBO.Number); if (LastVersion.CompareTo(CurrentVersion) > 0) { FileRelease release = new FileRelease() { Number = new CIVVersion(lastReleaseBO.Number), Release = lastReleaseBO.Release, Size = lastReleaseBO.Size, Url = lastReleaseBO.Url, History = lastReleaseBO.History, CRC = lastReleaseBO.CRC }; DoUpdateAvailable(new UpdateAvailabledEventArgs(release)); } else { DoUpdateNotAvailable(); } } } else if (IsNotCompatibleClient != null) { IsNotCompatibleClient(this, null); } } }
public void ConnectToServer(string ip, int port = 0, bool passProtected = false, string myPass = "") { try { if (IsOnServer()) { Client.Disconnect("Switching servers"); Wait(1000); } JavascriptHook.StopAllScripts(); JavascriptHook.TextElements.Clear(); ShowLoadingPrompt("Loading"); Function.Call(Hash.DISPLAY_RADAR, false); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); if (!_minimapSet) { var scal = new Scaleform("minimap"); scal.CallFunction("MULTIPLAYER_IS_ACTIVE", true, false); Function.Call(Hash._SET_RADAR_BIGMAP_ENABLED, true, false); Function.Call(Hash._SET_RADAR_BIGMAP_ENABLED, false, false); _minimapSet = true; } Chat.Init(); Client.Shutdown("Shutdown"); Wait(1000); var cport = GetOpenUdpPort(); if (cport == 0) { Util.Util.SafeNotify("No available UDP port was found."); return; } _config.Port = cport; Client = new NetClient(_config); Client.Start(); lock (Npcs) Npcs = new Dictionary <string, SyncPed>(); lock (_tickNatives) _tickNatives = new Dictionary <string, NativeData>(); var msg = Client.CreateMessage(); var obj = new ConnectionRequest(); obj.SocialClubName = string.IsNullOrWhiteSpace(Game.Player.Name) ? GetMacAddress() : Game.Player.Name; // To be used as identifiers in server files obj.DisplayName = string.IsNullOrWhiteSpace(PlayerSettings.DisplayName) ? obj.SocialClubName : PlayerSettings.DisplayName.Trim(); obj.ScriptVersion = CurrentVersion.ToString(); obj.CEF = !CefUtil.DISABLE_CEF; obj.CEFDevtool = EnableDevTool; obj.GameVersion = (byte)Game.Version; obj.MediaStream = EnableMediaStream; if (passProtected) { if (!string.IsNullOrWhiteSpace(myPass)) { obj.Password = myPass; } else { MainMenu.TemporarilyHidden = true; obj.Password = Game.GetUserInput(""); MainMenu.TemporarilyHidden = false; } } var bin = SerializeBinary(obj); msg.Write((byte)PacketType.ConnectionRequest); msg.Write(bin.Length); msg.Write(bin); try { Client.Connect(ip, port == 0 ? Port : port, msg); } catch (NetException ex) { GTA.UI.Notification.Show("~b~~h~AMP~h~~w~~n~" + ex.Message); OnLocalDisconnect(); return; } var pos = Game.Player.Character.Position; Function.Call(Hash.CLEAR_AREA_OF_PEDS, pos.X, pos.Y, pos.Z, 100f, 0); Function.Call(Hash.CLEAR_AREA_OF_VEHICLES, pos.X, pos.Y, pos.Z, 100f, 0); Function.Call(Hash.SET_GARBAGE_TRUCKS, 0); Function.Call(Hash.SET_RANDOM_BOATS, 0); Function.Call(Hash.SET_RANDOM_TRAINS, 0); Function.Call(Hash.CLEAR_ALL_BROKEN_GLASS); DisableSlowMo(); Game.TimeScale = 1; ResetPlayer(); _currentServerIp = ip; _currentServerPort = port == 0 ? Port : port; } catch (AccessViolationException ex) { LogManager.LogException(ex, "OnPlayerDisconnect"); } }
private void DoInit(bool isWork, Action callback) { this.PackageDownloader = new PackageDownloader(this); this.AppSettingSet = new AppSettingSet(this); this.CalcConfigSet = new CalcConfigSet(this); ContextInit(isWork); if (!string.IsNullOrEmpty(CommandLineArgs.KernelBrand)) { if (SysDicItemSet.TryGetDicItem("KernelBrand", CommandLineArgs.KernelBrand, out ISysDicItem brandItem)) { #region KernelBrandId string brand = $"KernelBrandId{brandItem.GetId()}KernelBrandId"; byte[] data = Encoding.UTF8.GetBytes(brand); if (data.Length != KernelBrandRaw.Length) { throw new InvalidProgramException(); } byte[] source = File.ReadAllBytes(ClientId.AppFileFullName); int index = 0; for (int i = 0; i < source.Length - KernelBrandRaw.Length; i++) { int j = 0; for (; j < KernelBrandRaw.Length; j++) { if (source[i + j] != KernelBrandRaw[j]) { break; } } if (j == KernelBrandRaw.Length) { index = i; break; } } for (int i = index; i < index + data.Length; i++) { source[i] = data[i - index]; } string brandExeFullName = Path.Combine(Path.GetDirectoryName(ClientId.AppFileFullName), Path.GetFileNameWithoutExtension(ClientId.AppFileFullName) + $"_{CommandLineArgs.KernelBrand}.exe"); File.WriteAllBytes(brandExeFullName, source); #endregion Environment.Exit(0); return; } } this.UserSet = new UserSet(); this.KernelProfileSet = new KernelProfileSet(this); this.GpusSpeed = new GpusSpeed(this); this.CoinShareSet = new CoinShareSet(this); this.MineWorkSet = new MineWorkSet(this); this.MinerGroupSet = new MinerGroupSet(this); this.OverClockDataSet = new OverClockDataSet(this); this.ColumnsShowSet = new ColumnsShowSet(this); MineWorkData mineWorkData = null; if (isWork) { mineWorkData = LocalJson.MineWork; } this._minerProfile = new MinerProfile(this, mineWorkData); NTMinerRegistry.SetLocation(ClientId.AppFileFullName); NTMinerRegistry.SetArguments(string.Join(" ", CommandLineArgs.Args)); NTMinerRegistry.SetCurrentVersion(CurrentVersion.ToString()); NTMinerRegistry.SetCurrentVersionTag(CurrentVersionTag); callback?.Invoke(); }
public void Flush() { #if UNITY_EDITOR File.WriteAllBytes(Application.persistentDataPath + "/version.txt", System.Text.Encoding.UTF8.GetBytes(CurrentVersion.ToString())); #else File.WriteAllBytes(Application.persistentDataPath + "/version.txt", System.Text.Encoding.UTF8.GetBytes(CurrentVersion.ToString())); #endif }
/// <summary> /// Checks for an update and pushes a notification out if there is one available (great for checking on startup) /// </summary> /// <returns>If there is an update available</returns> public bool CheckForUpdate() { if (Latest > CurrentVersion) { Notifications.Show(Properties.strings.BackEndUpdateManNewUpdateT, String.Format(Properties.strings.BackEndUpdateManNewUpdate, Latest.ToString(), CurrentVersion.ToString()), NotificationIcon.Update, "action=update"); return(true); } return(false); }
private void DoInit(bool isWork, Action callback) { this.PackageDownloader = new PackageDownloader(this); this.AppSettingSet = new AppSettingSet(this); this.CalcConfigSet = new CalcConfigSet(this); ContextInit(isWork); // 打码支持内核品牌 if (!string.IsNullOrEmpty(CommandLineArgs.KernelBrand)) { if (SysDicItemSet.TryGetDicItem("KernelBrand", CommandLineArgs.KernelBrand, out ISysDicItem brandItem)) { #region KernelBrandId string brand = $"KernelBrandId{brandItem.GetId()}KernelBrandId"; byte[] data = Encoding.UTF8.GetBytes(brand); if (data.Length != KernelBrandRaw.Length) { throw new InvalidProgramException(); } byte[] source = File.ReadAllBytes(ClientId.AppFileFullName); int index = 0; for (int i = 0; i < source.Length - KernelBrandRaw.Length; i++) { int j = 0; for (; j < KernelBrandRaw.Length; j++) { if (source[i + j] != KernelBrandRaw[j]) { break; } } if (j == KernelBrandRaw.Length) { index = i; break; } } for (int i = index; i < index + data.Length; i++) { source[i] = data[i - index]; } string brandExeFullName = Path.Combine(Path.GetDirectoryName(ClientId.AppFileFullName), Path.GetFileNameWithoutExtension(ClientId.AppFileFullName) + $"_{CommandLineArgs.KernelBrand}.exe"); File.WriteAllBytes(brandExeFullName, source); #endregion Environment.Exit(0); return; } } this.UserSet = new UserSet(); this.KernelProfileSet = new KernelProfileSet(this); this.GpusSpeed = new GpusSpeed(this); this.CoinShareSet = new CoinShareSet(this); this.MineWorkSet = new MineWorkSet(this); this.MinerGroupSet = new MinerGroupSet(this); this.OverClockDataSet = new OverClockDataSet(this); this.ColumnsShowSet = new ColumnsShowSet(this); MineWorkData mineWorkData = null; if (isWork) { mineWorkData = LocalJson.MineWork; } this._minerProfile = new MinerProfile(this, mineWorkData); // 这几个注册表内部区分挖矿端和群控客户端 NTMinerRegistry.SetLocation(ClientId.AppFileFullName); NTMinerRegistry.SetArguments(string.Join(" ", CommandLineArgs.Args)); NTMinerRegistry.SetCurrentVersion(CurrentVersion.ToString()); NTMinerRegistry.SetCurrentVersionTag(CurrentVersionTag); #region 发生了用户活动时检查serverJson是否有新版本 VirtualRoot.On <UserActionEvent>("发生了用户活动时检查serverJson是否有新版本", LogEnum.DevConsole, action: message => { OfficialServer.GetJsonFileVersionAsync(AssemblyInfo.ServerJsonFileName, (jsonFileVersion) => { if (!string.IsNullOrEmpty(jsonFileVersion) && JsonFileVersion != jsonFileVersion) { SpecialPath.GetAliyunServerJson((data) => { Write.DevLine($"有新版本{JsonFileVersion}->{jsonFileVersion}"); string rawJson = Encoding.UTF8.GetString(data); SpecialPath.WriteServerJsonFile(rawJson); ReInitServerJson(); bool isUseJson = !DevMode.IsDebugMode || VirtualRoot.IsMinerStudio; if (isUseJson) { // 作业模式下界面是禁用的,所以这里的初始化isWork必然是false ContextReInit(isWork: false); Logger.InfoDebugLine("刷新完成"); } else { Write.DevLine("不是使用的json,无需刷新"); } JsonFileVersion = jsonFileVersion; }); } else { Write.DevLine("server.json没有新版本", ConsoleColor.Green); } }); }); #endregion callback?.Invoke(); }
public void EditorFlush() { #if UNITY_EDITOR File.WriteAllBytes(Application.streamingAssetsPath + "/version.txt", System.Text.Encoding.UTF8.GetBytes(CurrentVersion.ToString())); #endif }
public void Initialize() { int CurrentVersion; _initialized = true; if (!File.Exists(FileName)) { return; } _stream = new FileStream(FileName, FileMode.Open, FileAccess.ReadWrite); _reader = new BinaryReader(_stream); CurrentVersion = _reader.ReadInt32(); if (CurrentVersion < 2) { MessageBox.Show("Wrong version, expecting lib version: " + LibVersion.ToString() + " found version: " + CurrentVersion.ToString() + ".", "Failed to open", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } Count = _reader.ReadInt32(); Images = new List <MImage>(); IndexList = new List <int>(); int frameSeek = 0; if (CurrentVersion >= 3) { frameSeek = _reader.ReadInt32(); } for (int i = 0; i < Count; i++) { IndexList.Add(_reader.ReadInt32()); } for (int i = 0; i < Count; i++) { Images.Add(null); } for (int i = 0; i < Count; i++) { CheckImage(i); } if (CurrentVersion >= 3) { _stream.Seek(frameSeek, SeekOrigin.Begin); var frameCount = _reader.ReadInt32(); for (int i = 0; i < frameCount; i++) { Frames.Add((MirAction)_reader.ReadByte(), new Frame(_reader)); } } }
public void Initialize() { int CurrentVersion; _initialized = true; if (!File.Exists(FileName)) { return; } _stream = new FileStream(FileName, FileMode.Open, FileAccess.ReadWrite); _reader = new BinaryReader(_stream); CurrentVersion = _reader.ReadInt32(); if (CurrentVersion != LibVersion) { MessageBox.Show("版本错误,应为lib版本: " + LibVersion.ToString() + " 当前版本: " + CurrentVersion.ToString() + ".", "Failed to open", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } Count = _reader.ReadInt32(); Images = new List <MImage>(); IndexList = new List <int>(); for (int i = 0; i < Count; i++) { IndexList.Add(_reader.ReadInt32()); } for (int i = 0; i < Count; i++) { Images.Add(null); } for (int i = 0; i < Count; i++) { CheckImage(i); } }
internal Config() { Attributes["Version"] = CurrentVersion.ToString(); }
public void Load() { Trace.Call(); #if LOG4NET _Logger.Debug("Loading config"); #endif string prefix; // setting required default values prefix = "Server/"; Get(prefix + "BindAddress", "127.0.0.1"); Get(prefix + "Port", 7689); Get(prefix + "Channel", "TCP"); Get(prefix + "Formatter", "binary"); prefix = "Engine/"; var oldConfigVersion = Get <string>(prefix + "ConfigVersion", null); if (!String.IsNullOrEmpty(oldConfigVersion)) { PreviousVersion = new Version(oldConfigVersion); } CurrentVersion = Engine.AssemblyVersion; Get(prefix + "ConfigVersion", CurrentVersion.ToString()); prefix = "Engine/Users/DEFAULT/Interface/"; Get(prefix + "ShowAdvancedSettings", false); Get(prefix + "ShowActivityCounter", true); prefix = "Engine/Users/DEFAULT/Interface/Notebook/"; Get(prefix + "TimestampFormat", "HH:mm"); Get(prefix + "TabPosition", "top"); Get(prefix + "BufferLines", 500); Get(prefix + "EngineBufferLines", 100); Get(prefix + "StripColors", false); Get(prefix + "StripFormattings", false); Get(prefix + "AutoSwitchPersonChats", false); Get(prefix + "AutoSwitchGroupChats", true); prefix = "Engine/Users/DEFAULT/Interface/Notebook/Tab/"; Get(prefix + "NoActivityColor", "#000000"); Get(prefix + "ActivityColor", "#0080FF"); Get(prefix + "EventColor", "#2020C0"); Get(prefix + "HighlightColor", "#E80000"); prefix = "Engine/Users/DEFAULT/Interface/Notebook/Channel/"; Get(prefix + "UserListPosition", "left"); Get(prefix + "TopicPosition", "top"); Get(prefix + "NickColors", true); prefix = "Engine/Users/DEFAULT/Interface/Chat/"; Get(prefix + "BackgroundColor", String.Empty); Get(prefix + "ForegroundColor", String.Empty); Get(prefix + "FontFamily", String.Empty); Get(prefix + "FontStyle", String.Empty); Get(prefix + "FontSize", 0); Get(prefix + "WrapMode", "Word"); Get(prefix + "Emojis", false); prefix = "Engine/Users/DEFAULT/Interface/Entry/"; Get(prefix + "CompletionCharacter", ":"); Get(prefix + "CommandCharacter", "/"); Get(prefix + "BashStyleCompletion", false); Get(prefix + "CommandHistorySize", 30); prefix = "Engine/Users/DEFAULT/Interface/Notification/"; Get(prefix + "NotificationAreaIconMode", "Never"); Get(prefix + "MessagingMenuEnabled", true); Get(prefix + "PopupsEnabled", true); prefix = "Engine/Users/DEFAULT/Sound/"; Get(prefix + "BeepOnHighlight", false); prefix = "Engine/Users/DEFAULT/Connection/"; Get(prefix + "Encoding", "ISO-8859-1"); Get(prefix + "AutoConvertUTF8", true); Get(prefix + "ProxyType", "System"); Get(prefix + "ProxyHostname", String.Empty); Get(prefix + "ProxyPort", -1); Get(prefix + "ProxyUsername", String.Empty); Get(prefix + "ProxyPassword", String.Empty); prefix = "Engine/Users/DEFAULT/Logging/"; Get(prefix + "Enabled", false); Get(prefix + "LogFilteredMessages", false); prefix = "Engine/Users/DEFAULT/MessageBuffer/"; Get <string>(prefix + "PersistencyType", MessageBufferPersistencyType.PersistentSqlite.ToString()); prefix = "Engine/Users/DEFAULT/MessageBuffer/Volatile/"; Get(prefix + "MaxCapacity", 200); prefix = "Engine/Users/DEFAULT/MessageBuffer/Persistent/"; Get(prefix + "MaxCapacity", 50 * 1000); prefix = "Engine/Users/DEFAULT/Servers/"; Get(prefix + "Servers", new string[] { "IRC/irc.oftc.net", "IRC/irc.gimp.org", "IRC/irc.geekshed.net", "IRC/irc.efnet.org", "IRC/irc.ircnet.org", "IRC/irc.freenode.net" }); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.oftc.net/"; Get(prefix + "Hostname", "irc.oftc.net"); Get(prefix + "Port", 6667); Get(prefix + "Network", "OFTC"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); Get(prefix + "OnStartupConnect", true); Get(prefix + "OnConnectCommands", new string[] { "/join #smuxi", } ); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.gimp.org/"; Get(prefix + "Hostname", "irc.gimp.org"); Get(prefix + "Port", 6667); Get(prefix + "Network", "GIMPNet"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.geekshed.net/"; Get(prefix + "Hostname", "irc.geekshed.net"); Get(prefix + "Port", 6667); Get(prefix + "Network", "GeekShed"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.efnet.org/"; Get(prefix + "Hostname", "irc.efnet.org"); Get(prefix + "Port", 6667); Get(prefix + "Network", "EFnet"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.ircnet.org/"; Get(prefix + "Hostname", "irc.ircnet.org"); Get(prefix + "Port", 6667); Get(prefix + "Network", "IRCnet"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); prefix = "Engine/Users/DEFAULT/Servers/IRC/irc.freenode.net/"; Get(prefix + "Hostname", "irc.freenode.net"); Get(prefix + "Port", 6667); Get(prefix + "Network", "freenode"); Get(prefix + "Nickname", String.Empty); Get(prefix + "Realname", String.Empty); Get(prefix + "Username", String.Empty); Get(prefix + "Password", String.Empty); Get(prefix + "UseEncryption", false); Get(prefix + "ValidateServerCertificate", false); prefix = "Engine/Users/"; Get(prefix + "Users", new string[] { "local" }); /* * prefix = "Engine/Users/local/"; * Get(prefix+"Password", String.Empty); * * prefix = "Engine/Users/local/Servers/"; * Get(prefix+"Servers", new string[] {}); */ prefix = "Server/"; LoadEntry(prefix + "Port", 7689); LoadEntry(prefix + "Formatter", "binary"); LoadEntry(prefix + "Channel", "TCP"); LoadEntry(prefix + "BindAddress", null); // loading defaults LoadAllEntries("Engine/Users/DEFAULT"); // are we upgrading from <= 1.0? if (String.IsNullOrEmpty(oldConfigVersion) || new Version(oldConfigVersion) < new Version(1, 0)) { // change default value to PersistentSqlite SetUserEntry("DEFAULT", "MessageBuffer/PersistencyType", MessageBufferPersistencyType.PersistentSqlite.ToString()); } prefix = "Engine/Users/"; string[] users = GetList(prefix + "Users"); m_Preferences[prefix + "Users"] = users; foreach (string user in users) { LoadUserEntry(user, "Password", "smuxi"); string[] startup_commands = GetList(prefix + user + "/OnStartupCommands"); if (startup_commands != null) { m_Preferences[prefix + user + "/OnStartupCommands"] = startup_commands; } else { m_Preferences[prefix + user + "/OnStartupCommands"] = new string[] {}; } string[] nick_list = GetList(prefix + user + "/Connection/Nicknames"); if (nick_list != null) { m_Preferences[prefix + user + "/Connection/Nicknames"] = nick_list; } else { string nick = Environment.UserName; // clean typical disallowed characters nick = nick.Replace(" ", String.Empty); if (String.IsNullOrEmpty(nick)) { nick = "Smuxi"; } m_Preferences[prefix + user + "/Connection/Nicknames"] = new string[] { nick }; } LoadUserEntry(user, "Connection/Username", String.Empty); string realname = null; try { string gecos = Mono.Unix.UnixUserInfo.GetRealUser().RealName; if (gecos == null) { gecos = String.Empty; } int pos = gecos.IndexOf(","); if (pos != -1) { realname = gecos.Substring(0, pos); } else { realname = gecos; } } catch (Exception ex) { #if LOG4NET _Logger.Warn("Load(): error getting realname from gecos (ignoring)", ex); #endif } if (String.IsNullOrEmpty(realname)) { realname = "Your Name"; } realname = "Your Name"; LoadUserEntry(user, "Connection/Realname", realname); LoadUserEntry(user, "Connection/Encoding", String.Empty); if (Get(prefix + user + "/Connection/AutoConvertUTF8", null) == null) { // upgrade path var enc = Get <string>(prefix + user + "/Connection/Encoding", String.Empty); if (((enc == String.Empty) && (System.Text.Encoding.Default.WebName.ToUpper() == "UTF-8")) || (enc.ToUpper() == "UTF-8")) { this[prefix + user + "/Connection/Encoding"] = "ISO-8859-1"; this[prefix + user + "/Connection/AutoConvertUTF8"] = true; } } LoadUserEntry(user, "Connection/AutoConvertUTF8", true); LoadUserEntry(user, "Connection/ProxyType", "System"); LoadUserEntry(user, "Connection/ProxyHostname", String.Empty); LoadUserEntry(user, "Connection/ProxyPort", -1); LoadUserEntry(user, "Connection/ProxyUsername", null); LoadUserEntry(user, "Connection/ProxyPassword", null); string[] command_list = GetList(prefix + user + "/Connection/OnConnectCommands"); if (command_list != null) { m_Preferences[prefix + user + "/Connection/OnConnectCommands"] = command_list; } else { m_Preferences[prefix + user + "/Connection/OnConnectCommands"] = new string[] {}; } string[] highlight_words = GetList(prefix + user + "/Interface/Chat/HighlightWords"); if (highlight_words != null) { m_Preferences[prefix + user + "/Interface/Chat/HighlightWords"] = highlight_words; } else { m_Preferences[prefix + user + "/Interface/Chat/HighlightWords"] = new string[] {}; } LoadUserEntry(user, "Interface/ShowAdvancedSettings", null); LoadUserEntry(user, "Interface/ShowActivityCounter", null); LoadUserEntry(user, "Interface/Notebook/TimestampFormat", null); LoadUserEntry(user, "Interface/Notebook/TabPosition", null); LoadUserEntry(user, "Interface/Notebook/BufferLines", null); LoadUserEntry(user, "Interface/Notebook/EngineBufferLines", null); LoadUserEntry(user, "Interface/Notebook/StripColors", null); LoadUserEntry(user, "Interface/Notebook/StripFormattings", null); LoadUserEntry(user, "Interface/Notebook/AutoSwitchPersonChats", null); LoadUserEntry(user, "Interface/Notebook/AutoSwitchGroupChats", null); LoadUserEntry(user, "Interface/Notebook/Tab/NoActivityColor", null); LoadUserEntry(user, "Interface/Notebook/Tab/ActivityColor", null); LoadUserEntry(user, "Interface/Notebook/Tab/EventColor", null); LoadUserEntry(user, "Interface/Notebook/Tab/HighlightColor", null); LoadUserEntry(user, "Interface/Notebook/Channel/UserListPosition", null); LoadUserEntry(user, "Interface/Notebook/Channel/TopicPosition", null); LoadUserEntry(user, "Interface/Notebook/Channel/NickColors", null); LoadUserEntry(user, "Interface/Chat/ForegroundColor", null); LoadUserEntry(user, "Interface/Chat/BackgroundColor", null); LoadUserEntry(user, "Interface/Chat/FontFamily", null); LoadUserEntry(user, "Interface/Chat/FontStyle", null); LoadUserEntry(user, "Interface/Chat/FontSize", null); LoadUserEntry(user, "Interface/Chat/WrapMode", null); LoadUserEntry(user, "Interface/Chat/Emojis", null); LoadUserEntry(user, "Interface/Entry/CompletionCharacter", null); LoadUserEntry(user, "Interface/Entry/CommandCharacter", null); LoadUserEntry(user, "Interface/Entry/BashStyleCompletion", null); LoadUserEntry(user, "Interface/Entry/CommandHistorySize", null); LoadUserEntry(user, "Interface/Notification/NotificationAreaIconMode", null); LoadUserEntry(user, "Interface/Notification/MessagingMenuEnabled", null); LoadUserEntry(user, "Interface/Notification/PopupsEnabled", null); LoadUserEntry(user, "Sound/BeepOnHighlight", null); LoadUserEntry(user, "Logging/Enabled", null); LoadUserEntry(user, "Logging/LogFilteredMessages", null); var persistencyKey = "MessageBuffer/PersistencyType"; LoadUserEntry(user, persistencyKey, null); // are we upgrading from < 1.0? if (String.IsNullOrEmpty(oldConfigVersion) || new Version(oldConfigVersion) < new Version(1, 0)) { // migrate all users automatically to SQLite SetUserEntry(user, persistencyKey, MessageBufferPersistencyType.PersistentSqlite.ToString()); } LoadUserEntry(user, "MessageBuffer/Volatile/MaxCapacity", null); LoadUserEntry(user, "MessageBuffer/Persistent/MaxCapacity", null); string[] servers = null; string sprefix = prefix + user + "/Servers/"; servers = GetList(sprefix + "Servers"); if (servers == null) { // this user has no servers string dprefix = prefix + "DEFAULT/Servers/"; servers = GetList(dprefix + "Servers"); if (servers == null) { // no default servers, use empty list servers = new string[] {}; } else { // we have default servers, so lets copy them foreach (string server in servers) { LoadEntry(sprefix + server + "/Hostname", Get(dprefix + server + "/Hostname", null)); LoadEntry(sprefix + server + "/Port", Get(dprefix + server + "/Port", null)); LoadEntry(sprefix + server + "/Network", Get(dprefix + server + "/Network", null)); LoadEntry(sprefix + server + "/Encoding", Get(dprefix + server + "/Encoding", null)); LoadEntry(sprefix + server + "/AutoConvertUTF8", Get(dprefix + server + "/AutoConvertUTF8", null)); LoadEntry(sprefix + server + "/Nickname", Get(dprefix + server + "/Nickname", null)); LoadEntry(sprefix + server + "/Realname", Get(dprefix + server + "/Realname", null)); LoadEntry(sprefix + server + "/Username", Get(dprefix + server + "/Username", null)); LoadEntry(sprefix + server + "/Password", Get(dprefix + server + "/Password", null)); LoadEntry(sprefix + server + "/UseEncryption", Get(dprefix + server + "/UseEncryption", null)); LoadEntry(sprefix + server + "/ValidateServerCertificate", Get(dprefix + server + "/ValidateServerCertificate", null)); LoadEntry(sprefix + server + "/OnStartupConnect", Get(dprefix + server + "/OnStartupConnect", null)); LoadEntry(sprefix + server + "/OnConnectCommands", Get(dprefix + server + "/OnConnectCommands", null)); } } m_Preferences[sprefix + "Servers"] = servers; } else { // this user has servers m_Preferences[sprefix + "Servers"] = servers; } foreach (string server in servers) { sprefix = prefix + user + "/Servers/" + server + "/"; LoadEntry(sprefix + "Hostname", null); LoadEntry(sprefix + "Port", null); LoadEntry(sprefix + "Network", String.Empty); LoadEntry(sprefix + "Encoding", null); LoadEntry(sprefix + "AutoConvertUTF8", null); LoadEntry(sprefix + "Nickname", String.Empty); LoadEntry(sprefix + "Realname", String.Empty); LoadEntry(sprefix + "Username", String.Empty); LoadEntry(sprefix + "Password", String.Empty); LoadEntry(sprefix + "UseEncryption", false); LoadEntry(sprefix + "ValidateServerCertificate", false); LoadEntry(sprefix + "ClientCertificateFilename", String.Empty); LoadEntry(sprefix + "OnStartupConnect", false); string[] commands = GetList(sprefix + "OnConnectCommands"); if (commands == null) { commands = new string[] {}; m_Preferences[sprefix + "OnConnectCommands"] = new string[] {}; } else { m_Preferences[sprefix + "OnConnectCommands"] = commands; } // HACK: XMPP specific values LoadEntry(sprefix + "Resource", null); LoadEntry(sprefix + "PriorityAvailable", null); LoadEntry(sprefix + "PriorityAway", null); } string[] filters = null; string cprefix = "Filters/"; filters = GetList(prefix + user + "/" + cprefix + "Filters"); if (filters == null) { filters = new string[] {}; m_Preferences[prefix + user + "/" + cprefix + "Filters"] = new string[] {}; } else { m_Preferences[prefix + user + "/" + cprefix + "Filters"] = filters; } foreach (string filter in filters) { cprefix = "Filters/" + filter + "/"; LoadUserEntry(user, cprefix + "Protocol", null); LoadUserEntry(user, cprefix + "NetworkID", null); LoadUserEntry(user, cprefix + "ChatType", null); LoadUserEntry(user, cprefix + "ChatID", null); LoadUserEntry(user, cprefix + "MessageType", null); LoadUserEntry(user, cprefix + "MessagePattern", null); } string lprefix = "MessagePatterns/"; var linkKeys = GetList(prefix + user + "/" + lprefix + "MessagePatterns"); if (linkKeys == null) { linkKeys = new string[] {}; m_Preferences[prefix + user + "/" + lprefix + "MessagePatterns"] = new string[] {}; } else { m_Preferences[prefix + user + "/" + lprefix + "MessagePatterns"] = linkKeys; } foreach (var linkKey in linkKeys) { lprefix = "MessagePatterns/" + linkKey + "/"; LoadUserEntry(user, lprefix + "MessagePartPattern", String.Empty); LoadUserEntry(user, lprefix + "MessagePartType", String.Empty); LoadUserEntry(user, lprefix + "LinkFormat", String.Empty); LoadUserEntry(user, lprefix + "TextFormat", String.Empty); } } }
public void Initialize() { int CurrentVersion; _initialized = true; if (!File.Exists(FileName)) { return; } _stream = new FileStream(FileName, FileMode.Open, FileAccess.ReadWrite); _reader = new BinaryReader(_stream); CurrentVersion = _reader.ReadInt32(); if (CurrentVersion != LibVersion) { Console.WriteLine("Wrong version, expecting lib version: " + LibVersion.ToString() + " found version: " + CurrentVersion.ToString() + ".", "Failed to open"); return; } Count = _reader.ReadInt32(); Images = new List <MImage>(); IndexList = new List <int>(); for (int i = 0; i < Count; i++) { IndexList.Add(_reader.ReadInt32()); } for (int i = 0; i < Count; i++) { Images.Add(null); } for (int i = 0; i < Count; i++) { CheckImage(i); } }
public void Init(Action callback) { Task.Factory.StartNew(() => { bool isWork = Environment.GetCommandLineArgs().Contains("--work", StringComparer.OrdinalIgnoreCase); if (isWork) { DoInit(isWork, callback); return; } // 如果是Debug模式且不是群控客户端且不是作业则使用本地数据库初始化 if (DevMode.IsDebugMode && !VirtualRoot.IsMinerStudio) { DoInit(isWork: false, callback: callback); return; } Logger.InfoDebugLine("开始下载server.json"); SpecialPath.GetAliyunServerJson((data) => { // 如果server.json未下载成功则不覆写本地server.json if (data != null && data.Length != 0) { Logger.InfoDebugLine("GetAliyunServerJson下载成功"); var serverJson = Encoding.UTF8.GetString(data); if (!string.IsNullOrEmpty(serverJson)) { SpecialPath.WriteServerJsonFile(serverJson); } OfficialServer.GetJsonFileVersionAsync(AssemblyInfo.ServerJsonFileName, (serverJsonFileVersion, minerClientVersion) => { SetServerJsonVersion(serverJsonFileVersion); if (!string.IsNullOrEmpty(minerClientVersion) && minerClientVersion != CurrentVersion.ToString()) { ServerVersion = minerClientVersion; VirtualRoot.Happened(new ServerVersionChangedEvent()); } }); } else { Logger.InfoDebugLine("GetAliyunServerJson下载失败"); } DoInit(isWork, callback); }); #region 发生了用户活动时检查serverJson是否有新版本 VirtualRoot.On <UserActionEvent>("发生了用户活动时检查serverJson是否有新版本", LogEnum.DevConsole, action: message => { OfficialServer.GetJsonFileVersionAsync(AssemblyInfo.ServerJsonFileName, (serverJsonFileVersion, minerClientVersion) => { if (!string.IsNullOrEmpty(minerClientVersion) && minerClientVersion != CurrentVersion.ToString()) { ServerVersion = minerClientVersion; VirtualRoot.Happened(new ServerVersionChangedEvent()); } string localServerJsonFileVersion = GetServerJsonVersion(); if (!string.IsNullOrEmpty(serverJsonFileVersion) && localServerJsonFileVersion != serverJsonFileVersion) { SpecialPath.GetAliyunServerJson((data) => { Write.UserInfo($"server.json配置文件有新版本{localServerJsonFileVersion}->{serverJsonFileVersion}"); string rawJson = Encoding.UTF8.GetString(data); SpecialPath.WriteServerJsonFile(rawJson); SetServerJsonVersion(serverJsonFileVersion); ReInitServerJson(); bool isUseJson = !DevMode.IsDebugMode || VirtualRoot.IsMinerStudio; if (isUseJson) { // 作业模式下界面是禁用的,所以这里的初始化isWork必然是false ContextReInit(isWork: VirtualRoot.IsMinerStudio); Write.UserInfo("刷新完成"); } else { Write.UserInfo("不是使用的server.json,无需刷新"); } }); } else { Write.DevDebug("server.json没有新版本"); } }); }); #endregion }); // 因为这个操作大概需要200毫秒 Task.Factory.StartNew(() => { NVIDIAGpuSet.NvmlInit(); }); }
public void Start() { Global.Logger.InfoDebugLine("开始启动Wcf服务"); string baseUrl = $"http://{Global.Localhost}:{Global.ClientPort}/"; ServiceHost minerClientServiceHost = new ServiceHost(typeof(Core.Impl.MinerClientService)); minerClientServiceHost.AddServiceEndpoint(typeof(IMinerClientService), ChannelFactory.BasicHttpBinding, new Uri(new Uri(baseUrl), nameof(IMinerClientService))); _serviceHosts = new List <ServiceHost> { minerClientServiceHost }; foreach (var serviceHost in _serviceHosts) { ServiceMetadataBehavior serviceMetadata = serviceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); if (serviceMetadata == null) { serviceMetadata = new ServiceMetadataBehavior(); serviceHost.Description.Behaviors.Add(serviceMetadata); } serviceMetadata.HttpGetEnabled = false; serviceHost.Open(); } Global.Logger.OkDebugLine($"服务启动成功: {DateTime.Now}."); Global.Logger.InfoDebugLine("服务列表:"); foreach (var serviceHost in _serviceHosts) { foreach (var endpoint in serviceHost.Description.Endpoints) { Global.Logger.InfoDebugLine(endpoint.Address.Uri.ToString()); } } Global.Logger.OkDebugLine("Wcf服务启动完成"); Server.TimeService.GetTime((remoteTime) => { if (Math.Abs((DateTime.Now - remoteTime).TotalSeconds) < Global.DesyncSeconds) { Global.Logger.OkDebugLine("时间同步"); } else { Global.Logger.WarnDebugLine($"本机时间和服务器时间不同步,请调整,本地:{DateTime.Now},服务器:{remoteTime}"); } }); Windows.Registry.SetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "Location", ClientId.AppFileFullName); Windows.Registry.SetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "Arguments", string.Join(" ", CommandLineArgs.Args)); Windows.Registry.SetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "CurrentVersion", CurrentVersion.ToString()); Windows.Registry.SetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "CurrentVersionTag", CurrentVersionTag); Report.Init(this); int shareCount = 0; DateTime shareOn = DateTime.Now; #region 挖矿开始时将无份额内核重启份额计数置0 Global.Access <MineStartedEvent>( Guid.Parse("e69e8729-868b-4b5d-b120-2914fffddf90"), "挖矿开始时将无份额内核重启份额计数置0", LogEnum.None, action: message => { shareCount = 0; shareOn = DateTime.Now; }); #endregion #region 每10秒钟检查是否需要重启 Global.Access <Per10SecondEvent>( Guid.Parse("16b3b7b4-5e6c-46b0-97a4-90e085614b78"), "每10秒钟检查是否需要重启", LogEnum.None, action: message => { #region 重启电脑 try { if (MinerProfile.IsPeriodicRestartComputer) { if ((DateTime.Now - this.CreatedOn).TotalHours > MinerProfile.PeriodicRestartComputerHours) { Global.Logger.WarnWriteLine($"每运行{MinerProfile.PeriodicRestartKernelHours}小时重启电脑"); Windows.Power.Restart(); return; // 退出 } } } catch (Exception e) { Global.Logger.ErrorDebugLine(e.Message, e); } #endregion #region 周期重启内核 try { if (IsMining && MinerProfile.IsPeriodicRestartKernel) { if ((DateTime.Now - CurrentMineContext.CreatedOn).TotalHours > MinerProfile.PeriodicRestartKernelHours) { Global.Logger.WarnWriteLine($"每运行{MinerProfile.PeriodicRestartKernelHours}小时重启内核"); RestartMine(); return; // 退出 } } } catch (Exception e) { Global.Logger.ErrorDebugLine(e.Message, e); } #endregion #region 收益没有增加重启内核 try { if (IsMining && MinerProfile.IsNoShareRestartKernel) { if ((DateTime.Now - shareOn).TotalMinutes > MinerProfile.NoShareRestartKernelMinutes) { if (this.CurrentMineContext.MainCoin != null) { ICoinShare mainCoinShare = this.CoinShareSet.GetOrCreate(this.CurrentMineContext.MainCoin.GetId()); int totalShare = mainCoinShare.TotalShareCount; if ((this.CurrentMineContext is IDualMineContext dualMineContext) && dualMineContext.DualCoin != null) { ICoinShare dualCoinShare = this.CoinShareSet.GetOrCreate(dualMineContext.DualCoin.GetId()); totalShare += dualCoinShare.TotalShareCount; } if (shareCount == totalShare) { Global.Logger.WarnWriteLine($"{MinerProfile.NoShareRestartKernelMinutes}分钟收益没有增加重启内核"); RestartMine(); } else { shareCount = totalShare; shareOn = DateTime.Now; } }
/// <summary> /// Executes a list of semicolon separated statements. /// Statements starting with /// </summary> /// <param name="statements">The statements.</param> protected void ExecuteStatements(string statements) { if (string.IsNullOrEmpty(statements)) { throw new ArgumentNullException("statements", "The sql statement to execute is empty. Database version: " + CurrentVersion.ToString()); } // replace block comments by whitespace statements = m_findComments.Replace(statements, " "); // execute all non-empty statements foreach (string statement in statements.Split(";".ToCharArray())) { string rawStatement = statement.Trim(); if (rawStatement.Length > 0) { SqlHelper.ExecuteNonQuery(rawStatement); } } }
internal Project(Unknown s, ObjectFactoryDelegate factory) : base(s, factory) { Attributes["Version"] = CurrentVersion.ToString(); }
public override string ToString() => $"v{CurrentVersion.ToString(3)}; {Released}; {Description}; {string.Join(", ", Changes)}; {WebpageUrl}";
/// <summary> /// Convert to a string representation /// </summary> /// <returns>string</returns> public override string ToString() { return("Version:" + CurrentVersion.ToString()); }