Ejemplo n.º 1
0
 public void UpdateTrwSubjects(IObjectSpace os)
 {
     foreach (TrwSubject trw_subj in os.GetObjects <TrwSubject>())
     {
         trw_subj.Period = trw_subj.Period;
         trw_subj.Subjects.Clear();
         trw_subj.Subjects.Add(trw_subj.Subject);
         //
         IList <TrwSubjectDealSale> deal_sales = new List <TrwSubjectDealSale>(trw_subj.DealsSale);
         foreach (TrwSubjectDealSale deal_sale in deal_sales)
         {
             if (deal_sale.DealBudget == null)
             {
                 deal_sale.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_REAL;
                 if (deal_sale.Deal != null)
                 {
                     deal_sale.CrmContractDeals.Add(deal_sale.Deal);
                 }
             }
             else
             {
                 os.Delete(deal_sale);
             }
         }
         TrwSubjectDealSale deal_sale_other = os.CreateObject <TrwSubjectDealSale>();
         trw_subj.DealsSale.Add(deal_sale_other);
         deal_sale_other.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER;
         os.Delete(trw_subj.DealOtherSale);
         trw_subj.DealOtherSale         = deal_sale_other.DealBudget;
         deal_sale_other.PersonInternal = TrwSettings.GetInstance(os).PersonOtherSale;
         //                deal_sale_other.UpdateConsolidateDeal(true);
         //
         IList <TrwSubjectDealBay> deal_bays = new List <TrwSubjectDealBay>(trw_subj.DealsBay);
         foreach (TrwSubjectDealBay deal_bay in deal_bays)
         {
             if (deal_bay.DealBudget == null)
             {
                 deal_bay.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_REAL;
                 if (deal_bay.Deal != null)
                 {
                     deal_bay.CrmContractDeals.Add(deal_bay.Deal);
                 }
             }
             else
             {
                 os.Delete(deal_bay);
             }
         }
         TrwSubjectDealBay deal_bay_other = os.CreateObject <TrwSubjectDealBay>();
         trw_subj.DealsBay.Add(deal_bay_other);
         deal_bay_other.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER;
         os.Delete(trw_subj.DealOtherBay);
         trw_subj.DealOtherBay         = deal_bay_other.DealBudget;
         deal_bay_other.PersonInternal = TrwSettings.GetInstance(os).PersonOtherBay;
         //                deal_bay_other.UpdateConsolidateDeal(true);
         //
     }
 }
        public static fmCAVTBookBuhStruct Import(fmCAVTBookBuhStruct struct_book, IObjectSpace os, Stream stream)
        {
            fmCAVTBookBuhStructXMLLoader loader = new fmCAVTBookBuhStructXMLLoader(os, struct_book, stream);

            os.Delete(struct_book.InInvoiceRecords);
            os.Delete(struct_book.OutInvoiceRecords);
            loader.Load();
            struct_book.StatusSet(fmCAVTBookBuhStructStatus.BUH_STRUCT_IMPORTED);
            return(struct_book);
        }
Ejemplo n.º 3
0
        private void DeleteBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            object cellObject = employeeGridView.GetRow(employeeGridView.FocusedRowHandle);

            securedObjectSpace.Delete(cellObject);
            securedObjectSpace.CommitChanges();
        }
        public virtual void ProcessRequestsToStartWorkflows()
        {
            var objectChangedXpoStartWorkflowRequests = new List <ObjectChangedXpoStartWorkflowRequest>();

            using (IObjectSpace objectSpace = ObjectSpaceProvider.CreateObjectSpace()) {
                foreach (var request in objectSpace.GetObjects <ObjectChangedXpoStartWorkflowRequest>())
                {
                    try {
                        var definition = GetService <IWorkflowDefinitionProvider>().FindDefinition(request.TargetWorkflowUniqueId);
                        if (definition != null && definition.CanOpenHost)
                        {
                            if (GetService <ObjectChangedStartWorkflowService>().StartWorkflow(definition.Name, request.TargetWorkflowUniqueId, request.TargetObjectKey, request.PropertyName, request.OldValue))
                            {
                                OnRequestProcessed(objectSpace, request);
                                objectChangedXpoStartWorkflowRequests.Add(request);
                            }
                        }
                    } catch (Exception e) {
                        e.Data.Add("StartWorkflowOnObjectChangeService.ProcessRequestsToStartWorkflows.currentRequest",
                                   string.Format("Key={0}, TargetObjectKey={1}, TargetWorkflowUniqueId={2}", objectSpace.GetKeyValue(request), request.TargetObjectKey, request.TargetWorkflowUniqueId));
                        throw;
                    }
                }
                objectSpace.Delete(objectChangedXpoStartWorkflowRequests);
                objectSpace.CommitChanges();
            }
        }
Ejemplo n.º 5
0
        public static void Set_UniqueValue(IProperty p, IObjectSpace os, bool value)
        {
            var name = p.Owner.Caption + "." + p.Caption + "唯一";
            var r    = p.Rules.SingleOrDefault(x => x.Name == name);

            if (value)
            {
                if (r == null)
                {
                    r      = os.CreateObject <IRuleUniqueValueInfo>();
                    r.Name = name;
                    p.Rules.Add(r);
                    RefreshRules(p);
                }
            }
            else
            {
                if (r != null)
                {
                    p.Rules.Remove(r);
                    os.Delete(r);
                    RefreshRules(p);
                }
            }
        }
Ejemplo n.º 6
0
        public static void ImportInContractBSR(TrwBudgetPeriod period, IObjectSpace os, TextReader reader)
        {
            DelimitedFileEngine engine = new DelimitedFileEngine(typeof(InContractBsrRecord));

            engine.Options.IgnoreFirstLines = 1;
            InContractBsrRecord[] records = (InContractBsrRecord[])engine.ReadStream(reader);
            os.Delete(period.InContractBSR);
            foreach (InContractBsrRecord rec in records)
            {
                if (!String.IsNullOrEmpty(rec.TrwSaleNomCode))
                {
                    TrwBudgetPeriodInContractBSR in_bsr = os.CreateObject <TrwBudgetPeriodInContractBSR>();
                    period.InContractBSR.Add(in_bsr);
                    in_bsr.SaleNomCode      = rec.TrwSaleNomCode.Trim();
                    in_bsr.SaleNomenclature = os.FindObject <TrwSaleNomenclature>(new BinaryOperator("TrwCode", rec.TrwSaleNomCode.Trim()));
//                    if (in_bsr.SaleNomenclature == null)
//                        throw new InvalidDataException("Unknow nomencalture: " + rec.TrwSaleNomCode);
                    in_bsr.Period00 = rec.Period00 != null ? (Decimal)rec.Period00 : 0;
                    in_bsr.Period01 = rec.Period01 != null ? (Decimal)rec.Period01 : 0;
                    in_bsr.Period02 = rec.Period02 != null ? (Decimal)rec.Period02 : 0;
                    in_bsr.Period03 = rec.Period03 != null ? (Decimal)rec.Period03 : 0;
                    in_bsr.Period04 = rec.Period04 != null ? (Decimal)rec.Period04 : 0;
                    in_bsr.Period05 = rec.Period05 != null ? (Decimal)rec.Period05 : 0;
                    in_bsr.Period06 = rec.Period06 != null ? (Decimal)rec.Period06 : 0;
                    in_bsr.Period07 = rec.Period07 != null ? (Decimal)rec.Period07 : 0;
                    in_bsr.Period08 = rec.Period08 != null ? (Decimal)rec.Period08 : 0;
                    in_bsr.Period09 = rec.Period09 != null ? (Decimal)rec.Period09 : 0;
                    in_bsr.Period10 = rec.Period10 != null ? (Decimal)rec.Period10 : 0;
                    in_bsr.Period11 = rec.Period11 != null ? (Decimal)rec.Period11 : 0;
                    in_bsr.Period12 = rec.Period12 != null ? (Decimal)rec.Period12 : 0;
                }
            }
        }
Ejemplo n.º 7
0
        public static void DeleteCashFlows(IObjectSpace objSpace, string criteria, params object[] parameters)
        {
            var cop       = CriteriaOperator.Parse(criteria, parameters);
            var cashFlows = objSpace.GetObjects <CashFlow>(cop);

            objSpace.Delete(cashFlows);
            objSpace.CommitChanges();
        }
Ejemplo n.º 8
0
        private void DeleteObsoleteRules(IObjectSpace objectSpace, IModelPurgingRule[] purgingRules)
        {
            var ids           = purgingRules.Cast <ModelNode>().Select(node => node.GetParent <IModelClass>().Id() + node.Id).ToArray();
            var rulesToDelete = objectSpace.GetObjectsQuery <RuleInfoObject>().Where(storage =>
                                                                                     storage.RuleScheduleType == RuleScheduleType.Purging && !ids.Contains(storage.RuleId)).ToArray();

            objectSpace.Delete(rulesToDelete);
            objectSpace.CommitChanges();
        }
Ejemplo n.º 9
0
 public static void AfterChange_PropertyType(IProperty p, IObjectSpace os)
 {
     if (p.PropertyType != null && p.PropertyType.ExtendSettingType != null)
     {
         os.Delete(p.ExtendSetting);
         p.ExtendSetting          = (IPropertyExtend)os.CreateObject(ReflectionHelper.FindType(p.PropertyType.ExtendSettingType));
         p.ExtendSetting.Property = p;
     }
 }
Ejemplo n.º 10
0
//        private struct LineKeyValue {
//            public Decimal SummCost;
//            public Decimal SummVat;
//            public Decimal SummAll;
//        }
        //
        public override void Calculate(IObjectSpace os)
        {
            os.Delete(this.BudgetValues);
            IDictionary <TrwBudgetKey, IList <TrwBudgetValue> > keys = new Dictionary <TrwBudgetKey, IList <TrwBudgetValue> >();

            foreach (TrwSubjectDealSale deal_sale in TrwSubject.DealsSale)
            {
                Load(os, deal_sale, keys);
            }
        }
Ejemplo n.º 11
0
 public override void DealUpdated()
 {
     using (IObjectSpace os = ObjectSpace.FindObjectSpaceByObject(this).CreateNestedObjectSpace()) {
         TrwSubjectDealSale subj_deal = os.GetObject <TrwSubjectDealSale>(this);
         subj_deal.CrmContractDeals.Clear();
         subj_deal.CrmContractDeals.Add(subj_deal.Deal);
         os.Delete(subj_deal.DealSaleOrders);
         TrwSubjectDealLogic.RefreshDeal(os, subj_deal);
         os.CommitChanges();
     }
 }
Ejemplo n.º 12
0
        public ActionResult Delete(Guid key)
        {
            Employee existing = objectSpace.GetObjectByKey <Employee>(key);

            if (existing != null)
            {
                objectSpace.Delete(existing);
                objectSpace.CommitChanges();
                return(NoContent());
            }
            return(NotFound());
        }
Ejemplo n.º 13
0
        private void DeleteViewVariantAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            IObjectSpaceLink currentLayoutItem = SelectViewVariantAction.SelectedItem.Data as IObjectSpaceLink;

            if (TryLoadViewVariantFromXML(defaultUserSettings))
            {
                IObjectSpace os = currentLayoutItem.ObjectSpace;
                os.Delete(currentLayoutItem);
                os.CommitChanges();
                isDefaultViewSelected = true;
                UpdateActions(null);
            }
        }
Ejemplo n.º 14
0
        public static async Task Delete_Two_Entities <TCloudEntity, TLocalEntity>(this IObjectSpace objectSpace,
                                                                                  TLocalEntity[] localEntites, Func <IObjectSpace, IObservable <TCloudEntity> > synchronize,
                                                                                  Func <Task> assert, TimeSpan timeout, TCloudEntity[] existingEntities)
        {
            var localEntity1 = objectSpace.GetObject(localEntites[0]);
            var cloudEntity1 = existingEntities.First();
            await objectSpace.NewCloudObject(localEntity1, cloudEntity1);

            var localEntity2 = objectSpace.GetObject(localEntites[1]);
            var cloudEntity2 = existingEntities.Skip(1).First();
            await objectSpace.NewCloudObject(localEntity2, cloudEntity2);

            var map = synchronize(objectSpace).SubscribeReplay();

            objectSpace.Delete(localEntity1);
            objectSpace.CommitChanges();
            objectSpace.Delete(localEntity2);
            objectSpace.CommitChanges();


            await map.Take(2).SelectMany((cloudEntity, i) => Observable.FromAsync(assert)).Timeout(timeout);
        }
Ejemplo n.º 15
0
 public static void Обновить(IObjectSpace os, ОперацияКонтИмпортСтруктур конт)
 {
     os.Delete(конт.Операции);
     foreach (var запись in конт.ДанныеСтруктур.InInvoiceRecords)
     {
         Обновить(os, конт, Основание.ТипИсточника.ВХОДЯЩИЙ, запись);
     }
     foreach (var запись in конт.ДанныеСтруктур.OutInvoiceRecords)
     {
         Обновить(os, конт, Основание.ТипИсточника.ИСХОДЯЩИЙ, запись);
     }
     //        public static void Обновить(IObjectSpace os, XPCollection<fmCAVTBookBuhStructRecord> записи) {
 }
Ejemplo n.º 16
0
        private void Service_ItemsProcessed(object sender, DevExpress.Persistent.Base.General.NotificationItemsEventArgs e)
        {
            IObjectSpace space = Application.CreateObjectSpace(typeof(MyNotifications));

            foreach (INotificationItem item in e.NotificationItems)
            {
                if (item.NotificationSource is MyNotifications)
                {
                    space.Delete(space.GetObject(item.NotificationSource));
                }
            }
            space.CommitChanges();
        }
Ejemplo n.º 17
0
        private void popupWindowShowActionCrgTms_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace();
            ArchivoCarga newObj;

            newObj = objectSpace.FindObject <ArchivoCarga>(null);
            if (newObj != null)
            {
                objectSpace.Delete(newObj);
            }

            newObj = objectSpace.CreateObject <ArchivoCarga>();
            e.View = Application.CreateDetailView(objectSpace, "ArchivoCarga_DetailView", true, newObj);
        }
Ejemplo n.º 18
0
        private void popupWindowShowActionCrgCtlgsCfdi_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace();
            FilterCFDI   newObj;

            newObj = objectSpace.FindObject <FilterCFDI>(null);
            if (newObj != null)
            {
                objectSpace.Delete(newObj);
            }

            newObj = objectSpace.CreateObject <FilterCFDI>();
            e.View = Application.CreateDetailView(objectSpace, "FilterCFDI_DetailView", true, newObj);
        }
Ejemplo n.º 19
0
        private void popupWindowShowActionAgrgrBtcr_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace    objectSpace = Application.CreateObjectSpace();
            AgregarBitacora newObj;

            newObj = objectSpace.FindObject <AgregarBitacora>(null);
            if (newObj != null)
            {
                objectSpace.Delete(newObj);
            }

            newObj = objectSpace.CreateObject <AgregarBitacora>();
            e.View = Application.CreateDetailView(objectSpace, "AgregarBitacora_DetailView", true, newObj);
        }
Ejemplo n.º 20
0
        private void popupWindowShowActionIncdncCncld_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace    objectSpace = Application.CreateObjectSpace();
            CancelaAtencion newObj;

            newObj = objectSpace.FindObject <CancelaAtencion>(null);
            if (newObj != null)
            {
                objectSpace.Delete(newObj);
            }

            newObj = objectSpace.CreateObject <CancelaAtencion>();
            e.View = Application.CreateDetailView(objectSpace, "CancelaAtencion_DetailView", true, newObj);
        }
Ejemplo n.º 21
0
        static public void Clear(IObjectSpace os, fmCAVTBookVAT book)
        {
            IList <fmCAVTBookVATRecord> del_record = new List <fmCAVTBookVATRecord>();

            foreach (var record in book.BookVATRecords)
            {
                if (Decimal.Round(record.C14_SummCost18, 2) == 0 && Decimal.Round(record.C15_SummCost10, 2) == 0 &&
                    Decimal.Round(record.C16_SummCost0, 2) == 0 && Decimal.Round(record.C17_SummVat18, 2) == 0 &&
                    Decimal.Round(record.C18_SummVat10, 2) == 0)
                {
                    del_record.Add(record);
                }
            }
            os.Delete(del_record);
        }
Ejemplo n.º 22
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            // Disable
            if (this.CurrentDBVersion != new Version("0.0.0.0"))
            {
                return;
            }

            if (this.CurrentDBVersion > new Version("1.1.1.218"))
            {
                return;
            }

            using (IObjectSpace os = ObjectSpace.CreateNestedObjectSpace()) {
                foreach (fmCDirection dir in os.GetObjects <fmCDirection>())
                {
                    if (dir.DateEnd < gfmCAnalytic.DateMinValue)
                    {
                        dir.IsPeriodUnlimited = true;
                    }
                }
                foreach (fmCSubjectExt subj in new List <fmCSubjectExt>(os.GetObjects <fmCSubjectExt>()))
                {
                    if (subj.DateEnd < gfmCAnalytic.DateMinValue)
                    {
                        subj.IsPeriodUnlimited = true;
                    }
                    if (subj.Name.ToLower() == "удалить")
                    {
                        subj.Status = fmISubjectStatus.DELETE;
                    }
                    if (subj.Status == fmISubjectStatus.DELETE &&
                        subj.OrderExts.Count == 0)
                    {
                        os.Delete(subj);
                    }
                }
                foreach (fmCOrderExt order in os.GetObjects <fmCOrderExt>(null, true))
                {
                    if (order.DateEnd < gfmCAnalytic.DateMinValue)
                    {
                        order.IsPeriodUnlimited = true;
                    }
                }
                os.CommitChanges();
            }
        }
Ejemplo n.º 23
0
        private void popupWindowShowActionIncdncHrr_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace        objectSpace = Application.CreateObjectSpace();
            ResponsableAtencion newObj;

            newObj = objectSpace.FindObject <ResponsableAtencion>(null);
            if (newObj != null)
            {
                objectSpace.Delete(newObj);
            }

            /*
             * if (newObj == null)*/
            newObj = objectSpace.CreateObject <ResponsableAtencion>();
            e.View = Application.CreateDetailView(objectSpace, "ResponsableAtencion_DetailView", true, newObj);
        }
        private void doDeleteAnlagenGruppe_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            IObjectSpace            workingOs    = Application.CreateObjectSpace();
            ChoiceActionItem        chosenOption = e.SelectedChoiceActionItem;
            LgHaustechnikKomponente chosenKomponente;

            if (chosenOption.Data != null)
            {
                //hier ist die Technikeinheit drin

                chosenKomponente = workingOs.GetObjectByKey <LgHaustechnikKomponente>(((LgHaustechnikKomponente)chosenOption.Data).Oid);
                workingOs.Delete(chosenKomponente);
                workingOs.CommitChanges();
                refreshDetailView();
            }
        }
        private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            GridListEditor editor = (View as ListView).Editor as GridListEditor;

            if (editor != null)
            {
                Type type = ((ListView)View).ObjectTypeInfo.Type;
                using (IObjectSpace objectSpace = Application.CreateObjectSpace(type))
                {
                    ArrayList objectsToDelete = new ArrayList();
                    objectsToDelete.AddRange(objectSpace.GetObjects(type, editor.GridView.ActiveFilterCriteria));
                    objectSpace.Delete(objectsToDelete);
                    objectSpace.CommitChanges();
                }
                ObjectSpace.Refresh();
                UpdateActionState();
            }
        }
Ejemplo n.º 26
0
        private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            ASPxGridListEditor listEditor = ((ListView)View).Editor as ASPxGridListEditor;

            if (listEditor != null)
            {
                Type type = ((ListView)View).ObjectTypeInfo.Type;
                using (IObjectSpace objectSpace = Application.CreateObjectSpace(type))
                {
                    ArrayList objectsToDelete = new ArrayList();
                    objectsToDelete.AddRange(objectSpace.GetObjects(type, CriteriaOperator.Parse(listEditor.Grid.FilterExpression)));
                    objectSpace.Delete(objectsToDelete);
                    objectSpace.CommitChanges();
                }
                ObjectSpace.Refresh();
                UpdateActionState();
            }
        }
Ejemplo n.º 27
0
        public static void ImportInData(FmDocsFmInData doc, IObjectSpace os, TextReader reader)
        {
            DelimitedFileEngine engine = new DelimitedFileEngine(typeof(InDataImport));

            engine.Options.IgnoreFirstLines = 1;
            InDataImport[] records = (InDataImport[])engine.ReadStream(reader);
            os.Delete(doc.Lines);
            fmCFAAccountSystem fact_system = os.FindObject <fmCFAAccountSystem>(new BinaryOperator("Code", "1000"));
            IList <fmCostItem> cost_items  = os.GetObjects <fmCostItem>();

            foreach (InDataImport rec in records)
            {
                FmDocsFmInData.Line line = doc.LinesCreate();
                line.FactAccount = fact_system.Accounts.FirstOrDefault(x => x.Code == rec.AccountCode);
                line.FmOrder     = os.FindObject <fmCOrder>(new BinaryOperator("Code", rec.OrderCode));
                line.FmCostItem  = cost_items.FirstOrDefault(x => x.Code == rec.CostItemCode);
                line.Summ        = rec.Summ;
            }
        }
Ejemplo n.º 28
0
        public ActionResult Delete(int id)
        {
            try
            {
                GenHelper.WriteLog("[Log]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Delete(" + id.ToString() + "):[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");

                PurchaseReturnDetail existing = objectSpace.GetObjectByKey <PurchaseReturnDetail>(id);
                if (existing != null)
                {
                    objectSpace.Delete(existing);
                    objectSpace.CommitChanges();
                    return(NoContent());
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Delete(" + id.ToString() + "):[" + ex.Message + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                throw new Exception(ex.Message);
            }
        }
        public static void ImportDocBSRLines(TrwBudgetPeriodDocBSR doc, IObjectSpace os, TextReader reader)
        {
            DelimitedFileEngine engine = new DelimitedFileEngine(typeof(DocBSRLineRecord));

            engine.Options.IgnoreFirstLines = 1;
            DocBSRLineRecord[] records = (DocBSRLineRecord[])engine.ReadStream(reader);
            os.Delete(doc.DocBSRLines);
            foreach (DocBSRLineRecord rec in records)
            {
                if (!String.IsNullOrEmpty(rec.TrwSaleNomCode))
                {
                    String nom_code = rec.TrwSaleNomCode.Trim();
                    TrwBudgetPeriodDocBSR.LineBSR in_bsr = doc.DocBSRLines.FirstOrDefault(x => x.SaleNomCode == nom_code);
                    if (in_bsr == null)
                    {
                        in_bsr                  = os.CreateObject <TrwBudgetPeriodDocBSR.LineBSR>();
                        in_bsr.SaleNomCode      = nom_code;
                        in_bsr.SaleNomenclature = os.FindObject <TrwSaleNomenclature>(new BinaryOperator("TrwCode", nom_code));
                        doc.DocBSRLines.Add(in_bsr);
                    }
//                    if (in_bsr.SaleNomenclature == null)
//                        throw new InvalidDataException("Unknow nomencalture: " + rec.TrwSaleNomCode);
                    in_bsr.Period00 += rec.Period00 != null ? (Decimal)rec.Period00 : 0;
                    in_bsr.Period01 += rec.Period01 != null ? (Decimal)rec.Period01 : 0;
                    in_bsr.Period02 += rec.Period02 != null ? (Decimal)rec.Period02 : 0;
                    in_bsr.Period03 += rec.Period03 != null ? (Decimal)rec.Period03 : 0;
                    in_bsr.Period04 += rec.Period04 != null ? (Decimal)rec.Period04 : 0;
                    in_bsr.Period05 += rec.Period05 != null ? (Decimal)rec.Period05 : 0;
                    in_bsr.Period06 += rec.Period06 != null ? (Decimal)rec.Period06 : 0;
                    in_bsr.Period07 += rec.Period07 != null ? (Decimal)rec.Period07 : 0;
                    in_bsr.Period08 += rec.Period08 != null ? (Decimal)rec.Period08 : 0;
                    in_bsr.Period09 += rec.Period09 != null ? (Decimal)rec.Period09 : 0;
                    in_bsr.Period10 += rec.Period10 != null ? (Decimal)rec.Period10 : 0;
                    in_bsr.Period11 += rec.Period11 != null ? (Decimal)rec.Period11 : 0;
                    in_bsr.Period12 += rec.Period12 != null ? (Decimal)rec.Period12 : 0;
                    in_bsr.Period13 += rec.Period13 != null ? (Decimal)rec.Period13 : 0;
                }
            }
        }
Ejemplo n.º 30
0
        public static void TransactPlan0(IObjectSpace os, FmFinPlanSubject fin_plan_subject, FmFinPlanSubjectDocFull doc)
        {
            if (doc.Order == null)
            {
                throw new NullReferenceException();
            }
            foreach (var oper in new List <FmJournalOperation>(fin_plan_subject.PlanFullOperations))
            {
                if (oper.Order == doc.Order)
                {
                    os.Delete(oper);
                }
//                os.Delete(fin_plan_subject.PlanFullOperations.Where(x => x.Order == doc.Order));
            }
            foreach (var doc_oper in doc.DocOperations)
            {
                FmJournalOperation oper = MakeOperationPlan0(os, fin_plan_subject);
                oper.BalanceSumma          = doc_oper.BalanceSumma;
                oper.BalanceValuta         = doc_oper.BalanceValuta;
                oper.BuhAccount            = doc_oper.BuhAccount;
                oper.CostItem              = doc_oper.CostItem;
                oper.Date                  = doc_oper.Date;
                oper.Deal                  = doc_oper.Deal;
                oper.Department            = doc_oper.Department;
                oper.DepartmentStructItem  = doc_oper.DepartmentStructItem;
                oper.FinAccount            = doc_oper.FinAccount;
                oper.FinAccountBalanceType = doc_oper.FinAccountBalanceType;
                oper.FinAccountType        = doc_oper.FinAccountType;
                oper.FinIndex              = doc_oper.FinIndex;
                oper.FinOperationType      = doc_oper.FinOperationType;
                oper.ObligationSumma       = doc_oper.ObligationSumma;
                oper.ObligationValuta      = doc_oper.ObligationValuta;
                oper.Order                 = doc_oper.Order;
                oper.Party                 = doc_oper.Party;
                oper.PayType               = doc_oper.PayType;
//                oper.Person = doc_oper.Person;
            }
        }
        public static void CreateSystemTypes(IObjectSpace ObjectSpace,IModelApplication app,bool deleteExists)
        {
            var objs = ObjectSpace.GetObjects<BusinessObject>(new BinaryOperator("IsRuntimeDefine", false));
            if (objs.Count > 0)
                return;

            ObjectSpace.Delete(objs);

            #region 系统类型
            AddBusinessObject(typeof (单据<>), "单据<明细>", CreateNameSpace(typeof (单据<>).Namespace,ObjectSpace),
                "单据<明细>,继承自单据基类,支持将明细类型做为参数传入(内部使用泛型实现)", false,ObjectSpace);

            //AddBusinessObject(typeof (订单<>), "订单<明细>", CreateNameSpace(typeof (订单<>).Namespace, ObjectSpace),
            //    "订单<明细>,继承自 单据<明细>基类 ,支持将明细类型做为参数传入(内部使用泛型实现),并支持各类订单类型的抽象实现.", false, ObjectSpace);

            //AddBusinessObject(typeof (仓库单据基类<>), "仓库单据基类<明细>", CreateNameSpace(typeof (仓库单据基类<>).Namespace,ObjectSpace),
            //    "仓库单据基类<明细>,继承自 单据<明细>基类,支持将明细类型做为参数传入(内部使用泛型实现),并支持各类仓库类单据的抽象实现.", false,ObjectSpace);

            //AddBusinessObject(typeof (库存单据明细<>), "库存单据明细<单据>", CreateNameSpace(typeof (库存单据明细<>).Namespace,ObjectSpace),
            //    "继承自库存流水,用于库存单据明细的基类,需要传入单据类型.", false,ObjectSpace);

            //AddBusinessObject(typeof (订单明细<>), "订单明细<订单>", CreateNameSpace(typeof (订单明细<>).Namespace,ObjectSpace), "可以与订单<订单明细>成对出现使用.",false,ObjectSpace);

            AddBusinessObject(typeof (明细<>), "明细<单据>", CreateNameSpace(typeof (明细<>).Namespace, ObjectSpace),
                "可以与单据<明细>成对继承使用.", false, ObjectSpace);
            //第一步,创建出所有基类类型

            var exists = ObjectSpace.GetObjects<BusinessObjectBase>(null, true);

            foreach (var bom in app.BOModel)
            {
                if (!bom.TypeInfo.Type.IsGenericType && bom.TypeInfo.Type.Assembly.Location != AdmiralEnvironment.UserDefineBusinessFile.FullName)
                {
                    var ns = CreateNameSpace(bom.TypeInfo.Type.Namespace, ObjectSpace);
                    AddBusinessObject(bom.TypeInfo.Type, bom.Caption, ns, "", false, ObjectSpace);
                }
            }

            //第二步,创建这些类的属性,因为属性中可能使用了类型,所以先要创建类型.
            var bos = ObjectSpace.GetObjects<BusinessObject>(null, true);
            foreach (var bob in bos.Where(x => !x.IsRuntimeDefine))
            {
                var type = ReflectionHelper.FindType(bob.FullName);

                if (type.BaseType != null && type.BaseType != typeof (object))
                {
                    var fullName = type.BaseType.Namespace + "." + type.BaseType.Name;

                    var baseType = bos.SingleOrDefault(x => x.FullName == fullName);
                    bob.Base = baseType;

                    if (bob.Base == null)
                    {
                        Debug.WriteLine(type.FullName + "没有找到基类:" + fullName);
                    }
                }

                if (type.IsGenericType)
                {
                    bob.DisableCreateGenericParameterValues = true;

                    foreach (var item in type.GetGenericArguments())
                    {
                        var gp = ObjectSpace.CreateObject<GenericParameter>();
                        gp.Owner = bob;
                        gp.Name = item.Name;
                        if (item.IsGenericParameter)
                        {
                            gp.ParameterIndex = item.GenericParameterPosition;
                        }
                        else
                        {
                        }
                        if (!string.IsNullOrEmpty(item.FullName))
                            gp.ParameterValue = exists.SingleOrDefault(x => x.FullName == item.FullName);

                        var att =
                            item.GetCustomAttributes(typeof (ItemTypeAttribute), false)
                                .OfType<ItemTypeAttribute>()
                                .FirstOrDefault();
                        if (att != null)
                        {
                            var gi = bos.SingleOrDefault(x => x.FullName == att.ItemType.FullName);
                            gp.DefaultGenericType = gi;
                        }
                    }
                }

                var typeInfo = CaptionHelper.ApplicationModel.BOModel.GetClass(type);
                if (typeInfo != null && false)
                {
                    foreach (var tim in typeInfo.OwnMembers)
                    {
                        if (tim.MemberInfo.IsAssociation)
                        {
                            var collectionMember = ObjectSpace.CreateObject<CollectionProperty>();
                            collectionMember.Owner = bob;

                            collectionMember.Aggregated = tim.MemberInfo.IsAggregated;
                            collectionMember.名称 = tim.Name;
                            collectionMember.PropertyType = bos.SingleOrDefault(x => x.FullName == tim.Type.FullName);
                            if (collectionMember.PropertyType == null)
                            {
                                Debug.WriteLine("没有找到属性类型:" + tim.Type.FullName);
                                //throw new Exception("没有找到属性类型" + tim.Type.FullName);
                            }
                        }
                        else
                        {
                            var member = ObjectSpace.CreateObject<Property>();
                            member.Owner = bob;
                            member.名称 = tim.Name;
                            member.PropertyType = exists.SingleOrDefault(x => x.FullName == tim.Type.FullName);
                            member.Owner = bob;
                            if (member.PropertyType == null)
                            {
                                Debug.WriteLine("没有找到属性类型:" + tim.Type.FullName);
                                //throw new Exception("没有找到属性类型" + tim.Type.FullName);
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("没有找到类型:" + type.FullName);
                }
            }

            //第三步,设置属性的关联属性,因为可能用到第二步中创建的属性,及,创建关系.
            foreach (var bob in bos.Where(x => !x.IsRuntimeDefine))
            {
                if (bob.CollectionProperties.Count > 0)
                {
                    var type = ReflectionHelper.FindType(bob.FullName);
                    var typeInfo = CaptionHelper.ApplicationModel.BOModel.GetClass(type);
                    foreach (var cp in bob.CollectionProperties)
                    {
                        var mi = typeInfo.FindMember(cp.名称);
                        cp.RelationProperty = cp.PropertyType.FindProperty(mi.MemberInfo.AssociatedMemberInfo.Name);
                    }
                }
            }

            #endregion

            ObjectSpace.CommitChanges();
        }
        private void ExecuteModule(IDynamicModule module, ExecuteCommand command, IObjectSpace os, IExamination examination)
        {
            // Определяем идентификатор приложения которое будет открывать файл обследования
            // Для модулей которые могут работать с несколькими приложениями
            Guid soft = examination.ExaminationSoftType.ExaminationSoftTypeId;

            // Получаем имя РЕАЛЬНОГО файла обследования из базы !!!
            string file = examination.ExaminationFile.RealFileName;
            Guid context = (examination as DevExpress.ExpressApp.DC.DCBaseObject).Oid;

            if (System.IO.File.Exists(file) == true)
            {// если файл удалось найти в том месте, где он должен быть
                if (FileWatcher.GetFileState(file) == FileState.Close)
                {// если файл никем не используется т.е закрыт
                    if (new FileInfo(file).Length == 0)
                    {// если файл обследования по какой то причине пустой, то открываем его как новый
                        // Проверяем готовность модуля
                        if (ModuleIsReady(module, soft, command) == false) return;

                        PatientData data = GetFromExamination(examination);

                        if (TryToExecuteModule(module, ExecuteCommand.New, file, context, data) == false)
                        {// если при запуске приложения возникла ошибка

                            // удаляем обследование если его можно удалять
                            if (examination.AllowEmptyOrNotExistsFile == false)
                                os.Delete(examination);
                            string message = CaptionHelper.GetLocalizedText("Exceptions", "TheExecutableFileOfRequestedApplicationWasNotFound");
                            string title = CaptionHelper.GetLocalizedText("Captions", "ApplicationLaunchError");

                            XtraMessageBox.Show(message, title,
                                         System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }

                        if (os.IsModified == true)
                            os.CommitChanges();
                    }
                    else
                    {// Если файл не пустой
                        // Проверяем готовность модуля
                        if (ModuleIsReady(module, soft, command) == false) return;

                        if (TryToExecuteModule(module, command, file, context) == false)
                        {
                            string message = CaptionHelper.GetLocalizedText("Exceptions", "TheExecutableFileOfRequestedApplicationWasNotFound");
                            string title = CaptionHelper.GetLocalizedText("Captions", "ApplicationLaunchError");

                            XtraMessageBox.Show(message, title,
                                         System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }

                        if (os.IsModified == true)
                            os.CommitChanges();
                    }
                }
                else
                {// если файл в момент записи открыт где то еще
                    string message = "Ошибка доступа к файлу обследования!\nВозможно файл открыт внешним приложением или нет прав доступа"; //CaptionHelper.GetLocalizedText("Warnings", "RequiredExaminationIsAlreadyLaunched");

                    XtraMessageBox.Show(message, "",
                        System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                    return;
                }
            }
            else // АХТУНГ !!! НАДО УДАЛЯТЬ ОБСЛЕДОВАНИЯ СОДЕРЖАШИЕ УДАЛЕННЫЕ ФАЙЛЫ ИЛИ НЕ НАДО ?!!?!?!?
            {// если реального файла нет - создаем новый пустой файл
                using (Stream stream = File.Create(file)) { };

                // Проверяем готовность модуля
                if (ModuleIsReady(module, soft, command) == false) return;

                PatientData data = GetFromExamination(examination);
                TryToExecuteModule(module, ExecuteCommand.New, file, context, data);
            }
            os.Refresh();
        }
 protected virtual void OnRequestProcessed(IObjectSpace objectSpace, ObjectChangedXpoStartWorkflowRequest request) {
     objectSpace.Delete(request);
     objectSpace.CommitChanges();
 }