Esempio n. 1
0
 ///
 /// <summary>
 /// Check if Truck or Remooc's checking date still valid
 /// </summary>
 /// <param name="trkNo">Truck(or Remooc) No</param>
 /// <param name="voyId">Voyage Id</param>
 /// <returns></returns>
 ///
 private TruckStatus IsTruckValidForVoy(string trkNo, int voyId)
 {
     Logger.Info("SaveExcelDetail voyId=" + voyId);
     try
     {
         //Get a Truck by Truck No
         TRUCK truck = _oraTruckService.GetByTruckNo(trkNo);
         //Get a Voyage by Voyage Id
         VOYAGE voyage = _oraVoyageRepository.GetById(voyId);
         if (truck != null)
         {
             if (truck.GCN_DATE.HasValue)
             {
                 //Check if voyage has ATB time
                 if (voyage.ATB.HasValue)
                 {
                     //Check if Truck's checking date after Actual Time Board
                     if (truck.GCN_DATE >= voyage.ATB)
                     {
                         //There is a truck in database and still valid
                         return(TruckStatus.HaveInfoAndValid);
                     }
                 }
                 //or ETB time
                 else if (voyage.ETB.HasValue)
                 {
                     if (truck.GCN_DATE >= voyage.ETB)
                     {
                         //There is a truck in database and still valid
                         return(TruckStatus.HaveInfoAndValid);
                     }
                 }
             }
         }
         //There is no Truck in database or not valid and need to be checked again
         return(TruckStatus.NotYetCheck);
     }
     catch (Exception e)
     {
         Logger.Error("IsTruckValidForVoy Error: ", e);
         throw e;
     }
 }
Esempio n. 2
0
        public ActionResult ImportExcel(ImportExcelViewModel model)
        {
            Logger.Info("CheckingController ImportExcel(model)");
            try
            {
                if (ModelState.IsValid)
                {
                    //Get UserName
                    //string userName = User.Identity.Name;
                    string        userName  = User.Identity.Name;
                    List <VOYAGE> lstVoyage = _oraVoyageService.GetVoyATD();
                    if (lstVoyage.Count > 0)
                    {
                        //Get data for dropdownlist of voyages
                        ViewBag.VesselId   = new SelectList(lstVoyage, "Id", "Code");
                        ViewBag.VesselName = lstVoyage.Select(x => new List <object>()
                        {
                            x.ID, x.NAME
                        });
                    }
                    var voyage = _oraVoyageRepository.GetById(model.VesselId);
                    //Import Function of FileExcelService
                    //TestUserId will be re-code after Login function
                    int[] state = _fileExcelService.Import(voyage.CODE, userName, model.CustomerId, model.FileImport);
                    //result of import
                    switch (state[0])
                    {
                    case (int)ImportedFileState.ContentBlank:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorContentBlank);
                        break;

                    case (int)ImportedFileState.Done:
                        return(RedirectToAction("GetInfoRegis", new { excelId = state[1] }));

                    case (int)ImportedFileState.Existed:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorExisted);
                        break;

                    case (int)ImportedFileState.NotEnoughParams:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorNotEnoughParams);
                        break;

                    case (int)ImportedFileState.NotFinished:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorNotFinished);
                        break;

                    case (int)ImportedFileState.WrongExtension:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorWrongExtension);
                        break;

                    case (int)ImportedFileState.ContentSizeWrong:
                        ModelState.AddModelError("", Resource_FileExcelUpload.ErrorContentSizeWrong);
                        break;
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resource_FileExcelUpload.ErrorNotEnoughParams);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", Resource_FileExcelUpload.ErrorServer);
                Logger.Error("CheckingController ImportExcel(model) Error: ", e);
            }
            return(View(model));
        }
Esempio n. 3
0
 public VOYAGE GetById(int id)
 {
     _oraVoyageRepository = new OraVoyageRepository();
     return(_oraVoyageRepository.GetById(id));
 }