示例#1
0
        public void Them(clsDuLieuPP ptDLPP)
        {
            daClient dC = new daClient();

            dC.Tao();

            using (var db = new LiteDatabase(dC.TenFileDuLieuPP))
            {
                var col = db.GetCollection <clsDuLieuPP>(dC.BangDuLieuPP);
                if (ptDLPP.ID == 0)
                {
                    try
                    {
                        ptDLPP.ID = col.Max() + 1;
                    }
                    catch
                    {
                        ptDLPP.ID = 1;
                    }
                    ptDLPP.DaTruyen = false;
                    col.Insert(ptDLPP);
                    col.EnsureIndex(x => x.ID);
                }
                else
                {
                    col.Update(ptDLPP.ID, ptDLPP);
                }
            }
        }
示例#2
0
        public clsDuLieuPP Tim(string rTranID)
        {
            daClient dC = new daClient();

            dC.Tao();
            clsDuLieuPP _kqtim = new clsDuLieuPP();

            using (var db = new LiteDatabase(dC.TenFileDuLieuPP))
            {
                var col = db.GetCollection <clsDuLieuPP>(dC.BangDuLieuPP);
                _kqtim = col.FindOne(x => x.TranID == rTranID);
            }

            return(_kqtim);
        }
        public void DocVaGhiDuLieu_LuuGiu()
        {
            string    rTenFile = "";
            daCauHinh dCH      = new daCauHinh();

            dCH.Lay(dCH.TimMaThamSo((int)daCauHinh.eCauHinh.Đường_Dẫn_Paypost));
            if (dCH.CauHinh != null)
            {
                rTenFile = dCH.CauHinh.GiaTri;
            }

            rTenFile = rTenFile + "\\TRANSACTION";

            dCH.Lay(dCH.TimMaThamSo((int)daCauHinh.eCauHinh.Tên_Đăng_nhập_Paypost));
            if (dCH.CauHinh != null)
            {
                rTenFile = rTenFile + "\\" + dCH.CauHinh.GiaTri;
            }

            DateTime _NgayPhatHanh = DateTime.Now;

            rTenFile = rTenFile + "\\" + _NgayPhatHanh.ToString("yyyyMMdd") + ".log";

            if (KiemTraCoTonTaiFile(rTenFile))
            {
                Transactions transactions = null;
                try
                {
                    transactions = ObjectXMLSerializer <Transactions> .Load(rTenFile, SerializedFormat.Binary);
                }
                catch
                {
                    transactions             = new Transactions();
                    transactions.Transaction = new PAYPOST.LOG.Transaction[0];
                }
                Transaction[] array = new Transaction[transactions.Transaction.Length];
                transactions.Transaction.CopyTo(array, 0);

                daDuLieuPayPost dDLPP = new daDuLieuPayPost();
                clsDuLieuPP     ptPP  = new clsDuLieuPP();
                Transaction     dlDoc;
                for (int i = 0; i < array.Length; i++)
                {
                    dlDoc = array[i];
                    ptPP  = dDLPP.Tim(dlDoc.TranID);
                    if (ptPP != null)
                    {
                        if (ptPP.TranTime != dlDoc.TranTime)
                        {
                            ptPP.DaTruyen = false;
                            dDLPP.Them(ptPP);
                        }
                    }
                    else
                    {
                        ptPP = new clsDuLieuPP();
                        ptPP.NgayPhatHanh    = _NgayPhatHanh;
                        ptPP.TranTime        = dlDoc.TranTime;
                        ptPP.TranCat         = dlDoc.TranCat;
                        ptPP.InvokedFrom     = dlDoc.InvokedFrom;
                        ptPP.TranID          = dlDoc.TranID;
                        ptPP.PAC             = dlDoc.PAC;
                        ptPP.AccountID       = dlDoc.AccountID;
                        ptPP.TranAmount      = dlDoc.TranAmount;
                        ptPP.SenderName      = dlDoc.SenderName;
                        ptPP.AddInfo1        = dlDoc.AddInfo1;
                        ptPP.AddInfo2        = dlDoc.AddInfo2;
                        ptPP.AddInfo3        = dlDoc.AddInfo3;
                        ptPP.AddInfo4        = dlDoc.AddInfo4;
                        ptPP.AddInfo5        = dlDoc.AddInfo5;
                        ptPP.AddInfo6        = dlDoc.AddInfo6;
                        ptPP.AddInfo7        = dlDoc.AddInfo7;
                        ptPP.AddInfo8        = dlDoc.AddInfo8;
                        ptPP.Fee             = dlDoc.Fee;
                        ptPP.Add_Info_Fee_01 = dlDoc.Add_Info_Fee_01;
                        ptPP.Add_Info_Fee_02 = dlDoc.Add_Info_Fee_02;
                        ptPP.Add_Info_Fee_03 = dlDoc.Add_Info_Fee_03;
                        ptPP.Add_Info_Fee_04 = dlDoc.Add_Info_Fee_04;
                        ptPP.Add_Info_Fee_05 = dlDoc.Add_Info_Fee_05;

                        dDLPP.Them(ptPP);
                    }

                    Ghi(ptPP, null);
                }
            }
        }
        private void DocGhi(string rTenFile, DateTime rNgay)
        {
            Transactions transactions = null;

            try
            {
                transactions = ObjectXMLSerializer <Transactions> .Load(rTenFile, SerializedFormat.Binary);
            }
            catch
            {
                transactions             = new Transactions();
                transactions.Transaction = new PAYPOST.LOG.Transaction[0];
            }
            Transaction[] array = new Transaction[transactions.Transaction.Length];
            transactions.Transaction.CopyTo(array, 0);

            daDuLieuPayPost dDLPP = new daDuLieuPayPost();
            clsDuLieuPP     ptPP  = new clsDuLieuPP();
            Transaction     dlDoc;

            for (int i = 0; i < array.Length; i++)
            {
                dlDoc = array[i];
                ptPP  = dDLPP.Tim(dlDoc.TranID);
                if (ptPP != null)
                {
                    if (ptPP.TranTime != dlDoc.TranTime)
                    {
                        ptPP.DaTruyen = false;
                        dDLPP.Them(ptPP);
                    }
                }
                else
                {
                    ptPP = new clsDuLieuPP();
                    ptPP.NgayPhatHanh    = rNgay;
                    ptPP.TranTime        = dlDoc.TranTime;
                    ptPP.TranCat         = dlDoc.TranCat;
                    ptPP.InvokedFrom     = dlDoc.InvokedFrom;
                    ptPP.TranID          = dlDoc.TranID;
                    ptPP.PAC             = dlDoc.PAC;
                    ptPP.AccountID       = dlDoc.AccountID;
                    ptPP.TranAmount      = dlDoc.TranAmount;
                    ptPP.SenderName      = dlDoc.SenderName;
                    ptPP.AddInfo1        = dlDoc.AddInfo1;
                    ptPP.AddInfo2        = dlDoc.AddInfo2;
                    ptPP.AddInfo3        = dlDoc.AddInfo3;
                    ptPP.AddInfo4        = dlDoc.AddInfo4;
                    ptPP.AddInfo5        = dlDoc.AddInfo5;
                    ptPP.AddInfo6        = dlDoc.AddInfo6;
                    ptPP.AddInfo7        = dlDoc.AddInfo7;
                    ptPP.AddInfo8        = dlDoc.AddInfo8;
                    ptPP.Fee             = dlDoc.Fee;
                    ptPP.Add_Info_Fee_01 = dlDoc.Add_Info_Fee_01;
                    ptPP.Add_Info_Fee_02 = dlDoc.Add_Info_Fee_02;
                    ptPP.Add_Info_Fee_03 = dlDoc.Add_Info_Fee_03;
                    ptPP.Add_Info_Fee_04 = dlDoc.Add_Info_Fee_04;
                    ptPP.Add_Info_Fee_05 = dlDoc.Add_Info_Fee_05;

                    dDLPP.Them(ptPP);
                }

                Ghi(ptPP, null);
            }
        }