public void recoverySelf(ModelsState state)
        {
            HandModifiedDataState copy = (HandModifiedDataState)state;

            this.state = copy.copy();
            notifyObservers();
        }
Exemple #2
0
 public override Config read(ModelsState modelsState, Config newConfig)
 {
     if (newConfig.logs != null)
     {
         modelsState.config.logs = new List <string>();
         for (int i = 0; i < newConfig.logs.Count; i++)
         {
             if (!File.Exists(newConfig.logs.ElementAt(i)))
             {
                 showErrorMessage("Один или несколько указанных файлов с логами" +
                                  " не сущестует(ют)");
                 modelsState.result = new Result(new CancelType());
                 return(modelsState.config);
             }
         }
         for (int i = 0; i < newConfig.logs.Count; i++)
         {
             modelsState.config.logs.Add(newConfig.logs.ElementAt(i));
         }
         modelsState.result = new Result(new OkType());
         return(modelsState.config);
     }
     else
     {
         return(giveNext(modelsState, newConfig));
     }
 }
        private bool dataBaseReady(ModelsState currentState)
        {
            //Проверка, доступна ли таблицы БД. Если доступны, то ранее уже
            //создавалась структура БД и есть минимум один администратор
            //(копия этой программы установлена на другом компьютере и уже все сделала)
            //Если нет, то нужно создать структуру таблиц и администратора
            List <string> checkTables = new List <string>();

            checkTables.Add("SELECT 1 FROM Users");
            checkTables.Add("SELECT 1 FROM Vendor");
            checkTables.Add("SELECT 1 FROM Software");
            checkTables.Add("SELECT 1 FROM History");
            checkTables.Add("SELECT 1 FROM UST");

            bool ready = true;
            MsSqlServerController msSqlServerController = new MsSqlServerController();

            for (int i = 0; i < checkTables.Count; i++)
            {
                if (!msSqlServerController.configAndExecute(currentState.config.connection,
                                                            checkTables.ElementAt(i)))
                {
                    ready = false;
                    break;
                }
            }
            return(ready);
        }
 public Config giveNext(ModelsState modelsState, Config newConfig)
 {
     if (next != null)
     {
         return(next.read(modelsState, newConfig));
     }
     else
     {
         throw new FinishChain();
     }
 }
Exemple #5
0
 public override Config read(ModelsState modelsState, Config newConfig)
 {
     if (newConfig.date != null)
     {
         modelsState.config.date = newConfig.date;
         modelsState.result      = new Result(new OkType());
         return(modelsState.config);
     }
     else
     {
         return(giveNext(modelsState, newConfig));
     }
 }
 public override Config read(ModelsState modelsState, Config newConfig)
 {
     if (newConfig.timeType != null & newConfig.modificator != -1)
     {
         modelsState.config.modificator = newConfig.modificator;
         modelsState.config.timeType    = newConfig.timeType;
         modelsState.result             = new Result(new OkType());
         return(modelsState.config);
     }
     else
     {
         return(giveNext(modelsState, newConfig));
     }
 }
        public override void calculationStatistics()
        {
            config.setRollbackReport(false);
            ModelsState backup = copySelf();

            for (int i = 0; i < config.getNumberOfStartsModeling(); i++)
            {
                run_simulation();
                if (i == 0)
                {
                    report = new ModelingReport(state);
                }
                report.updateReport(state);
                recoverySelf(backup);
            }
            config.setRollbackReport(true);
        }
Exemple #8
0
        public override void recoverySelf(ModelsState oldState)
        {
            MarcovitsModelState oldMarcovitsState = (MarcovitsModelState)oldState;

            state.income   = oldMarcovitsState.income;
            state.interval = oldMarcovitsState.interval;

            if (oldMarcovitsState.unicSoftwareNames != null)
            {
                state.unicSoftwareNames = (string[])oldMarcovitsState.unicSoftwareNames.Clone();
            }

            if (oldMarcovitsState.avgNumbersUseLicense != null)
            {
                state.avgNumbersUseLicense = (double[])oldMarcovitsState.avgNumbersUseLicense.Clone();
            }

            if (oldMarcovitsState.avgDeviationFromPurchasedNumber != null)
            {
                state.avgDeviationFromPurchasedNumber = (double[])oldMarcovitsState.
                                                        avgDeviationFromPurchasedNumber.Clone();
            }

            if (oldMarcovitsState.numberBuyLicense != null)
            {
                state.numberBuyLicense = (double[])oldMarcovitsState.numberBuyLicense.Clone();
            }

            if (oldMarcovitsState.percents != null)
            {
                state.percents = (double[, ])oldMarcovitsState.percents.Clone();
            }

            if (oldMarcovitsState.risk != null)
            {
                state.risk = (double[, ])oldMarcovitsState.risk.Clone();
            }

            for (int i = 0; i < oldMarcovitsState.data.Count; i++)
            {
                state.data.Add(oldMarcovitsState.data.ElementAt(i).copy());
            }

            notifyObservers();
        }
 public ModelsState install(ModelsState currentState)
 {
     if (dataBaseReady(currentState))
     {
         if (currentState.config.programType.getType().Equals("AnalitycsType"))
         {
             try
             {
                 installer.installAnalytics(currentState.config.programPath,
                                            currentState.config.connection);
                 currentState.result = new Result(new OkType());
                 return(currentState);
             }
             catch (Exception ex)
             {
                 ExceptionHandler.Concrete.ExceptionHandler.getInstance().processing(ex);
                 currentState.result = new Result(new CancelType());
                 return(currentState);
             }
         }
         else
         {
             try
             {
                 Director installDirector = new Director(new ConcreteIntallBuilder());
                 installDirector.install(currentState.config.copy());
                 currentState.result = new Result(new OkType());
                 return(currentState);
             }
             catch (Exception ex)
             {
                 ExceptionHandler.Concrete.ExceptionHandler.getInstance().processing(ex);
                 currentState.result = new Result(new CancelType());
                 return(currentState);
             }
         }
     }
     else
     {
         currentState.result = new Result(new DataBaseHaventTablesType());
         return(currentState);
     }
 }
Exemple #10
0
 public override Config read(ModelsState modelsState, Config newConfig)
 {
     if (newConfig.connection != null)
     {
         if (controller.configAndCheckConnect(newConfig.connection))
         {
             modelsState.config.connection = newConfig.connection;
             modelsState.result            = new Result(new ConnectionReadyType());
             return(modelsState.config);
         }
         else
         {
             modelsState.result = new Result(new ConnectionNotReadyType());
             return(modelsState.config);
         }
     }
     else
     {
         return(giveNext(modelsState, newConfig));
     }
 }
Exemple #11
0
 public override Config read(ModelsState modelsState, Config newConfig)
 {
     if (newConfig.programPath != null)
     {
         if (Directory.Exists(newConfig.programPath))
         {
             modelsState.config.programPath = newConfig.programPath;
             modelsState.result             = new Result(new OkType());
             return(modelsState.config);
         }
         else
         {
             showErrorMessage("Ошибка: указанный путь не существует.");
             modelsState.result = new Result(new CancelType());
             return(modelsState.config);
         }
     }
     else
     {
         return(giveNext(modelsState, newConfig));
     }
 }
Exemple #12
0
 public void recoverySelf(ModelsState state)
 {
     this.state = (ConcreteModelsState)state;
 }
 public ConfigModelCommand(Model model, ParseConfig config)
 {
     this.model  = model;
     state       = this.model.copySelf();
     this.config = config;
 }
Exemple #14
0
 public ParseCommand(Model model)
 {
     this.model = model;
     state      = this.model.copySelf();
 }
        public override void recoverySelf(ModelsState backUpState)
        {
            ModelingState oldState = (ModelingState)backUpState;

            state = new ModelingState();
            state.last_tranzaktions_id = oldState.last_tranzaktions_id;
            state.time_of_modeling     = oldState.time_of_modeling;
            state.idProcessingTranzact = oldState.idProcessingTranzact;
            state.rand = oldState.rand;
            config     = oldState.report.getConfig().copy();

            string[] originalRulesC = new string[oldState.originalRules.Count];
            oldState.originalRules.CopyTo(originalRulesC);
            for (int i = 0; i < originalRulesC.Length; i++)
            {
                state.originalRules.Add(originalRulesC[i]);
            }

            for (int i = 0; i < oldState.queues.Count; i++)
            {
                state.queues.Add(oldState.queues.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.tranzakts.Count; i++)
            {
                state.tranzakts.Add(oldState.tranzakts.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.lables.Count; i++)
            {
                state.lables.Add(oldState.lables.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.devices.Count; i++)
            {
                state.devices.Add(oldState.devices.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.storages.Count; i++)
            {
                state.storages.Add(oldState.storages.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.variables.Count; i++)
            {
                state.variables.Add(oldState.variables.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.tranzation_generators.Count; i++)
            {
                state.tranzation_generators.Add(oldState.tranzation_generators.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.newRules.Count; i++)
            {
                state.newRules.Add(oldState.newRules.ElementAt(i).clone());
            }

            //Откат report нужен только в случае отката всей
            //модели для просматра предыдущих результатов ее работы
            if (config.isRollbackReport())
            {
                report = oldState.report.copyReport(oldState);
            }

            notifyObservers();
        }
Exemple #16
0
 abstract public void recoverySelf(ModelsState state);
 abstract public Config read(ModelsState modelsState, Config newConfig);
Exemple #18
0
 public Config updateConfig(ModelsState modelsState, Config newConfig)
 {
     return(firstConfigReader.read(modelsState, newConfig));
 }