protected void NormalizeProfiles(AnalyticsItems analytics) { Assert.ArgumentNotNull(analytics, "analytics"); foreach (ProfileItem profileItem1 in analytics.Profiles) { ProfileItem profileItem = profileItem1; ContentProfile profile = null; // NM: Replaced the list first or default with a dictionary contains key string profileKey = profileItem.Name; if (profilesDictionary.ContainsKey(profileKey)) { profile = profilesDictionary[profileKey]; } if (profile == null) { profile = new ContentProfile(profileItem) { IsSavedInField = false }; profiles.Add(profile); profilesDictionary.Add(profileKey, profile); } ProcessProfileKeys(profile, profileItem); } }
protected static void ProcessProfileKeys(ContentProfile profile, ProfileItem profileItem) { Assert.ArgumentNotNull(profile, "profile"); Assert.ArgumentNotNull(profileItem, "profileItem"); Assert.IsFalse(profile.ProfileID == ID.Null, "profile ID"); foreach (ProfileKeyItem profileKeyItem in profileItem.Keys.ToList()) { ProfileKeyItem keyItem = profileKeyItem; // NM: Check to see if there are any keys if (profile.Keys.Length == 0) { continue; } if (profile.Keys.FirstOrDefault(k => string.Compare(k.Key, keyItem.Name, StringComparison.OrdinalIgnoreCase) == 0) == null) { ContentProfileKeyData key = new ContentProfileKeyData(keyItem) { Value = keyItem.GetDefaultValue() }; profile.AddKey(key); } } foreach (ContentProfileKeyData key in profile.Keys.Where(key => key.ProfileDefinitionId == Guid.Empty)) { profile.RemoveKey(key); } UpdateKeyValues(profile); }
void UpdatePartData() { PartDocument doc = (PartDocument)m_inventorApplication.ActiveDocument; // calculate mass string material = doc.ComponentDefinition.Material.InternalName.Trim(); double mass = doc.ComponentDefinition.MassProperties.Mass; if (mass > 0) { // Create a profile item Hashtable parameters = new Hashtable(); parameters.Add("mass", mass.ToString()); parameters.Add("massUnit", "g"); parameters.Add("name", Guid.NewGuid().ToString()); parameters.Add("representation", "full"); Hashtable options = new Hashtable(); options.Add("returnUnit", "g"); ProfileItem item = m_AMEEProfile.CreateItem(DataMapping.Instance().Item(material), parameters, options); // Show the info window and shove data in it if (!m_summaryForm.Visible) { m_summaryForm.Show(new InventorWindow()); } m_summaryForm.UpdateData(item); } }
public void GetEnumerator_Call_ReturnScoresWithKeyName(Db db, ID keyId1, ID keyId2, DbItem profileItem, IBehaviorProfileContext behaviorProfile) { //Arrange using (new SecurityDisabler()) { profileItem.Add(new DbItem("Key1", keyId1, ProfileKeyItem.TemplateID) { {ProfileKeyItem.FieldIDs.NameField,"key1name" } }); profileItem.Add(new DbItem("Key2", keyId2, ProfileKeyItem.TemplateID) { {ProfileKeyItem.FieldIDs.NameField,"key2name" } }); db.Add(profileItem); var item = db.GetItem(profileItem.FullPath); var profile = new ProfileItem(item); var behaviorScores = new List<KeyValuePair<ID, float>>() { new KeyValuePair<ID, float>(keyId1, 10), new KeyValuePair<ID, float>(keyId2, 20) }; behaviorProfile.Scores.Returns(behaviorScores); var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile); //Act var result = behaviorProfileDecorator.ToList(); //Assert result.Should().BeEquivalentTo(new[] { new KeyValuePair<string, float>("key1name", 10), new KeyValuePair<string, float>("key2name", 20) }); } }
public async Task <IActionResult> PutProfileItem(string id, ProfileItem profileItem) { HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi); if (id != profileItem.Id) { return(BadRequest()); } _context.Entry(profileItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfileItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Remove a item of a list items. /// </summary> /// <param name="item"></param> public void RemoveItem(ProfileItem item) { if (item != null) { items.Remove(item); } }
//private NameValueCollection GetPoints() //{ // var result = new NameValueCollection(); // if (Tracker.CurrentVisit. != null) // { // var selected = from profile in Tracker.Visitor.DataSet.Profiles // where profile.ProfileName.Equals(profileName, StringComparison.OrdinalIgnoreCase) // select profile; // var groupedproffiles = selected.GroupBy(x => x.ProfileName); // foreach (var groupedproffile in groupedproffiles) // { // var profileItem = new ProfileItem(Sitecore.Context.Database.GetItem("/sitecore/system/Marketing Center/Profiles/" + groupedproffile.Key)); // foreach (var key in profileItem.Keys) // { // var globalValue = groupedproffile.Sum(x => x.Values[key.KeyName]); // var currentValue = Tracker.CurrentVisit.Profiles.Where(x => x.ProfileName.Equals(groupedproffile.Key)).FirstOrDefault().Values[key.KeyName]; // string gloabalSessionValue = true ? string.Format("({0})", globalValue) : string.Empty; // result.Add(key.KeyName, string.Format(CultureInfo.CurrentCulture, "{0} {1}", currentValue, gloabalSessionValue)); // } // } // } // return result; //} private NameValueCollection GetProfileKeys(string profileName) { var result = new NameValueCollection(); if (Tracker.CurrentVisit.Profiles != null) { var selected = from profile in Tracker.Visitor.DataSet.Profiles where profile.ProfileName.Equals(profileName, StringComparison.OrdinalIgnoreCase) select profile; var groupedproffiles = selected.GroupBy(x => x.ProfileName); foreach (var groupedproffile in groupedproffiles) { var profileItem = new ProfileItem(Sitecore.Context.Database.GetItem("/sitecore/system/Marketing Center/Profiles/" + groupedproffile.Key)); foreach (var key in profileItem.Keys) { var globalValue = groupedproffile.Sum(x => x.Values[key.KeyName]); var currentValue = Tracker.CurrentVisit.Profiles.Where(x => x.ProfileName.Equals(groupedproffile.Key)).FirstOrDefault().Values[key.KeyName]; string gloabalSessionValue = true ? string.Format("({0})", globalValue) : string.Empty; result.Add(key.KeyName, string.Format(CultureInfo.CurrentCulture, "{0} {1}", currentValue, gloabalSessionValue)); } } } return result; }
private void drawGraphLineFrom(ProfileItem item, ref Vector2 pt, float factor, int start, int end, int offset, ref int height) { int prevValueHeight = height; float topThreshold = (item.settings.max - item.settings.start) * threshold; float botThreshold = (item.settings.min - item.settings.start) * threshold; var topRange = item.settings.max - topThreshold; var botRange = item.settings.min - botThreshold; for (int i = start + 1; i < end; i++) { // Enable these lines for more acurate graphs //GL.Vertex3 (pt.x, pt.y + prevValueHeight, 0); //GL.Vertex3 (pt.x+offset, pt.y + prevValueHeight, 0); float value = item.values[i] - item.settings.start; int valueHeight = (int)(value * factor); setColor(value, topThreshold, botThreshold, topRange, botRange); GL.Vertex3(pt.x, pt.y + prevValueHeight, 0); pt.x += 2 * offset; GL.Vertex3(pt.x, pt.y + valueHeight, 0); prevValueHeight = valueHeight; } GL.Vertex3(pt.x, pt.y + prevValueHeight, 0); pt.x += offset; GL.Vertex3(pt.x, pt.y + prevValueHeight, 0); pt.x += offset; height = prevValueHeight; }
public GraphSettings Add(string id, int height) { ProfileItem item; if (itemDict.TryGetValue(id, out item)) { item.settings.height = height; } else { item = new ProfileItem(id, height, historyLength); // Odd way of knowing that the behaviour has been disabled and not yet re-enabled if (itemList.Count == itemDict.Count) { itemList.Add(item); itemDict.Add(id, item); } else { newItemList.Add(item); } } return(item.settings); }
private void drawGraphLine(ProfileItem item, ref Vector2 pos) { var settings = item.settings; float factor = (settings.height - 1) / (settings.max - settings.min); int baseline = (int)((settings.start - settings.min) * factor); Vector2 graphPoint = new Vector2(0, pos.y - graphMargin.top - settings.height + baseline); int index = historyIndex + 1; if (scrollUpdates) { graphPoint.x = rowWidth - graphMargin.right; int height; if (index < historyLength) { height = (int)((item.values[index] - settings.start) * factor); drawGraphLineFrom(item, ref graphPoint, factor, index, historyLength, -1, ref height); graphPoint.x += 2; drawGraphLineFrom(item, ref graphPoint, factor, -1, index, -1, ref height); } else { drawGraphLineFrom(item, ref graphPoint, factor, 0, index, -1); } } else { graphPoint.x = pos.x + labelWidth + graphMargin.left; drawGraphLineFrom(item, ref graphPoint, factor, 0, index, 1); if (index < historyLength) { drawGraphLineFrom(item, ref graphPoint, factor, index, historyLength, 1); } } }
public InstalledModViewModel(InstalledItem installedItem, ProfileItem profileItem) { InstallInfo = installedItem; ActiveModInfo = profileItem; Name = InstallInfo.CachedDetails.Name; Author = InstallInfo.CachedDetails.Author; Version = InstallInfo.CachedDetails.LatestVersion.Version.ToString(); ReleaseDate = InstallInfo.CachedDetails.LatestVersion.ReleaseDate.ToString(Sys.Settings.DateTimeStringFormat); SortOrder = defaultSortOrder; // check active profile for custom category then default to library installed item _category = profileItem.Category; if (string.IsNullOrWhiteSpace(_category)) { _category = InstallInfo.CachedDetails.Category; } if (string.IsNullOrWhiteSpace(_category)) { Category = ModCategory.Unknown.ToString(); } BorderThickness = new Thickness(0); }
//private NameValueCollection GetPoints() //{ // var result = new NameValueCollection(); // if (Tracker.CurrentVisit. != null) // { // var selected = from profile in Tracker.Visitor.DataSet.Profiles // where profile.ProfileName.Equals(profileName, StringComparison.OrdinalIgnoreCase) // select profile; // var groupedproffiles = selected.GroupBy(x => x.ProfileName); // foreach (var groupedproffile in groupedproffiles) // { // var profileItem = new ProfileItem(Sitecore.Context.Database.GetItem("/sitecore/system/Marketing Center/Profiles/" + groupedproffile.Key)); // foreach (var key in profileItem.Keys) // { // var globalValue = groupedproffile.Sum(x => x.Values[key.KeyName]); // var currentValue = Tracker.CurrentVisit.Profiles.Where(x => x.ProfileName.Equals(groupedproffile.Key)).FirstOrDefault().Values[key.KeyName]; // string gloabalSessionValue = true ? string.Format("({0})", globalValue) : string.Empty; // result.Add(key.KeyName, string.Format(CultureInfo.CurrentCulture, "{0} {1}", currentValue, gloabalSessionValue)); // } // } // } // return result; //} private NameValueCollection GetProfileKeys(string profileName) { var result = new NameValueCollection(); if (Tracker.CurrentVisit.Profiles != null) { var selected = from profile in Tracker.Visitor.DataSet.Profiles where profile.ProfileName.Equals(profileName, StringComparison.OrdinalIgnoreCase) select profile; var groupedproffiles = selected.GroupBy(x => x.ProfileName); foreach (var groupedproffile in groupedproffiles) { var profileItem = new ProfileItem(Sitecore.Context.Database.GetItem("/sitecore/system/Marketing Center/Profiles/" + groupedproffile.Key)); foreach (var key in profileItem.Keys) { var globalValue = groupedproffile.Sum(x => x.Values[key.KeyName]); var currentValue = Tracker.CurrentVisit.Profiles.Where(x => x.ProfileName.Equals(groupedproffile.Key)).FirstOrDefault().Values[key.KeyName]; string gloabalSessionValue = true ? string.Format("({0})", globalValue) : string.Empty; result.Add(key.KeyName, string.Format(CultureInfo.CurrentCulture, "{0} {1}", currentValue, gloabalSessionValue)); } } } return(result); }
public void GetEnumerator_Call_ReturnScoresWithKeyName(Db db, ID keyId1, ID keyId2, DbItem profileItem, IBehaviorProfileContext behaviorProfile) { //Arrange using (new SecurityDisabler()) { profileItem.Add(new DbItem("Key1", keyId1, ProfileKeyItem.TemplateID) { { ProfileKeyItem.FieldIDs.NameField, "key1name" } }); profileItem.Add(new DbItem("Key2", keyId2, ProfileKeyItem.TemplateID) { { ProfileKeyItem.FieldIDs.NameField, "key2name" } }); db.Add(profileItem); var item = db.GetItem(profileItem.FullPath); var profile = new ProfileItem(item); var behaviorScores = new List <KeyValuePair <ID, float> >() { new KeyValuePair <ID, float>(keyId1, 10), new KeyValuePair <ID, float>(keyId2, 20) }; behaviorProfile.Scores.Returns(behaviorScores); var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile); //Act var result = behaviorProfileDecorator.ToList(); //Assert result.Should().BeEquivalentTo(new[] { new KeyValuePair <string, float>("key1name", 10), new KeyValuePair <string, float>("key2name", 20) }); } }
/// <summary> /// The Table Service supports two main types of insert operations. /// 1. Insert - insert a new entity. If an entity already exists with the same PK + RK an exception will be thrown. /// 2. Replace - replace an existing entity. Replace an existing entity with a new entity. /// 3. Insert or Replace - insert the entity if the entity does not exist, or if the entity exists, replace the existing one. /// 4. Insert or Merge - insert the entity if the entity does not exist or, if the entity exists, merges the provided entity properties with the already existing ones. /// </summary> /// <param name="table">The sample table name</param> /// <param name="entity">The entity to insert or merge</param> /// <returns>A Task object</returns> public static async Task <ProfileItem> InsertOrMergeEntityAsync(CloudTable table, ProfileItem entity) { if (entity == null) { throw new ArgumentNullException("entity"); } try { // Create the InsertOrReplace table operation TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity); // Execute the operation. TableResult result = await table.ExecuteAsync(insertOrMergeOperation); ProfileItem insertedProfile = result.Result as ProfileItem; return(insertedProfile); } catch (StorageException e) { Debug.WriteLine(e.Message); throw; } }
/// <summary> /// Display the currently set profile /// </summary> private void DisplayProfile() { if (_thisProfile == null) { _profileItem = null; } else { if (_profileItem != null) { _profileItem.Image = Mugshot.MugshotForUser(_thisProfile.Username, true).RealImage; _profileItem.ProfileData = _thisProfile; } else { Mugshot mugshot = Mugshot.MugshotForUser(_thisProfile.Username, true); _profileItem = new ProfileItem(prvDetails, false) { NameColour = UI.System.SelectionColour, Image = mugshot.RealImage, Font = _font, ProfileData = _thisProfile }; mugshot.Refresh(); prvDetails.Items.Add(_profileItem); } } }
public ProfileWindow(ProfileItem profileItem, OutoposManager outoposManager, BufferManager bufferManager) { _profileItem = profileItem; _outoposManager = outoposManager; _bufferManager = bufferManager; var digitalSignatureCollection = new List<object>(); digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" }); digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray()); InitializeComponent(); _wikiTextBox.MaxLength = Wiki.MaxNameLength; _chatTextBox.MaxLength = Chat.MaxNameLength; lock (_profileItem.ThisLock) { _uploadSignature = _profileItem.UploadSignature; _signatureCollection.AddRange(_profileItem.TrustSignatures); _wikiCollection.AddRange(_profileItem.Wikis); _chatCollection.AddRange(_profileItem.Chats); } _signatureListView.ItemsSource = _signatureCollection; _wikiListView.ItemsSource = _wikiCollection; _chatListView.ItemsSource = _chatCollection; _signatureComboBox.ItemsSource = digitalSignatureCollection; this.Sort(); }
/// <summary> /// Get a item in a item list. /// </summary> /// <param name="identificador"> Identifier of the item to search. </param> /// <returns> The searched item. </returns> public ProfileItem GetItem(int identificador) { ProfileItem returnValue = null; returnValue = items.Find(item => item.itemId == identificador); return(returnValue); }
public static dynamic GetTSObject(ProfileItem dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
private void InsertClampingConditions(ProfileItem profile, long testTypeId, long profileId) { InsertCondition(testTypeId, profileId, "CLAMP_Type", profile.ClampingForce); InsertCondition(testTypeId, profileId, "CLAMP_Force", profile.ParametersClamp); InsertCondition(testTypeId, profileId, "CLAMP_HeightMeasure", profile.IsHeightMeasureEnabled); InsertCondition(testTypeId, profileId, "CLAMP_HeightValue", profile.Height); InsertCondition(testTypeId, profileId, "CLAMP_Temperature", profile.Temperature); }
public IEnumerable <PatternMatch> GetPatternsWithGravityShare(ProfileItem visibleProfile) { var userPattern = visibleProfile.PatternSpace.CreatePattern(Tracker.Current.Interaction.Profiles[visibleProfile.Name]); var patterns = PopulateProfilePatternMatchesWithXdbData.GetPatternsWithGravityShare(visibleProfile, userPattern); return(patterns.Select(patternKeyValuePair => CreatePatternMatch(visibleProfile, patternKeyValuePair))); }
public IEnumerable<PatternMatch> GetPatternsWithGravityShare(ProfileItem visibleProfile) { var userPattern = visibleProfile.PatternSpace.CreatePattern(Tracker.Current.Interaction.Profiles[visibleProfile.Name]); var patterns = PopulateProfilePatternMatchesWithXdbData.GetPatternsWithGravityShare(visibleProfile, userPattern); return patterns.Select(patternKeyValuePair => CreatePatternMatch(visibleProfile, patternKeyValuePair)); }
/// <summary> /// Gets distance estimate for 2 profiles /// </summary> /// <param name="profileItem1">The profile item 1.</param> /// <param name="profileItem2">The profile item 2.</param> /// <returns>Distance estimate</returns> public double ProfileItemsDistance(ProfileItem profileItem1, ProfileItem profileItem2) { return (from i1 in profileItem1 from i2 in profileItem2 select i1.Value * i2.Value * this.NucleotideDistance(i1.Key, i2.Key)) .Sum(); }
private Pattern GetHistoricMatchedPattern(ProfileItem profile) { var behaviorProfile = Tracker.Current.Contact.BehaviorProfiles[profile.ID]; if (behaviorProfile == null) return null; IProfileData profileData = new BehaviorProfileDecorator(profile, behaviorProfile); return profile.PatternSpace.CreatePattern(profileData); }
protected int FillProfile(string aPrefix, string aName) { var xProfile = new ProfileItem { Prefix = aPrefix, Name = aName, IsPreset = true }; return(lboxProfile.Items.Add(xProfile)); }
public void Indexer_NullProfileKey_ReturnZero([Content]Item profileItem, IBehaviorProfileContext behaviorProfile) { //Arrange var profile = new ProfileItem(profileItem); var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile); //Assert behaviorProfileDecorator["profileKey"].Should().Be(0); }
protected int FillProfile(int aID) { var xProfile = new ProfileItem { Prefix = "User" + aID.ToString("000"), IsPreset = false }; xProfile.Name = mProps.GetProperty(xProfile.Prefix + "_Name"); return(lboxProfile.Items.Add(xProfile)); }
public IEnumerable<PatternMatch> GetPatternsWithGravityShare(ProfileItem visibleProfile, ProfilingTypes type) { Assert.ArgumentNotNull(visibleProfile, nameof(visibleProfile)); var userPattern = type == ProfilingTypes.Historic ? GetHistoricMatchedPattern(visibleProfile) : GetActiveMatchedPattern(visibleProfile); var patterns = PopulateProfilePatternMatchesWithXdbData.GetPatternsWithGravityShare(visibleProfile, userPattern); return patterns.Select(patternKeyValuePair => CreatePatternMatch(visibleProfile, patternKeyValuePair)).OrderByDescending(pm => pm.MatchPercentage); }
private void CopyProfileItemToProfile(ProfileItem Source, Profile Dest) { //копирование данных Source в Dest if (Source != null) { if (Dest != null) { Dest.Name = Source.ProfileName; Dest.Key = Source.ProfileKey; Dest.Timestamp = Source.ProfileTS; Dest.IsHeightMeasureEnabled = Source.IsHeightMeasureEnabled; Dest.ParametersClamp = Source.ParametersClamp; Dest.Height = Source.Height; Dest.Temperature = Source.Temperature; Dest.ParametersComm = Source.CommTestParameters; Dest.TestParametersAndNormatives.Clear(); foreach (var g in Source.GateTestParameters) { Dest.TestParametersAndNormatives.Add(g); } foreach (var b in Source.BVTTestParameters) { Dest.TestParametersAndNormatives.Add(b); } foreach (var v in Source.VTMTestParameters) { Dest.TestParametersAndNormatives.Add(v); } foreach (var d in Source.DvDTestParameterses) { Dest.TestParametersAndNormatives.Add(d); } foreach (var a in Source.ATUTestParameters) { Dest.TestParametersAndNormatives.Add(a); } foreach (var q in Source.QrrTqTestParameters) { Dest.TestParametersAndNormatives.Add(q); } foreach (var t in Source.TOUTestParameters) { Dest.TestParametersAndNormatives.Add(t); } } } }
public void Indexer_NullProfileKey_ReturnZero([Content] Item profileItem, IBehaviorProfileContext behaviorProfile) { //Arrange var profile = new ProfileItem(profileItem); var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile); //Assert behaviorProfileDecorator["profileKey"].Should().Be(0); }
public bool HasMatchingPattern(ProfileItem currentProfile) { var userPattern = Tracker.Current.Interaction.Profiles[currentProfile.Name]; if (userPattern?.PatternId == null) { return false; } var matchingPattern = Context.Database.GetItem(userPattern.PatternId.Value.ToID()); return matchingPattern != null; }
public async Task <string> CreateProfileRecordAsync(string userName, ProfileItem profileItem) { var record = await Client() .Child(_usersDocumentAlias) .Child(userName) .Child(_profileAlias) .PostAsync(profileItem); return(record.Key); }
/// <summary> /// Add a item to lists items. /// </summary> /// <param name="item">Item to add.</param> public void AddItem(ProfileItem item) { ProfileItem lastItem = items.Last(); if (item != null) { item.itemId = lastItem != null ? lastItem.itemId + 1 : 1; items.Add(item); } }
public IEnumerable <PatternMatch> GetPatternsWithGravityShare(ProfileItem visibleProfile, ProfilingTypes type) { Assert.ArgumentNotNull(visibleProfile, nameof(visibleProfile)); var userPattern = type == ProfilingTypes.Historic ? this.GetHistoricMatchedPattern(visibleProfile) : this.GetActiveMatchedPattern(visibleProfile); var patterns = PopulateProfilePatternMatchesWithXdbData.GetPatternsWithGravityShare(visibleProfile, userPattern); return(patterns.Select(patternKeyValuePair => CreatePatternMatch(visibleProfile, patternKeyValuePair)).OrderByDescending(pm => pm.MatchPercentage)); }
public async Task <ActionResult <ProfileItem> > PostProfileItem(ProfileItem profileItem) { HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi); profileItem.FirstLogin = false; // This is a synchronous call, so that the clients know, when they call Get, that the // call to the downstream API (Microsoft Graph) has completed. try { var profile = CallGraphApiOnBehalfOfUser().GetAwaiter().GetResult(); if (profile is string) { if (profile == "interaction required") { HttpContext.Response.ContentType = "application/json"; HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; await HttpContext.Response.WriteAsync(JsonConvert.SerializeObject("interaction required")); } } else { // OID is represented in id_token as a 32 digit number, while in MS Graph API, the // preceeding 0s are omitted. The following operation adds the omitted 0s back. int x = 32 - profile.Id.Length; string graphID = new string('0', x) + profile.Id; profileItem.Id = graphID; profileItem.UserPrincipalName = profile.UserPrincipalName; profileItem.GivenName = profile.GivenName; profileItem.Surname = profile.Surname; profileItem.JobTitle = profile.JobTitle; profileItem.MobilePhone = profile.MobilePhone; profileItem.PreferredLanguage = profile.PreferredLanguage; } } catch (MsalException ex) { HttpContext.Response.ContentType = "application/json"; HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized; await HttpContext.Response.WriteAsync(JsonConvert.SerializeObject("An authentication error occurred while acquiring a token for downstream API\n" + ex.ErrorCode + "\n" + ex.Message)); } catch (Exception ex) { HttpContext.Response.ContentType = "application/json"; HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; await HttpContext.Response.WriteAsync(JsonConvert.SerializeObject("An error occurred while calling the downstream API\n" + ex.Message)); } _context.ProfileItems.Add(profileItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProfileItem", new { id = profileItem.Id }, profileItem)); }
public Task <bool> DisconnectNetworkAsync(ProfileItem targetProfile, bool isManual = true) { Debug.WriteLine("Disconnect start!"); if (isManual) { EngagesPriority.Value = false; } return(WorkAsync(targetProfile, x => _worker.DisconnectNetworkAsync(x, _connectTimeout))); }
public async Task Add(Profile item) { ProfileItem profileItem = new ProfileItem { UserId = item.UserId, Username = item.UserName, PhotoBase64Encoded = item.PhotoBase64Encoded }; profileItem = await SamplesUtils.InsertOrMergeEntityAsync(table, profileItem); }
public async Task <Profile> Get(string UserName) { ProfileItem pi = await SamplesUtils.RetrieveProfileAsync(table, "1", UserName); return(new Profile { UserId = "1", UserName = pi.Username, PhotoBase64Encoded = pi.PhotoBase64Encoded }); }
/// <summary> /// Handle a mugshot updated. If this mugshot appears in any friend profile then we update /// the friend panel shown here. /// </summary> private void OnMugshotUpdated(object sender, MugshotEventArgs e) { Platform.UIThread(this, delegate { if (Profile != null && Profile.Username == e.Mugshot.Username) { ProfileItem item = (ProfileItem)prvDetails.Items[0]; item.Image = e.Mugshot.RealImage; item.UpdateImage(); } }); }
private Pattern GetHistoricMatchedPattern(ProfileItem profile) { var behaviorProfile = Tracker.Current.Contact.BehaviorProfiles[profile.ID]; if (behaviorProfile == null) { return(null); } IProfileData profileData = new BehaviorProfileDecorator(profile, behaviorProfile); return(profile.PatternSpace.CreatePattern(profileData)); }
public bool HasMatchingPattern(ProfileItem currentProfile, ProfilingTypes type) { if (type == ProfilingTypes.Historic) { var userPattern = Tracker.Current.Contact.BehaviorProfiles[currentProfile.ID]; return userPattern != null && userPattern.NumberOfTimesScored != 0; } else { var userPattern = Tracker.Current.Interaction.Profiles[currentProfile.Name]; return userPattern != null && userPattern.Count != 0; } }
public IEnumerable<PatternMatch> GetPatternsWithGravityShare(ProfileItem visibleProfile) { var userPattern = visibleProfile.PatternSpace.CreatePattern(Tracker.Current.Interaction.Profiles[visibleProfile.Name]); var patterns = PopulateProfilePatternMatchesWithXdbData.GetPatternsWithGravityShare(visibleProfile, userPattern); return from patternKeyValuePair in patterns let src = patternKeyValuePair.Key.Image.ImageUrl(new MediaUrlOptions { Width = 50, MaxWidth = 50 }) select new PatternMatch(visibleProfile.NameField, patternKeyValuePair.Key.NameField, src, patternKeyValuePair.Value); }
public bool HasMatchingPattern(ProfileItem currentProfile, ProfilingTypes type) { if (type == ProfilingTypes.Historic) { var userPattern = Tracker.Current.Contact.BehaviorProfiles[currentProfile.ID]; if (userPattern == null || ID.IsNullOrEmpty(userPattern.PatternId)) { return false; } return Context.Database.GetItem(userPattern.PatternId) != null; } else { var userPattern = Tracker.Current.Interaction.Profiles[currentProfile.Name]; if (userPattern?.PatternId == null) { return false; } return Context.Database.GetItem(userPattern.PatternId.Value.ToID()) != null; } }
public BehaviorProfileDecorator(ProfileItem profile, IBehaviorProfileContext behaviorProfile) { this.profile = profile; this.behaviorProfile = behaviorProfile; }
private static PatternMatch CreatePatternMatch(PatternCardItem matchingPattern, ProfileItem visibleProfile) { var image = matchingPattern.Image.MediaItem; var src = StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(image)); var patternMatch = new PatternMatch(visibleProfile.NameField, matchingPattern.Name, src); return patternMatch; }
/// <summary> /// загрузка профиля, новостей /// </summary> private void LoadMainViewInfo() { if (!App.GlobalVkClient.Active) { Login(); return; } Loading = true; App.GlobalVkClient.GetMainViewInfo( (response) => { if (response.Response == null) return; UserProfile = response.Response.User[0]; Status = response.Response.Status.Text; response.Response.News.Items.ForEach((feed) => { //switch (feed.Type) //{ // case "post": // { // if (feed.Text.Length > 140) feed.Text = feed.Text.Substring(0, 140) + "..."; // break; // } // default: // { // break; // } //} //feed.PostDate = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(feed.Date)).ToLocalTime(); foreach (var profile in response.Response.News.Profiles.Where(profile => profile.Uid == feed.SourceId)) { feed.Author.FirstName = profile.FirstName; feed.Author.LastName = profile.LastName; feed.Author.Photo = profile.Photo; feed.Author.Uid = profile.Uid; } foreach (var group in response.Response.News.Groups.Where(group => group.Gid == Math.Abs(feed.SourceId))) { feed.Author.FirstName = group.Name; feed.Author.Photo = group.Photo; feed.Author.Uid = group.Gid; } DataSource.Add(feed); }); Loading = false; }, (error) => Debug.WriteLine(error.Message)); }
private PatternCardItem GetMatchingPatternForContact(ProfileItem visibleProfile) { var userPattern = Tracker.Current.Interaction.Profiles[visibleProfile.Name]; if (userPattern?.PatternId == null) { return null; } var matchingPattern = Context.Database.GetItem(userPattern.PatternId.Value.ToID()); if (matchingPattern == null) { return null; } return new PatternCardItem(matchingPattern); }
private static PatternMatch CreatePatternMatch(PatternCardItem matchingPattern, ProfileItem visibleProfile) { var src = matchingPattern.Image.ImageUrl(new MediaUrlOptions() { Width = 50, MaxWidth = 50 }); var patternMatch = new PatternMatch(visibleProfile.NameField, matchingPattern.Name, src); return patternMatch; }
private void Setting_Init() { NativeMethods.SetThreadExecutionState(ExecutionState.SystemRequired | ExecutionState.Continuous); { bool initFlag = false; _outoposManager = new OutoposManager(Path.Combine(App.DirectoryPaths["Configuration"], "Cache.bitmap"), App.Cache.Path, _bufferManager); _outoposManager.Load(_configrationDirectoryPaths["OutoposManager"]); if (!File.Exists(Path.Combine(App.DirectoryPaths["Configuration"], "Outopos.version"))) { initFlag = true; // デフォルトのTrustSignaturesの設定。 { Settings.Instance.Global_TrustSignatures.Add("Lyrise@OTAhpWvmegu50LT-p5dZ16og7U6bdpO4z5TInZxGsCs"); } // デフォルトのChatタグを設定。 { var amoebaTag = OutoposConverter.FromChatString("Chat:AAAAAAAGQW1vZWJhAQAAACCrzcPHuDlkIdAKPyrMvdoRizFo3IOOSlWhQhPTKBIOiWRXEcU"); var outoposTag = OutoposConverter.FromChatString("Chat:AAAAAAAHT3V0b3BvcwEAAAAgr9B65c-3yJS95GHleeXi3TekYOtScR4VzJRpz7AoQ294gS26"); var testTag = OutoposConverter.FromChatString("Chat:AAAAAAAEVGVzdAEAAAAgye1mG24NVcdu5Vb2UZXwrnT_kwhXUNWONT0W0m5IAyplJHYb"); Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(amoebaTag)); Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(outoposTag)); Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(testTag)); } { byte[] buffer = new byte[32]; using (var random = RandomNumberGenerator.Create()) { random.GetBytes(buffer); } _outoposManager.SetBaseNode(new Node(buffer, null)); } _outoposManager.ListenUris.Clear(); _outoposManager.ListenUris.Add(string.Format("tcp:{0}:{1}", IPAddress.Any.ToString(), _random.Next(1024, ushort.MaxValue + 1))); _outoposManager.ListenUris.Add(string.Format("tcp:[{0}]:{1}", IPAddress.IPv6Any.ToString(), _random.Next(1024, ushort.MaxValue + 1))); var ipv4ConnectionFilter = new ConnectionFilter() { ConnectionType = ConnectionType.Tcp, UriCondition = new UriCondition() { Value = @"tcp:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}).*", }, }; var ipv6ConnectionFilter = new ConnectionFilter() { ConnectionType = ConnectionType.Tcp, UriCondition = new UriCondition() { Value = @"tcp:\[(\d|:)*\].*", }, }; var tcpConnectionFilter = new ConnectionFilter() { ConnectionType = ConnectionType.Tcp, UriCondition = new UriCondition() { Value = @"tcp:.*", }, }; var torConnectionFilter = new ConnectionFilter() { ConnectionType = ConnectionType.Socks5Proxy, ProxyUri = "tcp:127.0.0.1:29050", UriCondition = new UriCondition() { Value = @"tor:.*", }, }; var i2pConnectionFilter = new ConnectionFilter() { ConnectionType = ConnectionType.None, UriCondition = new UriCondition() { Value = @"i2p:.*", }, }; _outoposManager.Filters.Clear(); _outoposManager.Filters.Add(ipv4ConnectionFilter); _outoposManager.Filters.Add(ipv6ConnectionFilter); _outoposManager.Filters.Add(tcpConnectionFilter); _outoposManager.Filters.Add(torConnectionFilter); _outoposManager.Filters.Add(i2pConnectionFilter); if (CultureInfo.CurrentUICulture.Name == "ja-JP") { Settings.Instance.Global_UseLanguage = "Japanese"; } else { Settings.Instance.Global_UseLanguage = "English"; } // ProfileItem { var digitalSignature = new DigitalSignature("Anonymous", DigitalSignatureAlgorithm.Rsa2048_Sha256); Settings.Instance.Global_DigitalSignatureCollection.Add(digitalSignature); var profileItem = new ProfileItem(); Settings.Instance.Global_ProfileItem = profileItem; { profileItem.UploadSignature = digitalSignature.ToString(); profileItem.Exchange = new Exchange(ExchangeAlgorithm.Rsa2048); // Upload { _outoposManager.UploadProfile(profileItem.Cost, profileItem.Exchange.GetExchangePublicKey(), profileItem.TrustSignatures, profileItem.DeleteSignatures, profileItem.Wikis, profileItem.Chats, digitalSignature); } } } // Nodes.txtにあるノード情報を追加する。 if (File.Exists(Path.Combine(App.DirectoryPaths["Settings"], "Nodes.txt"))) { var list = new List<Node>(); using (StreamReader reader = new StreamReader(Path.Combine(App.DirectoryPaths["Settings"], "Nodes.txt"), new UTF8Encoding(false))) { string line; while ((line = reader.ReadLine()) != null) { list.Add(OutoposConverter.FromNodeString(line)); } } _outoposManager.SetOtherNodes(list); } } else { Version version; using (StreamReader reader = new StreamReader(Path.Combine(App.DirectoryPaths["Configuration"], "Outopos.version"), new UTF8Encoding(false))) { version = new Version(reader.ReadLine()); } if (version <= new Version(1, 0, 0)) { // デフォルトのTrustSignaturesの設定。 { Settings.Instance.Global_TrustSignatures.Add("Lyrise@OTAhpWvmegu50LT-p5dZ16og7U6bdpO4z5TInZxGsCs"); } } } using (StreamWriter writer = new StreamWriter(Path.Combine(App.DirectoryPaths["Configuration"], "Outopos.version"), false, new UTF8Encoding(false))) { writer.WriteLine(App.OutoposVersion.ToString()); } _autoBaseNodeSettingManager = new AutoBaseNodeSettingManager(_outoposManager); _autoBaseNodeSettingManager.Load(_configrationDirectoryPaths["AutoBaseNodeSettingManager"]); _overlayNetworkManager = new OverlayNetworkManager(_outoposManager, _bufferManager); _overlayNetworkManager.Load(_configrationDirectoryPaths["OverlayNetworkManager"]); _catharsisManager = new CatharsisManager(_outoposManager, _bufferManager); _catharsisManager.Load(_configrationDirectoryPaths["CatharsisManager"]); if (initFlag) { _catharsisManager.Save(_configrationDirectoryPaths["CatharsisManager"]); _overlayNetworkManager.Save(_configrationDirectoryPaths["OverlayNetworkManager"]); _autoBaseNodeSettingManager.Save(_configrationDirectoryPaths["AutoBaseNodeSettingManager"]); _outoposManager.Save(_configrationDirectoryPaths["OutoposManager"]); Settings.Instance.Save(_configrationDirectoryPaths["MainWindow"]); } { var outoposPath = Path.Combine(App.DirectoryPaths["Configuration"], "Outopos"); var libraryPath = Path.Combine(App.DirectoryPaths["Configuration"], "Library"); try { if (Directory.Exists(outoposPath)) { if (Directory.Exists(outoposPath + ".old")) Directory.Delete(outoposPath + ".old", true); MainWindow.CopyDirectory(outoposPath, outoposPath + ".old"); } if (Directory.Exists(libraryPath)) { if (Directory.Exists(libraryPath + ".old")) Directory.Delete(libraryPath + ".old", true); MainWindow.CopyDirectory(libraryPath, libraryPath + ".old"); } } catch (Exception e2) { Log.Warning(e2); } } } }
protected int FillProfile(int aID) { var xProfile = new ProfileItem { Prefix = "User" + aID.ToString("000"), IsPreset = false }; xProfile.Name = mProps.GetProperty(xProfile.Prefix + "_Name"); return lboxProfile.Items.Add(xProfile); }
protected int FillProfile(string aPrefix, string aName) { var xProfile = new ProfileItem { Prefix = aPrefix, Name = aName, IsPreset = true }; return lboxProfile.Items.Add(xProfile); }
private void Page_Load(object sender, EventArgs e) { Logo.Item = SiteConfiguration.GetPresentationSettingsItem(); DMSTitle.Text = SiteConfiguration.GetDictionaryText("DMS Session Info Title"); DMSInstructions.Text = SiteConfiguration.GetDictionaryText("DMS Session Info Instructions"); DMSNoPatternMatchName.Text = SiteConfiguration.GetDictionaryText("DMS Session Info No Pattern Match Name"); DMSNoPatternMatch.Text = SiteConfiguration.GetDictionaryText("DMS Session Info No Pattern Match"); DMSNoProfileValues.Text = SiteConfiguration.GetDictionaryText("DMS Session Info No Profile Key Values"); if (Sitecore.Analytics.Tracker.IsActive) { // show the values for the evaluate type keys Item evaluatorTypeProfile = SiteConfiguration.GetPeelBackProfilePathItem(); if (evaluatorTypeProfile != null) { List<KeyValuePair<string, float>> results = new List<KeyValuePair<string, float>>(); if (Tracker.CurrentVisit.Profiles != null) { var selected = from profile in Tracker.Visitor.DataSet.Profiles where profile.ProfileName.Equals(evaluatorTypeProfile.Name, StringComparison.OrdinalIgnoreCase) select profile; var groupedproffiles = selected.GroupBy(x => x.ProfileName); foreach (var profile in groupedproffiles) { var profileItem = new ProfileItem(Sitecore.Context.Database.GetItem("/sitecore/system/Marketing Center/Profiles/" + profile.Key)); foreach (var key in profileItem.Keys) { results.Add(new KeyValuePair<string, float>(key.KeyName, Tracker.CurrentVisit.Profiles.Where(x => x.ProfileName.Equals(profile.Key)).FirstOrDefault().Values[key.KeyName])); } litProfileKey.Text = profile.Key; ProfileValues.DataSource = results; ProfileValues.DataBind(); ProfileKeyNoValues.Visible = false; ProfileKeyValues.Visible = true; } } } // show the pattern match if there is one. var personaProfile = Tracker.CurrentVisit.Profiles.Where(profile => profile.ProfileName == evaluatorTypeProfile.Name).FirstOrDefault(); if (personaProfile != null) { // load the details about the matching pattern Item i = Sitecore.Context.Database.GetItem(new ID(personaProfile.PatternId)); if (i != null) { // make sure the right panels are showing PatternMatchPanel.Visible = true; PatternMatchPanelNoMatch.Visible = false; Name.Item = i; Description.Item = i; Image.Item = i; } } } else { DMSNote.Visible = true; DMSEnabled.Visible = false; } }
/// <summary> /// Gets distance estimate for nucleotide and profile /// </summary> /// <param name="nucleotide">The nucleotide.</param> /// <param name="profileItem">The profile item.</param> /// <returns>Distance estimate</returns> public double ProfileItemNucleotideDistance(Nucleotide nucleotide, ProfileItem profileItem) { return profileItem.Sum(n => n.Value * this.NucleotideDistance(n.Key, nucleotide)); }
private static PatternMatch CreatePatternMatch(ProfileItem visibleProfile, KeyValuePair<PatternCardItem, double> patternKeyValuePair) { return new PatternMatch(visibleProfile.NameField, patternKeyValuePair.Key.NameField, GetPatternImageUrl(patternKeyValuePair), patternKeyValuePair.Value); }
private Pattern GetActiveMatchedPattern(ProfileItem visibleProfile) { return visibleProfile.PatternSpace.CreatePattern(Tracker.Current.Interaction.Profiles[visibleProfile.Name]); }