Пример #1
0
        public void DoesAllStatsGetProcessed()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\StatConfiguration.xml";
            XMLConnection xmlConnection = new XMLConnection(settings);

            DataProviderSettings textfileSettings = new DataProviderSettings();

            textfileSettings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\storage.txt";
            textFileConnection        = new TextFileConnection(textfileSettings);

            DataProviderSettings seqSettings = new DataProviderSettings();

            seqSettings.Location = "http://localhost:5341/";
            seqSettings.APIKey   = "MbZ6wyBSuTVaYNfErgkO";
            seqConnection        = new SeqDataConnection(seqSettings);

            statConfiguration = new StatConfiguration(xmlConnection, "5");

            StatProcessor statProcessor = new StatProcessor(statConfiguration, seqConnection, textFileConnection);
            var           actual        = statProcessor.Run();
            var           expected      = 1;

            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        ///  Init the tree and the connection
        /// </summary>
        /// <param name="pGVSTreeName"></param>
        public GVSTreeWithRoot(string pGVSTreeName)
        {
            var t    = DateTime.Now.Subtract(new DateTime(1970, 01, 01, 01, 0, 0, 0));
            var time = (long)(t.TotalMilliseconds);

            this.gvsTreeId    = time;
            this.gvsTreeNodes = new HashSet <GVSTreeNode>();
            this.gvsTreeName  = pGVSTreeName ?? "";

            var gvsPortFile = AppSettings[GVSPORTFILE];
            var gvsHost     = AppSettings[GVSHOST];
            var gvsPort     = AppSettings[GVSPORT];

            if (gvsPortFile != null)
            {
                try{
                    Console.WriteLine("Load socketinformation from " + gvsPortFile);
                    var reader = new XmlTextReader(gvsPortFile);
                    while (reader.Read())
                    {
                        if (reader.IsStartElement("Port"))
                        {
                            reader.Read();
                            port = int.Parse(reader.Value);
                        }
                        if (reader.IsStartElement("Host"))
                        {
                            reader.Read();
                            host = reader.Value.ToString();
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine("Fehler Portfile");
                    Console.WriteLine(ex.Message);
                }
            }
            else if (gvsHost != null && gvsPort != null)
            {
                try{
                    Console.WriteLine("Load Socketinformation from AppConfig (Host,Port)");
                    this.host = gvsHost;
                    this.port = int.Parse(gvsPort);
                }
                catch (Exception ex) {
                    Console.WriteLine("port or host failed");
                    Console.WriteLine(ex.Message);
                }
            }

            else
            {
                Console.WriteLine("Keine Connection angaben. Lokaler Server. Port auf 3000");
                this.host = "127.0.0.1";
                this.port = 3000;
            }
            xmlConnection = new XMLConnection(host, port);
            xmlConnection.connectToServer();
        }
Пример #3
0
        public void Read_Source_XML_If_File_Exists()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\StatConfiguration.xml";
            xmlConnection     = new XMLConnection(settings);

            var expected = true;
            var actual   = (XmlReader)xmlConnection.Read(null);

            Assert.AreEqual(expected, actual != null);
        }
Пример #4
0
        public void Read_Source_XML_If_File_Is_Invalid()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "sdlkfjsdljf";
            xmlConnection     = new XMLConnection(settings);

            XmlReader expected = null;
            var       actual   = (string)xmlConnection.Read(null);

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void Read_Source_XML_If_File_Does_Not_Exist()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "test.txt";
            xmlConnection     = new XMLConnection(settings);

            XmlReader expected = null;
            var       actual   = (string)xmlConnection.Read(null);

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        public void Deserialize_XML_If_Path_Invalid()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\StatConfiguration.xml";
            XMLConnection xmlConnection = new XMLConnection(settings);

            List <StatElement> expected = null;
            var actual = xmlConnection.Deserialize <List <StatElement> >();

            Assert.AreEqual(expected, actual);
        }
        protected void Application_Start()
        {
            var typeConnectionString = ConfigurationManager.AppSettings["typeConnection"];
            var typeConnection       = GetTypeConnection(typeConnectionString);

            ConnectionBuilder connectionBuilder;

            switch (typeConnection)
            {
            case TypeConnection.XML:
                connectionBuilder = new XMLConnection();
                break;

            case TypeConnection.Hibernate:
                connectionBuilder = new HibernateConnection();
                break;

            default:
                throw new Exception("Unknown type of connection.");
            }

            IUnitOfWork unitOfWork = connectionBuilder.GetUnitOfWork();

            SessionManager.SetUnitOfWork(unitOfWork);

            string luceneFolderRelativePath = ConfigurationManager.ConnectionStrings["lucene"].ConnectionString;
            string lucenePath = $"{luceneFolderRelativePath}/{typeConnectionString}";
            var    luceneRepositoryFactory = new LuceneRepositoryFactory(lucenePath);

            SessionManager.SetLuceneRepositoryFactory(luceneRepositoryFactory);

            string          cacheTimeValue  = ConfigurationManager.AppSettings["cacheTime"];
            CacheRepository cacheRepository = new CacheRepository(int.Parse(cacheTimeValue));

            SessionManager.SetCacheRepository(cacheRepository);

            connectionBuilder.CreateRepositories();

            var updateLuceneValue = ConfigurationManager.AppSettings["updateLucene"];

            if (bool.Parse(updateLuceneValue))
            {
                new NewsPostService().UpdateLucene();
            }

            GlobalFilters.Filters.Add(new ElmahExceptionLogger());

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
        public void GetConfiguration_If_Path_Does_Not_Exist()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = Guid.NewGuid().ToString();
            XMLConnection xmlConnection = new XMLConnection(settings);

            StatConfiguration  config   = new StatConfiguration(xmlConnection, "2");
            List <StatElement> expected = null;
            var actual = (List <StatElement>)config.GetConfiguration <List <StatElement> >();

            Assert.AreEqual(expected, actual);
        }
        public void GetConfiguration_If_Interval_Is_Null()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\StatConfiguration.xml";
            XMLConnection xmlConnection = new XMLConnection(settings);

            StatConfiguration config = new StatConfiguration(xmlConnection, null);
            var expected             = 1;
            var actual = (List <StatElement>)config.GetConfiguration <List <StatElement> >();

            Assert.AreEqual(expected, actual.Count);
        }
        public void Check_If_Interval_Is_One_when_Setup_Is_Invalid()
        {
            DataProviderSettings settings = new DataProviderSettings();

            settings.Location = "C:\\Dev\\DevApps\\StatSnapShotter\\StatSnapShotter\\StatConfiguration.xml";
            XMLConnection xmlConnection = new XMLConnection(settings);

            StatConfiguration config = new StatConfiguration(xmlConnection, "sdfdsf");
            var expected             = 1;
            var actual = config.Interval;

            Assert.AreEqual(expected, actual);
        }
Пример #11
0
        /// <summary>
        ///	 Creates the Graph-Object. Id will be set to System.currentTimeMillis()
        ///  If no properties are set, the default port 3000 and localhost will be applied.
        /// </summary>
        /// <param name="pGVSGraphName"></param>
        /// <param name="pGvsStyle"></param>
        public GVSGraph(string pGVSGraphName)
        {
            //Create the System.currentTimeMillis()(JAVA)
            var t    = DateTime.Now.Subtract(new DateTime(1970, 01, 01, 01, 0, 0, 0));
            var time = (long)(t.TotalMilliseconds);

            this.gvsGraphId = time;

            this.gvsGraphName = pGVSGraphName ?? "";

            gvsGraphVertizes = new HashSet <GVSDefaultVertex>();
            gvsGraphEdges    = new HashSet <GVSGraphEdge>();

            var gvsPortFile = ConfigurationSettings.AppSettings[GVSPORTFILE];
            var gvsHost     = ConfigurationSettings.AppSettings[GVSHOST];
            var gvsPort     = ConfigurationSettings.AppSettings[GVSPORT];

            if (gvsPortFile != null)
            {
                try{
                    Console.WriteLine("Load socketinformation from " + gvsPortFile);
                    var reader = new XmlTextReader(gvsPortFile);
                    while (reader.Read())
                    {
                        if (reader.IsStartElement("Port"))
                        {
                            reader.Read();
                            port = int.Parse(reader.Value);
                        }
                        if (reader.IsStartElement("Host"))
                        {
                            reader.Read();
                            host = reader.Value.ToString();
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine("Error Portfile");
                    Console.WriteLine(ex.Message);
                }
            }
            else if (gvsHost != null && gvsPort != null)
            {
                try{
                    Console.WriteLine("Load Socketinformation from AppConfig (Host,Port)");
                    this.host = gvsHost;
                    this.port = int.Parse(gvsPort);
                }
                catch (Exception ex) {
                    Console.WriteLine("port or host failed");
                    Console.WriteLine(ex.Message);
                }
            }

            else
            {
                this.host = "127.0.0.1";
                this.port = 3000;
            }
            xmlConnection = new XMLConnection(host, port);
            xmlConnection.connectToServer();
        }