public bool delete(string carrierID) //todo kevin 要再將他搬至History
 {
     bool isSuccess = true;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             ACARRIER carrier = CarrierDao.getByID(con, carrierID);
             if (carrier != null)
             {
                 CarrierDao.delete(con, carrier);
             }
             else
             {
                 //todo kevin Exception log
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         isSuccess = false;
     }
     return isSuccess;
 }
            public void addOrUpdate(ACARRIER carrier)
            {
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    var vcarrierTemp = CarrierDao.getByID(con, carrier.ID);
                    if (vcarrierTemp == null)
                    {
                        CarrierDao.add(con, carrier);
                    }
                    else
                    {
                        //vcarrierTemp.INSER_TIME = carrier.INSER_TIME;
                        vcarrierTemp.LOCATION = carrier.LOCATION;
                        vcarrierTemp.INSTALLED_TIME = carrier.INSTALLED_TIME;
                        vcarrierTemp.RENAME_ID = carrier.RENAME_ID;
                        vcarrierTemp.STATE = carrier.STATE;
                        vcarrierTemp.LOT_ID = carrier.LOT_ID;
                        vcarrierTemp.TYPE = carrier.TYPE;
                        vcarrierTemp.READ_STATUS = carrier.READ_STATUS;
                        vcarrierTemp.FINISH_TIME = carrier.FINISH_TIME;
                        vcarrierTemp.HOSTSOURCE = carrier.HOSTSOURCE;
                        vcarrierTemp.HOSTDESTINATION = carrier.HOSTDESTINATION;

                        CarrierDao.update(con, vcarrierTemp);
                    }
                }
            }
 public bool updateReadStatus(string carrierID, ProtocolFormat.OHTMessage.E_ID_READ_STSTUS readResult,string renameCstID)
 {
     bool isSuccess = true;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             ACARRIER carrier = CarrierDao.getByID(con, carrierID);
             if (carrier != null)
             {
                 carrier.RENAME_ID = renameCstID;
                 carrier.READ_STATUS = readResult;
                 CarrierDao.update(con, carrier);
             }
             else
             {
                 isSuccess = false;
                 //todo kevin Exception log
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         isSuccess = false;
     }
     return isSuccess;
 }
 public bool updateRenameID(string carrierID, string renameID)
 {
     bool isSuccess = true;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             ACARRIER carrier = CarrierDao.getByID(con, carrierID);
             if (carrier != null)
             {
                 carrier.RENAME_ID = renameID;
                 CarrierDao.update(con, carrier);
             }
             else
             {
                 isSuccess = false;
                 //todo kevin Exception log
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         isSuccess = false;
     }
     return isSuccess;
 }
 public ACARRIER getCarrier(string carrierID)
 {
     ACARRIER carrier = null;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             carrier = CarrierDao.getByID(con, carrierID);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
     return carrier;
 }
 public (bool has, ACARRIER inLineCarrier) hasCarrierInLine(string carrierID)
 {
     ACARRIER carrier = null;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             carrier = CarrierDao.getInLineCarrierByCarrierID(con, carrierID);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
     return (carrier != null, carrier);
 }
 public bool updateLocationAndState(string carrierID, string location, ProtocolFormat.OHTMessage.E_CARRIER_STATE state)
 {
     bool isSuccess = true;
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             ACARRIER carrier = CarrierDao.getByID(con, carrierID);
             if (carrier != null)
             {
                 carrier.LOCATION = location;
                 carrier.STATE = state;
                 switch (state)
                 {
                     case ProtocolFormat.OHTMessage.E_CARRIER_STATE.Installed:
                         carrier.INSTALLED_TIME = DateTime.Now;
                         break;
                     case ProtocolFormat.OHTMessage.E_CARRIER_STATE.Complete:
                     case ProtocolFormat.OHTMessage.E_CARRIER_STATE.OpRemove:
                         carrier.FINISH_TIME = DateTime.Now;
                         break;
                 }
                 CarrierDao.update(con, carrier);
             }
             else
             {
                 isSuccess = false;
                 //todo kevin Exception log
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         isSuccess = false;
     }
     return isSuccess;
 }
        private async void btn_force_finish_Click(object sender, EventArgs e)
        {
            try
            {
                if (selection_index == -1)
                {
                    return;
                }
                btn_force_finish.Enabled = false;
                var       mcs_cmd = cmdMCSshowList[selection_index];
                ACMD      cmd;
                ATRANSFER transfer;
                (cmd, transfer) = await Task.Run(() => GetRealCommandInfo(mcs_cmd));

                if (transfer == null)
                {
                    MessageBox.Show($"Transfer cmd ID:{SCUtility.Trim(mcs_cmd.CMD_ID, true)} not exist.", "Check command fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                CarrierLocationChooseForm         carrierLocationChooseForm = new CarrierLocationChooseForm(mainform.BCApp.SCApplication, transfer);
                System.Windows.Forms.DialogResult result = carrierLocationChooseForm.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }
                string         finial_carrier_location = carrierLocationChooseForm.GetChooseLocation();
                CompleteStatus finish_complete_status  = carrierLocationChooseForm.GetCompleteStatus();

                await Task.Run(() =>
                {
                    try
                    {
                        //mainform.BCApp.SCApplication.VehicleService.Command.Finish(cmd.ID, CompleteStatus.ForceFinishByOp);
                        //todo 需要在review一下 kevin
                        ACARRIER carrier = mainform.BCApp.SCApplication.CarrierBLL.db.getCarrier(mcs_cmd.CARRIER_ID);

                        bool is_in_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.
                                        IsVehicleLocationExistByLocationRealID(finial_carrier_location);
                        E_CARRIER_STATE finial_carrier_state =
                            is_in_vh ? E_CARRIER_STATE.Installed : E_CARRIER_STATE.Complete;
                        if (carrier != null)
                        {
                            //如果原本是在車上,但後來變成不在車上要上報Remove
                            //如果原本不在車在,後來變成在車上要在報Install
                            bool source_is_in_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.
                                                   IsVehicleLocationExistByLocationRealID(carrier.LOCATION);
                            if (is_in_vh && !source_is_in_vh)
                            {
                                AVEHICLE intall_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.getVehicleByLocationRealID(finial_carrier_location);
                                if (intall_vh != null)
                                {
                                    mainform.BCApp.SCApplication.ReportBLL.newReportCarrierInstalled
                                        (intall_vh.Real_ID, mcs_cmd.CARRIER_ID, finial_carrier_location, null);
                                }
                            }
                            else if (!is_in_vh && source_is_in_vh)
                            {
                                AVEHICLE remove_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.getVehicleByLocationRealID(carrier.LOCATION);
                                if (remove_vh != null)
                                {
                                    mainform.BCApp.SCApplication.ReportBLL.newReportCarrierRemoved
                                        (remove_vh.Real_ID, mcs_cmd.CARRIER_ID, finial_carrier_location, null);
                                }
                            }
                            mainform.BCApp.SCApplication.CarrierBLL.db.updateLocationAndState
                                (transfer.CARRIER_ID, finial_carrier_location, finial_carrier_state);
                        }

                        if (cmd != null)
                        {
                            mainform.BCApp.SCApplication.VehicleService.Command.Finish(cmd.ID, finish_complete_status);
                        }
                        else
                        {
                            mainform.BCApp.SCApplication.TransferService.FinishTransferCommand(transfer.ID, finish_complete_status);
                        }
                    }
                    catch { }
                }
                               );

                updateTransferCommand();
            }
            catch (Exception ex) { }
            finally
            {
                btn_force_finish.Enabled = true;
            }
        }
예제 #9
0
 public void delete(DBConnection_EF con, ACARRIER carrier)
 {
     con.ACARRIER.Remove(carrier);
     con.SaveChanges();
 }
예제 #10
0
 public void update(DBConnection_EF con, ACARRIER carrier)
 {
     con.SaveChanges();
 }
예제 #11
0
 public void add(DBConnection_EF con, ACARRIER carrier)
 {
     con.ACARRIER.Add(carrier);
     con.SaveChanges();
 }