public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); // Disable version if (this.CurrentDBVersion != new Version("0.0.0.0")) { return; } // try { fmCSAImporter1C.GetInstance(((ObjectSpace)ObjectSpace).Session); } catch { } try { fmCSAImporter1CGazPromBank.GetInstance(((ObjectSpace)ObjectSpace).Session); } catch { } // Заполнение кодов ценностей и курсов валют UpdaterVaultaCourse uvc = new UpdaterVaultaCourse(((ObjectSpace)this.ObjectSpace).Session); uvc.FixValutaCourseEtc(); // // IList <fmCPRPaymentRequest> pays = ObjectSpace.GetObjects <fmCPRPaymentRequest>(new BinaryOperator("FBKManager.IsClosed", true), true); foreach (fmCPRPaymentRequest pay in pays) { String last_name = pay.FBKManager.LastName.Split(' ')[0]; IList <hrmStaff> staff = ObjectSpace.GetObjects <hrmStaff>(CriteriaOperator.And( new BinaryOperator("LastName", last_name), new BinaryOperator("FirstName", pay.FBKManager.FirstName), new BinaryOperator("Department.BuhCode", "560"), CriteriaOperator.Or( new BinaryOperator("IsClosed", false), new UnaryOperator(UnaryOperatorType.IsNull, "IsClosed") )), true); if (staff.Count == 1) { pay.FBKManager = staff[0]; } else { continue; } } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); // Disable version if (this.CurrentDBVersion != new Version("0.0.0.0")) { return; } // IObjectSpace os = ObjectSpace; Session ssn = ((ObjectSpace)os).Session; // Заполнение кодов ценностей и курсов валют UpdaterVaultaCourse uvc = new UpdaterVaultaCourse(ssn); uvc.FixValutaCourseEtc(); os.CommitChanges(); if (this.CurrentDBVersion.ToString() != "1.1.1.107") { return; } XPQuery <fmAutoBindingUpdater> autoBindingUpdaters = new XPQuery <fmAutoBindingUpdater>(ssn); fmAutoBindingUpdater ABU = (from autoBindingUpdater in autoBindingUpdaters select autoBindingUpdater).FirstOrDefault(); if (ABU == null) { ABU = os.CreateObject <fmAutoBindingUpdater>(); } if (ABU.AutoBindingUpdater) { return; // Updater уже исполнялся } // Зачистка fmCPRRepaymentJurnal результатов предыдущей автоматической привязки XPQuery <fmCPRRepaymentJurnal> paymentJurnals = new XPQuery <fmCPRRepaymentJurnal>(ssn); var queryRJ = (from paymentJurnal in paymentJurnals select paymentJurnal).ToList <fmCPRRepaymentJurnal>(); ssn.Delete(queryRJ); //ssn.PurgeDeletedObjects(); //os.CommitChanges(); //ssn.ExecuteQuery("UPDATE \"fmPRRepaymentJurnal\" SET \"GCRecord\"=null;"); // Зачистка fmCPRRepaymentTask результатов предыдущей автоматической привязки XPQuery <fmCPRRepaymentTask> repaymentTasks = new XPQuery <fmCPRRepaymentTask>(ssn); var queryRT = (from repaymentTask in repaymentTasks select repaymentTask).ToList <fmCPRRepaymentTask>(); ssn.Delete(queryRT); ssn.PurgeDeletedObjects(); os.CommitChanges(); // Возвращение PAYED в IN_PAYMENT XPQuery <fmCPRPaymentRequest> paymentRequests = new XPQuery <fmCPRPaymentRequest>(ssn, true); var queryPR = (from paymentRequest in paymentRequests where paymentRequest.State == PaymentRequestStates.PAYED select paymentRequest).ToList <fmCPRPaymentRequest>(); foreach (var pr in queryPR) { pr.State = PaymentRequestStates.IN_PAYMENT; } os.CommitChanges(); // "Наша" организация (она там одна, отсев не нужен) crmUserParty.CurrentUserParty = ValueManager.GetValueManager <crmUserParty>("UserParty"); XPQuery <crmUserParty> userParties = new XPQuery <crmUserParty>(ssn); var queryUP = (from userParty in userParties select userParty).ToList <crmUserParty>(); foreach (var up in queryUP) { crmUserParty.CurrentUserParty.Value = (crmUserParty)up; break; } // Новая автоматическая привязка DateTime startDate = new DateTime(2012, 4, 1); XPQuery <fmCSAImportResult> importResults = new XPQuery <fmCSAImportResult>(ssn); var queryIR = (from importResult in importResults select importResult).ToList <fmCSAImportResult>(); foreach (var ir in queryIR) { //ir.AutoBinding(null); foreach (fmCSAStatementAccount sa in ir.StatementOfAccounts) { //ssa.AutoBinding(null); foreach (fmCSAStatementAccountDoc sad in sa.PayInDocs) { if (sad.DocDate >= startDate) { fmCDocRCB paymentDoc = sad.PaymentDocument; paymentDoc.AutoBinding(sa.BankAccount, null); } } foreach (fmCSAStatementAccountDoc sad in sa.PayOutDocs) { if (sad.DocDate >= startDate) { fmCDocRCB paymentDoc = sad.PaymentDocument; paymentDoc.AutoBinding(sa.BankAccount, null); } } } os.CommitChanges(); } // Простановка признаков заявкам и документам, что они были привязаны, чтобы следующее выполнение этого updater // не изменяло ничего. ABU.AutoBindingUpdater = true; os.CommitChanges(); }