Exemple #1
0
 protected void Application_Start()
 {
     LoggingData.ClearLogs();
     AreaRegistration.RegisterAllAreas();
     //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Exemple #2
0
        static void Main(string[] args)
        {
            LoggingData.ClearLogs();
            client = new AsynchronousClient("localhost", 1450, null);
            Console.ReadLine();
            ItemData itemData = new ItemData();

            itemData.Action      = "SMS_REGISTRATION_CODE";
            itemData.StateObject = "Test sms";
            while (true)
            {
                if (client != null)
                {
                    byte[] recv = client.SendData(itemData.GetBytes());
                    if (recv != null)
                    {
                        ItemData recvData = ItemData.Parse(recv);
                        Console.WriteLine(recvData.StateObject.ToString());
                    }
                }
                Console.ReadLine();
            }
        }
        public static void Init()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(@"o========================================================================o");
            Console.WriteLine(@"|    _____ __  __  _____    _____ ______ _______      ________ _____     |");
            Console.WriteLine(@"|   / ____|  \/  |/ ____|  / ____|  ____|  __ \ \    / /  ____|  __ \    |");
            Console.WriteLine(@"|  | (___ | \  / | (___   | (___ | |__  | |__) \ \  / /| |__  | |__) |   |");
            Console.WriteLine(@"|   \___ \| |\/| |\___ \   \___ \|  __| |  _  / \ \/ / |  __| |  _  /    |");
            Console.WriteLine(@"|   ____) | |  | |____) |  ____) | |____| | \ \  \  /  | |____| | \ \    |");
            Console.WriteLine(@"|  |_____/|_|  |_|_____/  |_____/|______|_|  \_\  \/   |______|_|  \_\   |");
            Console.WriteLine(@"|                 _   _ _                      _                         |");
            Console.WriteLine(@"|                 | | | (_)                    (_)                       |");
            Console.WriteLine(@"|                 | | | |_ _ __   __ ___      ___ ___  ___               |");
            Console.WriteLine(@"|                 | | | | | '_ \ / _` \ \ /\ / / / __|/ _ \              |");
            Console.WriteLine(@"|                 \ \_/ / | | | | (_| |\ V  V /| \__ \  __/              |");
            Console.WriteLine(@"|                  \___/|_|_| |_|\__,_| \_/\_/ |_|___/\___|              |");
            Console.WriteLine(@"|                                                                        |");
            Console.WriteLine(@"o========================================================================o");
            Console.ResetColor();
            Console.WriteLine(string.Format("{0}: Starting modem application to init drivers", DateTime.Now));
            LoggingData.ClearLogs();
            try
            {
                Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "ModemApp\\WirelessModem.exe");
                Thread.Sleep(5000);
                foreach (var process in Process.GetProcessesByName("WirelessModem"))
                {
                    process.Kill();
                }
                Thread.Sleep(3000);
                Console.WriteLine(string.Format("{0}: Loading GSM modem control ", DateTime.Now));
                do
                {
                    Dictionary <string, object> dictData = CommonFunctions.GetSerializedObject(System.AppDomain.CurrentDomain.BaseDirectory + "GsmSettings.dat") as Dictionary <string, object>;
                    string   PortName = dictData["PORT_NAME"] as string;
                    int      BaudRate = (int)dictData["COM_BAUDRATE"];
                    int      DataBit  = (int)dictData["COM_DATA_BIT"];
                    StopBits stopBits = (StopBits)dictData["COM_STOP_BIT"];
                    Parity   parity   = (Parity)dictData["COM_PARITY"];
                    modem = new GSMModemDevice(PortName, BaudRate, 8, stopBits, parity);
                    modem.OpenPort();
                    if (modem != null && modem.IsOpened())
                    {
                        modem.InitModemConfig();
                        modem.setModemSIMReady();
                        Console.WriteLine(string.Format("{0}: GSM Modem ready on {1}", DateTime.Now, PortName));
                        break;
                    }
                    Console.WriteLine(string.Format("{0}: GSM Modem open port failed. Check your device is connected. Retry openmodem ", DateTime.Now));
                    Thread.Sleep(5000);
                } while (modem == null || !modem.IsOpened());

                SerialPortService.PortsChanged += SerialPortService_PortsChanged;

                Thread threadServerSms = new Thread(RunServer);
                threadServerSms.IsBackground = true;
                threadServerSms.Start();

                Console.WriteLine(string.Format("{0}: System is ready ...", DateTime.Now));
            }
            catch (Exception ex)
            {
                LoggingData.WriteLog(ex);
                Console.WriteLine("{0:dd-MM-yyyy HH:mm:ss}: {1} \r\nStackTrace: {2}", DateTime.Now, ex.Message, ex.StackTrace);
                System.Diagnostics.Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "SmsProviderServerService.exe");
                Environment.Exit(0);
            }
        }