예제 #1
0
        public int StartWork(
            uint noOfWorkers,
            string srcDir,
            string dstDir,
            Action <string> updateStatus = null)
        {
            InitialiseWork(srcDir, dstDir);

            Workers.Clear();

            for (int i = 0; i < 2; i++)
            {
                CancellationTokenSource ctk = new CancellationTokenSource();
                Tuple <Task, CancellationTokenSource> tp = Tuple.Create(
                    Task.Run(() => Work(
                                 ctk,
                                 updateStatus),
                             ctk.Token),
                    ctk);

                Workers.Add(tp);
            }

            Task.WaitAll(Workers.Select(x => x.Item1).ToArray());

            return(FilesProcessed.Count);
        }
예제 #2
0
        private void GetAllWorkers()
        {
            conn = new MySqlConnection("Server=localhost;Database=szakdoga_db;Uid=root;Pwd=;SslMode=none");
            string q_select = "SELECT * FROM workers";

            Workers.Clear();
            try
            {
                conn.Open();
                MySqlCommand    cmd        = new MySqlCommand(q_select, conn);
                MySqlDataReader dataReader = cmd.ExecuteReader();

                while (dataReader.Read())
                {
                    Workers.Add(new Model.Workers
                    {
                        Worker_ID         = Convert.ToInt32(dataReader["Worker_ID"]),
                        Username          = (dataReader["Username"]).ToString(),
                        Password          = (dataReader["Password"]).ToString(),
                        Registration_Date = DateTime.Parse(dataReader["Registration_Date"].ToString()),
                        Salary            = Convert.ToInt32(dataReader["Salary"]),
                        Title             = (dataReader["Title"]).ToString(),
                        Realname          = (dataReader["Realname"]).ToString()
                    });
                }
                dataReader.Close();
                this.DisplayPage = new Menu_users();
                conn.Close();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// Undo any pending changes and revert back fields to the old ones.
        /// </summary>
        public void UndoPendingChanges()
        {
            foreach (Worker worker in Workers)
            {
                worker.Calls.Remove(this);
            }

            //THIS NEEDS WORK!
            if (_id == 0)
            {
                //its new so lets delete it!

                ServiceUser.Calls.Remove(this);

                CallManager.Instance.Calls.Remove(this);
            }
            else
            {
                idServiceUser    = (int)this.Old["idServiceUser"];
                duration_mins    = (int)this.Old["duration_mins"];
                required_workers = (int)this.Old["required_workers"];
                time             = (DateTime)this.Old["time"];
                flag             = (FlagCode)this.Old["flagcode"];
                notes            = (string)this.Old["notes"];
                traveltime_mins  = (int)this.Old["traveltime_mins"];

                Workers.Clear();
                Workers.AddRange(OldWorkers);
            }

            _markedForDeletion = false;

            _MarkForSave = false;
        }
예제 #4
0
        private void SetWorkers(int divisionId)
        {
            if (Workers != null)
            {
                Workers.Clear();
            }

            using (DataSet ds = WorkerSQL.GetWorkers(divisionId))
            {
                try
                {
                    Workers = ds.Tables[0].AsEnumerable().Select(dataRow => new Worker
                    {
                        Id         = dataRow.Field <int>("ID"),
                        DivisionId = dataRow.Field <int>("DepartamentID"),
                        PersNum    = dataRow.Field <string>("PersNum"),
                        FullName   = dataRow.Field <string>("FullName"),
                        Birthday   = dataRow.Field <DateTime>("Birthday"),
                        HiringDay  = dataRow.Field <DateTime>("HiringDay"),
                        Salary     = Decimal.Round(dataRow.Field <decimal>("Salary"), 2),
                        ProfArea   = dataRow.Field <string>("ProfArea"),
                        Gender     = dataRow.Field <string>("Gender")
                    }).ToList();
                }
                catch (Exception ex) { Console.WriteLine(ex); }
            }
        }
예제 #5
0
        public void Unload()
        {
            SelectedWorkers.Clear();
            Workers.Clear();

            isLoaded = false;
        }
예제 #6
0
파일: ChartModel.cs 프로젝트: bregell/coap
 /**
  *
  **/
 public void ClearSeries()
 {
     Model.Series.Clear();
     Series.Clear();
     RaisePropertyChanged("LineSeries");
     RefreshPlot();
     Workers.Clear();
 }
예제 #7
0
 private void View_Waiters()
 {
     if (_is_manager == true)
     {
         Workers.Clear();
         GetAllWorkers();
         this.DisplayPage = new Menu_users();
     }
     else
     {
         Display_Message = "Manager only!";
     }
 }
예제 #8
0
 private void View_LoginWindow()
 {
     if (_is_manager == false && _is_waiter == false)
     {
         Workers.Clear();
         GetAllWorkers();
         this.DisplayPage = new Login();
     }
     else
     {
         Display_Message = "You have to log out first!";
     }
 }
예제 #9
0
 public ActionResult DeleteAll()
 {
     if (User.Identity.Name != "admin")
     {
         TempData["NoAdmin"] = string.Format("У вас немає прав адміністратора");
         return(RedirectToAction("Index"));
     }
     else
     {
         Workers.Clear();
         workerSelectionModels = workers.Select(e => (WorkerSelectionModel)e).OrderBy(e => e.Name);
         StaticDataContext.Save();
         TempData["Message"] = string.Format("Успішно видалено всіх працівників");
         return(PartialView("_TableBody", workerSelectionModels));
     }
 }
예제 #10
0
        private void RecacheWorkers()
        {
            Workers.Clear();
            var shares = _storage.GetSharesForCurrentRound();

            foreach (var miner in _minerManager.Miners)
            {
                if (!miner.Authenticated)
                {
                    continue;
                }

                Workers.Add(miner.Username, shares.ContainsKey(miner.Username) ? shares[miner.Username] : 0);
            }

            WorkersJson = JsonConvert.SerializeObject(Workers);
        }
예제 #11
0
        /// <summary>
        /// Cancel the shift without completing all work
        /// </summary>
        public void Cancel()
        {
            this.IsActive = false;

            foreach (var w in Workers)
            {
                w.Cancel();
            }

            foreach (var q in Queues)
            {
                q.Stop();
            }

            Workers.Clear();
            Queues.Clear();
        }
예제 #12
0
        private void Update()
        {
            if (!Workers.Any())
            {
                return;
            }

            foreach (var worker in Workers)
            {
                float scale = 1f + worker.WorkerSkill / 4f;
                craftTime += Time.deltaTime * scale;
            }
            if (craftTime < timeToCraft)
            {
                return;
            }

            foreach (var worker in Workers)
            {
                worker.JobComplete();
            }
            Workers.Clear();
            GameManager.Units.CreateUnit <Drone>(spawnPoint.position);
        }
예제 #13
0
        /// <summary>
        /// Save the Call
        /// </summary>
        public override void Save()
        {
            if (!MarkForSave && !_markedForDeletion)
            {
                return;
            }

            string query = "";

            if (_markedForDeletion)
            {
                //now properly delete it
                ServiceUser.Calls.Remove(this);

                foreach (Worker worker in Workers)
                {
                    worker.Calls.Remove(this);
                }

                Workers.Clear();

                CallManager.Instance.Calls.Remove(this);

                //first delete all current coverage
                query = "DELETE FROM tbl_Worker_Calls WHERE idCall = " + _id.ToString();
                Common.Database.ExecuteDatabaseStatement(query);

                //now delete the call
                query = "DELETE FROM tbl_Calls WHERE id = " + _id.ToString();
                Common.Database.ExecuteDatabaseStatement(query);


                //insert change
                ChangeTracker.InsertChange(System.Environment.UserName, DateTime.Now, "tbl_Calls", _id, this, ChangeTracker.ChangeType.Delete);

                return;
            }

            //save it here!
            bool isInsert = _id == 0;

            try
            {
                //do the save here to the database.
                if (isInsert)
                {
                    query  = "INSERT INTO tbl_Calls(idServiceUser, timeofCall, duration, required_workers, flagcode, notes, traveltime)";
                    query += " VALUES (@0, @1, @2, @3, @4, @5, @6)";

                    object[] prms = new object [] { ServiceUser.id,
                                                    time,
                                                    duration_mins,
                                                    required_workers,
                                                    ((int)flag),
                                                    notes,
                                                    traveltime_mins };

                    DataTable dt = Common.Database.ExecuteDatabaseQuery(query, prms, true);

                    if (dt.Rows.Count == 0)
                    {
                        throw new Exception("Failed To Insert Call");
                    }

                    _id = Convert.ToInt32(dt.Rows[0][0]);

                    //insert change
                    ChangeTracker.InsertChange(System.Environment.UserName, DateTime.Now, "tbl_Calls", _id, this, ChangeTracker.ChangeType.Insert);

                    ConstructOld();
                }
                else
                {
                    query = "UPDATE tbl_Calls SET";

                    query += " timeofCall= @0";
                    query += ",duration= @1";
                    query += ",required_workers = @2";
                    query += ",flagcode = @3";
                    query += ",notes = @4";
                    query += ",traveltime= @5";
                    query += " WHERE id = @6";

                    object[] prms = new object[] { time,
                                                   duration_mins,
                                                   required_workers,
                                                   ((int)flag),
                                                   notes,
                                                   traveltime_mins,
                                                   _id };

                    Common.Database.ExecuteDatabaseStatement(query, prms);

                    ChangeTracker.InsertChange(System.Environment.UserName, DateTime.Now, "tbl_Calls", _id, this, ChangeTracker.ChangeType.Update);

                    //update the olds!
                    this.Old["id"]               = _id;
                    this.Old["idServiceUser"]    = idServiceUser;
                    this.Old["duration_mins"]    = duration_mins;
                    this.Old["required_workers"] = required_workers;
                    this.Old["time"]             = time;
                    this.Old["flagcode"]         = flag;
                    this.Old["notes"]            = notes;
                    this.Old["traveltime_mins"]  = traveltime_mins;

                    this.OldWorkers.Clear();
                    this.OldWorkers.AddRange(Workers);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Call Save Failed", ex);
            }


            //Now do the worker cover saves
            try
            {
                //do the save here to the database.

                query  = "DELETE FROM tbl_Worker_Calls";
                query += " WHERE idCall = " + _id.ToString();

                Common.Database.ExecuteDatabaseStatement(query);

                foreach (Worker worker in Workers)
                {
                    query  = "INSERT INTO tbl_Worker_Calls(idCall, idWorker)";
                    query += " VALUES (@0, @1)";

                    Common.Database.ExecuteDatabaseStatement(query, new object[] { _id, worker.id });
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to Save All The Worker Calls", ex);
            }

            MarkForSave = false;
        }
예제 #14
0
 public void Clear()
 {
     Workers.Clear();
     Posts.Clear();
 }