Пример #1
0
 private void Init(CrmConnection connection, string id, int invalidationInterval = 20)
 {
     Id           = id;
     Connection   = connection;
     Cache        = new MemoryCache(id);
     ServiceCache = new OrganizationServiceCache(Cache, Connection);
     CachedOrganizationService = new CachedOrganizationService(Connection, ServiceCache);
     this.invalidationInterval = invalidationInterval;
     latestInvalidationDate    = DateTime.Now;
 }
Пример #2
0
        public static string GetCurrencySymbol(Guid currencyId)
        {
            // Lookup the currency code/symbol
            EntityCollection orgSettings = CachedOrganizationService.RetrieveMultiple(@"<fetch distinct='false' no-lock='false' mapping='logical'><entity name='organization'><attribute name='currencydisplayoption' /><attribute name='currencysymbol' /></entity></fetch>");
            Entity           orgSetting  = orgSettings.Entities[0];
            Entity           currency    = CachedOrganizationService.Retrieve("transactioncurrency", currencyId.ToString(), new string[] { "currencysymbol", "isocurrencycode" });

            if (orgSetting.GetAttributeValueOptionSet("currencydisplayoption").Value == 0) // Fixes Issue #23 - Thanks @advancedhair
            {
                // Currency Symbol
                return(currency.GetAttributeValueString("currencysymbol") + " ");
            }
            else
            {
                // Currency ISO Code
                return(currency.GetAttributeValueString("isocurrencycode") + " ");
            }
        }