Example #1
0
        public GenericODataController(IRepository <TEntity> repository)
        {
            var cacheManager = EngineContext.Current.Resolve <ICacheManager>();

            this.Service = new GenericDataService <TEntity>(cacheManager, repository);
            this.Logger  = LoggingUtilities.Resolve();
        }
Example #2
0
 protected KoreController()
 {
     WorkContext = EngineContext.Current.Resolve <IWebWorkContext>();
     T           = LocalizationUtilities.Resolve();
     Logger      = LoggingUtilities.Resolve();
     //Logger = NullLogger.Instance;
 }
Example #3
0
 public AppDataFolder(IAppDataFolderRoot root, IVirtualPathMonitor virtualPathMonitor)
 {
     _root = root;
     _virtualPathMonitor = virtualPathMonitor;
     T      = NullLocalizer.Instance;
     Logger = LoggingUtilities.Resolve();
 }
Example #4
0
        //public IRepository<TEntity> Repository
        //{
        //    get { return repository; }
        //}

        #endregion Properties

        #region Constructor

        public GenericDataService(ICacheManager cacheManager, IRepository <TEntity> repository)
        {
            this.cacheManager = cacheManager;
            this.repository   = repository;
            this.Logger       = LoggingUtilities.Resolve();

            // Resolving eventBus this way for now instead of via constructor injection, because
            //  putting it into the constructor will mean changing a LOT of classes in multiple projects..
            //  That will take too much time. Might do it in future, if necessary.
            this.eventBus = EngineContext.Current.Resolve <IEventBus>();
        }
Example #5
0
        public void Execute()
        {
            int maxTries;
            int messagesPerBatch;

            // TODO: This will now be a problem because of tenants feature.. we need to do this task for each tenant
            var smtpSettings = EngineContext.Current.Resolve <SmtpSettings>();

            if (!string.IsNullOrEmpty(smtpSettings.Host))
            {
                maxTries         = smtpSettings.MaxTries;
                messagesPerBatch = smtpSettings.MessagesPerBatch;
            }
            else
            {
                maxTries         = 3;
                messagesPerBatch = 50;
            }

            var emailSender = EngineContext.Current.Resolve <IEmailSender>();
            var providers   = EngineContext.Current.ResolveAll <IQueuedMessageProvider>();

            //var componentContext = EngineContext.Current.Resolve<IComponentContext>();
            //var logger = componentContext.Resolve<ILogger>(new TypedParameter(typeof(Type), typeof(ProcessQueuedMailTask)));
            var logger      = LoggingUtilities.Resolve();
            var workContext = EngineContext.Current.Resolve <IWorkContext>();

            foreach (var provider in providers)
            {
                var queuedEmails = provider.GetQueuedEmails(workContext.CurrentTenant.Id, maxTries, messagesPerBatch);

                if (!queuedEmails.Any())
                {
                    continue;
                }

                foreach (var queuedEmail in queuedEmails)
                {
                    try
                    {
                        var mailMessage = queuedEmail.GetMailMessage();
                        emailSender.Send(mailMessage);
                        provider.OnSendSuccess(queuedEmail);
                    }
                    catch (Exception x)
                    {
                        logger.Error(string.Format("Error sending e-mail. {0}", x.Message), x);
                        provider.OnSendError(queuedEmail);
                    }
                }
            }
        }
Example #6
0
        public LuceneSearchBuilder(Directory directory)
        {
            _directory = directory;
            Logger     = LoggingUtilities.Resolve();

            _count          = MaxResults;
            _skip           = 0;
            _clauses        = new List <BooleanClause>();
            _filters        = new List <BooleanClause>();
            _sort           = string.Empty;
            _comparer       = 0;
            _sortDescending = true;

            InitPendingClause();
        }
Example #7
0
        protected virtual ViewEngineResult FindThemeableView(ControllerContext controllerContext, string viewName, string masterName, bool useCache, bool mobile)
        {
            string[] viewPathSearchLocations;
            string[] masterPathSearchedLocations;

            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentException("View name cannot be null or empty.", "viewName");
            }

            var    theme          = GetCurrentTheme(mobile);
            string requiredString = controllerContext.RouteData.GetRequiredString("controller");
            string viewPath       = this.GetPath(controllerContext, this.ViewLocationFormats, this.AreaViewLocationFormats, "ViewLocationFormats", viewName, requiredString, theme, "View", useCache, mobile, out viewPathSearchLocations);
            string masterPath     = this.GetPath(controllerContext, this.MasterLocationFormats, this.AreaMasterLocationFormats, "MasterLocationFormats", masterName, requiredString, theme, "Master", useCache, mobile, out masterPathSearchedLocations);

            if (!string.IsNullOrEmpty(viewPath) && (!string.IsNullOrEmpty(masterPath) || string.IsNullOrEmpty(masterName)))
            {
                return(new ViewEngineResult(this.CreateView(controllerContext, viewPath, masterPath), this));
            }

            // 2015.04.23: This happened one time, but could not be replicated. Then after adding logging
            //  and trying again, it stopped happening... without having changed any logic (may have been a
            //  problem on that 1 production server only.
            if (viewPathSearchLocations == null)
            {
                var logger = LoggingUtilities.Resolve();
                logger.Error(
                    string.Format(
                        "Could not find locations for:{0}ViewName: {1}{0}MasterName: {2}",
                        System.Environment.NewLine,
                        viewName,
                        masterName));

                viewPathSearchLocations = new string[0];
            }

            if (masterPathSearchedLocations == null)
            {
                masterPathSearchedLocations = new string[0];
            }

            return(new ViewEngineResult(viewPathSearchLocations.Union <string>(masterPathSearchedLocations)));
        }
Example #8
0
        public void InitializeDatabase(TContext context)
        {
            bool dbExists;

            try
            {
                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    dbExists = context.Database.Exists();
                }
            }
            catch
            {
                dbExists = false;
            }

            if (dbExists)
            {
                var databaseInitializerHelper = EngineContext.Current.Resolve <IKoreEntityFrameworkHelper>();
                databaseInitializerHelper.EnsureTables(context);
            }
            else
            {
                //please don't remove this.. if you want it to work, then add "Persist Security Info=true" to your connection string.
                try
                {
                    var defaultInitializer = new CreateDatabaseIfNotExists <TContext>();
                    defaultInitializer.InitializeDatabase(context);
                }
                catch (Exception x)
                {
                    var logger = LoggingUtilities.Resolve();
                    logger.Error(x.Message, x);
                }
            }
        }
Example #9
0
 public GenericODataController(IGenericDataService <TEntity> service)
 {
     this.Service = service;
     this.Logger  = LoggingUtilities.Resolve();
 }
Example #10
0
 public DefaultVirtualPathMonitor(IClock clock)
 {
     _clock = clock;
     _thunk = new Thunk(this);
     Logger = LoggingUtilities.Resolve();
 }
Example #11
0
 public EntityFrameworkRepository(IDbContextFactory contextFactory, Lazy <IKoreEntityFrameworkHelper> efHelper)
 {
     this.contextFactory = contextFactory;
     this.efHelper       = efHelper;
     this.logger         = LoggingUtilities.Resolve();
 }
Example #12
0
        public static DataTable ReadCsv(this FileInfo fileInfo, bool hasHeaderRow, params string[] delimeters)
        {
            if (delimeters.IsNullOrEmpty())
            {
                delimeters = new[] { "," };
            }

            using (var parser = new TextFieldParser(fileInfo.FullName))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(delimeters);
                parser.HasFieldsEnclosedInQuotes = false;

                var table = new DataTable(Path.GetFileNameWithoutExtension(fileInfo.Name));

                int lineNumber = 1;
                while (!parser.EndOfData)
                {
                    string[] fields;
                    try
                    {
                        fields = parser.ReadFields();
                    }
                    catch (MalformedLineException x)
                    {
                        var logger = LoggingUtilities.Resolve();
                        logger.Error("Error when reading CSV file: " + fileInfo.FullName, x);
                        continue;
                    }

                    if (lineNumber == 1)
                    {
                        if (hasHeaderRow)
                        {
                            foreach (string field in fields)
                            {
                                table.Columns.Add(field);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < fields.Count(); i++)
                            {
                                table.Columns.Add("Column" + (i + 1));
                            }
                            table.Rows.Add(fields);
                        }
                    }
                    else
                    {
                        var row = table.NewRow();
                        for (int i = 0; i < table.Columns.Count; i++)
                        {
                            row[i] = fields[i];
                        }
                        table.Rows.Add(row);

                        //table.Rows.Add(fields); //  <-- this version breaks when accidenteally have extra comma at end of line
                    }

                    lineNumber++;
                }

                return(table);
            }
        }
Example #13
0
 public Notifier()
 {
     Logger  = LoggingUtilities.Resolve();
     entries = new List <NotifyEntry>();
 }
Example #14
0
 static PluginManager()
 {
     Logger = LoggingUtilities.Resolve();
 }