public void Test_Worker() { this.CreateBackup(); try { this.PreTestAsserts(); UpdateWorker worker = new UpdateWorker(); worker.PerformUpdate(new UpdateInstructions { Packages = new List <UpdateInstructions.PackageData>() { new UpdateInstructions.PackageData() { Version = "1.1", Path = Path.Combine(this.Update12Folder.FullName, "MyApp Update v. 1.1.zip") }, new UpdateInstructions.PackageData() { Version = "1.2", Path = Path.Combine(this.Update12Folder.FullName, "MyApp Update v. 1.2.zip") }, }, ProgramExecutableLocation = this.MyAppExePath.FullName }); this.PostTestAsserts(); } finally { this.Cleanup(); } }
public RayCastForm() { InitializeComponent(); UpdateWorker.WorkerReportsProgress = true; UpdateWorker.WorkerSupportsCancellation = true; RenderGraphics = this.CreateGraphics(); for (int i = 0; i <= 10; i++) { rSolidBrush = new SolidBrush(Color.FromArgb(i * 25, 0, 0)); solidBrushes.Add(rSolidBrush); pens.Add(new Pen(rSolidBrush)); } int ix = 0; //RPen = new Pen(GetBrushFromList(solidBrushes,10)); RPen = GetPenFromList(pens, 10); MyRayCast = new CRayCast(this.Width, this.Height); MyRayCast.InitRayCast(); GeneratePens(); mPen = new Pen(new SolidBrush(Color.White)); backpen = new Pen(new SolidBrush(Color.Red)); backpen.DashStyle = DashStyle.Dash; UpdateWorker.RunWorkerAsync(); Paint += new PaintEventHandler(RayCastForm_Paint); //RenderGraphics.Dispose(); }
public static unsafe void Process(HttpContext context, uint accountId) { var contentLength = (int)context.Request.ContentLength; var pctx = new ParseContext(Buffer.My, contentLength); context.ReadBytes(pctx); AccountStub stub = UpdatePool.RentStub(); stub.id = accountId; if (!TryParseAccountUpdate(ref pctx, stub)) { BadRequest(context, stub); return; } if (!stub.email.IsEmpty) { Account account = Database.GetAccount(accountId); Email previous = account.Email; Database.Replace(previous, stub.email); } UpdateWorker.Update(stub); context.Response.StatusCode = StatusCodes.Status202Accepted; context.Response.ContentLength = 2; context.Response.Body.Write(NewHandler.Empty); }
public static unsafe void Process(HttpContext context) { var contentLength = (int)context.Request.ContentLength; var pctx = new ParseContext(Buffer.My, contentLength); context.ReadBytes(pctx); if (!TryParseLikes(ref pctx, out HList <NewLike> result)) { if (result != null) { UpdatePool.Return(result); } BadRequest(context); return; } if (result != null) { UpdateWorker.AddLikes(result); } context.Response.StatusCode = StatusCodes.Status202Accepted; context.Response.ContentLength = 2; context.Response.Body.Write(NewHandler.Empty); }
static void Main(string[] args) { Console.WriteLine("1. CONTRACT with input data: 4097, new DateTime(2019, 12, 12)"); Console.WriteLine("2. CONTRACT with new input data"); Console.WriteLine(); Console.WriteLine("3. WORKER with input data: 4097, ..."); Console.WriteLine("4. WORKER with new input data"); string choice = Console.ReadLine(); if (choice == "1" || choice == "2") { UpdateContract.Process(choice); } else if (choice == "3" || choice == "4") { UpdateWorker.Process(choice); } else { Console.WriteLine("Wrong choice"); } Console.WriteLine("Press any key to close the console"); Console.ReadLine(); }
public WorkerViewModel() { addWorker = new AddWorker(this); UpdateWorker = new UpdateWorker(this); DeleteWorker = new DeleteWorker(this); CurrentWorker = new WorkerEntity(); SelectWorker = new WorkerEntity(); }
static void ProcessQueue() { while (true) { while (updateQueue.Count > 0) { UpdateWorker worker = null; lock (updateQueue) { worker = updateQueue.Dequeue(); } worker.InnerRun(); } queueSignal.WaitOne(); } }
public bool UpdateList(List <Employee> listData) { bool result = false; try { result = UpdateWorker.UpdateList(listData); } catch (Exception ex) { LogSystem.Error(ex); result = false; } return(result); }
public bool Update(ModuleRole data) { bool result = false; try { result = UpdateWorker.Update(data); } catch (Exception ex) { LogSystem.Error(ex); result = false; } return(result); }
public bool Update(CredentialData data) { bool result = false; try { result = UpdateWorker.Update(data); } catch (Exception ex) { LogSystem.Error(ex); result = false; } return(result); }
public async Task <IActionResult> Put([FromBody] UpdateWorker worker) { var LogReg = new LogReg { id = Guid.NewGuid(), HttpMethod = "PUT", ReqPath = "/Workers", Request = JsonConvert.SerializeObject(worker, Formatting.Indented), Response = JsonConvert.SerializeObject(new { result = "Worker with id " + worker.cedula_old + " was updated with the worker with id " + worker.cedula_new }) }; context.Add(LogReg); await context.SaveChangesAsync(); return(Ok(new { result = "Worker with id " + worker.cedula_old + " was updated with the worker with id " + worker.cedula_new })); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Task t1 = Task.Factory.StartNew(() => { var queryWorker = new QueryWorker(stoppingToken, _logger, _appConfig.Value); queryWorker.Run(); }, stoppingToken); tasks.Add(t1); Task t2 = Task.Factory.StartNew(() => { var updateWorker = new UpdateWorker(stoppingToken, _logger, _appConfig.Value); updateWorker.Run(); }, stoppingToken); tasks.Add(t2); while (!stoppingToken.IsCancellationRequested) { await Task.Delay(2000, stoppingToken); } try { Task.WaitAll(tasks.ToArray()); } catch (AggregateException e) { _logger.LogError("AggregateException thrown with the following inner exceptions:"); // Display information about each exception. foreach (var v in e.InnerExceptions) { if (v is TaskCanceledException) { _logger.LogError(" TaskCanceledException: Task {0}", ((TaskCanceledException)v).Task.Id); } else { _logger.LogError(" Exception: {0}", v.GetType().Name); } } } }
static void ProcessQueue() { while (true) { while (updateQueue.Count > 0) { UpdateWorker worker = null; lock (updateQueue) { worker = updateQueue.Dequeue(); } try { worker.InnerRun(); } catch (Exception e) { Console.WriteLine("Exception in syntax mode update thread:" + e); } } queueSignal.WaitOne(); } }
public PrintServer() { string rootPath = Environment.CurrentDirectory; this.HttpServer = new HTTPServer("0.0.0.0", this.GetServerPort()); this.HttpServer.SetRoot(rootPath); this.HttpServer.OnPostRequestReceived = this.OnPrintRequestReceived; this.HttpServer.Logger = new FileLogger(); this.printEngin = PrintObjectFactory.GetEngin(AppSettingHelper.GetOne("engin", "PDF")); this.printEngin.Initialize(); this.logContainer = new LogContainer(); this.printStatistics = new PrintStatistics(); this.ServerThread = new Thread(new ThreadStart(HttpServerThread)); this.OnPrintServerLogged = delegate(string maeesage) { Console.WriteLine(maeesage); }; this.updateWorker = new UpdateWorker(UpdateCheckerProvider.GetChcker()); }
public static void Process(HttpContext context) { var contentLength = (int)context.Request.ContentLength; var pctx = new ParseContext(Buffer.My, contentLength); context.ReadBytes(pctx); var stub = UpdatePool.RentStub(); var statusCode = TryParseAccount(ref pctx, stub); context.Response.StatusCode = statusCode; if (statusCode == 201) { context.Response.ContentLength = Empty.Length; context.Response.Body.Write(Empty); UpdateWorker.AddNew(Database.InsertFromPost(stub)); } else { UpdatePool.Return(stub); } }
public ActionResult Spawn() { var characters = Database.GetCharacterIds(); foreach (var cid in characters) { if (Database.GetTokenFor(cid, new[] { EsiCharacterScopes.WalletRead }) != null) { var parameters = new Parameter[] { new Parameter("character_id", cid, ParameterType.UrlSegment) }; var jobJournal = new UpdateWorker(UpdateWorkerType.CharacterWalletJournal, parameters); JobHelper.UpdateWorkers.Add(jobJournal); ThreadPool.QueueUserWorkItem(jobJournal.ThreadPoolCallback); var jobTransactions = new UpdateWorker(UpdateWorkerType.CharacterWalletTransactions, parameters); JobHelper.UpdateWorkers.Add(jobTransactions); ThreadPool.QueueUserWorkItem(jobTransactions.ThreadPoolCallback); } if (Database.GetTokenFor(cid, new[] { EsiCharacterScopes.IndustryMiningRead }) != null) { var parameters = new Parameter[] { new Parameter("character_id", cid, ParameterType.UrlSegment) }; var jobLedger = new UpdateWorker(UpdateWorkerType.CharacterMiningJournal, parameters); JobHelper.UpdateWorkers.Add(jobLedger); ThreadPool.QueueUserWorkItem(jobLedger.ThreadPoolCallback); } if (Database.GetTokenFor(cid, new[] { EsiCharacterScopes.MarketsOrdersRead }) != null) { var parameters = new Parameter[] { new Parameter("character_id", cid, ParameterType.UrlSegment) }; var jobMarketHistory = new UpdateWorker(UpdateWorkerType.CharacterMarketOrdersHistory, parameters); JobHelper.UpdateWorkers.Add(jobMarketHistory); ThreadPool.QueueUserWorkItem(jobMarketHistory.ThreadPoolCallback); } } return(RedirectToAction("Index")); }
private void OnUpdaterDownloadProgress(DownloadProgressEventArgs args) { UpdateWorker.ReportProgress((int)args.Percent, args); }
private void UpdateFormLoad(object sender, EventArgs e) { UpdateWorker.RunWorkerAsync(); }
public ViewModel() { #if DEBUG Constants.BmpQuality = 1; #endif _selectColor = new ItemsColor { Red = 185, Blue = 168, Green = 185, NameColorRAL = "RAL 7032" }; _panelColorPortal = new ViewPanel(); _viewPanelColorPortal = _panelColorPortal.DataContext as VMViewPanel; _panelColorPlace = new ViewPanel(); _viewPanelColorPlace = _panelColorPlace.DataContext as VMViewPanel; _panelColorA = new ViewPanel(); _viewPanelColorVMA = _panelColorA.DataContext as VMViewPanel; _nameElement = new ObservableCollection <string>(); _panelColorB = new ViewPanel(); _viewPanelColorVMB = _panelColorB.DataContext as VMViewPanel; _panelColorV = new ViewPanel(); _viewPanelColorVMV = _panelColorV.DataContext as VMViewPanel; _panelColorG = new ViewPanel(); _viewPanelColorVMG = _panelColorG.DataContext as VMViewPanel; _schemePanel = new SchemePanel(); _schemePanelVM = _schemePanel.DataContext as VMSchemePanel; _viewPanelPlace = new ViewPanel(); _viewPanelPlaceVM = _viewPanelPlace.DataContext as VMViewPanel; _viewPanelA = new ViewPanel(); _viewPanelVMA = _viewPanelA.DataContext as VMViewPanel; _viewPanelB = new ViewPanel(); _viewPanelVMB = _viewPanelB.DataContext as VMViewPanel; _viewPanelV = new ViewPanel(); _viewPanelVMV = _viewPanelV.DataContext as VMViewPanel; _viewPanelG = new ViewPanel(); _viewPanelVMG = _viewPanelG.DataContext as VMViewPanel; _viewPanelPlace = new ViewPanel(); _viewPanelPlaceVM = _viewPanelPlace.DataContext as VMViewPanel; _viewPanelPortal = new ViewPanel(); _viewPanelPortalVM = _viewPanelPortal.DataContext as VMViewPanel; VisibilityExpander = Visibility.Hidden; _appThemes = AppThemes.Instance; ListViewPlaceElement = new ObservableCollection <FrameworkElement>(); ListViewPlace = new ObservableCollection <BaseDrawClass>(); ListViewPlaceElementColor = new ObservableCollection <FrameworkElement>(); ListViewPlaceColor = new ObservableCollection <BaseDrawClass>(); ListViewPortalElement = new ObservableCollection <FrameworkElement>(); ListViewPortal = new ObservableCollection <BaseDrawClass>(); ListViewPortalElementColor = new ObservableCollection <FrameworkElement>(); ListViewPortalColor = new ObservableCollection <BaseDrawClass>(); ListColorElementA = new ObservableCollection <FrameworkElement>(); ListColorVMA = new ObservableCollection <BaseDrawClass>(); ListColorElementB = new ObservableCollection <FrameworkElement>(); ListColorVMB = new ObservableCollection <BaseDrawClass>(); ListColorElementV = new ObservableCollection <FrameworkElement>(); ListColorVMV = new ObservableCollection <BaseDrawClass>(); ListColorElementG = new ObservableCollection <FrameworkElement>(); ListColorVMG = new ObservableCollection <BaseDrawClass>(); ListViewsElementA = new ObservableCollection <FrameworkElement>(); ListViewsVMA = new ObservableCollection <BaseDrawClass>(); ListViewsElementB = new ObservableCollection <FrameworkElement>(); ListViewsVMB = new ObservableCollection <BaseDrawClass>(); ListViewsElementV = new ObservableCollection <FrameworkElement>(); ListViewsVMV = new ObservableCollection <BaseDrawClass>(); ListViewsElementG = new ObservableCollection <FrameworkElement>(); ListViewsVMG = new ObservableCollection <BaseDrawClass>(); ListPages = new ObservableCollection <UserControl>(); ListSchemeElement = new ObservableCollection <FrameworkElement>(); ListScheme = new List <VMSchemeElement>(); _appThemes.AppManager = this; //_preview = new Preview(); //CellsArrange = new CellsArrange(); _wizzardMain = new WizzardMain { AppManagement = this, //_wizzardMain.Updates = this; //_wizzardMain.CellsManagement = this; RelativePositions = this, WCommonParameters = GetCommonData() }; _wizzardMain.RelativePositions = this; _wizzardMain.ToastNotifications = this; InitializeCommands(); InitializeCommandParser(); InitializeToolbars(); InitializeMainParameters(); UpdateWorker.CheckUpdate(Application.Current.Shutdown, Logger.W, new Update.AppData() { Path = Constants.AppPath, AssemblyPath = Constants.AppAssemblyPath, Title = Constants.AppName, }, new Update.LineArgs() { From = Common.AppData.LineArgs.From, To = Common.AppData.LineArgs.To, Type = Common.AppData.LineArgs.Type, }, Core.Settings.LoadSettings().UpdateChannel == UpdateChannel.Beta ? "beta" : ""); }
public async Task <IActionResult> PutFile(string id, [FromQuery] string access_token) { Config.logger.LogDebug("PutFile: id=" + id); try { if (string.IsNullOrEmpty(access_token)) { Config.logger.LogError("status:500 accessToken is null"); return(StatusCode(500)); } Dictionary <string, Object> token = AccessTokenVerifier.DecodeJWT(access_token); Dictionary <string, string> user = (Dictionary <string, string>)token["user"]; Dictionary <string, string> metadata = (Dictionary <string, string>)token["metadata"]; if (!AccessTokenVerifier.VerifyAccessToken(id, (string)metadata["id"], (string)token["created"])) { Config.logger.LogError("status:500 accessToken is illegal"); return(StatusCode(500)); } Session editSession = Session.GetSessionFromRedis(id); if (editSession == null) { Config.logger.LogError("status:500 the session is null"); return(StatusCode(500)); } string fileName = editSession.LocalFilePath; if (!FilesService.FileExists(fileName)) { Config.logger.LogError("status:404 the file is not exsist"); return(StatusCode(404)); } string lockValue = editSession.LockString; string operation, xWopiLock = null; string[] xWopiEditors; var content = default(byte[]); using (var memstream = new MemoryStream()) { memstream.Flush(); memstream.Position = 0; Request.Body.CopyTo(memstream); content = memstream.ToArray(); } Request.Headers.TryGetValue("X-WOPI-Override", out var xWopiOverrideHeader); if (xWopiOverrideHeader.Count != 1 || string.IsNullOrWhiteSpace(xWopiOverrideHeader.FirstOrDefault())) { Config.logger.LogError("status:400, X-WOPI-Override header not found"); return(StatusCode(400)); } else { operation = xWopiOverrideHeader.FirstOrDefault(); } Request.Headers.TryGetValue("X-WOPI-Lock", out var xWopiLockHeader); if (xWopiLockHeader.Count > 0 && (!string.IsNullOrWhiteSpace(xWopiLockHeader.FirstOrDefault()))) { xWopiLock = xWopiLockHeader.FirstOrDefault(); } Request.Headers.TryGetValue("X-WOPI-Editors", out var xWopiEditorsHeader); if (xWopiEditorsHeader.Count > 0 && string.IsNullOrWhiteSpace(xWopiEditorsHeader.FirstOrDefault())) { xWopiEditors = xWopiLockHeader.FirstOrDefault().Split(","); } switch (operation) { case "PUT": if (xWopiLock == null || lockValue.Equals(xWopiLock)) { if (editSession.Save(content, user["id"])) { bool needWorker = !editSession.ChangesMade; editSession.ChangesMade = true; editSession.UserForUpload = new User(user["id"], user["authorization"]); editSession.SaveToRedis(); if (needWorker) { UpdateWorker worker = new UpdateWorker(id); Thread t = new Thread(new ThreadStart(worker.Work)); t.Start(); } Config.logger.LogDebug("status 200, the session {0} saved in redis", editSession.SessionId); return(StatusCode(200)); } else { //User unauthorized Config.logger.LogError("status 404, save session {0} is fail", editSession.SessionId); return(StatusCode(404)); } } else { Response.Headers.Add("X-WOPI-Lock", lockValue); Config.logger.LogError("status:409, lock value isnt the same"); return(StatusCode(409)); } //TODO case "RELATIVE_PUT" default: { Config.logger.LogError("status 500, Put fail"); return(StatusCode(500)); } } } catch (Exception e) { if (e is DriveFileNotFoundException) { Config.logger.LogError("status:404 PutFile Drive Error" + e.Message); return(StatusCode(404)); } else { Config.logger.LogError("status:500, PutFile Error:" + e.Message); return(StatusCode(500)); } } }