示例#1
0
        public void PostData(DpfData data, PostSettings ps, string failedDataDir)
        {
            if (data == null || ps == null)
            {
                throw new ArgumentNullException();
            }

            //splitsen in delen
            byte[][] dataParts = data.Split(ps.MaxPostSize);

            for (int i = 0; i < dataParts.Length; i++)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                byte[] dp       = dataParts[i];
                string dpLength = (dp != null) ? dp.Length.ToString() : "-";

                JsonRespons respons = Post(ps.URL, dp, ps.Username, ps.Password);

                sw.Stop();

                if (respons == null)
                {
                    //fout
                    //opslaan data
                    string fileName = string.Format("{2}\\{1} DPF Post Part {0} Failed.csv", i, DateTime.Now.ToString("yyyy-MM-dd HHmmss"), failedDataDir);
                    try
                    {
                        File.WriteAllBytes(fileName, dp);
                        debugLog.AppendFormat("POST Part {0} failed after {1} s.: {2} bytes saved to {3}\r\n", i, sw.Elapsed.TotalSeconds.ToString("F2"), dpLength, fileName);
                    }
                    catch (Exception ex)
                    {
                        debugLog.AppendFormat("POST Part {0} failed after {1} s.: {2} bytes could not be saved to {3}: {4}\r\n", i, sw.Elapsed.TotalSeconds.ToString("F2"), dpLength, fileName, ex.Message);
                    }
                }
                else
                {
                    //succes
                    debugLog.AppendFormat("POST Part {0} succes in {1} s.: {2} bytes, FietsViewerRespons.processId={3}\r\n", i, sw.Elapsed.TotalSeconds.ToString("F2"), dpLength, respons.FietsViewerRespons.ProcessId);
                }
            }
        }
示例#2
0
文件: DpfData.cs 项目: VCDH/vve
 public void Add(DpfData data)
 {
     Records.AddRange(data.Records);
 }