private void ReportResults(IntegratorUser integratorUser, IHasId <Guid> jobPoster, Report report) { const string method = "ReportResults"; _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportPostEvent { Success = true, IntegratorUserId = integratorUser.Id, PosterId = jobPoster.Id, JobAds = report.JobAds, Closed = report.Closed, Duplicates = report.Duplicates, Failed = report.Failed, Posted = report.Posted, Updated = report.Updated, Ignored = report.Ignored, }); var message = string.Format("Processing complete. {0} job ads created, {1} updated," + " {2} closed, {3} failed, {4} were ignored as duplicates of those from another source," + " {5} were ignored as coming from the ignored source.", report.Posted, report.Updated, report.Closed, report.Failed, report.Duplicates, report.Ignored); _logger.Raise(Event.Information, method, message); }
private void SaveSearch(IHasId <Guid> employer, MemberSearchCriteria criteria, CandidatesResponseModel model, int page) { try { var userAgent = HttpContext.Request.UserAgent; //never log monitoring calls if (!string.IsNullOrEmpty(userAgent) && userAgent.Contains("LinkmeMonitoring")) { return; } var app = ActivityContext.Channel.App; var execution = new MemberSearchExecution { Context = "NewSearch", Criteria = criteria.Clone(), Results = new MemberSearchResults { MemberIds = page == 1 ? (from c in model.Candidates select c.Id).ToArray() : new Guid[0], TotalMatches = model.TotalCandidates }, SearcherId = employer == null ? (Guid?)null : employer.Id, ChannelId = app.ChannelId, AppId = app.Id, StartTime = DateTime.Now, }; _memberSearchesCommand.CreateMemberSearchExecution(execution); } catch (Exception) { // Never fail for this. } }
private JobAdSortExecution Sort(IHasId <Guid> member, JobAdSearchSortCriteria sortCriteria, Range range, Func <IJobAdSortService, Guid?, JobAdSortQuery, JobAdSearchResults> sort) { var criteria = new JobAdSortCriteria { SortCriteria = sortCriteria }; JobAdSearchResults results; var service = _serviceManager.Create(); try { results = sort(service, member == null ? (Guid?)null : member.Id, criteria.GetSortQuery(range)); } catch (Exception) { _serviceManager.Abort(service); throw; } _serviceManager.Close(service); return(new JobAdSortExecution { Criteria = criteria, Results = results, }); }
protected void HasAccessToItemAndThrow(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user) { if (!this.HasAccessToItem(ruleType, storeItem, user)) { throw new StoreSecurityException(storeItem, user, ruleType); } }
private ResumeFileModel GetLastUsedResumeFile(IHasId <Guid> member) { if (member == null) { return(null); } var resumeFile = _candidateResumeFilesQuery.GetLastUsedResumeFile(member.Id); if (resumeFile == null) { return(null); } var fileReference = _filesQuery.GetFileReference(resumeFile.FileReferenceId); if (fileReference == null) { return(null); } return(new ResumeFileModel { FileReferenceId = resumeFile.FileReferenceId, FileName = fileReference.FileName, }); }
private ResourceListModel <TResource> GetResourceListModel <TResource>(IHasId <Guid> user, ResourceListModel <TResource> model) where TResource : Resource { if (user is Member) { var candidate = _candidatesQuery.GetCandidate(user.Id); var resume = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value); model.ResumePercentComplete = _memberStatusQuery.GetPercentComplete(CurrentMember, candidate, resume); model.HasResume = HasResume(candidate); } else { model.ResumePercentComplete = 0; model.HasResume = false; } model.TopRatedArticle = _resourcesQuery.GetTopRatedArticle(); model.TopViewedQnA = _resourcesQuery.GetTopViewedQnA(); // Set the data for all resources in the model. model.Viewings = GetViewings(model); model.LastViewedTimes = GetLastViewedTimes(model); model.Ratings = GetRatings(user.Id, model); model.Comments = GetComments(model); return(model); }
public void Build(object obj) { A4ormObject returnValue = new A4ormObject(); if (obj is IHasId) { IHasId iHasId = obj as IHasId; returnValue.Id = iHasId.Id; } else { //autogen id returnValue.Id = Guid.NewGuid().ToString(); } //walk the object var meta = TypeMetaCache.Instance.GetTypeMeta(obj.GetType()); meta.Properties.WithEach(propMeta => { A4ormProperty prop = new A4ormProperty(); prop.Type = propMeta.Type; }); var inspector = ObjectInspectorCache.Instance.GetInspector(obj.GetType()); return(returnValue); }
public NamedValueIHasIdDecoration(IHasId decorated, string name, object val) : base(decorated) { Condition.Requires(name).IsNotNullOrEmpty(); this.Name = name; this.Value = val; }
/// <summary> /// Compares navigational properties of two models defined by a foreign key property. These nagivational properties must implement IHasId interface and cannot be lists and collections. TODO: improve this method so that an actual navigational property is selected, not its foreign key /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="model1"></param> /// <param name="model2"></param> /// <param name="foreignKey"></param> /// <returns></returns> public static bool CompareNagivationalProperties <TModel>(TModel model1, TModel model2, Expression <Func <TModel, int?> > foreignKey) where TModel : class { if (foreignKey == null) { throw new ArgumentNullException("foreignKey may not be null whereas it is null now"); } MemberExpression mex = (MemberExpression)foreignKey.Body; PropertyInfo fkProperty = (PropertyInfo)mex.Member; ForeignKeyAttribute attr = fkProperty.GetCustomAttribute(typeof(ForeignKeyAttribute)) as ForeignKeyAttribute; if (attr == null) { throw new ArgumentException("foreignKey property does not contain ForeignKey attribute"); } int?key1 = fkProperty.GetValue(model1) as int?; int?key2 = fkProperty.GetValue(model2) as int?; if (key1 != key2) { return(false); } else if (key1 == null && key2 == null) { PropertyInfo property = typeof(TModel).GetProperty(attr.Name); IHasId val1 = property.GetValue(model1) as IHasId; IHasId val2 = property.GetValue(model2) as IHasId; if (val1?.Id != val2?.Id) { return(false); } } return(true); }
public static PolyfacingIHasIdDecoration <Tface> Polyfacing <Tface>(this IHasId decorated, Polyface rootFace = null) where Tface : IHasId { Condition.Requires(decorated).IsNotNull(); PolyfacingIHasIdDecoration <Tface> rv = null; /*Summary: * if we spec a root we are setting that root * if the condition is already polyfacing we use that otherwise build new one * if no root is spec'd we create new polyface */ //if we have polyface in our chain, we return that if (decorated.HasDecoration <PolyfacingIHasIdDecoration <Tface> >()) { rv = decorated.FindDecoration <PolyfacingIHasIdDecoration <Tface> >(); } else { rv = new PolyfacingIHasIdDecoration <Tface>(decorated, rootFace); } return(rv); }
public NamedValueIHasIdDecoration(IHasId decorated, string name, object val) : base(decorated) { Condition.Requires(name).IsNotNullOrEmpty(); this.Name = name; this.Value = val; }
private void CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster, bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2, string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle, JobTypes jobtypes, bool isResidenacyRequired, string externalRef, decimal?maxsalary, decimal?minsalary, string package, IList <Industry> reqIndustries, string companyname, LocationReference jobLocation, DateTime expiryDate) { var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 }; var newJobAd = new JobAd { Status = adStatus, PosterId = adPoster.Id, Visibility = { HideContactDetails = adHideContactDetails, HideCompany = false, }, ContactDetails = adContactDetails, Title = adTitle, Integration = { ExternalReferenceId = externalRef }, LogoId = logoImg == null ? (Guid?)null : logoImg.Id, ExpiryTime = expiryDate, Description = { CompanyName = companyname, Content = adContent, PositionTitle = positionTitle, ResidencyRequired = isResidenacyRequired, JobTypes = jobtypes, Industries = reqIndustries, Summary = summary, Salary = (minsalary.HasValue || maxsalary.HasValue ? new Salary { Currency = Currency.AUD, LowerBound = minsalary, UpperBound = maxsalary, Rate = SalaryRate.Year, } : null), Package = package, BulletPoints = bulletPoints, Location = jobLocation, } }; _jobAdsCommand.CreateJobAd(newJobAd); if (adStatus == JobAdStatus.Open) { _jobAdsCommand.OpenJobAd(newJobAd); } else if (adStatus == JobAdStatus.Closed) { _jobAdsCommand.CloseJobAd(newJobAd); } return; }
public static string Dehydrate(IHasId obj) { var item = new SerializedIHasId(obj); var rv = item.Dehydrate(); return(rv); }
private JobAd CreateJobAd(IHasId <Guid> employer, JobAdStatus status) { var jobAd = new JobAd { Id = Guid.NewGuid(), Status = status, Title = "Best Job in the World", CreatedTime = DateTime.Now, PosterId = employer.Id, Description = { BulletPoints = new[] { "good verbal communication", "self management and independency", "bullet point 3" }, Content = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.", JobTypes = JobTypes.FullTime, Industries = new List <Industry> { _industriesQuery.GetIndustry("Engineering") }, }, }; _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); if (status == JobAdStatus.Closed) { _jobAdsCommand.CloseJobAd(jobAd); } return(jobAd); }
private static bool CanAccessSearch(IHasId <Guid> owner, MemberSearch search) { if (owner == null) { return(false); } return(owner.Id == search.OwnerId); }
public void SetIndex(IHasId obj) { Condition.Requires(obj).IsNotNull(); var hasBits = this.IndexFactory.GenerateIndex(obj); var soid = obj.GetStoredObjectId(); this._storeOfIndices.SaveItem(new IndexedEntry(soid.BuildAsId().HasBits(hasBits))); }
/// <summary> /// ctor takes an IHasId. Kacks if it isn't. /// </summary> public StoredObjectId(IHasId iHasId) { Condition.Requires(iHasId).IsNotNull(); //copy the id/type over this._objectId = iHasId.Id; this._objectType = iHasId.GetType(); }
public static PendingReadModelUpdate Create(IHasId source, PendingReadModelUpdateSourceCategory category) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(Create(source.Id, category)); }
private JobAd ApplyForExternalJob(IHasId <Guid> member) { var employer = CreateEmployer(); var jobAd = _jobAdsCommand.PostTestJobAd(employer); ApplyForExternalJob(member, jobAd); return(jobAd); }
private static bool CanAccess(IHasId <Guid> user, IJobAd entry) { if (user == null) { return(false); } return(user.Id == entry.PosterId); }
private static bool CanAccessList(IHasId <Guid> employer, ApplicantList applicantList) { if (employer == null || applicantList == null) { return(false); } return(employer.Id == applicantList.PosterId); }
private static bool CanAccessList(IHasId <Guid> employer, IJobAd jobAd) { if (employer == null || jobAd == null) { return(false); } return(employer.Id == jobAd.PosterId); }
public PolyfacingIHasIdDecoration(IHasId decorated, Polyface rootFace = null) : base(decorated) { //if no polyface is set we create new one this.RootFace = (rootFace == null) ? Polyface.New() : rootFace; //register the face this.RootFace.Is(typeof(Tface), this); }
public bool Equals(IHasId <T>?x, IHasId <T>?y) { if (x == null) { return(y == null); } return(y != null && EqualityComparer <T> .Default.Equals(x.Id, y.Id)); }
public static IWriteableStore SaveItem(this IWriteableStore store, IHasId obj) { if (store == null) return store; store.Commit(CommitBag.New().MarkItemSaved(obj)); return store; }
public StoreSecurityException(IHasId item, IUserInfoStore user, StoredItemAccessMode ruleType) : base(string.Format("{2} Access denied on {0} for {1}", item, user, ruleType)) { Condition.Requires(item).IsNotNull(); Condition.Requires(user).IsNotNull(); this._item = item; this._user = user; this._ruleType = ruleType; }
private static int GetApplicationStatusCount(this IHasId <Guid> applicantList, IDictionary <Guid, IDictionary <ApplicantStatus, int> > counts, ApplicantStatus status) { if (applicantList == null || !counts.ContainsKey(applicantList.Id)) { return(0); } return(counts[applicantList.Id][status]); }
public void SetIndex(IHasId obj) { Condition.Requires(obj).IsNotNull(); var hasBits = this.IndexFactory.GenerateIndex(obj); var soid = obj.GetStoredObjectId(); this._storeOfIndices.SaveItem(new IndexedEntry(soid.BuildAsId().HasBits(hasBits))); }
public StoreSecurityException(IHasId item, IUserInfoStore user, StoredItemAccessMode ruleType) : base(string.Format("{2} Access denied on {0} for {1}", item, user, ruleType)) { Condition.Requires(item).IsNotNull(); Condition.Requires(user).IsNotNull(); this._item = item; this._user = user; this._ruleType = ruleType; }
public static StoredObjectId GetStoredObjectId(this IHasId item) { if (item == null) { return(null); } return(new StoredObjectId(item)); }
public static void SaveEvictingItem(this IEvictingStore store, IHasId obj, IExpirable evictingCondition) { if (store == null) { return; } store.Commit(new CommitBag().MarkItemSaved(obj), evictingCondition); }
private SerializedIHasId(IHasId obj) { Condition.Requires(obj).IsNotNull(); var id = obj.GetStoredObjectId(); this.Id = _serializer.Serialize(id); this.Context = _serializer.Serialize(obj); }
private static bool CanUpdateNote(IHasId <Guid> employer, CandidateNote note) { // Must own the note to update it. if (employer == null || note == null) { return(false); } return(note.RecruiterId == employer.Id); }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { // call base base.GetObjectData(info, context); //pull out added info this._item = info.GetValue("_item", typeof(object)) as IHasId; this._user = info.GetValue("_user", typeof( object)) as IUserInfoStore; this._ruleType = (StoredItemAccessMode)info.GetValue("_ruleType", typeof(StoredItemAccessMode)); }
public async Task Scrobble(IHasId item) { using (var request = new HttpRequestMessage(HttpMethod.Get, "/:/scrobble?identifier=com.plexapp.plugins.library&key=" + item.Id)) { var resp = await _httpClient.SendAsync(request); var respStr = await resp.Content.ReadAsStringAsync(); } }
/// <summary> /// returns a search filter that finds other objects that have the same id but not the same type /// </summary> /// <param name="obj"></param> /// <returns></returns> public static LogicOfTo<IHasId,bool> GetFindSameIdDiffTypeSearchFilter(IHasId obj) { LogicOfTo<IHasId, bool> filter = LogicOfTo<IHasId, bool>.New((item) => { bool hasSameId = item.Id.Equals(obj.Id); bool isSameType = item.GetType().Equals(obj.GetType()); return hasSameId && (!isSameType); }); return filter; }
public static void SaveItemIfUniqueElseThrow(this IStore store, IHasId obj) { if (store == null) return; //throw if the item exists var dup = store.Get(obj.GetStoredObjectId()); if (dup != null) throw new InvalidOperationException("Item already exists " + obj.Id.ToString()); store.Commit(new CommitBag().MarkItemSaved(obj)); }
/// <summary> /// replaces an item with the same id /// </summary> /// <typeparam name="T"></typeparam> /// <param name="store"></param> /// <param name="item"></param> public static void Replace(this IStoreOfUniqueId store, IHasId newItem) { Condition.Requires(store).IsNotNull(); if (newItem == null) return; //get the item with the same id var item = store.GetById(newItem.Id); store.DeleteItem(item.GetStoredObjectId()); //commit the new item store.SaveItem(newItem); }
private IHasBits _hasBits; //uses backing field to wrap #endregion #region Ctor /// <summary> /// /// </summary> /// <param name="decorated"></param> /// <param name="hasBits">if null will default to 32bit BitArrayHasBits instance</param> public HasBitsIHasIdDecoration(IHasId decorated, IHasBits hasBits = null) : base(decorated) { if (hasBits != null) { this._hasBits = hasBits; } else { this._hasBits = NaturalBitArrayHasBits.New(new BitArray(32)); } }
public ICommitBag MarkItemSaved(IHasId obj) { if (obj == null) { return this; } //we don't allow StoredObjectIds...we have to be dealing with actual objects if (obj is StoredObjectId) throw new InvalidOperationException("StoredObjectId type is not allowed"); lock (this._stateLock) { List<IHasId> list = this.ItemsToSave as List<IHasId>; list.RemoveAll(x => StoredObjectId.New(x).Equals(StoredObjectId.New(obj))); this.ItemsToSave.Add(obj); } return this; }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new HasMachineNameDecoration(thing, this.MachineName); }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new HasBitsIHasIdDecoration(thing, this._hasBits); }
/// <summary> /// for a particular stored item, accessing user, and access mode, get all applicable rules, in order of least /// dependent rule to most /// </summary> /// <param name="ruleType"></param> /// <param name="storeItem"></param> /// <param name="user"></param> /// <returns></returns> protected List<StoreAccessRule> GetItemRulesForUser(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user) { //first look for item specific rules, and null item rules SearchFilterOf<StoreAccessRule> filter = new SearchFilterOf<StoreAccessRule>((x) => { if (x.RuleType == ruleType && (x.Item == null || x.Item.Id.Equals(storeItem.Id))) return true; return false; }); var list = RuleStore.Search<StoreAccessRule>(filter); List<IHasDependencyOf<StoreAccessRule>> unsortedList = list.ConvertListTo<IHasDependencyOf<StoreAccessRule>, StoreAccessRule>(); //now order the list by dependency from least to most var sortedList = DependencyUtil.SortHasADependency(unsortedList); //return var sortedConvertedList = sortedList.ConvertListTo<StoreAccessRule, IHasDependencyOf<StoreAccessRule>>(); //add ALL overriding rules to the first on the list //RULE 1: The owner will always have full access to item sortedConvertedList.Insert(0, new StoreAccessRule("OWNER", ruleType, (ihasId, accessUser) => { if (accessUser.Id.Equals(user.Id)) { return true; } return null; })); return sortedConvertedList; }
public HasVersionDecoration(IHasId decorated, string version) : base(decorated) { Condition.Requires(version).IsNotNull(); this.Version = version; }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new StringableDecoration(thing); }
public DistributedId(IHasId decorated, DateTime dateCreated, Guid guid, string localMachine, IPAddress addr) :base(decorated.HasDateCreated(dateCreated).HasGUID(guid).HasMachineName(localMachine).HasIP(addr)) { }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new HasVersionDecoration(thing, this.Version); }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new HasDateCreatedDecoration(thing, this.DateCreated); }
public HasDateCreatedDecoration(IHasId decorated, DateTime dateCreated) : base(decorated) { this.DateCreated = dateCreated.ToUniversalTime(); }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new ContextualIHasIdDecoration(thing, this.Context); }
public NamingIHasIdDecoration(IHasId decorated, string name) : base(decorated) { Condition.Requires(name).IsNotNullOrEmpty(); this.Name = name; }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new NamedValueIHasIdDecoration(thing, this.Name, this.Value); }
public IHasBits GenerateIndex(IHasId obj) { //get all the bitlogic items var bitLogics = this.StoreOfBitLogic.GetAll().OrderBy(x => x.Id).ToArray(); var rv = NaturalBitArrayHasBits.New(new BitArray(bitLogics.Length)); //foreach item, position by position, set the hasbits values bitLogics.WithEach(x => { var nameFace = x.As<IHasName>(); var indexFace = x.As<IHasId<int>>(); var logicFace = x.As<LogicOfTo<IHasId, bool>>(); var logic = logicFace.Perform(obj) as LogicOfTo<IHasId, bool>; rv.SetBit(indexFace.Id, logic.Result); }); return rv; }
public HasMachineNameDecoration(IHasId decorated, string machineName) : base(decorated) { Condition.Requires(machineName).IsNotNull(); this.MachineName = machineName; }
public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing) { return new DistributedId(thing, this.DateCreated, this.GUID, this.MachineName, this.IPAddress); }
protected void HasAccessToItemAndThrow(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user) { if (!this.HasAccessToItem(ruleType, storeItem, user)) { throw new StoreSecurityException(storeItem, user, ruleType); } }
public StringableDecoration(IHasId decorated) : base(decorated) { }
protected bool HasAccessToItem(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user) { var rules = this.GetItemRulesForUser(ruleType, storeItem, user); //if no rules are present, default to no access if (rules == null || rules.Count == 0) return false; foreach (var each in rules) { var res = each.HasAccess(storeItem, user); //if it's doesn't have a value the rule is skipped if (!res.HasValue) { continue; } return res.Value; } return false; }
public HasDateLastTouchedDecoration(IHasId decorated, DateTime DateLastTouched) : base(decorated) { this.DateLastTouched = DateLastTouched.ToUniversalTime(); }
public ContextualIHasIdDecoration(IHasId decorated, object context) : base(decorated) { this.Context = context; }