コード例 #1
0
        //        private static responseTipTaskContext responseTipDatabase = new responseTipTaskContext();



        static void Main(string[] args)
        {
            string directoryPath = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

            backendLogger.SetPath(directoryPath);

            Startup.Configuration();

            backendLogger.LogLine("Backend_main configured...continuing", Logger.log_types.MESSAGE_LOG);

            arbiterFinder = new ArbiterFinder(dbContext);

            //      CleanTaskDatabase();

            //            decimal dollarPrice=externalAPIs.CallForBitcoinAverageDollarPrice();

            StateUpdateManager responseTipStateUpdateManager = new StateUpdateManager(typeof(TaskStatusesEnum));
            int responseTipStatesToUpdate = 0;

            StateUpdateManager textAnswerValidationUpdateManager = new StateUpdateManager(typeof(ArbiterTaskStatusesEnum));
            int textAnswerValidationStatesToUpdate = 0;

            while (true)//infinite loop
            {
                if (BtcHandlingClass.IsNextBlock())
                {
                    backendLogger.LogLine("New Block", Logger.log_types.MESSAGE_LOG);
                    responseTipStateUpdateManager.NewBlock();
                }

                BtcHandlingClass.UpdateKeyPool(ConfigurationManager.AppSettings["Bitcoin_WalletPassword"]);

                responseTipStatesToUpdate = responseTipStateUpdateManager.StatesToUpdateNow();
                responseTipStatePusherCycle(responseTipStatesToUpdate);

                textAnswerValidationStatesToUpdate = textAnswerValidationUpdateManager.StatesToUpdateNow();
                textAnswerValidationStatePusherCycle(textAnswerValidationStatesToUpdate);


                //reloads data from database
                var context = ((IObjectContextAdapter)dbContext).ObjectContext;

                /*                var refreshableObjects = (from entry in context.ObjectStateManager.GetObjectStateEntries(
                 *                                                         EntityState.Added
                 | EntityState.Deleted
                 | EntityState.Modified
                 | EntityState.Unchanged)
                 |                                        where entry.EntityKey != null
                 |                                        select entry.Entity).ToList();
                 */
                var refreshableObjects = dbContext.ChangeTracker.Entries().Select(c => c.Entity).ToList();
                context.Refresh(RefreshMode.StoreWins, refreshableObjects);
            }

            dbContext.TextAnswerValidationTasks.Load();


//            dbContext.Dispose();
//          dbContext = new ApplicationDbContext();
        }
コード例 #2
0
ファイル: backend_main.cs プロジェクト: GereG/ResponseTip
        //        private static responseTipTaskContext responseTipDatabase = new responseTipTaskContext();
        static void Main(string[] args)
        {
            string directoryPath = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
            backendLogger.SetPath(directoryPath);

            Startup.Configuration();

            backendLogger.LogLine("Backend_main configured...continuing", Logger.log_types.MESSAGE_LOG);

            arbiterFinder = new ArbiterFinder(dbContext);

              //      CleanTaskDatabase();

            //            decimal dollarPrice=externalAPIs.CallForBitcoinAverageDollarPrice();

            StateUpdateManager responseTipStateUpdateManager = new StateUpdateManager(typeof(TaskStatusesEnum));
            int responseTipStatesToUpdate = 0;

            StateUpdateManager textAnswerValidationUpdateManager = new StateUpdateManager(typeof(ArbiterTaskStatusesEnum));
            int textAnswerValidationStatesToUpdate = 0;

            while (true)//infinite loop
            {
                if (BtcHandlingClass.IsNextBlock())
                {
                    backendLogger.LogLine("New Block", Logger.log_types.MESSAGE_LOG);
                    responseTipStateUpdateManager.NewBlock();
                }

                BtcHandlingClass.UpdateKeyPool(ConfigurationManager.AppSettings["Bitcoin_WalletPassword"]);

                responseTipStatesToUpdate = responseTipStateUpdateManager.StatesToUpdateNow();
                responseTipStatePusherCycle(responseTipStatesToUpdate);

                textAnswerValidationStatesToUpdate = textAnswerValidationUpdateManager.StatesToUpdateNow();
                textAnswerValidationStatePusherCycle(textAnswerValidationStatesToUpdate);

                //reloads data from database
                               var context = ((IObjectContextAdapter)dbContext).ObjectContext;
                /*                var refreshableObjects = (from entry in context.ObjectStateManager.GetObjectStateEntries(
                                                                           EntityState.Added
                                                                           | EntityState.Deleted
                                                                           | EntityState.Modified
                                                                           | EntityState.Unchanged)
                                                          where entry.EntityKey != null
                                                          select entry.Entity).ToList();
                                                          */
                var refreshableObjects = dbContext.ChangeTracker.Entries().Select(c => c.Entity).ToList();
                context.Refresh(RefreshMode.StoreWins, refreshableObjects);
            }

            dbContext.TextAnswerValidationTasks.Load();

            //            dbContext.Dispose();
              //          dbContext = new ApplicationDbContext();
        }