예제 #1
0
 private void atolSettingsButton_Click(object sender, EventArgs e)
 {
     try
     {
         FprnM1C.IFprnM45 cmd = new FprnM1C.FprnM45();
         cmd.ShowProperties();
     }
     catch (Exception)
     {
         MessageBox.Show("Драйвер не установлен или поврежден. Скачайте и установите драйвера оборудования с сайта dvizh.net!");
     }
 }
예제 #2
0
        private string SendResponse(HttpListenerRequest request)
        {
            if (request.RawUrl == "/dvizh/cashier/api/1.0/")
            {
                System.IO.Stream       body   = request.InputStream;
                System.IO.StreamReader reader = new System.IO.StreamReader(body, request.ContentEncoding);
                string json = reader.ReadToEnd();
                services.actions.RequestAction requestAction = JsonConvert.DeserializeObject <services.actions.RequestAction> (json);
                switch (requestAction.method)
                {
                case "purchase":
                    services.actions.PurchaseAction product = JsonConvert.DeserializeObject <services.actions.PurchaseAction>(json);
                    fiscal.TopIndent();
                    product.purchase();
                    break;

                case "annulate":
                    services.actions.AnnulateAction annulate = JsonConvert.DeserializeObject <services.actions.AnnulateAction>(json);
                    foreach (var ann in annulate._params.elements)
                    {
                        ann.SetCancelAt(DateTime.Now.ToShortDateString());
                        fiscal.Annulate(ann);
                    }
                    break;

                case "storning":
                    services.actions.AnnulateAction storno = JsonConvert.DeserializeObject <services.actions.AnnulateAction>(json);
                    foreach (var st in storno._params.elements)
                    {
                        st.SetCancelAt(DateTime.Now.ToShortDateString());
                        fiscal.Storning(st);
                    }
                    break;

                case "session_start":
                    fiscal.OpenSession();
                    break;

                case "session_stop":
                    Console.WriteLine("stop");
                    fiscal.CloseSession();
                    break;

                case "set cashier":
                    services.actions.SetCashierAction setCashier = JsonConvert.DeserializeObject <services.actions.SetCashierAction>(json);
                    fiscal.SetCashier(setCashier._params.name);
                    break;

                case "settings":
                    FprnM1C.IFprnM45 cmd = new FprnM1C.FprnM45();
                    cmd.ShowProperties();
                    break;

                case "test":
                    fiscal.TestPrint();
                    break;

                default:
                    break;
                }
            }
            return("DvizhSeller");
        }
예제 #3
0
        static string SendResponse(HttpListenerRequest request)
        {
            if (request.RawUrl == "/dvizh/cashier/api/1.0/")
            {
                System.IO.Stream       body   = request.InputStream;
                System.IO.StreamReader reader = new System.IO.StreamReader(body, request.ContentEncoding);
                string json = reader.ReadToEnd();
                services.actions.RequestAction requestAction = JsonConvert.DeserializeObject <services.actions.RequestAction>(json);
                switch (requestAction.method)
                {
                case "purchase":
                    if (fiscal.IsSessionOpen())
                    {
                        services.actions.PurchaseAction product = JsonConvert.DeserializeObject <services.actions.PurchaseAction>(json);
                        for (int i = 0; i < Properties.Settings.Default.indentSize / 5; i++)
                        {
                            fiscal.ScrollPaper();
                        }
                        product.purchase();
                    }
                    else
                    {
                        return("{\n \"status\": " + fiscal.getStatus().ToString() + ",\n \"message\": \"Смена не открыта\"\n}");
                    }
                    break;

                case "annulate":
                    services.actions.AnnulateAction annulate = JsonConvert.DeserializeObject <services.actions.AnnulateAction>(json);
                    foreach (var ann in annulate._params.elements)
                    {
                        ann.SetCancelAt(DateTime.Now.ToShortDateString());
                        fiscal.Annulate(ann);
                    }
                    break;

                case "storning":
                    services.actions.AnnulateAction storno = JsonConvert.DeserializeObject <services.actions.AnnulateAction>(json);
                    foreach (var st in storno._params.elements)
                    {
                        st.SetCancelAt(DateTime.Now.ToShortDateString());
                        fiscal.Storning(st);
                    }
                    break;

                case "start":
                    fiscal.OpenSession();
                    return("{\n \"status\": " + fiscal.getStatus().ToString() + ",\n \"message\": \"Смена открыта\"\n}");

                    break;

                case "stop":
                    fiscal.CloseSession();
                    return("{\n \"status\": " + fiscal.getStatus().ToString() + ",\n \"message\": \"Смена закрыта\"\n}");

                    break;

                case "setCashier":
                    services.actions.SetCashierAction setCashier = JsonConvert.DeserializeObject <services.actions.SetCashierAction>(json);
                    fiscal.SetCashier(setCashier._params.name);
                    break;

                case "settings":
                    FprnM1C.IFprnM45 cmd = new FprnM1C.FprnM45();
                    cmd.ShowProperties();
                    break;

                case "test":
                    fiscal.TestPrint();
                    break;

                case "getStatus":
                    if (fiscal.getStatus() < 0)
                    {
                        return("{\n \"status\": " + fiscal.getStatus().ToString() + ",\n \"message\": \"Произошел сбой в работе ККМ\"\n}");
                    }
                    else
                    {
                        return("{\n \"status\": " + fiscal.getStatus().ToString() + ",\n \"message\": \"Оборудование готово к работе\"\n}");
                    };
                    break;

                case "advSettings":
                    string resp = "";
                    services.actions.Setting setting = JsonConvert.DeserializeObject <services.actions.Setting>(json);
                    resp = fiscal.AdvSetting(setting._params.com_port, setting._params.com_speed, setting._params.use_remote, setting._params.ip + ":" + setting._params.port, setting._params.model);
                    if (resp[0] != 'П')
                    {
                        Properties.Settings.Default.cashierSign = setting._params.purchase_Settings.cashierSign;
                        Properties.Settings.Default.buyerSign   = setting._params.purchase_Settings.buyerSign;
                        Properties.Settings.Default.comment     = setting._params.purchase_Settings.comment;
                        Properties.Settings.Default.indentSize  = setting._params.purchase_Settings.indent;
                        resp += "\"purchase settings\": {\n \"cashierSign\": \"OK\",\n \"buyerSing\": \"OK\",\n \"comment\" = \"" + Properties.Settings.Default.comment + "\",\n \"indent\": \"" + Properties.Settings.Default.indentSize + "\",\n}\n}";
                    }
                    return(resp);

                    break;

                case "getInfo":
                    return(fiscal.Get_info());

                    break;

                default:
                    break;
                }
            }
            return("{\n \"result\": \"Операция успешно выполнена\"\n}");
        }