Beispiel #1
0
        private static bool PrintEir(ContCard card)
        {
            System.Console.Write("Step 2. Checking INOUTREV at " + DateTime.Now.ToString("hh:mm:ss") + "...");
            InOutRevenue    revenue    = new InOutRevenue();
            InOutRevenueDAL revenueDal = new InOutRevenueDAL();

            revenue = revenueDal.FillInOutRevenueByInOutRevenueId(card.RefID);
            System.Console.WriteLine("OK");
            System.Console.Write("Step 3. Checking CUSTDO at " + DateTime.Now.ToString("hh:mm:ss") + "...");
            CustDo    custDo    = new CustDo();
            CustDoDAL custDoDAL = new CustDoDAL();

            custDo = custDoDAL.FillCustDoByCustDoId(revenue.RefId);

            System.Console.WriteLine("OK");
            System.Console.Write("Step 4. Checking CONTINOUT at " + DateTime.Now.ToString("hh:mm:ss") + "...");
            ContInOut    cont         = new ContInOut();
            ContInOutDAL contInOutDAL = new ContInOutDAL();

            cont = contInOutDAL.FillContInOutById(card.ContInOutID);
            if (cont.ContInOutId == 0)
            {
                System.Console.WriteLine("Error: Container is Invalid.");
                return(false);
            }
            if (cont.DtmOut.Length > 0)
            {
                System.Console.WriteLine("Error: Container is Gated Out: " + cont.Cont + " " + cont.DtmOut);
                return(false);
            }
            System.Console.WriteLine("OK");
            cont.VesselVoyage     = custDo.VesselVoyage;
            cont.VesselVoyageName = custDo.VesselVoyageName;
            cont.Destination      = custDo.Destination;
            cont.DestinationName  = custDo.DestinationName;
            cont.DoNumber         = custDo.DoNumber;
            cont.NoSeriOrOut      = revenue.NoSeri;
            cont.ActOut           = custDo.ActOut;
            cont.Shipper          = (custDo.ExBatalRealShipper.Length == 0) ? custDo.Shipper : custDo.ExBatalRealShipper;
            if (custDo.ExBatalRealShipper.Length > 0)
            {
                cont.Remarks = "EBO";
            }
            cont.DtmOutDepoIn = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss");
            cont.NoMobilOut   = card.NoMobilOut;
            if (cont.AngkutanOut.Length == 0)
            {
                cont.AngkutanOut = card.AngkutanOut;
            }
            cont.Seal = card.Seal1;
            if (cont.DtmOut.Length == 0)
            {
                cont.DtmOut = GlobalWebServiceDAL.GetServerDtm().AddMinutes(1.0).ToString("yyyy-MM-dd HH:mm:ss");
            }
            if (cont.DtmOut.Length == 0)
            {
                System.Console.WriteLine("Error: DtmOut Empty");
                return(false);
            }
            TruckInDepo    depo    = new TruckInDepo();
            TruckInDepoDAL depoDAL = new TruckInDepoDAL();

            depo = depoDAL.FillByNomobilNotOut(cont.NoMobilOut);
            if (depo.TruckInDepoId == 0)
            {
                depo.DtmOut = GlobalWebServiceDAL.GetServerDtm();
            }
            cont.EirOut   = CtsCounter.NextValCtsCounter("EIRCTR").ToString();
            cont.Location = "";

            try
            {
                int       contCount;
                ContInOut out2;
                if (revenue.TakeDef.Contains(cont.Cont))
                {
                    goto Label_04FD;
                }
                List <ContInOut> list = new List <ContInOut>();
                list = contInOutDAL.FillByNoSeriOrOut(revenue.NoSeri, cont.Size, cont.Type, revenue.TakeDef);
                int count = list.Count;
                System.Console.WriteLine("Checking over release of " + count.ToString() + " parties at " + DateTime.Now.ToString("hh:mm:ss") + "...");
                System.Console.Write("Please wait....");
                ContSpec spec = new ContSpec();

                string size = cont.Size;
                if (size != null)
                {
                    if (size != "20")
                    {
                        if (size == "40")
                        {
                            goto Label_042E;
                        }
                        if (size == "45")
                        {
                            goto Label_0438;
                        }
                    }
                    else
                    {
                        spec[0] = revenue.Take20;
                    }
                }
                goto Label_0442;
Label_042E:
                spec[0] = revenue.Take40;
                goto Label_0442;
Label_0438:
                spec[0] = revenue.Take45;
Label_0442:
                contCount = 0;
                foreach (ContSpec item in spec)
                {
                    if (item.ToString() == cont.Type)
                    {
                        contCount = item.ContTotalCount;
                    }
                }
                System.Console.WriteLine("completed at " + DateTime.Now.ToString("hh:mm:ss"));
                if (contCount <= count)
                {
                    System.Console.WriteLine("Error: Too Many Container Released");
                    return(false);
                }
Label_04FD:
                out2 = new ContInOut();
                ContInOutDAL contInOutDAL2 = new ContInOutDAL();
                out2 = contInOutDAL2.FillContInOutById(cont.ContInOutId);
                if (out2.DtmOut.Length > 0)
                {
                    System.Console.WriteLine("Error: Container " + out2.Cont + " Already Gate Out At " + out2.DtmOut + " !!!");
                    return(false);
                }
                contInOutDAL.UpdateContInOut(cont);
                if (depo.TruckInDepoId == 0)
                {
                    System.Console.Write("Step 5. Updating truckindepo at " + DateTime.Now.ToString("hh:mm:ss") + "...");
                    //depo.Update(null, tr);

                    System.Console.WriteLine("OK");
                }
                System.Console.Write("Step 6. Committing changes at " + DateTime.Now.ToString("hh:mm:ss") + "...");

                System.Console.WriteLine("OK");
                ContInOut    out3          = new ContInOut();
                ContInOutDAL contInOutDAL3 = new ContInOutDAL();
                out3 = contInOutDAL3.FillContInOutById(cont.ContInOutId);
                if (out3.DtmOut.Length == 0)
                {
                    System.Console.WriteLine("Re-Checking: continout dtmout is empty");
                    return(false);
                }
                System.Console.WriteLine("Re-Checking: continout dtmout is OK at " + out3.DtmOut);
                DoPrintEirOut(cont);
                return(true);
            }
            catch (Exception exception)
            {
                System.Console.WriteLine("Error printing : " + exception.Message);
                return(false);
            }
        }
Beispiel #2
0
 private static void ProcessInput(string input, SecureGateLog log)
 {
     System.Console.WriteLine("Proses " + input);
     if (input.Length > 0)
     {
         string   str      = string.Empty;
         string[] strArray = new string[] { ConfigurationSettings.AppSettings["eiroutprint.printer1.code"], ConfigurationSettings.AppSettings["eiroutprint.printer2.code"] };
         if ((strArray[0] == null) || (strArray[0] == string.Empty))
         {
             strArray[0] = "#1";
         }
         if ((strArray[1] == null) || (strArray[1] == string.Empty))
         {
             strArray[1] = "#2";
         }
         if (input.ToUpper().EndsWith(strArray[0].ToUpper()))
         {
             input     = input.Substring(0, input.Length - strArray[0].Length);
             posnumber = 1;
             str       = strArray[0];
         }
         else if (input.ToUpper().EndsWith(strArray[1].ToUpper()))
         {
             input     = input.Substring(0, input.Length - strArray[1].Length);
             posnumber = 2;
             str       = strArray[1];
         }
         else
         {
             //input = input.Substring(0, input.Length - strArray[1].Length);
             posnumber = 1;
             str       = strArray[0];
         }
         if (str != string.Empty)
         {
             System.Console.WriteLine("container card: " + input + " terminal: " + str);
             _LastProcessedInput = input + str;
         }
         else
         {
             System.Console.WriteLine("container card: " + input + " terminal: default");
             _LastProcessedInput = input;
         }
         ContCard    card        = new ContCard();
         ContCardDal contCardDal = new ContCardDal();
         card = contCardDal.CheckKendaraan(Convert.ToInt64(input));
         System.Console.WriteLine(input);
         if (card.ContCardID == 0)
         {
             System.Console.WriteLine("Card #" + card.ContCardID + " is NOT recognized !!!");
         }
         else if (card.Dtm2.Length == 0)
         {
             System.Console.WriteLine("Step 1. Start proceeding MODE " + card.CardMode + " at " + DateTime.Now.ToString("hh:mm:ss"));
             if ((card.CardMode == "OUT") && (card.ContInOutID > 0L))
             {
                 if (!PrintEir(card))
                 {
                     System.Console.WriteLine("INVALID EIROUT CONDITION DETECTED !!!");
                     return;
                 }
                 System.Console.Write("Step 7. Updating counter at " + DateTime.Now.ToString("hh:mm:ss") + "...");
                 //string str2 = "";
                 //int num = 0;
                 //string str4 = ConfigurationSettings.AppSettings["loginserver"];
                 //if (string.IsNullOrEmpty(str4))
                 //    str4 = "localhost";
                 //NpgsqlConnection connection = new NpgsqlConnection("Server=" + str4 + ";Port=5432;User=edimsl;Password=medus;Database=mitcts;");
                 //connection.Open();
                 //NpgsqlCommand command = new NpgsqlCommand("select * from counter", connection);
                 //if ((posnumber == 0) || (posnumber == 1))
                 //{
                 //    str2 = "1";
                 //}
                 //else if (posnumber == 2)
                 //{
                 //    str2 = "2";
                 //}
                 //num = Convert.ToInt16(str2) - 1;
             }
             else if ((card.CardMode == "IN") && ((card.Dtm3.Length == 0) || (card.UserID3.Length == 0)))
             {
                 System.Console.WriteLine("INVALID UNLOAD CONDITION DETECTED !!! please scan barcode on unload device before gate out.");
                 return;
             }
             card.Dtm2 = GlobalWebServiceDAL.GetServerDtm().ToString("yyyy-MM-dd HH:mm:ss");
             card.Loc2 = _SecureGateLocName;
             contCardDal.UpdateContCardGateOut(card.ContCardID, card.Loc2);
             System.Console.WriteLine("DTM2 USED");
             if (card.CardMode == "OUT")
             {
                 bool flag2 = false;
                 System.Console.Write("Checking DTM2 at " + DateTime.Now.ToString("hh:mm:ss") + "...");
                 //new ContInOut().FillByID(card.ContInOutID);
                 flag2 = card.Dtm2.Length > 0;
                 if (flag2)
                 {
                     System.Console.WriteLine("OK");
                 }
                 if (!flag2)
                 {
                     System.Console.WriteLine("Concard dtmout empty, Please contact Customer Service");
                 }
                 else
                 {
                     OpenGate(input, log, card);
                 }
             }
             else
             {
                 OpenGate(input, log, card);
             }
             if ((_CaptureFile.Length > 0) && File.Exists(_CaptureFile))
             {
                 FileStream     stream         = File.OpenRead(_CaptureFile);
                 BinaryReader   reader         = new BinaryReader(stream);
                 ContCardPic    pic            = new ContCardPic();
                 ContCardPICDal contCardPICDal = new ContCardPICDal();
                 pic.ContCardID = card.ContCardID;
                 pic.PicName    = "OUT";
                 pic.PicData    = reader.ReadBytes((int)stream.Length);
                 reader.Close();
                 stream.Close();
                 contCardPICDal.InsertContCardPIC(pic);
                 File.Move(_CaptureFile, string.Concat(new object[] { _CaptureFile, ".", CtsCounter.NextValCtsCounter("CONTCARDPICOUT_SEQ"), ".jpg" }));
                 System.Console.WriteLine("Picture Captured To Database.");
             }
         }
         else
         {
             System.Console.WriteLine("DTM 2 (STACKING) IS INVALID !!!");
         }
     }
 }
Beispiel #3
0
        private static void ProcessInput(string input, SecureGateLog log, Terminal terminal)
        {
            if (input.Length > 0)
            {
                System.Console.WriteLine("container card: " + input);
                _LastProcessedInput = input;
                ContCard    contCard = new ContCard();
                ContCardDal cardDAL  = new ContCardDal();
                contCard = cardDAL.GetContCardByContCardId(Convert.ToInt64(input));
                if (contCard.ContCardID <= 0)
                {
                    System.Console.WriteLine("INPUT NOT RECOGNIZED !!!");
                }
                else if (contCard.Dtm1.Length == 0)
                {
                    //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    contCard.Dtm1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    contCard.Loc1 = _SecureGateLocName;
                    cardDAL.UpdateContCardGateIn(contCard.ContCardID, contCard.Loc1);

                    System.Console.WriteLine("DTM1 USED");
                    OpenGate(input, log, contCard, terminal);

                    if ((_CaptureFile.Length > 0) && File.Exists(_CaptureFile))
                    {
                        FileStream     stream         = File.OpenRead(_CaptureFile);
                        BinaryReader   reader         = new BinaryReader(stream);
                        ContCardPic    pic            = new ContCardPic();
                        ContCardPICDal contCardPICDal = new ContCardPICDal();

                        pic.ContCardID = contCard.ContCardID;
                        pic.PicName    = "IN";
                        pic.PicData    = reader.ReadBytes((int)stream.Length);
                        reader.Close();
                        stream.Close();
                        contCardPICDal.InsertContCardPIC(pic);
                        File.Move(_CaptureFile, string.Concat(new object[] { _CaptureFile, ".", CtsCounter.NextValCtsCounter("CONTCARDPICIN_SEQ"), ".jpg" }));
                        System.Console.WriteLine("Picture Captured To Database.");
                    }
                }
                else
                {
                    System.Console.WriteLine("INPUT IS USED UP OR INVALID !!!");
                }
            }
        }