protected async override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await CheckCounterIsDisabled(); BWHelperFunctions.CheckIfMobile(); } if (!DisableCounters) { if (!navigationManager.Uri.Equals(CurrentURI)) { CurrentURI = navigationManager.Uri; await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "visit" }); } } await base.OnAfterRenderAsync(firstRender); }
/// <summary> /// Создать счётчик определённого типа /// </summary> /// <param name="type">Тип счётчика</param> /// <param name="counterName">Имя счётчика</param> /// <param name="counterDescription">Описание счётчика</param> /// <returns>Счётчик</returns> public override Counter CreateCounter(CounterTypes type, string counterName, string counterDescription) { if (counterName == null) { throw new ArgumentNullException("counterName"); } if (counterDescription == null) { throw new ArgumentNullException("counterDescription"); } if (State != WinCategoryState.Created) { throw new InvalidOperationException("Can't create counter inside initialized category. Category: " + this.ToString()); } if (_counters.ContainsKey(counterName)) { throw new PerformanceCounterCreationException("Counter with the same name is already existed. Name: " + counterName, new DuplicateCounterNameException("Counter with the same name is already existed. Name: " + counterName)); } Counter res = CounterHelper.CreateCounter(type, counterName, counterDescription, Info); if (!_counters.TryAdd(counterName, res)) { throw new PerformanceCounterCreationException("Counter with the same name is already existed. Name: " + counterName, new DuplicateCounterNameException("Counter with the same name is already existed. Name: " + counterName)); } return(res); }
static SiteNodeHelper() { _performanceHelper = PerformanceHelper.CreateCounterHelper <Counters>("Test"); _performanceHelper.RawValue(Counters.SuccessfullHttpRequests, 0); _performanceHelper.RawValue(Counters.FailedHttpRequests, 0); }
private void btnAddSellThing_Click(object sender, EventArgs e) { st = new SellThing() { SellNo = txtSellNo.Text, SellName = txtSellName.Text, SellPrice = Convert.ToDecimal(txtSellPrice.Text), format = Convert.ToString(txtformat.Text), Stock = Convert.ToInt32(txtStock.Text), datains_usr = AdminInfo.Account, datains_date = DateTime.Now }; if (CheckInput(st)) { new SellService().InsertSellThing(st); MessageBox.Show("添加商品成功"); dgvSellthing.DataSource = new SellService().SelectSellThingAll(); string SellId = new CounterHelper().GetNewId("SellId"); txtSellNo.Text = SellId; } else { UIMessageBox.ShowError("信息不完整,请检查!"); return; } }
public async void loadFileRegular() { log.Clear(); if (await LBDJsInterop.HasFile("fileUpload")) { await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "ClickButtonRegular" }); BWHTimeAnalyzer.Reset("Regular mode"); log.Add("started"); log.Add("js is loading file..."); StateHasChanged(); BWHTimeAnalyzer.Add("set data", MethodBase.GetCurrentMethod()); string a = await LBDJsInterop.GetFile(_BinaryInfo.variableName, "fileUpload"); log.Add(a); log.Add(".net loaded " + a.Length + " bytes"); log.Add("done"); BWHTimeAnalyzer.LogAll(); StateHasChanged(); } else { await LBDJsInterop.Alert("Please select file"); } }
public AccountController(CounterHelper <CustomeCounters> counterHelper, ILogger logger, UserManager <ApplicationUser> userManager) { this.counterHelper = counterHelper; this.logger = logger; _userManager = userManager; logger.Info("AccountController created"); }
/// <summary> /// Конструктор UseOnlyExistedWinMultiInstanceCategory /// </summary> /// <param name="name">Имя категории</param> /// <param name="description">Описание категории</param> /// <param name="rootName">Корневое имя</param> /// <param name="info">Информация о функционировании</param> internal UseOnlyExistedWinMultiInstanceCategory(string name, string description, string rootName, WinCountersWorkingInfo info) : base(name, description, rootName, info) { if (info.InstantiationMode != WinCountersInstantiationMode.UseOnlyExisted) { throw new InvalidOperationException("Category UseOnlyExistedWinSingleInstanceCategory can't be used with instantiation mode: " + info.InstantiationMode.ToString()); } if (!HasWinCategory()) { throw new CategoryCreationException(string.Format("Can't create category ({0}) cause it is not registerd in Windows (UseOnlyExisted mode)", this.ToString())); } _instances = new ConcurrentDictionary <string, WinInstanceInMultiInstanceCategory>(); _counters = new ConcurrentDictionary <string, WinCounterDescriptor>(); _winCategory = GetExistedWinCategory(); var existedCntr = _winCategory.GetCounters(""); foreach (var cnt in existedCntr) { var newCounter = CounterHelper.CreateDescriptorByExistedCounter(cnt, Info); if (newCounter != null) { _counters.TryAdd(newCounter.Name, newCounter); } cnt.Dispose(); } this.Init(); }
public async void loadFileFast() { ResetBinaryInfo(); if (await LBDJsInterop.HasFile("fileUpload")) { await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "ClickButtonFast" }); _BinaryInfo.progressInfo = "started"; log.Add("started"); BWHTimeAnalyzer.Reset("Fast mode"); BWHTimeAnalyzer.Add("reading in js", MethodBase.GetCurrentMethod()); _BinaryInfo.progressInfo = "js is loading file..."; log.Add("js is loading file..."); StateHasChanged(); await LBDJsInterop.ReadFile(_BinaryInfo.variableName, "fileUpload"); } else { await LBDJsInterop.Alert("Please select file"); } }
// 添加启动参数的处理 protected override void OnStartup(StartupEventArgs e) { // 根据传入参数进行任务调度 var startupMode = StartupMode.Normal; if (e.Args.Length > 0) { System.Enum.TryParse(e.Args[0], out startupMode); } if (startupMode == StartupMode.Normal) { // 启动主窗体 var mw = new MainWindow(); Current.ShutdownMode = ShutdownMode.OnMainWindowClose; Current.MainWindow = mw; mw.Show(); return; } if (startupMode == StartupMode.BackGround) { // 限制后台进程只能有一个 var mutex = new System.Threading.Mutex(true, nameof(WorkOverTimeCounter), out var ret); if (!ret) { //MessageBox.Show("已在运行中!"); Environment.Exit(0); } CounterHelper.StartCount(); return; } // 设置/取消自启动后结束进程 if (startupMode == StartupMode.SetSelfStart) { // 启动后台监视进程 var mutex = new System.Threading.Mutex(true, nameof(WorkOverTimeCounter), out var ret); if (ret) { var p = new Process(); var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase); processInfo.Arguments = StartupMode.BackGround.ToString(); p.StartInfo = processInfo; try { p.Start(); } catch (Exception exce) { MessageBox.Show(exce.Message); } } SetSelfStartingHelper.SetSelfStart(); } if (startupMode == StartupMode.UnsetSelfStart) { SetSelfStartingHelper.UnsetSelfStart(); } Environment.Exit(0); }
public AccountController(CounterHelper <ControllersCounters> counterHelper, ILogger logger, UserManager <ApplicationUser> userManager) { _counterHelper = counterHelper; _logger = logger; _userManager = userManager; _logger.Info("AccountController created"); }
public AccountController(UserManager <ApplicationUser> userManager, ILoggerService logger, CounterHelper <Counters> counterHelper) { _userManager = userManager; _logger = logger; _logger.Trace("AccountController created"); _counterHelper = counterHelper; }
/// <summary> /// Requests <paramref name="action"/> to be run on scheduler with <paramref name="state"/> being passed in /// </summary> public override void Schedule(Action <object> action, object state) { if (action == null) { return; // nothing to do } lock (_queue) { #pragma warning disable RCS1233 if (!(_disposed | _queue.Count >= UseThreadPoolQueueLength)) #pragma warning restore RCS1233 { _queue.Enqueue(new WorkItem(action, state)); if (_availableCount != 0) { Monitor.Pulse(_queue); // wake up someone } CounterHelper.Incr(Counter.ThreadPoolScheduled); return; } } // fallback to thread-pool CounterHelper.Incr(Counter.ThreadPoolPushedToMainThreadPool); ThreadPool.Schedule(action, state); }
private void FrmSellThingManager_Load(object sender, EventArgs e) { string SellId = new CounterHelper().GetNewId("SellId"); txtSellNo.Text = SellId; dgvSellthing.DataSource = new SellService().SelectSellThingAll(); dgvSellthing.AutoGenerateColumns = false; }
public HomeController(ILogger logger, CounterHelper <MvcMusicStoreCounters> musicStoreCounterHelper) { _logger = logger; _musicStoreCounterHelper = musicStoreCounterHelper; ; _logger.Info($"Call {nameof(HomeController)} constructor."); _logger.Debug($"GoToHomeCounter = {musicStoreCounterHelper.GetInstance(MvcMusicStoreCounters.GoToHome)?.RawValue}."); }
private void dgvReserList_CellClick(object sender, DataGridViewCellEventArgs e) { string custoNo = new CounterHelper().GetNewId("ReserId"); txtCustoNo.Text = custoNo; txtCustoName.Text = dgvReserList.SelectedRows[0].Cells["clCustoNm"].Value.ToString(); txtTel.Text = dgvReserList.SelectedRows[0].Cells["clTel"].Value.ToString(); }
public static void ConfigureCounters() { CounterHelper <Counters> counterHelper = DependencyResolver.Current.GetService(typeof(CounterHelper <Counters>)) as CounterHelper <Counters>; foreach (Counters counter in Enum.GetValues(typeof(Counters))) { counterHelper.Reset(counter); } }
private void MainForm_Load(object sender, EventArgs e) { counterHelper = PerformanceHelper.CreateCounterHelper <SingleInstance_PerformanceCounters>(); if (counterHelper == null) { MessageBox.Show("Counter not installed. Attempting to install."); PerformanceHelper.Install(typeof(SingleInstance_PerformanceCounters)); } }
public AccountController(UserManager <ApplicationUser> userManager) { _userManager = userManager; counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("MvcMusicStore"); if (ConfigurationManager.AppSettings["Logging"].AsBool()) { logger = new Logger(); } }
private void StartWorker(int id) { var thread = new Thread(ThreadRunWorkLoop) { Name = $"{Name}:{id}", Priority = Priority, IsBackground = true }; thread.Start(this); CounterHelper.Incr(Counter.ThreadPoolWorkerStarted); }
private void Execute(Action <object> action, object state) { try { action(state); CounterHelper.Incr(Counter.ThreadPoolExecuted); CounterHelper.Incr(action == SocketAwaitableEventArgs.InvokeStateAsAction ? ((Action)state).Method : action.Method); } catch (Exception ex) { _logger.LogVerbose(Name, ex.Message); } }
private async void CmdGetReport() { DisableButton = true; report1 = await CounterHelper.CmdGetReport1(CurrComboFilterOptionsIndex == 9, fromDate, toDate); LastRefreshDate = DateTime.Now; DisableButton = false; StateHasChanged(); }
protected async override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { BWHelperFunctions.CheckIfMobile(); } await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "visit" }); await base.OnAfterRenderAsync(firstRender); }
protected override async Task OnInitializedAsync() { JsFastDataExchanger.jsRuntime = jsRuntime; BWHWindowHelper.jsRuntime = jsRuntime; CounterHelper.Initialize(); await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "visit" }); await base.OnInitializedAsync(); return; }
protected override async Task OnInitializedAsync() { LBDLocalData.mainLayout = this; LocalFunctions.navigationManager = navigationManager; CounterHelper.Initialize(); LocalFunctions.RedirectIfNeeded(navigationManager); LBDJsInterop.jsRuntime = jsRuntime; BWHJsInterop.jsRuntime = jsRuntime; await CheckCounterIsDisabled(); //if (WebApiFunctions.httpClient is null) //{ // WebApiFunctions.httpClient = httpClient; // WebApiFunctions.httpClient.BaseAddress = LocalData.WebApi_Uri; // WebApiFunctions.httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite); // WebApiFunctions.CmdGetVisitor(); //} //if (LocalData.IsDevelopmentMode) //{ // if (!BlazorWindowHelper.BWHJsInterop.IsReady) // { // BlazorWindowHelper.BWHJsInterop.jsRuntime = jsRuntime; // BlazorWindowHelper.BWHJsInterop.IsReady = true; // } //} if (LBDLocalData.TimezoneOffset == -99999) { LBDLocalData.TimezoneOffset = await BWHJsInterop.GetTimezoneOffset(); } await base.OnInitializedAsync(); return; }
private async Task DoReceiveAsync() { Exception error = null; DebugLog("starting receive loop"); try { // 说明:recv方向上是recv from socket and push to pipe,所以这里回调应该是 // 执行在WriterScheduler上 _readerArgs = new SocketAwaitableEventArgs(InlineReads ? null : _receiveOptions.WriterScheduler); while (true) { if (ZeroLengthReads && Socket.Available == 0) { DebugLog($"awaiting zero-length receive..."); CounterHelper.Incr(Counter.OpenReceiveReadAsync); DoReceive(Socket, _readerArgs, default, Name);
/// <summary> /// Создать счётчик определённого типа, если он уже есть в Windows /// </summary> /// <param name="type">Тип счётчика</param> /// <param name="counterName">Имя счётчика</param> /// <param name="counterDescription">Описание счётчика</param> /// <returns>Счётчик</returns> public override Counter CreateCounter(CounterTypes type, string counterName, string counterDescription) { if (counterName == null) { throw new ArgumentNullException("counterName"); } if (counterDescription == null) { throw new ArgumentNullException("counterDescription"); } if (State == WinCategoryState.Disposed) { throw new ObjectDisposedException(this.GetType().Name); } Counter res = null; if (!_counters.TryGetValue(counterName, out res)) { throw new PerformanceCounterCreationException("Can't create not existed counter in mode 'UseOnlyExisted'. Counter: " + counterName + ", Category: " + this.ToString()); } if (res.Type != type && CounterHelper.IsWinCompatible(res.Type, type)) { var newCntr = CounterHelper.CreateCounter(type, counterName, res.Description, Info); if (_counters.TryUpdate(counterName, newCntr, res)) { (newCntr as IWinCounterInitialization).CounterInit(this.FullName, null); res = newCntr; } } if (res.Type != type) { throw new PerformanceCounterCreationException("Can't create not existed counter in mode 'UseOnlyExisted'. Counter: " + counterName, new InvalidCounterTypeException(string.Format("Counter types are not equal. Expected: {0}, Returned: {1}", type, res.Type))); } return(res); }
private void FrmInputs_Load(object sender, EventArgs e) { foreach (Control label in this.Controls) { if (label.GetType().ToString() == "System.Windows.Forms.Label") { label.Font = UI_FontUtil.SetControlFont(); } } string cardId = new CounterHelper().GetNewId("CustoId"); txtCustoNo.Text = cardId; #region 加载客户类型信息 List <CustoType> lstSourceGrid = new BaseService().SelectCustoTypeAll(); this.cbCustoType.DataSource = lstSourceGrid; this.cbCustoType.DisplayMember = "TypeName"; this.cbCustoType.ValueMember = "UserType"; this.cbCustoType.SelectedIndex = 0; this.cbCustoType.ReadOnly = true; #endregion #region 加载证件类型信息 List <PassPortType> passPorts = new BaseService().SelectPassPortTypeAll(); this.cbPassportType.DataSource = passPorts; this.cbPassportType.DisplayMember = "PassportName"; this.cbPassportType.ValueMember = "PassportId"; this.cbPassportType.SelectedIndex = 0; #endregion #region 加载性别信息 List <SexType> listSexType = new BaseService().SelectSexTypeAll(); this.cbSex.DataSource = listSexType; this.cbSex.DisplayMember = "sexName"; this.cbSex.ValueMember = "sexId"; this.cbSex.SelectedIndex = 0; #endregion }
private void btnReser_Click(object sender, EventArgs e) { Random random = new Random(); string reserid = ""; reserid = new CounterHelper().GetNewId("ReserId"); Reser reser = new Reser() { ReserId = reserid, CustoName = txtCustoName.Text.Trim(), CustoTel = txtCustoTel.Text.Trim(), ReserWay = cboReserWay.Text, ReserRoom = cboReserRoomNo.Text, ReserDate = dtpBouDate.Value, ReserEndDay = dtpEndDate.Value }; Room room = new Room() { RoomNo = cboReserRoomNo.Text, RoomStateId = 4 }; bool result1 = new ReserService().InserReserInfo(reser); bool result2 = new RoomService().UpdateRoomInfoWithReser(room); if (result1 == true && result2 == true) { MessageBox.Show("预约成功!请在指定时间内进行登记入住"); #region 获取添加操作日志所需的信息 OperationLog o = new OperationLog(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = LoginInfo.WorkerClub + LoginInfo.WorkerPosition + LoginInfo.WorkerName + "于" + DateTime.Now + "帮助" + txtCustoTel.Text + "进行了预订房间操作!"; o.OperationAccount = LoginInfo.WorkerNo; o.datains_usr = LoginInfo.WorkerNo; o.datains_date = DateTime.Now; #endregion new OperationlogService().InsertOperationLog(o); this.Close(); } }
//protected override void OnInitialized() //{ // base.OnInitialized(); //} public async void JsSendMessage() { if (!string.IsNullOrEmpty(JsMessage)) { await CounterHelper.CmdAddCounter(new TSCounter() { Source = navigationManager.Uri, Action = "ClickButtonRegular" }); ExpandData(); log.Add(JsMessage); BlazorTimeAnalyzer.Reset(); BlazorTimeAnalyzer.Add("set data", MethodBase.GetCurrentMethod()); await LBDJsInterop.SetData("myTmpVar1", JsMessage); BlazorTimeAnalyzer.Add("process data", MethodBase.GetCurrentMethod()); LBDJsInterop.ProcessData("myTmpVar1"); BlazorTimeAnalyzer.Add("get data", MethodBase.GetCurrentMethod()); log.Add(await LBDJsInterop.GetData("myTmpVar1")); BlazorTimeAnalyzer.LogAll(); JsMessage = string.Empty; } else { await LBDJsInterop.Alert("Please input message"); } StateHasChanged(); }
static HomeController() { CounterHelper = PerformanceHelper.CreateCounterHelper <StoreCounters>("Test counter project"); }
private void MainForm_Load(object sender, EventArgs e) { counterHelper = PerformanceHelper.CreateCounterHelper<SingleInstance_PerformanceCounters>(); if (counterHelper == null) { MessageBox.Show("Counter not installed. Attempting to install."); PerformanceHelper.Install(typeof(SingleInstance_PerformanceCounters)); } }
private void MainForm_Load(object sender, EventArgs e) { counterHelper = PerformanceHelper.CreateCounterHelper<MultiInstance_PerformanceCounters>(); }