Пример #1
0
        private void LoadAppSettings()
        {
            Settings = JsonSettings.Load <SettingsBag>("config.json").EnableAutosave();

            textBoxApiKey.Text      = Settings["key"] as String;
            textBoxServer.Text      = Settings["server"] as String;
            textBoxCutCommand.Text  = Settings.Get("cutcommand", "27.105");
            textBoxOpenCommand.Text = Settings.Get("opencommand", "27.112.48");

            if (Settings.Get("printer", "") != "")
            {
                printersDropdown.SelectedKey = Settings["printer"] as String;
            }
        }
Пример #2
0
        private static void GetRequestProcess(HttpListenerContext context)
        {
            var query  = context.Request.QueryString["documento"];
            var url    = Settings.Get("server", "http://localhoost/facturascripts");
            var token  = Settings.Get("key", "");
            var ticket = "Ticket no encontrado";

            RestClient  cliente = new RestClient(url);
            RestRequest request = new RestRequest("api/3/ticketes/{id}", Method.GET);

            request.AddHeader("Token", token);
            request.AddUrlSegment("id", query);
            request.Timeout = 2000;

            IRestResponse <Ticket> response = cliente.Execute <Ticket>(request);

            if (response.ErrorException != null)
            {
                Console.WriteLine("Error {0}: {1}", response.StatusCode, response.ErrorMessage);
                context.Response.StatusCode        = 408;
                context.Response.StatusDescription = "Request Timeout";
            }

            if (response.IsSuccessful)
            {
                ticket = response.Data.text;
                Print(ticket);
                context.Response.StatusCode        = 200;
                context.Response.StatusDescription = "OK";
            }

            // Response
            context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            context.Response.Headers.Add("Access-Control-Allow-Methods", "GET");

            context.Response.Close();
        }
Пример #3
0
        public PrintController()
        {
            printerName = Settings["printer"] as String;

            string command = Settings.Get("cutcommand", "27.105");

            foreach (var c in command.Split('.'))
            {
                int  unicode   = Convert.ToInt32(c);
                char character = (char)unicode;

                cutCommand += character.ToString();
            }

            command = Settings.Get("opencommand", "27.112.48");
            foreach (var c in command.Split('.'))
            {
                int  unicode   = Convert.ToInt32(c);
                char character = (char)unicode;

                openCommand += character.ToString();
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                OS = "windows";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                OS = "linux";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                OS = "OSX";
            }
        }