public ProductViewAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.Reloaded += ObjectSpace_Reloaded; objectSpace.ModifiedChanging += ObjectSpace_ModifiedChanging; }
private void ShowNavigationItemController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { ViewShortcut shortcut = e.ActionArguments.SelectedChoiceActionItem.Data as ViewShortcut; if (shortcut != null) { oldListView = Application.ProcessShortcut(shortcut) as ListView; if (oldListView != null) { e.Handled = true; NonPersistentObjectSpace nonPersistentObjectSpace = (NonPersistentObjectSpace)Application.CreateObjectSpace(typeof(ViewFilterContainer)); IObjectSpace persistentObjectSpace = Application.CreateObjectSpace(typeof(ViewFilterObject)); nonPersistentObjectSpace.AdditionalObjectSpaces.Add(persistentObjectSpace); ViewFilterContainer newViewFilterContainer = nonPersistentObjectSpace.CreateObject <ViewFilterContainer>(); newViewFilterContainer.ObjectType = oldListView.ObjectTypeInfo.Type; newViewFilterContainer.Filter = GetFilterObject(persistentObjectSpace, ((IModelListViewAdditionalCriteria)oldListView.Model).AdditionalCriteria, newViewFilterContainer.ObjectType); DetailView filterDetailView = Application.CreateDetailView(nonPersistentObjectSpace, newViewFilterContainer); filterDetailView.Caption = String.Format("Filter for the {0} ListView", oldListView.Caption); filterDetailView.ViewEditMode = ViewEditMode.Edit; e.ActionArguments.ShowViewParameters.CreatedView = filterDetailView; e.ActionArguments.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; DialogController dialogCotnroller = Application.CreateController <DialogController>(); dialogCotnroller.Accepting += new EventHandler <DialogControllerAcceptingEventArgs>(dialogCotnroller_Accepting); dialogCotnroller.Cancelling += dialogCotnroller_Cancelling; dialogCotnroller.ViewClosed += dialogCotnroller_ViewClosed; e.ActionArguments.ShowViewParameters.Controllers.Add(dialogCotnroller); } } }
public NonPersistentObjectSimpleFilteringAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.CustomCommitChanges += ObjectSpace_CustomCommitChanges; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; }
private void ObjectSpace_Committing(object sender, System.ComponentModel.CancelEventArgs e) { NonPersistentObjectSpace objectSpace = (NonPersistentObjectSpace)sender; using (IDbConnection conn = new SqlConnection("uid=sa;pwd=sa;Pooling=false;Data Source=.;Initial Catalog=SkyFaith")) { foreach (object obj in objectSpace.ModifiedObjects) { if (obj is BusinessObjects.NonPersistentObjects.Student) { if (objectSpace.IsNewObject(obj)) { conn.Execute("insert into student(Id,name,gender,phone) values(@Id,@name,@gender,@phone)", obj); } else if (objectSpace.IsDeletedObject(obj)) { conn.Execute("delete from student where Id = @Id", obj); } else { conn.Execute("update student set name=@name,gender=@gender,phone=@phone where Id=@Id", obj); } } } } }
public ObjectMap(NonPersistentObjectSpace objectSpace, params Type[] types) { this.objectSpace = objectSpace; this.typeMap = new Dictionary <Type, Dictionary <object, object> >(); foreach (var type in types) { typeMap.Add(type, new Dictionary <object, object>()); } }
public LiveSummaryAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; this.objectMap = new Dictionary <Guid, LiveSummary>(); objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.Reloaded += ObjectSpace_Reloaded; }
private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) { NonPersistentObjectSpace nonPersistentObjectSpace = e.ObjectSpace as NonPersistentObjectSpace; if (nonPersistentObjectSpace != null) { nonPersistentObjectSpace.ObjectsGetting += NonPersistentObjectSpace_ObjectsGetting; // Subscribe to NonPersistentObjectSpace events and customize its properties } }
public NonPersistentObjectAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; objectSpace.Reloaded += ObjectSpace_Reloaded; objectSpace.ObjectReloading += ObjectSpace_ObjectReloading; objectSpace.CustomCommitChanges += ObjectSpace_CustomCommitChanges; objectMap = new Dictionary <TKey, TObject>(); }
private void EnsureObjectSpaceForType(NonPersistentObjectSpace npos, Type type) { if (!npos.IsKnownType(type)) { if (!npos.AdditionalObjectSpaces.Any(os => os.IsKnownType(type))) { IObjectSpace persistentObjectSpace = application.CreateObjectSpace(type); npos.AdditionalObjectSpaces.Add(persistentObjectSpace); } } }
public TransientNonPersistentObjectAdapter(NonPersistentObjectSpace objectSpace, ObjectMap objectMap, NonPersistentObjectFactoryBase factory) { this.objectSpace = objectSpace; this.factory = factory; this.objectMap = objectMap; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; objectSpace.Reloaded += ObjectSpace_Reloaded; objectSpace.CustomCommitChanges += ObjectSpace_CustomCommitChanges; objectSpace.ObjectReloading += ObjectSpace_ObjectReloading; }
private void ObjectSpace_Disposed(object sender, EventArgs e) { NonPersistentObjectSpace objectSpace = sender as NonPersistentObjectSpace; objectSpace.ObjectsGetting -= ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting -= ObjectSpace_ObjectByKeyGetting; objectSpace.ObjectsCountGetting -= ObjectSpace_ObjectsCountGetting; objectSpace.ObjectGetting -= ObjectSpace_ObjectGetting; objectSpace.Committing -= ObjectSpace_Committing; additionalObjectSpace.Dispose(); additionalObjectSpace = null; }
public static void PutMCategory(NPCategory nPCategory, NonPersistentObjectSpace objectSpace) { var persistentObjectSpace = objectSpace.AdditionalObjectSpaces.FirstOrDefault(); using (var connect = MakeConnect(persistentObjectSpace)) { var category = connect.Categories.Find(nPCategory.Id); var part = connect.Parts.Find(nPCategory.PartId); category.MPart = part; connect.SaveChanges(); } }
public NonPersistentObjectSpaceExtender(NonPersistentObjectSpace objectSpace, List <BaseNonPersistentClass> globalObjects, IObjectSpace additionalObjectSpace) { this.globalObjects = globalObjects; this.additionalObjectSpace = additionalObjectSpace; if (objectSpace != null) { objectSpace.Committing += ObjectSpace_Committing; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; objectSpace.AdditionalObjectSpaces.Add(additionalObjectSpace); objectSpace.ObjectsCountGetting += ObjectSpace_ObjectsCountGetting; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.Disposed += ObjectSpace_Disposed; } }
public NonPersistentObjectSpaceExtender(NonPersistentObjectSpace objectSpace, GlobalObjectStorage globalObjects) { this.objectSpace = objectSpace; this.globalObjects = globalObjects; localObjects = new Dictionary <int, BaseNonPersistent>(); if (objectSpace == null) { return; } objectSpace.Committing += ObjectSpace_Committing; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; objectSpace.ObjectGetting += ObjectSpace_ObjectGetting; objectSpace.Reloaded += ObjectSpace_Reloaded; objectSpace.Disposed += ObjectSpace_Disposed; objectSpace.ObjectReloading += ObjectSpace_ObjectReloading; }
public void CreateDemoObjects() { if (ObjectSpace.CanInstantiate(typeof(Project))) { if (!ObjectSpace.CanInstantiate(typeof(Technology))) { var typesInfo = ObjectSpace.TypesInfo; var npos = new NonPersistentObjectSpace(typesInfo, ((DevExpress.ExpressApp.DC.TypesInfo)typesInfo).FindEntityStore(typeof(DevExpress.ExpressApp.DC.NonPersistentTypeInfoSource))); ((CompositeObjectSpace)ObjectSpace).AdditionalObjectSpaces.Add(npos); ((CompositeObjectSpace)ObjectSpace).AutoCommitAdditionalObjectSpaces = true; new NPTechnologyAdapter(npos); } CreateProjects(); CreateProducts(); CreateEpochs(); CreateDepartments(); } }
private void ObjectSpace_Committing(Object sender, CancelEventArgs e) { NonPersistentObjectSpace objectSpace = (NonPersistentObjectSpace)sender; foreach (Object obj in objectSpace.ModifiedObjects) { if (obj is BaseNonPersistentClass) { if (!globalObjects.Contains((BaseNonPersistentClass)obj)) { globalObjects.Add((BaseNonPersistentClass)obj); } else if (objectSpace.IsDeletedObject(obj)) { globalObjects.Remove((BaseNonPersistentClass)obj); } } } }
private void Application_ObjectSpaceCreated(Object sender, ObjectSpaceCreatedEventArgs e) { if (e.ObjectSpace is NonPersistentObjectSpace) { NonPersistentObjectSpace npos = (NonPersistentObjectSpace)e.ObjectSpace; if (basePersistentTypes != null) { foreach (var type in basePersistentTypes) { EnsureObjectSpaceForType(npos, type); } } npos.AutoDisposeAdditionalObjectSpaces = true; foreach (var adapterCreator in AdapterCreators) { adapterCreator.Invoke(npos); } } }
void ShowNavigationItemAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) { if (e.ShowViewParameters.CreatedView is ListView) { oldListView = (ListView)e.ShowViewParameters.CreatedView; NonPersistentObjectSpace nonPersistentObjectSpace = (NonPersistentObjectSpace)Application.CreateObjectSpace(typeof(ViewFilterContainer)); IObjectSpace persistentObjectSpace = Application.CreateObjectSpace(typeof(ViewFilterObject)); nonPersistentObjectSpace.AdditionalObjectSpaces.Add(persistentObjectSpace); ViewFilterContainer newViewFilterContainer = nonPersistentObjectSpace.CreateObject <ViewFilterContainer>(); newViewFilterContainer.ObjectType = oldListView.ObjectTypeInfo.Type; newViewFilterContainer.Filter = GetFilterObject(persistentObjectSpace, ((IModelListViewAdditionalCriteria)oldListView.Model).AdditionalCriteria, newViewFilterContainer.ObjectType); DetailView filterDetailView = Application.CreateDetailView(nonPersistentObjectSpace, newViewFilterContainer); filterDetailView.Caption = String.Format("Filter for the {0} ListView", oldListView.Caption); filterDetailView.ViewEditMode = ViewEditMode.Edit; e.ShowViewParameters.CreatedView = filterDetailView; e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; DialogController dialogCotnroller = Application.CreateController <DialogController>(); dialogCotnroller.Accepting += new EventHandler <DialogControllerAcceptingEventArgs>(dialogCotnroller_Accepting); dialogCotnroller.ViewClosed += dialogCotnroller_ViewClosed; e.ShowViewParameters.Controllers.Add(dialogCotnroller); } }
protected override void OnActivated() { base.OnActivated(); processCurrentObjectController = Frame.GetController <ListViewProcessCurrentObjectController>(); if (processCurrentObjectController != null) { processCurrentObjectController.CustomProcessSelectedItem += processCurrentObjectController_CustomProcessSelectedItem; } SearchableTypes = new List <Type>(); foreach (ModuleBase moduleBase in this.Application.Modules) { var IsIGetSuperSearchTypes = moduleBase as IGetSuperSearchTypes; if (IsIGetSuperSearchTypes != null) { SearchableTypes.AddRange(IsIGetSuperSearchTypes.GetSupperSearchTypes()); } } NonPersistentObjectSpace objectSpace = ((NonPersistentObjectSpace)this.View.CollectionSource.ObjectSpace); objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; }
public NPTechnologyAdapter(NonPersistentObjectSpace npos) : base(npos) { }
public static IObservable <(NonPersistentObjectSpace objectSpace, ObjectsGettingEventArgs e)> WhenObjectsGetting(this NonPersistentObjectSpace source) { return(Observable.Return(source).ObjectsGetting()); }
public NPGroupAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; objectSpace.ObjectByKeyGetting += ObjectSpace_ObjectByKeyGetting; }
private void ExecuteAction(IObjectSpace newFormOs, 单据 fromObject, FlowAction action) { //action数据是来自于 初始化按钮时的os,它可能不是当前objectspace action = ObjectSpace.GetObject(action); var os = new NonPersistentObjectSpace(null); var toType = ReflectionHelper.FindType(action.To.Form); #region 生成目标单据主表属性 单据 toObject = null; //查找当前单据是从那张单据生成过来的 var record = ObjectSpace.FindObject <单据流程状态记录>(CriteriaOperator.Parse("目标单据=?", CurrentObject.GetMemberValue("Oid").ToString())); if (action.目标类型 == 目标类型.生成单据) { toObject = newFormOs.CreateObject(toType) as 单据; } else if (action.目标类型 == 目标类型.更新单据) { var history = ObjectSpace.FindObject <单据流程状态记录>(CriteriaOperator.Parse("来源单据=? and 执行动作.Oid=?", CurrentObject.GetMemberValue("Oid").ToString(), action.Oid)); if (history != null) { //更新动作已经执行过了,不要再执行。 return; } //如果是更新单据,那必然是有已经生成过的单据。 if (record != null) { toObject = newFormOs.GetObject(record.来源单据); // newFormOs.GetObjectByStringKey(action.ToType, record.来源单据) as 单据; } else { return; } if (toObject == null) { return; } } var clsname = action.GetFlowLogicClassFullName(); var actionLogicType = ReflectionHelper.FindType(clsname); IExecuteFlowAction actionLogic = null; if (actionLogicType != null) { actionLogic = Activator.CreateInstance(actionLogicType) as IExecuteFlowAction; if (actionLogic != null) { actionLogic.ExecuteMasterCore(fromObject, toObject); } } #endregion #region 生成目标单据子表记录 var fromItems = fromObject.GetMemberValue("明细项目") as XPBaseCollection; var toItems = toObject.GetMemberValue("明细项目") as XPBaseCollection; var toItemType = toItems.GetObjectClassInfo().ClassType; //来源单据的明细,当前单据 var detailRecords = new List <Tuple <string, string> >(); foreach (XPBaseObject item in fromItems) { //查找记录? XPBaseObject toItem = null; if (action.目标类型 == 目标类型.更新单据) { //如果是更新单据(反写)时,没有找到反写目标明细,则继续。忽略当前条目。 //recs可以查到来源明细 // var recs = record.明细.FirstOrDefault(x => x.目标 == item.GetMemberValue("Oid").ToString()); toItem = (toObject.GetMemberValue("明细项目") as IList).OfType <BaseObject>().FirstOrDefault(x => x.Oid.ToString() == recs.来源); if (toItem == null) { continue; } } else if (action.目标类型 == 目标类型.生成单据) { toItem = newFormOs.CreateObject(toItemType) as XPBaseObject; } else { throw new Exception("未处理的目标类型!"); } toItems.BaseAdd(toItem); if (actionLogic != null) { actionLogic.ExecuteChildrenCore(item, toItem); } //foreach (var f in action.ItemsMapping) //{ // var fromValue = item.Evaluate(f.FromProperty.Name); // toItem.SetMemberValue(f.ToProperty.Name, fromValue); //} detailRecords.Add(new Tuple <string, string>(item.GetMemberValue("Oid").ToString(), toItem.GetMemberValue("Oid").ToString())); } #region 生成主表记录 EventHandler act = null; act = (snd, evt) => { newFormOs.Committed -= act; var process = ObjectSpace.CreateObject <单据流程状态记录>(); process.来源单据 = this.CurrentObject as 单据; process.目标单据 = this.ObjectSpace.GetObject(toObject); process.执行动作 = action; process.业务项目 = process.来源单据.业务项目; foreach (var item in detailRecords) { var det = ObjectSpace.CreateObject <单据流程记录明细>(); det.来源 = item.Item1; det.目标 = item.Item2; process.明细.Add(det); } ObjectSpace.CommitChanges(); }; newFormOs.Committed += act; #endregion #endregion if (action.自动保存) { newFormOs.CommitChanges(); } if (action.显示编辑界面) { var para = new ShowViewParameters(); para.CreatedView = Application.CreateDetailView(newFormOs, toObject, true); para.TargetWindow = TargetWindow.Default; Application.ShowViewStrategy.ShowView(para, new ShowViewSource(this.Frame, this.FlowToNext)); //e.ShowViewParameters.CreatedView = } }
public static IObservable <(NonPersistentObjectSpace objectSpace, ObjectsGettingEventArgs e)> WhenObjectsGetting(this NonPersistentObjectSpace item) { return(Observable.FromEventPattern <EventHandler <ObjectsGettingEventArgs>, ObjectsGettingEventArgs>(h => item.ObjectsGetting += h, h => item.ObjectsGetting -= h) .TransformPattern <ObjectsGettingEventArgs, NonPersistentObjectSpace>()); }
public NPFeatureAdapter(NonPersistentObjectSpace npos) : base(npos) { }
public static void AddPersistentOsToNonPersistentOs(XafApplication application, NonPersistentObjectSpace os, Type type) { var additionalObjectSpace = application.CreateObjectSpace(type); if (os.AdditionalObjectSpaces.Count == 0) { os.AdditionalObjectSpaces.Add(additionalObjectSpace); } }
public static void DisposeAdditionalPersistentObjectSpace(XafApplication application, NonPersistentObjectSpace os) { if (os.AdditionalObjectSpaces.Count <= 0) { return; } var additionalObjectSpace = os.AdditionalObjectSpaces.FirstOrDefault(); os.AdditionalObjectSpaces.Remove(additionalObjectSpace); additionalObjectSpace?.Dispose(); }
public NPAgentAdapter(NonPersistentObjectSpace npos) : base(npos) { }
public ArticleAdapter(NonPersistentObjectSpace npos) { this.objectSpace = npos; objectSpace.ObjectsGetting += ObjectSpace_ObjectsGetting; }
public NPResourceAdapter(NonPersistentObjectSpace npos) : base(npos) { }