Beispiel #1
0
        //returns "MODEL.Job" object if successful/found
        //returns "null" if not
        internal Job findJobByJobId(int jobId)
        {
            int result = (int)CODE.MINUS_ONE;
            Job job    = null;

            //validate jobId
            if (
                result == (int)CODE.ZERO ||
                string.IsNullOrWhiteSpace(jobId.ToString()) ||
                !Validate.isAllNumbers(jobId.ToString()) ||
                !Validate.integerIsBiggerThan(jobId, (int)CODE.TRANSLATO_DATABASE_SEED - 1)
                )
            {
                result = (int)CODE.ZERO;
            }
            if (result != (int)CODE.ZERO)//safe to proceed
            {
                IJobs _DbJobs = new DbJobs();

                try
                {
                    using (var trScope = TransactionScopeBuilder.CreateSerializable())
                    {
                        job = _DbJobs.findJobByJobId(jobId);

                        trScope.Complete();
                    }
                }
                catch (TransactionAbortedException taEx)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(taEx.ToString());
                }
                catch (ApplicationException aEx)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(aEx.ToString());
                }
                catch (Exception ex)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(ex.ToString());
                }
            }
            else
            {
                result = (int)CODE.ZERO;
            }

            if (result == (int)CODE.ZERO || job == null)
            {
                return(null);
            }
            else
            {
                return(job);
            }
        }