示例#1
0
        /// <summary>
        /// Get report async.
        /// </summary>
        /// <param name="option">Option.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>API result.</returns>
        public Task <ApiResult <string> > GetAsync(ReportOption option = null, CancellationToken cancellationToken = default)
        {
            if (option == null)
            {
                return(GetBaseAsync(null, cancellationToken));
            }

            return(GetBaseAsync(new ExtendedReportOption {
                Language = option.Language, Compressed = option.Compressed
            }, cancellationToken));
        }
示例#2
0
        /// <summary>
        /// Get report.
        /// </summary>
        /// <param name="option">Option.</param>
        /// <returns>API result.</returns>
        public ApiResult <string> Get(ReportOption option = null)
        {
            if (option == null)
            {
                return(GetBase(null));
            }

            return(GetBase(new ExtendedReportOption {
                Language = option.Language, Compressed = option.Compressed
            }));
        }
示例#3
0
        /// <summary>
        /// Get report.
        /// </summary>
        /// <param name="option">Option.</param>
        /// <returns>API result.</returns>
        public ApiResult <string> Get(ReportOption option = null)
        {
            var resource = GetResource();

            if (option == null)
            {
                return(GetBase(resource, null));
            }

            return(GetBase(resource, new ExtendedReportOption {
                Language = option.Language, Compressed = option.Compressed
            }));
        }
 /// <summary>CommissionReportBuilder constructor</summary>
 /// <param name="reportRoot">The root XML element containg the report template</param>
 /// <param name="startDate">TBD</param>
 /// <param name="endDate">TBD</param>
 /// <param name="requestedReportOption">TBD</param>
 /// <param name="companyId">TBD</param>
 public CommissionReportBuilder(string reportRoot, DateTime startDate, DateTime endDate, ReportOption requestedReportOption, int companyId)
 {
     CommissionReport = new StringBuilder();
     ReportTemplateDoc = new XmlDocument();
     //ReportTemplateDoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/CommissionReportTemplate.xml"));
     ReportTemplateDoc.Load(HostingEnvironment.MapPath(HostingEnvironment.ApplicationVirtualPath + "/App_Data/CommissionReportTemplate.xml"));
     this.ReportRoot = reportRoot;
     this.StartDate = startDate;
     this.EndDate = endDate;
     this.ReportYear = endDate.Year;
     this.CommissionReportOption = requestedReportOption;
     this.CompanyId = companyId;
 }
 /// <summary>TBD</summary>
 /// <param name="asOfDate">TBD</param>
 /// <param name="requestedReportOption">TBD</param>
 /// <param name="companyId">TBD</param>
 public CommissionAnalysisReportBuilder(DateTime asOfDate, ReportOption requestedReportOption, int companyId)
     : base(REPORT_TEMPLATE_NAME, DateTime.Now, DateTime.Now, requestedReportOption, companyId)
 {
     this.asOfDate = asOfDate;
     this.asOfYear = asOfDate.Year;
     this.asOfPreviousYear = asOfYear - 1;
     this.companyId = companyId;
 }
 /// <summary>AccountingCommissionReportBuilder constructor</summary>
 /// <param name="asOfDate">TBD</param>
 /// <param name="requestedReportOption">TBD</param>
 /// <param name="companyId">TBD</param>
 public AECommissionByMarketReportBuilder(DateTime asOfDate, ReportOption requestedReportOption, int companyId)
     : base(REPORT_TEMPLATE_NAME, DateTime.Now, DateTime.Now, requestedReportOption, companyId)
 {
     this.asOfDate = asOfDate;
 }
 /// <summary>AccountingCommissionReportBuilder constructor</summary>
 /// <param name="startDate">TBD</param>
 /// <param name="endDate">TBD</param>
 /// <param name="requestedReportOption">TBD</param>
 /// <param name="companyId">TBD</param>
 public AccountingCommissionReportBuilder(DateTime startDate, DateTime endDate, ReportOption requestedReportOption, int companyId)
     : base(REPORT_TEMPLATE_NAME, startDate, endDate, requestedReportOption, companyId)
 {
 }
        public static IFolderComparisonReport Compare(this IFolder folder1, IFolder folder2, ReportOption reportOption = ReportOption.EqualOnly)
        {
            #region Null & Not Exists folders cases
            if (folder1 == null)
            {
                if (folder2 == null || !folder2.Exists())
                    return new FolderComparisonReport(equal: true);
                return new FolderComparisonReport(equal: false);
            }
            if (folder2 == null)
            {
                if (!folder1.Exists())
                    return new FolderComparisonReport(equal: true);
                return new FolderComparisonReport(equal: false);
            }

            if (!folder1.Exists() && !folder2.Exists())
                return new FolderComparisonReport(equal: true);

            if (!folder1.Exists() && folder2.Exists())
                return new FolderComparisonReport(equal: false);
            if (folder1.Exists() && !folder2.Exists())
                return new FolderComparisonReport(equal: false);
            #endregion

            #region Files comparison
            string[] entries1 = Directory.GetFileSystemEntries(folder1.Folder);
            string[] entries2 = Directory.GetFileSystemEntries(folder2.Folder);

            if (entries1.Length == 0 && entries2.Length == 0)
                return new FolderComparisonReport(equal: true);

            switch (reportOption)
            {
                case ReportOption.EqualOnly:
                    if (entries1.Length != entries2.Length)
                        return new FolderComparisonReport(equal: false);
                    break;
            }

            string[] files1 = Array.ConvertAll(Directory.GetFiles(folder1.Folder), fileName => Path.GetFileName(fileName).ToLower());
            string[] files2 = Array.ConvertAll(Directory.GetFiles(folder2.Folder), fileName => Path.GetFileName(fileName).ToLower());

            var uniqInFolder1 = new List<string>();
            var uniqInFolder2 = new List<string>();

            switch (reportOption)
            {
                case ReportOption.EqualOnly:
                    bool foundAllFilesFromList1InList2 = Found(files1, files2);
                    if (!foundAllFilesFromList1InList2)
                        return new FolderComparisonReport(equal: false);

                    bool foundAllFilesFromList2InList1 = Found(files2, files1);
                    if (!foundAllFilesFromList2InList1)
                        return new FolderComparisonReport(equal: false);
                    break;
                case ReportOption.CollectDifferentFiles:
                    FoundUniq(files1, files2, uniqInFolder1, uniqInFolder2);
                    break;
                default:
                    throw new NotImplementedException(String.Format("reportOption {0} not implemented", reportOption));
            }

            #endregion

            #region Directory comparison
            string[] directories1 = Array.ConvertAll(Directory.GetDirectories(folder1.Folder), folderName => Path.GetFileName(folderName).ToLower());
            string[] directories2 = Array.ConvertAll(Directory.GetDirectories(folder2.Folder), folderName => Path.GetFileName(folderName).ToLower());

            switch (reportOption)
            {
                case ReportOption.EqualOnly:
                    bool foundAllDirectoriesFromList1InList2 = Found(directories1, directories2);
                    if (!foundAllDirectoriesFromList1InList2)
                        return new FolderComparisonReport(equal: false);
                    bool foundAllDirectoriesFromList2InList1 = Found(directories2, directories1);
                    if (!foundAllDirectoriesFromList2InList1)
                        return new FolderComparisonReport(equal: false);
                    break;
                case ReportOption.CollectDifferentFiles:
                    FoundUniq(directories1, directories2, uniqInFolder1, uniqInFolder2);
                    break;
                default:
                    throw new NotImplementedException(String.Format("reportOption {0} not implemented", reportOption));
            }

            foreach (string subFolder in directories1)
            {
                IFolder subFolder1 = new DataFolder(Path.Combine(folder1.Folder, subFolder));
                IFolder subFolder2 = new DataFolder(Path.Combine(folder2.Folder, subFolder));
                IFolderComparisonReport comparisonReport = subFolder1.Compare(subFolder2, reportOption);
                switch (reportOption)
                {
                    case ReportOption.EqualOnly:
                        if (!comparisonReport.Equal)
                            return new FolderComparisonReport(equal: false);
                        break;
                    case ReportOption.CollectDifferentFiles:
                        uniqInFolder1.AddRange(comparisonReport.Folder1Files.ConvertAll(fileName => subFolder + @"\" + fileName));
                        uniqInFolder2.AddRange(comparisonReport.Folder2Files.ConvertAll(fileName => subFolder + @"\" + fileName));
                        break;
                    default:
                        throw new NotImplementedException(String.Format("reportOption {0} not implemented", reportOption));
                }
            }
            #endregion

            switch (reportOption)
            {
                case ReportOption.EqualOnly:
                    return new FolderComparisonReport(equal: true);
                case ReportOption.CollectDifferentFiles:
                    return new FolderComparisonReport(uniqInFolder1, uniqInFolder2);
                default:
                    throw new NotImplementedException(String.Format("reportOption {0} not implemented", reportOption));
            }
        }
        public static IFolderComparisonReport Compare(this IFolder folder1, string[] folderContent2, ReportOption reportOption = ReportOption.EqualOnly)
        {
            if (folderContent2 == null)
            {
                IFolder folder2 = null;
                return folder1.Compare(folder2);
            }

            using (var temporaryFolder = new TemporaryFolder())
            {
                foreach (string folderEntity in folderContent2)
                {
                    temporaryFolder.CreateFile(folderEntity);
                }
                return folder1.Compare(temporaryFolder, reportOption);
            }
        }