public int UnLockSession(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo, string soPO, string soPhieuNhap, DateTime transactionDate, DateTime ngayNhap) { Session currentSession = GetCurrentSession(); return(ExecuteCommand( @"Update tbl_lichsu_nhaphang set sessionid = null, processid = null, lockaccount = null, lockmachine = null, lockat = null where inventoryorg = :inventoryorg and inventorysub = :inventorysub and sopo = :sopo and sophieunhap = :sophieunhap and transaction_date = :transactiondate and ngaynhap = :ngaynhap and loaigiaodich = :loaigiaodich and sessionid = :sessionid and processid = :processid and lockaccount = :lockaccount and lockmachine = :lockmachine", inventoryOrg, inventorySub, soPO, soPhieuNhap, transactionDate, ngayNhap, Convert.ToInt32(loaiGiaoDichPo), currentSession.SID, currentSession.Process, currentSession.Account, currentSession.Machine)); }
public int LockSession(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo, string soPO, string soPhieuNhap, DateTime transactionDate, DateTime ngayNhap, int lockForced, DateTime lockAt) { Session currentSession = GetCurrentSession(); if (lockAt == DateTime.MinValue) { return(ExecuteCommand( @"Update tbl_lichsu_nhaphang set sessionid = :sessionid, processid = :processid, lockaccount = :lockaccount, lockmachine = :lockmachine, lockat = sysdate where inventoryorg = :inventoryorg and inventorysub = :inventorysub and sopo = :sopo and sophieunhap = :sophieunhap and transaction_date = :transactiondate and ngaynhap = :ngaynhap and loaigiaodich = :loaigiaodich and (sessionid is null or sessionid = :sessionid or :lockForced = 1) and (processid is null or processid = :processid or :lockForced = 1) and (lockaccount is null or lockaccount = :lockaccount or :lockForced = 1) and (lockmachine is null or lockmachine = :lockmachine or :lockForced = 1)", currentSession.SID, currentSession.Process, currentSession.Account, currentSession.Machine, inventoryOrg, inventorySub, soPO, soPhieuNhap, transactionDate, ngayNhap, Convert.ToInt32(loaiGiaoDichPo), lockForced)); } return(ExecuteCommand( @"Update tbl_lichsu_nhaphang set sessionid = :sessionid, processid = :processid, lockaccount = :lockaccount, lockmachine = :lockmachine, lockat = localtimestamp where inventoryorg = :inventoryorg and inventorysub = :inventorysub and sopo = :sopo and sophieunhap = :sophieunhap and transaction_date = :transactiondate and ngaynhap = :ngaynhap and loaigiaodich = :loaigiaodich and lockat = :lockat and (sessionid is null or sessionid = :sessionid or :lockForced = 1) and (processid is null or processid = :processid or :lockForced = 1) and (lockaccount is null or lockaccount = :lockaccount or :lockForced = 1) and (lockmachine is null or lockmachine = :lockmachine or :lockForced = 1)", currentSession.SID, currentSession.Process, currentSession.Account, currentSession.Machine, inventoryOrg, inventorySub, soPO, soPhieuNhap, transactionDate, ngayNhap, Convert.ToInt32(loaiGiaoDichPo), lockAt, lockForced)); }
public DateTime GetLastUpdateDate(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo) { return (GetObjectCommand <DateTime>( @"SELECT MAX(Last_Update_Date) FROM tbl_LichSu_NhapHang WHERE InventoryOrg = :InventoryOrg AND InventorySub = :InventorySub AND LoaiGiaoDich = :LoaiGiaoDich" , inventoryOrg, inventorySub, Convert.ToInt32(loaiGiaoDichPo))); }
public void DeleteLichSuNhapHang(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo) { ExecuteCommand( @"DELETE FROM tbl_Tmp_NhapHang@qlbh_ta t WHERE exists (SELECT TransactionID FROM tbl_LichSu_NhapHang WHERE InventoryOrg = :InventoryOrg AND InventorySub = :InventorySub AND LoaiGiaoDich = :LoaiGiaoDich AND TransactionID = t.TransactionID)", inventoryOrg, inventorySub, Convert.ToInt32(loaiGiaoDichPo)); }
public Session GetSessionLocking(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo, string soPO, string soPhieuNhap, DateTime transactionDate, DateTime ngayNhap) { return (GetObjectCommand <Session>( @"select sessionid sid, processid process, lockmachine machine, lockaccount account, lockat from tbl_lichsu_nhaphang where inventoryorg = :inventoryorg and inventorysub = :inventorysub and sopo = :sopo and sophieunhap = :sophieunhap and transaction_date = :transactiondate and ngaynhap = :ngaynhap and loaigiaodich = :loaigiaodich and rownum = 1", inventoryOrg, inventorySub, soPO, soPhieuNhap, transactionDate, ngayNhap, Convert.ToInt32(loaiGiaoDichPo))); }
public int LockSession(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo, string soPO, string soPhieuNhap, DateTime transactionDate, DateTime ngayNhap) { PurchaseOrderDao.Session lockingSession = PurchaseOrderDao.Instance. GetSessionLocking(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap); if (lockingSession.LockAt != DateTime.MinValue && lockingSession.LockAt.AddHours(2) < CommonProvider.Instance.GetSysDate()) { return(PurchaseOrderDao.Instance.LockSession(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap, 1, lockingSession.LockAt)); } if (!String.IsNullOrEmpty(lockingSession.Account) && lockingSession.Account.ToLower() != Declare.UserName.ToLower()) { throw new ManagedException(String.Format("Phiếu nhập này đang bị lock bởi người dùng {0} tại máy {1} lúc {2}", lockingSession.Account, lockingSession.Machine, lockingSession.LockAt)); } if (!String.IsNullOrEmpty(lockingSession.Machine) && !lockingSession.Machine.EndsWith("\\" + Dns.GetHostName().ToUpper())) { throw new ManagedException(String.Format("Phiếu nhập này đang bị lock bởi người dùng {0} tại máy {1} lúc {2}", lockingSession.Account, lockingSession.Machine, lockingSession.LockAt)); } if (!String.IsNullOrEmpty(lockingSession.Process)) { lockingSession.Process = lockingSession.Process.Split(':')[0]; if (lockingSession.Process != Process.GetCurrentProcess().Id.ToString()) { try { Process pr = Process.GetProcessById(Common.IntValue(lockingSession.Process)); if (pr.MainModule.ModuleName == Process.GetCurrentProcess().MainModule.ModuleName) { throw new ManagedException( String.Format("Phiếu nhập này đang bị lock bởi người dùng {0} tại máy {1} lúc {2}", lockingSession.Account, lockingSession.Machine, lockingSession.LockAt)); } } catch (Exception ex) { if (ex is ArgumentException || ex is Win32Exception) { return(PurchaseOrderDao.Instance. LockSession(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap, 1, lockingSession.LockAt)); } throw; } } return(PurchaseOrderDao.Instance.LockSession(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap, 1, lockingSession.LockAt)); } return(PurchaseOrderDao.Instance.LockSession(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap, 0, lockingSession.LockAt)); }
public int UnLockSession(string inventoryOrg, string inventorySub, LoaiGiaoDichPO loaiGiaoDichPo, string soPO, string soPhieuNhap, DateTime transactionDate, DateTime ngayNhap) { return(PurchaseOrderDao.Instance.UnLockSession(inventoryOrg, inventorySub, loaiGiaoDichPo, soPO, soPhieuNhap, transactionDate, ngayNhap)); }