Ejemplo n.º 1
0
        public void TestValidation2Event()
        {
            //Test the function of UpdateCommitLowerBound() in the event-driven senario.
            TransactionExecution tex1 = new TransactionExecution(null, this.versionDb);

            while (tex1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.InitTx();
            }

            UpdateCommitLowerBoundRequest txCommitReq = new UpdateCommitLowerBoundRequest(tex1.txId, 5L);

            this.versionDb.EnqueueTxEntryRequest(tex1.txId, txCommitReq);

            this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            while (txCommitReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            long txCommitTs            = txCommitReq.Result == null ? VersionDb.RETURN_ERROR_CODE : (long)txCommitReq.Result;
            GetTxEntryRequest getTxReq = new GetTxEntryRequest(tex1.txId);

            this.versionDb.EnqueueTxEntryRequest(tex1.txId, getTxReq);
            while (getTxReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            TxTableEntry txEntry = getTxReq.Result as TxTableEntry;

            Assert.AreEqual(5L, txEntry.CommitLowerBound);
            Assert.AreEqual(-1L, txCommitTs);

            //Test the function of SetCommitTs() in the event-driven senario.
            SetCommitTsRequest setTsReq = new SetCommitTsRequest(tex1.txId, 6L);

            this.versionDb.EnqueueTxEntryRequest(tex1.txId, setTsReq);
            while (setTsReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            long commitTime = setTsReq.Result == null ? -1 : (long)setTsReq.Result;

            Assert.AreEqual(6L, commitTime);
        }
Ejemplo n.º 2
0
        public void TestPostProcessing1Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texUpdate.Update(TABLE_ID, DEFAULT_KEY, "value_update");
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Upload();
            }
            texUpdate.Abort();
            while (texUpdate.CurrentProc != new Procedure(texUpdate.PostProcessingAfterAbort))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Abort();
            }
            texUpdate.PostProcessingAfterAbort();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.PostProcessingAfterAbort();
            }

            Assert.AreEqual(null, this.GetVersionByKey(2L));
            VersionEntry versionEntry = this.GetVersionByKey(1L);

            Assert.AreEqual(0L, versionEntry.BeginTimestamp);
            Assert.AreEqual(long.MaxValue, versionEntry.EndTimestamp);
            Assert.AreEqual(-1L, versionEntry.TxId);
        }
Ejemplo n.º 3
0
        public void TestPostProcessing3Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texUpdate.Update(TABLE_ID, DEFAULT_KEY, "value_update");
            texUpdate.maxCommitTsOfWrites = 4L;
            texUpdate.Commit();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.CurrentProc();
            }

            VersionEntry newVersionEntry = this.GetVersionByKey(2L);

            Assert.AreEqual(5L, newVersionEntry.BeginTimestamp);
            Assert.AreEqual(long.MaxValue, newVersionEntry.EndTimestamp);
            Assert.AreEqual(-1L, newVersionEntry.TxId);

            VersionEntry oldVersionEntry = this.GetVersionByKey(1L);

            Assert.AreEqual(0L, oldVersionEntry.BeginTimestamp);
            Assert.AreEqual(5L, oldVersionEntry.EndTimestamp);
            Assert.AreEqual(-1L, oldVersionEntry.TxId);
        }
Ejemplo n.º 4
0
        public void TestSetGetCommitTs2Event()
        {
            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex.Update(TABLE_ID, DEFAULT_KEY, "value_update");
            tex.Commit();
            while (tex.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.CurrentProc();
            }

            GetTxEntryRequest getTxReq = new GetTxEntryRequest(tex.txId);

            this.versionDb.EnqueueTxEntryRequest(tex.txId, getTxReq);
            this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            while (getTxReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            TxTableEntry txEntry = getTxReq.Result as TxTableEntry;

            Assert.AreEqual(1L, txEntry.CommitTime);
        }
Ejemplo n.º 5
0
        public void TestReplaceOldCase9Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            texUpdate.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate.SetCommitTimestamp), texUpdate.CurrentProc);

            TransactionExecution texUpdate1 = new TransactionExecution(null, this.versionDb);

            texUpdate1.DEBUG_MODE = true;
            while (texUpdate1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.InitTx();
            }
            texUpdate1.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead1, out object payloadRead1);
            while (!receivedRead1)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.Read(TABLE_ID, DEFAULT_KEY, out receivedRead1, out payloadRead1);
            }

            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(texUpdate.Validate), texUpdate.CurrentProc);
            texUpdate.Validate();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Validate();
            }
            Assert.AreEqual(new Procedure(texUpdate.WriteToLog), texUpdate.CurrentProc);
            texUpdate.WriteToLog();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.WriteToLog))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.WriteToLog();
            }
            Assert.AreEqual(new Procedure(texUpdate.PostProcessingAfterCommit), texUpdate.CurrentProc);
            texUpdate.PostProcessingAfterCommit();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.PostProcessingAfterCommit();
            }

            texUpdate1.Update(TABLE_ID, DEFAULT_KEY, "value_update_1");
            texUpdate1.Upload();
            while (texUpdate1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate1.Abort), texUpdate1.CurrentProc);
        }
Ejemplo n.º 6
0
        // case2: upload new inserted entry failed under event-driven senario.
        public void TestUploadNewCase2Event()
        {
            TransactionExecution texDelete = new TransactionExecution(null, this.versionDb);

            while (texDelete.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.InitTx();
            }
            texDelete.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texDelete.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texDelete.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texDelete.Commit();
            while (texDelete.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.CurrentProc();
            }

            TransactionExecution texInsert = new TransactionExecution(null, this.versionDb);

            texInsert.DEBUG_MODE = true;
            while (texInsert.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texInsert.InitTx();
            }
            texInsert.ReadAndInitialize(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texInsert.ReadAndInitialize(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            texInsert.Insert(TABLE_ID, DEFAULT_KEY, "value_insert");
            texInsert.Upload();
            while (texInsert.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texInsert.Upload();
            }
            Assert.AreEqual(new Procedure(texInsert.SetCommitTimestamp), texInsert.CurrentProc);


            TransactionExecution texInsert1 = new TransactionExecution(null, this.versionDb);

            texInsert1.DEBUG_MODE = true;
            while (texInsert1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texInsert1.InitTx();
            }
            texInsert1.ReadAndInitialize(TABLE_ID, DEFAULT_KEY, out bool receivedInsert1, out object payloadInsert1);
            while (!receivedInsert1)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texInsert1.ReadAndInitialize(TABLE_ID, DEFAULT_KEY, out receivedInsert1, out payloadInsert1);
            }
            texInsert1.Insert(TABLE_ID, DEFAULT_KEY, "value_insert1");
            texInsert1.Upload();
            while (texInsert1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texInsert1.Upload();
            }
            Assert.AreEqual(new Procedure(texInsert1.Abort), texInsert1.CurrentProc);
        }
Ejemplo n.º 7
0
 static internal bool IsAborted(this TransactionExecution self)
 {
     return(self.TxStatus == TxStatus.Aborted);
 }
Ejemplo n.º 8
0
 static internal TransactionExecution Read(
     this TransactionExecution self, object key)
 {
     self.SyncRead(YcsbHelper.YCSB_TABLE, key);
     return(self);
 }
Ejemplo n.º 9
0
 static internal TransactionExecution Insert(
     this TransactionExecution self, object key, object val)
 {
     self.InitAndInsert(YcsbHelper.YCSB_TABLE, key, val);
     return(self);
 }
Ejemplo n.º 10
0
        public void TestPostProcessing4Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texUpdate.Update(TABLE_ID, DEFAULT_KEY, "value_update");
            texUpdate.maxCommitTsOfWrites = 4L;
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Upload();
            }
            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            texUpdate.Validate();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Validate();
            }
            Assert.AreEqual(new Procedure(texUpdate.WriteToLog), texUpdate.CurrentProc);
            texUpdate.WriteToLog();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.WriteToLog))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.WriteToLog();
            }

            TransactionExecution texDelete = new TransactionExecution(null, this.versionDb);

            texDelete.DEBUG_MODE = true;
            while (texDelete.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.InitTx();
            }
            texDelete.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            texDelete.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texDelete.Upload();
            while (texDelete.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.Upload();
            }

            texUpdate.PostProcessingAfterCommit();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.PostProcessingAfterCommit();
            }

            VersionEntry newVersionEntry = this.GetVersionByKey(2L);

            Assert.AreEqual(5L, newVersionEntry.BeginTimestamp);
            Assert.AreEqual(long.MaxValue, newVersionEntry.EndTimestamp);
            Assert.AreEqual(texDelete.txId, newVersionEntry.TxId);

            VersionEntry oldVersionEntry = this.GetVersionByKey(1L);

            Assert.AreEqual(0L, oldVersionEntry.BeginTimestamp);
            Assert.AreEqual(5L, oldVersionEntry.EndTimestamp);
            Assert.AreEqual(-1L, oldVersionEntry.TxId);
        }
        public List <KeyValuePair <string, string> > GetDavl(string dataname, string davlType, string sqlStatement, string[] sqlParameters)
        {
            UserContext Context = (UserContext)HttpContext.Current.Session["UserContext"];

            TransactionExecution Execution = new TransactionExecution(Context);
            List <KeyValuePair <string, string> > ReturnValue = new List <KeyValuePair <string, string> >();
            DataTable FieldChoiceValues = null;
            string    CacheKey          = "";

            if (davlType == "SQL")
            {
                CacheKey = davlType + "_" +
                           sqlStatement.GetHashCode().ToString() + "_" +
                           sqlStatement.ToUpperInvariant().GetHashCode().ToString() + "_" +
                           Context.TroposServer + "_" + Context.TroposDatabase + "_" +
                           Context.TroposSession.Language;
                if (sqlParameters != null)
                {
                    int i = 0;
                    foreach (string sqlParameter in sqlParameters)
                    {
                        i = i ^ sqlParameter.GetHashCode();
                    }
                    CacheKey = CacheKey + "_" + i.ToString();
                }
            }
            else
            {
                CacheKey = davlType + "_" + dataname + "_" + Context.TroposServer + "_" + Context.TroposDatabase + "_" + Context.TroposSession.Language;
            }
            if (HttpContext.Current.Cache[CacheKey] == null)
            {
                switch (davlType)
                {
                case "UOM":
                    FieldChoiceValues = Execution.GetUOMChoices();
                    break;

                case "YorN":
                case "YorM":
                    FieldChoiceValues = Execution.GetFieldChoiceValues(davlType.ToUpper(CultureInfo.InvariantCulture));
                    break;

                case "SQL":
                    FieldChoiceValues = GetSqlFieldChoices(Context, sqlStatement, sqlParameters);
                    break;

                case "Yes":
                    FieldChoiceValues = Execution.GetFieldChoiceValues(dataname);
                    break;

                default:
                    FieldChoiceValues = new DataTable();
                    break;
                }
                HttpContext.Current.Cache.Insert(CacheKey, FieldChoiceValues, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(60));
            }
            else
            {
                FieldChoiceValues = (DataTable)HttpContext.Current.Cache[CacheKey];
            }
            if (FieldChoiceValues.Rows.Count == 0)
            {
                ReturnValue.Add(new KeyValuePair <string, string>("?", "No field choices available"));
                ;
            }
            else
            {
                foreach (DataRow Row in FieldChoiceValues.Rows)
                {
                    ReturnValue.Add(new KeyValuePair <string, string>((string)Row["Code"], (string)Row["Description"]));
                }
            }
            return(ReturnValue);
        }
Ejemplo n.º 12
0
        private void DoTransaction(string TransactionCode)
        {
            TransactionExecution Execution = new TransactionExecution(this.UserContext);
            bool ReturnAfterDcal           = false;

            if (this.UserContext.Status != TroposStatus.AwaitingTransaction)
            {
                Execution.DoReply("N", new ElectronicSignatureData(), int.Parse(this.UserContext.DataValidAttachKey, CultureInfo.InvariantCulture));
            }

            bool?NoUpdate = Session["DcalNoUpdate"] as bool?;

            if (NoUpdate != null && (bool)NoUpdate && TransactionCode == "UCAL")
            {
                // No Update flag is set, so do DCAL instead of UCAL
                TransactionCode = "DCAL";
                ReturnAfterDcal = true;
            }

            Session["CalculatorModeFieldValues"] = DimensionHelper.EvaluateFields(TroposFields.Controls[3].Controls);
            ExecuteReturn ReturnValue;

            ReturnValue = Execution.DoTransaction(TroposFields.Controls[3].Controls, TransactionCode, ScreenCode, false, false);
            {
                Dictionary <string, string> FieldValues  = null;
                Dictionary <string, string> _fieldValues = null;
                object    SessionFieldValues             = null;
                DataTable FieldValuesTable = ReturnValue.FieldValuesTable;
                DataRow   FieldValuesRow   = FieldValuesTable.Rows[0];
                switch (ReturnValue.WaitefReturn)
                {
                case "ExoutvarOk":
                case "Exread":
                case "Exread2":
                    // The DCAL transaction comes here - set up the fields in case we need to return them
                    FieldValuesTable = ReturnValue.FieldValuesTable;
                    FieldValuesRow   = FieldValuesTable.Rows[0];
                    FieldValues      = RowToDictionary(FieldValuesTable, FieldValuesRow);
                    if (ReturnAfterDcal)
                    {
                        TransactionReturn(FieldValues);
                    }
                    break;

                case "ExdoneOk":
                    // UCAL comes here - set up the fields from the pre-update values, then add the result fields
                    SessionFieldValues = Session["CalculatorModeFieldValues"];
                    if (SessionFieldValues != null)
                    {
                        FieldValues = (Dictionary <string, string>)SessionFieldValues;
                        Session.Remove("CalculatorModeFieldValues");
                    }
                    FieldValuesTable = ReturnValue.FieldValuesTable;
                    FieldValuesRow   = FieldValuesTable.Rows[0];
                    _fieldValues     = RowToDictionary(FieldValuesTable, FieldValuesRow);
                    FieldValues["iATTVALFROM-DQ"] = _fieldValues["iATTVALFROM-DQ"];
                    FieldValues["iUOM-ATT1"]      = _fieldValues["iUOM-ATT1"];
                    TransactionReturn(FieldValues);
                    break;

                case "ExoutvarFail":
                    TroposResourceProvider Trp = new TroposResourceProvider(UserContext);
                    if (ReturnValue.Message.Trim() == Trp.GetResource("MSG_NO_CHANGES"))
                    {
                        switch (TransactionCode)
                        {
                        case "UCAL":
                            // set up the fields from the pre-update values, then add the result fields
                            SessionFieldValues = Session["CalculatorModeFieldValues"];
                            if (SessionFieldValues != null)
                            {
                                FieldValues = (Dictionary <string, string>)SessionFieldValues;
                                Session.Remove("CalculatorModeFieldValues");
                            }
                            FieldValuesTable = ReturnValue.FieldValuesTable;
                            FieldValuesRow   = FieldValuesTable.Rows[0];
                            _fieldValues     = RowToDictionary(FieldValuesTable, FieldValuesRow);
                            FieldValues["iATTVALFROM-DQ"] = _fieldValues["iATTVALFROM-DQ"];
                            FieldValues["iUOM-ATT1"]      = _fieldValues["iUOM-ATT1"];
                            TransactionReturn(FieldValues);
                            break;

                        case "DCAL":
                            if (ReturnAfterDcal)
                            {
                                FieldValuesTable = ReturnValue.FieldValuesTable;
                                FieldValuesRow   = FieldValuesTable.Rows[0];
                                FieldValues      = RowToDictionary(FieldValuesTable, FieldValuesRow);
                                TransactionReturn(FieldValues);
                            }
                            break;
                        }
                    }
                    break;
                }
            }

            ValidationResult MandatoryCheckResult = new ValidationResult();

            Execution.LoadScreenFields(
                ReturnValue.FieldValuesTable,
                ReturnValue.Message,
                ReturnValue.ScrollTable,
                ReturnValue.TextTable,
                TroposFields.Controls[3].Controls,
                TransactionCode,
                MandatoryCheckResult);

            Label ErrorField = (Label)TroposFields.FindControl("eError");

            if (ErrorField != null)
            {
                if (ReturnValue.Success)
                {
                    ErrorField.Text     = "";
                    ErrorField.CssClass = "TroposError TroposDisplay TroposField";
                }
                else
                {
                    ErrorField.Text = ReturnValue.Message;
                    if (string.IsNullOrEmpty(ReturnValue.Message))
                    {
                        ErrorField.CssClass = "TroposError TroposDisplay TroposField";
                    }
                    else
                    {
                        ErrorField.CssClass = "TroposErrorPopulated TroposDisplay TroposField";
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public void TestValidation7_2Event()
        {
            TransactionExecution tex1 = new TransactionExecution(null, this.versionDb);

            tex1.DEBUG_MODE = true;
            while (tex1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.InitTx();
            }
            tex1.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex1.Upload();
            while (tex1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Upload();
            }

            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            tex.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }
            tex.maxCommitTsOfWrites = 4L;
            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);

            tex1.maxCommitTsOfWrites = 5L;
            tex1.SetCommitTimestamp();
            while (tex1.CurrentProc == new Procedure(tex1.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.SetCommitTimestamp();
            }
            tex1.Validate();
            while (tex1.CurrentProc == new Procedure(tex1.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.Validate();
            }
            Assert.AreEqual(new Procedure(tex1.Abort), tex1.CurrentProc);
        }
Ejemplo n.º 14
0
        public void TestValidation6Event()
        {
            TransactionExecution tex1 = new TransactionExecution(null, this.versionDb);

            tex1.DEBUG_MODE = true;
            while (tex1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.InitTx();
            }
            tex1.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex1.Upload();
            while (tex1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Upload();
            }

            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            tex.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }

            tex1.maxCommitTsOfWrites = 3L;
            tex1.SetCommitTimestamp();
            while (tex1.CurrentProc == new Procedure(tex1.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.SetCommitTimestamp();
            }
            tex1.Validate();
            while (tex1.CurrentProc == new Procedure(tex1.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.Validate();
            }
            Assert.AreEqual(new Procedure(tex1.WriteToLog), tex1.CurrentProc);

            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);

            GetTxEntryRequest getTxReq = new GetTxEntryRequest(tex.txId);

            this.versionDb.EnqueueTxEntryRequest(tex.txId, getTxReq);
            this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            while (getTxReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            TxTableEntry txEntry = getTxReq.Result as TxTableEntry;

            Assert.AreEqual(5L, txEntry.CommitTime);
        }
Ejemplo n.º 15
0
        public void TestValidation4Event()
        {
            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }

            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool receivedUpdate, out object payloadUpdate);
            while (!receivedUpdate)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out receivedUpdate, out payloadUpdate);
            }
            texUpdate.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate.SetCommitTimestamp), texUpdate.CurrentProc);
            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(texUpdate.Validate), texUpdate.CurrentProc);
            texUpdate.Abort();
            while (texUpdate.CurrentProc != new Procedure(texUpdate.PostProcessingAfterAbort))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Abort();
            }

            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(tex.Validate), tex.CurrentProc);
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);
        }
Ejemplo n.º 16
0
 public SyncExecution(TransactionExecution txExec)
 {
     this.txExec = txExec;
 }