Пример #1
0
 public static void CreateRequestFile(Request req)
 {
     Stream stream = File.Open($"Request({req.GetDate():yyyy-MM-dd}).osl", FileMode.Create);
         BinaryFormatter bformatter = new BinaryFormatter();
         bformatter.Serialize(stream, req);
         stream.Close();
 }
Пример #2
0
 public static void MakeReport(int a, int b, int q)
 {
     string[] paths = FilePaths.GetPath();
     var quarterFiles = new List<Tuple<string, DateTime>>();
     ReportClass report = new ReportClass();
     Request request = new Request();
     for (int i = 0; i < paths.Length; i++)
     {
         var date = DateTime.Parse(Regex.Match(paths[i], @"\(([^)]*)\)").Groups[1].Value);
         if (date.Month >= a && date.Month <= b)
         {
             quarterFiles.Add(new Tuple<string, DateTime>(paths[i], date));
         }
     }
     quarterFiles.Sort((x, y) => y.Item2.CompareTo(x.Item2));
     DateTime compareTime = quarterFiles[0].Item2;
     request = RequestSerializer.Deserialize(quarterFiles[0].Item1);
     report.AddRange(request.GoodsList);
     for (int i = 1; i < quarterFiles.Count; i++)
     {
         if (compareTime.Year == quarterFiles[i].Item2.Year)
         {
             request = null;
             request = RequestSerializer.Deserialize(quarterFiles[i].Item1);
             report.AddRange(request.GoodsList);
         }
         else
         {
             RequestSerializer.CreateReportFile(report, q);
             report.GoodsList.Clear();
             compareTime = quarterFiles[i].Item2;
             request = RequestSerializer.Deserialize(quarterFiles[i].Item1);
             report.AddRange(request.GoodsList);
         }
     }
     RequestSerializer.CreateReportFile(report, q);
     for (int i = 0; i < quarterFiles.Count; i++)
     {
         File.Delete(quarterFiles[i].Item1);
     }
 }