public ProfileWorker creation(UserInfo userInfo, WorkerInfo workerInfoData, List <RatingWorker> ratings, List <PostAProject> projects) { var profile = new ProfileWorker(); profile.UserId = userInfo.UserId; profile.FristName = userInfo.FristName; profile.LastName = userInfo.LastName; profile.Email = userInfo.Email; profile.DateofBrith = userInfo.DateofBrith; profile.JoinDate = userInfo.JoinDate; profile.ProPic = userInfo.ProPic; profile.City = userInfo.City; profile.State = userInfo.State; profile.Country = userInfo.Country; profile.UserType = userInfo.UserType; profile.Balance = userInfo.Balance; profile.ratePerHour = workerInfoData.RatePerHour; profile.PostAProject = projects; foreach (var v in ratings) { CommunicationSkill.Add(v.CommunicationSkill); OnBudget.Add(v.OnBudget); OnTime.Add(v.OnTime); Behaviour.Add(v.Behaviour); Completeness.Add(v.Completeness); } profile.CcommunicationSkill = _communictionSkill; profile.OonTime = _onTime; profile.OonBudget = _onBudget; profile.Bbehaviour = _behaviour; profile.Ccompleteness = _completeness; profile.tot = TotalRating; return(profile); }
public void Update(WorkerInfo info) { db.Open(); string query = " UPDATE [dbo].[Worker] SET " + " [ChineseName] = @ChineseName " + ", [EnglishName] = @EnglishName " + ", [Introducer] = @Introducer " + ", [Address] = @Address " + ", [HKID1] = @HKID1 " + ", [HKID2] = @HKID2 " + ", [HKID3] = @HKID3 " + ", [DOB] = @DOB " + ", [Gender] = @Gender " + ", [PhoneNo] = @PhoneNo " + ", [PayrollGroup] = @PayrollGroup " + ", [PayrollRemarks] = @PayrollRemarks " + ", [BankCode] = @BankCode " + ", [BankACNo] = @BankACNo " + ", [BankName] = @BankName " + ", [MPFOption] = @MPFOption " + ", [DateJoin] = @DateJoin " + ", [WorkArea] = @WorkArea " + ", [Remarks] = @Remarks " + ", [CreateUser] = @CreateUser " + ", [CreateDate] = @CreateDate " + ", [LastModifyUser] = @LastModifyUser " + ", [LastModifyDate] = @LastModifyDate " + " where WorkerID = @WorkerID "; db.Execute(query, info); db.Close(); }
public Result <WorkerInfo> Save(WorkerInfo userinfo) { var result = new Result <WorkerInfo>(); try { var objtosave = _context.workerInfos.FirstOrDefault(u => u.UserId == userinfo.UserId); if (objtosave == null) { objtosave = new WorkerInfo(); _context.workerInfos.Add(objtosave); } objtosave.EarnedMoney = userinfo.EarnedMoney; objtosave.UserId = userinfo.UserId; objtosave.RatePerHour = userinfo.RatePerHour; if (!IsValid(objtosave, result)) { return(result); } _context.SaveChanges(); } catch (Exception ex) { result.HasError = true; result.Message = ex.Message; } return(result); }
public void Start(int?noOfSubsets = null, int?testingSubsetIndex = null) { _excelService = new ExcelService(_trainingModel.TrainingData.FilePath, _trainingModel.TrainingData.Sheet, _trainingModel.TrainingData.IdColumn, _trainingModel.TrainingData.InputVariables, _trainingModel.TrainingData.OutputVariables); _worker = new BackgroundWorker(); _worker.DoWork += worker_DoWork; if (_progressChangedEventHandler != null) { _worker.ProgressChanged += _progressChangedEventHandler; } _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.RunWorkerCompleted += worker_RunWorkerCompleted; var workerInfo = new WorkerInfo { LearningRate = _trainingModel.LearningRate, Epochs = _trainingModel.NoOfEpochs, Error = _trainingModel.MinError, TrainingRows = GetTrainingRows(noOfSubsets, testingSubsetIndex), NoOfSubsets = noOfSubsets, TestingSubsetIndex = testingSubsetIndex }; _worker.RunWorkerAsync(workerInfo); }
private void Bw_DoWorkCont(object sender, DoWorkEventArgs e) { WorkerInfo wi = (WorkerInfo)e.Argument; vector3 v = wi.centertile; int xp = (int)v.x; int yp = (int)v.y; int zoom = (int)v.z; int NumSquare = wi.NumberOfTiles; int progress = 0; for (int x = -NumSquare; x < NumSquare + 1; x++) { for (int y = -NumSquare; y < NumSquare + 1; y++) { progress++; _contworker.ReportProgress(progress); ContinuityMap c = new ContinuityMap("rgb", 512); c.Combine(x + xp, y + yp, zoom, ".jpg"); c = new ContinuityMap("height", 256); c.Combine(x + xp, y + yp, zoom, ".png"); } } }
public IPlan RecaulculatePlan(WorkerInfo workerInfo) { BasicPlan plan = new BasicPlan(); int currentWorker = workerInfo.GetMinWorker(); ITask result = null; int min = Int32.MaxValue; foreach (var task in _taskList) { int singlefitnessval = FitnessFunction(workerInfo, currentWorker, task); if (singlefitnessval < min) { min = singlefitnessval; result = task; } } if (result != null) { Console.WriteLine("Winner: " + result.ToString() + " MIN: " + min); plan.Plan.Add(result, currentWorker); _taskList.Remove(result); } return(plan); }
TWorkItem IWorkQueue <TWorkItem, TWorkResult> .GetNext(WorkerInfo executor) { _logger.Log(LogLevel.Debug, "AddinWorkQueue - GetNext called"); TWorkItem nextWorkItem = default(TWorkItem); if (_queuedWork.TryTake(out nextWorkItem) == false) { if (_queuedWork.IsAddingCompleted && PropertyChanged != null) { lock (this) { if (!_isCompleteRaised) { _logger.Log(LogLevel.Info, "AddinWorkQueue - IsComplete set"); PropertyChanged(this, new PropertyChangedEventArgs("IsComplete")); _isCompleteRaised = true; } } } } else { _pendingWork.AddOrUpdate(nextWorkItem.Id, nextWorkItem, (key, oldValue) => nextWorkItem); } return(nextWorkItem); }
public ActionResult EditProfileWorker(Worker workerVM) { UserInfo u = new UserInfo(); u.UserId = CurrentUser.User.UserId; if (workerVM.ConfirmPassword == null) { u.Password = CurrentUser.User.Password; } else { u.Password = workerVM.ConfirmPassword; } u.FristName = workerVM.FristName; u.LastName = workerVM.LastName; // u.DateofBrith = ownerVM.DateofBrith; u.Country = workerVM.Country; u.City = workerVM.City; u.State = workerVM.State; var result = userDao.Save(u); WorkerInfo o = new WorkerInfo(); o.RatePerHour = workerVM.RatePerHour; o.EarnedMoney = workerVM.EarnedMoney; o.UserId = CurrentUser.User.UserId; var result2 = workerDao.Save(o); return(RedirectToAction("WorkerProfile")); }
private void Run(object t) { var token = (CancellationToken)t; while (token.IsCancellationRequested == false) { var request = _requests.Take(token); while (_workerQueue.Any(w => w.IsWorking == false) == false) { Thread.Sleep(100); } WorkerInfo worker = _workerQueue.First(w => w.IsWorking == false); worker.IsWorking = true; request.AssignedTo = worker; request.Message.Push(new NetMQFrame(worker.Address)); _backend.SendMessage(request.Message); lock (_sentRequests) _sentRequests.Add(request); } }
private void workerListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { WorkerInfo info = (WorkerInfo)this.workerListBox.SelectedItem; this.workerIpLabel.Content = info.getIp(); this.workerPortLabel.Content = info.getPort(); }
public void Start(int?noOfSubsets = null, int?testingSubsetIndex = null) { var inputVariables = GetNeuralNetworkInputVariables(_testingModel.NeuralNetworkPath); _excelService = new ExcelService(_testingModel.DataFilePath, _testingModel.Sheet, _testingModel.IdColumn, inputVariables, _testingModel.OutputVariables); _worker = new BackgroundWorker(); _worker.DoWork += worker_DoWork; if (_progressChangedEventHandler != null) { _worker.ProgressChanged += _progressChangedEventHandler; } _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.RunWorkerCompleted += worker_RunWorkerCompleted; var workerInfo = new WorkerInfo { NoOfSubsets = noOfSubsets, TestingSubsetIndex = testingSubsetIndex, TestingRows = GetTestingRows(noOfSubsets, testingSubsetIndex) }; _worker.RunWorkerAsync(workerInfo); }
public WorkerInfo EditWorkerInfo(ProfileWorker profile, WorkerInfo workerInfo) { workerInfo.RatePerHour = profile.ratePerHour; return(workerInfo); }
public void Insert(WorkerInfo info) { db.Open(); string query = "INSERT INTO [dbo].[Worker] ( [WorkerID] " + ",[ChineseName] " + ",[EnglishName] " + ",[Introducer] " + ",[Address] " + ",[HKID1] " + ",[HKID2] " + ",[HKID3] " + ",[DOB] " + ",[Gender] " + ",[PhoneNo] " + ",[PayrollGroup] " + ",[PayrollRemarks] " + ",[BankCode] " + ",[BankACNo] " + ",[BankName] " + ",[MPFOption] " + ",[DateJoin] " + ",[WorkArea] " + ",[Remarks] " + ",[CreateUser] " + ",[CreateDate] " + ",[LastModifyUser] " + ",[LastModifyDate] " + ") " + "VALUES ( @WorkerID " + ",@ChineseName " + ",@EnglishName " + ",@Introducer " + ",@Address " + ",@HKID1 " + ",@HKID2 " + ",@HKID3 " + ",@DOB " + ",@Gender " + ",@PhoneNo " + ",@PayrollGroup " + ",@PayrollRemarks " + ",@BankCode " + ",@BankACNo " + ",@BankName " + ",@MPFOption " + ",@DateJoin " + ",@WorkArea " + ",@Remarks " + ",@CreateUser " + ",@CreateDate " + ",@LastModifyUser " + ",@LastModifyDate " + ") "; db.Execute(query, info); db.Close(); }
private void SetWorkerForErase(string socketid) { WorkerInfo w = GetWorker(socketid); w.bbpaddress = ""; w.receivedtime = 1; SetWorker(w, socketid); }
private Thread StartWorker(WorkerInfo workerInfo) { ParameterizedThreadStart threadDelegate = new ParameterizedThreadStart(Worker); Thread thread = new Thread(threadDelegate); thread.Start((object)workerInfo); return(thread); }
public LunarRover() { _workerInfo = new WorkerInfo() { Id = Guid.NewGuid().ToString(), Name = Environment.MachineName }; }
protected void InvokeAssignableLocations(WorkerInfo info) { var locations = GetLocations(info.Worker); foreach (var location in locations) { location.EnableAssignment(); } }
public bool IsExisted(WorkerInfo info) { db.Open(); String query = "select count(*) from Worker " + " where WorkerID = @WorkerID "; var obj = (List <int>)db.Query <int>(query, info); db.Close(); return(obj[0] > 0); }
public void Save(WorkerInfo info) { if (this.IsExisted(info)) { this.Update(info); } else { this.Insert(info); } }
protected void Deselect() { if (currentSelected == null) { return; } currentSelected.Deselect(); InvokeUnAssignableLocations(currentSelected); currentSelected = null; }
public async Task <IActionResult> StartNewWorker(string fenPositionString, byte color, ChessAI.OponentAlgorith oponent) { if (fenPositionString == null || !Fen.ISStringFen(fenPositionString) || (color != PieceData.White && color != PieceData.Black)) { return(BadRequest("Bad Parameters")); } if (ModelState.IsValid) { try { WorkerResult newWorkerResult = new WorkerResult(); newWorkerResult.Finished = false; int i = 0; while (WorkerResultExists(i)) { ++i; } newWorkerResult.WorkerID = i; _context.Add(newWorkerResult); //Start new Thread WorkerInfo newWorkerInfo = new WorkerInfo(Fen.LoadPositionFromFen(fenPositionString), color, newWorkerResult.WorkerID); _context.SaveChanges(); bool WorkerQueued = false; if (oponent.Equals(ChessAI.OponentAlgorith.Rand)) { WorkerQueued = ThreadPool.QueueUserWorkItem(new ChessAIService(new DbContextFactory()).GetRandMoveWrapper, newWorkerInfo); } else if (oponent.Equals(ChessAI.OponentAlgorith.NegaMax)) { WorkerQueued = ThreadPool.QueueUserWorkItem(new ChessAIService(new DbContextFactory()).GetNegaMaxMoveWrapper, newWorkerInfo); } if (WorkerQueued) { return(Accepted(HttpContext.Request.PathBase + "/Worker/Result/", newWorkerInfo.WorkerID)); } else { _context.Remove(newWorkerInfo); _context.SaveChanges(); return(BadRequest("Couldn't queue Task")); } } catch (DbUpdateConcurrencyException) { throw; } } return(BadRequest("Invalid ModelState")); }
public static void PrintStatusLinesToConsole(WorkerInfo w) { try { Console.Write($"GPU {w.ID,-3}: {w.GPUName,-20} "); switch (w.GPUStatus) { case "STARTING": Console.ForegroundColor = ConsoleColor.Yellow; Console.Write($"{"STARTING",-10}"); break; case "ONLINE": Console.ForegroundColor = ConsoleColor.Green; Console.Write($"{"ONLINE",-10}"); break; case "OFFLINE": Console.ForegroundColor = ConsoleColor.Red; Console.Write($"{"OFFLINE",-10}"); break; case "DISABLED": Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write($"{"DISABLED",-10}"); break; case "ERROR": Console.ForegroundColor = ConsoleColor.Red; Console.Write($"{"ERROR",-10}"); break; case "NO MEMORY": Console.ForegroundColor = ConsoleColor.Red; Console.Write($"{"NO MEMORY",-12}"); break; } Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write($" Mining at {w.GraphsPerSecond,5:F2} gps"); Console.ResetColor(); Console.WriteLine($" Solutions: {w.TotalSols}"); Console.ForegroundColor = IsLinux ? ConsoleColor.Gray : ConsoleColor.DarkGray; Console.WriteLine($" Last Message: {w.LastLog.ToShortString()}"); Console.ResetColor(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"ERROR GPU {w.ID}, MSG: {ex.Message}"); Console.ResetColor(); } }
private Thread InitializeGenericWorker(DoWork workMethod, int SleepSeconds, bool sleepAtStart) { WorkerInfo workerInfo = new WorkerInfo(); workerInfo.CampfireInfo = CampfireInfo; workerInfo.SleepSeconds = SleepSeconds; workerInfo.SleepAtStart = sleepAtStart; workerInfo.WorkFunc = workMethod; workerInfo.CreateEventLogEntryIfNotConfigured = firstWorker; firstWorker = false; workerInfo.API = new CampfireAPI.API(SmokeSignalConfig.Instance.CampfireName, SmokeSignalConfig.Instance.CampfireToken); return StartWorker(workerInfo); }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 0: if (field.Type == TType.List) { { Success = new List <WorkerInfo>(); TList _list0 = iprot.ReadListBegin(); for (int _i1 = 0; _i1 < _list0.Count; ++_i1) { WorkerInfo _elem2; _elem2 = new WorkerInfo(); _elem2.Read(iprot); Success.Add(_elem2); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
private void _backEnd_ReceiveReady(object sender, NetMQSocketEventArgs e) { var message = e.Socket.ReceiveMessage(); var workerIdentity = message.Pop().Buffer; // After this Client address is again on top (if there is one) var content = Encoding.Unicode.GetString(message[0].Buffer); var worker = _workerQueue.SingleOrDefault(x => x.Address.SequenceEqual(workerIdentity)); switch (content) { case Paranoid.PPP_READY: if (worker != null) { Console.WriteLine("{0} - Worker {1} already in queue", DateTime.Now.ToLongTimeString(), worker.ShortId); break; } worker = new WorkerInfo(workerIdentity); _workerQueue.Add(worker); Console.WriteLine("{0} - Worker {1} is ready", DateTime.Now.ToLongTimeString(), worker.ShortId); break; case Paranoid.PPP_HEARTBEAT: if (worker != null) { worker.ResetExpiry(); //Console.WriteLine(DateTime.Now.ToLongTimeString() + " - Worker " + Encoding.Unicode.GetString(workerIdentity) + " refresh"); } else { // This might happen when worker is just taken from queue so work is assigned to it Console.WriteLine("{0} - E: worker {1} not in queue", DateTime.Now.ToLongTimeString(), worker.ShortId); } break; // Return reply to client if it's not a control message default: worker.IsWorking = false; _frontend.SendMessage(message); var id = Encoding.Unicode.GetString(message.Last().Buffer); lock (_sentRequests) _sentRequests.Remove(_sentRequests.Single(s => s.Id == id)); break; } ; }
private void TaskCreatorOnNewTasks(IEnumerable <ITask> taskList) { var info = new WorkerInfo(); foreach (var worker in _workers) { info.WorkersTimeToEnd.Add(worker.Key, worker.Value.GetTimeToEnd()); } info.NumberOfWorker = _workers.Count; var plan = _planner.PreparePlan(info, taskList); DoPlan(plan); }
private Thread InitializeGenericWorker(DoWork workMethod, int SleepSeconds, bool sleepAtStart) { WorkerInfo workerInfo = new WorkerInfo(); workerInfo.CampfireInfo = CampfireInfo; workerInfo.SleepSeconds = SleepSeconds; workerInfo.SleepAtStart = sleepAtStart; workerInfo.WorkFunc = workMethod; workerInfo.CreateEventLogEntryIfNotConfigured = firstWorker; firstWorker = false; workerInfo.API = new CampfireAPI.API(SmokeSignalConfig.Instance.CampfireName, SmokeSignalConfig.Instance.CampfireToken); return(StartWorker(workerInfo)); }
public int AddWorker(WorkerInfo info) { if (_connection.State == System.Data.ConnectionState.Closed) { _connection.Open(); } var command = new SQLiteCommand(_connection); command.CommandText = "INSERT INTO user_maps(user_id,enroll_number,project_id) VALUES(@worker_id, @enroll_number, @project_id);"; command.Parameters.Add(new SQLiteParameter("@worker_id", info.UserId)); command.Parameters.Add(new SQLiteParameter("@enroll_number", info.EnrollNumber)); command.Parameters.Add(new SQLiteParameter("@project_id", info.ProjectId)); return(command.ExecuteNonQuery(System.Data.CommandBehavior.KeyInfo)); }
private void WaitUntilConfigured(WorkerInfo workerInfo) { while (!SmokeSignalConfig.Instance.IsSmokeSignalConfiged()) { GenerateLogEntryIfAppropriate(workerInfo); System.Threading.Thread.Sleep(delayWhileNotConfigedSeconds * 1000); } if (workerInfo.CreateEventLogEntryIfNotConfigured) { EventLog theEventLog = new System.Diagnostics.EventLog(); theEventLog.Log = "Application"; theEventLog.Source = "SmokeSignal"; theEventLog.WriteEntry("Smoke Signal is configured and ready to do its thing"); } }
private int FitnessFunction(WorkerInfo workerInfo, int currentIndex, ITask toAdd) { var tempInfo = new WorkerInfo(workerInfo); tempInfo.WorkersTimeToEnd[currentIndex] += toAdd.EstimatedTime; int max = tempInfo.WorkersTimeToEnd.Max(x => x.Value); int sum = 0; foreach (var val in tempInfo.WorkersTimeToEnd.Values) { sum = sum + (max - val); } return(sum); }
public void Start() { _worker.DoWork += worker_DoWork; _worker.ProgressChanged += _progressChangedEventHandler; _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.RunWorkerCompleted += worker_RunWorkerCompleted; var workerInfo = new WorkerInfo { K = _k, TrainingModel = _trainingModel, TestingModel = _testingModel }; _worker.RunWorkerAsync(workerInfo); }
public int AddWorker(object state) { lock (_workerLock) { if (_disposed) throw new ObjectDisposedException("WorkerThreads"); WorkerInfo info = new WorkerInfo() { Thread = new Thread(worker) { IsBackground = true }, Stopping = false, StopEvent = new AutoResetEvent(false), State = state }; _workers.Add(info); info.Thread.Start(info); return _workers.Count - 1; } }
private void GenerateLogEntryIfAppropriate(WorkerInfo workerInfo) { if (!workerInfo.CreateEventLogEntryIfNotConfigured) return; bmCounter++; if (bmCounter >= iterationsBeforeMessaging[bmIndex]) { bmIndex = (bmIndex + 1) % iterationsBeforeMessaging.Length; string myConfigPath = Assembly.GetExecutingAssembly().Location; string myDir = Path.GetDirectoryName(myConfigPath); string setupPath = Path.Combine(myDir, "SmokeSignalSetup.exe"); Utils.TraceMessage(TraceLevel.Warning, string.Format( "Smoke Signal is not configured, please run the Smoke Signal Startup app - {0}", setupPath)); } }
private void WaitUntilConfigured(WorkerInfo workerInfo) { while (!SmokeSignalConfig.Instance.IsSmokeSignalConfiged()) { GenerateLogEntryIfAppropriate(workerInfo); System.Threading.Thread.Sleep(delayWhileNotConfigedSeconds * 1000); } if (workerInfo.CreateEventLogEntryIfNotConfigured) { EventLog theEventLog = new System.Diagnostics.EventLog(); theEventLog.Log = "Application"; theEventLog.Source = "SmokeSignal"; theEventLog.WriteEntry("Smoke Signal is configured and ready to do its thing"); } }
/// <summary> /// Gets the WorkerInfo associated with the Worker for this room. /// If none exists, a new one is created and returned. /// </summary> /// <param name="worker">Who to check for</param> /// <returns>The WorkerInfo for the passed Worker</returns> protected WorkerInfo GetWorkerInfo(Worker worker) { for (var i = 0; i < _allWorkers.Count; i++) if (_allWorkers[i].worker == worker) return _allWorkers[i]; // It's a new Worker in the room so generate an // 'information card' about it. var newInfo = new WorkerInfo(worker, -1); worker.GiveTask(null); worker.transform.parent = transform; _allWorkers.Add(newInfo); return newInfo; }
/// <summary> /// Give the Worker a new task in a room. /// This should only ever be called once we know for sure that /// there is an empty task slot for that room. /// </summary> /// <param name="workerInfo">WorkerInfo</param> protected void DistributeTask(WorkerInfo workerInfo) { var last = _emptyTasks.Count - 1; var taskInfo = _emptyTasks[last]; workerInfo.taskIndex = taskInfo.roomTaskIndex; workerInfo.worker.GiveTask(taskInfo.task); workerInfo.worker.SetStatus(Worker.WorkerStatus.Busy); // If the task can have more than one worker at a time (waypoint) // we don't need to remove it (say it's taken) if (_emptyTasks[last].task.singleUser) _emptyTasks.RemoveAt(last); }
private Thread StartWorker(WorkerInfo workerInfo) { ParameterizedThreadStart threadDelegate = new ParameterizedThreadStart(Worker); Thread thread = new Thread(threadDelegate); thread.Start((object)workerInfo); return thread; }