예제 #1
0
        //public static RootObject check_last_check_print()
        //{
        //    string status = "";
        //    RootObject result = null;
        //    int count = 0; string last_guid = MainStaticClass.read_last_sell_guid();
        //    if (last_guid.Trim().Length!=36)
        //    {
        //        return result;
        //    }
        //    while (1 == 1)
        //    {
        //        count++;
        //        Thread.Sleep(1000);
        //        result = GET(MainStaticClass.url, last_guid);
        //        status = result.results[0].status;
        //        if (status != "ready")
        //        {
        //            if (count > 14)
        //            {
        //                break;
        //            }
        //        }
        //        else if ((status == "ready") || (status == "error"))
        //        {
        //            break;
        //        }
        //    }
        //    return result;
        //}



        public static RootObject check_print(string type, Check check, string num_doc)
        {
            string     status = "";
            RootObject result = null;

            //Check check = new Check();
            check.@operator       = new FiscallPrintJason.Operator();
            [email protected]  = MainStaticClass.Cash_Operator;     // "name";//необходимо переопределить
            [email protected] = MainStaticClass.cash_operator_inn; // "123654789507";//необходимо переопределить
            check.type            = type;
            string _check_ = JsonConvert.SerializeObject(check, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            string json = MainStaticClass.shablon.Replace("body", _check_);

            guid = Guid.NewGuid().ToString();
            string replace = "\"uuid\": \"" + guid + "\"";

            json = json.Replace("uuid", replace);
            //MainStaticClass.write_last_sell_guid(guid,num_doc);
            if (POST(MainStaticClass.url, json) == "Created")
            {
                //Здесь отметить задание, что оно принято к исполнению
                MainStaticClass.write_document_wil_be_printed(num_doc);
                int count = 0;
                while (1 == 1)
                {
                    count++;
                    Thread.Sleep(1000);
                    result = GET(MainStaticClass.url, guid);
                    status = result.results[0].status;
                    if (status != "ready")
                    {
                        if (count > 14)
                        {
                            break;
                        }
                    }
                    else if ((status == "ready") || (status == "error"))
                    {
                        break;
                    }
                }
            }

            return(result);
        }