protected virtual StoreModeData GetStoreMode(Guid id, Guid fileID)
        {
            StoreModeData result = null;
            DbCommand     dbCmd  = null;

            if (id != Guid.Empty || fileID != Guid.Empty)
            {
                dbCmd = this.SelectCommand;
                Database.SetParameterValue(dbCmd, "p_store_mode_id", id.ToString().ToUpper());
                Database.SetParameterValue(dbCmd, "p_physical_file_id", fileID.ToString().ToUpper());
            }
            else
            {
                dbCmd = GetNewStoreMode();
            }
            using (IDataReader reader = Database.ExecuteReader(dbCmd))
            {
                if (reader.Read())
                {
                    result = new StoreModeData();
                    FieldLookup lookup = this.EntityFactory.CreateFieldLookup(reader);
                    this.Adapter.SetEntityValue(result, reader, lookup);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static ConfigSettingData GetConfigSetting(IFileStorageProviderDataProvider dataProvider, Guid physicalFileID)
        {
            ConfigSettingData result = _settingsCacheByID[physicalFileID];

            if (result != null)
            {
                return(result.Clone());
            }
            lock (_settingsCacheByID)
            {
                result = _settingsCacheByID[physicalFileID];
            }
            if (result != null)
            {
                return(result.Clone());
            }
            if (dataProvider == null)
            {
                dataProvider = DataProvider;
            }
            StoreModeData storeData = dataProvider.GetStoreModeByFileID(physicalFileID);

            if (storeData != null)
            {
                if (!_settingsCache.TryGetValue(storeData.StoreParams, out result))
                {
                    lock (_settingsCache)
                    {
                        if (!_settingsCache.TryGetValue(storeData.StoreParams, out result))
                        {
                            result = ObjectFactory.XmlDeserializeObject(typeof(ConfigSettingData), storeData.StoreParams) as ConfigSettingData;
                            _settingsCache[storeData.StoreParams] = result;
                        }
                    }
                }
                if (result != null)
                {
                    lock (_settingsCacheByID)
                    {
                        _settingsCacheByID.Add(physicalFileID, result);
                    }
                    return(result.Clone());
                }
            }
            else
            {
                result = CurrentConfigSetting.Clone();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static void Initialize(IFileStorageProviderDataProvider dataProvider)
        {
            if (_currentStoreModeID == Guid.Empty || _lastDate != DateTime.UtcNow.Date)
            {
                lock (_inializeLock)
                {
                    if (_currentStoreModeID == Guid.Empty || _lastDate != DateTime.UtcNow.Date)
                    {
                        _lastDate = DateTime.UtcNow.Date;
                        Refresh();
                        ConfigSettingData configData = CurrentConfigSetting;
                        if (configData != null)
                        {
                            if (dataProvider == null)
                            {
                                dataProvider = DataProvider;
                            }
                            StoreModeData oldData = dataProvider.GetStoreModeByID(Guid.Empty);

                            StoreModeData data = new StoreModeData();
                            data.StoreParams = ObjectFactory.XmlSerializerObject(configData);
                            if (oldData != null && oldData.StoreParams == data.StoreParams)
                            {
                                _currentStoreModeID = oldData.ID;
                                return;
                            }
                            Guid id = CombineGuid.NewComboGuid();
                            data.ID = id;
                            dataProvider.SaveStoreMode(data);
                            if (!_settingsCache.ContainsKey(data.StoreParams))
                            {
                                lock (_settingsCache)
                                {
                                    if (!_settingsCache.ContainsKey(data.StoreParams))
                                    {
                                        _settingsCache[data.StoreParams] = configData;
                                    }
                                }
                            }
                            _currentStoreModeID = id;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override StoreModeData SaveStoreMode(StoreModeData configData)
        {
            StoreModeData result = null;

            if (configData != null)
            {
                StoreModeData data = (StoreModeData)configData.Clone();
                if (data.ID == Guid.Empty)
                {
                    data.ID = CombineGuid.NewComboGuid();
                }
                DbCommand dbCmd = this.InsertCommand;
                this.Adapter.SetParametersValue(dbCmd.Parameters, data);
                this.Database.ExecuteNonQuery(dbCmd);
                result = data;
            }
            return(result);
        }
Ejemplo n.º 5
0
 public abstract StoreModeData SaveStoreMode(StoreModeData configData);