private void ResetDataMembers() { _userID = null; _dataClient = null; _locationDevice = null; _displayConcurrentList = null; _zoneConcurrentList = null; }
private void SaveArchorInfoToXml(List <TModel.Location.AreaAndDev.Archor> archorList, LocationService service) { LocationDeviceList backUpList = new LocationDeviceList(); backUpList.DepList = new List <LocationDevices>(); foreach (var item in archorList) { if (item.DevInfo == null) { continue; } Area area = service.GetAreaById(item.ParentId); if (area == null) { Log.Info(string.Format("Error: Dev {0} area not find...", item.DevInfo.Id)); continue; } LocationDevices areaList = backUpList.DepList.Find(i => i.Name == area.Name); if (areaList == null) { areaList = new LocationDevices(); areaList.Name = area.Name; areaList.DevList = new List <LocationDevice>(); backUpList.DepList.Add(areaList); } if (areaList.DevList == null) { areaList.DevList = new List <LocationDevice>(); } LocationDevice dev = new LocationDevice(); dev.Name = item.Name; dev.Abutment_DevID = item.DevInfo.Abutment_DevID; dev.AnchorId = item.Code; dev.IP = item.Ip; dev.AbsolutePosX = item.X.ToString("f2"); dev.AbsolutePosY = item.Y.ToString("f2"); dev.AbsolutePosZ = item.Z.ToString("f2"); DevPos pos = item.DevInfo.Pos; if (pos != null) { dev.XPos = pos.PosX.ToString("f2"); dev.YPos = pos.PosY.ToString("f2"); dev.ZPos = pos.PosZ.ToString("f2"); } else { Log.Info("Error: dev.pos is null->" + item.DevInfo.Id); } areaList.DevList.Add(dev); } //string initFile = GetSaveDevDirectory() + "基站信息.xml"; //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8); SaveArchorDevXml("基站信息.xml", backUpList); }
private void MenuExportArchorData_Click(object sender, RoutedEventArgs e) { LocationDeviceList list = new LocationDeviceList(); list.DepList = new List <LocationDevices>(); Dictionary <int, List <Archor> > dict = new Dictionary <int, List <Archor> >(); Bll bll = new Bll(); var archorList = bll.Archors.ToList(); foreach (var item in archorList) { int pId = (int)item.ParentId; if (!dict.ContainsKey(pId)) { dict[pId] = new List <Archor>(); } dict[pId].Add(item); } foreach (var item in dict.Keys) { var area = bll.Areas.Find(item); var archors = dict[item]; LocationDevices devs = new LocationDevices(); devs.DevList = new List <LocationDevice>(); devs.Name = area.Name; list.DepList.Add(devs); foreach (var archor in archors) { var dev = new LocationDevice(); dev.AbsolutePosX = archor.X.ToString(); dev.AbsolutePosY = archor.Y.ToString(); dev.AbsolutePosZ = archor.Z.ToString(); dev.AnchorId = archor.Code; dev.IP = archor.Ip; dev.Name = archor.Name; dev.XPos = archor.DevInfo.PosX.ToString(); dev.YPos = archor.DevInfo.PosY.ToString(); dev.ZPos = archor.DevInfo.PosZ.ToString(); devs.DevList.Add(dev); } } string basePath = AppDomain.CurrentDomain.BaseDirectory; string filePath = basePath + "Data\\基站信息\\基站信息.xml"; XmlSerializeHelper.Save(list, filePath); FileInfo fi = new FileInfo(filePath); Process.Start(fi.Directory.FullName); }
/// <summary> /// 获取设备位置信息 /// </summary> /// <param name="locationDev"></param> /// <returns></returns> private static DevPos GetDevPos(LocationDevice locationDev, string devId) { DevPos pos = new DevPos(); pos.DevID = devId; pos.PosX = TryParseFloat(locationDev.XPos); pos.PosZ = TryParseFloat(locationDev.YPos); pos.PosY = TryParseFloat(locationDev.ZPos); pos.RotationX = 0; pos.RotationY = 0; pos.RotationZ = 0; pos.ScaleX = 1; pos.ScaleY = 1; pos.ScaleZ = 1; return(pos); }
public JsonResult LocationDevices(string id) { var query = Request.QueryString["action"]; if (Request.HttpMethod == "POST" && query == "arrived") { var keyArr = id.Split('_'); var key = $"{keyArr[0]}_{keyArr[1]}"; var hubContext = GlobalHost.ConnectionManager.GetHubContext <AgvMissonHub>(); hubContext.Clients.All.agvStateChange(id); var hubContext2 = GlobalHost.ConnectionManager.GetHubContext <NoticeHub>(); hubContext2.Clients.All.agvSignalChange(id); var eventBus = SimpleEventBus.GetDefaultEventBus(); eventBus.Post(new agvStateChange(id), TimeSpan.FromSeconds(1)); if (keyArr.Length >= 3) { hubContext2.Clients.All.agvOrderArrived(id); } return(Json(new { state = true, id = id }, JsonRequestBehavior.AllowGet)); } bool isArrived = true; if (StaticData.SignalDict.ContainsKey(id)) { isArrived = StaticData.SignalDict[id]; } var actionStatus = isArrived ? ActionStatus.DONE : ActionStatus.EXECUTING; var status = isArrived ? Status.IDLE : Status.EXECUTING; var node = new LocationDevice() { lastAction = query, name = id, lastActionStatus = Enum.Parse(typeof(ActionStatus), actionStatus.ToString(), false).ToString(), status = Enum.Parse(typeof(Status), status.ToString(), false).ToString() }; return(Json(node, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取基站信息 /// </summary> /// <param name="locationDev"></param> /// <param name="devID"></param> /// <returns></returns> private static Archor GetAnchorInfo(LocationDevice locationDev, string devID) { //new Archor() { Code = "85A4", Name = "基站1", X = 3000, Y = 870, Z = 200, Type = 0, IsAutoIp = true, Ip = "", ServerIp = "", ServerPort = 0, Power = 0, AliveTime = 0, Enable = 1 }; Archor archor = new Archor(); archor.Code = locationDev.AnchorId; archor.DevId = devID; archor.X = TryParseFloat(locationDev.XPos); archor.Y = TryParseFloat(locationDev.ZPos); archor.Z = TryParseFloat(locationDev.YPos); archor.Name = locationDev.Name; archor.Type = 0; archor.IsAutoIp = true; archor.Ip = ""; archor.ServerIp = ""; archor.ServerPort = 0; archor.Power = 0; archor.AliveTime = 0; archor.Enable = 1; return(archor); }
/// <summary> /// 获取基站信息 /// </summary> /// <param name="locationDev"></param> /// <param name="devID"></param> /// <returns></returns> private static Archor GetAnchorInfo(LocationDevice locationDev, int DevInfoId) { //new Archor() { Code = "85A4", Name = "基站1", X = 3000, Y = 870, Z = 200, Type = 0, IsAutoIp = true, Ip = "", ServerIp = "", ServerPort = 0, Power = 0, AliveTime = 0, Enable = 1 }; Archor archor = new Archor(); archor.Code = locationDev.AnchorId; archor.DevInfoId = DevInfoId; archor.X = TryParseFloat(locationDev.AbsolutePosX); archor.Y = TryParseFloat(locationDev.AbsolutePosY); archor.Z = TryParseFloat(locationDev.AbsolutePosZ); archor.Name = locationDev.Name; archor.Type = ArchorTypes.副基站; archor.IsAutoIp = true; archor.Ip = locationDev.IP; archor.ServerIp = ""; archor.ServerPort = 0; archor.Power = 0; archor.AliveTime = 0; archor.Enable = IsStart.是; return(archor); }
/// <summary> /// 获取设备信息 /// </summary> /// <param name="locationDev"></param> /// <param name="areaId"></param> /// <returns></returns> private static DevInfo GetDevInfo(LocationDevice locationDev, Area area) { DevInfo dev = new DevInfo(); dev.Local_DevID = Guid.NewGuid().ToString(); dev.IP = ""; dev.KKS = ""; dev.Name = locationDev.Name; dev.ModelName = area.Name == DepNames.FactoryName?TypeNames.ArchorOutdoor:TypeNames.Archor;//室外基站||室内基站 dev.Status = 0; dev.ParentId = area.Id; try { dev.Local_TypeCode = TypeCodes.Archor; } catch (Exception e) { dev.Local_TypeCode = 0; } dev.UserName = "******"; return(dev); }
public void LocationDeviceTest() { using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(LocationDevice.TableName); var profiles = db.LoadTimeBasedProfiles(); var realDevices = db.LoadRealDevices(out var deviceCategories, out var loadTypes, profiles); var locdevs = new ObservableCollection <LocationDevice>(); LocationDevice.LoadFromDatabase(locdevs, db.ConnectionString, realDevices, deviceCategories, loadTypes, false); (locdevs.Count).Should().Be(0); var locdev = new LocationDevice(null, realDevices[0], 1, db.ConnectionString, realDevices[0].Name, Guid.NewGuid().ToStrGuid()); locdev.SaveToDB(); LocationDevice.LoadFromDatabase(locdevs, db.ConnectionString, realDevices, deviceCategories, loadTypes, false); (locdevs.Count).Should().Be(1); db.Cleanup(); } }
/// <summary> /// Processes a Location /// </summary> /// <param name="location"></param> /// <returns></returns> private async Task AddLocationAysnc(Location location) { // Get the LocationDevice matching with the Location provided _locationDevice = await GetLocationDeviceFromLocationAsync(location); if (_locationDevice != null) { if (_locationDevice.Zone != null) { // Update the DisplayConcurrentList only if there is one or more than one DisplayEndpoints associated with the Zone if (_locationDevice.Zone.DisplayEndpoints?.Any() ?? false) { await UpdateDisplayConcurrentListAsync(); } // Update the ZoneConcurrentList await UpdateZoneConcurrentListAsync(); } } else { Context.Logger.LogLine("LocationDevice not found for the provided Location"); } }
/// <summary> /// 获取设备信息 /// </summary> /// <param name="locationDev"></param> /// <param name="areaId"></param> /// <returns></returns> private static DevInfo GetDevInfo(LocationDevice locationDev, int?areaId) { DevInfo dev = new DevInfo(); dev.DevID = Guid.NewGuid().ToString(); dev.IP = ""; dev.KKSCode = ""; dev.CreateTime = DateTime.Now; dev.ModifyTime = DateTime.Now; dev.Name = locationDev.Name; dev.ModelName = LocationDevModelName; dev.Status = 0; dev.ParentId = areaId; try { dev.TypeCode = int.Parse(LocationDevTypeCode); } catch (Exception e) { dev.TypeCode = 0; } dev.UserName = "******"; return(dev); }
/// <summary> /// Processes the input request /// </summary> /// <param name="request"></param> /// <returns></returns> private async Task <APIGatewayProxyResponse> ProcessRequestAsync(APIGatewayProxyRequest request) { APIGatewayProxyResponse response = new APIGatewayProxyResponse(); // Initialize DataClient Config.DataClientConfig dataClientConfig = new Config.DataClientConfig(Config.DataClientConfig.RdsDbInfrastructure.Aws); using (_dataClient = new DataClient(dataClientConfig)) { Location location = null; string locationSerialized = request?.Body; // Try to parse the provided json serialzed location into Location object try { location = JsonConvert.DeserializeObject <Location>(locationSerialized); location.LocatedAtTimestamp = location.LocatedAtTimestamp ?? DateTime.UtcNow; } catch (Exception ex) { Context.Logger.LogLine("Location deserialization ERROR: " + ex.Message); } // Validate the Location if (!(location == null || location.Type == LocationDeviceType.None || string.IsNullOrEmpty(location.DeviceID))) { // Check if corresponding LocationDevice exists in DB _locationDevice = await GetLocationDeviceFromLocationAsync(location); if (_locationDevice != null) { var notificationToReturn = await UpdateDisplayConcurrentListAsync(); // Exclude undesired properties from the returning json object var jsonResolver = new IgnorableSerializerContractResolver(); jsonResolver.Ignore(typeof(Notification), new string[] { "ClientSpot", "LocationDeviceNotifications", "DisplayEndpointNotifications", "Coupons" }); // Respond OK response.StatusCode = (int)HttpStatusCode.OK; response.Headers = new Dictionary <string, string>() { { "Access-Control-Allow-Origin", "'*'" } }; response.Body = JsonConvert.SerializeObject(notificationToReturn, jsonResolver.GetSerializerSettings()); } else { // Respond error Error error = new Error((int)HttpStatusCode.NotFound) { Description = "LocationDevice not found", ReasonPharse = "LocationDevice Not Found" }; response.StatusCode = error.Code; response.Body = JsonConvert.SerializeObject(error); Context.Logger.LogLine(error.Description); } } else { // Respond error Error error = new Error((int)HttpStatusCode.NotAcceptable) { Description = "Invalid Location input", ReasonPharse = "Not Acceptable Location" }; response.StatusCode = error.Code; response.Body = JsonConvert.SerializeObject(error); Context.Logger.LogLine(error.Description); } } return(response); }
private void ResetDataMembers() { _dataClient = null; _locationDevice = null; }
/// <summary> /// Seeds Configuration Data /// </summary> /// <param name="dataClientConfig"></param> /// <returns></returns> private async Task ConfigurationDataDemoAsync(Config.DataClientConfig dataClientConfig) { try { using (DataClient dataClient = new DataClient(dataClientConfig)) { if (dataClient.ConfigurationData != null) { ConfigurationData configurationData = dataClient.ConfigurationData; // Explicit loading. When the entity is first read, related data isn't retrieved. // Example code that retrieves the related data. It impacts retrieval performance hence only use if it's needed. await configurationData.Clients.Include(client => client.ClientSpots).LoadAsync(); await configurationData.ClientSpots.Include(clientSpot => clientSpot.Zones) .Include(clientSpot => clientSpot.LocationDevices) .Include(clientSpot => clientSpot.DisplayEndpoints) .Include(clientSpot => clientSpot.Notifications) .Include(clientSpot => clientSpot.Coupons).LoadAsync(); await configurationData.Zones.Include(zone => zone.LocationDevices) .Include(zone => zone.DisplayEndpoints).LoadAsync(); await configurationData.LocationDevices.Include(locationDevice => locationDevice.LocationDeviceNotifications).LoadAsync(); await configurationData.DisplayEndpoints.Include(displayEndpoint => displayEndpoint.DisplayEndpointNotifications).LoadAsync(); await configurationData.Notifications.Include(notification => notification.Coupons) .Include(notification => notification.LocationDeviceNotifications) .Include(notification => notification.DisplayEndpointNotifications).LoadAsync(); ///////// DB seeding with demo content ///////// // Look for any Clients if (configurationData.Clients.Any()) { string log = "Total Client found: " + configurationData.Clients.LongCount() + " | " + "Total ClientSpot found: " + configurationData.ClientSpots.LongCount() + " | " + "Total Zone found: " + configurationData.Zones.LongCount() + " | " + "Total LocationDevice found: " + configurationData.LocationDevices.LongCount() + " | " + "Total DisplayEndpoint found: " + configurationData.DisplayEndpoints.LongCount() + " | " + "Total Notification found: " + configurationData.Notifications.LongCount() + " | " + "Total Coupon found: " + configurationData.Coupons.LongCount() + " | " + "Total User found: " + configurationData.Users.LongCount(); Context.Logger.LogLine("[ConfigurationData Summary]"); Context.Logger.LogLine(log); return; // DB has been seeded already } // DB save operation Context.Logger.LogLine("[Adding contents for ConfigurationData]"); // Adding Clients var clients = new Client[] { new Client { Name = "Demo Mart", PhoneNumber = "001-123-4567", Address = "US" } }; foreach (Client client in clients) { configurationData.Clients.Add(client); } Context.Logger.LogLine("1 Client added"); // Adding ClientSpots var clientSpots = new ClientSpot[] { new ClientSpot { ClientID = clients[0].ClientID, Name = "DemoMart Seattle Store", PhoneNumber = "001-123-4567", Address = "Seattle, US" }, new ClientSpot { ClientID = clients[0].ClientID, Name = "DemoMart LA Store", PhoneNumber = "001-123-4567", Address = "LA, US" } }; foreach (ClientSpot clientSpot in clientSpots) { configurationData.ClientSpots.Add(clientSpot); } Context.Logger.LogLine("2 ClientSpots added"); // Adding Zones var zones = new Zone[] { new Zone { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Pseudo Zone" }, new Zone { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Entrance Zone (Scenario #1)" }, new Zone { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Bakery Zone (Scenario #2)" }, new Zone { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Electronics Zone (Scenario #3)" } }; foreach (Zone zone in zones) { configurationData.Zones.Add(zone); } Context.Logger.LogLine("4 Zones added"); // SAVING the changes into physical DB await configurationData.SaveChangesAsync(); // Adding LocationDevices var locationDevices = new LocationDevice[] { new LocationDevice { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[0].ZoneID, Type = LocationDeviceType.IBeacon, DeviceID = "pseudo-uuid" }, new LocationDevice { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[1].ZoneID, Type = LocationDeviceType.IBeacon, DeviceID = "11111111-1111-1111-1111-111111111111" }, new LocationDevice { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[2].ZoneID, Type = LocationDeviceType.IBeacon, DeviceID = "22222222-2222-2222-2222-222222222222" }, new LocationDevice { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[3].ZoneID, Type = LocationDeviceType.IBeacon, DeviceID = "33333333-3333-3333-3333-333333333333" }, new LocationDevice { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[3].ZoneID, Type = LocationDeviceType.IBeacon, DeviceID = "44444444-4444-4444-4444-444444444444" } }; foreach (LocationDevice locationDevice in locationDevices) { configurationData.LocationDevices.Add(locationDevice); } Context.Logger.LogLine("5 LocationDevices added"); // Adding DisplayEndpoints var displayEndpoints = new DisplayEndpoint[] { new DisplayEndpoint { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[0].ZoneID, Name = "Pseudo Display" }, new DisplayEndpoint { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[1].ZoneID, Name = "Demo Display 1" }, new DisplayEndpoint { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[2].ZoneID, Name = "Demo Display 2" }, new DisplayEndpoint { ClientSpotID = clientSpots[0].ClientSpotID, ZoneID = zones[3].ZoneID, Name = "Demo Display 3" } }; foreach (DisplayEndpoint displayEndpoint in displayEndpoints) { configurationData.DisplayEndpoints.Add(displayEndpoint); } Context.Logger.LogLine("4 DisplayEndpoints added"); // Adding Notifications var notifications = new Notification[] { new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Pseduo Notification", Timeout = 10, ContentMimeType = MimeType.ImagePng, ContentSubject = "Pseduo Notification", ContentCaption = "Pseduo advertisement", ContentBody = "http://www.abc.com/images/img1.png" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 1 (Scenario #1)", SortOrder = 1, Timeout = 20, ShowProgressBar = false, ContentMimeType = MimeType.ImagePng, ContentSubject = "Welcome Greetings", ContentCaption = "Welcome to DemoMart Seattle Store!", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/welcome.png" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 2 (Scenario #2)", SortOrder = 1, Timeout = 10, ContentMimeType = MimeType.ImageJpg, ContentSubject = "Advertisement for Doughnut", ContentCaption = "4 Delicious Doughnuts", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/doughnut.jpg" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 3 (Scenario #2)", SortOrder = 2, Timeout = 10, ContentMimeType = MimeType.ImageJpg, ContentSubject = "Advertisement for Croissant", ContentCaption = "Croissant for breakfast needs", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/croissant.jpg" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 4 (Scenario #2)", SortOrder = 3, Timeout = 10, ContentMimeType = MimeType.VideoMp4, ContentSubject = "Advertisement for Coke", ContentCaption = "Taste the Feeling", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/coke.mp4" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 5 (Scenario #3)", Timeout = 10, ContentMimeType = MimeType.ImageJpeg, ContentSubject = "Advertisement for Iron", ContentCaption = "Steam Iron", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/iron.jpeg" }, new Notification { ClientSpotID = clientSpots[0].ClientSpotID, Name = "Demo Notification 6 (Scenario #3)", Timeout = 10, ContentMimeType = MimeType.ImageJpeg, ContentSubject = "Advertisement for Smartphone", ContentCaption = "Extraordinary performance", ContentBody = "https://s3.amazonaws.com/hwconscious/notifications/demo_mart/smart-phone.jpeg" } }; foreach (Notification notification in notifications) { configurationData.Notifications.Add(notification); } Context.Logger.LogLine("7 Notifications added"); // SAVING the changes into physical DB await configurationData.SaveChangesAsync(); // Adding LocationDeviceNotifications var displayEndpointNotifications = new DisplayEndpointNotification[] { new DisplayEndpointNotification { DisplayEndpointID = displayEndpoints[0].DisplayEndpointID, NotificationID = notifications[0].NotificationID }, new DisplayEndpointNotification { DisplayEndpointID = displayEndpoints[1].DisplayEndpointID, NotificationID = notifications[1].NotificationID }, new DisplayEndpointNotification { DisplayEndpointID = displayEndpoints[2].DisplayEndpointID, NotificationID = notifications[2].NotificationID }, new DisplayEndpointNotification { DisplayEndpointID = displayEndpoints[2].DisplayEndpointID, NotificationID = notifications[3].NotificationID }, new DisplayEndpointNotification { DisplayEndpointID = displayEndpoints[2].DisplayEndpointID, NotificationID = notifications[4].NotificationID } }; foreach (DisplayEndpointNotification displayEndpointNotification in displayEndpointNotifications) { configurationData.DisplayEndpointNotifications.Add(displayEndpointNotification); } Context.Logger.LogLine("5 DisplayEndpointNotifications added"); // Adding LocationDeviceNotifications var locationDeviceNotifications = new LocationDeviceNotification[] { new LocationDeviceNotification { LocationDeviceID = locationDevices[3].LocationDeviceID, NotificationID = notifications[5].NotificationID }, new LocationDeviceNotification { LocationDeviceID = locationDevices[4].LocationDeviceID, NotificationID = notifications[6].NotificationID } }; foreach (LocationDeviceNotification locationDeviceNotification in locationDeviceNotifications) { configurationData.LocationDeviceNotifications.Add(locationDeviceNotification); } Context.Logger.LogLine("2 LocationDeviceNotifications added"); // Adding Coupons var coupons = new Coupon[] { new Coupon { ClientSpotID = clientSpots[0].ClientSpotID, NotificationID = notifications[0].NotificationID, Name = "Pseduo Coupon", CouponCode = "00000000000", Description = "Save $0.00", DiscountCents = 0.0 }, new Coupon { ClientSpotID = clientSpots[0].ClientSpotID, NotificationID = notifications[2].NotificationID, Name = "Doughnut Coupon", CouponCode = "09876543210", Description = "SAVE $1.99", DiscountCents = 199.0 }, new Coupon { ClientSpotID = clientSpots[0].ClientSpotID, NotificationID = notifications[3].NotificationID, Name = "Croissant Coupon", CouponCode = "92186293264", Description = "SAVE $0.49", DiscountCents = 49.0 }, new Coupon { ClientSpotID = clientSpots[0].ClientSpotID, NotificationID = notifications[4].NotificationID, Name = "Coke Coupon", CouponCode = "97294957293", Description = "SAVE $0.20", DiscountCents = 20.0 } }; foreach (Coupon coupon in coupons) { configurationData.Coupons.Add(coupon); } Context.Logger.LogLine("4 Coupons added"); // Adding Users var users = new User[] { new User { Type = UserType.Registered, Name = "Pseduo User", Email = "*****@*****.**" }, new User { Type = UserType.Registered, Name = "Demo User", Email = "*****@*****.**" }, new User { Type = UserType.Guest } }; foreach (User user in users) { configurationData.Users.Add(user); } Context.Logger.LogLine("3 Users added"); // SAVING the changes into physical DB await configurationData.SaveChangesAsync(); } } } catch (Exception ex) { Context.Logger.LogLine("ConfigurationData ERROR: " + ex.Message); } }