Exemplo n.º 1
0
        public PostSearch SearchRPO(string BoxID)
        {
            PostSearch ps     = new PostSearch();
            string     url    = string.Format("{0}{1}", Properties.Resources.SearchURL, BoxID);
            var        client = new RestClient(url);

            var r = new RestRequest();

            //r.Resource = "1.0/clean/address";
            r.Method  = Method.GET;
            r.Timeout = 3000;

            r.AddHeader("Authorization", Properties.Resources.Authorization);
            r.AddHeader("X-User-Authorization", Properties.Resources.XUserAuthorization);
            r.AddHeader("Content-Type", Properties.Resources.ContentType);

            //r.AddJsonBody(SimpleJson.DeserializeObject(output));

            IRestResponse response = client.Execute(r);

            try
            {
                ps = JsonConvert.DeserializeObject <PostSearch>(response.Content);
            }
            catch (Exception ex)
            {
                ThisAddIn.formProgress.SetLog("Error: " + ex.Message);
            }
            return(ps);
        }
Exemplo n.º 2
0
        private static bool PostImport_02(Excel.Worksheet ws, DataTable dt)
        {
            int            row = 2;
            bool           res = true;
            RuPostQueryAPI api = new RuPostQueryAPI();

            try
            {
                Excel.Range rng = ws.Rows[row].EntireRow;

                foreach (DataRow drow in dt.Rows)
                {
                    rng = ws.Rows[row].EntireRow;
                    rng.Copy(ws.Rows[row + 1]);

                    ws.Cells[row, 1].Value2 = drow["InputDate"];
                    ws.Cells[row, 2].Value2 = drow["ExecuteDate"];
                    ws.Cells[row, 3].Value2 = drow["OrderCode"];
                    ws.Cells[row, 5].Value2 = drow["Post_index"];
                    ws.Cells[row, 6].Value2 = drow["Post_region"];
                    ws.Cells[row, 7].Value2 = drow["Post_place"];
                    int  boxid = 0;
                    bool rr    = int.TryParse(drow["boxPostID"].ToString(), out boxid);
                    if (boxid != 0)
                    {
                        PostSearch ps = api.SearchRPO(drow["boxPostID"].ToString());
                        if (ps != null)
                        {
                            ws.Cells[row, 4].Value2  = ps.Barcode;
                            ws.Cells[row, 12].Value2 = ps.HumanOperationName;
                            ws.Cells[row, 11].Value2 = ps.LastOperDate;
                            ws.Cells[row, 9].Value2  = ps.TotalRateWoVat / 100;
                        }
                    }
                    row++;
                    formProgress.SetProgress(row - 2, 0, dt.Rows.Count);
                }
                rng = ws.Rows[row].EntireRow;
                rng.Delete();
            }
            catch (Exception ex)
            {
                formProgress.SetLog("Error: " + ex.Message);
                res = false;
            }
            return(res);
        }