Пример #1
0
        public int Update_MySQL(string SQL, string strType)
        {
            int             ID = -1;
            MySqlDataReader objReader;
            clsLog          objLog = new clsLog();

            try
            {
                if (strError == "")
                {
                    MySqlCommand objCommand = new MySqlCommand();
                    objCommand.Connection  = objConnection;
                    objCommand.CommandText = "Call " + SQL;


                    if (strType == "TimeIn")
                    {
                        objReader = objCommand.ExecuteReader();
                        ID        = returnMySqlID(objReader);
                        objReader.Close();
                    }
                    else if (strType == "TimeOut")
                    {
                        ID = objCommand.ExecuteNonQuery();
                    }
                }
            }
            catch (MySqlException ex)
            {
                strError = System.DateTime.Now.ToString("MM-dd-yyyy HH:mm") + " - Error - " + ex.Message;
                objLog.writeToLog(strError);
            }

            return(ID);
        }
Пример #2
0
        private void updateRemoteDB(List <Times> objQueries, string strType)
        {
            clsRemoteDB objRemoteDB = new clsRemoteDB();
            clsLocalDB  objLocalDB  = new clsLocalDB(resStaticData.localDB);

            int    totalIns = 0, totalOuts = 0;
            clsLog objLog = new clsLog();

            foreach (Times i in objQueries)
            {
                string Query    = i.Query;
                int    SQLiteID = i.SQLite_ID;

                int Rows;

                if (strType == "TimeIn")
                {
                    int MySQL_ID = objRemoteDB.Update_MySQL(Query, "TimeIn");
                    if (MySQL_ID != -1)
                    {
                        objLocalDB.addMySQLID(MySQL_ID, SQLiteID);
                        totalIns++;
                    }
                    else
                    {
                        objLog.writeToLog("There was an error adding sqlite_ID = " + SQLiteID.ToString() + " to remoteDB.");
                        totalIns--;
                    }
                }
                else if (strType == "TimeOut")
                {
                    Rows = objRemoteDB.Update_MySQL(Query, "TimeOut");
                    if (Rows > 0)
                    {
                        objLocalDB.updateTimeOut_Added(SQLiteID);
                        totalOuts++;
                    }
                    else
                    {
                        totalOuts--;
                    }
                }
            }

            objLog.writeToLog(returnLogMsg(totalOuts + totalIns, strType));
        }
Пример #3
0
        public clsRemoteDB()
        {
            clsLog objLog = new clsLog();

            try
            {
                objConnection.ConnectionString = resStaticData.MySQL_ConnectionString;
                objConnection.Open();
            }
            catch (MySqlException ex)
            {
                strError = System.DateTime.Now.ToString("MM-dd-yyyy HH:mm") + " - Error - " + ex.Message;
                objLog.writeToLog(strError);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            clsPingTest objPing = new clsPingTest();
            clsLog      objLog  = new clsLog();

            bool blPass = objPing.PingTest("htcCloudServer.net");

            if (blPass == true)
            {
                clsActions objActions = new clsActions();
                objActions.updateDBs();
            }
            else
            {
                string strError = System.DateTime.Now.ToString("MM-dd-yyyy HH:mm") + "- clsPingTest- the cloud server could not be reached.";
                objLog.writeToLog(strError);
            }
        }