Beispiel #1
0
        public bool Initialize(DatabaseContext _dbContext, CollectionConfiguration config)
        {
            //eviction is always enabled for now and can not be turned off.
            _isEvictionEnabled = true;
            if (_parent.CollectionConfiguration.EvictionConfiguration != null)  //TODO this check is added if eviction configuration is not available at collection level in db.config
            {
                //_isEvictionEnabled = _parent.CollectionConfiguration.EvictionConfiguration.EnabledEviction;
                if (_parent.CollectionConfiguration.EvictionConfiguration.Policy.ToLower() == "lru")
                {
                    _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
                }
            }
            else
            {
                _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
            }

            _persistenceManager = _parent.DbContext.PersistenceManager;
            _persistenceManager.AddMetadataIndex(_parent.Name, _parent.MetadataIndex);

            _indexManager = new CollectionIndexManager(_dbContext, _dbContext.IndexPersistanceManager, this, config.CollectionName);
            if (!_indexManager.Initialize(config.Indices))
            {
                return(false);
            }
            //if (_statsCollector != null)
            //    _statsCollector.SetStatsValue(StatisticsType.PendingPersistentDocuments, _dirtyDocuments.Count);

            if (_persistenceManager == null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
 /// <summary>
 /// Standard constructor.
 /// </summary>
 internal OnlineMergeIterator(IStateManager stateManager, Cache cache)
 {
     this.stateManager = stateManager;
     this.pm           = stateManager.PersistenceManager;
     this.mapping      = (Mappings)this.pm.NDOMapping;
     this.cache        = cache;
 }
Beispiel #3
0
        //Here to support dependency injection
        public MainViewModel(IWindowManager windowManager, IInformationProvider infoProvider,
                             IPersistenceManager persistenceManager)
        {
            DisplayName       = "Sojurn";
            wm                = windowManager;
            pm                = persistenceManager;
            this.infoProvider = infoProvider;

            Shows = new CollectionViewSource {
                Source = shows
            };
            Shows.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));

            TimeLine = new CollectionViewSource {
                Source = timeLine
            };
            TimeLine.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending));
            TimeLine.GroupDescriptions.Add(new PropertyGroupDescription("Date"));

            Backlog = new CollectionViewSource {
                Source = backlog
            };
            Backlog.GroupDescriptions.Add(new PropertyGroupDescription("ShowName"));
            Backlog.SortDescriptions.Add(new SortDescription("ShowName", ListSortDirection.Ascending));
            Backlog.SortDescriptions.Add(new SortDescription("SeasonNumber", ListSortDirection.Ascending));
            Backlog.SortDescriptions.Add(new SortDescription("EpisodeNumberThisSeason", ListSortDirection.Ascending));
        }
Beispiel #4
0
        public void SetUp()
        {
#if PORTABLE
            _persistenceManager = new PersistenceManager();
#endif
            CopyTestDataToImportFolder("graph_triples.nt");
        }
Beispiel #5
0
        private void UpdateTaskState(IPersistenceManager pm, DA.Task task, DT.TaskState taskState, Guid?slaveId, Guid?userId, string exception)
        {
            var stateLogDao     = pm.StateLogDao;
            var taskStateEntity = taskState.ToEntity();

            if (task.State == DA.TaskState.Transferring && taskStateEntity == DA.TaskState.Paused && task.Command == null)
            {
                // slave paused and uploaded the task (no user-command) -> set waiting.
                taskStateEntity = DA.TaskState.Waiting;
            }

            stateLogDao.Save(new DA.StateLog {
                State     = taskStateEntity,
                DateTime  = DateTime.Now,
                TaskId    = task.TaskId,
                UserId    = userId,
                SlaveId   = slaveId,
                Exception = exception
            });

            task.State = taskStateEntity;

            if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused ||
                task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted ||
                task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted)
            {
                task.Command = null;
            }
        }
 private void AggregateJob(IPersistenceManager pm, Guid id) {
   var jobDao = pm.JobDao;
   var factTaskDao = pm.FactTaskDao;
   pm.UseTransaction(() => {
     if (jobDao.Exists(id)) return;
     var jobTimeData = factTaskDao.GetByJobId(id).GroupBy(x => x.JobId).Select(x => new {
       CalculatingTime = x.Sum(y => y.CalculatingTime),
       WaitingTime = x.Sum(y => y.WaitingTime),
       TransferTime = x.Sum(y => y.TransferTime),
       InitialWaitingTime = x.Sum(y => y.InitialWaitingTime),
       StartTime = x.Min(y => y.StartTime),
       EndTime = x.Max(y => y.EndTime)
     }).SingleOrDefault();
     if (jobTimeData != null) {
       factTaskDao.DeleteByJobId(id);
       factTaskDao.Save(new FactTask {
         TaskId = Guid.NewGuid(),
         JobId = id,
         CalculatingTime = jobTimeData.CalculatingTime,
         WaitingTime = jobTimeData.WaitingTime,
         TransferTime = jobTimeData.TransferTime,
         InitialWaitingTime = jobTimeData.InitialWaitingTime,
         StartTime = jobTimeData.StartTime,
         EndTime = jobTimeData.EndTime,
         NumCalculationRuns = 0,
         NumRetries = 0,
         CoresRequired = 0,
         MemoryRequired = 0,
         Priority = 0,
         TaskState = TaskState.Finished
       });
     }
     pm.SubmitChanges();
   });
 }
        private void AggregateClientInfos(IPersistenceManager pm, List <FactClientInfo> clientInfos)
        {
            var factClientInfoDao = pm.FactClientInfoDao;
            var last  = clientInfos.Last();
            var infos = clientInfos.GroupBy(x => x.ClientId).Select(x => new {
                NumUsedCores    = (int)x.Average(y => y.NumUsedCores),
                NumTotalCores   = (int)x.Average(y => y.NumTotalCores),
                UsedMemory      = (int)x.Average(y => y.UsedMemory),
                TotalMemory     = (int)x.Average(y => y.TotalMemory),
                CpuUtilization  = Math.Round(x.Average(y => y.CpuUtilization), 2),
                IdleTime        = x.Sum(y => y.IdleTime),
                OfflineTime     = x.Sum(y => y.OfflineTime),
                UnavailableTime = x.Sum(y => y.UnavailableTime)
            }).SingleOrDefault();

            if (infos != null)
            {
                pm.UseTransaction(() => {
                    last.NumUsedCores    = infos.NumUsedCores;
                    last.NumTotalCores   = infos.NumTotalCores;
                    last.UsedMemory      = infos.UsedMemory;
                    last.TotalMemory     = infos.TotalMemory;
                    last.CpuUtilization  = infos.CpuUtilization;
                    last.IdleTime        = infos.IdleTime;
                    last.OfflineTime     = infos.OfflineTime;
                    last.UnavailableTime = infos.UnavailableTime;
                    clientInfos.Remove(last);
                    factClientInfoDao.Delete(clientInfos);
                    pm.SubmitChanges();
                });
            }
        }
Beispiel #8
0
        private SettingsManager()
        {
            _persistenceManager = ApplicationManager.GetInstance().
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            Update();
        }
Beispiel #9
0
 private void UpdateUserPriority(IPersistenceManager pm, DA.UserPriority up)
 {
     pm.UseTransaction(() => {
         up.DateEnqueued = DateTime.Now;
         pm.SubmitChanges();
     });
 }
Beispiel #10
0
 public SoundService(IPersistenceManager persistenceManager, ISoundWrapper soundWrapper)
 {
     _persistenceManager = persistenceManager;
     _soundWrapper       = soundWrapper;
     LoadOutputDevice();
     LoadPath();
 }
 private DT.TimeStatus GetTimeStatus(IPersistenceManager pm) {
   return pm.UseTransaction(() => {
     var factTaskDao = pm.FactTaskDao;
     var factTasks = factTaskDao.GetAll();
     var completedTasks = factTaskDao.GetCompletedTasks()
       .OrderByDescending(x => x.EndTime)
       .Take(LAST_TASKS);
     var lastCalculatingTimes = completedTasks
       .GroupBy(x => 1)
       .Select(x => new {
         Min = x.Min(y => y.CalculatingTime),
         Max = x.Max(y => y.CalculatingTime),
         Avg = (long)x.Average(y => (long?)y.CalculatingTime)
       }).FirstOrDefault();
     var calculatingTasks = factTasks.Where(x => x.TaskState == TaskState.Calculating);
     int count = calculatingTasks.Count() / 3;
     return new DT.TimeStatus {
       MinCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Min : 0,
       MaxCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Max : 0,
       AvgWaitingTime = count > 0 ? (long)calculatingTasks.OrderBy(x => x.StartTime).Take(count).Average(x => x.InitialWaitingTime) : 0,
       AvgCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Avg : 0,
       TotalCpuTime = factTasks.Sum(x => Convert.ToInt64(x.CalculatingTime)),
       StandardDeviationCalculatingTime = (long)StandardDeviation(completedTasks.Select(x => (double)x.CalculatingTime)),
       BeginDate = factTasks.Where(x => x.StartTime.HasValue).OrderBy(x => x.StartTime).Select(x => x.StartTime).FirstOrDefault()
     };
   });
 }
        protected virtual void DeserializeInlineProperty(object obj, IClassMap classMap, IPropertyMap propertyMap, XmlNode xmlObject)
        {
            IObjectManager      om = this.Context.ObjectManager;
            IPersistenceManager pm = this.Context.PersistenceManager;
            string element         = propertyMap.DocElement;
            object xmlValue        = null;
            bool   isNull          = true;

            if (element.Length > 0)
            {
            }
            else
            {
                string attribute = propertyMap.GetDocAttribute();

                if (!(xmlObject.Attributes[attribute] == null))
                {
                    xmlValue = xmlObject.Attributes[attribute].Value;
                    isNull   = false;
                }
                else
                {
                    xmlValue = DBNull.Value;
                    isNull   = true;
                }
            }

            object orgValue = FromString(obj, classMap, propertyMap, xmlValue);
            object value    = pm.ManageLoadedValue(obj, propertyMap, orgValue);

            om.SetNullValueStatus(obj, propertyMap.Name, isNull);
            om.SetPropertyValue(obj, propertyMap.Name, value);
            om.SetOriginalPropertyValue(obj, propertyMap.Name, orgValue);
        }
Beispiel #13
0
        /*
         * In this sample options page a text value is presented for editing
         * and will be saved to the registry. A validate method prevents
         * an empty message from being saved.
         */

        public OptionsPage3()
        {
            Name      = Constants.UI_OPTIONS_PAGE3;
            PageText  = "Options Page 3";
            GroupText = "Options Group 2";

            /*
             * Create the form layout.
             */

            textMessage          = new TextBox();
            textMessage.Location = new Point(15, 30);
            textMessage.Size     = new Size(400, 20);

            GroupBox groupBox = new GroupBox();

            groupBox.Size = new Size(430, 250);
            groupBox.Text = PageText;
            groupBox.Controls.Add(textMessage);

            Controls.Add(groupBox);

            /*
             * Create a persistence manager instance and load the
             * stored settings.
             */

            persistenceManager = ApplicationManager.GetInstance().
                                 GetPersistenceManager(Constants.PLUGIN_NAME);

            textMessage.Text = persistenceManager.ReadString(
                Constants.KEY_OPTION_TEXT_MESSAGE,
                "Enter a message here");
        }
 public NHObjectSpaceProvider(ITypesInfo typesInfo, IPersistenceManager persistenceManager)
 {
     Guard.ArgumentNotNull(typesInfo, "typesInfo");
     Guard.ArgumentNotNull(persistenceManager, "persistenceManager");
     this.typesInfo = typesInfo;
     this.persistenceManager = persistenceManager;
 }
Beispiel #15
0
        internal NHNestedObjectSpace(ITypesInfo typesInfo, IEntityStore entityStore, IPersistenceManager persistenceManager, 
            Dictionary<object, ObjectSpaceInstanceInfo> instances,  NHObjectSpace parentObjectSpace) : 
            base(typesInfo, entityStore, persistenceManager, instances, null)
        {

            this.parentObjectSpace = parentObjectSpace;
        }
Beispiel #16
0
        public static IUnitOfWork GetIsolatedUnitOfWork(this object obj)
        {
            IPersistenceManager persistenceManager = IoCFactory.Container.Resolve <IPersistenceManager>() as IPersistenceManager;
            IUnitOfWork         uow = persistenceManager.UnitOfWorkFactory.CreateIsolatedUnitOfWork(false, true);

            return(uow);
        }
Beispiel #17
0
 public UserService(IPersistenceManager persistenceManager, ILoginForm loginForm, IHttpWrapper httpRequest, IDialogWrapper dialogWrapper)
 {
     _persistenceManager = persistenceManager;
     _loginForm          = loginForm;
     _httpRequest        = httpRequest;
     _dialogWrapper      = dialogWrapper;
 }
Beispiel #18
0
        public void SetUp()
        {
#if PORTABLE
        _persistenceManager = new PersistenceManager();
#endif
            CopyTestDataToImportFolder("graph_triples.nt");
        }
Beispiel #19
0
 private DT.TimeStatus GetTimeStatus(IPersistenceManager pm)
 {
     return(pm.UseTransaction(() => {
         var factTaskDao = pm.FactTaskDao;
         var factTasks = factTaskDao.GetAll();
         var completedTasks = factTaskDao.GetCompletedTasks()
                              .OrderByDescending(x => x.EndTime)
                              .Take(LAST_TASKS);
         var lastCalculatingTimes = completedTasks
                                    .GroupBy(x => 1)
                                    .Select(x => new {
             Min = x.Min(y => y.CalculatingTime),
             Max = x.Max(y => y.CalculatingTime),
             Avg = (long)x.Average(y => (long?)y.CalculatingTime)
         }).FirstOrDefault();
         var calculatingTasks = factTasks.Where(x => x.TaskState == TaskState.Calculating);
         int count = calculatingTasks.Count() / 3;
         return new DT.TimeStatus {
             MinCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Min : 0,
             MaxCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Max : 0,
             AvgWaitingTime = count > 0 ? (long)calculatingTasks.OrderBy(x => x.StartTime).Take(count).Average(x => x.InitialWaitingTime) : 0,
             AvgCalculatingTime = lastCalculatingTimes != null ? lastCalculatingTimes.Avg : 0,
             TotalCpuTime = factTasks.Sum(x => (long?)x.CalculatingTime) ?? 0,
             StandardDeviationCalculatingTime = (long)StandardDeviation(completedTasks.Select(x => (double)x.CalculatingTime)),
             BeginDate = factTasks.Where(x => x.StartTime.HasValue).OrderBy(x => x.StartTime).Select(x => x.StartTime).FirstOrDefault()
         };
     }));
 }
        public AppendOnlyFilePageStore(IPersistenceManager persistenceManager, string filePath, int pageSize, bool readOnly, bool disableBackgroundWrites)
        {
            _peristenceManager = persistenceManager;
            _path = filePath;

            if ((_pageSize % 4096) != 0)
            {
                throw new ArgumentException("Page size must be a multiple of 4096 bytes");
            }
            _pageSize = pageSize;
            _bitShift = (int)Math.Log(_pageSize, 2.0);

            if (!_peristenceManager.FileExists(filePath) && !readOnly)
            {
                // Create an empty file that we can write to later
                _peristenceManager.CreateFile(filePath);
            }
            _stream = _peristenceManager.GetInputStream(_path);
            _nextPageId = ((ulong)_stream.Length >> _bitShift) + 1;
            if (!readOnly)
            {
                _newPages = new List<IPage>(512);
                _newPageOffset = _nextPageId;
            }
            _pageSize = pageSize;
            _readonly = readOnly;

            if (!readOnly && !disableBackgroundWrites)
            {
                _backgroundPageWriter =
                    new BackgroundPageWriter(persistenceManager.GetOutputStream(filePath, FileMode.Open));
            }

        }
Beispiel #21
0
        public SqlMetalForm(SqlConnection selectedConnection)
        {
            InitializeComponent();

            _applicationManager =
                QuickSharp.Core.ApplicationManager.GetInstance();

            _persistenceManager = _applicationManager.
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            _sqlConnectionManager =
                SqlConnectionManager.GetInstance();

            _provider         = selectedConnection.Provider;
            _connectionString = selectedConnection.ConnectionString;

            _useCompactEdition = _sqlConnectionManager.
                                 ConnectionIsSqlServerCe(selectedConnection);

            _output = _applicationManager.GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY)
                      as OutputForm;

            /*
             * Get the tool path.
             */

            _sqlMetalPath = _persistenceManager.ReadString(
                Constants.KEY_SQL_METAL_PATH,
                Constants.SQL_METAL_DEFAULT_PATH);

            /*
             * Populate the filename with the database name.
             */

            _filenameTextBox.Text = GetOutputFilename();

            /*
             * Update the UI
             */

            Text = Resources.SqlMetalFormTitle;
            _filenameLabel.Text     = Resources.SqlMetalFormFilename;
            _includeGroupBox.Text   = Resources.SqlMetalFormIncludeGroup;
            _viewsCheckBox.Text     = Resources.SqlMetalFormViews;
            _functionsCheckBox.Text = Resources.SqlMetalFormFunctions;
            _sprocsCheckBox.Text    = Resources.SqlMetalFormSprocs;
            _okButton.Text          = Resources.SqlMetalFormOk;
            _cancelButton.Text      = Resources.SqlMetalFormCancel;

            CheckToolAvailable();

            /*
             * Allow client applications to modify form.
             */

            SqlMetalFormProxy.GetInstance().
            UpdateFormControls(Controls);
        }
Beispiel #22
0
        public NHEntityStore(ITypesInfo typesInfo, IPersistenceManager persistenceManager)
        {
            Guard.ArgumentNotNull(typesInfo, "typesInfo");
            Guard.ArgumentNotNull(persistenceManager, "persistenceManager");

            this.typesInfo = typesInfo;
            this.persistenceManager = persistenceManager;
        }
Beispiel #23
0
        protected void Application_End()
        {
            ModuleManager.ShutdownModules();
            IPersistenceManager pManager = PersistenceFactory.GetPersistenceManager();

            pManager.Shutdown(); // release all data access related resources!
            IoCFactory.ShutdownContainer();
        }
        static ResourceTableTests()
        {
#if SILVERLIGHT
            PersistenceManager = new IsolatedStoragePersistanceManager();
#else
            PersistenceManager = new FilePersistenceManager();
#endif
        }
 internal NHibernateBulkUnitOfWork(NHibernatePersistenceManager persistenceManager, Conversation conversation, bool autoCommit = false, bool throwExceptionOnError = true)
 {
     this.PersistenceManager    = persistenceManager;
     this.autoCommit            = autoCommit;
     this.throwExceptionOnError = throwExceptionOnError;
     this.Conversation          = conversation;
     this.Conversation.Start(this);
 }
 public NHObjectSpaceProvider(ITypesInfo typesInfo, IPersistenceManager persistenceManager, ISelectDataSecurityProvider selectDataProvider)
 {
     Guard.ArgumentNotNull(typesInfo, "typesInfo");
     Guard.ArgumentNotNull(persistenceManager, "persistenceManager");
     this.typesInfo          = typesInfo;
     this.persistenceManager = persistenceManager;
     this.selectDataProvider = selectDataProvider;
 }
            public SceneReferenceItem(IPersistenceManager persistenceManager, Guid sceneGuid, bool isStartup)
            {
                m_PersistenceManager = persistenceManager;

                IsStartup = isStartup;
                SceneGuid = sceneGuid;
                ScenePath = m_PersistenceManager.GetSceneAssetPath(SceneGuid);
            }
Beispiel #28
0
        static TestUtils()
        {
#if SILVERLIGHT
            PersistenceManager = new IsolatedStoragePersistanceManager();
#else
            PersistenceManager = new FilePersistenceManager();
#endif
        }
Beispiel #29
0
        static TestUtils()
        {
#if SILVERLIGHT
            PersistenceManager = new IsolatedStoragePersistanceManager();
#else
            PersistenceManager = new FilePersistenceManager();
#endif
        }
 static void Main(string[] args)
 {
     Console.WriteLine("Hello World!");
     var query      = "";
     var parameters = new KeyValueList();
     IPersistenceManager persist = PersistenceFactory.GetDatabase("MYSQL");
     List <Dictionary <string, string> > result = persist.ExecuteQuery(query, parameters);
 }
Beispiel #31
0
        public NHEntityStore(ITypesInfo typesInfo, IPersistenceManager persistenceManager)
        {
            Guard.ArgumentNotNull(typesInfo, "typesInfo");
            Guard.ArgumentNotNull(persistenceManager, "persistenceManager");

            this.typesInfo          = typesInfo;
            this.persistenceManager = persistenceManager;
        }
Beispiel #32
0
        static ResourceTableTests()
        {
#if SILVERLIGHT
            PersistenceManager = new IsolatedStoragePersistanceManager();
#else
            PersistenceManager = new FilePersistenceManager();
#endif
        }
Beispiel #33
0
        public ReplayManager(IPersistenceManager persistenceManager)
        {
            _persistenceManager = persistenceManager;

            _entries = _persistenceManager.Load<ReplayEntries>(ReplayModule.ReplayManagerLibraryPersistenceName, ReplayModule.ReplayManagerPersistenceProviderKey);

            if (_entries == null)
                _entries = new ReplayEntries();
        }
Beispiel #34
0
 private void EnsureEmptyDirectory(IPersistenceManager pm, string dirName)
 {
     if (pm.DirectoryExists(dirName))
     {
         pm.DeleteDirectory(dirName);
     }
     Thread.Sleep(10);
     pm.CreateDirectory(dirName);
 }
 public void SetUp()
 {
     _persistenceManager = new FilePersistenceManager();
     if (Directory.Exists(BaseDirectory))
     {
         Directory.Delete(BaseDirectory, true);
     }
     Directory.CreateDirectory(BaseDirectory);
 }
Beispiel #36
0
 internal NHibernateUnitOfWork(NHibernatePersistenceManager persistenceManager, ISession session, bool autoCommit = false, bool throwExceptionOnError = true, bool allowMultipleCommit = false)
 {
     this.PersistenceManager    = persistenceManager;
     this.autoCommit            = autoCommit;
     this.throwExceptionOnError = throwExceptionOnError;
     this.allowMultipleCommit   = allowMultipleCommit;
     this.Session = session;
     this.Session.BeginTransaction();
 }
 public AssessmentsImagePackage(
     IAssessmentDB assessDB,
     IPersistenceManager PM,
     string packageFileName,
     IUnitSystemPreferenceProvider UnitsSystemProvider)
 {
     this._ZP = new ZipBredPackage(packageFileName, false);
     this._AssessmentsClient = new ERDC.CERL.SMS.Libraries.Service.Managers.Assessments.Assessments(assessDB, PM, (IImageDeletionProvider)this, UnitsSystemProvider, false);
 }
 public void SetUp()
 {
     _persistenceManager = new FilePersistenceManager();
     if (Directory.Exists(BaseDirectory))
     {
         Directory.Delete(BaseDirectory, true);
     }
     Directory.CreateDirectory(BaseDirectory);
 }
 public NHObjectSpaceProvider(ITypesInfo typesInfo, IPersistenceManager persistenceManager, ISelectDataSecurityProvider selectDataProvider)
 {
     Guard.ArgumentNotNull(typesInfo, "typesInfo");
     Guard.ArgumentNotNull(persistenceManager, "persistenceManager");
     this.typesInfo = typesInfo;
     this.persistenceManager = persistenceManager;
     this.selectDataProvider = selectDataProvider;
     ParseCriteriaScope.Init(typesInfo);
 }
        internal KetchupConfiguration(IPersistenceManager persistence)
        {
            Argument.CannotBeNull(
                persistence,
                "persistence",
                "Ketchup must be able to access it's database via an IPersistenceManager");

            this._instance    = new Ketchup();
            this._persistence = persistence;
        }
 public RecordingInputSourceDecorator(IInputSource source, String filePath, IPersistenceManager persistenceManager, Int32 buttonCount)
 {
     _frame = 0;
     _source = source;
     _filePath = filePath;
     _persistenceManager = persistenceManager;
     _previousState = new InputState();
     _data = new ReplayData();
     _buttonCount = buttonCount;
 }
        public StatisticsManager(IPersistenceManager persistenceManager)
        {
            _persistenceManager = persistenceManager;

            _userState = persistenceManager.Load<UserStatisticState>("Statistics.state",
                StatisticsModule.StatisticsStatePersistenceProviderKey);

            if (_userState == null)
                _userState = new UserStatisticState();
        }
        internal KetchupConfiguration(IPersistenceManager persistence)
        {
            Argument.CannotBeNull(
                persistence,
                "persistence",
                "Ketchup must be able to access it's database via an IPersistenceManager");

            this._instance = new Ketchup();
            this._persistence = persistence;
        }
 private DA.Permission GetPermissionForJob(IPersistenceManager pm, Guid jobId, Guid userId) {
   var jobDao = pm.JobDao;
   var jobPermissionDao = pm.JobPermissionDao;
   var job = jobDao.GetById(jobId);
   if (job == null) return DA.Permission.NotAllowed;
   if (job.OwnerUserId == userId) return DA.Permission.Full;
   var jobPermission = jobPermissionDao.GetByJobAndUserId(jobId, userId);
   if (jobPermission == null) return DA.Permission.NotAllowed;
   return jobPermission.Permission;
 }
        private void AuthorizeJob(IPersistenceManager pm, Guid jobId, DT.Permission requiredPermission)
        {
            var requiredPermissionEntity = requiredPermission.ToEntity();

            DA.Permission permission = GetPermissionForJob(pm, jobId, UserManager.CurrentUserId);
            if (permission == Permission.NotAllowed ||
                ((permission != requiredPermissionEntity) && requiredPermissionEntity == Permission.Full))
            {
                throw new SecurityException(NOT_AUTHORIZED);
            }
        }
Beispiel #46
0
 public void Stop()
 {
     if (runStage == RunStage.Production)
     {
         ModuleManager.ShutdownModules();
         IPersistenceManager pManager = PersistenceFactory.GetPersistenceManager();
         pManager.Shutdown(); // release all data access related resources!
         IoCFactory.ShutdownContainer();
         started = false;
     }
 }
        /// <summary>
        /// Start Unit of Work specifying IPersistenceManager
        /// </summary>
        /// <param name="manager">IPersistenceManager</param>
        /// <returns></returns>
        public static IUnitOfWork Start(IPersistenceManager manager)
        {
            if (IsStarted)
                throw new InvalidOperationException("Unit of Work is already started.");

            IUnitOfWork unitOfWork = manager.CreateUnitOfWork();

            LocalUnitOfWork = unitOfWork;

            return unitOfWork;
        }
Beispiel #48
0
 /// <summary>
 /// Searches for slaves which are timed out, puts them and their task offline
 /// </summary>
 private void SetTimeoutSlavesOffline(IPersistenceManager pm) {
   var slaveDao = pm.SlaveDao;
   var slaves = slaveDao.GetOnlineSlaves();
   foreach (var slave in slaves) {
     if (!slave.LastHeartbeat.HasValue ||
         (DateTime.Now - slave.LastHeartbeat.Value) >
         Properties.Settings.Default.SlaveHeartbeatTimeout) {
       slave.SlaveState = SlaveState.Offline;
     }
   }
 }
        public void Setup()
        {
            var moqManager = new Mock<IPersistenceManager>();
            _manager = moqManager.Object;

            var moqUnitOfWork = new Mock<UnitOfWorkBase>();
            moqUnitOfWork.CallBase = true;

            moqManager.Expect(x => x.CreateUnitOfWork())
                .Returns(moqUnitOfWork.Object);
        }
Beispiel #50
0
        public void SetUp()
        {
            if (_connectionString.Contains("type=rest"))
            {
                StartService();
            }
#if PORTABLE
        _persistenceManager = new PersistenceManager();
#endif
            CopyTestDataToImportFolder("graph_triples.nt");

        }
        private ResourceManager()
        {
            persistenceManager = new DiskPersistenceManager(Settings);

            globalChunkCache = new GlobalChunkCache(
                (p, i) => loadChunkColumn(p, i),
                (p, i, c) => saveChunkColumn(p, i, c));

            planets = new Dictionary<int, IPlanet>();

            bool.TryParse(Settings.Get<string>("DisablePersistence"), out disablePersistence);
        }
Beispiel #52
0
        static PageFileTests()
        {
#if SILVERLIGHT
            PersistenceManager = new IsolatedStoragePersistanceManager();
#else
            PersistenceManager = new FilePersistenceManager();
#endif
            TestBuffer = new byte[8192];
            for (ulong i = 0; i < 1024; i++ )
            {
                BitConverter.GetBytes(i).CopyTo(TestBuffer, (int)i*8);
            }
        }
Beispiel #53
0
 public static void Initialise(string logFileName, bool enableDebug = false)
 {
     _persistenceManager = PlatformAdapter.Resolve<IPersistenceManager>();
     if (logFileName != null)
     {
         if (!_persistenceManager.FileExists(logFileName))
         {
             _persistenceManager.CreateFile(logFileName);
         }
         _logFileName = logFileName;
     }
     IsDebugEnabled = enableDebug;
 }
 private IEnumerable<DT.TaskStatus> GetTaskStatus(IPersistenceManager pm) {
   return pm.UseTransaction(() => {
     var query = pm.DataContext.ExecuteQuery<UserTaskStatus>(SQL_USER_TASK_STATUS).ToList();
     return query.Select(uts => new DT.TaskStatus {
       User = new DT.User {
         Id = uts.UserId.ToString(),
         Name = ServiceLocator.Instance.UserManager.GetUserNameById(uts.UserId)
       },
       CalculatingTasks = uts.CalculatingTasks,
       WaitingTasks = uts.WaitingTasks
     }).OrderBy(x => x.User.Name);
   });
 }
        public AchievementsManager(IAchievementsService achievementsService, ISettingsManager settingsManager, IPersistenceManager persistenceManager, IEventAggregator eventAggregator)
        {
            _settingsManager = settingsManager;
            _persistenceManager = persistenceManager;
            _achievementsService = achievementsService;
            _eventAggregator = eventAggregator;

            eventAggregator.Subscribe<LoggedOnEvent>((ev) =>
                {
                    SynchronizeAchievementDefinitions();
                    SynchronizeAchievementState();
                });

            eventAggregator.Subscribe<EmulatorStartingEvent>(EmulatorStarting);
        }
Beispiel #56
0
 public static MasterFile Open(IPersistenceManager persistenceManager, string directoryPath)
 {
     var masterFilePath = Path.Combine(directoryPath, MasterFileName);
     if (!persistenceManager.FileExists(masterFilePath))
     {
         throw new StoreManagerException(directoryPath, "Master file not found");
     }
     var mf = new MasterFile(persistenceManager, directoryPath, masterFilePath,
                             StoreConfiguration.DefaultStoreConfiguration, Guid.Empty);
     using (var mfStream = persistenceManager.GetInputStream(masterFilePath))
     {
         mf.Load(mfStream);
     }
     return mf;
 }
Beispiel #57
0
 /// <summary>
 /// Looks for parent tasks which have FinishWhenChildJobsFinished and set their state to finished
 /// </summary>
 private void FinishParentTasks(IPersistenceManager pm) {
   var resourceDao = pm.ResourceDao;
   var taskDao = pm.TaskDao;
   var resourceIds = resourceDao.GetAll().Select(x => x.ResourceId).ToList();
   var parentTasksToFinish = taskDao.GetParentTasks(resourceIds, 0, true);
   foreach (var task in parentTasksToFinish) {
     task.State = TaskState.Finished;
     task.StateLogs.Add(new StateLog {
       State = task.State,
       SlaveId = null,
       UserId = null,
       Exception = string.Empty,
       DateTime = DateTime.Now
     });
   }
 }
        public GameLibraryManager(IDirectoryManager directoryManager, IPersistenceManager persistenceManager, IEventAggregator eventAggregator)
        {
            _directoryManager = directoryManager;
            _persistenceManager = persistenceManager;
            _games = new List<GameInfo>();
            _providers = new List<IGameInfoProvider>();
            eventAggregator.Subscribe<GameSelectedEvent>(ev =>
                {
                    var gse = ev as GameSelectedEvent;
                    this.UpdateGameInfo(gse.Game);
                });

            _gameInfoEntries = persistenceManager.Load<GameInfoEntries>(GameLibraryModule.GameLibraryPersistenceName, GameLibraryModule.GameLibraryPersistenceProviderKey);

            if (_gameInfoEntries == null)
                _gameInfoEntries = new GameInfoEntries();
        }
Beispiel #59
0
 public static MasterFile Create(IPersistenceManager persistenceManager, string directoryPath,
                                 StoreConfiguration storeConfiguration, Guid storeSetId)
 {
     var masterFilePath = Path.Combine(directoryPath, MasterFileName);
     if (persistenceManager.FileExists(masterFilePath))
     {
         throw new StoreManagerException(directoryPath, "Master file already exists");
     }
     persistenceManager.CreateFile(masterFilePath);
     using (var stream = persistenceManager.GetOutputStream(masterFilePath, FileMode.Open))
     {
         var newMaster = new MasterFile(persistenceManager, directoryPath, masterFilePath, storeConfiguration,
                                        storeSetId);
         newMaster.Save(stream);
         return newMaster;
     }
 }
Beispiel #60
0
        //Here to support dependency injection
        public MainViewModel(IWindowManager windowManager, IInformationProvider infoProvider,
            IPersistenceManager persistenceManager)
        {
            DisplayName = "Sojurn";
            wm = windowManager;
            pm = persistenceManager;
            this.infoProvider = infoProvider;

            Shows = new CollectionViewSource {Source = shows};
            Shows.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));

            TimeLine = new CollectionViewSource {Source = timeLine};
            TimeLine.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending));
            TimeLine.GroupDescriptions.Add(new PropertyGroupDescription("Date"));

            Backlog = new CollectionViewSource {Source = backlog};
            Backlog.GroupDescriptions.Add(new PropertyGroupDescription("ShowName"));
            Backlog.SortDescriptions.Add(new SortDescription("ShowName", ListSortDirection.Ascending));
            Backlog.SortDescriptions.Add(new SortDescription("SeasonNumber", ListSortDirection.Ascending));
            Backlog.SortDescriptions.Add(new SortDescription("EpisodeNumberThisSeason", ListSortDirection.Ascending));
        }