Ejemplo n.º 1
0
        public static int GetOrCreateUmJobKey(Int64 AUnitKey, string APositionName, string APositionScope)
        {
            int JobKey = 0;

            UmJobTable JobTableTemp = new UmJobTable();
            UmJobRow   TemplateRow  = (UmJobRow)JobTableTemp.NewRow();

            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction, ref SubmissionOK,
                                                                  delegate
            {
                TemplateRow.UnitKey       = AUnitKey;
                TemplateRow.PositionName  = APositionName;
                TemplateRow.PositionScope = APositionScope;
                JobTableTemp = UmJobAccess.LoadUsingTemplate(TemplateRow, Transaction);

                // if no corresponding job record found then we need to create a new job key
                if (JobTableTemp.Count == 0)
                {
                    JobKey = Convert.ToInt32(MCommon.WebConnectors.TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_job));

                    SubmissionOK = true;
                }
                else
                {
                    JobKey = ((UmJobRow)JobTableTemp.Rows[0]).JobKey;
                }
            });

            return(JobKey);
        }
Ejemplo n.º 2
0
        public static int GetOrCreateUmJobKey(Int64 AUnitKey, string APositionName, string APositionScope)
        {
            int  JobKey;
            bool NewTransaction;

            UmJobTable JobTableTemp = new UmJobTable();
            UmJobRow   TemplateRow  = (UmJobRow)JobTableTemp.NewRow();

            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction);

            TemplateRow.UnitKey       = AUnitKey;
            TemplateRow.PositionName  = APositionName;
            TemplateRow.PositionScope = APositionScope;
            JobTableTemp = UmJobAccess.LoadUsingTemplate(TemplateRow, Transaction);

            // if no corresponding job record found then we need to create a new job key
            if (JobTableTemp.Count == 0)
            {
                JobKey = Convert.ToInt32(MCommon.WebConnectors.TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_job));

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            else
            {
                JobKey = ((UmJobRow)JobTableTemp.Rows[0]).JobKey;

                DBAccess.GDBAccessObj.RollbackTransaction();
            }

            return(JobKey);
        }