Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Check for a SolrConnection
            string solrString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            if (!string.IsNullOrEmpty(solrString))
            {
                SolrService.Init(solrString);
            }
            else
            {
                Console.Error.WriteLine("Could not initialize connection to the Solr server. Please verify that your SolrServer app property is correct.");
                return;
            }

            if (args.Length > 0)
            {
                Database.SetInitializer <CatfishDbContext>(null);
                using (CatfishDbContext Db = new CatfishDbContext())
                {
                    if (args[0] == "import")
                    {
                        import(Db);
                    }
                    else if (args[0] == "export")
                    {
                        export(Db);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void CanInitializeSolr()
        {
            string connectionString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            SolrService.Init(connectionString);

            Assert.IsTrue(SolrService.IsInitialized);
            Assert.IsNotNull(SolrService.SolrOperations);
        }
Ejemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (e.Args.Contains("GenerateIndex"))
            {
                SolrService.Init(this);
                //SolrService solrSrv = new SolrService(new ApplicationDbContext());
                //solrSrv.GenerateSolrIndexTemplate(Console.Out, new Type[] { typeof(MainForm) }, true);
            }
        }
Ejemplo n.º 4
0
 public void TestFailedServiceInitialization()
 {
     try
     {
         SolrService.Init(null);
         Assert.Fail("Initialization passed with no connection string.");
     }
     catch (InvalidOperationException e)
     {
         // Failed to initialize. This passes the test.
         Assert.IsTrue(true);
     }
 }
Ejemplo n.º 5
0
 public void TestFailedServiceInitialization()
 {
     try
     {
         SolrService.Init((string)null);
         Assert.Fail("Initialization passed with no connection string.");
     }
     catch (InvalidOperationException ex)
     {
         // Failed to initialize. This passes the test.
         Console.WriteLine("Exception : {0}", ex.Message);
         Assert.IsTrue(true);
     }
 }
Ejemplo n.º 6
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Metadata provider
            ModelMetadataProviders.Current = new Catfish.Areas.Manager.Helpers.ModelMetadataProvider();

            //Custom model binders
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(FormField), new XmlModelBinder());
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(OptionsField), new XmlModelBinder());
            // ModelBinders.Binders.Add(typeof(DateTime), new DateModelBinder());

            //Additional CSS and Javascripts
            Hooks.Head.Render += (ui, str, page, post) =>
            {
                // Do something
                str.Append("<script src=\"/Scripts/jquery-2.1.1.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/jquery-ui.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/bootstrap.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/jquery-ui.min.css\" />");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/bootstrap.min.css\" />");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/Custom.css\" />");
            };

            //Adding manager menu items
            AddManagerMenus();

            //Multilingual menu
            Hooks.Menu.RenderItemLink = ViewHelper.MultilingualMenuRenderer;

            // Setup Validation Attributes
            FormFieldValidationAttribute.CurrentLanguageCodes = () => new string[] { ViewHelper.GetActiveLanguage().TwoLetterISOLanguageName };

            // Check for a SolrConnection
            string solrString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            if (!string.IsNullOrEmpty(solrString))
            {
                SolrService.Init(solrString);
            }
        }
Ejemplo n.º 7
0
        public CatfishDbContext(System.Data.Common.DbConnection connection, bool contextOwnsConnection) : base(connection, contextOwnsConnection)
        {
            //if (SolrService.IsInitialized)
            //{
            //    solr = ServiceLocator.Current.GetInstance<ISolrOperations<Dictionary<string, object>>>();
            //}
            string solrString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            if (!string.IsNullOrEmpty(solrString))
            {
                SolrService.Init(solrString);
            }

            var sqlTimeout = ConfigurationManager.AppSettings["SqlConnectionTimeoutSeconds"];

            if (!string.IsNullOrEmpty(sqlTimeout))
            {
                ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = int.Parse(sqlTimeout);
            }
        }
Ejemplo n.º 8
0
        void Application_Start(object sender, EventArgs e)
        {
            // Load Plugins
            LoadPlugins();
            ControllerBuilder.Current.SetControllerFactory(typeof(PluginControllerFactory));
            ViewEngines.Engines.Add(PluginContext.Current.ViewEngine);

            // Code that runs on application startup
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            RegisterPluginRoutes();

            //Metadata provider
            ModelMetadataProviders.Current = new Catfish.Areas.Manager.Helpers.ModelMetadataProvider();

            //Custom model binders
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(FormField), new XmlModelBinder());
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(OptionsField), new XmlModelBinder());
            // ModelBinders.Binders.Add(typeof(DateTime), new DateModelBinder());

            //Additional CSS and Javascripts
            Hooks.Head.Render += (ui, str, page, post) =>
            {
                // Do something
                str.Append("<script src=\"/Scripts/jquery-2.1.1.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/jquery-ui.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/bootstrap.min.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/catfish-global.js\" type=\"text/javascript\" ></script>");
                str.Append("<script src=\"/Scripts/solrQueryParser.js\" type=\"text/javascript\" ></script>");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/jquery-ui.min.css\" />");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/bootstrap.min.css\" />");
                str.Append("<link type=\"text/css\" rel=\"stylesheet\" href=\"/content/Custom.css\" />");
            };

            //Adding manager menu items
            AddManagerMenus();

            //Multilingual menu
            Hooks.Menu.RenderItemLink = ViewHelper.MultilingualMenuRenderer;
            //register multiple languange for the site --May 17 2018
            foreach (string lang in ConfigHelper.LanguagesCodes)
            {
                Piranha.WebPages.WebPiranha.RegisterCulture(lang, new System.Globalization.CultureInfo(lang));
            }


            // Setup Validation Attributes
            FormFieldValidationAttribute.CurrentLanguageCodes = () => new string[] { ViewHelper.GetActiveLanguage().TwoLetterISOLanguageName };

            // Check for a SolrConnection
            string solrString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            if (!string.IsNullOrEmpty(solrString))
            {
                SolrService.Init(solrString);
            }

            CFXmlModel.InitializeExternally = (CFXmlModel model) =>
            {
                if (HttpContext.Current.User != null) // If we are just loading a model, this may be null.
                {
                    string guid = HttpContext.Current.User.Identity.Name;
                    model.CreatedByGuid = guid;

                    // This is done to avoid a massive performance hit when loading models from the database
                    var ctx = Catfish.Contexts.UserContext.GetContextForUser(guid);

                    if (ctx != null && ctx.User != null)
                    {
                        model.CreatedByName = ctx.User.Firstname + " " + ctx.User.Surname;
                    }
                }
            };

            AddPublicUserListIfDoesNotExist();


            // Initialize Plugins
            InitializePlugins();
        }
Ejemplo n.º 9
0
        public void TestSuccessServiceInitialization()
        {
            string connectionString = System.Configuration.ConfigurationManager.AppSettings["SolrServer"];

            SolrService.Init(connectionString);
        }