Beispiel #1
0
        public static async Task LoadTestForQuery(ServiceTable serviceTable, VersionTable versionTable)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var version = await versionTable.GetCurrent(ResourceType.Service);

            if (version != null)
            {
                stopWatch.Stop();
                Console.WriteLine($"verion: {version.RowKey}, takes {stopWatch.ElapsedMilliseconds} milli-seconds");
            }
            stopWatch.Start();
            var services = await serviceTable.GetFromParitionKey(version.RowKey);

            var models = new List <ServiceViewModel>();

            foreach (var entity in services)
            {
                try
                {
                    models.Add(ServiceViewModel.FromEntity((ServiceEntity)entity));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            stopWatch.Stop();
            Console.WriteLine($"query {models.Count} takes {stopWatch.ElapsedMilliseconds} milli-seconds");
        }
Beispiel #2
0
        /// <summary>
        /// Створює елементи вектору з данними виносу.
        /// </summary>
        private void CreateDrawingStakeOut()
        {
            if (this.PointStation == null)
            {
                return;
            }

            AcGe.Point3d pntStart = new AcGe.Point3d(this.PointStation.E, this.PointStation.N, this.PointStation.H);
            AcGe.Point3d pntEnd   = new AcGe.Point3d(this.Coordinates.X, this.Coordinates.Y, 0);

            AcDb.Line line = new AcDb.Line(pntStart, pntEnd);
            line.Visible = this.Visible;

            AcGe.Point3d pntMiddle = new AcGe.LineSegment3d(pntStart, pntEnd).MidPoint;

            double angleTXT = line.Angle;

            if (angleTXT > Math.PI / 2 && angleTXT < Math.PI * 3 / 2)
            {
                angleTXT += Math.PI;
            }

            AcDb.MText text = new AcDb.MText();
            text.Contents = this.DistanceToString(AcRx.DistanceUnitFormat.Decimal) + "\r\n"
                            + "л.к. " + ServiceTable.FormatAngleValue(this.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds));
            text.Rotation   = angleTXT;
            text.Location   = pntMiddle;
            text.Attachment = AcDb.AttachmentPoint.MiddleCenter;
            text.Width      = 25;
            text.TextHeight = 1.8 * this.ScaleDrawing;


            this.lineID = ServiceCAD.InsertObject(line);
            this.txtID  = ServiceCAD.InsertObject(text);
        }
Beispiel #3
0
        public void сreate(LandParcel parcel, double scaleTable)
        {
            LandParcel parcelСombinedLimiting = ServiceTable.СombinedLimiting(parcel);

            string titleTable = ServiceTable.ReplaceValueCodeInTitle(parcelСombinedLimiting, this.Setting);

            foreach (AcDb.DBObject obj in ServiceTable.GetCapTables(titleTable, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetBoundTable(parcelСombinedLimiting.Limiting.Count, this.Setting.TextHeight * 6, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetDataTableLimiting(parcelСombinedLimiting, this.Setting))
            {
                objects.Add(obj);
            }

            string nameBlockTable = ServiceBlockElements.CreateBlock(this.objects, this.Setting.KeyTable);

            ServiceBlockElements.ManualInsertBlock(nameBlockTable, scaleTable);
            objects = new AcDb.DBObjectCollection();
        }
Beispiel #4
0
        public void сreate(LandParcel parcel, double scaleTable)
        {
            // ???????
            LandParcel parcelСombinedLand = ServiceTable.СombinedLand(parcel);

            throw new NotImplementedException();
        }
 protected override async Task OnExecuteAsync(CommandLineApplication app)
 {
     ValidateParameters();
     var storageAccount = AzureStorageAccount.CreateStorageAccountFromConnectionString(ConnectionString);
     var serviceTable   = new ServiceTable(AzureStorageAccount.GetStorageTable(ConnectionString));
     var versionTable   = new VersionTable(AzureStorageAccount.GetStorageTable(ConnectionString));
     await Helper.LoadTestForQuery(serviceTable, versionTable);
 }
        public ServiceProvider(IEnumerable <ServiceDescriptor> serviceDescriptors)
        {
            _root  = this;
            _table = new ServiceTable(serviceDescriptors);

            _table.Add(typeof(IServiceProvider), new ServiceProviderService());
            _table.Add(typeof(IServiceScopeFactory), new ServiceScopeService());
            _table.Add(typeof(IEnumerable <>), new OpenIEnumerableService(_table));
        }
        public ServiceProvider(
            IEnumerable <IServiceDescriptor> serviceDescriptors,
            IServiceProvider fallbackServiceProvider)
        {
            _table    = new ServiceTable(serviceDescriptors);
            _fallback = fallbackServiceProvider;

            _table.Add(typeof(IServiceProvider), new ServiceProviderService());
            _table.Add(typeof(IServiceScopeFactory), new ServiceScopeService());
            _table.Add(typeof(IEnumerable <>), new OpenIEnumerableService(_table));
        }
Beispiel #8
0
 public MainForm()
 {
     InitializeComponent();
     classTableWorker   = new WorkerTable(GridViewWorker);
     classTableService  = new ServiceTable(GridViewService);
     classTableCustomer = new CustomerTable(GridViewСustomers);
     groupTable         = new GroupTable(GridViewGroups);
     visitTable         = new VisitTable(GridViewVisitGroup);
     timetable          = new TimetableTable(GridViewTimeTable);
     recordGroup        = new RecordGroupTable(GridViewRecordGroups);
     timetable.DateDay  = SelectDate.Value;
     timetable.Room     = cbRoom.Text;
 }
        public ServiceTableFieldViewModel(ServiceTableFieldWindow sourceWindow, ServiceTableField selectedServiceTableField)
        {
            this._contextDal  = new ServiceTableFieldDAL();
            this.SourceWindow = sourceWindow;
            this.SelectedServiceTableField = selectedServiceTableField;
            this.SaveCommand     = new RelayCommand(SaveServiceTableField, CanExecute);
            this.DictionaryDal   = new DictionaryDAL();
            this.ServiceTableDal = new ServiceTableDAL();
            this.TableFieldList  = new ObservableCollection <Dictionary>(DictionaryDal.DictionaryListByType(3));
            ServiceTable st = ServiceTableDal.FindById((int)selectedServiceTableField.TableID);
            int          contextSessionGroupID = st.Team.SessionGroupID;

            this.TableList = new ObservableCollection <ServiceTable>(ServiceTableDal.FindAll(x => x.Team.SessionGroupID == contextSessionGroupID));
        }
        public void CreateServiceTable()
        {
            ServiceTable serviceTable = new ServiceTable()
            {
                TeamID = ContextStudent.TeamID
            };
            ServiceTableWindow target = new ServiceTableWindow(serviceTable)
            {
                Owner = this.SourceWindow
            };

            SwitchWindows(target, true);
            this.ServiceTableList = ReloadServiceTableList();
        }
        protected override async Task OnExecuteAsync(CommandLineApplication app)
        {
            var keyvaultAddress = $"https://{KeyVaultName}.vault.azure.net/";
            var azureHelper     = new AzureHelper(TenantId);

            var storageAccount = CloudStorageAccount.Parse(
                azureHelper.GetSecretValue(
                    keyvaultAddress, "StorageAccountConnectionString").GetAwaiter().GetResult());
            var tableClient = storageAccount.CreateCloudTableClient();

            var serviceTable = new ServiceTable(tableClient);
            var versionTable = new VersionTable(tableClient);
            await Helper.LoadTestForQuery(serviceTable, versionTable);
        }
        public ServiceProvider(IEnumerable <ServiceDescriptor> serviceDescriptors, bool validateScopes)
        {
            Root = this;

            if (validateScopes)
            {
                _callSiteValidator = new CallSiteValidator();
            }

            _table = new ServiceTable(serviceDescriptors);

            _table.Add(typeof(IServiceProvider), new ServiceProviderService());
            _table.Add(typeof(IServiceScopeFactory), new ServiceScopeService());
            _table.Add(typeof(IEnumerable <>), new OpenIEnumerableService(_table));
        }
        // This constructor is called exclusively to create a child scope from the parent
        internal ServiceProvider(ServiceProvider parent)
        {
            _root     = parent._root;
            _table    = parent._table;
            _fallback = parent._fallback;

            // Rescope the fallback service provider if it contains an IServiceScopeFactory
            var scopeFactory = GetFallbackServiceOrNull <IServiceScopeFactory>();

            if (scopeFactory != null)
            {
                var scope = scopeFactory.CreateScope();
                _fallback = scope.ServiceProvider;
                _disposables.Add(scope);
            }
        }
Beispiel #14
0
        internal static Func <ServiceProvider, object> RealizeService(ServiceTable table, Type serviceType, IServiceCallSite callSite)
        {
            var callCount = 0;

            return(provider => {
                if (Interlocked.Increment(ref callCount) == 2)
                {
                    Task.Run(() => {
                        var realizedService = new CallSiteExpressionBuilder(_callSiteRuntimeResolver)
                                              .Build(callSite);
                        table.RealizedServices[serviceType] = realizedService;
                    });
                }

                return _callSiteRuntimeResolver.Resolve(callSite, provider);
            });
        }
        public void DeleteServiceTable(object param)
        {
            ServiceTable selectedServiceTable = (ServiceTable)((DataGrid)param).SelectedItem;

            if (ServiceTableFieldDal.FindAll().Exists(x => x.TableID == selectedServiceTable.ID))
            {
                MessageBox.Show("A táblához tartozik mező, ezért nem törölhető!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Valóban törli?", "Törlés megerősítése", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    ServiceTableList.Remove(selectedServiceTable);
                    ServiceTableDal.LogicalDelete(selectedServiceTable);
                }
                ServiceTableList = ReloadServiceTableList();
            }
        }
        internal static Func <ServiceProvider, object> RealizeService(ServiceTable table, Type serviceType, IServiceCallSite callSite)
        {
            var callCount = 0;

            return(provider =>
            {
                if (Interlocked.Increment(ref callCount) == 2)
                {
                    Task.Run(() =>
                    {
                        var providerExpression = Expression.Parameter(typeof(ServiceProvider), "provider");

                        var lambdaExpression = Expression.Lambda <Func <ServiceProvider, object> >(
                            callSite.Build(providerExpression),
                            providerExpression);

                        table.RealizedServices[serviceType] = lambdaExpression.Compile();
                    });
                }

                return callSite.Invoke(provider);
            });
        }
Beispiel #17
0
        public void сreate(LandParcel polygon, double scale)
        {
            string titleTable = ServiceTable.ReplaceValueCodeInTitle(polygon, this.Setting);

            foreach (AcDb.DBObject obj in ServiceTable.GetCapTables(titleTable, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetBoundTable(polygon.Points.Count + 1, this.Setting.TextHeight * 2, this.Setting))
            {
                objects.Add(obj);
            }

            foreach (AcDb.DBObject obj in ServiceTable.GetDataTableStakeOutParcelPoints(polygon, this.Setting))
            {
                objects.Add(obj);
            }

            string nameBlockTable = ServiceBlockElements.CreateBlock(this.objects, this.Setting.KeyTable);

            ServiceBlockElements.ManualInsertBlock(nameBlockTable, scale);
            objects = new AcDb.DBObjectCollection();
        }
Beispiel #18
0
        private void bttAdd_Click(object sender, EventArgs e)
        {
            if (tbName.Text == String.Empty || tbPrice.Text == String.Empty || cbHouse.Text == String.Empty)
            {
                MessageBox.Show("Заполните поля",
                                "Внимание",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            classTableService = new ServiceTable(tbName.Text, Int32.Parse(cbHouse.Text), Int32.Parse(tbPrice.Text));
            if (classTableService.CheckSimilarName(tbName.Text))
            {
                MessageBox.Show("Такая услуга существует",
                                "Внимание",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            DialogResult dialogResult = MessageBox.Show("Вы уверены что хотите сохранить услугу?",
                                                        "Внимание",
                                                        MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Information);

            if (dialogResult == DialogResult.No)
            {
                return;
            }



            classTableService.AddRow();
            this.Close();
        }
Beispiel #19
0
        public List <MOMessage> 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} " +
                             MOMessageTable.GetColumnNames("[mom]") +
                             (this.Depth > 0 ? "," + MessageTable.GetColumnNames("[mom_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[mom_m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[mom_m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[mom_m_mo]") : string.Empty) +
                             " FROM [stats].[MOMessage] AS [mom] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [stats].[Message] AS [mom_m] ON [mom].[MessageID] = [mom_m].[MessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [mom_m_s] ON [mom_m].[ServiceID] = [mom_m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [mom_m_c] ON [mom_m].[CustomerID] = [mom_m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [mom_m_mo] ON [mom_m].[MobileOperatorID] = [mom_m_mo].[MobileOperatorID] ";
                }


                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("mom", "customloadmany", "notfound"), "MOMessage 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 <MOMessage>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MOMessageTable      momTable      = new MOMessageTable(query);
                MessageTable        mom_mTable    = (this.Depth > 0) ? new MessageTable(query) : null;
                ServiceTable        mom_m_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                CustomerTable       mom_m_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                MobileOperatorTable mom_m_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;

                List <MOMessage> result = new List <MOMessage>();
                do
                {
                    Service        mom_m_sObject  = (this.Depth > 1) ? mom_m_sTable.CreateInstance() : null;
                    Customer       mom_m_cObject  = (this.Depth > 1) ? mom_m_cTable.CreateInstance() : null;
                    MobileOperator mom_m_moObject = (this.Depth > 1) ? mom_m_moTable.CreateInstance() : null;
                    Message        mom_mObject    = (this.Depth > 0) ? mom_mTable.CreateInstance(mom_m_sObject, mom_m_cObject, mom_m_moObject) : null;
                    MOMessage      momObject      = (this.Depth > -1) ? momTable.CreateInstance(mom_mObject) : null;
                    result.Add(momObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "customloadmany", "exception"), "MOMessage 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, "MOMessage", "Exception while loading (custom/many) MOMessage object from database. See inner exception for details.", ex);
            }
        }
Beispiel #20
0
        protected override MOMessage 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 " +
                             MOMessageTable.GetColumnNames("[mom]") +
                             (this.Depth > 0 ? "," + MessageTable.GetColumnNames("[mom_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[mom_m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[mom_m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[mom_m_mo]") : string.Empty) +
                             " FROM [stats].[MOMessage] AS [mom] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [stats].[Message] AS [mom_m] ON [mom].[MessageID] = [mom_m].[MessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [mom_m_s] ON [mom_m].[ServiceID] = [mom_m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [mom_m_c] ON [mom_m].[CustomerID] = [mom_m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [mom_m_mo] ON [mom_m].[MobileOperatorID] = [mom_m_mo].[MobileOperatorID] ";
                }
                sqlCmdText += "WHERE [mom].[MOMessageID] = @MOMessageID;";

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

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "loadinternal", "notfound"), "MOMessage 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);

                MOMessageTable      momTable      = new MOMessageTable(query);
                MessageTable        mom_mTable    = (this.Depth > 0) ? new MessageTable(query) : null;
                ServiceTable        mom_m_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                CustomerTable       mom_m_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                MobileOperatorTable mom_m_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;


                Service        mom_m_sObject  = (this.Depth > 1) ? mom_m_sTable.CreateInstance() : null;
                Customer       mom_m_cObject  = (this.Depth > 1) ? mom_m_cTable.CreateInstance() : null;
                MobileOperator mom_m_moObject = (this.Depth > 1) ? mom_m_moTable.CreateInstance() : null;
                Message        mom_mObject    = (this.Depth > 0) ? mom_mTable.CreateInstance(mom_m_sObject, mom_m_cObject, mom_m_moObject) : null;
                MOMessage      momObject      = momTable.CreateInstance(mom_mObject);
                sqlReader.Close();

                return(momObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "loadinternal", "exception"), "MOMessage 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, "MOMessage", "Exception while loading MOMessage object from database. See inner exception for details.", ex);
            }
        }
        protected override TranslationValue 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 " +
                             TranslationValueTable.GetColumnNames("[tv]") +
                             (this.Depth > 0 ? "," + TranslationKeyTable.GetColumnNames("[tv_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationKeyTable.GetColumnNames("[tv_tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTable.GetColumnNames("[tv_tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tv_tk_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[tv_tk_s]") : string.Empty) +
                             (this.Depth > 0 ? "," + TranslationGroupKeyTable.GetColumnNames("[tv_tgk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationGroupTable.GetColumnNames("[tv_tgk_tg]") : string.Empty) +
                             " FROM [core].[TranslationValue] AS [tv] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationKey] AS [tv_tk] ON [tv].[TranslationKeyID] = [tv_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tv_tk_tk] ON [tv_tk].[FallbackTranslationKeyID] = [tv_tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Translation] AS [tv_tk_t] ON [tv_tk].[TranslationID] = [tv_tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tv_tk_l] ON [tv_tk].[LanguageID] = [tv_tk_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tv_tk_s] ON [tv_tk].[ServiceID] = [tv_tk_s].[ServiceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationGroupKey] AS [tv_tgk] ON [tv].[TranslationGroupKeyID] = [tv_tgk].[TranslationGroupKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationGroup] AS [tv_tgk_tg] ON [tv_tgk].[TranslationGroupID] = [tv_tgk_tg].[TranslationGroupID] ";
                }
                sqlCmdText += "WHERE [tv].[TranslationValueID] = @TranslationValueID;";

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

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tv", "loadinternal", "notfound"), "TranslationValue 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);

                TranslationValueTable    tvTable        = new TranslationValueTable(query);
                TranslationKeyTable      tv_tkTable     = (this.Depth > 0) ? new TranslationKeyTable(query) : null;
                TranslationKeyTable      tv_tk_tkTable  = (this.Depth > 1) ? new TranslationKeyTable(query) : null;
                TranslationTable         tv_tk_tTable   = (this.Depth > 1) ? new TranslationTable(query) : null;
                LanguageTable            tv_tk_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceTable             tv_tk_sTable   = (this.Depth > 1) ? new ServiceTable(query) : null;
                TranslationGroupKeyTable tv_tgkTable    = (this.Depth > 0) ? new TranslationGroupKeyTable(query) : null;
                TranslationGroupTable    tv_tgk_tgTable = (this.Depth > 1) ? new TranslationGroupTable(query) : null;


                TranslationKey      tv_tk_tkObject  = (this.Depth > 1) ? tv_tk_tkTable.CreateInstance() : null;
                Translation         tv_tk_tObject   = (this.Depth > 1) ? tv_tk_tTable.CreateInstance() : null;
                Language            tv_tk_lObject   = (this.Depth > 1) ? tv_tk_lTable.CreateInstance() : null;
                Service             tv_tk_sObject   = (this.Depth > 1) ? tv_tk_sTable.CreateInstance() : null;
                TranslationKey      tv_tkObject     = (this.Depth > 0) ? tv_tkTable.CreateInstance(tv_tk_tkObject, tv_tk_tObject, tv_tk_lObject, tv_tk_sObject) : null;
                TranslationGroup    tv_tgk_tgObject = (this.Depth > 1) ? tv_tgk_tgTable.CreateInstance() : null;
                TranslationGroupKey tv_tgkObject    = (this.Depth > 0) ? tv_tgkTable.CreateInstance(tv_tgk_tgObject) : null;
                TranslationValue    tvObject        = tvTable.CreateInstance(tv_tkObject, tv_tgkObject);
                sqlReader.Close();

                return(tvObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tv", "loadinternal", "exception"), "TranslationValue 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, "TranslationValue", "Exception while loading TranslationValue object from database. See inner exception for details.", ex);
            }
        }
        public List <TranslationValue> 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} " +
                             TranslationValueTable.GetColumnNames("[tv]") +
                             (this.Depth > 0 ? "," + TranslationKeyTable.GetColumnNames("[tv_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationKeyTable.GetColumnNames("[tv_tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTable.GetColumnNames("[tv_tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tv_tk_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[tv_tk_s]") : string.Empty) +
                             (this.Depth > 0 ? "," + TranslationGroupKeyTable.GetColumnNames("[tv_tgk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationGroupTable.GetColumnNames("[tv_tgk_tg]") : string.Empty) +
                             " FROM [core].[TranslationValue] AS [tv] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationKey] AS [tv_tk] ON [tv].[TranslationKeyID] = [tv_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tv_tk_tk] ON [tv_tk].[FallbackTranslationKeyID] = [tv_tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Translation] AS [tv_tk_t] ON [tv_tk].[TranslationID] = [tv_tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tv_tk_l] ON [tv_tk].[LanguageID] = [tv_tk_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tv_tk_s] ON [tv_tk].[ServiceID] = [tv_tk_s].[ServiceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationGroupKey] AS [tv_tgk] ON [tv].[TranslationGroupKeyID] = [tv_tgk].[TranslationGroupKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationGroup] AS [tv_tgk_tg] ON [tv_tgk].[TranslationGroupID] = [tv_tgk_tg].[TranslationGroupID] ";
                }


                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("tv", "customloadmany", "notfound"), "TranslationValue 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 <TranslationValue>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                TranslationValueTable    tvTable        = new TranslationValueTable(query);
                TranslationKeyTable      tv_tkTable     = (this.Depth > 0) ? new TranslationKeyTable(query) : null;
                TranslationKeyTable      tv_tk_tkTable  = (this.Depth > 1) ? new TranslationKeyTable(query) : null;
                TranslationTable         tv_tk_tTable   = (this.Depth > 1) ? new TranslationTable(query) : null;
                LanguageTable            tv_tk_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceTable             tv_tk_sTable   = (this.Depth > 1) ? new ServiceTable(query) : null;
                TranslationGroupKeyTable tv_tgkTable    = (this.Depth > 0) ? new TranslationGroupKeyTable(query) : null;
                TranslationGroupTable    tv_tgk_tgTable = (this.Depth > 1) ? new TranslationGroupTable(query) : null;

                List <TranslationValue> result = new List <TranslationValue>();
                do
                {
                    TranslationKey      tv_tk_tkObject  = (this.Depth > 1) ? tv_tk_tkTable.CreateInstance() : null;
                    Translation         tv_tk_tObject   = (this.Depth > 1) ? tv_tk_tTable.CreateInstance() : null;
                    Language            tv_tk_lObject   = (this.Depth > 1) ? tv_tk_lTable.CreateInstance() : null;
                    Service             tv_tk_sObject   = (this.Depth > 1) ? tv_tk_sTable.CreateInstance() : null;
                    TranslationKey      tv_tkObject     = (this.Depth > 0) ? tv_tkTable.CreateInstance(tv_tk_tkObject, tv_tk_tObject, tv_tk_lObject, tv_tk_sObject) : null;
                    TranslationGroup    tv_tgk_tgObject = (this.Depth > 1) ? tv_tgk_tgTable.CreateInstance() : null;
                    TranslationGroupKey tv_tgkObject    = (this.Depth > 0) ? tv_tgkTable.CreateInstance(tv_tgk_tgObject) : null;
                    TranslationValue    tvObject        = (this.Depth > -1) ? tvTable.CreateInstance(tv_tkObject, tv_tgkObject) : null;
                    result.Add(tvObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tv", "customloadmany", "exception"), "TranslationValue 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, "TranslationValue", "Exception while loading (custom/many) TranslationValue object from database. See inner exception for details.", ex);
            }
        }
Beispiel #23
0
        protected override Customer 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 " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_mo_c].[CountryID] ";
                }
                sqlCmdText += "WHERE [c].[CustomerID] = @CustomerID;";

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

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "notfound"), "Customer 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);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;


                UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                Customer             cObject       = cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject);
                sqlReader.Close();

                return(cObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "exception"), "Customer 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, "Customer", "Exception while loading Customer object from database. See inner exception for details.", ex);
            }
        }
Beispiel #24
0
        public List <Customer> 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} " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_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("c", "customloadmany", "notfound"), "Customer 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 <Customer>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;

                List <Customer> result = new List <Customer>();
                do
                {
                    UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                    User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                    Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                    Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                    Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                    ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                    UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                    Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                    Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                    ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                    Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                    Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                    Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                    Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                    Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                    Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                    MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                    Customer             cObject       = (this.Depth > -1) ? cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject) : null;
                    result.Add(cObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "customloadmany", "exception"), "Customer 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, "Customer", "Exception while loading (custom/many) Customer object from database. See inner exception for details.", ex);
            }
        }
        public TranslationKey Load(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} " +
                             TranslationKeyTable.GetColumnNames("[tk]") +
                             (this.Depth > 0 ? "," + TranslationKeyTable.GetColumnNames("[tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationKeyTable.GetColumnNames("[tk_tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTable.GetColumnNames("[tk_tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tk_tk_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[tk_tk_s]") : string.Empty) +
                             (this.Depth > 0 ? "," + TranslationTable.GetColumnNames("[tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTypeTable.GetColumnNames("[tk_t_tt]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[tk_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[tk_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[tk_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[tk_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[tk_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[tk_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[tk_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[tk_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tk_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[tk_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[tk_s_t]") : string.Empty) +
                             " FROM [core].[TranslationKey] AS [tk] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tk_tk] ON [tk].[FallbackTranslationKeyID] = [tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tk_tk_tk] ON [tk_tk].[FallbackTranslationKeyID] = [tk_tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Translation] AS [tk_tk_t] ON [tk_tk].[TranslationID] = [tk_tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_tk_l] ON [tk_tk].[LanguageID] = [tk_tk_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tk_tk_s] ON [tk_tk].[ServiceID] = [tk_tk_s].[ServiceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Translation] AS [tk_t] ON [tk].[TranslationID] = [tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationType] AS [tk_t_tt] ON [tk_t].[TranslationTypeID] = [tk_t_tt].[TranslationTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_l] ON [tk].[LanguageID] = [tk_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tk_s] ON [tk].[ServiceID] = [tk_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Application] AS [tk_s_a] ON [tk_s].[ApplicationID] = [tk_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Product] AS [tk_s_p] ON [tk_s].[ProductID] = [tk_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Merchant] AS [tk_s_m] ON [tk_s].[MerchantID] = [tk_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceType] AS [tk_s_st] ON [tk_s].[ServiceTypeID] = [tk_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserSessionType] AS [tk_s_ust] ON [tk_s].[UserSessionTypeID] = [tk_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [tk_s_c] ON [tk_s].[FallbackCountryID] = [tk_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_s_l] ON [tk_s].[FallbackLanguageID] = [tk_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceConfiguration] AS [tk_s_sc] ON [tk_s].[ServiceConfigurationID] = [tk_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Template] AS [tk_s_t] ON [tk_s].[TemplateID] = [tk_s_t].[TemplateID] ";
                }


                parameters.Top = 1;
                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("tk", "customload", "notfound"), "TranslationKey could not be loaded using custom logic as it was not found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                TranslationKeyTable       tkTable       = new TranslationKeyTable(query);
                TranslationKeyTable       tk_tkTable    = (this.Depth > 0) ? new TranslationKeyTable(query) : null;
                TranslationKeyTable       tk_tk_tkTable = (this.Depth > 1) ? new TranslationKeyTable(query) : null;
                TranslationTable          tk_tk_tTable  = (this.Depth > 1) ? new TranslationTable(query) : null;
                LanguageTable             tk_tk_lTable  = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceTable              tk_tk_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                TranslationTable          tk_tTable     = (this.Depth > 0) ? new TranslationTable(query) : null;
                TranslationTypeTable      tk_t_ttTable  = (this.Depth > 1) ? new TranslationTypeTable(query) : null;
                LanguageTable             tk_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                ServiceTable              tk_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          tk_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              tk_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             tk_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          tk_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      tk_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              tk_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             tk_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable tk_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             tk_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;


                TranslationKey       tk_tk_tkObject = (this.Depth > 1) ? tk_tk_tkTable.CreateInstance() : null;
                Translation          tk_tk_tObject  = (this.Depth > 1) ? tk_tk_tTable.CreateInstance() : null;
                Language             tk_tk_lObject  = (this.Depth > 1) ? tk_tk_lTable.CreateInstance() : null;
                Service              tk_tk_sObject  = (this.Depth > 1) ? tk_tk_sTable.CreateInstance() : null;
                TranslationKey       tk_tkObject    = (this.Depth > 0) ? tk_tkTable.CreateInstance(tk_tk_tkObject, tk_tk_tObject, tk_tk_lObject, tk_tk_sObject) : null;
                TranslationType      tk_t_ttObject  = (this.Depth > 1) ? tk_t_ttTable.CreateInstance() : null;
                Translation          tk_tObject     = (this.Depth > 0) ? tk_tTable.CreateInstance(tk_t_ttObject) : null;
                Language             tk_lObject     = (this.Depth > 0) ? tk_lTable.CreateInstance() : null;
                Application          tk_s_aObject   = (this.Depth > 1) ? tk_s_aTable.CreateInstance() : null;
                Product              tk_s_pObject   = (this.Depth > 1) ? tk_s_pTable.CreateInstance() : null;
                Merchant             tk_s_mObject   = (this.Depth > 1) ? tk_s_mTable.CreateInstance() : null;
                ServiceType          tk_s_stObject  = (this.Depth > 1) ? tk_s_stTable.CreateInstance() : null;
                UserSessionType      tk_s_ustObject = (this.Depth > 1) ? tk_s_ustTable.CreateInstance() : null;
                Country              tk_s_cObject   = (this.Depth > 1) ? tk_s_cTable.CreateInstance() : null;
                Language             tk_s_lObject   = (this.Depth > 1) ? tk_s_lTable.CreateInstance() : null;
                ServiceConfiguration tk_s_scObject  = (this.Depth > 1) ? tk_s_scTable.CreateInstance() : null;
                Template             tk_s_tObject   = (this.Depth > 1) ? tk_s_tTable.CreateInstance() : null;
                Service              tk_sObject     = (this.Depth > 0) ? tk_sTable.CreateInstance(tk_s_aObject, tk_s_pObject, tk_s_mObject, tk_s_stObject, tk_s_ustObject, tk_s_cObject, tk_s_lObject, tk_s_scObject, tk_s_tObject) : null;
                TranslationKey       tkObject       = tkTable.CreateInstance(tk_tkObject, tk_tObject, tk_lObject, tk_sObject);
                sqlReader.Close();

                return(tkObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tk", "customload", "exception"), "TranslationKey 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, "TranslationKey", "Exception while loading (custom/single) TranslationKey object from database. See inner exception for details.", ex);
            }
        }
        protected override ApplicationRouteSetMap 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 " +
                             ApplicationRouteSetMapTable.GetColumnNames("[arsm]") +
                             (this.Depth > 0 ? "," + ApplicationTable.GetColumnNames("[arsm_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + InstanceTable.GetColumnNames("[arsm_a_i]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTypeTable.GetColumnNames("[arsm_a_at]") : string.Empty) +
                             (this.Depth > 1 ? "," + RuntimeTypeTable.GetColumnNames("[arsm_a_rt]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[arsm_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[arsm_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[arsm_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[arsm_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[arsm_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[arsm_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[arsm_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[arsm_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[arsm_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[arsm_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + RouteSetTable.GetColumnNames("[arsm_rs]") : string.Empty) +
                             (this.Depth > 1 ? "," + InstanceTable.GetColumnNames("[arsm_rs_i]") : string.Empty) +
                             " FROM [core].[ApplicationRouteSetMap] AS [arsm] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [arsm_a] ON [arsm].[ApplicationID] = [arsm_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Instance] AS [arsm_a_i] ON [arsm_a].[InstanceID] = [arsm_a_i].[InstanceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ApplicationType] AS [arsm_a_at] ON [arsm_a].[ApplicationTypeID] = [arsm_a_at].[ApplicationTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[RuntimeType] AS [arsm_a_rt] ON [arsm_a].[RuntimeTypeID] = [arsm_a_rt].[RuntimeTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [arsm_s] ON [arsm].[ServiceID] = [arsm_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Application] AS [arsm_s_a] ON [arsm_s].[ApplicationID] = [arsm_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Product] AS [arsm_s_p] ON [arsm_s].[ProductID] = [arsm_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Merchant] AS [arsm_s_m] ON [arsm_s].[MerchantID] = [arsm_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceType] AS [arsm_s_st] ON [arsm_s].[ServiceTypeID] = [arsm_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserSessionType] AS [arsm_s_ust] ON [arsm_s].[UserSessionTypeID] = [arsm_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [arsm_s_c] ON [arsm_s].[FallbackCountryID] = [arsm_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [arsm_s_l] ON [arsm_s].[FallbackLanguageID] = [arsm_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceConfiguration] AS [arsm_s_sc] ON [arsm_s].[ServiceConfigurationID] = [arsm_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Template] AS [arsm_s_t] ON [arsm_s].[TemplateID] = [arsm_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[RouteSet] AS [arsm_rs] ON [arsm].[RouteSetID] = [arsm_rs].[RouteSetID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Instance] AS [arsm_rs_i] ON [arsm_rs].[InstanceID] = [arsm_rs_i].[InstanceID] ";
                }
                sqlCmdText += "WHERE [arsm].[ApplicationRouteSetMapID] = @ApplicationRouteSetMapID;";

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

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("arsm", "loadinternal", "notfound"), "ApplicationRouteSetMap 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);

                ApplicationRouteSetMapTable arsmTable     = new ApplicationRouteSetMapTable(query);
                ApplicationTable            arsm_aTable   = (this.Depth > 0) ? new ApplicationTable(query) : null;
                InstanceTable             arsm_a_iTable   = (this.Depth > 1) ? new InstanceTable(query) : null;
                ApplicationTypeTable      arsm_a_atTable  = (this.Depth > 1) ? new ApplicationTypeTable(query) : null;
                RuntimeTypeTable          arsm_a_rtTable  = (this.Depth > 1) ? new RuntimeTypeTable(query) : null;
                ServiceTable              arsm_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          arsm_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              arsm_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             arsm_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          arsm_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      arsm_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              arsm_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             arsm_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable arsm_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             arsm_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                RouteSetTable             arsm_rsTable    = (this.Depth > 0) ? new RouteSetTable(query) : null;
                InstanceTable             arsm_rs_iTable  = (this.Depth > 1) ? new InstanceTable(query) : null;


                Instance               arsm_a_iObject   = (this.Depth > 1) ? arsm_a_iTable.CreateInstance() : null;
                ApplicationType        arsm_a_atObject  = (this.Depth > 1) ? arsm_a_atTable.CreateInstance() : null;
                RuntimeType            arsm_a_rtObject  = (this.Depth > 1) ? arsm_a_rtTable.CreateInstance() : null;
                Application            arsm_aObject     = (this.Depth > 0) ? arsm_aTable.CreateInstance(arsm_a_iObject, arsm_a_atObject, arsm_a_rtObject) : null;
                Application            arsm_s_aObject   = (this.Depth > 1) ? arsm_s_aTable.CreateInstance() : null;
                Product                arsm_s_pObject   = (this.Depth > 1) ? arsm_s_pTable.CreateInstance() : null;
                Merchant               arsm_s_mObject   = (this.Depth > 1) ? arsm_s_mTable.CreateInstance() : null;
                ServiceType            arsm_s_stObject  = (this.Depth > 1) ? arsm_s_stTable.CreateInstance() : null;
                UserSessionType        arsm_s_ustObject = (this.Depth > 1) ? arsm_s_ustTable.CreateInstance() : null;
                Country                arsm_s_cObject   = (this.Depth > 1) ? arsm_s_cTable.CreateInstance() : null;
                Language               arsm_s_lObject   = (this.Depth > 1) ? arsm_s_lTable.CreateInstance() : null;
                ServiceConfiguration   arsm_s_scObject  = (this.Depth > 1) ? arsm_s_scTable.CreateInstance() : null;
                Template               arsm_s_tObject   = (this.Depth > 1) ? arsm_s_tTable.CreateInstance() : null;
                Service                arsm_sObject     = (this.Depth > 0) ? arsm_sTable.CreateInstance(arsm_s_aObject, arsm_s_pObject, arsm_s_mObject, arsm_s_stObject, arsm_s_ustObject, arsm_s_cObject, arsm_s_lObject, arsm_s_scObject, arsm_s_tObject) : null;
                Instance               arsm_rs_iObject  = (this.Depth > 1) ? arsm_rs_iTable.CreateInstance() : null;
                RouteSet               arsm_rsObject    = (this.Depth > 0) ? arsm_rsTable.CreateInstance(arsm_rs_iObject) : null;
                ApplicationRouteSetMap arsmObject       = arsmTable.CreateInstance(arsm_aObject, arsm_sObject, arsm_rsObject);
                sqlReader.Close();

                return(arsmObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("arsm", "loadinternal", "exception"), "ApplicationRouteSetMap 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, "ApplicationRouteSetMap", "Exception while loading ApplicationRouteSetMap object from database. See inner exception for details.", ex);
            }
        }
 // This constructor is called exclusively to create a child scope from the parent
 internal ServiceProvider(ServiceProvider parent)
 {
     _root  = parent._root;
     _table = parent._table;
 }
Beispiel #28
0
 public PoloRegistry()
 {
     Services = new ServiceTable();
 }
        protected override ShortMessageRequest 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 " +
                             ShortMessageRequestTable.GetColumnNames("[smr]") +
                             (this.Depth > 0 ? "," + ShortMessageTable.GetColumnNames("[smr_sm]") : string.Empty) +
                             (this.Depth > 1 ? "," + ActionContextTable.GetColumnNames("[smr_sm_ac]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[smr_sm_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[smr_sm_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[smr_sm_c]") : string.Empty) +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[smr_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[smr_u_ut]") : string.Empty) +
                             " FROM [core].[ShortMessageRequest] AS [smr] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[ShortMessage] AS [smr_sm] ON [smr].[ShortMessageID] = [smr_sm].[ShortMessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ActionContext] AS [smr_sm_ac] ON [smr_sm].[ActionContextID] = [smr_sm_ac].[ActionContextID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [smr_sm_s] ON [smr_sm].[ServiceID] = [smr_sm_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [smr_sm_mo] ON [smr_sm].[MobileOperatorID] = [smr_sm_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Customer] AS [smr_sm_c] ON [smr_sm].[CustomerID] = [smr_sm_c].[CustomerID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[User] AS [smr_u] ON [smr].[UserID] = [smr_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserType] AS [smr_u_ut] ON [smr_u].[UserTypeID] = [smr_u_ut].[UserTypeID] ";
                }
                sqlCmdText += "WHERE [smr].[ShortMessageRequestID] = @ShortMessageRequestID;";

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

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("smr", "loadinternal", "notfound"), "ShortMessageRequest 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);

                ShortMessageRequestTable smrTable       = new ShortMessageRequestTable(query);
                ShortMessageTable        smr_smTable    = (this.Depth > 0) ? new ShortMessageTable(query) : null;
                ActionContextTable       smr_sm_acTable = (this.Depth > 1) ? new ActionContextTable(query) : null;
                ServiceTable             smr_sm_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                MobileOperatorTable      smr_sm_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                CustomerTable            smr_sm_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                UserTable     smr_uTable    = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable smr_u_utTable = (this.Depth > 1) ? new UserTypeTable(query) : null;


                ActionContext       smr_sm_acObject = (this.Depth > 1) ? smr_sm_acTable.CreateInstance() : null;
                Service             smr_sm_sObject  = (this.Depth > 1) ? smr_sm_sTable.CreateInstance() : null;
                MobileOperator      smr_sm_moObject = (this.Depth > 1) ? smr_sm_moTable.CreateInstance() : null;
                Customer            smr_sm_cObject  = (this.Depth > 1) ? smr_sm_cTable.CreateInstance() : null;
                ShortMessage        smr_smObject    = (this.Depth > 0) ? smr_smTable.CreateInstance(smr_sm_acObject, smr_sm_sObject, smr_sm_moObject, smr_sm_cObject) : null;
                UserType            smr_u_utObject  = (this.Depth > 1) ? smr_u_utTable.CreateInstance() : null;
                User                smr_uObject     = (this.Depth > 0) ? smr_uTable.CreateInstance(smr_u_utObject) : null;
                ShortMessageRequest smrObject       = smrTable.CreateInstance(smr_smObject, smr_uObject);
                sqlReader.Close();

                return(smrObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("smr", "loadinternal", "exception"), "ShortMessageRequest 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, "ShortMessageRequest", "Exception while loading ShortMessageRequest object from database. See inner exception for details.", ex);
            }
        }
 public ServiceTableWindow(ServiceTable selectedServiceTable)
 {
     InitializeComponent();
     this.DataContext = new ServiceTableViewModel(this, selectedServiceTable);
 }
 // This constructor is called exclusively to create a child scope from the parent
 internal ServiceProvider(ServiceProvider parent)
 {
     Root               = parent.Root;
     _table             = parent._table;
     _callSiteValidator = parent._callSiteValidator;
 }