private void Create(BaseClass baseClass, Write write) { BaseClass = baseClass; Define = new Define(); Init = new Init(this); Write = write; }
public static void Main(string[] args){ Comunication write = new Write(); Comunication call = new Call(); write.comunicate(); call.comunicate(); }
protected void Page_Load(object sender, EventArgs e) { _write = new Write(fileName); List<string> childs = _write.PrintChild(); string temp=""; foreach (string name in childs) temp = temp + name + "\n"; txtChilds.Text = temp; }
public static void Main(string[] args) { Table env = new Table(); Symbol k; object v; k = Lua.Symbol.Intern("print"); v = new Print(); env[k] = v; k = Lua.Symbol.Intern("setmetatable"); v = new SetMetatable(); env[k] = v; k = Lua.Symbol.Intern("pairs"); v = new Pairs(); env[k] = v; Lua.Symbol s = Lua.Symbol.Intern("tonumber"); k = s; v = new ToNumber(); env[k] = v; k = Lua.Symbol.Intern("os"); Table os = new Table(); v = os; env[k] = v; k = Lua.Symbol.Intern("clock"); v = new Clock(); os[k] = v; k = Lua.Symbol.Intern("io"); Table io = new Table(); v = io; env[k] = v; k = Lua.Symbol.Intern("write"); v = new Write(); io[k] = v; k = Lua.Symbol.Intern("math"); Table math = new Table(); v = math; env[k] = v; k = Lua.Symbol.Intern("floor"); v = new Floor(); math[k] = v; Closure c = (Closure)Assembly.LoadFrom(args[0] + ".dll"). GetType(args[0] + ".function1").GetConstructor(new Type[0]). Invoke(new object[0]); c.Env = env; c.InvokeS(); for(int i = 0; i <= System.GC.MaxGeneration; i++) Console.WriteLine(System.GC.CollectionCount(i)); }
public static void Main(string[] args) { Table env = new Table(); Symbol k; object v; k = Lua.Symbol.Intern("print"); v = new Print(); env[k] = v; k = Lua.Symbol.Intern("setmetatable"); v = new SetMetatable(); env[k] = v; k = Lua.Symbol.Intern("pairs"); v = new Pairs(); env[k] = v; Lua.Symbol s = Lua.Symbol.Intern("tonumber"); k = s; v = new ToNumber(); env[k] = v; k = Lua.Symbol.Intern("os"); Table os = new Table(); v = os; env[k] = v; k = Lua.Symbol.Intern("clock"); v = new Clock(); os[k] = v; k = Lua.Symbol.Intern("io"); Table io = new Table(); v = io; env[k] = v; k = Lua.Symbol.Intern("write"); v = new Write(); io[k] = v; k = Lua.Symbol.Intern("math"); Table math = new Table(); v = math; env[k] = v; k = Lua.Symbol.Intern("floor"); v = new Floor(); math[k] = v; function1 f = new function1(); f.Env = env; f.InvokeS(); for(int i = 0; i <= System.GC.MaxGeneration; i++) Console.WriteLine(System.GC.CollectionCount(i)); }
/// <summary> /// Adds entity of type <typeparamref name="E4"/> /// </summary> /// <param name="c">ORM Channel Write End</param> /// <param name="entity">Entity to add</param> /// <returns>Fluent</returns> public static Sql Sql <E1, E2, E3, E4>(this Write <CommandChannel <Command>, _, _, _, _, MakesSqlCommands> c, Expression <Func <E1, E2, E3, E4, string> > stroke) { return(Before(c, stroke, typeof(E1), typeof(E2), typeof(E3), typeof(E4))); }
private static void SaveUsername() { // Salva os dados Lists.Options.SaveUsername = Get("Connect_Save_Username").Checked; Write.Options(); }
static void Main(string[] args) { string input; int number = new int(); bool correct = true; int brackets = 0; int max = 0; Write.EscMessage(); Write.Arrow(); while (Methods.ReadOrStop(out input)) { if (!int.TryParse(input, out number)) { continue; } if (number != 0 && number != 1) { continue; } if (!correct) { Write.Arrow(); continue; } if (number == 0) { brackets++; } if (number == 1) { brackets--; } if (brackets > max) { max = brackets; } if (brackets < 0) { correct = false; } Write.Arrow(); } if (correct) { Console.WriteLine($"corect: {max}"); } else { Console.WriteLine("incorect"); } }
internal Debug(DebugLevel level, String application, Write write) { this.level = level; this.application = application; this.write = write; }
public static Delete Delete <T1, T2, T3, T4, T5, T6>(this Write <CommandChannel <Command>, T1, T2, T3, T4, T5, T6> c, T3 entity) { return(DeleteCore(c, entity)); }
protected void btnViewXml_Click(object sender, EventArgs e) { _write = new Write(fileName); System.Diagnostics.Process.Start("chrome.exe", fileName); }
public override void Failed(Exception exception) { Write.Error(exception.Message); }
public void Initialize(IPipelines pipelines) { Write.WriteLine("Initializing the gossip loop in GossipStartup"); GossipLoop.Init(); }
private void Equip(Gladiator g) { Console.Clear(); Return.Info(); Write.Line(20, 6, Colour.NAME + g.Name + Colour.RESET); Write.Line(20, 8, Colour.HEALTH + "Wins" + Colour.RESET + $" { g.Win}"); Write.Line(20, 9, Colour.DAMAGE + "Strength" + Colour.RESET + $" {g.Strength}"); Write.Line(20, 10, Colour.HIT + "Offence" + Colour.RESET + $" {g.Offence}"); Write.Line(20, 11, Colour.HIT + "Defence" + Colour.RESET + $" {g.Defence}"); Write.Line(20, 12, Colour.SPEAK + "Endurance" + Colour.RESET + $" {g.Endurance}"); if (g.Traits.Count > 0) { Write.Line(20, 14, Colour.ABILITY + $"{g.Trait1}" + Colour.RESET); } if (g.Traits.Count > 1) { Write.Line(20, 15, Colour.ABILITY + $"{g.Trait2}" + Colour.RESET); } if (g.Traits.Count > 2) { Write.Line(20, 16, Colour.ABILITY + $"{g.Trait3}" + Colour.RESET); } Write.Line(50, 6, Colour.ITEM + "Head Armor " + Colour.RESET + $" {g.Torso.Head.Armor.Name}"); Write.Line(50, 7, Colour.ITEM + "Torso Armor " + Colour.RESET + $" {g.Torso.Armor.Name}"); Write.Line(50, 8, Colour.ITEM + "Arm Armor " + Colour.RESET + $" {g.Torso.RightArm.Armor.Name}"); Write.Line(50, 9, Colour.ITEM + "Hand Armor " + Colour.RESET + $" {g.Torso.RightArm.Hand.Armor.Name}"); Write.Line(50, 10, Colour.ITEM + "Leg Armor " + Colour.RESET + $" {g.Torso.RightLeg.Armor.Name}"); Write.Line(50, 11, Colour.ITEM + "Main Hand Weapon" + Colour.RESET + $" {g.Torso.RightArm.Hand.Weapon.Name} "); Write.Line(50, 12, Colour.ITEM + "Off Hand Weapon " + Colour.RESET + $" {g.Torso.LeftArm.Hand.Weapon.Name} "); Write.Line(0, 18, "[1] " + Colour.ITEM + "Upgrade Head Armor " + Colour.GOLD + $"{armorUpgrade[g.Torso.Head.Armor.Current + 1]}\n" + Colour.RESET); Write.Line("[2] " + Colour.ITEM + "Upgrade Torso Armor " + Colour.GOLD + $"{armorUpgrade[g.Torso.Armor.Current + 1]}" + Colour.RESET); Write.Line("[3] " + Colour.ITEM + "Upgrade Arm Armor " + Colour.GOLD + $"{armorUpgrade[g.Torso.RightArm.Armor.Current + 1]}" + Colour.RESET); Write.Line("[4] " + Colour.ITEM + "Upgrade Hand Armor " + Colour.GOLD + $"{armorUpgrade[g.Torso.RightArm.Hand.Armor.Current + 1]}" + Colour.RESET); Write.Line("[5] " + Colour.ITEM + "Upgrade Leg Armor " + Colour.GOLD + $"{armorUpgrade[g.Torso.RightLeg.Armor.Current + 1]}" + Colour.RESET); Write.Line("[M] " + Colour.ITEM + "Upgrade Main Hand " + Colour.GOLD + $"{armorUpgrade[g.Torso.RightArm.Hand.Weapon.Current + 1]}" + Colour.RESET); Write.Line("[O] " + Colour.ITEM + "Upgrade Off Hand " + Colour.GOLD + $"{armorUpgrade[g.Torso.LeftArm.Hand.Weapon.Current + 1]}" + Colour.RESET); Write.Line("[0] " + Colour.TIME + "Return to compound " + Colour.RESET); string choice = Return.Option(); if (choice == "1") { if (Return.Afford(armorUpgrade[g.Torso.Head.Armor.Current + 1])) { g.Torso.Head.Armor = HeadArmor[g.Torso.Head.Armor.Current + 1]; Owner.p.Gold -= armorUpgrade[g.Torso.Head.Armor.Current + 1]; g.Torso.Head.Armor.Current++; } else { Write.KeyPress(); } } else if (choice == "2") { if (Return.Afford(armorUpgrade[g.Torso.Armor.Current + 1])) { g.Torso.Armor = TorsoArmor[g.Torso.Armor.Current + 1]; Owner.p.Gold -= armorUpgrade[g.Torso.Armor.Current + 1]; g.Torso.Armor.Current++; } else { Write.KeyPress(); } } else if (choice == "3") { if (Return.Afford(armorUpgrade[g.Torso.RightArm.Armor.Current + 1])) { g.Torso.RightArm.Armor = ArmArmor[g.Torso.RightArm.Armor.Current + 1]; g.Torso.LeftArm.Armor = ArmArmor[g.Torso.RightArm.Armor.Current + 1]; Owner.p.Gold -= armorUpgrade[g.Torso.RightArm.Armor.Current + 1]; g.Torso.RightArm.Armor.Current++; } else { Write.KeyPress(); } } else if (choice == "4") { if (Return.Afford(armorUpgrade[g.Torso.RightArm.Hand.Armor.Current + 1])) { g.Torso.RightArm.Hand.Armor = HandArmor[g.Torso.RightArm.Hand.Armor.Current + 1]; g.Torso.LeftArm.Hand.Armor = HandArmor[g.Torso.RightArm.Hand.Armor.Current + 1]; Owner.p.Gold -= armorUpgrade[g.Torso.RightArm.Hand.Armor.Current + 1]; g.Torso.RightArm.Hand.Armor.Current++; } else { Write.KeyPress(); } } else if (choice == "5") { if (Return.Afford(armorUpgrade[g.Torso.RightLeg.Armor.Current + 1])) { g.Torso.RightLeg.Armor = LegArmor[g.Torso.RightLeg.Armor.Current + 1]; g.Torso.LeftLeg.Armor = LegArmor[g.Torso.RightLeg.Armor.Current + 1]; Owner.p.Gold -= armorUpgrade[g.Torso.RightLeg.Armor.Current + 1]; g.Torso.RightLeg.Armor.Current++; } else { Write.KeyPress(); } } else if (choice == "m") { if (Return.Afford(weaponUpgrade[g.Torso.RightArm.Hand.Weapon.Current + 1])) { g.Torso.RightArm.Hand.Weapon = Weapons[g.Torso.RightArm.Hand.Weapon.Current + 1]; Owner.p.Gold -= weaponUpgrade[g.Torso.RightArm.Hand.Weapon.Current + 1]; g.Torso.RightArm.Hand.Weapon.Current++; } else { Write.KeyPress(); } } else if (choice == "o") { if (Return.Afford(weaponUpgrade[g.Torso.LeftArm.Hand.Weapon.Current + 1])) { g.Torso.LeftArm.Hand.Weapon = Weapons[g.Torso.LeftArm.Hand.Weapon.Current + 1]; Owner.p.Gold -= weaponUpgrade[g.Torso.LeftArm.Hand.Weapon.Current + 1]; g.Torso.LeftArm.Hand.Weapon.Current++; } else { Write.KeyPress(); } } else if (choice == "0") { Location.list[2].Go(); } Equip(g); }
public void ExecuteAction() { Write.NoUpdateForComment(); Program.BeginQuestions(); }
public virtual void Visit(Write node) { }
private MineWorkViewModels() { #if DEBUG NTStopwatch.Start(); #endif if (WpfUtil.IsInDesignMode) { return; } foreach (var item in NTMinerContext.Instance.MinerStudioContext.MineWorkSet.AsEnumerable()) { if (!_dicById.ContainsKey(item.Id)) { _dicById.Add(item.Id, new MineWorkViewModel(item)); } } if (RpcRoot.IsOuterNet) { AppRoot.AddEventPath <MineWorkSetInitedEvent>("作业集初始化后初始化Vm内存", LogEnum.DevConsole, action: message => { foreach (var item in NTMinerContext.Instance.MinerStudioContext.MineWorkSet.AsEnumerable()) { if (!_dicById.ContainsKey(item.Id)) { _dicById.Add(item.Id, new MineWorkViewModel(item)); } } OnPropertyChangeds(); MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMineWork(MinerClientsWindowViewModel.Instance.MinerClients.ToArray()); }, this.GetType()); } this.Add = new DelegateCommand(() => { new MineWorkViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add); }); AppRoot.AddEventPath <MineWorkAddedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole, action: message => { if (!_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm)) { vm = new MineWorkViewModel(message.Source); _dicById.Add(message.Source.GetId(), vm); OnPropertyChangeds(); if (message.Source.GetId() == MinerClientsWindowVm.SelectedMineWork.GetId()) { MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect; } } }, location: this.GetType()); AppRoot.AddEventPath <MineWorkUpdatedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole, action: message => { if (_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm)) { vm.Update(message.Source); } }, location: this.GetType()); AppRoot.AddEventPath <MineWorkRemovedEvent>("移除了作业后刷新Vm内存", LogEnum.DevConsole, action: message => { if (_dicById.TryGetValue(message.Source.Id, out MineWorkViewModel vm)) { _dicById.Remove(vm.Id); OnPropertyChangeds(); if (vm.Id == MinerClientsWindowVm.SelectedMineWork.GetId()) { MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect; } } }, this.GetType()); #if DEBUG var elapsedMilliseconds = NTStopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
public List <NvGpu> GetGpus() { List <NvGpu> results = new List <NvGpu>(); try { if (NvmlInit()) { _nvmlDevices.Clear(); uint deviceCount = 0; var r = NvmlNativeMethods.nvmlDeviceGetCount(ref deviceCount); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetCount)} {r}"); } for (int i = 0; i < deviceCount; i++) { NvGpu gpu = new NvGpu { GpuIndex = i }; nvmlDevice nvmlDevice = new nvmlDevice(); r = NvmlNativeMethods.nvmlDeviceGetHandleByIndex((uint)i, ref nvmlDevice); _nvmlDevices.Add(nvmlDevice); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetHandleByIndex)}({(uint)i}) {r}"); } r = NvmlNativeMethods.nvmlDeviceGetName(nvmlDevice, out string name); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetName)} {r}"); } nvmlMemory memory = new nvmlMemory(); r = NvmlNativeMethods.nvmlDeviceGetMemoryInfo(nvmlDevice, ref memory); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetMemoryInfo)} {r}"); } // short gpu name if (!string.IsNullOrEmpty(name)) { name = name.Replace("GeForce GTX ", string.Empty); name = name.Replace("GeForce ", string.Empty); } nvmlPciInfo pci = new nvmlPciInfo(); r = NvmlNativeMethods.nvmlDeviceGetPciInfo(nvmlDevice, ref pci); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetPciInfo)} {r}"); } gpu.Name = name; gpu.BusId = (int)pci.bus; gpu.TotalMemory = memory.total; results.Add(gpu); } } } catch { } return(results); }
public UserSet() { VirtualRoot.BuildCmdPath <AddUserCommand>(action: message => { if (!_dicByLoginName.ContainsKey(message.User.LoginName)) { Server.UserService.AddUserAsync(new UserData { LoginName = message.User.LoginName, Password = message.User.Password, IsEnabled = message.User.IsEnabled, Description = message.User.Description }, (response, exception) => { if (response.IsSuccess()) { UserData entity = new UserData(message.User); _dicByLoginName.Add(message.User.LoginName, entity); VirtualRoot.RaiseEvent(new UserAddedEvent(message.Id, entity)); } else { Write.UserFail(response.ReadMessage(exception)); } }); } }); VirtualRoot.BuildCmdPath <UpdateUserCommand>(action: message => { if (_dicByLoginName.ContainsKey(message.User.LoginName)) { UserData entity = _dicByLoginName[message.User.LoginName]; UserData oldValue = new UserData(entity); entity.Update(message.User); Server.UserService.UpdateUserAsync(new UserData { LoginName = message.User.LoginName, Password = message.User.Password, IsEnabled = message.User.IsEnabled, Description = message.User.Description }, (response, exception) => { if (!response.IsSuccess()) { entity.Update(oldValue); VirtualRoot.RaiseEvent(new UserUpdatedEvent(message.Id, entity)); Write.UserFail(response.ReadMessage(exception)); } }); VirtualRoot.RaiseEvent(new UserUpdatedEvent(message.Id, entity)); } }); VirtualRoot.BuildCmdPath <RemoveUserCommand>(action: message => { if (_dicByLoginName.ContainsKey(message.LoginName)) { UserData entity = _dicByLoginName[message.LoginName]; Server.UserService.RemoveUserAsync(message.LoginName, (response, exception) => { if (response.IsSuccess()) { _dicByLoginName.Remove(entity.LoginName); VirtualRoot.RaiseEvent(new UserRemovedEvent(message.Id, entity)); } else { Write.UserFail(response.ReadMessage(exception)); } }); } }); }
public AMDGpuSet(INTMinerRoot root) : this() { #if DEBUG Write.Stopwatch.Start(); #endif _root = root; adlHelper.Init(); this.OverClock = new GpuOverClock(adlHelper); int deviceCount = 0; deviceCount = adlHelper.GpuCount; for (int i = 0; i < deviceCount; i++) { var atiGpu = adlHelper.GetGpuName(i); string name = atiGpu.AdapterName; // short gpu name if (!string.IsNullOrEmpty(name)) { name = name.Replace("Radeon (TM) RX ", string.Empty); name = name.Replace("Radeon RX ", string.Empty); } var gpu = Gpu.Create(i, atiGpu.BusNumber.ToString(), name); gpu.TotalMemory = adlHelper.GetTotalMemory(i); _gpus.Add(i, gpu); } if (deviceCount > 0) { this.DriverVersion = adlHelper.GetDriverVersion(); this.Properties.Add(new GpuSetProperty(GpuSetProperty.DRIVER_VERSION, "驱动版本", DriverVersion)); const ulong minG = (ulong)5 * 1024 * 1024 * 1024; bool has470 = _gpus.Any(a => a.Key != NTMinerRoot.GpuAllId && a.Value.TotalMemory < minG); if (has470) { Dictionary <string, string> kvs = new Dictionary <string, string> { { "GPU_MAX_ALLOC_PERCENT", "100" }, { "GPU_MAX_HEAP_SIZE", "100" }, { "GPU_SINGLE_ALLOC_PERCENT", "100" } }; foreach (var kv in kvs) { var property = new GpuSetProperty(kv.Key, kv.Key, kv.Value); this.Properties.Add(property); } Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerRoot.GpuAllId); foreach (var kv in kvs) { Environment.SetEnvironmentVariable(kv.Key, kv.Value); } }); } else { Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerRoot.GpuAllId); }); } } #if DEBUG var elapsedMilliseconds = Write.Stopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
public MainWindow() { this.MinHeight = 430; this.MinWidth = 640; this.Width = AppStatic.MainWindowWidth; this.Height = AppStatic.MainWindowHeight; #if DEBUG Write.Stopwatch.Start(); #endif this.Loaded += (sender, e) => { ConsoleWindow.Instance.Show(); ConsoleWindow.Instance.MouseDown += (ss, ee) => { MoveConsoleWindow(); }; this.Owner = ConsoleWindow.Instance; hwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource; hwndSource.AddHook(new HwndSourceHook(Win32MessageProc.WindowProc)); MoveConsoleWindow(); }; InitializeComponent(); BtnMinerProfileGrip.Visibility = Visibility.Collapsed; if (WpfUtil.IsInDesignMode) { return; } UIThread.StartTimer(); _borderBrush = this.BorderBrush; DateTime lastGetServerMessageOn = DateTime.MinValue; NTMinerRoot.RefreshArgsAssembly.Invoke(); // 切换了主界面上的Tab时 this.MainArea.SelectionChanged += (sender, e) => { // 延迟创建,以加快主界面的启动 var selectedItem = MainArea.SelectedItem; if (selectedItem == TabItemSpeedTable) { if (SpeedTableContainer.Child == null) { SpeedTableContainer.Child = GetSpeedTable(); } } else if (selectedItem == TabItemMessage) { if (MessagesContainer.Child == null) { MessagesContainer.Child = new Messages(); } } else if (selectedItem == TabItemToolbox) { if (ToolboxContainer.Child == null) { ToolboxContainer.Child = new Toolbox(); } } else if (selectedItem == TabItemMinerProfileOption) { if (MinerProfileOptionContainer.Child == null) { MinerProfileOptionContainer.Child = new MinerProfileOption(); } } VirtualRoot.SetIsServerMessagesVisible(selectedItem == TabItemMessage); if (selectedItem == TabItemMessage) { if (lastGetServerMessageOn.AddSeconds(10) < DateTime.Now) { lastGetServerMessageOn = DateTime.Now; VirtualRoot.Execute(new LoadNewServerMessageCommand()); } } }; this.IsVisibleChanged += (sender, e) => { if (this.IsVisible) { NTMinerRoot.IsUiVisible = true; NTMinerRoot.MainWindowRendedOn = DateTime.Now; } else { NTMinerRoot.IsUiVisible = false; } MoveConsoleWindow(); }; this.ConsoleRectangle.IsVisibleChanged += (sender, e) => { MoveConsoleWindow(); }; this.StateChanged += (s, e) => { if (Vm.MinerProfile.IsShowInTaskbar) { ShowInTaskbar = true; } else { if (WindowState == WindowState.Minimized) { ShowInTaskbar = false; } else { ShowInTaskbar = true; } } if (WindowState == WindowState.Maximized) { ResizeCursors.Visibility = Visibility.Collapsed; this.BorderBrush = WpfUtil.BlackBrush; } else { ResizeCursors.Visibility = Visibility.Visible; this.BorderBrush = _borderBrush; } MoveConsoleWindow(); }; this.ConsoleRectangle.SizeChanged += (s, e) => { MoveConsoleWindow(); }; NotiCenterWindow.Bind(this, ownerIsTopMost: true); this.LocationChanged += (sender, e) => { MoveConsoleWindow(); }; VirtualRoot.BuildCmdPath <CloseMainWindowCommand>(action: message => { UIThread.Execute(() => { this.Close(); }); }); this.BuildEventPath <PoolDelayPickedEvent>("从内核输出中提取了矿池延时时展示到界面", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { if (message.IsDual) { Vm.StateBarVm.DualPoolDelayText = message.PoolDelayText; } else { Vm.StateBarVm.PoolDelayText = message.PoolDelayText; } }); }); this.BuildEventPath <MineStartedEvent>("开始挖矿后将清空矿池延时", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.StateBarVm.PoolDelayText = string.Empty; Vm.StateBarVm.DualPoolDelayText = string.Empty; }); }); this.BuildEventPath <MineStopedEvent>("停止挖矿后将清空矿池延时", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.StateBarVm.PoolDelayText = string.Empty; Vm.StateBarVm.DualPoolDelayText = string.Empty; }); }); this.BuildEventPath <Per1MinuteEvent>("挖矿中时自动切换为无界面模式 和 守护进程状态显示", LogEnum.DevConsole, action: message => { if (NTMinerRoot.IsUiVisible && NTMinerRoot.Instance.MinerProfile.IsAutoNoUi && NTMinerRoot.Instance.IsMining) { if (NTMinerRoot.MainWindowRendedOn.AddMinutes(NTMinerRoot.Instance.MinerProfile.AutoNoUiMinutes) < message.Timestamp) { VirtualRoot.Out.ShowSuccess($"界面展示{NTMinerRoot.Instance.MinerProfile.AutoNoUiMinutes}分钟后自动切换为无界面模式,可在选项页调整配置", "开源矿工"); VirtualRoot.Execute(new CloseMainWindowCommand()); } } }); this.BuildEventPath <CpuPackageStateChangedEvent>("CPU包状态变更后刷新Vm内存", LogEnum.None, action: message => { UIThread.Execute(UpdateCpuView); }); #if DEBUG var elapsedMilliseconds = Write.Stopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
protected void btnReplaceChild_Click(object sender, EventArgs e) { _write = new Write(fileName); _write.Replace(); }
public StateBar() { #if DEBUG Write.Stopwatch.Start(); #endif InitializeComponent(); if (WpfUtil.IsInDesignMode) { return; } this.RunOneceOnLoaded((window) => { window.Activated += (object sender, EventArgs e) => { Vm.OnPropertyChanged(nameof(Vm.IsAutoAdminLogon)); Vm.OnPropertyChanged(nameof(Vm.AutoAdminLogonToolTip)); Vm.OnPropertyChanged(nameof(Vm.IsRemoteDesktopEnabled)); Vm.OnPropertyChanged(nameof(Vm.RemoteDesktopToolTip)); }; window.BuildEventPath <LocalIpSetInitedEvent>("本机IP集刷新后刷新状态栏", LogEnum.DevConsole, action: message => { UIThread.Execute(() => Vm.RefreshLocalIps()); }); window.BuildEventPath <MinutePartChangedEvent>("时间的分钟部分变更过更新计时器显示", LogEnum.None, action: message => { UIThread.Execute(() => { Vm.UpdateDateTime(); }); }); window.BuildEventPath <Per1SecondEvent>("挖矿计时秒表", LogEnum.None, action: message => { UIThread.Execute(() => { DateTime now = DateTime.Now; Vm.UpdateBootTimeSpan(now - NTMinerRoot.Instance.CreatedOn); var mineContext = NTMinerRoot.Instance.LockedMineContext; if (mineContext != null) { Vm.UpdateMineTimeSpan(now - mineContext.CreatedOn); } }); }); window.BuildEventPath <AppVersionChangedEvent>("发现了服务端新版本", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.SetCheckUpdateForeground(isLatest: MainAssemblyInfo.CurrentVersion >= NTMinerRoot.ServerVersion); }); }); window.BuildEventPath <KernelSelfRestartedEvent>("内核自我重启时刷新计数器", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.OnPropertyChanged(nameof(Vm.KernelSelfRestartCountText)); }); }); window.BuildEventPath <MineStartedEvent>("挖矿开始后将内核自我重启计数清零", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.OnPropertyChanged(nameof(Vm.KernelSelfRestartCountText)); }); }); }); var gpuSet = NTMinerRoot.Instance.GpuSet; // 建议每张显卡至少对应4G虚拟内存,否则标红 if (NTMinerRoot.OSVirtualMemoryMb < gpuSet.Count * 4) { BtnShowVirtualMemory.Foreground = WpfUtil.RedBrush; } #if DEBUG var elapsedMilliseconds = Write.Stopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
public DDocRow() { DWriteHead = WriteHead; DWriteTail = WriteTail; DWriteAmong = WriteAmong; }
public MineWorkSet() { VirtualRoot.AddCmdPath <AddMineWorkCommand>(action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } MineWorkData entity = new MineWorkData().Update(message.Input); var response = RpcRoot.Server.MineWorkService.AddOrUpdateMineWork(entity); if (response.IsSuccess()) { _dicById.Add(entity.Id, entity); VirtualRoot.RaiseEvent(new MineWorkAddedEvent(message.Id, entity)); } else { Write.UserFail(response?.Description); } }, location: this.GetType()); VirtualRoot.AddCmdPath <UpdateMineWorkCommand>(action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.Input.GetId())) { return; } MineWorkData entity = _dicById[message.Input.GetId()]; MineWorkData oldValue = new MineWorkData().Update(entity); entity.Update(message.Input); RpcRoot.Server.MineWorkService.AddOrUpdateMineWorkAsync(entity, (response, exception) => { if (!response.IsSuccess()) { entity.Update(oldValue); VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(message.Id, entity)); Write.UserFail(response.ReadMessage(exception)); } }); VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(message.Id, entity)); }, location: this.GetType()); VirtualRoot.AddCmdPath <RemoveMineWorkCommand>(action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } MineWorkData entity = _dicById[message.EntityId]; RpcRoot.Server.MineWorkService.RemoveMineWorkAsync(entity.Id, (response, exception) => { if (response.IsSuccess()) { _dicById.Remove(entity.Id); VirtualRoot.RaiseEvent(new MineWorkRemovedEvent(message.Id, entity)); } else { Write.UserFail(response.ReadMessage(exception)); } }); }, location: this.GetType()); }
public MinerProfileViewModel() { #if DEBUG Write.Stopwatch.Restart(); #endif if (Design.IsInDesignMode) { return; } if (Instance != null) { throw new InvalidProgramException(); } if (this.IsCreateShortcut) { CreateShortcut(); } this.AutoStartDelaySecondsUp = new DelegateCommand(() => { this.AutoStartDelaySeconds++; }); this.AutoStartDelaySecondsDown = new DelegateCommand(() => { if (this.AutoStartDelaySeconds > 0) { this.AutoStartDelaySeconds--; } }); this.AutoRestartKernelTimesUp = new DelegateCommand(() => { this.AutoRestartKernelTimes++; }); this.AutoRestartKernelTimesDown = new DelegateCommand(() => { if (this.AutoRestartKernelTimes > 0) { this.AutoRestartKernelTimes--; } }); this.NoShareRestartKernelMinutesUp = new DelegateCommand(() => { this.NoShareRestartKernelMinutes++; }); this.NoShareRestartKernelMinutesDown = new DelegateCommand(() => { if (this.NoShareRestartKernelMinutes > 0) { this.NoShareRestartKernelMinutes--; } }); this.NoShareRestartComputerMinutesUp = new DelegateCommand(() => { this.NoShareRestartComputerMinutes++; }); this.NoShareRestartComputerMinutesDown = new DelegateCommand(() => { if (this.NoShareRestartComputerMinutes > 0) { this.NoShareRestartComputerMinutes--; } }); this.PeriodicRestartKernelHoursUp = new DelegateCommand(() => { this.PeriodicRestartKernelHours++; }); this.PeriodicRestartKernelHoursDown = new DelegateCommand(() => { if (this.PeriodicRestartKernelHours > 0) { this.PeriodicRestartKernelHours--; } }); this.PeriodicRestartKernelMinutesUp = new DelegateCommand(() => { this.PeriodicRestartKernelMinutes++; }); this.PeriodicRestartKernelMinutesDown = new DelegateCommand(() => { if (this.PeriodicRestartKernelMinutes > 0) { this.PeriodicRestartKernelMinutes--; } }); this.PeriodicRestartComputerHoursUp = new DelegateCommand(() => { this.PeriodicRestartComputerHours++; }); this.PeriodicRestartComputerHoursDown = new DelegateCommand(() => { if (this.PeriodicRestartComputerHours > 0) { this.PeriodicRestartComputerHours--; } }); this.PeriodicRestartComputerMinutesUp = new DelegateCommand(() => { this.PeriodicRestartComputerMinutes++; }); this.PeriodicRestartComputerMinutesDown = new DelegateCommand(() => { if (this.PeriodicRestartComputerMinutes > 0) { this.PeriodicRestartComputerMinutes--; } }); this.CpuGETemperatureSecondsUp = new DelegateCommand(() => { this.CpuGETemperatureSeconds++; }); this.CpuGETemperatureSecondsDown = new DelegateCommand(() => { this.CpuGETemperatureSeconds--; }); this.CpuStopTemperatureUp = new DelegateCommand(() => { this.CpuStopTemperature++; }); this.CpuStopTemperatureDown = new DelegateCommand(() => { this.CpuStopTemperature--; }); this.CpuLETemperatureSecondsUp = new DelegateCommand(() => { this.CpuLETemperatureSeconds++; }); this.CpuLETemperatureSecondsDown = new DelegateCommand(() => { this.CpuLETemperatureSeconds--; }); this.CpuStartTemperatureUp = new DelegateCommand(() => { this.CpuStartTemperature++; }); this.CpuStartTemperatureDown = new DelegateCommand(() => { this.CpuStartTemperature--; }); this.EPriceUp = new DelegateCommand(() => { this.EPrice = Math.Round(this.EPrice + 0.1, 2); }); this.EPriceDown = new DelegateCommand(() => { if (this.EPrice > 0.1) { this.EPrice = Math.Round(this.EPrice - 0.1, 2); } }); this.PowerAppendUp = new DelegateCommand(() => { this.PowerAppend++; }); this.PowerAppendDown = new DelegateCommand(() => { if (this.PowerAppend > 0) { this.PowerAppend--; } }); this.MaxTempUp = new DelegateCommand(() => { this.MaxTemp++; }); this.MaxTempDown = new DelegateCommand(() => { if (this.MaxTemp > 0) { this.MaxTemp--; } }); this.AutoNoUiMinutesUp = new DelegateCommand(() => { this.AutoNoUiMinutes++; }); this.AutoNoUiMinutesDown = new DelegateCommand(() => { if (this.AutoNoUiMinutes > 0) { this.AutoNoUiMinutes--; } }); NTMinerRoot.SetRefreshArgsAssembly(() => { if (CoinVm != null && CoinVm.CoinKernel != null && CoinVm.CoinKernel.Kernel != null) { var coinKernelProfile = CoinVm.CoinKernel.CoinKernelProfile; var kernelInput = CoinVm.CoinKernel.Kernel.KernelInputVm; if (coinKernelProfile != null && kernelInput != null) { if (coinKernelProfile.IsDualCoinEnabled && !kernelInput.IsAutoDualWeight) { if (coinKernelProfile.DualCoinWeight > kernelInput.DualWeightMax) { coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMax; } else if (coinKernelProfile.DualCoinWeight < kernelInput.DualWeightMin) { coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMin; } NTMinerRoot.Instance.MinerProfile.SetCoinKernelProfileProperty(coinKernelProfile.CoinKernelId, nameof(coinKernelProfile.DualCoinWeight), coinKernelProfile.DualCoinWeight); } } } this.ArgsAssembly = NTMinerRoot.Instance.BuildAssembleArgs(out _, out _, out _); }); VirtualRoot.BuildEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole, action: message => { OnPropertyChanged(nameof(CoinVm)); }); AppContext.AppContextCmdPath <RefreshAutoBootStartCommand>("刷新开机启动和自动挖矿的展示", LogEnum.DevConsole, action: message => { MinerProfileData data = NTMinerRoot.CreateLocalRepository <MinerProfileData>().GetByKey(this.Id); if (data != null) { this.IsAutoBoot = data.IsAutoBoot; this.IsAutoStart = data.IsAutoStart; } }); AppContext.AppContextEventPath <MinerProfilePropertyChangedEvent>("MinerProfile设置变更后刷新VM内存", LogEnum.DevConsole, action: message => { OnPropertyChanged(message.PropertyName); }); VirtualRoot.BuildEventPath <LocalContextVmsReInitedEvent>("本地上下文视图模型集刷新后刷新界面", LogEnum.DevConsole, action: message => { AllPropertyChanged(); if (CoinVm != null) { CoinVm.OnPropertyChanged(nameof(CoinVm.Wallets)); CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.OnPropertyChanged(nameof(CoinVm.Wallets)); CoinVm.CoinProfile.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedWallet)); CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.CoinProfile.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedDualCoinWallet)); } }); #if DEBUG Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor"); #endif }
private void RefreshTotalSpeedChart(int limit) { //NTMinerRoot.Current.DebugLine($"获取总算力数据,范围{leftTime} - {rightTime}"); Server.ControlCenterService.GetLatestSnapshotsAsync( limit, (response, exception) => { if (response == null) { return; } if (!response.IsSuccess()) { Write.UserFail(response.ReadMessage(exception)); return; } UIThread.Execute(() => { bool isOnlyOne = limit == 1; Vm.TotalMiningCount = response.TotalMiningCount; Vm.TotalOnlineCount = response.TotalOnlineCount; foreach (var chartVm in Vm.ChartVms) { var list = response.Data.Where(a => a.CoinCode == chartVm.CoinVm.Code).ToList(); if (list.Count == 0) { list.Add(new CoinSnapshotData { CoinCode = chartVm.CoinVm.Code, DualCoinOnlineCount = 0, DualCoinMiningCount = 0, MainCoinOnlineCount = 0, MainCoinMiningCount = 0, RejectShareDelta = 0, ShareDelta = 0, Speed = 0, Timestamp = DateTime.Now.AddSeconds(-5) }); } CoinSnapshotData one = null; if (isOnlyOne) { one = list.Last(); } else { list = list.OrderBy(a => a.Timestamp).ToList(); } CoinSnapshotData latestData = list.Last(); chartVm.SnapshotDataVm.Update(latestData); foreach (var riser in chartVm.Series) { if (riser.Title == "speed") { if (list.Count > 0) { if (isOnlyOne) { riser.Values.Add(new MeasureModel() { DateTime = one.Timestamp, Value = one.Speed }); } else { foreach (var item in list) { riser.Values.Add(new MeasureModel() { DateTime = item.Timestamp, Value = item.Speed }); } } } } else if (riser.Title == "onlineCount") { if (isOnlyOne) { riser.Values.Add(new MeasureModel() { DateTime = one.Timestamp, Value = one.MainCoinOnlineCount + one.DualCoinOnlineCount }); } else { foreach (var item in list) { riser.Values.Add(new MeasureModel() { DateTime = item.Timestamp, Value = item.MainCoinOnlineCount + item.DualCoinOnlineCount }); } } } else if (riser.Title == "miningCount") { if (isOnlyOne) { riser.Values.Add(new MeasureModel() { DateTime = one.Timestamp, Value = one.MainCoinMiningCount + one.DualCoinMiningCount }); } else { foreach (var item in list) { riser.Values.Add(new MeasureModel() { DateTime = item.Timestamp, Value = item.MainCoinMiningCount + item.DualCoinMiningCount }); } } } else if (riser.Title == "rejectShare") { if (isOnlyOne) { riser.Values.Add(new MeasureModel() { DateTime = one.Timestamp, Value = one.RejectShareDelta }); } else { foreach (var item in list) { riser.Values.Add(new MeasureModel() { DateTime = item.Timestamp, Value = item.RejectShareDelta }); } } } else if (riser.Title == "acceptShare") { if (isOnlyOne) { riser.Values.Add(new MeasureModel() { DateTime = one.Timestamp, Value = one.ShareDelta }); } else { foreach (var item in list) { riser.Values.Add(new MeasureModel() { DateTime = item.Timestamp, Value = item.ShareDelta }); } } } } DateTime now = DateTime.Now.AddSeconds(10); foreach (var riser in chartVm.Series) { IChartValues valuesTotal = riser.Values; if (valuesTotal.Count > 0 && ((MeasureModel)valuesTotal[0]).DateTime.AddMinutes(NTMinerRoot.SpeedHistoryLengthByMinute) < now) { valuesTotal.RemoveAt(0); } } chartVm.SetAxisLimits(now); } }); }); }
public static Delete Delete <T1, T2>(this Write <CommandChannel <Command>, T1, T2> c, T2 entity) { return(DeleteCore(c, entity)); }
public ColumnsShowSet(INTMinerRoot root) { _root = root; VirtualRoot.Window <AddColumnsShowCommand>("添加列显", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty || message.Input.GetId() == ColumnsShowData.PleaseSelect.Id) { throw new ArgumentNullException(); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } ColumnsShowData entity = new ColumnsShowData().Update(message.Input); Server.ControlCenterService.AddOrUpdateColumnsShowAsync(entity, (response, exception) => { if (response.IsSuccess()) { _dicById.Add(entity.Id, entity); VirtualRoot.Happened(new ColumnsShowAddedEvent(entity)); } else { Write.UserFail(response.ReadMessage(exception)); } }); }); VirtualRoot.Window <UpdateColumnsShowCommand>("更新列显", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.Input.GetId())) { return; } ColumnsShowData entity = _dicById[message.Input.GetId()]; ColumnsShowData oldValue = new ColumnsShowData().Update(entity); entity.Update(message.Input); Server.ControlCenterService.AddOrUpdateColumnsShowAsync(entity, (response, exception) => { if (!response.IsSuccess()) { entity.Update(oldValue); VirtualRoot.Happened(new ColumnsShowUpdatedEvent(entity)); Write.UserFail(response.ReadMessage(exception)); } }); VirtualRoot.Happened(new ColumnsShowUpdatedEvent(entity)); }); VirtualRoot.Window <RemoveColumnsShowCommand>("移除列显", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty || message.EntityId == ColumnsShowData.PleaseSelect.Id) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } ColumnsShowData entity = _dicById[message.EntityId]; Server.ControlCenterService.RemoveColumnsShowAsync(entity.Id, (response, exception) => { if (response.IsSuccess()) { _dicById.Remove(entity.Id); VirtualRoot.Happened(new ColumnsShowRemovedEvent(entity)); } else { Write.UserFail(response.ReadMessage(exception)); } }); }); }
public void WriteSave() { byte[] file = Write.WriteSave(SaveFile); File.WriteAllBytes(SaveFilename, file); }
public void Init() { instance = new Write(); }
private static void Chat() { // Desabilita a prévia do chat Lists.Options.Chat = global::Chat.Text_Visible = Get("Options_Chat").Checked; Write.Options(); }
protected void btnAdd_Click(object sender, EventArgs e) { _write = new Write(fileName); _write.Add(); }
/// <summary> /// Adds entity of type <typeparamref name="E1"/> /// </summary> /// <param name="c">ORM Channel Write End</param> /// <param name="entity">Entity to add</param> /// <returns>Fluent</returns> public static Sql Sql <E1>(this Write <CommandChannel <Command>, MakesSqlCommands> c, Expression <Func <E1, string> > stroke) { return(Before(c, stroke, typeof(E1))); }
protected void btnInsertBefore_Click(object sender, EventArgs e) { _write = new Write(fileName); _write.InsertBefore(); }
private void Attack() { //Bonuses based on strength int g1Bonus = (Gladiator1.Strength - 10) / 2; int g2Bonus = (Gladiator2.Strength - 10) / 2; //Gladiator 1 Right and left hand. Shield Bonus //Empty Right Hand is 2, or Weapon Dam int weapon1R = (Gladiator1.Torso.RightArm.Hand.Weapon.Level == 0) ? 2 : Gladiator1.Torso.RightArm.Hand.Weapon.Damage; if (Gladiator1.Traits.Contains((Trait)11) && Gladiator1.Torso.RightArm.Hand.Weapon.Level == 0) { weapon1R += 2; } //Block value is shield if they have on or 0 int shield1 = (Gladiator1.Torso.LeftArm.Hand.Weapon.Type == "Shield") ? Gladiator1.Torso.LeftArm.Hand.Weapon.Damage : 0; //Empty Left Hand is 0, or Weapon Dam int weapon1L = 0; if (Gladiator1.Traits.Contains((Trait)14)) { weapon1L += (Gladiator1.Torso.LeftArm.Hand.Weapon.Level == 0 && Gladiator1.Traits.Contains((Trait)11)) ? 2 : Gladiator1.Torso.LeftArm.Hand.Weapon.Damage; } //Gladiator 2 Right and left hand. Shield Bonus //Empty Right Hand is 2, or Weapon Dam int weapon2R = (Gladiator2.Torso.RightArm.Hand.Weapon.Level == 0)? 2 : Gladiator2.Torso.RightArm.Hand.Weapon.Damage; if (Gladiator2.Traits.Contains((Trait)11) && Gladiator2.Torso.RightArm.Hand.Weapon.Level == 0) { weapon2R += 2; } //Block value is shield if they have on or 0 int shield2 = (Gladiator2.Torso.LeftArm.Hand.Weapon.Type == "Shield") ? Gladiator2.Torso.LeftArm.Hand.Weapon.Damage : 0; //Empty Left Hand is 0, or Weapon Dam int weapon2L = 0; if (Gladiator2.Traits.Contains((Trait)14)) { weapon2L += (Gladiator2.Torso.LeftArm.Hand.Weapon.Level == 0 && Gladiator2.Traits.Contains((Trait)11)) ? 2 : Gladiator2.Torso.LeftArm.Hand.Weapon.Damage; } int attackRoll = Return.RandomInt(1, 101); if (attackRoll < 96 && attackRoll > 5) { attackRoll -= Gladiator1.Offence; attackRoll += Gladiator2.Offence; if (attackRoll < 50) { attackRoll += Gladiator2.Defence - Gladiator1.Offence; attackRoll = (attackRoll > 50) ? 50 : attackRoll; } if (attackRoll > 50) { attackRoll += Gladiator1.Defence - Gladiator2.Offence; attackRoll = (attackRoll < 50) ? 50 : attackRoll; } if (attackRoll < (41 - shield2) && attackRoll >= (25 - shield2)) { //Gladiator1 strikes int damage = (weapon1R + weapon1L) / 2 + g1Bonus / 2; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator2); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator2.MaxEndurance -= 5; Gladiator2.Endurance = (Gladiator2.Endurance - 10 <= 0) ? 0 : Gladiator2.Endurance; } } if (player) { Console.Write(Flavor(Gladiator1, Gladiator2, body, 1)); } } else if (attackRoll < (25 - shield2) && attackRoll >= (11 - shield2)) { //Gladiator1 strikes int damage = weapon1R + weapon1L + g1Bonus; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator2); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator2.MaxEndurance -= 5; Gladiator2.Endurance = (Gladiator2.Endurance - 10 <= 0) ? 0 : Gladiator2.Endurance; } } if (player) { Console.Write(Flavor(Gladiator1, Gladiator2, body, 2)); } } else if (attackRoll < (11 - shield2)) { //Gladiator1 strikes int damage = weapon1R + weapon1L + g1Bonus * 2; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator2); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator2.MaxEndurance -= 5; Gladiator2.Endurance = (Gladiator2.Endurance - 10 <= 0) ? 0 : Gladiator2.Endurance; } } if (player) { Console.Write(Flavor(Gladiator1, Gladiator2, body, 3)); } } else if (attackRoll > (59 + shield1) && attackRoll <= (75 + shield1)) { //Gladiator2 strikes int damage = (weapon2R + weapon2L) / 2 + g2Bonus / 2; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator1); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator1.MaxEndurance -= 5; Gladiator1.Endurance = (Gladiator1.Endurance - 10 <= 0) ? 0 : Gladiator1.Endurance; } } if (player) { Console.Write(Flavor(Gladiator2, Gladiator1, body, 1)); } } else if (attackRoll > (75 + shield1) && attackRoll <= (90 + shield1)) { //Gladiator2 strikes int damage = weapon2R + weapon2L + g2Bonus; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator1); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator1.MaxEndurance -= 5; Gladiator1.Endurance = (Gladiator1.Endurance - 10 <= 0) ? 0 : Gladiator1.Endurance; } } if (player) { Console.Write(Flavor(Gladiator2, Gladiator1, body, 2)); } } else if (attackRoll > (90 + shield1)) { //Gladiator2 strikes int damage = weapon2R + weapon2L + g2Bonus * 2; damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator1); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator1.MaxEndurance -= 5; Gladiator1.Endurance = (Gladiator1.Endurance - 10 <= 0) ? 0 : Gladiator1.Endurance; } } if (player) { Console.Write(Flavor(Gladiator2, Gladiator1, body, 3)); } } else if (player) { Write.Line("The gladiators square off, neither gaining a real advantage"); } } else { if (attackRoll < 6) { int damage = weapon1R + weapon1L + (Gladiator1.Strength - 10); damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator2); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator2.MaxEndurance -= 5; Gladiator2.Endurance = (Gladiator2.Endurance - 10 <= 0) ? 0 : Gladiator2.Endurance; } } if (player) { Console.Write(Flavor(Gladiator1, Gladiator2, body, 3)); } } if (attackRoll > 95) { int damage = weapon2R + weapon2L + (Gladiator1.Strength - 10); damage = (damage <= 0) ? damage = 1 : damage; Body body = Target(Gladiator2); if (body.Disabled == false) { body.TakeDamage(damage); if (body.Disabled) { Gladiator1.MaxEndurance -= 5; Gladiator1.Endurance = (Gladiator1.Endurance - 10 <= 0) ? 0 : Gladiator1.Endurance; } } if (player) { Console.Write(Flavor(Gladiator2, Gladiator1, body, 3)); } } } }
/// <summary> /// Put file (size less than 1Mo) in the safebox. /// </summary> /// <param name="fileName">Required</param> /// <param name="fileTitle">Required and must be UNIQUE</param> /// <param name="fileCreator"></param> /// <param name="fileSubject"></param> /// <param name="fileDescription"></param> /// <param name="filePublisher"></param> /// <param name="fileType"></param> /// <param name="stream"></param> ///<returns>Unique Id to store.</returns> ///<remarks>null if K.O</remarks> public string WriteWS(string fileName, string fileTitle, string fileCreator, string fileSubject, string fileDescription, string filePublisher, string fileType, FileStream stream) { if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(fileTitle)) { throw new Exception("D3SError - WriteWS : fileName and fileTitle are required."); } Dictionary<string, string> toMetadatas = new Dictionary<string, string>(); toMetadatas.Add("fileName", fileName); toMetadatas.Add("fileTitle", fileTitle); toMetadatas.Add("fileCreator", fileCreator); toMetadatas.Add("fileSubject", fileSubject); toMetadatas.Add("fileDescription", fileDescription); toMetadatas.Add("filePublisher", filePublisher); toMetadatas.Add("fileType", fileType); DictaoD3SStorage.Metadata[] Metadatas = _InitializeMetadatas(toMetadatas); GrantWrite pGrantWrite = new GrantWrite(); pGrantWrite.applicantPath = this._D3SUser; pGrantWrite.containerPath = this._D3SSafeboxPath; try { GrantWriteResponseContent pGrantWriteResponseContent = this._ClientAuthority.grantWrite(pGrantWrite); //check authority if (pGrantWriteResponseContent.grantWriteResponse.securityToken != null && pGrantWriteResponseContent.grantWriteResponse.certificates != null) { //Permission granted Write pWrite = new Write(); pWrite.applicantPath = this._D3SUser; pWrite.securityToken = new DictaoD3SStorage.SAMLToken(); pWrite.securityToken.Value = pGrantWriteResponseContent.grantWriteResponse.securityToken.Value; pWrite.containerPath = this._D3SSafeboxPath; pWrite.certificates = new DictaoD3SStorage.Certificates(); pWrite.certificates.Value = pGrantWriteResponseContent.grantWriteResponse.certificates.Value; pWrite.metadatas = Metadatas; pWrite.data = new byte[stream.Length]; stream.Read(pWrite.data, 0, Convert.ToInt32(stream.Length)); WriteResponse pWriteResponse = this._ClientStorage.write(pWrite); if (pWriteResponse != null) { string resourcePath = pWriteResponse.resourcePath; return _GetIdFromResourcePath(resourcePath); } } } catch (Exception ex) { throw new Exception(ex.Message); } finally { stream.Close(); } return null; }
public MineWorkViewModel(Guid id) { _id = id; this.Save = new DelegateCommand(() => { if (this.Id == Guid.Empty) { return; } if (string.IsNullOrEmpty(this.Name)) { VirtualRoot.Out.ShowError("作业名称是必须的"); } bool isMineWorkChanged = false; bool isMinerProfileChanged = false; MineWorkData mineWorkData = new MineWorkData(this); if (NTMinerRoot.Instance.MineWorkSet.TryGetMineWork(this.Id, out IMineWork entity)) { string sha1 = NTMinerRoot.Instance.MinerProfile.GetSha1(); // 如果作业设置变更了则一定变更了 if (this.Sha1 != sha1) { isMinerProfileChanged = true; } else { // 如果作业设置没变更但作业引用的服务器数据库记录状态变更了则变更了 LocalJsonDb localJsonObj = new LocalJsonDb(NTMinerRoot.Instance, mineWorkData); ServerJsonDb serverJsonObj = new ServerJsonDb(NTMinerRoot.Instance, localJsonObj); var serverJson = VirtualRoot.JsonSerializer.Serialize(serverJsonObj); sha1 = HashUtil.Sha1(serverJson); if (sha1 != this.ServerJsonSha1) { isMinerProfileChanged = true; } } if (entity.Name != this.Name || entity.Description != this.Description) { isMineWorkChanged = true; } CloseWindow?.Invoke(); } else { isMinerProfileChanged = true; VirtualRoot.Execute(new AddMineWorkCommand(this)); CloseWindow?.Invoke(); this.Edit.Execute(FormType.Edit); } if (isMinerProfileChanged) { Write.DevDebug("检测到MinerProfile状态变更"); NTMinerRoot.ExportWorkJson(mineWorkData, out string localJson, out string serverJson); if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson)) { Server.ControlCenterService.ExportMineWorkAsync(this.Id, localJson, serverJson, callback: null); } if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1) { this.ServerJsonSha1 = mineWorkData.ServerJsonSha1; isMineWorkChanged = true; } } if (isMineWorkChanged) { VirtualRoot.Execute(new UpdateMineWorkCommand(mineWorkData)); } }); this.Edit = new DelegateCommand <FormType?>((formType) => { if (this.Id == Guid.Empty) { return; } if (!AppContext.Instance.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel mineWorkVm)) { WpfUtil.ShowInputDialog("作业名称", string.Empty, workName => { if (string.IsNullOrEmpty(workName)) { return("作业名称是必须的"); } return(string.Empty); }, onOk: workName => { new MineWorkViewModel(this) { Name = workName }.Save.Execute(null); }); } else { // 编辑作业前切换上下文 // 根据workId下载json保存到本地并调用LocalJson.Instance.ReInit() string json = Server.ControlCenterService.GetLocalJson(this.Id); if (!string.IsNullOrEmpty(json)) { File.WriteAllText(SpecialPath.LocalJsonFileFullName, json); } else { File.Delete(SpecialPath.LocalJsonFileFullName); } NTMinerRoot.Instance.ReInitMinerProfile(); this.Sha1 = NTMinerRoot.Instance.MinerProfile.GetSha1(); VirtualRoot.Execute(new MineWorkEditCommand(formType ?? FormType.Edit, new MineWorkViewModel(this))); } }, formType => { if (this == PleaseSelect) { return(false); } return(true); }); this.Remove = new DelegateCommand(() => { if (this.Id == Guid.Empty) { return; } this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除吗?", title: "确认", onYes: () => { VirtualRoot.Execute(new RemoveMineWorkCommand(this.Id)); })); }, () => { if (this == PleaseSelect) { return(false); } return(true); }); }
public void Debug(string mes) { Write?.Invoke("Debug: " + mes); }
protected void btnFirstChid_Click(object sender, EventArgs e) { _write = new Write(fileName); txtFirstChild.Text = _write.ShowFirstChild(); }
public void Info(string mes) { Write?.Invoke("Info: " + mes); }
protected void btnRemoveNode_Click(object sender, EventArgs e) { _write = new Write(fileName); _write.Remove(); }
public Classes(BaseClass baseClass, Write write) { Create(baseClass, write); }
protected void btnTotalNode_Click(object sender, EventArgs e) { _write = new Write(fileName); txtFirstChild.Text = _write.Count().ToString(); }
private void SaveList() { Write.WriteToFile(ListPath, RawString); }
public void Error(string mes) { Write?.Invoke("Error: " + mes); Info("Exit"); }
protected void btnSubmit_Click(object sender, EventArgs e) { _write = new Write(fileName); _write.CreateFile(); }