-
Notifications
You must be signed in to change notification settings - Fork 1
/
Updater.cs
55 lines (53 loc) · 2.83 KB
/
Updater.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Dashboards;
using DevExpress.ExpressApp.Updating;
using DevExpress.Persistent.BaseImpl;
using System;
using System.Reflection;
using ShowDetailViewFromDashboard.Module.BusinessObjects;
namespace ShowDetailViewFromDashboard.Module.DatabaseUpdate {
public class Updater : ModuleUpdater {
public Updater(IObjectSpace objectSpace, Version currentDBVersion) :
base(objectSpace, currentDBVersion) {
}
public override void UpdateDatabaseAfterUpdateSchema() {
base.UpdateDatabaseAfterUpdateSchema();
Contact contactMary = ObjectSpace.FindObject<Contact>(CriteriaOperator.Parse("FirstName == 'Mary' && LastName == 'Tellitson'"));
if(contactMary == null) {
contactMary = ObjectSpace.CreateObject<Contact>();
contactMary.FirstName = "Mary";
contactMary.LastName = "Tellitson";
contactMary.Email = "mary_tellitson@md.com";
contactMary.Birthday = new DateTime(1980, 11, 27);
}
Contact contactJohn = ObjectSpace.FindObject<Contact>(CriteriaOperator.Parse("FirstName == 'John' && LastName == 'Nilsen'"));
if(contactJohn == null) {
contactJohn = ObjectSpace.CreateObject<Contact>();
contactJohn.FirstName = "John";
contactJohn.LastName = "Nilsen";
contactJohn.Email = "john_nilsen@md.com";
contactJohn.Birthday = new DateTime(1981, 10, 3);
}
Contact contactAndrew = ObjectSpace.FindObject<Contact>(CriteriaOperator.Parse("FirstName == 'Andrew' && LastName == 'Fuller'"));
if(contactAndrew == null) {
contactAndrew = ObjectSpace.CreateObject<Contact>();
contactAndrew.FirstName = "Andrew";
contactAndrew.LastName = "Fuller";
contactAndrew.Email = "andrewfuller@example.com";
contactAndrew.Birthday = new DateTime(1952, 3, 19);
}
Contact contactRobert = ObjectSpace.FindObject<Contact>(CriteriaOperator.Parse("FirstName == 'Robert' && LastName == 'King'"));
if(contactRobert == null) {
contactRobert = ObjectSpace.CreateObject<Contact>();
contactRobert.FirstName = "Robert";
contactRobert.LastName = "King";
contactRobert.Email = "robertking@example.com";
contactRobert.Birthday = new DateTime(1975, 4, 25);
}
Assembly assembly = Assembly.GetExecutingAssembly();
DashboardsModule.AddDashboardDataFromResources<DashboardData>(ObjectSpace, "Contacts", assembly, "ShowDetailViewFromDashboard.Module.Dashboards.Contacts.xml");
ObjectSpace.CommitChanges();
}
}
}