Example #1
0
        public override int ExecuteUpdate(ND_USER user, SM_POCKET obj)
        {
            this.ValidPocketData(obj);
            if (obj.Id <= 0)
            {
                DateTime now = BaseExtends.GetServerDate();
                obj.POCKETDATE = DateTime.Parse(now.ToShortDateString());
                obj.OPERDATE   = DateTime.Parse(now.ToShortDateString());
                obj.POCKID     = BaseExtends.GetNewAutoNo("PK");
                obj.OPERATOR   = user.USERDM;
            }

            int lnno = 1;

            foreach (SM_POCKETDTL d in obj.POCKETDTL)
            {
                d.POCKID   = obj.POCKID;
                d.POCKLNNO = lnno;
                lnno++;
            }
            DbEntry.NewTransaction(delegate
            {
                base.ExecuteUpdate(user, obj);
                string csql = string.Format("exec SMProc_PocketStatus '{0}' ", obj.ORDERID);
                DbEntry.Provider.ExecuteNonQuery(csql);
            });
            return(obj.Id);
        }
Example #2
0
 private static void IfUsingTransaction(bool isUsing, Action callback)
 {
     if (isUsing)
     {
         DbEntry.NewTransaction(callback);
     }
     else
     {
         callback();
     }
 }
Example #3
0
        public void TestGetTheRightCopier2()
        {
            var dc = new DataProvider("SqlServerMock");

            DbEntry.NewTransaction(delegate
            {
                IDbBulkCopy c = dc.GetDbBulkCopy(false); // exception
                Assert.IsNotNull(c);
                Assert.IsTrue(c is SqlServerBulkCopy);
            });
        }
Example #4
0
 public void TestPartialUpdateThatSetValueByTransaction()
 {
     DbEntry.NewTransaction(delegate {
         var u = new sUser(1, "Ok", 18)
         {
             Name = "Tom"
         };
         DbEntry.Save(u);
     });
     Assert.AreEqual(1, StaticRecorder.Messages.Count);
     Assert.AreEqual("UPDATE [s_User] SET [Name]=@Name_0  WHERE [Id] = @Id_1;\n<Text><30>(@Name_0=Tom:String,@Id_1=1:Int64)", StaticRecorder.LastMessage);
 }
Example #5
0
        public void TestSmartUpdateForDynamicObject4()
        {
            var u = LoadAsUser("jerry", 18);

            DbEntry.NewTransaction(delegate {
                DbEntry.NewTransaction(delegate {
                    u.Name = "Tom";
                    DbEntry.Save(u);
                });
            });
            Assert.AreEqual(1, StaticRecorder.Messages.Count);
            Assert.AreEqual("UPDATE [as_User] SET [theName]=@theName_0  WHERE [Id] = @Id_1;\n<Text><30>(@theName_0=Tom:String,@Id_1=1:Int64)", StaticRecorder.LastMessage);
        }
Example #6
0
 public void Test2()
 {
     DbEntry.UsingTransaction(
         () =>
     {
         new CtxUser {
             Name = "test"
         }.Save();
         DbEntry.NewTransaction(() => new CtxSvcUser {
             Name = "aaa"
         }.Save());
     });
 }
Example #7
0
 public void TestPartialUpdateThatSetedValueByTransactionWithException()
 {
     Util.CatchAll(() =>
                   DbEntry.NewTransaction(delegate {
         var u = new sUser(1, "Tom", 18)
         {
             Name = "Tom"
         };
         DbEntry.Save(u);
         throw new Exception();     // emulate exception
     }));
     Assert.AreEqual(0, StaticRecorder.Messages.Count);
     Assert.AreEqual("", StaticRecorder.LastMessage);
 }
Example #8
0
        public override int ExecuteDelete(SM_POCKET obj)
        {
            int c = 0;

            DbEntry.NewTransaction(delegate
            {
                c = base.ExecuteDelete(obj);
                if (c == 1)
                {
                    string csql = string.Format("update SM_SALEORDERSTATUS set POCKETTAG=0 WHERE ORDERID='{0}' ", obj.ORDERID);
                    DbEntry.Provider.ExecuteNonQuery(csql);
                }
            });
            return(c);
        }
Example #9
0
 private void ProcessWrite(Action callback)
 {
     DbEntry.NewTransaction(() =>
     {
         if (_identityInsert)
         {
             var name = _provider.Dialect.QuoteForTableName(DestinationTableName);
             _provider.ExecuteNonQuery(string.Format("SET IDENTITY_INSERT {0} ON", name));
             callback();
             _provider.ExecuteNonQuery(string.Format("SET IDENTITY_INSERT {0} OFF", name));
         }
         else
         {
             callback();
         }
     });
 }
Example #10
0
        public void ProcessLog(LogLevel type, string name, string message, Exception exception)
        {
            var li = new LeafingLog(type, name, message, exception);

            try {
                DbEntry.NewTransaction(() => DbEntry.Save(li));
            } catch (Exception ex) {
                string msg = (exception == null) ? message : message + "\n" + exception;
                if (Logger.System.LogRecorders != null)
                {
                    foreach (var recorder in Logger.System.LogRecorders)
                    {
                        recorder.ProcessLog(type, name, msg, ex);
                    }
                }
            }
        }