Ejemplo n.º 1
0
        private static void OpenGate(string openedby, SecureGateLog log, ContCard contCard)
        {
            try
            {
                if (_CaptureImageExeFile.Length > 0)
                {
                    System.Console.WriteLine("info: capturing container picture...");
                    Process.Start(_CaptureImageExeFile);
                    System.Console.WriteLine("info: container picture captured");
                    Thread.Sleep(1000);
                }
                else
                {
                    System.Console.WriteLine("warning: container picture not captured");
                }
            }
            catch (Exception exception)
            {
                System.Console.WriteLine("error: " + exception.Message);
            }
            try
            {
                var terminal = new Terminal(_SecureGateTelnetAddress, Convert.ToInt32(_SecureGateTelnetPort), 10, 80, 40); // hostname, port, timeout [s], width, height
                PushCommand.PushOK(terminal);

                Thread.Sleep(1000);
            }
            catch (Exception exception2)
            {
                System.Console.WriteLine("error: " + exception2.Message);
            }
            try
            {
                SecureGateLogDAL logDal = new SecureGateLogDAL();
                log.Loc1      = _SecureGateLocName;
                log.LogCat    = "GATE OPEN EVENT";
                log.LogRemark = openedby;
                log.RefID     = contCard.ContCardID;
                if (log.SecureGateLogID <= 0)
                {
                    logDal.DeleteSecureGateLog(log);
                    logDal.InsertSecureGateLog(log);
                }
                else
                {
                    logDal.UpdateSecureGateLog(log);
                }
            }
            catch (Exception exception3)
            {
                System.Console.WriteLine("error: " + exception3.Message);
            }
        }
Ejemplo n.º 2
0
        private static void OpenGate(string openedBy, SecureGateLog log, ContCard contCard, Terminal terminal)
        {
            try
            {
                if (_CaptureImageExeFile.Length > 0)
                {
                    System.Console.WriteLine("info: capturing container picture...");
                    Process.Start(_CaptureImageExeFile);
                    System.Console.WriteLine("info: container picture captured");
                    Thread.Sleep(1000);
                }
                else
                {
                    System.Console.WriteLine("warning: container picture not captured");
                }
            }
            catch (Exception exception)
            {
                System.Console.WriteLine("error: " + exception.Message);
            }
            try
            {
                PushCommand.PushOK(terminal);

                Thread.Sleep(1000);
            }
            catch (Exception exception2)
            {
                System.Console.WriteLine("error: " + exception2.Message);
            }
            try
            {
                SecureGateLogDAL logDal = new SecureGateLogDAL();
                log.Loc1      = _SecureGateLocName;
                log.LogCat    = "GATE OPEN EVENT";
                log.LogRemark = openedBy;
                log.RefID     = contCard.ContCardID;
                if (log.SecureGateLogID <= 0)
                {
                    logDal.DeleteSecureGateLog(log);
                    logDal.InsertSecureGateLog(log);
                }
                else
                {
                    logDal.UpdateSecureGateLog(log);
                }
            }
            catch (Exception exception3)
            {
                System.Console.WriteLine("error: " + exception3.Message);
            }
        }
Ejemplo n.º 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 !!!");
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            SecureGateLog log = new SecureGateLog();

            _SecureGateTelnetAddress = ConfigurationSettings.AppSettings["TelnetAddress"];
            _SecureGateTelnetPort    = ConfigurationSettings.AppSettings["TelnetPort"];
            bool      flag;
            bool      flag2;
            Exception exception;
            bool      flag3;

            _SecureGateLocName     = ConfigurationSettings.AppSettings["sgatelocname"];
            _WarningPaperOut       = Convert.ToInt32(ConfigurationSettings.AppSettings["warningpaperout"]);
            _WarningPaperOutMailTo = ConfigurationSettings.AppSettings["warningpaperoutmailto"];
            _WarningPaperOutMailCC = ConfigurationSettings.AppSettings["warningpaperoutmailcc"];
            _CaptureImageExeFile   = ConfigurationSettings.AppSettings["sgatecaptureexefile"];
            _CaptureFile           = ConfigurationSettings.AppSettings["capturefile"];
            if ((_SecureGateLocName == null) || (_SecureGateLocName == string.Empty))
            {
                _SecureGateLocName = "sgateout1";
            }

            System.Console.WriteLine("welcome to Secure Gate Out System " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ", the SCGOUT interactive terminal." + System.Console.Out.NewLine + System.Console.Out.NewLine + @"type: \c for copyright info" + System.Console.Out.NewLine + @"    : \h for help with SCGOUT command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine + System.Console.Out.NewLine + "warning: make sure barcode scanner & impact printer are connected and " + System.Console.Out.NewLine + "working properly. See SCGOUT manual page \"Installation and Setup\" for " + System.Console.Out.NewLine + "instruction.");
            string str = ConfigurationSettings.AppSettings["loginserver"];

            if (string.IsNullOrEmpty(str))
            {
                str = "localhost";
            }
            System.Console.WriteLine(System.Console.Out.NewLine + System.Console.Out.NewLine + "info: SCGOUT location: " + _SecureGateLocName + System.Console.Out.NewLine + "info: logging in..." + System.Console.Out.NewLine + "server: '" + str + "'");
            Random random = new Random();

            goto Label_04A2;
Label_048B:
            if (flag)
            {
                goto Label_04A2;
            }
Label_0498:
            flag3 = true;
            System.Console.Write("SCGOUT> ");
            string input = System.Console.ReadLine();

            flag = false;
            string str3 = input.ToLower();

            if (str3 != null)
            {
                if (str3 != @"\c")
                {
                    if (str3 == @"\q")
                    {
                        return;
                    }
                    if ((str3 == @"\h") || (str3 == @"\?"))
                    {
                    }
                }
                else
                {
                    flag = true;
                    goto Label_048B;
                }
            }
            System.Console.WriteLine(System.Console.Out.NewLine + @"type: \c to connect" + System.Console.Out.NewLine + @"    : \h for help with SCGOUT command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine);
            goto Label_048B;
Label_04A2:
            flag3 = true;
            try
            {
                //AppPrincipal.LoginForService();
                System.Console.Write("info: logged in" + System.Console.Out.NewLine + "info: waiting for input..." + System.Console.Out.NewLine);
                input = string.Empty;
                flag2 = false;
                goto Label_07BE;
            }
            catch (Exception)
            {
                System.Console.WriteLine("error: unable to login");
                if (random.Next(2) > 0)
                {
                    System.Console.WriteLine("info: make sure the database server is online and configured correctly. " + System.Console.Out.NewLine + "See SCGOUT manual page \"Installation and Setup\" for details.");
                }
                else
                {
                    System.Console.WriteLine("info: make sure the Secure Gate Out is configured properly. " + System.Console.Out.NewLine + "See SCGOUT manual page \"Installation and Setup\" for instruction.");
                }
                System.Console.WriteLine(System.Console.Out.NewLine + @"type: \c to connect" + System.Console.Out.NewLine + @"    : \h for help with SCGOUT command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine);
            }
            input = string.Empty;
            flag  = false;
            goto Label_0498;
Label_07B0:
            if (flag2)
            {
                System.Console.WriteLine("info: logging out...");
                //AppPrincipal.LogOut();
                System.Console.WriteLine("info: logged out");
                return;
            }
Label_07BE:
            flag3 = true;
            System.Console.Write("SCGOUT> ");
            input = System.Console.ReadLine();
            flag2 = false;
            switch (input.ToLower())
            {
            case @"\c":
                System.Console.WriteLine(System.Console.Out.NewLine + "Secure Gate Out terminal" + System.Console.Out.NewLine + System.Console.Out.NewLine + "Copyright (c) 2018, Intercon International Terminal. All rights reserved." + System.Console.Out.NewLine + System.Console.Out.NewLine + "Portions Copyright (c) 2018, AGY Solutions." + System.Console.Out.NewLine);
                goto Label_07B0;

            case @"\q":
            case "quit":
            case "exit":
                flag2 = true;
                goto Label_07B0;

            case @"\o":
            case "openup":
            case "open":
                try
                {
                    OpenGate("openup command", log, new ContCard());
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                    System.Console.WriteLine("error: " + exception.Message);
                    _LastProcessedInput = string.Empty;
                }
                goto Label_07B0;

            case @"\h":
            case @"\?":
            case "help":
            case "?":
                System.Console.WriteLine(System.Console.Out.NewLine + "type: {container card number}[terminal code] scan container card barcode or " + System.Console.Out.NewLine + "enter the number manually" + System.Console.Out.NewLine + @"    : \o to open the gate" + System.Console.Out.NewLine + @"    : \c for copyright info" + System.Console.Out.NewLine + @"    : \h for help with SCGOUT command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine);
                goto Label_07B0;

            default:
                try
                {
                    ProcessInput(input, log);
                }
                catch (Exception exception3)
                {
                    exception = exception3;
                    System.Console.WriteLine("error: " + exception.Message);
                    _LastProcessedInput = string.Empty;
                }
                goto Label_07B0;
            }
            //System.Console.WriteLine("--- Welcome to gate app (GATE OUT)---");
            //InputDataGate(service);
        }
Ejemplo n.º 5
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 !!!");
         }
     }
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            SecureGateLog log = new SecureGateLog();

            _SecureGateTelnetAddress = ConfigurationSettings.AppSettings["TelnetAddress"];
            _SecureGateTelnetPort    = ConfigurationSettings.AppSettings["TelnetPort"];
            _SecureGateLocName       = ConfigurationSettings.AppSettings["sgatelocname"];
            _CaptureImageExeFile     = ConfigurationSettings.AppSettings["sgatecaptureexefile"];
            _CaptureFile             = ConfigurationSettings.AppSettings["capturefile"];
            if ((_CaptureImageExeFile == null) || (_CaptureImageExeFile == string.Empty))
            {
                _CaptureImageExeFile = @"capture\capture.exe";
            }
            if ((_CaptureFile == null) || (_CaptureFile == string.Empty))
            {
                _CaptureFile = @"capture\capture.jpg";
            }

            System.Console.WriteLine("welcome to Secure Gate In System " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ", the Secure Gate In Terminal." + System.Console.Out.NewLine + System.Console.Out.NewLine + @"type: \c for copyright info" + System.Console.Out.NewLine + @"    : \h for help with Secure Gate IN command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine + System.Console.Out.NewLine + "warning: make sure barcode scanner & impact printer are connected and " + System.Console.Out.NewLine + "working properly. See Secure Gate IN manual page \"Installation and Setup\" for " + System.Console.Out.NewLine + "instruction.");
            string str = ConfigurationSettings.AppSettings["loginserver"];

            if (string.IsNullOrEmpty(str))
            {
                str = "localhost";
            }
            System.Console.WriteLine(System.Console.Out.NewLine + System.Console.Out.NewLine + "info: Secure Gate IN location: " + _SecureGateLocName + System.Console.Out.NewLine + "info: logging in..." + System.Console.Out.NewLine + "server: '" + str + "'");
            Random random = new Random();

Label_0271:
            try
            {
                //login logic
                var terminal = new Terminal(_SecureGateTelnetAddress, Convert.ToInt32(_SecureGateTelnetPort), 10, 80, 40); // hostname, port, timeout [s], width, height
                terminal.Connect();                                                                                        //tambahan grafik 17-04-2018
                System.Console.Write("info: logged in" + System.Console.Out.NewLine + "info: waiting for input..." + System.Console.Out.NewLine);
                string input = string.Empty;
                bool   flag2 = false;
                do
                {
                    System.Console.Write("SCGIN> ");
                    //if (string.IsNullOrEmpty(input)) input = terminal.getResponse();//tambahan grafik 17-04-2018
                    int countLoop = 0;
Label_0101:
                    for (countLoop = 0; countLoop <= 50; countLoop++)
                    {
                        input = terminal.getResponse();
                    }
                    if (countLoop > 50)
                    {
                        goto Label_0102;
                    }
                    if (string.IsNullOrEmpty(input))
                    {
                        goto Label_0101;
                    }
                    else
                    {
                        System.Console.ReadLine();
                    }
Label_0102:
                    System.Console.WriteLine("Manually Input Container Card Number Secure Gate IN terminal " +
                                             System.Console.Out.NewLine + @"type: \r to to retry process get barcode from System"
                                             );
                    input = System.Console.ReadLine();
                    //if (string.IsNullOrEmpty(input)) input = terminal.getResponse();//tambahan grafik 17-04-2018
                    flag2 = false;
                    switch (input.ToLower())
                    {
                    case @"\r":
                        countLoop = 0;
                        goto Label_0101;

                    case @"\c":
                        System.Console.WriteLine(System.Console.Out.NewLine + "Secure Gate IN terminal"
                                                 + System.Console.Out.NewLine
                                                 + System.Console.Out.NewLine + "Copyright (c) 2018, Intercon International Terminal. All rights reserved."
                                                 + System.Console.Out.NewLine
                                                 + System.Console.Out.NewLine + "Portions Copyright (c) 2018, AGY Solutions."
                                                 + System.Console.Out.NewLine);
                        break;

                    case @"\q":
                    case "quit":
                    case "exit":
                        flag2 = true;
                        break;

                    case @"\o":
                    case "openup":
                    case "open":
                        try
                        {
                            OpenGate("openup command", log, new ContCard(), terminal);
                        }
                        catch (Exception exception)
                        {
                            System.Console.WriteLine("error: " + exception.Message);
                            _LastProcessedInput = string.Empty;
                        }
                        break;

                    case @"\h":
                    case @"\?":
                    case "help":
                    case "?":
                        System.Console.WriteLine(System.Console.Out.NewLine + "type: {container card number}[terminal code] scan container card barcode or " + System.Console.Out.NewLine + "enter the number manually" + System.Console.Out.NewLine + @"    : \o to open the gate" + System.Console.Out.NewLine + @"    : \c for copyright info" + System.Console.Out.NewLine + @"    : \h for help with SCGIN command" + System.Console.Out.NewLine + @"    : \q to quit" + System.Console.Out.NewLine);
                        break;

                    default:
                        try
                        {
                            ProcessInput(input, log, terminal);
                        }
                        catch (Exception exception2)
                        {
                            System.Console.WriteLine("error: " + exception2.Message);
                            _LastProcessedInput = string.Empty;
                        }
                        break;
                    }
                }while (!flag2);
                System.Console.WriteLine("info: logging out...");
                System.Console.WriteLine("info: logged out");
                terminal.Close();
                return;
            }
            catch (Exception)
            {
                System.Console.WriteLine("error: unable to login / connect to Gate");
                if (random.Next(2) > 0)
                {
                    System.Console.WriteLine("info: make sure the database server is online and configured correctly. "
                                             + System.Console.Out.NewLine + "See SCGIN manual page \"Installation and Setup\" for details.");
                }
                else
                {
                    System.Console.WriteLine("info: make sure the Secure Gate IN is configured properly. "
                                             + System.Console.Out.NewLine + "See SCGIN manual page \"Installation and Setup\" for instruction.");
                }
                System.Console.WriteLine(System.Console.Out.NewLine + @"type: \c to connect"
                                         + System.Console.Out.NewLine + @"    : \h for help with SCGIN command"
                                         + System.Console.Out.NewLine + @"    : \q to quit"
                                         + System.Console.Out.NewLine);
            }
            string str2 = string.Empty;
            bool   flag = false;

Label_0340:
            System.Console.Write("SCGIN> ");
            str2 = System.Console.ReadLine();
            flag = false;
            string str4 = str2.ToLower();

            if (str4 != null)
            {
                if (str4 != @"\c")
                {
                    if (str4 == @"\q")
                    {
                        return;
                    }
                    if ((str4 == @"\h") || (str4 == @"\?"))
                    {
                    }
                }
                else
                {
                    flag = true;
                    goto Label_0403;
                }
            }
            System.Console.WriteLine(System.Console.Out.NewLine + @"type: \c to connect"
                                     + System.Console.Out.NewLine + @"    : \h for help with SCGIN command"
                                     + System.Console.Out.NewLine + @"    : \q to quit"
                                     + System.Console.Out.NewLine);
Label_0403:
            if (!flag)
            {
                goto Label_0340;
            }
            goto Label_0271;
        }