Exemple #1
0
        public String GetPhrase(Int32 i32IdResource, Boolean blnIsStatic, ref Boolean blnRetVal)
        {
            String strRetVal = String.Empty;

            try
            {
                SQLDatabase DBConnection = new SQLDatabase(ConfigurationManager.ConnectionStrings["dbConnectionString"].ToString());
                if (DBConnection == null)
                {
                    blnRetVal = false;
                    return(String.Empty);
                }

                DBConnection.Connect();

                ResorceManager Function = new ResorceManager(DBConnection, System.Web.HttpContext.Current.Session);
                if (Function == null)
                {
                    blnRetVal = false;
                    return(String.Empty);
                }

                if (blnIsStatic)
                {
                    Function.SelectStaticPhrase(i32IdResource, ref strRetVal);
                }
                else
                {
                    Function.SelectPhrase(i32IdResource, ref strRetVal);
                }

                DBConnection.Disconnect();

                if (strRetVal == String.Empty)
                {
                    SessionLanguage Language = (SessionLanguage)System.Web.HttpContext.Current.Session["SessionLanguage"];

                    String strError = String.Format("Missing data for phrase witch IdResource = {0} and IdLanguage = {1}!", i32IdResource, Language.GetLanguage());
                    blnRetVal = false;

                    Global.ErrorMessage(strError, System.Web.HttpContext.Current);
                    return("No data for this phrase!");
                }
            }
            catch (SQLException Ex)
            {
                Global.ErrorMessage(Ex, System.Web.HttpContext.Current);
                blnRetVal = false;
                return(Ex.Message);
            }
            catch (NullReferenceException Ex)
            {
                Global.ErrorMessage(Ex, System.Web.HttpContext.Current);
                blnRetVal = false;
                return(Ex.Message);
            }

            return(strRetVal);
        }
Exemple #2
0
        protected Boolean DeleteByLivePhrase()
        {
            SharedResorceManagerPool.WaitOne();

            try
            {
                SQLDatabase DBConnection = new SQLDatabase(ConfigurationManager.ConnectionStrings["dbConnectionString"].ToString());
                if (DBConnection == null)
                {
                    return(false);
                }

                DBConnection.Connect();

                ResorceManager rsMenager = new ResorceManager(DBConnection);
                if (rsMenager == null)
                {
                    return(false);
                }

                DataSet dsLanguages = null;
                rsMenager.ListAllLanguages(out dsLanguages);
                DBConnection.Disconnect();

                DateTime IsLiveTime = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(2)).ToLocalTime();

                Int32     IdLanguage = 0;
                DataRow[] RowPhrases;
                foreach (DataRow row in dsLanguages.Tables["Languages"].Rows)
                {
                    IdLanguage = Convert.ToInt32(row["IdLanguage"]);

                    RowPhrases = dsPhrases.Tables["tblPhrases"].Select(String.Format("IdLanguage = {0} AND DateTimeLive <= #{1:s}#", IdLanguage, IsLiveTime));
                    foreach (DataRow RowPhrase in RowPhrases)
                    {
                        RowPhrase.Delete();
                    }

                    dsPhrases.Tables["tblPhrases"].AcceptChanges();
                }
            }
            catch (Exception Ex)
            {
                Global.ErrorMessage(Ex, System.Web.HttpContext.Current);
                return(false);
            }
            finally
            {
                SharedResorceManagerPool.ReleaseMutex();
            }

            return(true);
        }
Exemple #3
0
        public static Boolean GetPhrase(Int32 i32IdResource, Byte IdLanguage, Boolean blnIsStatic, ref String strRetVal)
        {
            try
            {
                SQLDatabase DBConnection = new SQLDatabase(ConfigurationManager.ConnectionStrings["dbConnectionString"].ToString());
                if (DBConnection == null)
                {
                    return(false);
                }

                DBConnection.Connect();

                ResorceManager Function = new ResorceManager(DBConnection);
                if (Function == null)
                {
                    return(false);
                }
                ;

                if (blnIsStatic)
                {
                    Function.SelectStaticPhraseByLanguage(i32IdResource, IdLanguage, ref strRetVal);
                }
                else
                {
                    Function.SelectPhraseByLanguage(i32IdResource, IdLanguage, ref strRetVal);
                }

                DBConnection.Disconnect();

                if (strRetVal == String.Empty)
                {
                    String strError = String.Format("Missing data for phrase witch IdResource = {0} and IdLanguage = {1}!", i32IdResource, IdLanguage);
                    strRetVal = "No data for this phrase!";

                    Global.ErrorMessage(strError, System.Web.HttpContext.Current);
                    return(false);
                }
            }
            catch (SQLException Ex)
            {
                Global.ErrorMessage(Ex, System.Web.HttpContext.Current);
                return(false);
            }
            catch (NullReferenceException Ex)
            {
                Global.ErrorMessage(Ex, System.Web.HttpContext.Current);
                return(false);
            }
            return(true);
        }