Exemple #1
0
        public static string ToXml(this ReportList requestList)
        {
            XmlSerializer xsSubmit = new XmlSerializer(typeof(ReportList));

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

            xsSubmit.Serialize(writer, requestList);
            return(sww.ToString());
        }
Exemple #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.CreatedByName,
                    PerformOnDate = report.PerformOnDate,
                    IsDeleted     = report.IsDeleted,
                    DanhSachFile  = listFiles.ToArray()
                };
            }

            return(result);
        }