Example #1
0
 public MyClass(IUnitOfWorkFactory uowFactory,
     CurrencyProvider currencyProvider,
     IFooPolicy fooPolicy,
     IBarService barService,
     ICoffeeMaker coffeeMaker,
     IKitchenSink kitchenSink)
 {
 }
Example #2
0
        public static void DemandCreateOrUpdate(Invoice invoice)
        {
            if (invoice.IssueDate == DateTime.MinValue ||
                invoice.ContactID <= 0 ||
                invoice.DueDate == DateTime.MinValue ||
                String.IsNullOrEmpty(invoice.Currency) ||
                invoice.ExchangeRate <= 0 ||
                String.IsNullOrEmpty(invoice.Terms))
            {
                throw new ArgumentException();
            }

            using (var scope = DIHelper.Resolve())
            {
                var daoFactory = scope.Resolve <DaoFactory>();
                var contact    = daoFactory.ContactDao.GetByID(invoice.ContactID);
                if (contact == null)
                {
                    throw new ArgumentException();
                }
                if (!CanAccessTo(contact))
                {
                    throw new SecurityException(CRMErrorsResource.AccessDenied);
                }

                if (invoice.ConsigneeID != 0 && invoice.ConsigneeID != invoice.ContactID)
                {
                    var consignee = daoFactory.ContactDao.GetByID(invoice.ConsigneeID);
                    if (consignee == null)
                    {
                        throw new ArgumentException();
                    }
                    if (!CanAccessTo(consignee))
                    {
                        throw new SecurityException(CRMErrorsResource.AccessDenied);
                    }
                }

                if (invoice.EntityID != 0)
                {
                    var deal = daoFactory.DealDao.GetByID(invoice.EntityID);
                    if (deal == null)
                    {
                        throw new ArgumentException();
                    }
                    if (!CanAccessTo(deal))
                    {
                        throw new SecurityException(CRMErrorsResource.AccessDenied);
                    }

                    var dealMembers = daoFactory.DealDao.GetMembers(invoice.EntityID);
                    if (!dealMembers.Contains(invoice.ContactID))
                    {
                        throw new ArgumentException();
                    }
                }
            }

            if (CurrencyProvider.Get(invoice.Currency.ToUpper()) == null)
            {
                throw new ArgumentException();
            }
        }
Example #3
0
        private XDocument BuildSalesReport(IEnumerable <object[]> reportData, Guid responsibleID,
                                           DateTime fromDate,
                                           DateTime toDate)
        {
            var fromDateStr = String.Empty;

            if (fromDate != DateTime.MinValue)
            {
                fromDateStr = fromDate.ToShortDateString();
            }


            var toDateStr = String.Empty;

            if (toDate != DateTime.MinValue)
            {
                toDateStr = toDate.ToShortDateString();
            }

            var responsibleStr = String.Empty;

            if (responsibleID != Guid.Empty)
            {
                responsibleStr = ASC.Core.CoreContext.UserManager.GetUsers(ASC.Core.SecurityContext.CurrentAccount.ID).DisplayUserName();
            }


            var result = reportData.GroupBy(row =>
            {
                var bidCurrency = Convert.ToString(row[1]);

                if (bidCurrency != Global.TenantSettings.DefaultCurrency.Abbreviation)
                {
                    row[2] = CurrencyProvider.MoneyConvertToDefaultCurrency(Convert.ToDecimal(row[2]), bidCurrency);
                }

                return(row[0]);
            }).Select(group => new[]
            {
                group.Key,
                group.Sum(p => Convert.ToDecimal(p[2])),
                group.Sum(p => Convert.ToDecimal(p[3])),
                0
            }).ToList();

            var totalDeals = result.Sum(row => Convert.ToInt32(row[2]));

            if (totalDeals == 0)
            {
                return(new XDocument());
            }

            foreach (var item in result)
            {
                item[3] = Convert.ToInt32(item[2]) * 100 / totalDeals;
            }

            var xDocument = new XDocument(
                new XDeclaration("1.0", "utf-8", "true"),
                new XElement("report",
                             new XElement("metadata",
                                          new XElement("filters",
                                                       new XElement("filter", new XAttribute("name", "fromDate"),
                                                                    fromDateStr,
                                                                    new XAttribute("title", CRMCommonResource.From)),
                                                       new XElement("filter", new XAttribute("name", "toDate"),
                                                                    toDateStr,
                                                                    new XAttribute("title", CRMCommonResource.To)),
                                                       new XElement("filter", new XAttribute("name", "responsible"), responsibleStr, new XAttribute("title", CRMCommonResource.Responsible))

                                                       ),
                                          new XElement("totalDeals", totalDeals),
                                          new XElement("description", "",
                                                       new XAttribute("title", CRMCommonResource.Description))
                                          ),
                             new XElement("content",
                                          new XElement("columns",
                                                       new XElement("column", new XAttribute("name", "title"), ""),
                                                       new XElement("column", new XAttribute("name", "amount"),
                                                                    CRMDealResource.DealAmount),
                                                       new XElement("column", new XAttribute("name", "count"),
                                                                    CRMDealResource.DealCount),
                                                       new XElement("column", new XAttribute("name", "percent"),
                                                                    CRMCommonResource.Part)),
                                          new XElement("rows",
                                                       result.ConvertAll(row =>
                                                                         new XElement("row",
                                                                                      new XElement("title", row[0]),
                                                                                      new XElement("amount", row[1]),
                                                                                      new XElement("count", row[2]),
                                                                                      new XElement("percent", row[3])
                                                                                      )

                                                                         ).ToArray()))));

            InsertCommonMetadata(xDocument);


            return(xDocument);
        }
Example #4
0
        private void BuildSalesReport(ref Report report,
                                      IEnumerable <object[]> reportData, Guid responsibleID,
                                      DateTime fromDate,
                                      DateTime toDate)
        {
            report.Lables = new List <String>
            {
                CRMDealResource.DealAmount,
                CRMDealResource.DealCount,
                CRMCommonResource.Part
            };

            var fromDateStr = String.Empty;

            if (fromDate != DateTime.MinValue)
            {
                fromDateStr = fromDate.ToShortDateString();
            }


            var toDateStr = String.Empty;

            if (toDate != DateTime.MinValue)
            {
                toDateStr = toDate.ToShortDateString();
            }

            var responsibleStr = String.Empty;

            if (responsibleID != Guid.Empty)
            {
                responsibleStr = ASC.Core.CoreContext.UserManager.GetUsers(ASC.Core.SecurityContext.CurrentAccount.ID).DisplayUserName();
            }


            var result = reportData.GroupBy(row =>
            {
                var bidCurrency = Convert.ToString(row[1]);

                if (bidCurrency != Global.TenantSettings.DefaultCurrency.Abbreviation)
                {
                    row[2] = CurrencyProvider.MoneyConvertToDefaultCurrency(Convert.ToDecimal(row[2]), bidCurrency);
                }

                return(row[0]);
            }).Select(group => new[]
            {
                group.Key,
                group.Sum(p => Convert.ToDecimal(p[2])),
                group.Sum(p => Convert.ToDecimal(p[3])),
                0
            }).ToList();

            var totalDeals = result.Sum(row => Convert.ToInt32(row[2]));

            foreach (var item in result)
            {
                item[3] = Convert.ToInt32(item[2]) * 100 / totalDeals;
            }


            report.Data = result.ConvertAll(row => new
            {
                title   = row[0],
                amount  = row[1],
                count   = row[2],
                percent = row[3]
            });
        }
Example #5
0
        public XDocument BuildSalesByMonthReport(Guid responsibleID, DateTime fromDate, DateTime toDate)
        {
            var sqlQuery = new SqlQuery("crm_deal tbl_deal")
                           .Select("MONTH(tbl_deal.actual_close_date) as acdMonth",
                                   "tbl_deal.bid_currency",
                                   @"sum(CASE tbl_deal.bid_type
                                           WHEN 0 THEN
                                             (tbl_deal.bid_value)
                                           ELSE
                                             (tbl_deal.bid_value * tbl_deal.per_period_value)
                                           END) AS bid_value",
                                   "count(tbl_deal.id) as count")
                           .LeftOuterJoin("crm_deal_milestone tbl_list", Exp.EqColumns("tbl_deal.deal_milestone_id", "tbl_list.id"))
                           .Where(Exp.Eq("tbl_list.tenant_id", TenantID) & Exp.Eq("tbl_deal.tenant_id", TenantID) &
                                  Exp.Between("tbl_deal.actual_close_date", fromDate, toDate) &
                                  !Exp.Eq("tbl_deal.bid_value", 0) &
                                  Exp.Eq("tbl_list.status", (int)DealMilestoneStatus.ClosedAndWon))
                           .GroupBy("acdMonth", "tbl_deal.bid_currency");

            if (responsibleID != Guid.Empty)
            {
                sqlQuery.Where(Exp.Eq("tbl_deal.responsible_id", responsibleID));
            }

            using (var db = GetDb())
            {
                var sqlResult = db.ExecuteList(sqlQuery);

                if (sqlResult.Count == 0)
                {
                    return(new XDocument());
                }

                var result = sqlResult.GroupBy(row =>
                {
                    var bidCurrency = Convert.ToString(row[1]);

                    if (bidCurrency != Global.TenantSettings.DefaultCurrency.Abbreviation)
                    {
                        row[2] = CurrencyProvider.MoneyConvertToDefaultCurrency(Convert.ToDecimal(row[2]), bidCurrency);
                    }

                    return(row[0]);
                }).Select(group => new[]
                {
                    group.Key,
                    group.Sum(p => Convert.ToDecimal(p[2])),
                    group.Sum(p => Convert.ToDecimal(p[3])),
                    0
                }).ToList();

                var totalDeals = result.Sum(row => Convert.ToInt32(row[2]));

                if (totalDeals == 0)
                {
                    return(new XDocument());
                }

                foreach (var item in result)
                {
                    item[3] = Convert.ToInt32(item[2]) * 100 / totalDeals;
                }
            }
            throw new NotImplementedException();
        }
Example #6
0
 public RateInfo ChangeCurrency(string fromCurrency, string toCurrency)
 {
     return(new RateInfo(CurrencyProvider.MoneyConvert(1, fromCurrency, toCurrency),
                         CurrencyProvider.Get(fromCurrency).Title, CurrencyProvider.Get(toCurrency).Title));
 }
Example #7
0
        private IEnumerable <OpportunityWrapper> ToListOpportunityWrapper(ICollection <Deal> deals)
        {
            if (deals == null || deals.Count == 0)
            {
                return(new List <OpportunityWrapper>());
            }

            var result = new List <OpportunityWrapper>();

            var contactIDs       = new List <int>();
            var dealIDs          = new List <int>();
            var dealMilestoneIDs = new List <int>();

            foreach (var deal in deals)
            {
                contactIDs.Add(deal.ContactID);
                dealIDs.Add(deal.ID);
                dealMilestoneIDs.Add(deal.DealMilestoneID);
            }

            dealMilestoneIDs = dealMilestoneIDs.Distinct().ToList();

            var contacts = new Dictionary <int, ContactBaseWrapper>();

            var customFields = DaoFactory.CustomFieldDao.GetEnityFields(EntityType.Opportunity, dealIDs.ToArray())
                               .GroupBy(item => item.EntityID)
                               .ToDictionary(item => item.Key, item => item.Select(ToCustomFieldBaseWrapper));

            var dealMilestones = DaoFactory.DealMilestoneDao.GetAll(dealMilestoneIDs.ToArray())
                                 .ToDictionary(item => item.ID, item => new DealMilestoneBaseWrapper(item));


            var dealMembers = DaoFactory.DealDao.GetMembers(dealIDs.ToArray());

            foreach (var value in dealMembers.Values)
            {
                contactIDs.AddRange(value);
            }

            contactIDs = contactIDs.Distinct().ToList();

            if (contactIDs.Count > 0)
            {
                DaoFactory.ContactDao.GetContacts(contactIDs.ToArray()).ForEach(item =>
                {
                    if (item == null)
                    {
                        return;
                    }
                    contacts.Add(item.ID, ToContactBaseWrapper(item));
                });
            }

            foreach (var deal in deals)
            {
                var dealWrapper = new OpportunityWrapper(deal);

                if (contacts.ContainsKey(deal.ContactID))
                {
                    dealWrapper.Contact = contacts[deal.ContactID];
                }

                dealWrapper.CustomFields = customFields.ContainsKey(deal.ID)
                                               ? customFields[deal.ID]
                                               : new List <CustomFieldBaseWrapper>();

                dealWrapper.Members = dealMembers.ContainsKey(dealWrapper.ID)
                                          ? dealMembers[dealWrapper.ID].Where(contacts.ContainsKey).Select(item => contacts[item])
                                          : new List <ContactBaseWrapper>();

                if (dealMilestones.ContainsKey(deal.DealMilestoneID))
                {
                    dealWrapper.Stage = dealMilestones[deal.DealMilestoneID];
                }

                dealWrapper.IsPrivate = CRMSecurity.IsPrivate(deal);

                if (dealWrapper.IsPrivate)
                {
                    dealWrapper.AccessList = CRMSecurity.GetAccessSubjectTo(deal).Select(item => EmployeeWraper.Get(item.Key)).ToItemList();
                }

                if (!string.IsNullOrEmpty(deal.BidCurrency))
                {
                    dealWrapper.BidCurrency = ToCurrencyInfoWrapper(CurrencyProvider.Get(deal.BidCurrency));
                }

                result.Add(dealWrapper);
            }

            return(result);
        }
        private Invoice GetInvoice(DaoFactory dao)
        {
            var invoice = new Invoice();

            if (ActionType == InvoiceActionType.Edit)
            {
                invoice.ID     = TargetInvoice.ID;
                invoice.Number = TargetInvoice.Number;
                invoice.FileID = TargetInvoice.FileID;
            }
            else
            {
                invoice.Number = Request["invoiceNumber"];
                if (dao.InvoiceDao.IsExist(invoice.Number))
                {
                    throw new InvoiceValidationException(CRMErrorsResource.InvoiceNumberBusy);
                }
            }

            DateTime issueDate;

            if (!DateTime.TryParse(Request["invoiceIssueDate"], out issueDate))
            {
                throw new InvoiceValidationException("invalid issueDate");
            }
            invoice.IssueDate = issueDate;

            invoice.ContactID = Convert.ToInt32(Request["invoiceContactID"]);
            if (invoice.ContactID <= 0)
            {
                throw new InvoiceValidationException(CRMErrorsResource.InvoiceContactNotFound);
            }
            var contact = dao.ContactDao.GetByID(invoice.ContactID);

            if (contact == null || !CRMSecurity.CanAccessTo(contact))
            {
                throw new InvoiceValidationException(CRMErrorsResource.InvoiceContactNotFound);
            }

            invoice.ConsigneeID = Convert.ToInt32(Request["invoiceConsigneeID"]);
            if (invoice.ConsigneeID > 0)
            {
                var consignee = dao.ContactDao.GetByID(invoice.ConsigneeID);
                if (consignee == null || !CRMSecurity.CanAccessTo(consignee))
                {
                    throw new InvoiceValidationException(CRMErrorsResource.InvoiceConsigneeNotFound);
                }
            }
            else
            {
                invoice.ConsigneeID = 0;
            }


            invoice.EntityType = EntityType.Opportunity;

            invoice.EntityID = Convert.ToInt32(Request["invoiceOpportunityID"]);
            if (invoice.EntityID > 0)
            {
                var deal = dao.DealDao.GetByID(invoice.EntityID);
                if (deal == null || !CRMSecurity.CanAccessTo(deal))
                {
                    throw new InvoiceValidationException(CRMErrorsResource.DealNotFound);
                }

                var dealMembers = dao.DealDao.GetMembers(invoice.EntityID);
                if (!dealMembers.Contains(invoice.ContactID))
                {
                    throw new InvoiceValidationException("contact doesn't have this opportunity");
                }
            }

            DateTime dueDate;

            if (!DateTime.TryParse(Request["invoiceDueDate"], out dueDate))
            {
                throw new InvoiceValidationException(CRMErrorsResource.InvoiceDueDateInvalid);
            }
            if (issueDate > dueDate)
            {
                throw new InvoiceValidationException(CRMErrorsResource.InvoiceIssueMoreThanDue);
            }
            invoice.DueDate = dueDate;

            invoice.Language = Request["invoiceLanguage"];
            if (string.IsNullOrEmpty(invoice.Language) || SetupInfo.EnabledCultures.All(c => c.Name != invoice.Language))
            {
                throw new InvoiceValidationException(CRMErrorsResource.LanguageNotFound);
            }

            invoice.Currency = Request["invoiceCurrency"];
            if (string.IsNullOrEmpty(invoice.Currency))
            {
                throw new InvoiceValidationException(CRMErrorsResource.CurrencyNotFound);
            }
            else
            {
                invoice.Currency = invoice.Currency.ToUpper();
                if (CurrencyProvider.Get(invoice.Currency) == null)
                {
                    throw new InvoiceValidationException(CRMErrorsResource.CurrencyNotFound);
                }
            }

            invoice.ExchangeRate = Convert.ToDecimal(Request["invoiceExchangeRate"], new CultureInfo("en-US"));
            if (invoice.ExchangeRate <= 0)
            {
                throw new InvoiceValidationException(CRMErrorsResource.ExchangeRateNotSet);
            }

            invoice.PurchaseOrderNumber = Request["invoicePurchaseOrderNumber"];

            invoice.Terms = Request["invoiceTerms"];
            if (string.IsNullOrEmpty(invoice.Terms))
            {
                throw new InvoiceValidationException(CRMErrorsResource.InvoiceTermsNotFound);
            }

            invoice.Description = Request["invoiceDescription"];

            invoice.Status = InvoiceStatus.Draft;

            invoice.TemplateType = InvoiceTemplateType.Eur;

            return(invoice);
        }
        public virtual OrderSummaryPaymentViewModel BuildOrderSummaryPaymentViewModel(Overture.ServiceModel.Orders.Payment payment, CultureInfo cultureInfo)
        {
            var methodDisplayNames = LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = cultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            }).Result;

            var paymentMethodDisplayName = methodDisplayNames.FirstOrDefault(x => x.Key == payment.PaymentMethod.Type.ToString()).Value;

            var paymentVm = new OrderSummaryPaymentViewModel
            {
                FirstName         = payment.BillingAddress?.FirstName,
                LastName          = payment.BillingAddress?.LastName,
                PaymentMethodName = paymentMethodDisplayName,
            };

            paymentVm.BillingAddress = CartViewModelFactory.GetAddressViewModel(payment.BillingAddress, cultureInfo);
            paymentVm.Amount         = LocalizationProvider.FormatPrice((decimal)payment.Amount, CurrencyProvider.GetCurrency());

            return(paymentVm);
        }
Example #10
0
 public DataManager()
 {
     this.ActorProvider    = new ActorProvider();
     this.CurrencyProvider = new CurrencyProvider();
 }
Example #11
0
        public virtual OrderSummaryPaymentViewModel BuildOrderSummaryPaymentViewModel(Overture.ServiceModel.Orders.Payment payment, CultureInfo cultureInfo)
        {
            var creditCartNumber  = string.Empty;
            var expiryDate        = string.Empty;
            var paymentMethodName = string.Empty;

            if (payment.PaymentMethod.PropertyBag != null)
            {
                //TODO : use viewmodelmapper through cartviewmodelfactory ( already exist )
                if (payment.PaymentMethod.Type == PaymentMethodType.SavedCreditCard)
                {
                    if (payment.PaymentMethod.PropertyBag.ContainsKey(SavedCardMask))
                    {
                        creditCartNumber = payment.PaymentMethod.PropertyBag[SavedCardMask].ToString();
                    }

                    if (payment.PaymentMethod.PropertyBag.ContainsKey(SavedExpiryDate))
                    {
                        expiryDate = payment.PaymentMethod.PropertyBag[SavedExpiryDate].ToString();
                    }

                    if (payment.PaymentMethod.PropertyBag.ContainsKey(SavedCardType))
                    {
                        paymentMethodName = payment.PaymentMethod.PropertyBag[SavedCardType].ToString();
                    }
                }
                else
                {
                    if (payment.PaymentMethod.PropertyBag.ContainsKey(CreditCardPaymentProperties.CreditCardNumberLastDigitsKey))
                    {
                        creditCartNumber = payment.PaymentMethod.PropertyBag[CreditCardPaymentProperties.CreditCardNumberLastDigitsKey].ToString();
                    }

                    if (payment.PaymentMethod.PropertyBag.ContainsKey(CreditCardPaymentProperties.CreditCardExpiryDateKey))
                    {
                        expiryDate = payment.PaymentMethod.PropertyBag[CreditCardPaymentProperties.CreditCardExpiryDateKey].ToString();
                    }

                    if (payment.PaymentMethod.PropertyBag.ContainsKey(CreditCardPaymentProperties.CreditCardBrandKey))
                    {
                        paymentMethodName = payment.PaymentMethod.PropertyBag[CreditCardPaymentProperties.CreditCardBrandKey].ToString();
                    }
                }
            }

            bool hasExpired = false;

            if (DateTime.TryParse(expiryDate, out DateTime expirationDate))
            {
                hasExpired = expirationDate < DateTime.UtcNow;
            }

            var paymentVm = new OrderSummaryPaymentViewModel
            {
                FirstName         = payment.BillingAddress.FirstName,
                LastName          = payment.BillingAddress.LastName,
                PaymentMethodName = paymentMethodName,
                CreditCardNumber  = creditCartNumber,
                ExpiryDate        = expiryDate,
                IsExpired         = hasExpired
            };

            paymentVm.BillingAddress = CartViewModelFactory.GetAddressViewModel(payment.BillingAddress, cultureInfo);
            paymentVm.Amount         = LocalizationProvider.FormatPrice(payment.Amount, CurrencyProvider.GetCurrency());

            return(paymentVm);
        }
        public static Bank CreateExampleBank()
        {
            Bank bank = new Bank();

            //parasoft-begin-suppress CS.INTER.ITT
            bank.AddCurrency(new CurrencyInfo("USD", "$", "{1}{0}"));
            bank.AddCurrency(new CurrencyInfo("EUR", "€", "{1}{0}"));
            bank.AddCurrency(new CurrencyInfo("JPY", "Â¥", "{1}{0}"));
            bank.AddCurrency(new CurrencyInfo("PLN", "zł", "{0} {1}"));
            bank.AddCurrency(new CurrencyInfo("ISK", "kr", "{0} {1}"));

            BankUser user1 = new BankUser("John", "White", "jwhite", "jwhite");
            BankUser user2 = new BankUser("Angela", "Smith", "asmith", "asmith");
            BankUser user3 = new BankUser("Kenta", "Suzuki", "ksuzuki", "ksuzuki");

            bank.AddUser(user1);
            bank.AddUser(user2);
            bank.AddUser(user3);

            bank.AddAccount(new BankAccount(user1, CurrencyProvider.GetCurrency(1323.12m, bank.GetCurrency("USD")), AccountNumber.Create("84534789450005711")));
            bank.AddAccount(new BankAccount(user1, CurrencyProvider.GetCurrency(782.32m, bank.GetCurrency("EUR")), AccountNumber.Create("12534789451800068")));
            bank.AddAccount(new BankAccount(user1, CurrencyProvider.GetCurrency(2182.98m, bank.GetCurrency("JPY")), AccountNumber.Create("67534000458748357")));
            bank.AddAccount(new BankAccount(user1, CurrencyProvider.GetCurrency(82402m, bank.GetCurrency("ISK")), AccountNumber.Create("67534789455487870")));

            bank.AddAccount(new BankAccount(user2, CurrencyProvider.GetCurrency(18681.20m, bank.GetCurrency("EUR")), AccountNumber.Create("32534789459735154")));
            bank.AddAccount(new BankAccount(user3, CurrencyProvider.GetCurrency(5111.71m, bank.GetCurrency("JPY")), AccountNumber.Create("67534789450120008")));

            bank.Coverter = new CurrencyExchangeConverter(bank.GetCurrency("USD"));

            bank.Coverter.AddRatio(bank.GetCurrency("EUR"), 0.775f);
            bank.Coverter.AddRatio(bank.GetCurrency("JPY"), 95.71f);
            bank.Coverter.AddRatio(bank.GetCurrency("ISK"), 125.96f);
            bank.Coverter.AddRatio(bank.GetCurrency("PLN"), 3.243f);

            //Make some transactions

            IList <BankAccount> user1Accounts = bank.GetAccounts(user1);
            IList <BankAccount> user2Accounts = bank.GetAccounts(user2);
            IList <BankAccount> user3Accounts = bank.GetAccounts(user3);

            Currency amount = CurrencyProvider.GetCurrency("1000",
                                                           user1Accounts[0].CurrencyInfo, Thread.CurrentThread.CurrentCulture);

            bank.Transfer(user1Accounts[0], user1Accounts[1].Number, amount);

            amount = CurrencyProvider.GetCurrency("1000",
                                                  user1Accounts[2].CurrencyInfo, Thread.CurrentThread.CurrentCulture);
            bank.Transfer(user1Accounts[2], user2Accounts[0].Number, amount);

            amount = CurrencyProvider.GetCurrency("5000",
                                                  user1Accounts[3].CurrencyInfo, Thread.CurrentThread.CurrentCulture);
            bank.Transfer(user1Accounts[3], user1Accounts[0].Number, amount);

            amount = CurrencyProvider.GetCurrency("50",
                                                  user1Accounts[1].CurrencyInfo, Thread.CurrentThread.CurrentCulture);
            bank.Transfer(user1Accounts[1], user1Accounts[2].Number, amount);

            amount = CurrencyProvider.GetCurrency("250",
                                                  user3Accounts[0].CurrencyInfo, Thread.CurrentThread.CurrentCulture);
            bank.Transfer(user3Accounts[0], user1Accounts[2].Number, amount);

            amount = CurrencyProvider.GetCurrency("350",
                                                  user3Accounts[0].CurrencyInfo, Thread.CurrentThread.CurrentCulture);
            bank.Transfer(user3Accounts[0], user1Accounts[2].Number, amount);

            //parasoft-end-suppress CS.INTER.ITT));
            return(bank);
        }
Example #13
0
        public List <RateAndAbbr> UpdateSummaryTable(string newCurrency)
        {
            var table = CurrencyProvider.MoneyConvert(CurrencyProvider.Get(newCurrency));

            return(table.Select(tableItem => new RateAndAbbr(tableItem.Value, tableItem.Key.Abbreviation)).ToList());
        }
Example #14
0
 public Decimal ConvertAmount(Decimal amount, String fromcurrency, String tocurrency)
 {
     return(CurrencyProvider.MoneyConvert(amount, fromcurrency, tocurrency));
 }
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            using (var scope = DIHelper.Resolve())
            {
                var daoFactory = scope.Resolve <DaoFactory>();

                var allTags         = daoFactory.TagDao.GetAllTags();
                var contactTags     = allTags.Where(r => r.Key == EntityType.Contact).Select(r => r.Value).ToList();
                var caseTags        = allTags.Where(r => r.Key == EntityType.Case).Select(r => r.Value).ToList();
                var opportunityTags = allTags.Where(r => r.Key == EntityType.Opportunity).Select(r => r.Value).ToList();

                var allListItems           = daoFactory.ListItemDao.GetItems();
                var contactStatusListItems = allListItems.Where(r => r.ListType == ListType.ContactStatus).ToList();
                contactStatusListItems.Insert(0,
                                              new ListItem {
                    ID = 0, Title = CRMCommonResource.NotSpecified, Color = "0"
                });

                var contactStages = contactStatusListItems.ConvertAll(item => new
                {
                    value     = item.ID,
                    title     = item.Title.HtmlEncode(),
                    classname = "colorFilterItem color_" + item.Color.Replace("#", "").ToLower()
                });

                var contactTypeListItems = allListItems.Where(r => r.ListType == ListType.ContactType).ToList();
                contactTypeListItems.Insert(0, new ListItem {
                    ID = 0, Title = CRMContactResource.CategoryNotSpecified
                });

                var contactTypes = contactTypeListItems.ConvertAll(item => new
                {
                    value = item.ID,
                    title = item.Title.HtmlEncode()
                });

                var dealMilestones = daoFactory.DealMilestoneDao.GetAll();

                Converter <string, object> tagsConverter = item => new
                {
                    value = item.HtmlEncode(),
                    title = item.HtmlEncode()
                };
                Converter <InvoiceStatus, object> invoiceStatusesConverter = item => new
                {
                    value       = (int)item,
                    displayname = item.ToLocalizedString(),
                    apiname     = item.ToString().ToLower()
                };

                var invoiceStatuses = new List <InvoiceStatus>(4)
                {
                    InvoiceStatus.Draft,
                    InvoiceStatus.Sent,
                    InvoiceStatus.Rejected,
                    InvoiceStatus.Paid
                }
                .ConvertAll(invoiceStatusesConverter);

                return(new List <KeyValuePair <string, object> >(1)
                {
                    RegisterObject(
                        new
                    {
                        contactStages,
                        contactTypes,
                        contactTags = contactTags.ConvertAll(tagsConverter),
                        caseTags = caseTags.ConvertAll(tagsConverter),
                        dealTags = opportunityTags.ConvertAll(tagsConverter),
                        mailQuotas = MailSender.GetQuotas(),
                        dealMilestones = dealMilestones.ConvertAll(item =>
                                                                   new
                        {
                            value = item.ID,
                            title = item.Title,
                            classname = "colorFilterItem color_" + item.Color.Replace("#", "").ToLower()
                        }),
                        invoiceStatuses,
                        currencies = CurrencyProvider.GetAll()
                    })
                });
            }
        }
        public static void DemandCreateOrUpdate(Invoice invoice)
        {
            if (invoice.IssueDate == DateTime.MinValue ||
                invoice.ContactID <= 0 ||
                invoice.DueDate == DateTime.MinValue ||
                String.IsNullOrEmpty(invoice.Currency) ||
                invoice.ExchangeRate <= 0 ||
                String.IsNullOrEmpty(invoice.Terms) ||
                String.IsNullOrEmpty(invoice.Currency))
            {
                throw new ArgumentException();
            }

            var contact = Global.DaoFactory.GetContactDao().GetByID(invoice.ContactID);

            if (contact == null)
            {
                throw new ArgumentException();
            }
            if (!CanAccessTo(contact))
            {
                throw new SecurityException("Access denied to contact");
            }

            if (invoice.ConsigneeID != 0 && invoice.ConsigneeID != invoice.ContactID)
            {
                var consignee = Global.DaoFactory.GetContactDao().GetByID(invoice.ConsigneeID);
                if (consignee == null)
                {
                    throw new ArgumentException();
                }
                if (!CanAccessTo(consignee))
                {
                    throw new SecurityException("Access denied to consignee contact");
                }
            }

            if (invoice.EntityID != 0)
            {
                var deal = Global.DaoFactory.GetDealDao().GetByID(invoice.EntityID);
                if (deal == null)
                {
                    throw new ArgumentException();
                }
                if (!CanAccessTo(deal))
                {
                    throw new SecurityException("Access denied to opportunity");
                }

                var dealMembers = Global.DaoFactory.GetDealDao().GetMembers(invoice.EntityID);
                if (!dealMembers.Contains(invoice.ContactID))
                {
                    throw new ArgumentException();
                }
            }

            if (CurrencyProvider.Get(invoice.Currency.ToUpper()) == null)
            {
                throw new ArgumentException();
            }
        }
Example #17
0
        public List <Object[]> BuildSalesForecastByClientReport(DateTime fromDate, DateTime toDate)
        {
            var sqlQuery = new SqlQuery("crm_deal tbl_deal")
                           .Select("tbl_deal.contact_id",
                                   "tbl_deal.bid_currency",
                                   @"sum(CASE tbl_deal.bid_type
                                           WHEN 0 THEN
                                             (tbl_deal.bid_value)
                                           ELSE
                                             (tbl_deal.bid_value * tbl_deal.per_period_value * tbl_deal.deal_milestone_probability)
                                           END) AS bid_value",
                                   "count(tbl_deal.id) as count")
                           .LeftOuterJoin("crm_deal_milestone tbl_list", Exp.EqColumns("tbl_deal.deal_milestone_id", "tbl_list.id"))
                           .Where(Exp.Eq("tbl_list.tenant_id", TenantID) & Exp.Eq("tbl_deal.tenant_id", TenantID) &
                                  Exp.Between("tbl_deal.expected_close_date", fromDate, toDate) &
                                  !Exp.Eq("tbl_deal.bid_value", 0) &
                                  !Exp.Eq("tbl_deal.contact_id", 0) &
                                  Exp.Eq("tbl_list.status", (int)DealMilestoneStatus.Open))
                           .GroupBy("tbl_deal.contact_id", "tbl_deal.bid_currency");

            using (var db = GetDb())
            {
                var sqlResult = db.ExecuteList(sqlQuery);

                if (sqlResult.Count == 0)
                {
                    return(sqlResult);
                }

                sqlResult.ForEach(row => row[0] = Global.DaoFactory.GetContactDao().GetByID((int)row[0]).GetTitle());

                sqlResult = sqlResult.GroupBy(row =>
                {
                    var bidCurrency = Convert.ToString(row[1]);

                    if (bidCurrency != Global.TenantSettings.DefaultCurrency.Abbreviation && CurrencyProvider.IsConvertable(bidCurrency))
                    {
                        row[2] = CurrencyProvider.MoneyConvertToDefaultCurrency(Convert.ToDecimal(row[2]), bidCurrency);
                    }

                    return(row[0]);
                }).Select(group => new[]
                {
                    group.Key,
                    group.Sum(p => Convert.ToDecimal(p[2])),
                    group.Sum(p => Convert.ToDecimal(p[3])),
                    0
                }).ToList();

                var totalDeals = sqlResult.Sum(row => Convert.ToInt32(row[2]));

                foreach (var item in sqlResult)
                {
                    item[3] = Convert.ToInt32(item[2]) * 100 / totalDeals;
                }

                return(sqlResult);
            }
        }
Example #18
0
        protected void SaveOrUpdateContact(object sender, CommandEventArgs e)
        {
            try
            {
                var            dao = Global.DaoFactory;
                Contact        contact;
                List <Contact> contactsForSetManager = new List <Contact>();

                var typeAddedContact = Request["typeAddedContact"];

                #region Rights part #1

                ShareType shareType = ShareType.None;// 0 - NotShared, 1 - ReadWriting, 2 - Reading

                if (!String.IsNullOrEmpty(Request["isPublicContact"]))
                {
                    try
                    {
                        shareType = (ShareType)(Convert.ToInt32(Request["isPublicContact"]));
                    }
                    catch (Exception)
                    {
                        throw new ArgumentException();
                    }
                }


                #endregion

                #region BaseInfo

                var companyID = 0;

                if (!String.IsNullOrEmpty(Request["baseInfo_compID"]))
                {
                    companyID = Convert.ToInt32(Request["baseInfo_compID"]);
                }
                else if (!String.IsNullOrEmpty(Request["baseInfo_compName"]))
                {
                    var peopleCompany = new Company
                    {
                        CompanyName = Request["baseInfo_compName"].Trim(),
                        ShareType   = shareType
                    };

                    peopleCompany.ID = dao.GetContactDao().SaveContact(peopleCompany);

                    companyID = peopleCompany.ID;
                    contactsForSetManager.Add(peopleCompany);
                }


                if (typeAddedContact.Equals("people"))
                {
                    contact = new Person
                    {
                        FirstName = Request["baseInfo_firstName"].Trim(),
                        LastName  = Request["baseInfo_lastName"].Trim(),
                        JobTitle  = Request["baseInfo_personPosition"].Trim(),
                        CompanyID = companyID
                    };
                }
                else
                {
                    contact = new Company
                    {
                        CompanyName = Request["baseInfo_companyName"].Trim()
                    };
                }


                contact.About     = !String.IsNullOrEmpty(Request["baseInfo_contactOverview"]) ? Request["baseInfo_contactOverview"].Trim() : null;
                contact.ShareType = shareType;

                #endregion

                #region ContactType and Currency

                contact.ContactTypeID = Convert.ToInt32(Request["baseInfo_contactType"]);
                if (contact.ContactTypeID != 0)
                {
                    var listItem = dao.GetListItemDao().GetByID(contact.ContactTypeID);
                    if (listItem == null)
                    {
                        throw new Exception(CRMErrorsResource.ContactTypeNotFound);
                    }
                }

                contact.Currency = Convert.ToString(Request["baseInfo_currency"]);
                if (!String.IsNullOrEmpty(contact.Currency))
                {
                    var currency = CurrencyProvider.Get(contact.Currency);
                    if (currency == null)
                    {
                        throw new Exception(CRMErrorsResource.CurrencyNotFound);
                    }
                }

                #endregion

                #region Base Operation Of Save/Update

                if (TargetContact != null)
                {
                    contact.ID       = TargetContact.ID;
                    contact.StatusID = TargetContact.StatusID;
                    dao.GetContactDao().UpdateContact(contact);

                    var messageAction = contact is Company ? MessageAction.CompanyUpdated : MessageAction.PersonUpdated;
                    MessageService.Send(HttpContext.Current.Request, messageAction, contact.GetTitle());

                    contact = dao.GetContactDao().GetByID(contact.ID);
                }
                else
                {
                    contact.ID = dao.GetContactDao().SaveContact(contact);

                    var messageAction = contact is Company ? MessageAction.CompanyCreated : MessageAction.PersonCreated;
                    MessageService.Send(HttpContext.Current.Request, messageAction, contact.GetTitle());

                    contact = dao.GetContactDao().GetByID(contact.ID);
                }

                contactsForSetManager.Add(contact);

                #endregion

                #region persons for company

                if (contact is Company)
                {
                    var assignedContactsIDs = new List <int>();

                    if (!String.IsNullOrEmpty(Request["baseInfo_assignedNewContactsIDs"]))
                    {
                        try
                        {
                            var assignedContactsObjs = JArray.Parse(Request["baseInfo_assignedNewContactsIDs"]);
                            var newAssignedContacts  = new List <Contact>();
                            var recordIndex          = 0;

                            foreach (var assignedContactsObj in assignedContactsObjs)
                            {
                                newAssignedContacts.Add(new Person
                                {
                                    ID        = recordIndex,
                                    ShareType = shareType,
                                    CompanyID = contact.ID,
                                    FirstName = assignedContactsObj.Value <String>("FirstName"),
                                    LastName  = assignedContactsObj.Value <String>("LastName")
                                });
                                recordIndex++;
                            }

                            dao.GetContactDao().SaveContactList(newAssignedContacts);

                            if (newAssignedContacts.Count != 0)
                            {
                                contactsForSetManager.AddRange(newAssignedContacts);
                                assignedContactsIDs.AddRange(newAssignedContacts.Select(c => c.ID).ToList());
                            }
                        }
                        catch (Exception ex)
                        {
                            log4net.LogManager.GetLogger("ASC.CRM").Error(ex);
                        }
                    }

                    if (!String.IsNullOrEmpty(Request["baseInfo_assignedContactsIDs"]))
                    {
                        assignedContactsIDs.AddRange(Request["baseInfo_assignedContactsIDs"].Split(',').Select(item => Convert.ToInt32(item)).ToList());
                    }


                    if (TargetContact != null && !CRMSecurity.IsAdmin)
                    {
                        var restrictedMembers = dao.GetContactDao().GetRestrictedMembers(contact.ID);
                        assignedContactsIDs.AddRange(restrictedMembers.Select(m => m.ID).ToList());
                    }

                    dao.GetContactDao().SetMembers(contact.ID, assignedContactsIDs.ToArray());
                }

                #endregion

                #region tags

                var assignedTags = Request["baseInfo_assignedTags"];
                if (assignedTags != null)
                {
                    var oldTagList = dao.GetTagDao().GetEntityTags(EntityType.Contact, contact.ID);
                    foreach (var tag in oldTagList)
                    {
                        dao.GetTagDao().DeleteTagFromEntity(EntityType.Contact, contact.ID, tag);
                    }
                    if (assignedTags != string.Empty)
                    {
                        var tagListInfo = JObject.Parse(assignedTags)["tagListInfo"].ToArray();
                        var newTagList  = tagListInfo.Select(t => t.ToString()).ToArray();
                        dao.GetTagDao().SetTagToEntity(EntityType.Contact, contact.ID, newTagList);
                    }
                }

                #endregion

                #region contact infos (addresses, mailes, phones etc.)

                var contactInfos    = new List <ContactInfo>();
                var addressList     = new Dictionary <int, ContactInfo>();
                var addressTemplate = new JObject();

                foreach (String addressPartName in Enum.GetNames(typeof(AddressPart)))
                {
                    addressTemplate.Add(addressPartName.ToLower(), "");
                }

                var addressTemplateStr = addressTemplate.ToString();

                foreach (var item in Request.Form.AllKeys)
                {
                    if (item.StartsWith("customField_"))
                    {
                        int    fieldID    = Convert.ToInt32(item.Split('_')[1]);
                        String fieldValue = Request.Form[item].Trim();

                        if (contact is Person)
                        {
                            if (!String.IsNullOrEmpty(fieldValue))
                            {
                                dao.GetCustomFieldDao().SetFieldValue(EntityType.Person, contact.ID, fieldID, "");
                            }
                            dao.GetCustomFieldDao().SetFieldValue(EntityType.Person, contact.ID, fieldID, fieldValue);
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(fieldValue))
                            {
                                dao.GetCustomFieldDao().SetFieldValue(EntityType.Company, contact.ID, fieldID, "");
                            }
                            dao.GetCustomFieldDao().SetFieldValue(EntityType.Company, contact.ID, fieldID, fieldValue);
                        }
                    }
                    else if (item.StartsWith("contactInfo_"))
                    {
                        var nameParts       = item.Split('_').Skip(1).ToList();
                        var contactInfoType = (ContactInfoType)Enum.Parse(typeof(ContactInfoType), nameParts[0]);
                        var category        = Convert.ToInt32(nameParts[2]);

                        if (contactInfoType == ContactInfoType.Address)
                        {
                            var index            = Convert.ToInt32(nameParts[1]);
                            var addressPart      = (AddressPart)Enum.Parse(typeof(AddressPart), nameParts[3]);
                            var isPrimaryAddress = Convert.ToInt32(nameParts[4]) == 1;
                            var dataValues       = Request.Form.GetValues(item).Select(n => n.Trim()).ToList();

                            if (!addressList.ContainsKey(index))
                            {
                                var newAddress = new ContactInfo
                                {
                                    Category  = category,
                                    InfoType  = contactInfoType,
                                    Data      = addressTemplateStr,
                                    IsPrimary = isPrimaryAddress,
                                    ContactID = contact.ID
                                };
                                addressList.Add(index, newAddress);
                            }

                            foreach (var data in dataValues)
                            {
                                var addressParts = JObject.Parse(addressList[index].Data);
                                addressParts[addressPart.ToString().ToLower()] = data;
                                addressList[index].Data = addressParts.ToString();
                            }
                            continue;
                        }

                        var isPrimary = Convert.ToInt32(nameParts[3]) == 1;
                        if (Request.Form.GetValues(item) != null)
                        {
                            var dataValues = Request.Form.GetValues(item).Where(n => !string.IsNullOrEmpty(n.Trim())).ToList();

                            contactInfos.AddRange(dataValues.Select(dataValue => new ContactInfo
                            {
                                Category  = category,
                                InfoType  = contactInfoType,
                                Data      = dataValue.Trim(),
                                IsPrimary = isPrimary,
                                ContactID = contact.ID
                            }));
                        }
                    }
                }

                if (addressList.Count > 0)
                {
                    contactInfos.AddRange(addressList.Values.ToList());
                }

                dao.GetContactInfoDao().DeleteByContact(contact.ID);
                dao.GetContactInfoDao().SaveList(contactInfos);

                #endregion

                #region Photo

                var photoPath = Request["uploadPhotoPath"];

                if (!String.IsNullOrEmpty(photoPath))
                {
                    if (photoPath != "null")
                    {
                        if (photoPath.StartsWith(PathProvider.BaseAbsolutePath))
                        {
                            var tmpDirName = photoPath.Substring(0, photoPath.LastIndexOf('/'));
                            ContactPhotoManager.TryUploadPhotoFromTmp(contact.ID, TargetContact == null, tmpDirName);
                        }
                        else
                        {
                            ContactPhotoManager.UploadPhoto(photoPath, contact.ID);
                        }
                    }
                }
                else if (TargetContact != null)
                {
                    ContactPhotoManager.DeletePhoto(TargetContact.ID);
                }
                #endregion


                #region Rights part #2

                SetContactManager(contactsForSetManager);

                #endregion

                Response.Redirect(String.Compare(e.CommandArgument.ToString(), "0", true) == 0
                                      ? String.Format("default.aspx?id={0}{1}", contact.ID,
                                                      contact is Company
                                                          ? ""
                                                          : String.Format("&{0}=people", UrlConstant.Type))
                                      : String.Format("default.aspx?action=manage{0}",
                                                      contact is Company
                                                          ? ""
                                                          : String.Format("&{0}=people", UrlConstant.Type)), false);
                Context.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                log4net.LogManager.GetLogger("ASC.CRM").Error(ex);
                var cookie = HttpContext.Current.Request.Cookies.Get(ErrorCookieKey);
                if (cookie == null)
                {
                    cookie = new HttpCookie(ErrorCookieKey)
                    {
                        Value = ex.Message
                    };
                    HttpContext.Current.Response.Cookies.Add(cookie);
                }
            }
        }
Example #19
0
        public XDocument BuildSalesByStageReport(Guid responsibleID, DateTime fromDate, DateTime toDate)
        {
            var sqlQuery = new SqlQuery("crm_deal_milestone tbl_list")
                           .LeftOuterJoin("crm_deal tbl_deal", Exp.EqColumns("tbl_deal.deal_milestone_id", "tbl_list.id"))
                           .Select("tbl_list.title",
                                   "bid_currency",
                                   @"sum(CASE tbl_deal.bid_type
                                   WHEN 0 THEN
                                     (tbl_deal.bid_value)
                                   ELSE
                                     (tbl_deal.bid_value * tbl_deal.per_period_value)
                                   END) AS bid_value",
                                   "count(tbl_deal.id) as count",
                                   "tbl_list.color")
                           .Where(Exp.Eq("tbl_list.tenant_id", TenantID) & Exp.Eq("tbl_deal.tenant_id", TenantID))
                           .GroupBy("tbl_list.id", "tbl_deal.bid_currency")
                           .OrderBy("tbl_list.sort_order", true);

            if (responsibleID != Guid.Empty)
            {
                sqlQuery.Where(Exp.Eq("tbl_deal.responsible_id", responsibleID));
            }

            if (fromDate > DateTime.MinValue && toDate > DateTime.MinValue)
            {
                sqlQuery.Where(Exp.Ge("tbl_deal.expected_close_date", fromDate) & Exp.Le("tbl_deal.expected_close_date", toDate));
            }

            using (var db = GetDb())
            {
                var sqlResult = db.ExecuteList(sqlQuery);

                if (sqlResult.Count == 0)
                {
                    return(new XDocument());
                }

                var result = sqlResult.GroupBy(row =>
                {
                    var bidCurrency = Convert.ToString(row[1]);

                    if (bidCurrency != Global.TenantSettings.DefaultCurrency.Abbreviation)
                    {
                        row[2] = CurrencyProvider.MoneyConvertToDefaultCurrency(Convert.ToDecimal(row[2]), bidCurrency);
                    }

                    return(row[0]);
                }).Select(group => new[]
                {
                    group.Key,
                    group.Sum(p => Convert.ToDecimal(p[2])),
                    group.Sum(p => Convert.ToDecimal(p[3])),
                    group.First()[4],
                    0
                }).ToList();

                var totalDeals = result.Sum(row => Convert.ToInt32(row[2]));

                if (totalDeals == 0)
                {
                    return(new XDocument());
                }

                for (int index = 0; index < result.Count; index++)
                {
                    result[index][4] = Convert.ToInt32(result[index][2]) * 100 / totalDeals;
                    result[index][2] = result.Skip(index).Sum(row => Convert.ToInt32(row[2]));
                }

                String fromDateStr = String.Empty;

                if (fromDate != DateTime.MinValue)
                {
                    fromDateStr = fromDate.ToShortDateString();
                }

                String toDateStr = String.Empty;

                if (toDate != DateTime.MinValue)
                {
                    toDateStr = toDate.ToShortDateString();
                }

                String responsibleStr = String.Empty;

                if (responsibleID != Guid.Empty)
                {
                    responsibleStr = ASC.Core.CoreContext.UserManager.GetUsers(ASC.Core.SecurityContext.CurrentAccount.ID).DisplayUserName();
                }

                var xDocument = new XDocument(
                    new XElement("report",
                                 new XElement("metadata",
                                              new XElement("filters",
                                                           new XElement("filter", new XAttribute("name", "fromDate"), fromDateStr, new XAttribute("title", CRMCommonResource.From)),
                                                           new XElement("filter", new XAttribute("name", "toDate"), toDateStr, new XAttribute("title", CRMCommonResource.To)),
                                                           new XElement("filter", new XAttribute("name", "responsible"), responsibleStr, new XAttribute("title", CRMCommonResource.Responsible))
                                                           ),
                                              new XElement("totalDeals", totalDeals),
                                              new XElement("description", CRMReportResource.Report_SalesByStage_Description, new XAttribute("title", CRMCommonResource.Description))
                                              ),
                                 new XElement("content",
                                              new XElement("columns",
                                                           new XElement("column", new XAttribute("name", "color"), ""),
                                                           new XElement("column", new XAttribute("name", "title"), CRMDealResource.DealMilestone),
                                                           new XElement("column", new XAttribute("name", "amount"), CRMDealResource.DealAmount),
                                                           new XElement("column", new XAttribute("name", "count"), CRMDealResource.DealCount),
                                                           new XElement("column", new XAttribute("name", "percent"), CRMCommonResource.Part)),
                                              new XElement("rows",
                                                           result.ConvertAll(row =>
                                                                             new XElement("row",
                                                                                          new XElement("title", row[0]),
                                                                                          new XElement("amount", row[1]),
                                                                                          new XElement("count", row[2]),
                                                                                          new XElement("color", row[3]),
                                                                                          new XElement("percent", row[4]))

                                                                             ).ToArray()))
                                 )
                    );

                InsertCommonMetadata(xDocument);

                return(xDocument);
            }
        }
Example #20
0
 public IEnumerable <CurrencyInfoWrapper> GetAvaliableCurrency()
 {
     return(CurrencyProvider.GetAll().ConvertAll(item => new CurrencyInfoWrapper(item)).ToItemList());
 }
Example #21
0
        public string ConvertAmount(decimal amount, string fromCurrency, string toCurrency)
        {
            var conversionResult = CurrencyProvider.MoneyConvert(amount, fromCurrency, toCurrency);

            return(String.Format("{0} {1} = {2} {3}", amount, fromCurrency, conversionResult, toCurrency));
        }