Пример #1
0
        public static string ToXml(this ReportList reportList)
        {
            XmlSerializer xsSubmit = new XmlSerializer(typeof(ReportList));

            System.IO.StringWriter sww = new System.IO.StringWriter();
            XmlWriter writer           = XmlWriter.Create(sww);

            xsSubmit.Serialize(writer, reportList);
            return(sww.ToString());
        }
Пример #2
0
        public static ReportList ConvertToXmlObject(List <Report> reports)
        {
            int i = 0;

            var result = new ReportList()
            {
                Reports = new ReportElement[reports.Count]
            };

            foreach (var report in reports)
            {
                var listFiles = new List <FileDinhKem>();

                foreach (var file in report.Files)
                {
                    string path = $"{ConfigurationManager.AppSettings["Path_Upload"]}\\{file.FileName}";

                    if (System.IO.File.Exists(path))
                    {
                        listFiles.Add(new FileDinhKem
                        {
                            FileName = file.FileName,
                            Content  = System.IO.File.ReadAllBytes(path)
                        });
                    }
                }

                result.Reports[i] = new ReportElement
                {
                    RequestID     = report.Request.RequestID,
                    ReportID      = report.ReportID,
                    Status        = report.Status,
                    ReportContent = report.ReportContent,
                    ReporterName  = report.ReporterName,
                    PerformOnDate = report.PerformOnDate,
                    IsDeleted     = report.IsDeleted,
                    DanhSachFile  = listFiles.ToArray()
                };
            }

            return(result);
        }