Example #1
0
        static public string CubeName(int id)
        {
            string cubename = "";

            Helpers.ETLHelpers.Debug("Trying to get cubename by chain: " + DdDReportState.currentChain);
            var chainConnString = DdDReportState.ChainConnectionString(DdDReportState.currentChain);

            Helpers.ETLHelpers.Debug("Got the chain connectionString: " + chainConnString);
            using (SqlConnection connection = new SqlConnection(DdDReportState.ChainConnectionString(DdDReportState.currentChain)))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = String.Format("SELECT cubeName FROM ddd.dbo.Users2 WHERE id = {0}", id);
                    Helpers.ETLHelpers.Debug("SQL to fire: " + cmd.CommandText);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            cubename = reader.GetString(0);
                        }
                    }
                }
            }

            return(Helpers.ETLHelpers.RemoveSpecialChars(cubename));
        }
Example #2
0
        static public bool FirstLogin(int id)
        {
            bool isFirstLogin = true;

            using (SqlConnection connection = new SqlConnection(DdDReportState.ChainConnectionString(DdDReportState.currentChain)))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = String.Format("SELECT * from ddd.dbo.DdDreportActiveUsers WHERE id = {0}", id);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            isFirstLogin = false;
                        }
                    }

                    if (isFirstLogin)
                    {
                        var cube     = "";
                        var username = "";
                        cmd.CommandText = String.Format("SELECT username,cubeName FROM ddd.dbo.Users2 WHERE id = {0}", id);
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                username = reader.GetString(0);
                                cube     = reader.GetString(1);
                            }
                        }

                        cmd.CommandText = String.Format("INSERT INTO ddd.dbo.DdDreportActiveUsers values ({0},'{1}','{2}',CURRENT_TIMESTAMP)", id, username, cube);
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            return(isFirstLogin);
        }
Example #3
0
        public static string Currency(int id)
        {
            string currency = "";

            using (SqlConnection connection = new SqlConnection(DdDReportState.ChainConnectionString(DdDReportState.currentChain)))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = String.Format("SELECT currency FROM ddd.dbo.Users2 where id={0}", id);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            currency = reader.GetString(0);
                        }
                    }
                }
            }

            return(currency);
        }
Example #4
0
        static public string Email(int id)
        {
            string email = "";

            using (SqlConnection connection = new SqlConnection(DdDReportState.ChainConnectionString(DdDReportState.currentChain)))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = String.Format("SELECT email FROM ddd.dbo.Users2 WHERE id = {0}", id);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            email = reader.GetString(0);
                        }
                    }
                }
            }

            return(email);
        }