protected IObservable <Unit> TestObjects <T>(XafApplication application, bool parallel, int count = 100, int objectSpaceCount = 1, Action beforeSave = null) { if (parallel) { return(Observable.Range(1, count).SelectMany(i => Observable.Defer(() => Observable.Start(() => { for (int j = 0; j < objectSpaceCount; j++) { using var objectSpace = application.CreateObjectSpace(); objectSpace.CreateObject <T>(); beforeSave?.Invoke(); objectSpace.CommitChanges(); } })))); } return(Observable.Start(() => { for (int i = 0; i < objectSpaceCount; i++) { using var objectSpace = application.CreateObjectSpace(); for (int j = 0; j < count; j++) { objectSpace.CreateObject <T>(); beforeSave?.Invoke(); objectSpace.CommitChanges(); } } })); }
public WorkBook(IWorkbook workBook, IModelClass primaryBusinessObject, XafApplication application) { _workBook = workBook; _primaryBusinessObject = primaryBusinessObject; this.DataObjectSpace = application.CreateObjectSpace(); this.FunctionObjectSpace = application.CreateObjectSpace(); Application = application; }
public static ObjectView NewObjectView(this XafApplication application, Type viewType, Type objectType) { if (viewType == typeof(ListView)) { var listViewId = application.FindListViewId(objectType); var collectionSource = application.CreateCollectionSource(application.CreateObjectSpace(), objectType, listViewId); return(application.CreateListView((IModelListView)application.Model.Views[listViewId], collectionSource, true)); } var modelDetailView = application.Model.BOModel.GetClass(objectType).DefaultDetailView; return(application.CreateDetailView(application.CreateObjectSpace(), modelDetailView, true)); }
public static ImportDataDelegate <Agent> CreateCoolAgentImportDataFromXmlFileDelegate(XafApplication application) { IObjectSpace os1 = application.CreateObjectSpace(); SelectedData data = GetData(os1); return(delegate(IObjectSpace os, object[] args) { object masterObject = null; int index = 0; if (args != null) { if (args.Length == 2) { masterObject = args[0]; index = Convert.ToInt32(args[1]); } } foreach (var result in data.ResultSet) { if (index < result.Rows.Count()) { Agent agent = os.CreateObject <Agent>(); agent.Name = result.Rows[index].Values[0].ToString(); agent.Address = result.Rows[index].Values[1].ToString(); agent.Code = result.Rows[index].Values[2].ToString(); return agent; } } return null; }); }
public void MaybeFast(ReportExecution reportExecution, DetailView view, XafApplication applciation, bool showMeResult = false) { var objectSpace = applciation.CreateObjectSpace() as XPObjectSpace; var report = objectSpace.Session.Query <DoSoReport>().FirstOrDefault(); var xml = report?.Xml; if (!string.IsNullOrEmpty(xml)) { Workbook outDocument = null; var control = reportExecution.SpreadsheetControl; if (control.Document.MailMergeDataSource is SqlDataSource) { outDocument = ExportFromSqlDataSource(control.Document.MailMergeDataSource as SqlDataSource, control); } if (control.Document.MailMergeDataSource is ExcelDataSource) { outDocument = ExportFromExcelDataSource(control.Document.MailMergeDataSource as ExcelDataSource, control); } outDocument.Worksheets.RemoveAt(0); var fullName = Path.Combine(@"C:\Users\Beka\Desktop\New folder", HS.MyTempName + ".Xlsx"); outDocument.SaveDocument(fullName); if (showMeResult) { using (var sheetForm = new DoSoSheetFrom(false)) { sheetForm.spreadsheetControl1.LoadDocument(fullName); sheetForm.ShowDialog(); } } } }
public static ImportDataDelegate <Customer> CreateCoolCustomerImportDataFromXmlFileDelegate(XafApplication application) { IObjectSpace os1 = application.CreateObjectSpace(); SelectedData data = GetData(os1); return(delegate(IObjectSpace os, object[] args) { object masterObject = null; int index = 0; if (args != null) { if (args.Length == 2) { masterObject = args[0]; index = Convert.ToInt32(args[1]); } } foreach (var result in data.ResultSet) { if (index < result.Rows.Count()) { Customer customer = os.CreateObject <Customer>(); customer.Name = result.Rows[index].Values[0].ToString(); customer.Address = result.Rows[index].Values[1].ToString(); customer.Code = result.Rows[index].Values[2].ToString(); customer.CreditDays = Convert.ToInt32(result.Rows[index].Values[3]); customer.CreditLimit = Convert.ToDecimal(result.Rows[index].Values[4]); customer.ERPCode = result.Rows[index].Values[2].ToString(); return customer; } } return null; }); }
private static IObservable <View> CreateView(this XafApplication application, ExecuteActionJob job, IModelView modelView) => application.WhenViewCreating() .Select(t => { var objectType = modelView.AsObjectView.ModelClass.TypeInfo.Type; t.e.View = application.CreateView(job, modelView, application.CreateObjectSpace(objectType, true), objectType); return(t.e.View); }).FirstAsync().IgnoreElements();
public override void Setup(XafApplication application) { base.Setup(application); if (application != null && !DesignMode) { application.SettingUp += ApplicationOnSettingUp; application.SetupComplete += ApplicationOnSetupComplete; } Application.UserDifferencesLoaded += OnUserDifferencesLoaded; Application.CreateCustomUserModelDifferenceStore += ApplicationOnCreateCustomUserModelDifferenceStore; AddToAdditionalExportedTypes(typeof(ModelDifferenceObject).Namespace, GetType().Assembly); if (application is ServerApplication serverApplication) { if ((serverApplication is IModelDifferenceServerModels serverModels)) { serverApplication.SetupComplete += (sender, args) => { serverApplication.TypesInfo.RegisterEntity(typeof(XPObjectType)); using (var objectSpace = application.CreateObjectSpace()){ var modelDifferenceObjects = objectSpace.GetObjectsQuery <ModelDifferenceObject>(); foreach (var modelDifferenceObject in serverModels.Where(modelDifferenceObjects)) { modelDifferenceObject.GetModel((ModelApplicationBase)application.Model); } } LoadModels(); }; return; } throw new NotSupportedException($"Your {serverApplication.GetType().FullName} must implement the {nameof(IModelDifferenceServerModels)}"); } }
private static void OpenDetailView(XafApplication app) { IObjectSpace os = app.CreateObjectSpace(); //Find an existing object. //Contact obj = os.FindObject<Contact>(CriteriaOperator.Parse("FirstName=?", "My Contact")); //Or create a new object. Script obj = os.CreateObject <Script>(); obj.Name = "My Contact"; //Save the changes if necessary. //os.CommitChanges(); //Configure how our View will be displayed (all parameters except for the CreatedView are optional). ShowViewParameters svp = new ShowViewParameters(); DetailView dv = app.CreateDetailView(os, obj); dv.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit; svp.CreatedView = dv; //svp.TargetWindow = TargetWindow.NewModalWindow; //svp.Context = TemplateContext.PopupWindow; //svp.CreateAllControllers = true; //You can pass custom Controllers for intercommunication or to provide a standard functionality (e.g., functionality of a dialog window). //DialogController dc = Application.CreateController<DialogController>(); //svp.Controllers.Add(dc); // Show our View once the ShowViewParameters object is initialized. app.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); }
static void AddSystemConfigurationToValueManager(XafApplication application, ITypeInfo type) { var os = application.CreateObjectSpace(); IValueManager <Dictionary <string, object> > valueManager = ValueManager.GetValueManager <Dictionary <string, object> >("Values"); if (valueManager.CanManageValue) { valueManager.Value = null; } var systemConfig = os.FindObject(type.Type, null); if (systemConfig != null) { Dictionary <string, object> values = new Dictionary <string, object>(); foreach (var property in type.Members.Where(x => x.IsProperty)) { values.Add(property.Name, property.GetValue(systemConfig)); } valueManager = ValueManager.GetValueManager <Dictionary <string, object> >("Values"); if (valueManager.CanManageValue) { valueManager.Value = values; } } }
public static Task NewTask(this XafApplication application, TaskStatus taskStatus) { using var objectSpace = application.CreateObjectSpace(); var task = objectSpace.NewTask(taskStatus); objectSpace.CommitChanges(); return(task); }
public static Event NewEvent(this XafApplication application) { using var objectSpace = application.CreateObjectSpace(); var newEvent = objectSpace.NewEvent(); objectSpace.CommitChanges(); return(newEvent); }
public static DevExpress.Persistent.BaseImpl.Event NewEvent(this XafApplication application) { using var objectSpace = application.CreateObjectSpace(); var newEvent = objectSpace.NewEvent(); objectSpace.CommitChanges(); return(newEvent); }
private static ReactiveLoggerModule LoggerModule(XafApplication xafApplication) { var module = xafApplication.AddModule <ReactiveLoggerModule>(typeof(RL)); xafApplication.Logon(); xafApplication.CreateObjectSpace(); return(module.Application.Modules.OfType <ReactiveLoggerModule>().First()); }
private T createListViewController <T>(PersistentBase currentObject, bool activate, XPObjectSpace XPObjectSpace, HandleInfo handleInfo) where T : ViewController, new() { var controller = createController <T>(currentObject.GetType(), activate, XPObjectSpace, handleInfo); XafApplication application = controller.Application; Isolate.WhenCalled(() => application.CreateObjectSpace()).WillReturn(XPObjectSpace); return(controller); }
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 IObjectSpace CreateObjectSpace(Type type) { if (Application != null) { return(Application.CreateObjectSpace(type)); } return(null); }
internal static IObservable <T> DefaultPropertiesProvider <T>(this XafApplication application, Func <Document, IObservable <T> > factory) { var documentStyleManager = application.Model.DocumentStyleManager(); using var objectSpace = application.CreateObjectSpace(documentStyleManager.DefaultPropertiesProvider.TypeInfo.Type); var theObject = objectSpace.GetObjects(documentStyleManager.DefaultPropertiesProvider.TypeInfo.Type, objectSpace.ParseCriteria(documentStyleManager.DefaultPropertiesProviderCriteria)).Cast <object>().FirstOrDefault(); var value = (byte[])documentStyleManager.DefaultPropertiesProviderMember.MemberInfo.GetValue(theObject); return(Observable.Using(() => new RichEditDocumentServer(), server => factory(RichEditDocumentServerExtensions.LoadDocument(server, value)))); }
public static DetailView NewDetailView(this XafApplication application, object currentObject, IModelDetailView modelDetailView = null, bool isRoot = true) { var objectSpace = application.CreateObjectSpace(); modelDetailView ??= application.FindModelDetailView(currentObject.GetType()); var detailView = application.CreateDetailView(objectSpace, modelDetailView, isRoot); detailView.CurrentObject = objectSpace.GetObject(currentObject); return(detailView); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace newObjectSpace = application.CreateObjectSpace(); CollectionSourceBase collectionSource = application.CreateCollectionSource(newObjectSpace, type, ListViewId); DevExpress.ExpressApp.ListView lv = application.CreateListView(ListViewId, collectionSource, true); svp.CreatedView = lv; application.ShowViewStrategy.ShowView(svp, new ShowViewSource(application.MainWindow, null)); }
public static Employee GetEmployee(XafApplication Application) { Employee employee = null; if (SecuritySystem.CurrentUserId.ToString() != string.Empty) { employee = Application.CreateObjectSpace().GetObjectByKey <Employee>((Guid)SecuritySystem.CurrentUserId); } return(employee); }
protected void AssertNextSequences <T>(XafApplication application, int itemsCount, TestObserver <T> nextSequenceTest) where T : ISequentialNumber { nextSequenceTest.ItemCount.ShouldBe(itemsCount); using var space = application.CreateObjectSpace(); for (int i = 0; i < itemsCount; i++) { var item = nextSequenceTest.Items[i]; item.SequentialNumber.ShouldBe(i); space.GetObject(item).SequentialNumber.ShouldBe(i); } }
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 DashboardDataSourceWizardViewBase(ScriptDashboardWizardParameters parameters, IObjectSpace objectSpace, XafApplication application) { ObjectSpace = objectSpace; WizardParameters = parameters; Application = application; ParamsObjectSpace = application.CreateObjectSpace(); paramsView = CreateDetailView(ParamsObjectSpace); paramsView.CreateControls(); paramsView.LayoutManager.CustomizationEnabled = false; panelBaseContent.Controls.Add((XafLayoutControl)paramsView.LayoutManager.Container); }
// TODO: check if collectionsource is the right way to create list view public void ShowView(string listViewId) { var objSpace = _objSpace ?? _app.CreateObjectSpace(); _svp = new ShowViewParameters(); var collectionSource = new CollectionSource(objSpace, _objType); _svp.CreatedView = _app.CreateListView(listViewId, collectionSource, true); _svp.TargetWindow = TargetWindow.NewModalWindow; _svp.Context = TemplateContext.PopupWindow; _svp.CreateAllControllers = true; if (Accepting != null) { _dc.Accepting += DialogController_Accepting; } _svp.Controllers.Add(_dc); _app.ShowViewStrategy.ShowView(_svp, new ShowViewSource(null, null)); }
protected async Task <(DashboardViewItem listViewItem, DashboardViewItem detailViewItem)> ViewItems(XafApplication xafApplication) { var modelDashboardView = NewModelDashboardView(xafApplication); var masterDetailDashoardViewItems = MasterDetailService.MasterDetailDashboardViewItems.Replay(); masterDetailDashoardViewItems.Connect(); var dashboardView = xafApplication.CreateDashboardView(xafApplication.CreateObjectSpace(), modelDashboardView.Id, true); dashboardView.MockCreateControls(); var tuple = await masterDetailDashoardViewItems.FirstAsync(); return(tuple); }
private void CreateSampleData(XafApplication App) { var Os = App.CreateObjectSpace(); var Account = Os.CreateObject <SmtpEmailAccount>(); Account.SmtpPort = 25; Account.Name = AccountNamePort25; Account.Description = "Account using port 25 and not auth"; Account.EnableSSL = false; Account.SmtpServer = "localhost"; Account.UseUsernameAndPassword = false; Os.CommitChanges(); }
private void CreateRequest(string requestName, CancellationTokenSource ts) { var objSpace = application.CreateObjectSpace(); request = objSpace.CreateObject <ActionRequest>(); SetRequester(request); request.RequestName = requestName; request.RequestStatus = RequestStatus.Processing; request.CommitChanges(); request.SetCancellationTokenSource(ts); request.CommitChanges(); }
public override void SaveDifference(ModelApplicationBase model) { if (model != null) { _objectSpace = _application.CreateObjectSpace(typeof(ModelDifferenceObject)) as XPObjectSpace; ModelDifferenceObject modelDifferenceObject = GetActiveDifferenceObject(model.Id) ?? GetNewDifferenceObject(_objectSpace) .InitializeMembers(model.Id == "Application" ? Application.Title : model.Id, Application.Title, Application.GetType().FullName); OnDifferenceObjectSaving(modelDifferenceObject, model); } }
private void ReconcileForecastChoice(XafApplication app, View view) { var bankStmt = (BankStmt)view.CurrentObject; // reconcile specific statement line var objSpace = app.CreateObjectSpace(); // Show Cash flow View var dialog = new Xafology.ExpressApp.SystemModule.PopupDialogListViewManager(app, typeof(CashFlow), objSpace); dialog.Accepting += reconcileForecastDialog_Accepting; dialog.ShowView("CashFlow_LookupListView", CriteriaOperator.Parse("TranDate = ? And Status = ? And Account.Oid = ? And AccountCcyAmt = ?", bankStmt.TranDate, CashFlowStatus.Forecast, bankStmt.Account.Oid, bankStmt.TranAmount)); }
public override void Setup(){ base.Setup(); modelDifferenceModule = Isolate.Fake.Instance<ModelDifferenceBaseModule<XpoModelDictionaryDifferenceStore>>(); application = Isolate.Fake.Instance<XafApplication>(); Session session = Session.DefaultSession; using (RecorderManager.StartRecording()){ application.SetupComplete += null; } modelDifferenceModule.Setup(application); eventHandler = ((EventHandler<EventArgs>)RecorderManager.LastMockedEvent.GetEventHandle()); var objectSpace = Isolate.Fake.Instance<ObjectSpace>(); Isolate.WhenCalled(() => objectSpace.Session).WillReturn(session); Isolate.WhenCalled(() => application.CreateObjectSpace()).WillReturn(objectSpace); }
protected XpoDictionaryDifferenceStore(XafApplication application) { _application = application; _objectSpace = (XPObjectSpace)application.CreateObjectSpace(typeof(ModelDifferenceObject)); }
public XPObjectSpaceAwareControlInitializer(IXPObjectSpaceAwareControl control, XafApplication theApplication) : this(control, theApplication != null ? theApplication.CreateObjectSpace() : null) { }
protected XpoDictionaryDifferenceStore(XafApplication application) { _application = application; _objectSpace = application.CreateObjectSpace() as ObjectSpace; }
protected XpoDictionaryDifferenceStore(XafApplication application) { this.application = application; objectSpace = application.CreateObjectSpace(); }
public XPObjectSpaceAwareControlInitializer(IXPObjectSpaceAwareControl control, XafApplication theApplication) : this(control, theApplication != null ? theApplication.CreateObjectSpace(typeof(DashboardDefinition)) : null) { }