public void Prepare(Delta delta)
        {
            Console.WriteLine("Pozvan je prepare na NMS-u");
            IDistributedTransactionCallback callback = OperationContext.Current.GetCallbackChannel <IDistributedTransactionCallback>();

            try
            {
                UpdateResult updateResult = gda.ApplyUpdate(delta);
                if (updateResult.Result == ResultType.Succeeded)
                {
                    callback.CallbackPrepare(true);
                }
                else
                {
                    //Rollback();
                    callback.CallbackPrepare(false);
                }
            }
            catch (Exception ex)
            {
                //Rollback();
                callback.CallbackPrepare(false); // problematicno ako se desi exception u pozivu, nece se uhvatiti
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void Prepare(Delta delta)
        {
            Console.WriteLine("Pozvan je prepare na DMS-u");

            newTree = DMSServiceHost.Instance.InitializeNetwork(delta);
            DMSServiceHost.updatesCount += 1;
            IDistributedTransactionCallback callback = OperationContext.Current.GetCallbackChannel <IDistributedTransactionCallback>();

            if (newTree.Data.Values.Count != 0)
            {
                callback.CallbackPrepare(true);
            }
            else
            {
                callback.CallbackPrepare(false);
            }
        }
        /// <summary>
        /// Trying to apply, APPLYING if it is possible, and write new configuration to new file
        /// </summary>
        /// <param name="delta"></param>
        public void Prepare(ScadaDelta delta)
        {
            Console.WriteLine("Pozvan je Prepare na SCADA");

            IDistributedTransactionCallback callback = OperationContext.Current.GetCallbackChannel <IDistributedTransactionCallback>();

            if (dbContext.ApplyDelta(delta))
            {
                try
                {
                    ScadaModelParser parser = new ScadaModelParser();

                    // to do:
                    // mozda ove serijaliyacije da budu taskovi_
                    // novu konfiguraciju cuvamo u fajlu
                    parser.SerializeScadaModel(modifiedConfigFile);

                    Console.WriteLine("Prepare true");
                    callback.CallbackPrepare(true);
                }
                catch (Exception ex)
                {
                    ScadaModelParser parser = new ScadaModelParser();
                    parser.DeserializeScadaModel(); // returning to old state (state was previosuly changed in apply delta)

                    Console.WriteLine(ex.Message);
                    Console.WriteLine("1Prepare false");
                    callback.CallbackPrepare(false);
                }
            }
            else
            {
                ScadaModelParser parser = new ScadaModelParser();
                parser.DeserializeScadaModel(); // returning to old state (state was previosuly changed in apply delta)
                Console.WriteLine("2Prepare false");
                callback.CallbackPrepare(false);
            }
        }