private void UpdateEnterpriseLocation(EnterpriseLocationModel enterpriseLocation) { if (enterpriseLocation != null) { Rp.ExecuteAction(() => { var dbEnterpriseLocation = (from el in ProxylessContext.EnterpriseLocations.Where(el2 => el2.IsActive) where el.PKID == enterpriseLocation.PKID select el).FirstOrDefault(); if (dbEnterpriseLocation != null) { dbEnterpriseLocation.Address1 = enterpriseLocation.Location != null ? enterpriseLocation.Location.Address1 : null; dbEnterpriseLocation.Address2 = enterpriseLocation.Location != null ? enterpriseLocation.Location.Address2 : null; dbEnterpriseLocation.City = enterpriseLocation.Location != null ? enterpriseLocation.Location.City : null; dbEnterpriseLocation.Country = enterpriseLocation.Location != null && enterpriseLocation.Location.Country != null ? enterpriseLocation.Location.Country.ISOCountryCode : null; dbEnterpriseLocation.Phone = enterpriseLocation.Phone; dbEnterpriseLocation.PhoneISOCountryCode = enterpriseLocation.PhoneISOCountryCode; dbEnterpriseLocation.State = enterpriseLocation.Location != null && enterpriseLocation.Location.State != null ? enterpriseLocation.Location.State.ISOStateCode : null; dbEnterpriseLocation.PostalCode = enterpriseLocation.Location != null ? enterpriseLocation.Location.PostalCode : null; } }); } }
public void CheckTimeOut(object Obj, EventArgs Args) { lock (_Clients) { List <ClientInfo> Infos = new List <ClientInfo>(); foreach (ClientInfo Info in _Clients.Values) { if (Info.Update()) { Infos.Add(Info); } } foreach (ClientInfo Info in Infos) { Log.Error("RpcServer", "Client disconnected : " + Info._Id); _Clients.Remove(Info._Id); foreach (ARpc Rp in _Rpcs) { Rp.Disconnected(Info._Id); } } } }
public SMSStockMessage SaveSMSStockMessage(int userId, SMSStockMessage message) { var result = RootRepository.HotelRepository.CheckHotelPermission(userId, message.FKHotel); if (result.Result == PermissionResults.Authorized) { if (message.PKID != 0) { var msg = Rp.ExecuteAction(() => ProxylessContext.SMSStockMessages.FirstOrDefault(m => m.PKID == message.PKID)); if (msg != null) { msg.Name = message.Name; msg.Text = message.Text; ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId)); return(msg); } } else { var msg = new SMSStockMessage { Name = message.Name, Text = message.Text, FKHotel = message.FKHotel }; ProxylessContext.SMSStockMessages.Add(msg); ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId)); return(msg); } } return(null); }
public void UpdateCategories(int deviceId, List <int> addCategoryIds, List <int> removeCategoryIds) { if (addCategoryIds != null || removeCategoryIds != null) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); if (addCategoryIds != null) { Rp.ExecuteAction(() => { addCategoryIds.ForEach(id => Context.HotelCategoryMaps.Add(new HotelCategoryMap() { CategoryMap = Context.CategoryMaps.FirstOrDefault(cm => cm.FKChildCategory == id && cm.FKParentCategory == null), FKDevice = deviceId })); Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); }); } if (removeCategoryIds != null) { DeleteHotelCategories(deviceId, removeCategoryIds); } } }
public HotelModel GetHotelFromDevice(int deviceId) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); var hotel = Rp.ExecuteAction(() => (from h in Context.Hotels let hd = h.HotelDetail where h.Devices.Select(d => d.PKID).Contains(deviceId) select new HotelModel { Location = new LocationModel { Address = hd.Address, City = hd.City, ISOCountryCode = hd.ISOCountryCode, Latitude = h.HotelDetail.Latitude, Longitude = h.HotelDetail.Longitude, PostalCode = hd.Zip, ISOStateCode = hd.State, }, Name = h.Name, PKID = h.PKID, RadiusInMiles = h.HotelDetail.Radius }).FirstOrDefault()); return(hotel); }
private void GenerateRpNode(HtmlDocument doc, HtmlNode parentDiv, Rp rp, bool solo = false) { var res = CreateDiv(doc, solo ? "rpw solo": "rpw", string.Empty); var link = doc.CreateElement("a"); link.SetAttributeValue("href", rp.Url); res.AppendChild(link); var titre = doc.CreateElement("span"); titre.AddClass("titreun"); titre.AppendChild(doc.CreateTextNode(rp.Titre)); link.AppendChild(titre); parentDiv.AppendChild(res); if (rp.Partenaires.Any()) { var participants = doc.CreateElement("i"); participants.AppendChildren(GenerateParticipantsNodes(doc, participants, rp)); res.AppendChild(participants); } if (rp.Type.HasValue) { res.AppendChild(CreateDiv(doc, "icon " + rp.Type.Value.GetDescription(), "")); } }
private void InsertTip(int deviceId, int userId, string tip, int?amenityId = null, int?enterpriseId = null, int?enterpriseLocationId = null) { Rp.ExecuteAction(() => { int?hotelId = Rp.ExecuteAction(() => (from d in Context.Devices.Where(d2 => d2.DeviceDetail.IsActive) where d.PKID == deviceId select d.FKHotel)).FirstOrDefault(); if (hotelId.HasValue) { var now = DateTime.Now; var insiderTip = new InsiderTip() { FKAmenity = amenityId, FKContactUser = userId, FKEnterprise = enterpriseId, FKEnterpriseLocation = enterpriseLocationId, FKHotel = hotelId, LastModifiedDateTime = now, FKLastModifiedContactUser = userId, Tip = tip, TipDateTime = now }; Context.InsiderTips.AddObject(insiderTip); } }); }
public UnitOfWork() { dormitoryContext = new DormitoryContext(); rp = new Rp(dormitoryContext); violationRecords = new ViolationRecordRepository(dormitoryContext); lateArrivals = new LateArrivalRepository(dormitoryContext); }
public void UpdateCategories(int deviceId, List <CategoryModel> categories) { if (categories != null) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); Rp.ExecuteAction(() => { HotelCategoryMap hotelCategoryMap; foreach (var category in categories) { hotelCategoryMap = (from hcm in Context.HotelCategoryMaps.Where(hcm2 => hcm2.IsActive == null || hcm2.IsActive) let cm = hcm.CategoryMap let c = cm.ChildCategory where hcm.FKDevice == deviceId && c != null && c.PKID == category.PKID select hcm).FirstOrDefault(); if (hotelCategoryMap != null) { hotelCategoryMap.Ordinal = category.Order; } } Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); }); } }
public void UpdateCategory(int deviceId, CategoryModel category) { if (category != null) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); Rp.ExecuteAction(() => { CategoryMap categoryMap = (from cm in Context.CategoryMaps.Where(cm2 => cm2.IsActive) where cm.FKChildCategory == category.PKID && cm.FKParentCategory == null select cm).FirstOrDefault(); if (categoryMap != null) { HotelCategoryMap hotelCategoryMap = (from hcm in Context.HotelCategoryMaps.Where(hcm2 => hcm2.IsActive) where hcm.FKDevice == deviceId && hcm.FKCategoryMap == categoryMap.PKID select hcm).FirstOrDefault(); if (hotelCategoryMap != null) { hotelCategoryMap.FKImage = category.Image.PKID; Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); } } }); } }
private void DeleteEnterpriseLocationRecommendation(int deviceId, int enterpriseId, int enterpriseLocationId, List <int> categoryIds) { if (categoryIds != null) { Rp.ExecuteAction(() => { var hotelBestOfEnterpriseLocationMaps = (from hboelm in ProxylessContext.HotelBestOfEnterpriseLocationMaps.Where(hboelm2 => hboelm2.HotelBestOfEnterpriseMap.IsActive) let hboem = hboelm.HotelBestOfEnterpriseMap where hboem.FKDevice == deviceId && hboem.EnterpriseCategoryMap.FKEnterprise == enterpriseId && hboelm.FKEnterpriseLocation == enterpriseLocationId && categoryIds.Contains(hboem.EnterpriseCategoryMap.CategoryMap.ChildCategory.PKID) select hboelm).ToList(); ProxylessContext.HotelBestOfEnterpriseLocationMaps.DeleteObjects(hotelBestOfEnterpriseLocationMaps); var hotelBestOfEnterpriseMap = (from hboem in ProxylessContext.HotelBestOfEnterpriseMaps.Where(hboem2 => hboem2.IsActive) where hboem.FKDevice == deviceId && hboem.EnterpriseCategoryMap.FKEnterprise == enterpriseId && !hboem.HotelBestOfEnterpriseLocationMaps.Any() select hboem).FirstOrDefault(); if (hotelBestOfEnterpriseMap != null) { ProxylessContext.HotelBestOfEnterpriseMaps.DeleteObject(hotelBestOfEnterpriseMap); } }); } }
public string GetJsonAnalyticParameters(int deviceId) { RootRepository.SecurityRepository.AssertDeviceAuthorization(deviceId); var device = RootRepository.DeviceRepository.GetDevice(deviceId); var requestCategories = Rp.ExecuteAction( () => ProxylessContext.RequestCategories.Where(x => x.FKHotel == device.FKHotel) .OrderBy(x => x.Ordinal) .Select( x => new { x.PKID, x.Name })).Distinct().OrderBy(x => x.Name).ToArray(); var requestTypes = Rp.ExecuteAction( () => ProxylessContext.RequestTypes.Where(x => x.FKHotel == device.FKHotel) .OrderBy(x => x.Ordinal) .Select(x => new { x.PKID, x.Name, x.FKRequestCategory })).Distinct().OrderBy(x => x.Name).ToArray(); var requestUsers = Rp.ExecuteAction( () => ProxylessContext.RequestGroups.Where(x => x.FKHotel == device.FKHotel) .SelectMany(x => x.RequestGroupUserMaps.Select(y => new { y.RequestUser.PKID, y.RequestUser.Name }))) .Distinct().OrderBy(x => x.Name) .ToArray(); return(new { RequestCategories = requestCategories, RequestTypes = requestTypes, RequestUsers = requestUsers, PKID = deviceId }.ToJSON()); }
private void UpdateEnterprise(EnterpriseModel enterprise) { var culture = MvcApplication.GetCurrentCulture(); var nativeLanguage = Monscierge.Utilities.Translation.GetLanguageFromCulture(culture); if (enterprise != null) { Rp.ExecuteAction(() => { var dbEnterprise = (from e in ProxylessContext.Enterprises.Where(e2 => e2.IsActive) where e.PKID == enterprise.PKID select e).FirstOrDefault(); if (dbEnterprise != null) { if (dbEnterprise.DescriptionLanguage.Equals(nativeLanguage, StringComparison.InvariantCultureIgnoreCase)) { dbEnterprise.Description = enterprise.Description; } else { dbEnterprise.LocalizedDescription = Localization.SetLocalizedText(dbEnterprise.LocalizedDescription, nativeLanguage, enterprise.Description); } dbEnterprise.FacebookUrl = enterprise.FacebookUrl; dbEnterprise.Name = enterprise.Name; dbEnterprise.TwitterUrl = enterprise.TwitterUrl; dbEnterprise.URL = enterprise.WebsiteUrl; } }); } }
public PermissionResult CheckDevicePermission(int userId, int deviceId) { var device = GetDevice(deviceId); if (device == null) { return(new PermissionResult(PermissionResults.InvalidObject, "The Device you are trying to access does not exist", new[] { new KeyValuePair <string, object>("deviceId", deviceId) } )); } var hasPermission = Rp.ExecuteAction(() => Context.GetDevicesForUser(userId).Select(ud => ud.PKID).Contains(deviceId)); if (hasPermission) { return new PermissionResult { Result = PermissionResults.Authorized } } ; return(RootRepository.SecurityRepository.IsSuperAdmin() ? new PermissionResult { Result = PermissionResults.Authorized } : new PermissionResult(PermissionResults.Unauthorized, "You are unauthorized to access this device.", new[] { new KeyValuePair <string, object>("deviceId", deviceId), })); }
public void InsertEnterpriseLocationBlacklist(int deviceId, int enterpriseLocationId) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); var enterpriseId = Rp.ExecuteAction(() => (from el in Context.EnterpriseLocations where el.PKID == enterpriseLocationId select el.FKEnterprise)).FirstOrDefault(); DeleteEnterpriseLocationRecommend(deviceId, enterpriseId, enterpriseLocationId); Rp.ExecuteAction(() => { var hotelId = (from d in Context.Devices.Where(d2 => d2.DeviceDetail.IsActive) where d.PKID == deviceId select d.FKHotel).FirstOrDefault(); var blacklistEnterpriseLocationMap = new BlackListEnterpriseLocationMap { FKEnterpriseLocation = enterpriseLocationId, FKHotel = hotelId }; Context.BlackListEnterpriseLocationMaps.AddObject(blacklistEnterpriseLocationMap); Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); }); }
public void Load() { foreach (ARpc Rp in _Server._Rpcs) { Log.Info("ClientInfo", "Loading of : " + Rp.GetType()); RemotingConfiguration.RegisterWellKnownServiceType(Rp.GetType(), Rp.GetType().Name + _Id + _Server._Key, WellKnownObjectMode.Singleton); } }
public IQueryable <SMSStockMessage> GetSMSStockMessages(int userId, int hotelId) { return (Rp.ExecuteAction( () => ProxylessContext.SMSStockMessages.Where( m => m.FKHotel == hotelId))); }
public Device GetDevice(int deviceId) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); var device = Rp.ExecuteAction(() => Context.Devices.FirstOrDefault(d => d.PKID == deviceId)); return(device); }
public List <Device> GetDevicesForUser(int contactUserId) { var devices = Rp.ExecuteAction(() => Context.GetDevicesForUser(contactUserId) .Include(x => x.Hotel) .Include(x => x.Hotel.HotelDetail).ToList()); return(devices); }
public List <ImageModel> GetCustomImages() { var currentUser = RootRepository.SecurityRepository.GetLoggedInUser(); return(Rp.ExecuteAction(() => (from ci in Context.Images where ci.IsActive && ci.FKAccount == currentUser.FKAccount && ci.FKAccount != null select ci)).ToList().Select(i => new ImageModel(i)).ToList()); }
public IQueryable <SMSStockMessage> GetSmsStockMessage(int userId, int messageId) { return (Rp.ExecuteAction( () => ProxylessContext.SMSStockMessages.Where( m => m.PKID == messageId))); }
public void InsertEnterpriseLocationTip(int deviceId, int userId, string tip, int enterpriseId, int enterpriseLocationId) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); InsertTip(deviceId, userId, tip, null, enterpriseId, enterpriseLocationId); Rp.ExecuteAction(() => Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId)); }
public IQueryable <MarketingCampaign> GetMarketingCampaign(int id) { return(Rp.ExecuteAction( () => ProxylessContext.MarketingCampaigns.Where( x => x.PKID == id) )); }
public int GetTodaysPostcardCount(int deviceId) { var count = Rp.ExecuteAction(() => Context.Postcards .Where(p => p.FKDevice == deviceId && p.SentDateTime >= DateTime.Today )).Count(); return(count); }
public override global::System.Data.DataSet Clone() { Rp cln = ((Rp)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public int GetTodaysRequestCount(int hotelId) { var count = Rp.ExecuteAction(() => Context.Requests .Where(r => r.RequestGroup.Hotel.PKID == hotelId && r.RequestActions.OrderBy(ra => ra.ActionTime).FirstOrDefault().ActionTime > DateTime.Today )).Count(); return(count); }
public IEnumerable <ReleaseNote> GetReleaseNotificationsForUser(int contactUserId) { var releaseNotes = Rp.ExecuteAction(() => (from r in Context.ReleaseNotes where r.ReleaseNoteContactUserReadMaps.All(m => m.FKContactUser != contactUserId) && r.NoteExpires > DateTime.Now orderby r.ReleaseDate descending select r)).ToList(); return(releaseNotes); }
public void MapMobileBackgroundImage(int deviceId, Image image) { RootRepository.SecurityRepository.AssertDeviceAuthorization(deviceId); var hotelDetail = Rp.ExecuteAction(() => (from d in ProxylessContext.Devices where d.PKID == deviceId select d.Hotel.HotelDetail)) .First(); hotelDetail.MobileBackgroundImage = image; ProxylessContext.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); }
public List <PostalCode> GetPostalCodes(string name) { var postalCodes = CacheManager.Get( "PostalCodes", () => Rp.ExecuteAction(() => (from pc in ProxylessContext.PostalCodes.Include(pc => pc.Country.States).Include(pc => pc.State) where pc.IsActive select pc))); return(postalCodes.Where(pc => pc.Name == name).ToList()); }
public List <MobileApp> SearchMobileApp(string searchText, string includes) { RootRepository.SecurityRepository.AssertSuperAdmin(); var mobileApps = Rp.ExecuteAction(() => { var h = ProxylessContext.MobileApps.Where(x => x.Name.ToLower().Contains(searchText.ToLower())); return(includes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Aggregate(h, (current, include) => current.Include(include))); }); return(mobileApps.ToList()); }