Пример #1
0
    private IEnumerator                     StartConnection()
    {
        yield return(new WaitForSeconds(0.1f));

        int i = 0;

        ConnectionProgressBar.Progress = 0;
        ConnectionProgressBar.Caption  = "Connecting...";
        Util.Timer connClock = new Util.Timer();
        _blnIsConnecting = true;
        Display(true);
        connClock.StartTimer();
        Net.ClientConnect();
        while (!Net.IsConnected && connClock.GetTime <= Net.CONNECTION_TIMEOUT)
        {
            yield return(null);

            i++;
            ConnectionProgressBar.SetProgress(connClock.GetFloatTime, Net.CONNECTION_TIMEOUT);
            yield return(null);
        }
        connClock.StopTimer();
        _blnIsConnecting = false;
        _blnAutoConnect  = false;
        ConnectionProgressBar.Caption = "";
        if (!Net.IsConnected && connClock.GetFloatTime > Net.CONNECTION_TIMEOUT)
        {
            Display();
        }
        connClock = null;
    }
Пример #2
0
    private IEnumerator     DoStart()
    {
        yield return(new WaitForSeconds(1.0f));

        if (!_blnLoadAllAtStart)
        {
            _blnInitialized = true;
            yield break;
        }
        Util.Timer clock = new Util.Timer();
        clock.StartTimer();
        int i = 0;

        while (!Database.IsConnected && clock.GetTime < 10)
        {
            i++;
            yield return(null);
        }
        clock.StopTimer();
        if (clock.GetTime > 10)
        {
            // DO NOTHING
        }
        else if (Database.IsConnectedCheck)
        {
            LoadAll(false);
        }
        clock           = null;
        _blnInitialized = true;
    }
Пример #3
0
    // STORED PROCEDURES
    public IEnumerator                             GetIDBSPstring(string strSP, string strParamList = "")                                                               // PIPE ("|") SEPARATED STRING
    {
        bool blnDone = false;

        _blnProcessing = true;
        Util.Timer clock = new Util.Timer();
        _strDBresponse = "";

        // SPLIT PARAMETER LIST STRING ON PIPE CHARACTER
        string[] strParams = strParamList.Split('|');

        // OPEN THE CONNECTION TO THE DATABASE
        if (DAL.IsConnected)
        {
            // ADD THE PARAMETERS
            DAL.ClearParams();
            foreach (string st in strParams)
            {
                DAL.AddParam(st.Split('=')[0], st.Split('=')[1]);
            }

            // MAKE THE STORED PROCEDURE CALL
            _strDBresponse = DAL.GetSPString(strSP);
            clock.StartTimer();

            // WAIT FOR THE RESPONSE
            while (!blnDone && clock.GetTime < QUERY_TIMEOUT)
            {
                blnDone = (_strDBresponse != "");
                yield return(null);
            }

            // DISPOSE OF TIMEOUT TIMER
            clock.StopTimer();
            clock = null;

            // IF NO RESULTS RETURNED ON TIME, SEND BACK EMPTY
            if (!blnDone)
            {
                _strDBresponse = "";
            }

            // RETURN VALUE
            _blnProcessing = false;
            yield return(_strDBresponse);
        }
        else
        {
                                #if IS_DEBUGGING
                                #if USES_APPLICATIONMANAGER
            App.AddToDebugLog("Database not connected");
            App.AddToDebugLog("Queries:\n" + DAL.SQLqueries);
            App.AddToDebugLog("Errors:\n" + DAL.Errors);
                                #endif
                                #endif
            _strDBresponse = "";
        }
        _blnProcessing = false;
    }
Пример #4
0
    // stored procedures
    public IEnumerator GetIDBSPstring(string strSP, string strParamList = "")               // PIPE ("|") SEPARATED STRING
    {
        bool blnDone = false;

        _blnProcessing = true;
        Util.Timer clock = new Util.Timer();
        _strDBresponse = "";

        // split parameter list string on pipe character
        string[] strParams = strParamList.Split('|');

        // open the connection to the database
        if (DAL.IsConnected)
        {
            // add the parameters
            DAL.ClearParams();
            foreach (string st in strParams)
            {
                DAL.AddParam(st.Split('=')[0], st.Split('=')[1]);
            }

            // make the stored procedure call
            _strDBresponse = DAL.GetSPString(strSP);
            clock.StartTimer();

            // wait for the response
            while (!blnDone && clock.GetTime < QUERY_TIMEOUT)
            {
                blnDone = (_strDBresponse != "");
                yield return(null);
            }

            // dispose of timeout timer
            clock.StopTimer();
            clock = null;

            // if no results returned on time, send back empty
            if (!blnDone)
            {
                _strDBresponse = "";
            }

            // return value
            _blnProcessing = false;
            yield return(_strDBresponse);
        }
        else
        {
#if is_debugging
#if uses_applicationmanager
            App.AddToDebugLog("Database not connected");
            App.AddToDebugLog("Queries:\n" + DAL.SQLqueries);
            App.AddToDebugLog("Errors:\n" + DAL.Errors);
#endif
#endif
            _strDBresponse = "";
        }
        _blnProcessing = false;
    }
Пример #5
0
    public IEnumerator                             GetIDBSQLdataTable(string strSQL)
    {
        bool blnDone = false;

        Util.Timer clock = new Util.Timer();
        _strDBresponse = "";
        _blnProcessing = true;
        _dtDBresponse  = null;

        // OPEN THE CONNECTION TO THE DATABASE
        if (DAL.IsConnected)
        {
            DAL.ClearParams();

            // MAKE THE SQL CALL
            _dtDBresponse = DAL.GetSQLSelectDataTable(strSQL);
            clock.StartTimer();

            // WAIT FOR THE RESPONSE
            while (!blnDone && clock.GetTime < QUERY_TIMEOUT)
            {
                blnDone = (_dtDBresponse != null);
                yield return(null);
            }

            // DISPOSE OF TIMEOUT TIMER
            clock.StopTimer();
            clock = null;

            // IF NO RESULTS RETURNED ON TIME, SEND BACK EMPTY
            if (!blnDone)
            {
                _dtDBresponse = null;
            }

            // TURN OFF PROCESSING FLAG
            _blnProcessing = false;

            // RETURN VALUE
            yield return(_dtDBresponse);
        }
        else
        {
                                #if IS_DEBUGGING
                                #if USES_APPLICATIONMANAGER
            App.AddToDebugLog("Database not connected");
            App.AddToDebugLog("Queries:\n" + DAL.SQLqueries);
            App.AddToDebugLog("Errors:\n" + DAL.Errors);
                                #endif
                                #endif
            _strDBresponse = "";
            _dtDBresponse  = null;
        }
        _blnProcessing = false;
    }
Пример #6
0
    public IEnumerator GetIDBSPdataTable(string strSP, string[] strParamList = null)
    {
        bool blnDone = false;

        _blnProcessing = true;
        Util.Timer clock = new Util.Timer();
        _strDBresponse = "";
        _dtDBresponse  = null;

        // open the connection to the database
        if (DAL.IsConnected)
        {
            // add the parameters
            DAL.ClearParams();
            foreach (string st in strParamList)
            {
                DAL.AddParam(st.Split('=')[0], st.Split('=')[1]);
            }

            // make the stored procedure call
            _dtDBresponse = DAL.GetSPDataTable(strSP);
            clock.StartTimer();

            // wait for the response
            while (!blnDone && clock.GetTime < QUERY_TIMEOUT)
            {
                blnDone = (_dtDBresponse != null);
                yield return(null);
            }

            // dispose of timeout timer
            clock.StopTimer();
            clock = null;

            // if no results returned on time, send back empty
            if (!blnDone)
            {
                _dtDBresponse = null;
            }

            // return value
            _blnProcessing = false;
            yield return(_dtDBresponse);
        }
        else
        {
            Debug.Log("Database not connected");
            Debug.Log("Queries:\n" + DAL.SQLqueries);
            Debug.Log("Errors:\n" + DAL.Errors);
            _strDBresponse = "";
            _dtDBresponse  = null;
        }
        _blnProcessing = false;
    }
Пример #7
0
    public IEnumerator GetIDBSQLdataTable(string strSQL)
    {
        bool blnDone = false;

        Util.Timer clock = new Util.Timer();
        _strDBresponse = "";
        _blnProcessing = true;
        _dtDBresponse  = null;

        // open the connection to the database
        if (DAL.IsConnected)
        {
            DAL.ClearParams();

            // make the sql call
            _dtDBresponse = DAL.GetSQLSelectDataTable(strSQL);
            clock.StartTimer();

            // wait for the response
            while (!blnDone && clock.GetTime < QUERY_TIMEOUT)
            {
                blnDone = (_dtDBresponse != null);
                yield return(null);
            }

            // dispose of timeout timer
            clock.StopTimer();
            clock = null;

            // if no results returned on time, send back empty
            if (!blnDone)
            {
                _dtDBresponse = null;
            }

            // turn off processing flag
            _blnProcessing = false;

            // return value
            yield return(_dtDBresponse);
        }
        else
        {
            Debug.Log("Database not connected");
            Debug.Log("Queries:\n" + DAL.SQLqueries);
            Debug.Log("Errors:\n" + DAL.Errors);
            _strDBresponse = "";
            _dtDBresponse  = null;
        }
        _blnProcessing = false;
    }
Пример #8
0
    private IEnumerator                                     InitializeDatabase(bool blnReadSettingsFile = true)
    {
        // DO NOT RE-INITIALIZE IF ALREADY OPEN
        if (!_blnInitialized)
        {
            // CONNECT TO DATABASE.  IF NOT CONNECTED IN TIMEOUT PERIOD, CLOSE APPLICATION
            Util.Timer clock = new Util.Timer();
            OpenDatabase(blnReadSettingsFile);
            bool blnCont = IsConnected;
            clock.StartTimer();
            while (clock.GetTime < CONNECTION_TIMEOUT && !blnCont)
            {
                blnCont = IsConnected;
                yield return(null);
            }
            clock.StopTimer();
            clock = null;

            if (!blnCont)
            {
                                        #if USES_STATUSMANAGER
                Status.Status = "Unable to Connect to Database.";
                                        #endif
            }
            else
            {
                _blnInitialized = true;
            }

            if (!KeepConnectionOpen)
            {
                // WAIT FOR THE CONNECTION TO COMPLETE, THEN CLOSE IT
                yield return(new WaitForSeconds(1.2f));

                CloseDatabase();
            }
        }
        yield return(new WaitForSeconds(1.5f));

                        #if USES_STATUSMANAGER
        Status.UpdateStatus();
                        #endif
        yield return(null);
    }
    private IEnumerator             DoStart()
    {
        // WE'RE GOING TO TEST IF WE CAN CONNECT TO THE DATABASE BY OPENING A CONNECTION THEN CLOSE IT
        int i = 0;

        Util.Timer clock = new Util.Timer();
        clock.StartTimer();
        while (!Database.IsConnected && clock.GetTime < 4)
        {
            yield return(null);

            i++;
        }
        ResultText = "Database Connected = " + Database.IsConnectedCheck.ToString() + " (After " + clock.GetTime + " seconds, " + i.ToString() + ")";
        if (!Database.KeepConnectionOpen)
        {
            Database.CloseDatabase();
        }
        clock.StopTimer();
    }
    private IEnumerator                     StartConnection()
    {
        int i = 0;

        ConnectionProgressBar.SetProgress(0, 100);
        ConnectionProgressBar.Caption = "Loading...";
        Util.Timer connClock = new Util.Timer();
        connClock.StartTimer();
        if (_blnForceConnection)
        {
            Net.ClientConnect();
        }
        while (!Net.IsConnected && connClock.GetTime <= Net.CONNECTION_TIMEOUT)
        {
            yield return(null);

            i++;
            ConnectionProgressBar.SetProgress(connClock.GetFloatTime, Net.CONNECTION_TIMEOUT);
            yield return(null);
        }
        connClock.StopTimer();
        ConnectionProgressBar.Caption = "";
        if (!Net.IsConnected && connClock.GetFloatTime > Net.CONNECTION_TIMEOUT)
        {
            ConnectionProgressBar.Caption = "Unable to Load.";
            if (Net.IsClient)
            {
                Net.ClientDisconnect();
//				if (Net.UsesMatchMaking)
//				{
//					PanelManager.Instance.ShowMatchMakingPanel();
//					Net.StartMatchMaking();
//				} else
                PanelManager.Instance.ShowConnectPanel();
            }
        }
        connClock = null;
    }