Exemple #1
0
        public void CommitTest()
        {
            ModelGRRefDelete m = new ModelGRRefDelete() {
                RefGRNumber = "5000389802",
                RefGRItemNumber = "0001",
                PONumber = "4500122102",
                POItemNumber = "00010",
                UserID = 1513
            }; // TODO: Initialize to an appropriate value
            GRRefDelete target = new GRRefDelete(m); // TODO: Initialize to an appropriate value
            int _traceID = target.Commit();
            Assert.IsTrue(_traceID > 0);

            GRRefDelete target2 = new GRRefDelete(_traceID); // TODO: Initialize to an appropriate value
            int expected = 0;
            int actual;
            actual = target2.Rollback();
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public int Rollback()
        {
            try
            {
                var objs = from o in _dbContext.ABi_Trace
                           where o.ABi_Trace_ID == _traceInfo.TraceID
                           select o;

                if (objs != null && objs.Count() > 0)
                {
                    var obj = objs.First();
                    if (obj.Status == (int)Trace.eTraceStatus.eCommit)
                    {
                        _model = new ModelGRRefDelete();
                        if (obj.TraceType == (int)_model.GetTraceType())
                        {
                            _model = (ModelGRRefDelete)_model.Deserialize(obj.Data);
                            var grs = from o in _dbContext.ABi_GR
                                      where _model.GRIDs.Contains(o.ABi_GR_ID)
                                      select o;
                            foreach (var gr in grs)
                            {
                                gr.Deleted = false;
                            }

                            obj.Status = (int)VPBLL.Trace.eTraceStatus.eRollback;
                            obj.DateModified = DateTime.Now;
                            _dbContext.SaveChanges();
                            return 0;
                        }

                        _logger.LogInfo(String.Format("Invalid Trace Type: {0} != {1}. {1}", obj.TraceType, _model.GetTraceType(), _model.Serialize()));
                        return -2;  //Invalid trace type.
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(String.Format("GRRefDelete.Rollback(TraceID:{0})", _traceInfo.TraceID), ex);
            }
            return -1;
        }
Exemple #3
0
 public GRRefDelete(ModelGRRefDelete m)
 {
     _model = m;
 }