示例#1
0
        public override Response Refresh(string objectType)
        {
            string keyFile = string.Format("{0}{1}.{2}.key",
                                           _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]);

            if (File.Exists(_settings["DBDictionaryPath"]))
            {
                _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_settings["DBDictionaryPath"], keyFile);
            }

            if (_dbDictionary == null || _dbDictionary.dataObjects == null)
            {
                Response response = new Response()
                {
                    Level    = StatusLevel.Error,
                    Messages = new Messages()
                    {
                        "Dictionary is empty."
                    },
                };

                return(response);
            }

            return(Generate(_settings["projectName"], _settings["applicationName"]));
        }
示例#2
0
        public NHibernateDataLayer(AdapterSettings settings, IDictionary keyRing) : base(settings)
        {
            var ninjectSettings = new NinjectSettings {
                LoadExtensions = false, UseReflectionBasedInjection = true
            };

            _kernel = new StandardKernel(ninjectSettings, new NHibernateModule());
            _kernel.Load(new XmlExtensionModule());
            _nSettings = _kernel.Get <NHibernateSettings>();
            _nSettings.AppendSettings(settings);
            _keyRing = keyRing;

            _kernel.Rebind <AdapterSettings>().ToConstant(_settings);
            _kernel.Bind <IDictionary>().ToConstant(_keyRing).Named("KeyRing");

            _dataDictionaryPath = string.Format("{0}DataDictionary.{1}.xml",
                                                _settings["AppDataPath"],
                                                _settings["Scope"]
                                                );

            _dbDictionaryPath = string.Format("{0}DatabaseDictionary.{1}.xml",
                                              _settings["AppDataPath"],
                                              _settings["Scope"]
                                              );

            string keyFile = string.Format("{0}{1}.{2}.key",
                                           _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]);

            if (File.Exists(_dbDictionaryPath))
            {
                _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_dbDictionaryPath, keyFile);
            }
            else if (utility.Utility.isLdapConfigured && utility.Utility.FileExistInRepository <DatabaseDictionary>(_dbDictionaryPath))
            {
                _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_dbDictionaryPath, keyFile);
            }

            _dataDictionary             = new DataDictionary();
            _dataDictionary.dataObjects = _dbDictionary.dataObjects;

            string relativePath = String.Format("{0}AuthorizationBindingConfiguration.{1}.xml",
                                                _settings["AppDataPath"],
                                                _settings["Scope"]
                                                );

            _authorizationBindingPath = Path.Combine(
                _settings["BaseDirectoryPath"],
                relativePath
                );

            relativePath = String.Format("{0}SummaryBindingConfiguration.{1}.xml",
                                         _settings["AppDataPath"],
                                         _settings["Scope"]
                                         );

            _summaryBindingPath = Path.Combine(
                _settings["BaseDirectoryPath"],
                relativePath
                );

            //_kernel.Load(_authorizationBindingPath);
            if (File.Exists(_authorizationBindingPath))
            {
                _kernel.Load(_authorizationBindingPath);
            }
            else if (utility.Utility.isLdapConfigured && utility.Utility.FileExistInRepository <XElementClone>(_authorizationBindingPath))
            {
                XElement bindingConfig = Utility.GetxElementObject(_authorizationBindingPath);
                string   fileName      = Path.GetFileName(_authorizationBindingPath);
                string   tempPath      = Path.GetTempPath() + fileName;
                bindingConfig.Save(tempPath);
                _kernel.Load(tempPath);
            }
            else
            {
                _logger.Error("Authourization Binding configuration not found.");
            }
        }