Beispiel #1
0
        // dstore
        public static void CreateDataStore(DataStore dstore)
        {
            // grab current line contents
            var dstoreEntries = dstore.DataLines.Select(x => x.Contents).ToList();

            // read current dstore type if any
            DataStoreType exstDStoreType =
                dstore.DataFormatter.ReadDataStoreType(dstoreEntries);

            // check if existing data store is defined and matches the provided type
            if (exstDStoreType != null && !exstDStoreType.Equals(dstore.DataStoreType))
            {
                throw new Exception(
                          string.Format("Datastore type does not match existing \"{0}\"", exstDStoreType)
                          );
            }

            // if no existing dstore type is found, create based on input dstore type
            if (exstDStoreType is null)
            {
                // if file is not empty, throw an exception
                if (dstore.DataLines.Count > 0)
                {
                    throw new Exception("Datastore is not configured as a flat database and is not empty.");
                }

                // if empty
                // ask the formatter to build the entry and submit a change request
                var ecReq = dstore.DataFormatter.BuildDataStoreEntry(dstoreEntries,
                                                                     dstore.DataStoreType);
                // submit dstore and entry change request for processing
                ProcessChangeRequest(dstore, ecReq);
            }
        }
        public void UseBackupWhenAppropriate(DataStoreType appSetting, bool expectedOutcome)
        {
            TestAppSettings.SetDataStoreType(appSetting);
            var payment = new PaymentService();

            Assert.AreEqual(expectedOutcome, payment.GetDataStore() is BackupAccountDataStore);
        }
Beispiel #3
0
        public void Configuration_Page_Shows_All_Settings()
        {
            // Arrange
            LoginAsAdmin();

            // Act
            Driver.FindElement(By.CssSelector("a[href='/settings']")).Click();

            // Assert
            Assert.That(Driver.ElementValue("#SiteName"), Is.EqualTo("Acceptance Tests"));
            Assert.That(Driver.ElementValue("#SiteUrl"), Is.EqualTo("http://*****:*****@"~/App_Data/Attachments"));
            Assert.That(Driver.ElementValue("#AllowedFileTypes"), Is.EqualTo("jpg,png,gif,zip,xml,pdf"));

            Assert.False(Driver.IsCheckboxChecked("UseWindowsAuth"));
            Assert.True(Driver.IsCheckboxChecked("AllowUserSignup"));
            Assert.False(Driver.IsCheckboxChecked("IsRecaptchaEnabled"));
            Assert.False(Driver.IsCheckboxChecked("UseObjectCache"));
            Assert.False(Driver.IsCheckboxChecked("UseBrowserCache"));

            Assert.That(Driver.FindElements(By.CssSelector("#DataStoreTypeName option")).Count, Is.EqualTo(DataStoreType.AllTypes.Count()));
            SelectElement element = new SelectElement(Driver.FindElement(By.CssSelector("#DataStoreTypeName")));

            Assert.That(element.SelectedOption.GetAttribute("value"), Is.EqualTo(DataStoreType.ByName("SqlServer2012").Name));
            Assert.That(Driver.SelectedIndex("#MarkupType"), Is.EqualTo(0));
            Assert.That(Driver.SelectedIndex("#Theme"), Is.EqualTo(3));
            Assert.False(Driver.IsCheckboxChecked("OverwriteExistingFiles"));
            Assert.That(Driver.ElementValue("#HeadContent"), Is.EqualTo(""));
            Assert.That(Driver.ElementValue("#MenuMarkup"), Is.EqualTo("* %mainpage%\r\n* %categories%\r\n* %allpages%\r\n* %newpage%\r\n* %managefiles%\r\n* %sitesettings%\r\n\r\n"));
        }
        public DataStoreType ReadDataStoreType(List <string> dstoreEntries)
        {
            DataStoreType dstoreType = null;

            var dstoreFinder         = buildMdataRegex(mdataDStore, "dstoretype");
            var dstoreSourceFinder   = buildMdataRegex(mdataDStoreSource, "dstorefile");
            var dstoreVersionFinder  = buildMdataRegex(mdataDStoreVersion, "dstoreversion");
            var dstoreEncodingFinder = buildMdataRegex(mdataDStoreEncoding, "dstoreencoding");

            foreach (string dsEntry in dstoreEntries)
            {
                var match = dstoreFinder.Match(dsEntry);
                if (match.Success)
                {
                    var dbinfo        = decodeValue(match.Groups["dstoretype"].Value);
                    var sourceMatch   = dstoreSourceFinder.Match(dsEntry);
                    var versionMatch  = dstoreVersionFinder.Match(dsEntry);
                    var encodingMatch = dstoreEncodingFinder.Match(dsEntry);
                    dstoreType = new DataStoreType(
                        dsource: decodeValue(sourceMatch.Groups["dstorefile"].Value),
                        dsourceVersion: new Version(decodeValue(versionMatch.Groups["dstoreversion"].Value)),
                        dsourceEncoding: Encoding.GetEncoding(decodeValue(encodingMatch.Groups["dstoreencoding"].Value))
                        );
                    break;
                }
            }

            return(dstoreType);
        }
        internal void FinalizeInstall(SettingsViewModel model)
        {
            // The name as a string is passed through each step, so parse it
            DataStoreType dataStoreType = DataStoreType.ByName(model.DataStoreTypeName);

            model.DataStoreTypeName = dataStoreType.Name;

            // Update all repository references for the dependencies of this class
            // (changing the For() in StructureMap won't do this as the references have already been created).
            _repository = RepositoryManager.ChangeRepository(dataStoreType, model.ConnectionString, model.UseObjectCache);
            UserService.UpdateRepository(_repository);
            _settingsService.UpdateRepository(_repository);
            _searchService.UpdateRepository(_repository);

            // Default these two properties for installations
            model.IgnoreSearchIndexErrors = true;
            model.IsPublicSite            = true;

            // Update the web.config first, so all connections can be referenced.
            _configReaderWriter.Save(model);

            // Create the roadkill schema and save the configuration settings
            _settingsService.CreateTables(model);
            _settingsService.SaveSiteSettings(model);

            // Add a user if we're not using AD.
            if (!model.UseWindowsAuth)
            {
                UserService.AddUser(model.AdminEmail, "admin", model.AdminPassword, true, false);
            }

            // Create a blank search index
            _searchService.CreateIndex();
        }
Beispiel #6
0
 public void AddObjectDataStore(JObject value, DataStoreType dataStoreType)
 {
     foreach (var val in value)
     {
         this.UpdateValue(dataStoreType, this.CurrentRoute, val.Key, val.Value);
     }
 }
Beispiel #7
0
		public void Startup(DataStoreType dataStoreType, string connectionString, bool enableCache)
		{
			if (!string.IsNullOrEmpty(connectionString))
			{
				LightSpeedContext context = new LightSpeedContext();
				context.ConnectionString = connectionString;
				context.DataProvider = dataStoreType.LightSpeedDbType;
				context.IdentityMethod = IdentityMethod.GuidComb;
				context.CascadeDeletes = true;
				context.VerboseLogging = true;
				context.Logger = new DatabaseLogger();

				if (enableCache)
					context.Cache = new CacheBroker(new DefaultCache());

				ObjectFactory.Configure(x =>
				{
					x.For<LightSpeedContext>().Singleton().Use(context);
					x.For<IUnitOfWork>().HybridHttpOrThreadLocalScoped().Use(ctx => ctx.GetInstance<LightSpeedContext>().CreateUnitOfWork());
				});
			}
			else
			{
				Log.Warn("LightSpeedRepository.Startup skipped as no connection string was provided");
			}
		}
Beispiel #8
0
        public static void GatherStorePattern(string reportName, DataStoreType type) // 采集存储模式
        {
            GatherReport report = new GatherReport();
            GatherTable  tab    = report.GetReportTable(reportName);

            tab.采集模式(type);
        }
Beispiel #9
0
 public virtual void Install(DataStoreType dataStoreType, string connectionString, bool enableCache)
 {
     Installed = true;
     InstalledDataStoreType    = dataStoreType;
     InstalledConnectionString = connectionString;
     InstalledEnableCache      = enableCache;
 }
Beispiel #10
0
        private JToken GetLastValueFromDataStore(string key, DataStoreType dataStoreType = DataStoreType.Any)
        {
            List <DataStoreItem> itemsList = null;
            JToken itemToReturn            = null;

            if (dataStoreType == DataStoreType.Private || dataStoreType == DataStoreType.Any)
            {
                var values = GetValueAndRoutesFromDataStore(this.PrivateDataStore, key, DataStoreType.Private);
                if (values.Any())
                {
                    itemsList = values;
                }
            }

            if (dataStoreType == DataStoreType.Public || dataStoreType == DataStoreType.Any)
            {
                var values = GetValueAndRoutesFromDataStore(this.PublicDataStore, key, DataStoreType.Private);
                if (values.Any())
                {
                    itemsList = values;
                }
            }

            if (itemsList != null)
            {
                itemToReturn = itemsList.Any(p => p.Route.ToLowerInvariant() == "requestparameters")
                    ? itemsList.Single(p => p.Route.ToLowerInvariant() == "requestparameters").Value
                    : itemsList.Last().Value;
            }

            return(itemToReturn);
        }
Beispiel #11
0
        public void UpdateValue(DataStoreType dataStoreType, string route, string key, JToken value)
        {
            bool foundInPrivate = false;
            bool foundInPublic  = false;

            if (dataStoreType == DataStoreType.Private || dataStoreType == DataStoreType.Any)
            {
                foundInPrivate = UpdateItemIntoDataStore(this.PrivateDataStore, route, key, value);
            }

            if (dataStoreType == DataStoreType.Public || dataStoreType == DataStoreType.Any)
            {
                foundInPublic = UpdateItemIntoDataStore(this.PublicDataStore, route, key, value);
            }

            if (!foundInPublic && !foundInPrivate)
            {
                if (dataStoreType == DataStoreType.Private || dataStoreType == DataStoreType.Any)
                {
                    AddModifyItemToDataStore(this.PrivateDataStore, route, key, value);
                }

                if (dataStoreType == DataStoreType.Public)
                {
                    AddModifyItemToDataStore(this.PublicDataStore, route, key, value);
                }
            }
        }
Beispiel #12
0
        public void LoadGatherTable(GatherInfo info, GatherTimer time, IGatherItem IItem, IGatherDB db, IThreadAction _action)
        {
            this._action        = _action;
            this._db            = db;
            this._info          = info;
            this.tb             = db.GetDataTable();
            this.临时缓存           = this.tb.Clone();
            this.临时缓存.TableName = info.reportName;
            this.time           = time;
            GatherItem item = null;

            row = new GatherRow();
            int         count = this.tb.Columns.Count;
            GatherField field = null;

            for (int i = 0; i < count; i++)
            {
                field = info.GetFiled(this.tb.Columns[i].ColumnName);
                if (field == null)
                {
                    continue;
                }
                if (field._SourceType != 数据来源类型.未知)
                {
                    item = new GatherItem(field, IItem.GetComputerItem(field.DataNo));
                }
                else
                {
                    item = new GatherItem(field, IItem.GetIValue(field.DataNo));
                }
                this.row.AddItem(item);
            }
            storeType = DataStoreType.SynDB; // 默认采集模式是同步进行
        }
        public List <Dictionary <string, object> > ReadRecordsData(List <string> dstoreEntries,
                                                                   DataStoreType dstoreType,
                                                                   DatabaseDefinition dbDef,
                                                                   TableDefinition tableDef)
        {
            var recordList = new List <Dictionary <string, object> >();

            // find table range
            var tableRange = extractTableRange(dstoreType.TypeName, dstoreEntries, dbDef, tableDef);

            // skip the table def line
            foreach (string entryLine in dstoreEntries.GetRange(tableRange.First + 1, tableRange.Count - 1))
            {
                string cleanedDLine = entryLine;
                if (tableDef.IsHidden)
                {
                    cleanedDLine = cleanedDLine.Replace(medataLineStart + mdataRecordSeparator, "");
                }
                var fieldValues     = cleanedDLine.Split(new string[] { tableDef.FieldDelimiter }, StringSplitOptions.None);
                var fieldValuesDict = new Dictionary <string, object>();
                int fieldIndex      = 0;

                foreach (var field in tableDef.Fields)
                {
                    fieldValuesDict.Add(field.Name, decodeFieldValue(fieldValueString: fieldValues[fieldIndex],
                                                                     fieldType: field.FieldType));
                    fieldIndex++;
                }

                recordList.Add(fieldValuesDict);
            }

            return(recordList);
        }
Beispiel #14
0
 internal GeneralPurpose(object container,
                         IComparer <TKey> comparer, string name, DataStoreType dataStoreType,
                         ISortedDictionaryOnDisk dataStore, bool isDataInKeySegment) :
     base(
         container, comparer, name, dataStoreType, dataStore, isDataInKeySegment)
 {
 }
        /// <summary>
        /// Tests the database connection, changing the current registered repository.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <returns>Any error messages or an empty string if no errors occurred.</returns>
        public static string TestDbConnection(string connectionString, string databaseType)
        {
            try
            {
                DataStoreType dataStoreType = DataStoreType.ByName(databaseType);
                if (dataStoreType == null)
                {
                    dataStoreType = DataStoreType.ByName("SQLServer2005");
                }

                IRepository repository = ChangeRepository(dataStoreType, connectionString, false);
                repository.TestConnection(dataStoreType, connectionString);
                return("");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
            finally
            {
                // Restore to their previous state
                ApplicationSettings appSettings = ObjectFactory.GetInstance <ApplicationSettings>();
                IRepository         repository  = ChangeRepository(appSettings.DataStoreType, appSettings.ConnectionString, false);
            }
        }
        public void Startup(DataStoreType dataStoreType, string connectionString, bool enableCache)
        {
            if (!string.IsNullOrEmpty(connectionString))
            {
                LightSpeedContext context = new LightSpeedContext();
                context.ConnectionString = connectionString;
                context.DataProvider     = dataStoreType.LightSpeedDbType;
                context.IdentityMethod   = IdentityMethod.GuidComb;
                context.CascadeDeletes   = true;

                if (_applicationSettings.IsLoggingEnabled)
                {
                    context.VerboseLogging = true;
                    context.Logger         = new DatabaseLogger();
                }

                if (enableCache)
                {
                    context.Cache = new CacheBroker(new DefaultCache());
                }

                ObjectFactory.Configure(x =>
                {
                    x.For <LightSpeedContext>().Singleton().Use(context);
                    x.For <IUnitOfWork>().HybridHttpOrThreadLocalScoped().Use(ctx => ctx.GetInstance <LightSpeedContext>().CreateUnitOfWork());
                });
            }
            else
            {
                Log.Warn("LightSpeedRepository.Startup skipped as no connection string was provided");
            }
        }
Beispiel #17
0
 public void AddObjectDataStore(string route, JObject value, DataStoreType dataStoreType)
 {
     foreach (var val in value)
     {
         this.UpdateValue(dataStoreType, route, val.Key, val.Value);
     }
 }
        public DataStore FindDataStore(DataStoreType tag)
        {
            DataStore dataStoreResult = null;

            dataStoreDict.TryGetValue(tag, out dataStoreResult);
            return(dataStoreResult);
        }
        internal static string ToSerializedValue(this DataStoreType value)
        {
            switch (value)
            {
            case DataStoreType.AzureBlob:
                return("AzureBlob");

            case DataStoreType.AzureFile:
                return("AzureFile");

            case DataStoreType.AzureDataLake:
                return("AzureDataLake");

            case DataStoreType.AzureSqlDatabase:
                return("AzureSqlDatabase");

            case DataStoreType.AzurePostgreSql:
                return("AzurePostgreSql");

            case DataStoreType.DBFS:
                return("DBFS");

            case DataStoreType.AzureDataLakeGen2:
                return("AzureDataLakeGen2");

            case DataStoreType.GlusterFs:
                return("GlusterFs");
            }
            return(null);
        }
Beispiel #20
0
 public DataStore(DataStoreType type, string key, string data, string username, string userToken)
 {
     Type      = type;
     Key       = key;
     Data      = data;
     Username  = username;
     UserToken = userToken;
 }
Beispiel #21
0
 public StageTableCfg(string dir, string table, bool isNativeStore = true, string tsCol = null, DataStoreType storeType = DataStoreType.Db)
 {
     Dir           = dir;
     Table         = table;
     IsNativeStore = isNativeStore;
     StoreType     = storeType;
     TsCol         = tsCol ?? (isNativeStore ? "Updated" : null);
 }
 public ItemDetailViewModel(DataStoreType dataStoreType, Item item = null)
 {
     Title             = item?.Name;
     DataStoreType_    = dataStoreType;
     Item              = item;
     DisposalDataStore = new MockDisposedDataStore();
     ShoppingDataStore = new MockShoppingDataStore();
 }
Beispiel #23
0
        public void ByName_Should_Throw_DatabaseException_If_DataStoreType_Not_Found()
        {
            // Arrange
            IEnumerable <DataStoreType> dataStoreTypes = DataStoreType.AllTypes;

            // Act + Assert
            DataStoreType datastoreType = DataStoreType.ByName("thunderbird");
        }
        /// <summary>
        /// Saves the configuration settings. This will save a subset of the <see cref="SettingsViewModel" /> based on
        /// the values that match those found in the <see cref="RoadkillSection" />
        /// </summary>
        /// <param name="settings">The application settings.</param>
        /// <exception cref="InstallerException">An exception occurred while updating the settings to the web.config</exception>
        public override void Save(SettingsViewModel settings)
        {
            try
            {
                if (settings.UseWindowsAuth)
                {
                    WriteConfigForWindowsAuth();
                }
                else
                {
                    WriteConfigForFormsAuth();
                }

                // Create a "Roadkill" connection string, or use the existing one if it exists.
                ConnectionStringSettings roadkillConnection = new ConnectionStringSettings("Roadkill", settings.ConnectionString);

                if (_config.ConnectionStrings.ConnectionStrings["Roadkill"] == null)
                {
                    _config.ConnectionStrings.ConnectionStrings.Add(roadkillConnection);
                }
                else
                {
                    _config.ConnectionStrings.ConnectionStrings["Roadkill"].ConnectionString = settings.ConnectionString;
                }

                // The roadkill section
                DataStoreType   dataStoreType = DataStoreType.ByName(settings.DataStoreTypeName);
                RoadkillSection section       = _config.GetSection("roadkill") as RoadkillSection;
                section.AdminRoleName            = settings.AdminRoleName;
                section.AttachmentsFolder        = settings.AttachmentsFolder;
                section.AzureContainer           = settings.AzureContainer;
                section.UseObjectCache           = settings.UseObjectCache;
                section.UseBrowserCache          = settings.UseBrowserCache;
                section.ConnectionStringName     = "Roadkill";
                section.DataStoreType            = dataStoreType.Name;
                section.EditorRoleName           = settings.EditorRoleName;
                section.LdapConnectionString     = settings.LdapConnectionString;
                section.LdapUsername             = settings.LdapUsername;
                section.LdapPassword             = settings.LdapPassword;
                section.RepositoryType           = dataStoreType.CustomRepositoryType;
                section.UseWindowsAuthentication = settings.UseWindowsAuth;
                section.Version            = ApplicationSettings.FileVersion.ToString();
                section.UseGoogleAnalytics = settings.UseGoogleAnalytics;
                section.GAName             = settings.GAName;
                section.GANumber           = settings.GANumber;

                // For first time installs: these need to be explicit as the DefaultValue="" in the attribute doesn't determine the value when saving.
                section.IsPublicSite            = settings.IsPublicSite;
                section.IgnoreSearchIndexErrors = settings.IgnoreSearchIndexErrors;
                section.Installed = true;

                _config.Save(ConfigurationSaveMode.Minimal);
            }
            catch (ConfigurationErrorsException ex)
            {
                throw new InstallerException(ex, "An exception occurred while updating the settings to the web.config");
            }
        }
        /// <summary>
        /// Gets the current application settings, which is usually cached settings from the <see cref="Load" /> method.
        /// </summary>
        /// <returns>
        /// A new <see cref="ApplicationSettings" /> instance
        /// </returns>
        public override ApplicationSettings GetApplicationSettings()
        {
            ApplicationSettings appSettings = new ApplicationSettings();

            appSettings.AdminRoleName         = _section.AdminRoleName;
            appSettings.AttachmentsFolder     = _section.AttachmentsFolder;
            appSettings.AttachmentsRoutePath  = _section.AttachmentsRoutePath;
            appSettings.AzureConnectionString = _section.AzureConnectionString;
            appSettings.AzureContainer        = _section.AzureContainer;

            appSettings.ConnectionStringName = _section.ConnectionStringName;
            appSettings.ConnectionString     = _config.ConnectionStrings.ConnectionStrings[_section.ConnectionStringName].ConnectionString;
            if (string.IsNullOrEmpty(appSettings.ConnectionString))
            {
                appSettings.ConnectionString = ConfigurationManager.ConnectionStrings[_section.ConnectionStringName].ConnectionString;
            }

            if (string.IsNullOrEmpty(appSettings.ConnectionString))
            {
                Log.Warn("ConnectionString property is null/empty.");
            }

            // Ignore the legacy useCache and cacheText section keys, as the behaviour has changed.
            appSettings.UseObjectCache  = _section.UseObjectCache;
            appSettings.UseBrowserCache = _section.UseBrowserCache;

            // Look for the legacy database type key
            string dataStoreType = _section.DataStoreType;

            if (string.IsNullOrEmpty(dataStoreType) && !string.IsNullOrEmpty(_section.DatabaseType))
            {
                dataStoreType = _section.DatabaseType;
            }

            appSettings.LoggingTypes            = _section.Logging;
            appSettings.LogErrorsOnly           = _section.LogErrorsOnly;
            appSettings.DataStoreType           = DataStoreType.ByName(dataStoreType);
            appSettings.ConnectionStringName    = _section.ConnectionStringName;
            appSettings.EditorRoleName          = _section.EditorRoleName;
            appSettings.IgnoreSearchIndexErrors = _section.IgnoreSearchIndexErrors;
            appSettings.IsPublicSite            = _section.IsPublicSite;
            appSettings.Installed                = _section.Installed;
            appSettings.LdapConnectionString     = _section.LdapConnectionString;
            appSettings.LdapUsername             = _section.LdapUsername;
            appSettings.LdapPassword             = _section.LdapPassword;
            appSettings.RepositoryType           = _section.RepositoryType;
            appSettings.UseAzureFileStorage      = _section.UseAzureFileStorage;
            appSettings.UseHtmlWhiteList         = _section.UseHtmlWhiteList;
            appSettings.UserServiceType          = _section.UserServiceType;
            appSettings.UseWindowsAuthentication = _section.UseWindowsAuthentication;
            appSettings.UpgradeRequired          = UpgradeChecker.IsUpgradeRequired(_section.Version);

            appSettings.UseGoogleAnalytics = _section.UseGoogleAnalytics;
            appSettings.GAName             = _section.GAName;
            appSettings.GANumber           = _section.GANumber;

            return(appSettings);
        }
Beispiel #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataStoreType"></param>
        /// <param name="connectionString"></param>
        /// <exception cref="MongoConnectionException">Can't connect to the MongoDB server (but it's a valid connection string)</exception>
        public void TestConnection(DataStoreType dataStoreType, string connectionString)
        {
            string        databaseName = MongoUrl.Create(connectionString).DatabaseName;
            MongoClient   client       = new MongoClient(connectionString);
            MongoServer   server       = client.GetServer();
            MongoDatabase database     = server.GetDatabase(databaseName);

            database.GetCollectionNames();
        }
        public override void Save(SettingsViewModel settings)
        {
            Saved = true;

            // The bare minimum needed to test the installer
            ApplicationSettings.ConnectionString = settings.ConnectionString;
            ApplicationSettings.DataStoreType    = DataStoreType.ByName(settings.DataStoreTypeName);
            ApplicationSettings.UseBrowserCache  = settings.UseBrowserCache;
            ApplicationSettings.UseObjectCache   = settings.UseObjectCache;
        }
Beispiel #28
0
        public string GetValueAtIndex(string key, string index, DataStoreType dataStoreType = DataStoreType.Any)
        {
            int i = 0;

            if (this.KeyExists(index))
            {
                i = int.Parse(this.GetValue(index));
            }
            return(this.GetAllValues(key)[i]);
        }
Beispiel #29
0
        public void ByName_Should_Find_DataStoreType_And_Be_Case_Insensitive()
        {
            // Arrange
            IEnumerable <DataStoreType> dataStoreTypes = DataStoreType.AllTypes;

            // Act
            DataStoreType datastoreType = DataStoreType.ByName("mOngoDB");

            // Assert
            Assert.That(datastoreType.Name, Is.EqualTo("MongoDB"));
        }
Beispiel #30
0
        public bool RouteAndKeyExists(string route, string key, DataStoreType dataStoreType = DataStoreType.Any)
        {
            var listOfKeys = this.GetValueAndRoutesFromDataStore(dataStoreType, key).ToList();

            if (listOfKeys.Any())
            {
                return(listOfKeys.Any(p => p.Route.ToLowerInvariant().Equals(route.ToLowerInvariant())));
            }

            return(false);
        }
Beispiel #31
0
        public async Task <int[]> MakeAndSum(int size, int shift, DataStoreType dataStoreType)
        {
            Log.Information("MakeAndSum Started - {Size} - Enum Parameter {DataStoreType}", size, dataStoreType);
            var things = (0 + shift).RangeTo(size + shift).Select(i => new Thing {
                Number = i
            });
            var res = await things.Process(Ctx, b => CountThings(b), new() { MaxParallel = 2 });

            Log.Information("MakeAndSum Complete {Batches}", res.Count);
            return(res.Select(r => r.OutState).ToArray());
        }
        public void TestConnection(DataStoreType dataStoreType, string connectionString)
        {
            LightSpeedContext context = ObjectFactory.GetInstance<LightSpeedContext>();
            if (context == null)
                throw new InvalidOperationException("Repository.Test failed - LightSpeedContext was null from the ObjectFactory");

            using (IDbConnection connection = context.DataProviderObjectFactory.CreateConnection())
            {
                connection.ConnectionString = connectionString;
                connection.Open();
            }
        }
Beispiel #33
0
 public void LoadGatherTable(GatherInfo info, GatherTimer time, IGatherItem IItem,IGatherDB db,IThreadAction _action)
 {
     this._action = _action;
     this._db = db;
     this._info = info;
     this.tb = db.GetDataTable();
     this.临时缓存 = this.tb.Clone();
     this.临时缓存.TableName = info.reportName;
     this.time = time;
     GatherItem item = null;
     row = new GatherRow();
     int count = this.tb.Columns.Count;
     GatherField field = null;
     for (int i = 0; i < count; i++)
     {
         field = info.GetFiled(this.tb.Columns[i].ColumnName);
         if (field == null) { continue; }
         if (field._SourceType != 数据来源类型.未知)
             item = new GatherItem(field, IItem.GetComputerItem(field.DataNo));
         else
             item = new GatherItem(field, IItem.GetIValue(field.DataNo));
         this.row.AddItem(item);
     }
     storeType = DataStoreType.SynDB; // 默认采集模式是同步进行
 }
        public void Install(DataStoreType dataStoreType, string connectionString, bool enableCache)
        {
            LightSpeedContext context = ObjectFactory.GetInstance<LightSpeedContext>();
            if (context == null)
                throw new InvalidOperationException("Repository.Install failed - LightSpeedContext was null from the ObjectFactory");

            using (IDbConnection connection = context.DataProviderObjectFactory.CreateConnection())
            {
                connection.ConnectionString = connectionString;
                connection.Open();

                IDbCommand command = context.DataProviderObjectFactory.CreateCommand();
                command.Connection = connection;

                dataStoreType.Schema.Drop(command);
                dataStoreType.Schema.Create(command);
            }
        }
Beispiel #35
0
 // 采集存储模式
 public void GatherStorePattern(string reportName,DataStoreType type)
 {
     GatherFace.GatherStorePattern(reportName,type);
 }
Beispiel #36
0
 public void 采集模式(DataStoreType storeType)
 {
     this.storeType = storeType;
     if (storeType == DataStoreType.LastDB)
     {
         actionData = AddArr;
     }
     else
     {
         actionData = AddArrToDB;
     }
 }
Beispiel #37
0
 // 采集存储模式
 public static void GatherStorePattern(string reportName,DataStoreType type)
 {
     GatherReport report = new GatherReport();
     GatherTable tab = report.GetReportTable(reportName);
     tab.采集模式(type);
 }