Exemple #1
0
        public bool Varified()
        {
            ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
            try
            {
                db.setQuery(@"select * from AVLUserVarify 
 WHERE userID=@userID AND phoneVarified = @phoneVarified ");
                db.AddParams("@userID", this.userID);
                db.AddParams("@phoneVarified", true);
                if (db.Query_DataTable().Rows.Count > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                ClassLibrary.JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemple #2
0
 public static bool SendToOldDatabase(byte[] pData)
 {
     System.Data.SqlClient.SqlConnectionStringBuilder constr = new System.Data.SqlClient.SqlConnectionStringBuilder();
     constr.DataSource     = ".";
     constr.InitialCatalog = "BusAvlSendLogs";
     constr.UserID         = "sa";
     constr.Password       = "******";
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase(constr);
     try
     {
         db.setQuery("Insert into SendLogs(SendLog) VALUES(@SendLog)");
         db.AddParams("SendLog", pData);
         if (db.Query_Execute() >= 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
Exemple #3
0
        public static bool AddAVL(DataTable pDT, string pErrorCommand)
        {
            if (pDT == null || pDT.Rows.Count == 0)
            {
                return(true);
            }
            string fileName = Guid.NewGuid().ToString();

            BusManagment.Transaction.JTicketTransactions.WriteDataTableToFile(pDT, fileName, false);

            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            int BusSerial             = 0;

            try
            {
                if (pDT.Rows.Count >= 1)
                {
                    int.TryParse(pDT.Rows[0]["BusSerial"].ToString(), out BusSerial);
                }
                if (BusSerial > 0 && BusSerial < 10000)
                {
                    if (semaphore[BusSerial] == null)
                    {
                        semaphore[BusSerial] = new Semaphore(1, 1);
                    }
                    semaphore[BusSerial].WaitOne();
                }
                db.DataTypesName = "dbo.AVLPointList";
                db.setQuery(@"EXEC SP_InsertAUTAvlTransactionWithDataTable @List");
                db.AddParams("@List", pDT);

                db.CommandTimeout = 60 * pDT.Rows.Count;
                db.Query_Execute();
                if (!db.Error)
                {
                    BusManagment.Transaction.JTicketTransactions.Deleted(fileName, false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (BusSerial > 0 && BusSerial < 10000)
                {
                    semaphore[BusSerial].Release();
                }
                db.Dispose();
            }
        }
Exemple #4
0
        public bool Update()
        {
            //JPersonAddressTable addressTable = new JPersonAddressTable();
            //addressTable.SetValueProperty(this);
            //return addressTable.Update();
            ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
            try
            {
                db.setQuery(@"UPDATE AVLUserVarify SET
                email=@email , phonenumber = @phonenumber, phoneVarified = @phoneVarified, emailVarified = @emailVarified 
 WHERE userID=@userID");
                db.AddParams("@email", this.email);
                db.AddParams("@phonenumber", this.phonenumber);
                db.AddParams("@phoneVarified", this.phoneVarified);
                db.AddParams("@emailVarified", this.emailVarified);
                db.AddParams("@userID", this.userID);
                db.beginTransaction("UpdateAVLUserVarify");
                if (db.Query_Execute() > -1)
                {
                    if (db.Commit())
                    {
                        return(true);
                    }
                }
                db.Rollback("UpdateAVLUserVarify");
                return(false);
            }
            catch (Exception ex)
            {
                ClassLibrary.JSystem.Except.AddException(ex);
                db.Rollback("UpdateAVLUserVarify");
                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemple #5
0
        public static bool AddAVL(TransactionPublic.JTransactionAVLHeader AH, TransactionPublic.JTransactionAVL AVL, Int64 recordNumber, string Header_IMEI, float Header_BusSerial, byte[] Header_Version, ClassLibrary.JDataBase db)
        {
            if (db == null || AH == null || AVL == null)
            {
                return(false);
            }
            db.Params.Clear();
            if (db.Params.Count > 0)
            {
                try
                {
                    db.Params.Remove("Longitude");
                    db.Params.Remove("Latitude");
                    db.Params.Remove("Altitude");
                    db.Params.Remove("Speed");
                    db.Params.Remove("Course");
                    db.Params.Remove("EventDate");
                    db.Params.Remove("SimCardCharge");
                    db.Params.Remove("BusSerial");
                    db.Params.Remove("IMEI");
                    db.Params.Remove("Version");
                    db.Params.Remove("BatteryCharge");
                    db.Params.Remove("GpsAnt");
                    db.Params.Remove("GsmAnt");
                    db.Params.Remove("recordNumber");
                    db.Params.Remove("TransactionID");
                    db.Params.Remove("Dir");
                }
                catch
                {
                }
            }

            DateTime dtemp;
            string   date = (new DateTime(AH.DATE.Year, AH.DATE.Month, AH.DATE.Day, AVL.Time[0], AVL.Time[1], AVL.Time[2])).ToString("yyyy-MM-dd HH:mm:ss");

            if (DateTime.TryParse(date, out dtemp) & AH.DATE.Year >= 2015)
            {
            }
            else
            {
                date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            db.setQuery(@"EXEC SP_InsertAUTAvlTransaction_Zarrin_Save_Just_Point
	                    @Longitude,
	                    @Latitude,
	                    @Altitude,
	                    @Speed,
	                    @Course,
	                    @EventDate,
	                    @SimCardCharge,
	                    @BusSerial,
	                    @IMEI,
	                    @Version,
	                    @BatteryCharge,
	                    @GpsAnt,
	                    @GsmAnt,
	                    @recordNumber,
	                    @TransactionID,
                        @Dir");
            db.AddParams("Longitude", AVL.Lon);
            db.AddParams("Latitude", AVL.Lat);
            db.AddParams("Altitude", AVL.Alt.ToString());
            db.AddParams("Speed", AVL.Speed.ToString());
            db.AddParams("Course", AVL.Cource.ToString());
            db.AddParams("EventDate", date);
            db.AddParams("SimCardCharge", AH.SimCharge.ToString());
            db.AddParams("BusSerial", AH.busSerial.ToString());
            db.AddParams("IMEI", Header_IMEI.ToString());
            db.AddParams("Version", Header_Version);
            db.AddParams("BatteryCharge", AH.Battryvoltvalue.ToString());
            db.AddParams("GpsAnt", AH.GpsAnttena.ToString());
            db.AddParams("GsmAnt", AH.GsmAnttena.ToString());
            db.AddParams("recordNumber", recordNumber.ToString());
            db.AddParams("TransactionID", AVL.transactionid.ToString());
            db.AddParams("Dir", AVL.Dir.ToString());
            db.CommandTimeout = 60;
            if (db.Query_Execute() >= 0)
            {
                db.Params.Clear();
                return(true);
            }
            return(true);
        }
Exemple #6
0
        public static bool AddAVL(Transaction.JTransactionAVLHeader AH, Transaction.JTransactionAVL AVL, Int64 recordNumber, string Header_IMEI, float Header_BusSerial, byte[] Header_Version, ClassLibrary.JDataBase pdb, string pErrorCommand)
        {
            if (AH == null || AVL == null)
            {
                return(false);
            }

            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            db.Params.Clear();
            //if(AH.busSerial == 2122)
            //    db.Params.Clear();
            if (db.Params.Count > 0)
            {
                try
                {
                    db.Params.Remove("Longitude");
                    db.Params.Remove("Latitude");
                    db.Params.Remove("Altitude");
                    db.Params.Remove("Speed");
                    db.Params.Remove("Course");
                    db.Params.Remove("EventDate");
                    db.Params.Remove("SimCardCharge");
                    db.Params.Remove("BusSerial");
                    db.Params.Remove("IMEI");
                    db.Params.Remove("Version");
                    db.Params.Remove("BatteryCharge");
                    db.Params.Remove("GpsAnt");
                    db.Params.Remove("GsmAnt");
                    db.Params.Remove("recordNumber");
                    db.Params.Remove("TransactionID");
                    db.Params.Remove("Dir");
                    db.Params.Remove("BusLine");
                }
                catch
                {
                }
            }

            string date = (new DateTime(AH.DATE.Year, AH.DATE.Month, AH.DATE.Day, AVL.Time[0], AVL.Time[1], AVL.Time[2])).ToString("yyyy-MM-dd HH:mm:ss");

            db.setQuery(@"EXEC SP_InsertAUTAvlTransaction_Zarrin_Save_Just_Point
	                    @Longitude,
	                    @Latitude,
	                    @Altitude,
	                    @Speed,
	                    @Course,
	                    @EventDate,
	                    @SimCardCharge,
	                    @BusSerial,
	                    @IMEI,
	                    @Version,
	                    @BatteryCharge,
	                    @GpsAnt,
	                    @GsmAnt,
	                    @recordNumber,
	                    @TransactionID,
                        @Dir,
                        @BusLine");
            db.AddParams("Longitude", AVL.Lon);
            db.AddParams("Latitude", AVL.Lat);
            db.AddParams("Altitude", AVL.Alt.ToString());
            db.AddParams("Speed", AVL.Speed.ToString());
            db.AddParams("Course", AVL.Cource.ToString());
            db.AddParams("EventDate", date);
            db.AddParams("SimCardCharge", AH.SimCharge.ToString());
            db.AddParams("BusSerial", AH.busSerial.ToString());
            db.AddParams("IMEI", Header_IMEI.ToString());
            db.AddParams("Version", Header_Version);
            db.AddParams("BatteryCharge", AH.Battryvoltvalue.ToString());
            db.AddParams("GpsAnt", AH.GpsAnttena.ToString());
            db.AddParams("GsmAnt", AH.GsmAnttena.ToString());
            db.AddParams("recordNumber", recordNumber.ToString());
            db.AddParams("TransactionID", AVL.transactionid.ToString());
            db.AddParams("Dir", AVL.Dir.ToString());
            db.AddParams("BusLine", AH.busLine.ToString());
            DataTable dt;

            try
            {
                db.CommandTimeout = 60;
                db.Query_Execute(true, pErrorCommand, false);
                //db.Dispose();
                return(true);
                //dt = db.Query_DataTable();
                //if (dt != null && dt.Rows.Count > 0 && Convert.ToInt32(dt.Rows[0][0]) > 0)
                //{
                //    db.Params.Clear();
                //    return true;
                //}
                //else
                //    return false;
            }
            catch (Exception ex)
            {
                return(false);
            }
        }