public async Task <IActionResult> Edit(int id, [Bind("Id,Fname,Lname,EmailId,EventId,Company,IndvDeadline,Position")] Ams ams) { if (id != ams.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ams); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AmsExists(ams.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Invitee", new { eid = ams.EventId })); } // return RedirectToAction(nameof(Index)); ams = await _context.Ams.Include(e => e.Event).FirstOrDefaultAsync(i => i.Id == id); return(View(ams)); }
/// <summary> /// Get the current routes /// </summary> /// <returns></returns> public IList<string> GetCurrentRoutes() { var amsSpecial = new Ams(ams.AmsSocket); amsSpecial.AmsNetIdSource = ams.AmsNetIdSource; amsSpecial.AmsNetIdTarget = ams.AmsNetIdTarget; amsSpecial.AmsPortTarget = 10000; bool ok = true; uint index = 0; var routes = new List<string>(); while (ok) { try { AdsReadCommand adsCommand = new AdsReadCommand(0x00000323, index++, 0x0800); var result = adsCommand.Run(amsSpecial); int length = result.Data.Length - 44; byte[] routeBytes = new byte[length]; Array.Copy(result.Data, 44, routeBytes, 0, length); string routeString = ByteArrayHelper.ByteArrayToString(routeBytes); int stringLlength = routeString.Length + 1; Array.Copy(routeBytes, stringLlength, routeBytes, 0, length - stringLlength); routeString += " " + ByteArrayHelper.ByteArrayToString(routeBytes); routes.Add(routeString); } catch (AdsException ex) { if (ex.ErrorCode == 1814) ok = false; else throw; } } return routes; }
public async Task <IActionResult> Edit(int id, [Bind("Fname,Lname,PassportName,Paname,Paemail,EmailId,EventId,EventGroupId,Company,UniqId,Patel,Atime,Adate,Dtime,Ddate,Id,AcityName,DcityName,IsRequired,OwnArrDate,OwnArrTime,OwnArrFlightNo,OwnDepDate,OwnDepTime,OwnDepFlightNo,HotelChkIn,HotelChkOut,IsVisaReq,DtSubmit,IsAttending,AttendingOpt,IsFollowupReq,IsHotelReq,Comments,IsTransferReq,Tempemail,ObflightNo,Obdate,Obetd,Obeta,Obclass,InflightNo,Indate,Inetd,Ineta,Inclass,Obsec,Insec,AirTktFileName,IsNew,IsVisaReqOpt,VisaFileName,City,Starter,Grill,Dessert,DtModified,NoOfCoAttendee,FdAllergy,AlleryDesc,AgendaFileName,IcsFileName,IndvDeadline,Position,ActualAttendance")] Ams ams) { if (id != ams.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ams); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AmsExists(ams.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.EventMaster, "EventId", "EventName", ams.EventId); return(View(ams)); }
protected override void RunAfter(Ams ams) { var notification = ams.NotificationRequests.FirstOrDefault(n => n.NotificationHandle == notificationHandle); if (notification != null) { ams.NotificationRequests.Remove(notification); } }
protected T Run <T>(Ams ams) where T : AdsCommandResponse { RunBefore(ams); var result = ams.RunCommand <T>(this); if (result.AdsErrorCode > 0) { throw new AdsException(result.AdsErrorCode); } RunAfter(ams); return(result); }
/// <summary> /// Get an xml description of the plc /// You can use XDocument.Parse(xml).ToString() to make the xml more readable /// </summary> /// <returns></returns> public string GetTargetDesc() { var amsSpecial = new Ams(ams.AmsSocket); amsSpecial.AmsNetIdSource = ams.AmsNetIdSource; amsSpecial.AmsNetIdTarget = ams.AmsNetIdTarget; amsSpecial.AmsPortTarget = 10000; AdsReadCommand adsCommand = new AdsReadCommand(0x000002bc, 0x00000001, 4); var result = adsCommand.Run(amsSpecial); uint length = BitConverter.ToUInt32(result.Data, 0); adsCommand = new AdsReadCommand(0x000002bc, 0x00000001, length); result = adsCommand.Run(amsSpecial); string xml = ByteArrayHelper.ByteArrayToString(result.Data); return xml; }
public void DeleteAms(Ams _entity) { if (_entity == null || !_entity.IsValid) { new ArgumentNullException("Ams"); } using (var _databaseContext = new DatabaseContext()) { _databaseContext.Amss.Attach(_entity); _databaseContext.Amss.Remove(_entity); _databaseContext.SaveChanges(); } }
public int AddOrUpdateAms(Ams _entity) { if (_entity == null || !_entity.IsValid) { new ArgumentNullException("Ams"); } using (var _databaseContext = new DatabaseContext()) { _entity = _databaseContext.UpdateGraph(_entity, map => map.AssociatedCollection(a => a.Users).AssociatedCollection(a => a.Pagers)); _databaseContext.SaveChanges(); return(_entity.Id); } }
public async Task <ActionResult> Invitee_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Ams> ams) { // Will keep the inserted entitites here. Used to return the result later. var entities = new List <Ams>(); if (ModelState.IsValid) { foreach (var Invitee in ams) { // Create a new Product entity and set its properties from the posted ProductViewModel. var entity = new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = Invitee.EventGroupId }; // Store the entity for later use. entities.Add(entity); // Attach the entity. _context.Ams.Attach(entity); // Change its state to Modified so Entity Framework can update the existing product instead of creating a new one. _context.Entry(entity).State = EntityState.Modified; // Or use ObjectStateManager if using a previous version of Entity Framework. // northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); } // Update the entities in the database. _context.SaveChanges(); } // Return the updated entities. Also return any validation errors. return(Json(await entities.ToDataSourceResultAsync(request, ModelState, Invitee => new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = Invitee.EventGroupId }))); }
/// <summary> /// Get an xml description of the plc /// You can use XDocument.Parse(xml).ToString() to make the xml more readable /// </summary> /// <returns></returns> public string GetTargetDesc() { var amsSpecial = new Ams(ams.AmsSocket); amsSpecial.AmsNetIdSource = ams.AmsNetIdSource; amsSpecial.AmsNetIdTarget = ams.AmsNetIdTarget; amsSpecial.AmsPortTarget = 10000; AdsReadCommand adsCommand = new AdsReadCommand(0x000002bc, 0x00000001, 4); var result = adsCommand.Run(amsSpecial); uint length = BitConverter.ToUInt32(result.Data, 0); adsCommand = new AdsReadCommand(0x000002bc, 0x00000001, length); result = adsCommand.Run(amsSpecial); string xml = ByteArrayHelper.ByteArrayToString(result.Data); return(xml); }
public async Task <ActionResult> Invitee_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Ams> ams) { // Will keep the inserted entitites here. Used to return the result later. var entities = new List <Ams>(); if (ModelState.IsValid) { foreach (var Invitee in ams) { // Create a new Product entity and set its properties from the posted ProductViewModel. var entity = new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position }; // Store the entity for later use. entities.Add(entity); // Attach the entity. _context.Ams.Attach(entity); // Delete the entity. _context.Ams.Remove(entity); // Or use DeleteObject if using a previous versoin of Entity Framework. // northwind.Products.DeleteObject(entity); } // Delete the entity in the database. _context.SaveChanges(); } // Return the destroyed entities. Also return any validation errors. return(Json(await entities.ToDataSourceResultAsync(request, ModelState, Invitee => new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = Invitee.EventGroupId }))); }
/// <summary> /// Get the current routes /// </summary> /// <returns></returns> public IList <string> GetCurrentRoutes() { var amsSpecial = new Ams(ams.AmsSocket); amsSpecial.AmsNetIdSource = ams.AmsNetIdSource; amsSpecial.AmsNetIdTarget = ams.AmsNetIdTarget; amsSpecial.AmsPortTarget = 10000; bool ok = true; uint index = 0; var routes = new List <string>(); while (ok) { try { AdsReadCommand adsCommand = new AdsReadCommand(0x00000323, index++, 0x0800); var result = adsCommand.Run(amsSpecial); int length = result.Data.Length - 44; byte[] routeBytes = new byte[length]; Array.Copy(result.Data, 44, routeBytes, 0, length); string routeString = ByteArrayHelper.ByteArrayToString(routeBytes); int stringLlength = routeString.Length + 1; Array.Copy(routeBytes, stringLlength, routeBytes, 0, length - stringLlength); routeString += " " + ByteArrayHelper.ByteArrayToString(routeBytes); routes.Add(routeString); } catch (AdsException ex) { if (ex.ErrorCode == 1814) { ok = false; } else { throw; } } } return(routes); }
public SettingsAmsViewModel(IBusiness _business, int _id) { try { business = _business; //Query lists for selection UserList = new ObservableCollection <User>(business.GetAllUserAsync().Result); PagerList = new ObservableCollection <Pager>(business.GetAllPagerAsync().Result); //Query item with relations ams = business.GetAmsById(_id); if (ams == null) { ams = new Ams(); } //Do selection from list } catch (Exception ex) { Logger.WriteError(MethodBase.GetCurrentMethod(), ex); } }
public Task<AdsReadStateCommandResponse> RunAsync(Ams ams) { return RunAsync<AdsReadStateCommandResponse>(ams); }
protected virtual void RunAfter(Ams ams) { }
protected virtual void RunBefore(Ams ams) { }
public AdsWriteCommandResponse Run(Ams ams) { return(Run <AdsWriteCommandResponse>(ams)); }
internal AdsSpecial(Ams ams) { this.ams = ams; }
public AdsReadStateCommandResponse Run(Ams ams) { return Run<AdsReadStateCommandResponse>(ams); }
public async Task <ActionResult> Invitee_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Ams> ams) { var entities = new List <Ams>(); try { // Will keep the inserted entitites here. Used to return the result later. if (ModelState.IsValid) { foreach (var Invitee in ams) { // Create a new Product entity and set its properties from the posted ProductViewModel. var entity = new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = GetNextGroupID(Invitee.EventId) == null ? 1 : (short?)(GetNextGroupID(Invitee.EventId) + 1) }; // Add the entity. _context.Ams.Add(entity); // Store the entity for later use. entities.Add(entity); } // Insert the entities in the database. _context.SaveChanges(); //} } // Return the inserted entities. The Grid needs the generated ProductID. Also return any validation errors. return(Json(await entities.ToDataSourceResultAsync(request, ModelState, Invitee => new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = Invitee.EventGroupId }))); } catch (Exception e) { //********************************* // // https://stackoverflow.com/questions/17790107/how-to-return-modelstate-errors-to-kendo-grid-in-mvc-web-api-post-method // //**************************** var messageSplit = e.InnerException.Message.Split("("); var messageToClient = ""; if (e.InnerException.Message.ToLower().Contains("unique key constraint")) { messageToClient = "Please remove duplicate email " + messageSplit[1].Split(",")[0] + " and click 'Save Changes' "; } else { messageToClient = e.InnerException.Message; } ModelState.AddModelError(string.Empty, messageToClient); // Return the inserted entities. The Grid needs the generated ProductID. Also return any validation errors. return(Json(await entities.ToDataSourceResultAsync(request, ModelState, Invitee => new Ams { Fname = Invitee.Fname, Lname = Invitee.Lname, EmailId = Invitee.EmailId, Position = Invitee.Position, IndvDeadline = Invitee.IndvDeadline, Company = Invitee.Position, EventGroupId = Invitee.EventGroupId }))); } }
public Task <AdsAddDeviceNotificationCommandResponse> RunAsync(Ams ams) { return(RunAsync <AdsAddDeviceNotificationCommandResponse>(ams)); }
public AdsAddDeviceNotificationCommandResponse Run(Ams ams) { return(Run <AdsAddDeviceNotificationCommandResponse>(ams)); }
public Task <AdsReadDeviceInfoCommandResponse> RunAsync(Ams ams) { return(RunAsync <AdsReadDeviceInfoCommandResponse>(ams)); }
public async Task<AdsReadDeviceInfoCommandResponse> RunAsync(Ams ams) { return await RunAsync<AdsReadDeviceInfoCommandResponse>(ams); }
public Task<AdsAddDeviceNotificationCommandResponse> RunAsync(Ams ams) { return RunAsync<AdsAddDeviceNotificationCommandResponse>(ams); }
protected override void RunBefore(Ams ams) { ams.NotificationRequests.Add(Notification); }
public Task <AdsReadStateCommandResponse> RunAsync(Ams ams) { return(RunAsync <AdsReadStateCommandResponse>(ams)); }
public AdsAddDeviceNotificationCommandResponse Run(Ams ams) { return Run<AdsAddDeviceNotificationCommandResponse>(ams); }
public Task <AdsWriteReadCommandResponse> RunAsync(Ams ams) { return(RunAsync <AdsWriteReadCommandResponse>(ams)); }
public AdsReadDeviceInfoCommandResponse Run(Ams ams) { return Run<AdsReadDeviceInfoCommandResponse>(ams); }
public AdsReadCommandResponse Run(Ams ams) { return(Run <AdsReadCommandResponse>(ams)); }
public AdsReadDeviceInfoCommandResponse Run(Ams ams) { return(Run <AdsReadDeviceInfoCommandResponse>(ams)); }
protected override void RunAfter(Ams ams) { var notification = ams.NotificationRequests.FirstOrDefault(n => n.NotificationHandle == notificationHandle); if (notification != null) ams.NotificationRequests.Remove(notification); }
public async Task<AdsDeleteDeviceNotificationCommandResponse> RunAsync(Ams ams) { return await RunAsync<AdsDeleteDeviceNotificationCommandResponse>(ams); }
public Task<AdsWriteReadCommandResponse> RunAsync(Ams ams) { return RunAsync<AdsWriteReadCommandResponse>(ams); }
public AdsWriteReadCommandResponse Run(Ams ams) { return Run<AdsWriteReadCommandResponse>(ams); }
public async Task<AdsWriteCommandResponse> RunAsync(Ams ams) { return await RunAsync<AdsWriteCommandResponse>(ams); }