コード例 #1
0
        public static SboReportDocument FromDefaultReportFor(string reportCode, string cardCode, int?userSign = null)
        {
            Logger.Trace("Getting Crystal Report document from default for {0} - {1} - {2}", reportCode, cardCode, userSign);

            string layoutCode = null;

            var cacheKey = $"SboReportDocument.FromDefaultReportFor({reportCode},{cardCode},{userSign})";

            if (SboTemporaryCache.Contains(cacheKey))
            {
                layoutCode = SboTemporaryCache.Get <string>(cacheKey);
            }

            if (layoutCode == null)
            {
                using (var factory = new SboDisposableBusinessObjectFactory())
                {
                    var companyService      = factory.GetCompanyService();
                    var reportLayoutService = (ReportLayoutsService)companyService.GetBusinessService(ServiceTypes.ReportLayoutsService);

                    var reportParam =
                        (ReportParams)reportLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportParams);
                    reportParam.UserID     = userSign ?? SboAddon.Instance.Company.UserSignature;
                    reportParam.ReportCode = reportCode;
                    reportParam.CardCode   = cardCode;

                    var reportLayout = reportLayoutService.GetDefaultReport(reportParam);
                    layoutCode = reportLayout.LayoutCode;

                    SboTemporaryCache.Set(cacheKey, layoutCode);
                }
            }

            return(FromLayoutCode(layoutCode));
        }
コード例 #2
0
        public static string GetLocalCurrency()
        {
            if (_getLocalCurrencyCache != null)
            {
                return(_getLocalCurrencyCache);
            }

            using (var factory = new SboDisposableBusinessObjectFactory())
            {
                CompanyService companyService = factory.GetCompanyService();
                AdminInfo      adminInfo      = companyService.GetAdminInfo();

                _getLocalCurrencyCache = adminInfo.LocalCurrency.ToUpperInvariant();
                return(_getLocalCurrencyCache);
            }
        }
コード例 #3
0
        public static SboReportDocument FromLayoutCode(string layoutCode)
        {
            Logger.Trace("Getting Crystal Report document from layoutCode {0}", layoutCode);

            string tempFilename = null;
            var    cacheKey     = $"SboReportDocument.FromLayoutCode({layoutCode})";

            if (SboTemporaryCache.Contains(cacheKey))
            {
                tempFilename = SboTemporaryCache.Get <string>(cacheKey);
            }

            if (tempFilename == null || !File.Exists(tempFilename))
            {
                using (var factory = new SboDisposableBusinessObjectFactory())
                {
                    var companyService = factory.GetCompanyService();
                    var blobParams     = (BlobParams)companyService.GetDataInterface(CompanyServiceDataInterfaces.csdiBlobParams);
                    blobParams.Table = "RDOC";
                    blobParams.Field = "Template";

                    BlobTableKeySegment keySegment = blobParams.BlobTableKeySegments.Add();
                    keySegment.Name  = "DocCode";
                    keySegment.Value = layoutCode;

                    var blob = (Blob)companyService.GetDataInterface(CompanyServiceDataInterfaces.csdiBlob);
                    blob = companyService.GetBlob(blobParams);

                    tempFilename = Path.GetTempFileName();
                    File.WriteAllBytes(tempFilename, Convert.FromBase64String(blob.Content));

                    SboTemporaryCache.Set(cacheKey, tempFilename);
                }
            }

            return(FromFile(tempFilename));
        }