コード例 #1
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        CountryTableCollection _tbl = new CountryTableCollection();

        if (mode != "Insert")
        {
            int          _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            CountryTable _ct  = new CountryTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue"))
            {
                this.dxhfOrder.Remove("oldvalue");
            }
            this.dxhfOrder.Add("oldvalue", _ct.CountryName);
        }
        else
        {
            CountryTable _ct = new CountryTable();
            _tbl.Add(_ct);
        }

        this.fmvCountry.DataSource = _tbl;
        this.fmvCountry.DataBind();
    }
コード例 #2
0
 public void UpdateOriginCountryTable()
 {
     CountryTable.DataSource = null;
     CountryTable.Update();
     CountryTable.Refresh();
     CountryTable.DataSource = CountryList;
     CountryTable.Update();
     CountryTable.Refresh();
 }
コード例 #3
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_country()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            CountryTable _tbl = new CountryTable();

            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtCountryInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("CountryName", "CountryTable", _newvalue))
                {
                    _tbl.CountryName = _txt.Text.Trim().ToString();

                    //ISO code
                    _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtISOInsert");
                    if (_txt != null && _txt.Text != "")
                    {
                        _tbl.ISOCode = _txt.Text.Trim().ToString();
                    }

                    //euro
                    ASPxCheckBox _chk = (ASPxCheckBox)this.fmvCountry.FindControl("dxckEuroInsert");
                    if (_chk != null)
                    {
                        _tbl.Eu = _chk.Checked ? true : false;
                    }

                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text          = _ex;
                    this.dxpnlErr.ClientVisible = true;
                }
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return(_newid);
    }
コード例 #4
0
        static void Main(string[] args)
        {
            Database db = new Database();

            db.Connect();

            Vehicle u = new Vehicle();

            u.Id = 14;
            // u.Manufacturer = "Stadler";
            //u.Model = "Tango NF2 kopie";


            Console.WriteLine("Seznam vsech statu ve DB");
            foreach (Country c in CountryTable.Select())
            {
                Console.WriteLine(c.Id + " " + c.Name + " " + c.Continent);
            }
            Console.WriteLine("----");

            Console.WriteLine("Seznam vsech mest ve DB");
            foreach (City c in CityTable.Select())
            {
                Console.WriteLine(c.Id + " " + c.Name + " " + c.Region + " STAT: " + c.Country.Name);
            }
            Console.WriteLine("----");


            Console.WriteLine("Seznam vsech vozidel ve DB");
            foreach (Vehicle v in VehicleTable.Select())
            {
                Console.WriteLine(v.Id + "  Znacka:" + v.vehicleModel.Manufacturer + " Model:" + v.vehicleModel.Model + " Podtyp:" + v.Podtyp + " City:" + v.city.Name + " Depo:" + v.depot.Name);
            }

            Console.WriteLine("Seznam vsech company ve DB");
            foreach (Company c in CompanyTable.Select())
            {
                Console.WriteLine(c.Id + " Nazev:" + c.Name);
            }


            //VehicleTable.Insert(u, db);

            /*
             * int count1 = VehicleTable.Select(db).Count;
             * int dltCount = VehicleTable.Delete(7, db);
             * int count2 = VehicleTable.Select(db).Count;
             *
             * Console.WriteLine("#C: " + count1);
             * Console.WriteLine("#D: " + dltCount);
             * Console.WriteLine("#C: " + count2);
             */
            db.Close();
            Console.ReadKey();
        }
コード例 #5
0
	    public void Insert(string CountryName,bool? Eu,string ISOCode,byte[] Ts)
	    {
		    CountryTable item = new CountryTable();
		    
            item.CountryName = CountryName;
            
            item.Eu = Eu;
            
            item.ISOCode = ISOCode;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
コード例 #6
0
    /// <summary>
    /// update hvoyagetable
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_country()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for countryname
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";

        if (_pid > 0)
        {
            try
            {
                //new instance of record
                CountryTable _tbl = new CountryTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtCountryEdit");
                if (_txt != null && _txt.Text != "")
                {
                    string _newvalue  = _txt.Text.Trim().ToString(); //country name
                    bool   _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("CountryName", "CountryTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.CountryName = _newvalue;
                        //ISO code
                        _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtISOEdit");
                        if (_txt != null && _txt.Text != "")
                        {
                            _tbl.ISOCode = _txt.Text.Trim().ToString();
                        }

                        //euro
                        ASPxCheckBox _chk = (ASPxCheckBox)this.fmvCountry.FindControl("dxckEuroEdit");
                        if (_chk != null)
                        {
                            _tbl.Eu = _chk.Checked ? true : false;
                        }

                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text          = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text          = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
コード例 #7
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_country()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            CountryTable _tbl = new CountryTable();
            
            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtCountryInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("CountryName", "CountryTable", _newvalue))
                {
                    _tbl.CountryName = _txt.Text.Trim().ToString();

                    //ISO code
                    _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtISOInsert");
                    if (_txt != null && _txt.Text != "")
                    {
                        _tbl.ISOCode = _txt.Text.Trim().ToString();
                    }

                    //euro
                    ASPxCheckBox _chk = (ASPxCheckBox)this.fmvCountry.FindControl("dxckEuroInsert");
                    if (_chk != null)
                    {
                        _tbl.Eu = _chk.Checked ? true : false;
                    }

                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text = _ex;
                    this.dxpnlErr.ClientVisible = true;
                }
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
コード例 #8
0
    /// <summary>
    /// update hvoyagetable
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_country()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for countryname
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";
   
        if (_pid > 0)
        {
            try
            {
                //new instance of record
                CountryTable _tbl = new CountryTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtCountryEdit");
                if (_txt != null && _txt.Text != "")
                {  
                    string _newvalue = _txt.Text.Trim().ToString(); //country name
                    bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("CountryName", "CountryTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.CountryName = _newvalue;
                        //ISO code
                        _txt = (ASPxTextBox)this.fmvCountry.FindControl("dxtxtISOEdit");
                        if (_txt != null && _txt.Text != "")
                        {
                            _tbl.ISOCode = _txt.Text.Trim().ToString();
                        }

                        //euro
                        ASPxCheckBox _chk = (ASPxCheckBox)this.fmvCountry.FindControl("dxckEuroEdit");
                        if (_chk != null)
                        {
                            _tbl.Eu = _chk.Checked ? true : false;
                        }

                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
コード例 #9
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        CountryTableCollection _tbl = new CountryTableCollection();
        if (mode != "Insert")
        {
            int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            CountryTable _ct = new CountryTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); }
            this.dxhfOrder.Add("oldvalue", _ct.CountryName); 
        }
        else
        {
            CountryTable _ct = new CountryTable();
            _tbl.Add(_ct);
        }

        this.fmvCountry.DataSource = _tbl;
        this.fmvCountry.DataBind();
    }
コード例 #10
0
ファイル: Test_Core.cs プロジェクト: olcayseker/Kerosene
		public static void Nested_UpdateReaders( IKLink link )
		{
			Console.WriteLine( "\n===== Nested Updates..." );

			KCommandRaw raw = link.Raw();
			Console.WriteLine( "\n== SUSPENDING THE CONSTRAINTS..." );
			raw.Set( "ALTER TABLE Countries NOCHECK CONSTRAINT ALL" ); raw.Execute();
			raw.Set( "ALTER TABLE Employees NOCHECK CONSTRAINT ALL" ); raw.Execute();

			var cmd = link.Update( x => x.Countries )
				.Where( x => x.Id == "es" )
				.Column( x => x.Id = "es#" );
			Console.WriteLine( "\n> Command => {0}", cmd );

			foreach( var ctry in cmd.ConvertBy( rec => {
				CountryTable table = new CountryTable(); dynamic d = rec;
				table.Id = d.Id;
				table.Name = d.Name;
				table.RegionId = d.RegionId;

				_Nested_UpdateReaders_Employees( link );
				return table;
			} ) ) Console.WriteLine( "\n> Country => {0}", ctry );
			cmd.Dispose();

			Console.WriteLine( "\n== REACTIVATING THE CONSTRAINTS..." );
			raw.Set( "ALTER TABLE Countries CHECK CONSTRAINT ALL" ); raw.Execute();
			raw.Set( "ALTER TABLE Employees CHECK CONSTRAINT ALL" ); raw.Execute();
		}
コード例 #11
0
ファイル: Test_Core.cs プロジェクト: olcayseker/Kerosene
		static void _Nested_Readers_Employees( IKLink link, CountryTable ctry )
		{
			var cmd = link.From( x => x.Employees ).Where( x => x.CountryId == ctry.Id );
			DEBUG.IndentLine( "\n> Command => {0}", cmd );

			foreach( var emp in cmd.ConvertBy( rec => {
				EmployeeTable table = new EmployeeTable(); dynamic d = rec;
				table.Id = d.Id;
				table.FirstName = d.FirstName;
				table.LastName = d.LastName;
				table.CountryId = d.CountryId;

				ctry.Employees.Add( table );
				return table;
			} ) ) DEBUG.WriteLine( "\n> Employee => {0}", emp );
			cmd.Dispose();

			DEBUG.Unindent();
		}
コード例 #12
0
ファイル: Test_Core.cs プロジェクト: olcayseker/Kerosene
		public static void Nested_Readers( IKLink link )
		{
			Console.WriteLine( "\n===== Nested readers..." );

			var cmd = link.From( x => x.Countries ).OrderBy( x => x.Name );
			Console.WriteLine( "\n> Command => {0}", cmd );

			foreach( var ctry in cmd.ConvertBy( rec => {
				CountryTable table = new CountryTable(); dynamic d = rec;
				table.Id = d.Id;
				table.Name = d.Name;
				table.RegionId = d.RegionId;

				_Nested_Readers_Employees( link, table );
				return table;
			} ) ) Console.WriteLine( "\n> Country => {0}", ctry );
			cmd.Dispose();
		}
コード例 #13
0
 async void GetCountryList()
 {
     CountryTable.CountryList = await CountryTable.GetCompactCountrylist();
 }
コード例 #14
0
	    public void Update(int CountryID,string CountryName,bool? Eu,string ISOCode,byte[] Ts)
	    {
		    CountryTable item = new CountryTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.CountryID = CountryID;
				
			item.CountryName = CountryName;
				
			item.Eu = Eu;
				
			item.ISOCode = ISOCode;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }
コード例 #15
0
        public List <Message> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             MessageTable.GetColumnNames("[m]") +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[m_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[m_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[m_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[m_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[m_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[m_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[m_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CustomerTable.GetColumnNames("[m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTable.GetColumnNames("[m_c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[m_c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_c_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[m_c_mo]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[m_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_mo_c]") : string.Empty) +
                             " FROM [stats].[Message] AS [m] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [m_s] ON [m].[ServiceID] = [m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [m_s_a] ON [m_s].[ApplicationID] = [m_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [m_s_p] ON [m_s].[ProductID] = [m_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [m_s_m] ON [m_s].[MerchantID] = [m_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [m_s_st] ON [m_s].[ServiceTypeID] = [m_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [m_s_ust] ON [m_s].[UserSessionTypeID] = [m_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [m_s_c] ON [m_s].[FallbackCountryID] = [m_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [m_s_l] ON [m_s].[FallbackLanguageID] = [m_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [m_s_sc] ON [m_s].[ServiceConfigurationID] = [m_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [m_s_t] ON [m_s].[TemplateID] = [m_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [m_c] ON [m].[CustomerID] = [m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [m_c_u] ON [m_c].[UserID] = [m_c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [m_c_s] ON [m_c].[ServiceID] = [m_c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_c_c] ON [m_c].[CountryID] = [m_c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [m_c_l] ON [m_c].[LanguageID] = [m_c_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_c_mo] ON [m_c].[MobileOperatorID] = [m_c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_mo] ON [m].[MobileOperatorID] = [m_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_mo_c] ON [m_mo].[CountryID] = [m_mo_c].[CountryID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "customloadmany", "notfound"), "Message list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <Message>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MessageTable              mTable       = new MessageTable(query);
                ServiceTable              m_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          m_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              m_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             m_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          m_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      m_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              m_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             m_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable m_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             m_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CustomerTable             m_cTable     = (this.Depth > 0) ? new CustomerTable(query) : null;
                UserTable           m_c_uTable         = (this.Depth > 1) ? new UserTable(query) : null;
                ServiceTable        m_c_sTable         = (this.Depth > 1) ? new ServiceTable(query) : null;
                CountryTable        m_c_cTable         = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable       m_c_lTable         = (this.Depth > 1) ? new LanguageTable(query) : null;
                MobileOperatorTable m_c_moTable        = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                MobileOperatorTable m_moTable          = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable        m_mo_cTable        = (this.Depth > 1) ? new CountryTable(query) : null;

                List <Message> result = new List <Message>();
                do
                {
                    Application          m_s_aObject   = (this.Depth > 1) ? m_s_aTable.CreateInstance() : null;
                    Product              m_s_pObject   = (this.Depth > 1) ? m_s_pTable.CreateInstance() : null;
                    Merchant             m_s_mObject   = (this.Depth > 1) ? m_s_mTable.CreateInstance() : null;
                    ServiceType          m_s_stObject  = (this.Depth > 1) ? m_s_stTable.CreateInstance() : null;
                    UserSessionType      m_s_ustObject = (this.Depth > 1) ? m_s_ustTable.CreateInstance() : null;
                    Country              m_s_cObject   = (this.Depth > 1) ? m_s_cTable.CreateInstance() : null;
                    Language             m_s_lObject   = (this.Depth > 1) ? m_s_lTable.CreateInstance() : null;
                    ServiceConfiguration m_s_scObject  = (this.Depth > 1) ? m_s_scTable.CreateInstance() : null;
                    Template             m_s_tObject   = (this.Depth > 1) ? m_s_tTable.CreateInstance() : null;
                    Service              m_sObject     = (this.Depth > 0) ? m_sTable.CreateInstance(m_s_aObject, m_s_pObject, m_s_mObject, m_s_stObject, m_s_ustObject, m_s_cObject, m_s_lObject, m_s_scObject, m_s_tObject) : null;
                    User           m_c_uObject         = (this.Depth > 1) ? m_c_uTable.CreateInstance() : null;
                    Service        m_c_sObject         = (this.Depth > 1) ? m_c_sTable.CreateInstance() : null;
                    Country        m_c_cObject         = (this.Depth > 1) ? m_c_cTable.CreateInstance() : null;
                    Language       m_c_lObject         = (this.Depth > 1) ? m_c_lTable.CreateInstance() : null;
                    MobileOperator m_c_moObject        = (this.Depth > 1) ? m_c_moTable.CreateInstance() : null;
                    Customer       m_cObject           = (this.Depth > 0) ? m_cTable.CreateInstance(m_c_uObject, m_c_sObject, m_c_cObject, m_c_lObject, m_c_moObject) : null;
                    Country        m_mo_cObject        = (this.Depth > 1) ? m_mo_cTable.CreateInstance() : null;
                    MobileOperator m_moObject          = (this.Depth > 0) ? m_moTable.CreateInstance(m_mo_cObject) : null;
                    Message        mObject             = (this.Depth > -1) ? mTable.CreateInstance(m_sObject, m_cObject, m_moObject) : null;
                    result.Add(mObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "customloadmany", "exception"), "Message list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Message", "Exception while loading (custom/many) Message object from database. See inner exception for details.", ex);
            }
        }
コード例 #16
0
        protected override Message LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             MessageTable.GetColumnNames("[m]") +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[m_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[m_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[m_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[m_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[m_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[m_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[m_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CustomerTable.GetColumnNames("[m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTable.GetColumnNames("[m_c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[m_c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_c_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[m_c_mo]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[m_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_mo_c]") : string.Empty) +
                             " FROM [stats].[Message] AS [m] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [m_s] ON [m].[ServiceID] = [m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [m_s_a] ON [m_s].[ApplicationID] = [m_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [m_s_p] ON [m_s].[ProductID] = [m_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [m_s_m] ON [m_s].[MerchantID] = [m_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [m_s_st] ON [m_s].[ServiceTypeID] = [m_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [m_s_ust] ON [m_s].[UserSessionTypeID] = [m_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [m_s_c] ON [m_s].[FallbackCountryID] = [m_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [m_s_l] ON [m_s].[FallbackLanguageID] = [m_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [m_s_sc] ON [m_s].[ServiceConfigurationID] = [m_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [m_s_t] ON [m_s].[TemplateID] = [m_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [m_c] ON [m].[CustomerID] = [m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [m_c_u] ON [m_c].[UserID] = [m_c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [m_c_s] ON [m_c].[ServiceID] = [m_c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_c_c] ON [m_c].[CountryID] = [m_c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [m_c_l] ON [m_c].[LanguageID] = [m_c_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_c_mo] ON [m_c].[MobileOperatorID] = [m_c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_mo] ON [m].[MobileOperatorID] = [m_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_mo_c] ON [m_mo].[CountryID] = [m_mo_c].[CountryID] ";
                }
                sqlCmdText += "WHERE [m].[MessageID] = @MessageID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@MessageID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "loadinternal", "notfound"), "Message could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MessageTable              mTable       = new MessageTable(query);
                ServiceTable              m_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          m_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              m_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             m_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          m_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      m_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              m_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             m_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable m_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             m_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CustomerTable             m_cTable     = (this.Depth > 0) ? new CustomerTable(query) : null;
                UserTable           m_c_uTable         = (this.Depth > 1) ? new UserTable(query) : null;
                ServiceTable        m_c_sTable         = (this.Depth > 1) ? new ServiceTable(query) : null;
                CountryTable        m_c_cTable         = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable       m_c_lTable         = (this.Depth > 1) ? new LanguageTable(query) : null;
                MobileOperatorTable m_c_moTable        = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                MobileOperatorTable m_moTable          = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable        m_mo_cTable        = (this.Depth > 1) ? new CountryTable(query) : null;


                Application          m_s_aObject   = (this.Depth > 1) ? m_s_aTable.CreateInstance() : null;
                Product              m_s_pObject   = (this.Depth > 1) ? m_s_pTable.CreateInstance() : null;
                Merchant             m_s_mObject   = (this.Depth > 1) ? m_s_mTable.CreateInstance() : null;
                ServiceType          m_s_stObject  = (this.Depth > 1) ? m_s_stTable.CreateInstance() : null;
                UserSessionType      m_s_ustObject = (this.Depth > 1) ? m_s_ustTable.CreateInstance() : null;
                Country              m_s_cObject   = (this.Depth > 1) ? m_s_cTable.CreateInstance() : null;
                Language             m_s_lObject   = (this.Depth > 1) ? m_s_lTable.CreateInstance() : null;
                ServiceConfiguration m_s_scObject  = (this.Depth > 1) ? m_s_scTable.CreateInstance() : null;
                Template             m_s_tObject   = (this.Depth > 1) ? m_s_tTable.CreateInstance() : null;
                Service              m_sObject     = (this.Depth > 0) ? m_sTable.CreateInstance(m_s_aObject, m_s_pObject, m_s_mObject, m_s_stObject, m_s_ustObject, m_s_cObject, m_s_lObject, m_s_scObject, m_s_tObject) : null;
                User           m_c_uObject         = (this.Depth > 1) ? m_c_uTable.CreateInstance() : null;
                Service        m_c_sObject         = (this.Depth > 1) ? m_c_sTable.CreateInstance() : null;
                Country        m_c_cObject         = (this.Depth > 1) ? m_c_cTable.CreateInstance() : null;
                Language       m_c_lObject         = (this.Depth > 1) ? m_c_lTable.CreateInstance() : null;
                MobileOperator m_c_moObject        = (this.Depth > 1) ? m_c_moTable.CreateInstance() : null;
                Customer       m_cObject           = (this.Depth > 0) ? m_cTable.CreateInstance(m_c_uObject, m_c_sObject, m_c_cObject, m_c_lObject, m_c_moObject) : null;
                Country        m_mo_cObject        = (this.Depth > 1) ? m_mo_cTable.CreateInstance() : null;
                MobileOperator m_moObject          = (this.Depth > 0) ? m_moTable.CreateInstance(m_mo_cObject) : null;
                Message        mObject             = mTable.CreateInstance(m_sObject, m_cObject, m_moObject);
                sqlReader.Close();

                return(mObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "loadinternal", "exception"), "Message could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Message", "Exception while loading Message object from database. See inner exception for details.", ex);
            }
        }