コード例 #1
0
        public void SetAccountSettings(GCAccountSettings accountSettings)
        {
            var settings = new UmbAccountSettings()
            {
                //AccountItemId = accountSettings.AccountItemId,
                ApiKey = accountSettings.ApiKey,
                //ApiUrl = Constants.ApiUrl,
                ApiUserName      = accountSettings.Username,
                DateFormat       = accountSettings.DateFormat,
                GatherContentUrl = accountSettings.GatherContentUrl
            };

            var query           = new Sql().Select("*").From <UmbAccountSettings>();
            var accountSettingU = this.ContextDatabase.Database.Fetch <UmbAccountSettings>(query).FirstOrDefault();

            if (accountSettingU != null)
            {
                settings.Id = accountSettingU.Id;
                ContextDatabase.Database.Update("gcAccountSettings", "Id", settings);
            }
            else
            {
                ContextDatabase.Database.Save("gcAccountSettings", "Id", settings);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="itemsRepository"></param>
        /// <param name="mappingRepository"></param>
        /// <param name="itemsService"></param>
        /// <param name="mappingManager"></param>
        /// <param name="importManager"></param>
        /// <param name="accountsService"></param>
        /// <param name="projectsService"></param>
        /// <param name="templateService"></param>
        /// <param name="cacheManager"></param>
        /// <param name="gcAccountSettings"></param>
        public UpdateManager(
            IItemsRepository itemsRepository,
            IMappingRepository mappingRepository,
            IItemsService itemsService,
            IMappingManager mappingManager,
            IImportManager importManager,
            IAccountsService accountsService,
            IProjectsService projectsService,
            ITemplatesService templateService,
            ICacheManager cacheManager,
            GCAccountSettings gcAccountSettings)
            : base(accountsService, projectsService, templateService, cacheManager)
        {
            ItemsRepository = itemsRepository;

            MappingRepository = mappingRepository;

            ItemsService = itemsService;

            MappingManager = mappingManager;

            ImportManager = importManager;

            GcAccountSettings = gcAccountSettings;
        }
コード例 #3
0
        public GCAccountSettings GetAccountSettings()
        {
            var query             = new Sql().Select("*").From <UmbAccountSettings>();
            var accountSettingU   = this.ContextDatabase.Database.Fetch <UmbAccountSettings>(query).FirstOrDefault();
            var gcAccountSettings = new GCAccountSettings();

            if (accountSettingU != null)
            {
                var tenantName  = string.Empty;
                var tenantMatch = System.Text.RegularExpressions.Regex.Match(accountSettingU.GatherContentUrl, @"^(http(s)?:\/\/)?(?<tenant>.*)\.gathercontent\.com(\/)?$");
                if (tenantMatch.Groups["tenant"] != null)
                {
                    tenantName = tenantMatch.Groups["tenant"].Value.ToLower();
                }

                gcAccountSettings.ApiKey           = accountSettingU.ApiKey;
                gcAccountSettings.ApiUrl           = Constants.ApiUrl;
                gcAccountSettings.DateFormat       = accountSettingU.DateFormat;
                gcAccountSettings.ImportDateFormat = accountSettingU.ImportDateFormat;
                gcAccountSettings.GatherContentUrl = accountSettingU.GatherContentUrl;
                gcAccountSettings.Username         = accountSettingU.ApiUserName;
                gcAccountSettings.TenantName       = tenantName;
            }

            gcAccountSettings.CmsVersion = UmbracoVersion.Current.ToString();

            return(gcAccountSettings);
        }
コード例 #4
0
 public TestConnectionManager(
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     ICacheManager cacheManager,
     GCAccountSettings gcAccountSettings) : base(accountsService, projectsService, templateService, cacheManager, gcAccountSettings)
 {
 }
コード例 #5
0
        protected BaseService(GCAccountSettings accountSettings)
        {
            _apiUrl   = accountSettings.ApiUrl;
            _apiKey   = accountSettings.ApiKey;
            _userName = accountSettings.Username;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
        }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="accountsService"></param>
 /// <param name="projectsService"></param>
 /// <param name="templateService"></param>
 /// <param name="cacheManager"></param>
 public BaseManager(IAccountsService accountsService, IProjectsService projectsService, ITemplatesService templateService, ICacheManager cacheManager, GCAccountSettings gcAccountSettings)
 {
     AccountsService   = accountsService;
     ProjectsService   = projectsService;
     TemplatesService  = templateService;
     GcAccountSettings = gcAccountSettings;
     CacheManager      = cacheManager;
 }
コード例 #7
0
 public MappingManager(
     IMappingRepository mappingRepository,
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     IItemsService itemService,
     ICacheManager cacheManager,
     GCAccountSettings accountSettings)
     : base(accountsService, projectsService, templateService, cacheManager)
 {
     AccountSettings   = accountSettings;
     MappingRepository = mappingRepository;
     ItemService       = itemService;
     TemplateService   = templateService;
 }
コード例 #8
0
 public ImportManager(
     IItemsRepository itemsRepository,
     IMappingRepository mappingRepository,
     IItemsService itemsService,
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     ICacheManager cacheManager,
     GCAccountSettings gcAccountSettings)
     : base(accountsService, projectsService, templateService, cacheManager, gcAccountSettings)
 {
     ItemsRepository   = itemsRepository;
     MappingRepository = mappingRepository;
     ItemsService      = itemsService;
 }
コード例 #9
0
 public MappingManager(
     IMappingRepository mappingRepository,
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     IItemsService itemService,
     ICacheManager cacheManager,
     ILogger logger,
     GCAccountSettings accountSettings)
     : base(accountsService, projectsService, templateService, cacheManager, accountSettings)
 {
     MappingRepository = mappingRepository;
     ItemService       = itemService;
     Log             = logger ?? new NullLogger();
     TemplateService = templateService;
 }
コード例 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="itemsRepository"></param>
 /// <param name="mappingRepository"></param>
 /// <param name="itemsService"></param>
 /// <param name="accountsService"></param>
 /// <param name="projectsService"></param>
 /// <param name="templateService"></param>
 /// <param name="cacheManager"></param>
 /// <param name="logger"></param>
 /// <param name="gcAccountSettings"></param>
 public UpdateManager(
     IItemsRepository itemsRepository,
     IMappingRepository mappingRepository,
     IItemsService itemsService,
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     ICacheManager cacheManager,
     ILogger logger,
     GCAccountSettings gcAccountSettings)
     : base(accountsService, projectsService, templateService, cacheManager, gcAccountSettings)
 {
     ItemsRepository   = itemsRepository;
     MappingRepository = mappingRepository;
     ItemsService      = itemsService;
     Log = logger ?? new NullLogger();
 }
コード例 #11
0
 public void Post(GCAccountSettings model)
 {
     if (model == null)
     {
         throw new Exception("Gather Content settings is null");
     }
     try
     {
         _accountSettingManager.SetSettings(model);
     }
     catch (WebException exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                                     exception.Message + " Please check your credentials"));
     }
     catch (Exception exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Message));
     }
 }
コード例 #12
0
 public IHttpActionResult Post(GCAccountSettings model)
 {
     if (model == null)
     {
         BadRequest("Gather Content settings is null");
     }
     try
     {
         FactoryService.Managers.AccountSettingManager.SetSettings(model);
         return(Ok());
     }
     catch (WebException exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         return(BadRequest(exception.Message + " Please check your credentials"));
     }
     catch (Exception exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         return(BadRequest(exception.Message));
     }
 }
コード例 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="accountSettings"></param>
 public ProjectsService(GCAccountSettings accountSettings)
     : base(accountSettings)
 {
 }
コード例 #14
0
 public void SetSettings(GCAccountSettings accountSettings)
 {
     FactoryRepository.Repositories.AccountRepository.SetAccountSettings(accountSettings);
 }
コード例 #15
0
 protected BaseService(GCAccountSettings accountSettings)
 {
     _apiUrl   = accountSettings.ApiUrl;
     _apiKey   = accountSettings.ApiKey;
     _userName = accountSettings.Username;
 }
コード例 #16
0
 public DropTreeManager(IDropTreeRepository dropTreeRepository, IAccountsRepository accountsRepository, GCAccountSettings gcAccountSettings)
 {
     AccountsRepository = accountsRepository;
     GcAccountSettings  = gcAccountSettings;
     DropTreeRepository = dropTreeRepository;
 }
コード例 #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="accountSettings"></param>
 public ItemsService(GCAccountSettings accountSettings)
     : base(accountSettings)
 {
 }
コード例 #18
0
 public TemplatesService(GCAccountSettings accountSettings)
     : base(accountSettings)
 {
 }
コード例 #19
0
 public void SetSettings(GCAccountSettings accountSettings)
 {
     _accountsRepository.SetAccountSettings(accountSettings);
 }