示例#1
0
 public bool SetWorker(Employee worker)
 {
     int index = stations.FindIndex(x => x.Worker == null);
     if(index != -1)
     {
         return stations[index].CheckWorkerShift(worker);
     }
     else
     {
         return false;
     }
 }
示例#2
0
 public Machine(Employee employee)
 {
     Worker = employee;
 }
示例#3
0
        public static List<Employee> GetEmployees()
        {
            try
            {
                Database db = new Database("SELECT * FROM [employees] ORDER BY [firstname] ASC");
                List<Dictionary<string, object>> datalist = db.Fetch();

                if(datalist != null)
                {
                    List<Employee> workers = new List<Employee> { };
                    foreach (Dictionary<string, object> item in datalist)
                    {
                        // Initiate Employee informations
                        int id = (int)item["id"];
                        string firstname = (string)item["firstname"];
                        string lastname = (string)item["lastname"];
                        string user = (string)item["username"];

                        Employee worker = new Employee(id, firstname, lastname, user);

                        // Load task for each Employee
                        Dictionary<string, object> param = new Dictionary<string, object> { };
                        param.Add("id", id);
                        List<Dictionary<string, object>> block = new Database("getTask", param).FetchProcedure();

                        // Checking if Employee have any task
                        if (block != null)
                        {
                            foreach (Dictionary<string, object> jobdata in block)
                            {
                                int mid = (int)jobdata["machineId"];
                                int eid = (int)jobdata["employeeId"];
                                DateTime aDate = (DateTime)jobdata["activeDate"];
                                DateTime dDate = (DateTime)jobdata["deadline"];
                                bool jid = (bool)jobdata["completed"];

                                worker.Joblist.Add(new Job(mid, eid, aDate, dDate, jid));
                            }
                        }

                        // Add Employee to list
                        workers.Add(worker);
                    }

                    return workers;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception exc)
            {
                Log.Record(exc);
                return null;
            }
        }
示例#4
0
 public bool CheckWorkerShift(Employee worker)
 {
     if(worker.Joblist != null)
     {
         int index = worker.Joblist.FindIndex(x => CheckTime(x.TaskDate));
         if (index != -1)
         {
             Worker = worker;
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         return false;
     }
 }