Beispiel #1
0
        public ISettings GetDefault()
        {
            var languageName = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

            var findedCurrency =
                CurrencyProvider.GetAll().Find(item => String.Compare(item.CultureName, languageName, true) == 0);

            if (findedCurrency != null)
            {
                return new CRMSettings
                       {
                           defaultCurrency              = findedCurrency.Abbreviation,
                           IsConfiguredPortal           = false,
                           ChangeContactStatusGroupAuto = null,
                           WebFormKey        = Guid.Empty,
                           SMTPServerSetting = new SMTPServerSetting()
                       }
            }
            ;

            return(new CRMSettings
            {
                defaultCurrency = "USD",
                IsConfiguredPortal = false,
                ChangeContactStatusGroupAuto = null,
                WebFormKey = Guid.Empty,
                SMTPServerSetting = new SMTPServerSetting()
            });
        }
    }
Beispiel #2
0
        public override ISettings GetDefault()
        {
            var languageName = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

            var findedCurrency = CurrencyProvider.GetAll().Find(item => String.Compare(item.CultureName, languageName, true) == 0);

            return(new CRMSettings
            {
                defaultCurrency = findedCurrency != null ? findedCurrency.Abbreviation : "USD",
                IsConfiguredPortal = false,
                ChangeContactStatusGroupAuto = null,
                AddTagToContactGroupAuto = null,
                WriteMailToHistoryAuto = false,
                WebFormKey = Guid.Empty,
                InvoiceSetting = InvoiceSetting.DefaultSettings
            });
        }
        public static void DataContactActionView(BasePage page, Contact targetContact, List <CustomField> data, List <ContactInfo> networks)
        {
            var daoFactory = page.DaoFactory;

            var tags = targetContact != null?daoFactory.TagDao.GetEntityTags(EntityType.Contact, targetContact.ID) : new string[]
            {
            };
            var availableTags = daoFactory.TagDao.GetAllTags(EntityType.Contact).Where(item => !tags.Contains(item));

            String json;

            using (var stream = new MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(data.GetType());
                serializer.WriteObject(stream, data);
                json = Encoding.UTF8.GetString(stream.ToArray());
            }

            var listItems = daoFactory.ListItemDao.GetItems(ListType.ContactType);

            var presetCompanyForPersonJson = "";

            if (targetContact != null && targetContact is Person && ((Person)targetContact).CompanyID > 0)
            {
                var company = daoFactory.ContactDao.GetByID(((Person)targetContact).CompanyID);
                if (company == null)
                {
                    LogManager.GetLogger("ASC.CRM").ErrorFormat("Can't find parent company (CompanyID = {0}) for person with ID = {1}", ((Person)targetContact).CompanyID, targetContact.ID);
                }
                else
                {
                    presetCompanyForPersonJson = JsonConvert.SerializeObject(new
                    {
                        id           = company.ID,
                        displayName  = company.GetTitle().HtmlEncode().ReplaceSingleQuote().Replace(@"\", @"\\"),
                        smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(company.ID, true)
                    });
                }
            }

            var presetPersonsForCompanyJson = "";

            if (targetContact != null && targetContact is Company)
            {
                var people = daoFactory.ContactDao.GetMembers(targetContact.ID);
                if (people.Count != 0)
                {
                    presetPersonsForCompanyJson = JsonConvert.SerializeObject(people.ConvertAll(item => new
                    {
                        id           = item.ID,
                        displayName  = item.GetTitle().HtmlEncode().ReplaceSingleQuote().Replace(@"\", @"\\"),
                        smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(item.ID, false)
                    }));
                }
            }

            var script = String.Format(@"
                                var customFieldList = {0};
                                var contactNetworks = {1};
                                var contactActionTags = {2};
                                var contactActionAvailableTags = {3};
                                var contactAvailableTypes = {4};
                                var presetCompanyForPersonJson = '{5}';
                                var presetPersonsForCompanyJson = '{6}';
                                var twitterSearchEnabled = {7};
                                var contactActionCurrencies = {8};",
                                       json,
                                       JsonConvert.SerializeObject(networks),
                                       JsonConvert.SerializeObject(tags.ToList().ConvertAll(t => t.HtmlEncode())),
                                       JsonConvert.SerializeObject(availableTags.ToList().ConvertAll(t => t.HtmlEncode())),
                                       JsonConvert.SerializeObject(
                                           listItems.ConvertAll(n => new
            {
                id    = n.ID,
                title = n.Title.HtmlEncode()
            })),
                                       presetCompanyForPersonJson,
                                       presetPersonsForCompanyJson,
                                       IsTwitterSearchEnabled.ToString().ToLower(),
                                       JsonConvert.SerializeObject(CurrencyProvider.GetAll())
                                       );

            page.RegisterInlineScript(script, onReady: false);
        }