public bool Delete <T>(DeleteConfig config, object deleteObject) { Type type = typeof(T); PropertyInfo[] properties = type.GetProperties(); CommandParameter[] parameters = BuildCommandParameters(deleteObject, properties); DbCommand dbCommand = BuildCommand(config, parameters); bool pass = true; if (dbTransaction == null) { try { db.ExecuteNonQuery(dbCommand); } catch (Exception ex) { LogHelper.Warn("BlueFramework.Blood.DataAccess.Command.Delete<T> :", ex); pass = false; } } else { db.ExecuteNonQuery(dbCommand, dbTransaction); } return(pass); }
//FIXME Лучше в будущем разделить тест на разные. Сейчас было лень переписывать код. public virtual void NHMappedCollectionsAllInOneTest(PersistentClass mapping, Property prop) { var collectionMap = (prop.Value as Bag); Type collectionItemType = null; if (collectionMap.Element is OneToMany) { collectionItemType = (collectionMap.Element as OneToMany).AssociatedClass.MappedClass; } else if (collectionMap.Element is ManyToOne) { collectionItemType = (collectionMap.Element as ManyToOne).Type.ReturnedClass; } var collectionItemClassInfo = DeleteConfig.GetDeleteRule(collectionItemType); Assert.That(collectionItemClassInfo, Is.Not.Null, "Класс {0} не имеет правил удаления, но используется в коллекции {1}.{2}.", collectionItemType, mapping.MappedClass.Name, prop.Name); var info = DeleteConfig.GetDeleteRule(mapping.MappedClass); Assert.That(info, Is.Not.Null, "Коллекция {0}.{1} объектов {2} замаплена в ненастроенном классе.", mapping.MappedClass.Name, prop.Name, collectionItemType.Name); if (collectionMap.IsOneToMany) { var deleteDepend = info.DeleteItems.Find(r => r.ObjectClass == collectionItemType && r.CollectionName == prop.Name); Assert.That(deleteDepend, Is.Not.Null, "Для коллекции {0}.{1} не определены зависимости удаления класса {2}", mapping.MappedClass.Name, prop.Name, collectionItemType.Name ); } else { var removeDepend = collectionItemClassInfo.RemoveFromItems.Find(r => r.ObjectClass == info.ObjectClass && r.CollectionName == prop.Name); Assert.That(removeDepend, Is.Not.Null, "Для коллекции {0}.{1} не определены зависимости удаления элементов при удалении класса {2}", mapping.MappedClass.Name, prop.Name, collectionItemType.Name ); } if (collectionItemClassInfo is IHibernateDeleteRule) { Assert.That(info, Is.InstanceOf <IHibernateDeleteRule>(), "Удаление через Hibernate элементов коллекции {0}.{1}, поддерживается только если удаление родительского класса {0} настроено тоже через Hibernate", mapping.MappedClass.Name, prop.Name ); } }
internal static int Delete(DeleteConfig !config) { if (config.servers == null) { Console.WriteLine("no servers given"); return(-1); } DNSContract.Imp dnsConn = ((!)config.dnsRef).Acquire(); if (dnsConn == null) { Console.WriteLine("Could not initialize DNS endpoint."); return(1); } dnsConn.RecvReady(); for (int i = 0; i < config.servers.Length; i++) { IPv4 resolver; if (IPv4.Parse(config.servers[i], out resolver) == false) { Console.WriteLine("Invalid IP address: {0}", config.servers[i]); } dnsConn.SendRemoveNameServer((uint)resolver); dnsConn.RecvAck(); } delete dnsConn; return(0); }
internal static int Delete(DeleteConfig !config) { RoutingContract.Imp routeConn = ((!)config.routingRef).Acquire(); if (routeConn == null) { Console.WriteLine("Could not initialize routing endpoint."); return(1); } routeConn.RecvReady(); IPv4Network destination; if (IPv4Network.Parse(config.destination, out destination) == false) { Console.WriteLine("Could not parse destination address."); } Network destNet = ChannelUtils.NetworkToChannelNetwork(destination); routeConn.SendFindSpecificNetRoute(destNet); switch receive { case routeConn.NoRouteFound(): Console.WriteLine("No route for destination."); delete routeConn; return(-1); case routeConn.Route(RouteEntry r): // Do nothing; success. break; case routeConn.ChannelClosed(): Console.WriteLine("routeConn channel closed."); throw new Exception("routeConn channel closed."); } routeConn.SendDeleteRoute(destNet); switch receive { case routeConn.NoRouteFound(): Console.WriteLine("Unexpected error attempting to delete the route"); break; case routeConn.OK(): Console.WriteLine("Route successfully deleted"); break; case routeConn.ChannelClosed(): Console.WriteLine("routeConn channel closed"); throw new Exception("routeConn channel closed"); } delete routeConn; return(0); }
/// <summary> /// Display a delete dialog. /// </summary> /// <param name="config">The dialog configuration.</param> public virtual IDisposable Delete(DeleteConfig config) { // If available, call the delegate to see if presenting this dialog is allowed. if (MessagingServiceCore.Delegate == null || MessagingServiceCore.Delegate.OnDeleteRequested(config)) { return(PresentDelete(config)); } return(null); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления в модуле Banks..."); DeleteConfig.AddHibernateDeleteInfo <BankRegion>() .AddDeleteDependence <Bank>(item => item.Region); DeleteConfig.AddHibernateDeleteInfo <Bank>() .AddDeleteDependence <Account>(item => item.InBank); DeleteConfig.AddHibernateDeleteInfo <Account>(); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления в модуле Contacts..."); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(PhoneType), SqlSelect = "SELECT id, name FROM @tablename ", DisplayString = "Тип телефона {1}", DeleteItems = new List <DeleteDependenceInfo> { DeleteDependenceInfo.Create <Phone> (item => item.NumberType) } }.FillFromMetaInfo() ); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(Phone), SqlSelect = "SELECT id, number, additional FROM @tablename ", DisplayString = "Телефон {1} доб. {2}" }.FillFromMetaInfo() ); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(EmailType), SqlSelect = "SELECT id, name FROM @tablename ", DisplayString = "Тип E-mail {1}", DeleteItems = new List <DeleteDependenceInfo> { DeleteDependenceInfo.Create <Email> (item => item.EmailType) } }.FillFromMetaInfo() ); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(Email), SqlSelect = "SELECT id, address FROM @tablename ", DisplayString = "{1}" }.FillFromMetaInfo() ); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(Person), SqlSelect = "SELECT id, surname, name FROM @tablename ", DisplayString = "{1} {2}" }.FillFromMetaInfo() ); DeleteConfig.AddDeleteInfo(new DeleteInfo { ObjectClass = typeof(Post), SqlSelect = "SELECT id, name FROM @tablename ", DisplayString = "{1}" }.FillFromMetaInfo() ); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления..."); DeleteConfig.AddHibernateDeleteInfo <AttachedFile>(); DeleteConfig.AddHibernateDeleteInfo <BodyMaterial>() .AddDeleteDependence <Fitting>(x => x.BodyMaterial); DeleteConfig.AddHibernateDeleteInfo <Conductor>() .AddDeleteDependence <ProjectItem>(x => x.Conductor); DeleteConfig.AddHibernateDeleteInfo <ConnectionType>() .AddDeleteDependence <Fitting>(x => x.ConnectionType); DeleteConfig.AddHibernateDeleteInfo <Diameter>() .AddDeleteDependence <Fitting>(x => x.Diameter); DeleteConfig.AddHibernateDeleteInfo <Fitting>() .AddDeleteDependence <AttachedFile>(x => x.Fitting) .AddDeleteDependence <ProjectItem>(x => x.Fitting) .AddDeleteDependence <PriceItem>(x => x.Fitting); DeleteConfig.AddHibernateDeleteInfo <FittingType>() .AddDeleteDependence <Fitting>(x => x.Name); DeleteConfig.AddHibernateDeleteInfo <Pressure>() .AddDeleteDependence <Fitting>(x => x.Pressure); DeleteConfig.AddHibernateDeleteInfo <PriceItem>() .AddClearDependence <ProjectItem>(x => x.SelectedPriceItem); DeleteConfig.AddHibernateDeleteInfo <Price>() .AddDeleteDependence <PriceItem>(x => x.Price); DeleteConfig.AddHibernateDeleteInfo <ProjectItem>(); DeleteConfig.AddHibernateDeleteInfo <Project>() .AddDeleteDependence <ProjectItem>(x => x.Project); DeleteConfig.AddHibernateDeleteInfo <Provider>() .AddDeleteDependence <Price>(x => x.Provider); DeleteConfig.AddHibernateDeleteInfo <User>(); //Для тетирования #if DEBUG DeleteConfig.DeletionCheck(); #endif logger.Info("Ок"); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления в модуле Banks..."); DeleteConfig.AddHibernateDeleteInfo <BankRegion>() .AddDeleteDependence <Bank>(item => item.Region); DeleteConfig.AddHibernateDeleteInfo <Bank>() .AddDeleteDependence <Account>(item => item.InBank) .AddDeleteDependenceFromCollection(item => item.CorAccounts); DeleteConfig.AddHibernateDeleteInfo <Account>() .AddClearDependence <Bank>(item => item.DefaultCorAccount); }
/// <summary> /// Тест наличия каскадной зависимости для ссылок на другие сущьности в класе. /// </summary> public virtual void CascadeDependenceRuleExisitForNHMappedEntityRelationTest(PersistentClass mapping, Property prop, IDeleteRule related) { if (IgnoreProperties.ContainsKey(mapping.MappedClass) && IgnoreProperties[mapping.MappedClass].Any(x => x.PropertyName == prop.Name)) { Assert.Ignore(IgnoreProperties[mapping.MappedClass].First(x => x.PropertyName == prop.Name).ReasonForIgnoring); } var info = DeleteConfig.GetDeleteRule(mapping.MappedClass); Assert.That(info.DeleteItems.Any(x => x.ParentPropertyName == prop.Name && x.IsCascade), "Cвойство {0}.{1} не имеет каскадного правила удаления, хотя класс {2} помечен как требующий каскадного удаления.", info.ObjectClass.Name, prop.Name, related.ObjectClass.Name); }
public bool Delete(DeleteConfig config, object objectId) { DbCommand dbCommand = BuildCommand(config, objectId); bool pass = true; if (dbTransaction == null) { try { db.ExecuteNonQuery(dbCommand); } catch (Exception ex) { LogHelper.Warn("BlueFramework.Blood.DataAccess.Command.Delete :", ex); pass = false; } } else { db.ExecuteNonQuery(dbCommand, dbTransaction); } return(pass); }
public void TransactionTest() { InsertConfig config = new InsertConfig { Id = "test.insertUser", Sql = "insert into [user](username,birthday,address) values(#{UserName},#{Birthday},#{Address})", KeyProperty = "UserId", KeyMadeOrder = IdentityMadeOrder.Inserting, KeyPropertySql = "select @UserId=@@IDENTITY" }; UpdateConfig updateConfig = new UpdateConfig { Id = "test.insertUser", Sql = "update [user] set username=#{UserName} where id=#{UserId}", }; DeleteConfig deleteConfig = new DeleteConfig { Id = "test.deleteUser", Sql = "delete from [user] where id=#{value}", }; int insertCount = 0; int beginId = 0; using (var command = new Command()) { try { command.BeginTransaction(); for (int i = 0; i < 10; i++) { UserInfo userInfo = new UserInfo() { UserId = 0, UserName = "******" + i.ToString(), Birthday = DateTime.Now }; UserInfo o = command.Insert <UserInfo>(config, userInfo); insertCount++; if (o != null && i == 0) { beginId = o.UserId; } } for (int i = 0; i < 5; i++) { UserInfo userInfo = new UserInfo() { UserId = i + 50, UserName = "******" + i.ToString(), Birthday = DateTime.Now }; command.Update <UserInfo>(updateConfig, userInfo); } for (int i = beginId; i <= beginId + 5; i++) { command.Delete(deleteConfig, i); } command.CommitTransaction(); } catch (Exception ex) { command.RollbackTransaction(); } } Assert.AreEqual(insertCount, 10); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления..."); #region Связь DeleteConfig.AddHibernateDeleteInfo <MessageTemplate>(); #endregion #region Организация DeleteConfig.AddHibernateDeleteInfo <Department>() .AddClearDependence <EmployeeCard>(x => x.Department) .AddClearDependence <Post>(x => x.Department); DeleteConfig.AddHibernateDeleteInfo <EmployeeCard>() .AddDeleteDependence <EmployeeCardItem>(x => x.EmployeeCard) .AddDeleteDependence <EmployeeVacation>(x => x.Employee) .AddDeleteDependence <Expense>(x => x.Employee) .AddDeleteDependence <CollectiveExpenseItem>(x => x.Employee) .AddDeleteDependence <Income>(x => x.EmployeeCard) .AddDeleteDependence <EmployeeIssueOperation>(x => x.Employee) .AddDeleteDependence <EmployeeSize>(x => x.Employee) .AddDeleteDependence <IssuanceSheetItem>(x => x.Employee) .AddClearDependence <Leader>(x => x.Employee); DeleteConfig.AddHibernateDeleteInfo <EmployeeCardItem>(); DeleteConfig.AddHibernateDeleteInfo <EmployeeVacation>(); DeleteConfig.AddHibernateDeleteInfo <Leader>() .AddClearDependence <EmployeeCard>(x => x.Leader) .AddClearDependence <IssuanceSheet>(x => x.HeadOfDivisionPerson) .AddClearDependence <IssuanceSheet>(x => x.ResponsiblePerson) .AddClearDependence <UserSettings>(x => x.DefaultResponsiblePerson) .AddClearDependence <UserSettings>(x => x.DefaultLeader); DeleteConfig.AddHibernateDeleteInfo <Organization>() .AddClearDependence <IssuanceSheet>(x => x.Organization) .AddClearDependence <UserSettings>(x => x.DefaultOrganization); DeleteConfig.AddHibernateDeleteInfo <Post>() .AddRemoveFromDependence <Norm>(x => x.Posts) .AddClearDependence <EmployeeCard>(x => x.Post); DeleteConfig.AddHibernateDeleteInfo <Subdivision>() .AddDeleteDependence <Department>(x => x.Subdivision) .AddDeleteDependence <SubdivisionPlace>(x => x.Subdivision) .AddDeleteDependence <Expense>(x => x.Subdivision) .AddDeleteDependence <Income>(x => x.Subdivision) .AddDeleteDependence <SubdivisionIssueOperation>(x => x.Subdivision) .AddClearDependence <EmployeeCard>(x => x.Subdivision) .AddClearDependence <Post>(x => x.Subdivision) .AddClearDependence <IssuanceSheet>(x => x.Subdivision) .AddClearDependence <Subdivision>(x => x.ParentSubdivision); DeleteConfig.AddHibernateDeleteInfo <SubdivisionPlace>() .AddClearDependence <ExpenseItem>(x => x.SubdivisionPlace) .AddClearDependence <SubdivisionIssueOperation>(x => x.SubdivisionPlace); DeleteConfig.AddHibernateDeleteInfo <VacationType>() .AddDeleteDependence <EmployeeVacation>(x => x.VacationType); #endregion #region Нормы выдачи DeleteConfig.AddHibernateDeleteInfo <Norm>() .AddRemoveFromDependence <EmployeeCard>(x => x.UsedNorms, x => x.RemoveUsedNorm) .AddDeleteDependence <NormItem>(x => x.Norm); DeleteConfig.AddHibernateDeleteInfo <NormItem>() .AddClearDependence <EmployeeIssueOperation>(x => x.NormItem) //Ну нужна так как должна удалятся через пересчет. .AddClearDependence<EmployeeCardItem> (x => x.ActiveNormItem) //FIXME После этого нужно пересчитать требования к выдаче, то новому списку норм. ; DeleteConfig.AddHibernateDeleteInfo <NormCondition>() .AddClearDependence <NormItem>(x => x.NormCondition); DeleteConfig.AddHibernateDeleteInfo <Profession>() .AddClearDependence <Post>(x => x.Profession); DeleteConfig.AddHibernateDeleteInfo <ProtectionTools>() .AddDeleteDependence <EmployeeCardItem>(x => x.ProtectionTools) .AddDeleteDependence <NormItem>(x => x.ProtectionTools) .AddDeleteDependence <IssuanceSheetItem>(x => x.ProtectionTools) .AddClearDependence <ExpenseItem>(x => x.ProtectionTools) .AddClearDependence <CollectiveExpenseItem>(x => x.ProtectionTools) .AddClearDependence <EmployeeIssueOperation>(x => x.ProtectionTools); DeleteConfig.AddHibernateDeleteInfo <RegulationDoc>() .AddDeleteDependence <Norm>(x => x.Document) .AddDeleteDependence <RegulationDocAnnex>(x => x.Document); DeleteConfig.AddHibernateDeleteInfo <RegulationDocAnnex>() .AddClearDependence <Norm>(x => x.Annex); #endregion #region Склад DeleteConfig.AddHibernateDeleteInfo <Warehouse>() .AddDeleteDependence <Income>(x => x.Warehouse) .AddDeleteDependence <Expense>(x => x.Warehouse) .AddDeleteDependence <CollectiveExpense>(x => x.Warehouse) .AddDeleteDependence <WriteoffItem>(x => x.Warehouse) .AddDeleteDependence <Transfer>(x => x.WarehouseFrom) .AddDeleteDependence <Transfer>(x => x.WarehouseTo) .AddDeleteDependence <WarehouseOperation>(x => x.ReceiptWarehouse) .AddDeleteDependence <WarehouseOperation>(x => x.ExpenseWarehouse) .AddClearDependence <Subdivision>(x => x.Warehouse) .AddClearDependence <UserSettings>(x => x.DefaultWarehouse) .AddDeleteDependence <Completion>(x => x.ResultWarehouse) .AddDeleteDependence <Completion>(x => x.SourceWarehouse); DeleteConfig.AddHibernateDeleteInfo <MeasurementUnits>() .AddClearDependence <ItemsType>(x => x.Units); DeleteConfig.AddHibernateDeleteInfo <Nomenclature> () .AddDeleteDependence <ExpenseItem> (x => x.Nomenclature) .AddDeleteDependence <CollectiveExpenseItem> (x => x.Nomenclature) .AddDeleteDependence <IncomeItem> (x => x.Nomenclature) .AddDeleteDependence <WriteoffItem> (x => x.Nomenclature) .AddDeleteDependence <TransferItem>(x => x.Nomenclature) .AddDeleteDependence <EmployeeIssueOperation>(x => x.Nomenclature) .AddDeleteDependence <SubdivisionIssueOperation>(x => x.Nomenclature) .AddDeleteDependence <WarehouseOperation>(x => x.Nomenclature) .AddDeleteDependence <IssuanceSheetItem>(x => x.Nomenclature); DeleteConfig.AddHibernateDeleteInfo <Expense> () .AddDeleteDependence <ExpenseItem> (x => x.ExpenseDoc) .AddDeleteDependence <IssuanceSheet>(x => x.Expense); DeleteConfig.AddHibernateDeleteInfo <ExpenseItem> () .AddDeleteDependence <IssuanceSheetItem>(x => x.ExpenseItem) .AddDeleteCascadeDependence(x => x.EmployeeIssueOperation) .AddDeleteCascadeDependence(x => x.SubdivisionIssueOperation) .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <CollectiveExpense>() .AddDeleteDependence <CollectiveExpenseItem>(x => x.Document) .AddDeleteDependence <IssuanceSheet>(x => x.CollectiveExpense); DeleteConfig.AddHibernateDeleteInfo <CollectiveExpenseItem> () .AddDeleteDependence <IssuanceSheetItem>(x => x.CollectiveExpenseItem) .AddDeleteCascadeDependence(x => x.EmployeeIssueOperation) .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <Income> () .AddDeleteDependence <IncomeItem>(x => x.Document); DeleteConfig.AddHibernateDeleteInfo <IncomeItem> () .AddDeleteCascadeDependence(x => x.ReturnFromEmployeeOperation) .AddDeleteCascadeDependence(x => x.ReturnFromSubdivisionOperation) .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <ItemsType>() .AddDeleteDependence <Nomenclature>(x => x.Type) .AddDeleteDependence <ProtectionTools>(x => x.Type); DeleteConfig.AddHibernateDeleteInfo <Writeoff> () .AddDeleteDependence <WriteoffItem>(x => x.Document) .AddClearDependence <Expense>(x => x.WriteOffDoc); DeleteConfig.AddHibernateDeleteInfo <WriteoffItem> () .AddRemoveFromDependence <Writeoff>(x => x.Items) //Необходимо иначе будут исключения при удалении строк выдачи которые создают списание. .AddDeleteCascadeDependence(x => x.EmployeeWriteoffOperation) .AddDeleteCascadeDependence(x => x.SubdivisionWriteoffOperation) .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <Transfer>() .AddDeleteDependence <TransferItem>(x => x.Document); DeleteConfig.AddHibernateDeleteInfo <TransferItem>() .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <Completion>() .AddDeleteDependence <CompletionSourceItem>(x => x.Completion) .AddDeleteDependence <CompletionResultItem>(x => x.Completion); DeleteConfig.AddHibernateDeleteInfo <CompletionSourceItem>() .AddDeleteCascadeDependence(x => x.WarehouseOperation); DeleteConfig.AddHibernateDeleteInfo <CompletionResultItem>() .AddDeleteCascadeDependence(x => x.WarehouseOperation); #endregion #region Statements DeleteConfig.AddHibernateDeleteInfo <IssuanceSheet>() .AddDeleteDependence <IssuanceSheetItem>(x => x.IssuanceSheet); DeleteConfig.AddHibernateDeleteInfo <IssuanceSheetItem>(); #endregion #region Операции DeleteConfig.AddHibernateDeleteInfo <EmployeeIssueOperation>() .RequiredCascadeDeletion() .AddDeleteDependence <EmployeeIssueOperation>(x => x.IssuedOperation) .AddDeleteDependence <ExpenseItem>(x => x.EmployeeIssueOperation) .AddDeleteDependence <CollectiveExpenseItem>(x => x.EmployeeIssueOperation) .AddDeleteDependence <IncomeItem>(x => x.ReturnFromEmployeeOperation) .AddDeleteDependence <WriteoffItem>(x => x.EmployeeWriteoffOperation) .AddDeleteCascadeDependence(x => x.EmployeeOperationIssueOnWriteOff) .AddClearDependence <IssuanceSheetItem>(x => x.IssueOperation) .AddClearDependence <EmployeeIssueOperation>(x => x.EmployeeOperationIssueOnWriteOff); DeleteConfig.AddHibernateDeleteInfo <SubdivisionIssueOperation>() .RequiredCascadeDeletion() .AddDeleteDependence <SubdivisionIssueOperation>(x => x.IssuedOperation) .AddDeleteDependence <ExpenseItem>(x => x.SubdivisionIssueOperation) .AddDeleteDependence <IncomeItem>(x => x.ReturnFromSubdivisionOperation) .AddDeleteDependence <WriteoffItem>(x => x.SubdivisionWriteoffOperation); DeleteConfig.AddHibernateDeleteInfo <WarehouseOperation>() .RequiredCascadeDeletion() .AddDeleteDependence <ExpenseItem>(x => x.WarehouseOperation) .AddDeleteDependence <CollectiveExpenseItem>(x => x.WarehouseOperation) .AddDeleteDependence <IncomeItem>(x => x.WarehouseOperation) .AddDeleteDependence <WriteoffItem>(x => x.WarehouseOperation) .AddDeleteDependence <TransferItem>(x => x.WarehouseOperation) .AddDeleteDependence <EmployeeIssueOperation>(x => x.WarehouseOperation) .AddDeleteDependence <SubdivisionIssueOperation>(x => x.WarehouseOperation) .AddDeleteDependence <CompletionResultItem>(x => x.WarehouseOperation) .AddDeleteDependence <CompletionSourceItem>(x => x.WarehouseOperation); #endregion #region Пользователь DeleteConfig.AddHibernateDeleteInfo <UserBase>() .AddDeleteDependence <UserSettings>(x => x.User) .AddClearDependence <EmployeeCard>(x => x.CreatedbyUser) .AddClearDependence <Writeoff>(x => x.CreatedbyUser) .AddClearDependence <Expense>(x => x.CreatedbyUser) .AddClearDependence <CollectiveExpense>(x => x.CreatedbyUser) .AddClearDependence <Income>(x => x.CreatedbyUser) .AddClearDependence <Transfer>(x => x.CreatedbyUser) .AddClearDependence <Completion>(x => x.CreatedbyUser); DeleteConfig.AddHibernateDeleteInfo <UserSettings>(); #endregion #region азмеры DeleteConfig.AddHibernateDeleteInfo <Size>() .AddClearDependence <CollectiveExpenseItem>(x => x.Height) .AddClearDependence <CollectiveExpenseItem>(x => x.WearSize) .AddClearDependence <EmployeeIssueOperation>(x => x.Height) .AddClearDependence <EmployeeIssueOperation>(x => x.WearSize) .AddClearDependence <ExpenseItem>(x => x.Height) .AddClearDependence <ExpenseItem>(x => x.WearSize) .AddClearDependence <IncomeItem>(x => x.Height) .AddClearDependence <IncomeItem>(x => x.WearSize) .AddClearDependence <IssuanceSheetItem>(x => x.Height) .AddClearDependence <IssuanceSheetItem>(x => x.WearSize) .AddClearDependence <SubdivisionIssueOperation>(x => x.Height) .AddClearDependence <SubdivisionIssueOperation>(x => x.WearSize) .AddClearDependence <WarehouseOperation>(x => x.Height) .AddClearDependence <WarehouseOperation>(x => x.WearSize) .AddClearDependence <WriteoffItem>(x => x.Height) .AddClearDependence <WriteoffItem>(x => x.WearSize) .AddDeleteDependence <EmployeeSize>(x => x.Size); DeleteConfig.AddHibernateDeleteInfo <SizeType>() .AddDeleteDependence <Size>(x => x.SizeType) .AddDeleteDependence <EmployeeSize>(x => x.SizeType) .AddClearDependence <ItemsType>(x => x.SizeType) .AddClearDependence <ItemsType>(x => x.HeightType); DeleteConfig.AddHibernateDeleteInfo <EmployeeSize>(); #endregion logger.Info("Ок"); }
public static void ConfigureDeletion() { logger.Info("Настройка параметров удаления..."); QSContactsMain.ConfigureDeletion(); QSBanksMain.ConfigureDeletion(); DeleteConfig.AddClearDependence <Post> (ClearDependenceInfo.Create <Contact> (item => item.Post)); DeleteConfig.AddClearDependence <Account> (ClearDependenceInfo.Create <Organization> (item => item.DefaultAccount)); DeleteConfig.AddClearDependence <Account> (ClearDependenceInfo.Create <Counterparty> (item => item.DefaultAccount)); #region Client DeleteConfig.AddHibernateDeleteInfo <Contact>() .AddDeleteDependenceFromBag(item => item.Emails) .AddDeleteDependenceFromBag(item => item.Phones) .AddRemoveFromDependence <DeliveryPoint>(x => x.Contacts); DeleteConfig.AddHibernateDeleteInfo <Contract>().HasSubclasses() ; DeleteConfig.AddHibernateDeleteInfo <ContractLongLease>() .AddDeleteDependence <ContractLongLeaseAddress>(x => x.Contract); DeleteConfig.AddHibernateDeleteInfo <ContractLongLeaseAddress>(); DeleteConfig.AddHibernateDeleteInfo <ContractMaintenance>() .AddDeleteDependence <ContractMaintenanceAddress>(x => x.Contract); DeleteConfig.AddHibernateDeleteInfo <ContractMaintenanceAddress>(); DeleteConfig.AddHibernateDeleteInfo <ContractShortLease>() .AddDeleteDependence <ContractShortLeaseAddress>(x => x.Contract); DeleteConfig.AddHibernateDeleteInfo <ContractShortLeaseAddress>() ; DeleteConfig.AddHibernateDeleteInfo <Counterparty>() .AddDeleteDependence <Contact>(x => x.Counterparty) .AddDeleteDependence <Contract>(x => x.Counterparty) .AddDeleteDependence <DeliveryPoint>(x => x.Counterparty) .AddDeleteDependenceFromBag(item => item.Emails) .AddDeleteDependenceFromBag(item => item.Phones) .AddDeleteDependenceFromBag(item => item.Accounts); DeleteConfig.AddHibernateDeleteInfo <DeliveryPoint>() .AddDeleteDependence <ContractLongLeaseAddress>(x => x.DeliveryPoint) .AddDeleteDependence <ContractShortLeaseAddress>(x => x.DeliveryPoint) .AddDeleteDependence <ContractMaintenanceAddress>(x => x.DeliveryPoint) //.AddDeleteDependenceFromBag(x => x.Contacts) FIXME сделать чтобы работало. ; DeleteConfig.AddHibernateDeleteInfo <DocTemplate>() .AddClearDependence <Contract>(x => x.ContractTemplate); #endregion #region Company DeleteConfig.AddHibernateDeleteInfo <CabineColor>() .AddClearDependence <Cabine>(x => x.Color); DeleteConfig.AddHibernateDeleteInfo <Cabine>() .AddRemoveFromDependence <ContractLongLeaseAddress>(x => x.Cabines); DeleteConfig.AddHibernateDeleteInfo <Employee>() .AddClearDependence <Counterparty>(x => x.PaymentManager) .AddClearDependence <Organization>(x => x.Buhgalter) .AddClearDependence <Organization>(x => x.Leader) .AddDeleteDependenceFromBag(x => x.Phones); DeleteConfig.AddHibernateDeleteInfo <Organization>() .AddDeleteDependence <Contract>(x => x.Organization) .AddDeleteDependenceFromBag(x => x.Phones) .AddDeleteDependenceFromBag(x => x.Accounts); DeleteConfig.AddHibernateDeleteInfo <User>() .AddClearDependence <Employee>(x => x.User); #endregion //Для тетирования #if DEBUG DeleteConfig.IgnoreMissingClass.Add(typeof(ContactAndPhonesView)); DeleteConfig.DeletionCheck(); #endif logger.Info("Ок"); }