예제 #1
0
        private void dgvWorkOrderStates_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            WorkOrderState wos = new WorkOrderState();

            wos = _workOrderStateService.GetLast(Machine);
            if (wos.Id != 0)
            {
                if (wos.State.ToLower() == "start")
                {
                    int i = 0;
                    foreach (DataGridViewRow row in dgvWorkOrderStates.Rows)
                    {
                        if (i == 0)
                        {
                            row.DefaultCellStyle.BackColor = Color.FromArgb(102, 187, 106);
                        }
                        else
                        {
                            row.DefaultCellStyle.BackColor = Color.FromArgb(239, 83, 80);
                        }
                        i++;
                    }
                }
                else
                {
                    foreach (DataGridViewRow row in dgvWorkOrderStates.Rows)
                    {
                        row.DefaultCellStyle.BackColor = Color.FromArgb(239, 83, 80);
                    }
                }
            }
            else
            {
            }
        }
        public WorkOrderState GetLast(Machine machine)
        {
            string         connString     = string.Format("server={0};user=root;database={1};port=3306;password=root;Connection Timeout=1", machine.Ip, _raspiDb);
            WorkOrderState workOrderState = new WorkOrderState();

            try
            {
                using (_conn = new MySqlConnection(connString))
                {
                    string query = string.Format("select * from {0} order by Id desc limit 1", _raspiWorkOrderStateTableName);
                    using (MySqlCommand cmd = new MySqlCommand(query, _conn))
                    {
                        _conn.Open();
                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                workOrderState.Id          = reader.GetInt32(0);
                                workOrderState.WorkOrderNo = reader.GetString(1);
                                workOrderState.State       = reader.GetString(2);
                                workOrderState.Date        = reader.GetDateTime(3);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("workorderstate  getlast'de sıkıntı var\n" + e);
            }
            return(workOrderState);
        }
예제 #3
0
        private void btnBasla_click(object sender, EventArgs e)
        {
            Button btn   = sender as Button;
            int    index = Convert.ToInt32(btn.Name.ToString());

            if (!string.IsNullOrWhiteSpace(_tbWorkOrderNo[index].Text))
            {
                List <Machine> machines = new List <Machine>();
                machines = GetMachines();
                Machine machine = machines[index];

                Log      lastLog = _logService.GetLastLog(machine.Ip, _raspiDb, "Logs");
                TimeSpan time    = DateTime.Now.Subtract(lastLog.Date);
                Log      log     = new Log
                {
                    Name      = lastLog.Name,
                    LastState = lastLog.State,
                    LastDate  = lastLog.Date,
                    State     = lastLog.State,
                    Time      = time,
                    Shift     = lastLog.Shift
                };
                _logService.Add(log, machine);
                int            id             = lastLog.Id + 1;
                string         workOrderNo    = _tbWorkOrderNo[index].Text;
                WorkOrderState workOrderState = new WorkOrderState
                {
                    Id          = id,
                    WorkOrderNo = workOrderNo,
                    State       = "start"
                };
                _workOrderStateService.Add(workOrderState, machine);
                _tbWorkOrderNo[index].Text = "";
            }
        }
예제 #4
0
        private void btnBitir_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(tbWorkOrderNo.Text))
            {
                WorkOrderState wos = new WorkOrderState();
                wos = _workOrderStateService.GetLast(Machine);
                if (wos.State.ToLower() != "finish")
                {
                    if (wos.WorkOrderNo == tbWorkOrderNo.Text)
                    {
                        Machine machine = Machine;

                        Log      lastLog = _logService.GetLastLog(machine.Ip, _raspiDb, "Logs");
                        TimeSpan time    = DateTime.Now.Subtract(lastLog.Date);
                        Log      log     = new Log
                        {
                            Name      = lastLog.Name,
                            LastState = lastLog.State,
                            LastDate  = lastLog.Date,
                            State     = lastLog.State,
                            Time      = time,
                            Shift     = lastLog.Shift
                        };
                        _logService.Add(log, machine);
                        int            id             = lastLog.Id + 1;
                        string         workOrderNo    = tbWorkOrderNo.Text;
                        WorkOrderState workOrderState = new WorkOrderState
                        {
                            Id          = id,
                            WorkOrderNo = workOrderNo,
                            State       = "finish"
                        };
                        _workOrderStateService.Add(workOrderState, machine);
                        tbWorkOrderNo.Text = "";
                    }
                    else
                    {
                        MessageBox.Show(string.Format("{0} numaralı bir iş emri başlatılmamış", tbWorkOrderNo.Text));
                    }
                    FillWos();
                }
                else
                {
                    MessageBox.Show("Devam etmekte olan iş emri yok !");
                }
            }
            else
            {
                MessageBox.Show("Lütfen İş Emri No Giriniz !");
            }
            tbWorkOrderNo.Text = "";
            WorkOrders();
        }
예제 #5
0
        private void btnBaslat_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(tbWorkOrderNo.Text))
            {
                WorkOrderState wos = new WorkOrderState();
                wos = _workOrderStateService.GetLast(Machine);
                Console.WriteLine("wos.id = {0}", wos.Id);
                Console.WriteLine("wos.state = {0}", wos.State);
                if (wos.State.ToLower() == "start")
                {
                    MessageBox.Show(string.Format("{0} numaralı iş emri hala devam etmekte !", wos.WorkOrderNo));
                }
                else
                {
                    Machine machine = Machine;

                    Log      lastLog = _logService.GetLastLog(machine.Ip, _raspiDb, "Logs");
                    TimeSpan time    = DateTime.Now.Subtract(lastLog.Date);
                    Log      log     = new Log
                    {
                        Name      = lastLog.Name,
                        LastState = lastLog.State,
                        LastDate  = lastLog.Date,
                        State     = lastLog.State,
                        Time      = time,
                        Shift     = lastLog.Shift
                    };
                    _logService.Add(log, machine);
                    int            id             = lastLog.Id + 1;
                    string         workOrderNo    = tbWorkOrderNo.Text;
                    WorkOrderState workOrderState = new WorkOrderState
                    {
                        Id          = id,
                        WorkOrderNo = workOrderNo,
                        State       = "start"
                    };
                    _workOrderStateService.Add(workOrderState, machine);
                    tbWorkOrderNo.Text = "";
                    MessageBox.Show("iş emri başlatıldı");
                }

                FillWos();
            }
            else
            {
                MessageBox.Show("Lütfen İş Emri No Giriniz !");
            }
            tbWorkOrderNo.Text = "";
            WorkOrders();
        }
예제 #6
0
        public void WorkOrders()
        {
            WorkOrderState wos = new WorkOrderState();

            wos = _workOrderStateService.GetLast(Machine);
            if (wos.Id == 0)
            {
                lblWorkOrder.Text = "Bu Makinede Hiç Bir İş Emri Bulunamadı";
            }
            else
            {
                bool isWorkOrderFinish = _workOrderStateService.IsWorkOrderFinish(Machine, wos.WorkOrderNo);
                if (isWorkOrderFinish)
                {
                    List <WorkOrderState> workOrderStates = new List <WorkOrderState>();
                    workOrderStates = _workOrderStateService.GetByWorkOrderNo(Machine, wos.WorkOrderNo);
                    DateTime start    = workOrderStates[1].Date;
                    DateTime finish   = workOrderStates[0].Date;
                    TimeSpan duration = finish - start;
                    string   wo       = string.Format("{0} numaralı iş emri {1} zamanında bitti ", wos.WorkOrderNo, duration);
                    lblWorkOrder.Text = wo;
                    int startId  = workOrderStates[0].Id;
                    int finishId = workOrderStates[1].Id;
                    //dgvWorkOrdersDetails.DataSource = _logService.GetById(Machine.Ip, "Machine", "Logs", startId, finishId);
                }
                else
                {
                    List <WorkOrderState> workOrderStates = new List <WorkOrderState>();
                    workOrderStates = _workOrderStateService.GetByWorkOrderNo(Machine, wos.WorkOrderNo);
                    int      startId = workOrderStates[0].Id;
                    DateTime start   = workOrderStates[0].Date;
                    string   wo      = string.Format("{0} tarihinde başlayan {1}  numaralı iş emri hala devam ediyor", start, wos.WorkOrderNo);
                    lblWorkOrder.Text = wo;
                    //dgvWorkOrdersDetails.DataSource = _logService.GetById(Machine.Ip, "Machine", "Logs", startId, 0);
                }
            }
        }
        public List <WorkOrderState> GetAllByMachine(Machine machine)
        {
            string connString = string.Format("server={0};user=root;database={1};port=3306;password=root;Connection Timeout=1", machine.Ip, _raspiDb);
            List <WorkOrderState> workOrderStates = new List <WorkOrderState>();

            try
            {
                using (_conn = new MySqlConnection(connString))
                {
                    string query = string.Format("select * from {0} order by Id desc", _raspiWorkOrderStateTableName);
                    using (MySqlCommand cmd = new MySqlCommand(query, _conn))
                    {
                        _conn.Open();
                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                WorkOrderState workOrderState = new WorkOrderState
                                {
                                    Id          = reader.GetInt32(0),
                                    WorkOrderNo = reader.GetString(1),
                                    State       = reader.GetString(2),
                                    Date        = reader.GetDateTime(3)
                                };
                                workOrderStates.Add(workOrderState);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("workorderstate  getAllByMachine'de sıkıntı var\n" + e);
            }
            return(workOrderStates);
        }
        public void Add(WorkOrderState workOrderState, Machine machine)
        {
            string connString = string.Format("server={0};user=root;database={1};port=3306;password=root;Connection Timeout=1;Allow User Variables=True", machine.Ip, _raspiDb);

            try
            {
                using (MySqlConnection _conn = new MySqlConnection(connString))
                {
                    string query = string.Format("insert into {0} (Id,WorkOrderNo,State) values (@Id,@WorkOrderNo,@State) ", _raspiWorkOrderStateTableName);
                    using (MySqlCommand cmd = new MySqlCommand(query, _conn))
                    {
                        _conn.Open();
                        cmd.Parameters.AddWithValue("@Id", workOrderState.Id);
                        cmd.Parameters.AddWithValue("@WorkOrderNo", workOrderState.WorkOrderNo);
                        cmd.Parameters.AddWithValue("@State", workOrderState.State);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("add workorderstate'de sıkıntı var" + e);
            }
        }
예제 #9
0
 public void Add(WorkOrderState workOrderState, Machine machine)
 {
     _workOrderStateDal.Add(workOrderState, machine);
 }