private async Task ReloadProfileListAsync(ProfilesFile.SelectedProfile selectedProfile = ProfilesFile.SelectedProfile.Current) { var selectedIndex = Profiles.SelectedProfileIndex; await Profiles.ReloadAsync(selectedProfile); if (Controls.Count == 0) { return; } ComboBox_CurrentProfile.DataSource = Profiles.ToArray(); switch (selectedProfile) { case ProfilesFile.SelectedProfile.Current: ComboBox_CurrentProfile.SelectedIndex = selectedIndex; break; case ProfilesFile.SelectedProfile.First: ComboBox_CurrentProfile.SelectedIndex = Profiles.Any() ? 0 : -1; break; case ProfilesFile.SelectedProfile.Last: ComboBox_CurrentProfile.SelectedIndex = Profiles.Any() ? Profiles.Count() - 1 : -1; break; } }
public float[][] GetTrainData() { //List<Profile> profiles = Profile.GetAll(); int profileCount = Profiles.Count(); int questionCount = Questions.Count(); //using (SQLiteConnection connection = new SQLiteConnection(App.DatabaseLocation)) //{ // profiles = connection.Table<Profile>().ToList(); // Profiles = new ObservableCollection<Profile>(profiles as List<Profile>); //} //1 sample by candidate float[][] ret = new float[profileCount][]; for (int i = 0; i < profileCount; i++) { //number of features equal to number of questions //+1 for the class attributed to this train sample ret[i] = new float[questionCount + 1]; for (int j = 0; j < questionCount; j++) { //get the choice of the i candidate for the j question (+1 as Primary key starts from 1) ret[i][j] = ProfileQuestions.SingleOrDefault(pq => pq.Profile.Id == i + 1 && pq.Question.Id == j + 1).Choice; //ProfileQuestion pq = ProfileQuestion.GetProfileQuestion(i + 1, j + 1); //ret[i][j] = pq.Choice; } //last column is the attributed class ret[i][questionCount] = i; } return(ret); }
public static void ViewMenu() { if (Profiles.Count() > 0) { PrintUsers: int numProfile = ChoiseProfile(); switch (numProfile) { case -1: break; default: if (numProfile > -1 && numProfile < Profiles.Count()) { UserMenu(Profiles.GetUser(numProfile), numProfile); } else { goto PrintUsers; } break; } } else { Auth.Login(); } }
/// <summary> /// Сохранить пользователей /// </summary> /// <returns></returns> public static bool WriteUsers() { try { User[] toWrite = new User[0]; for (int i = 0; i < Profiles.Count(); i++) { var user = Profiles.GetUser(i); if (user != null) { Array.Resize(ref toWrite, toWrite.Length + 1); toWrite[toWrite.Length - 1] = user.GetProtectedUser(cryptPass); } } var FavoriteData = JsonConvert.SerializeObject(toWrite, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); File.WriteAllText(path, FavoriteData, Encoding.UTF8); return(true); } catch (Exception ex) { TextConsole.PrintConsole.Print(ex.Message, TextConsole.MenuType.Error); return(false); } }
public override MstProperties Info() { MstProperties info = base.Info(); info.Add("Database Accessor", profileDatabaseAccessor != null ? "Connected" : "Not Connected"); info.Add("Profiles", Profiles.Count()); return(info); }
public void RebuildScore() { // Every social channel is good for 0.25 points on the friend scale, // every hard profile is good for 0.10 points, // every soft profile is good for 0.7 points. var socialScore = Math.Min( (0.25 * Profiles.Count(p => p.SourceChannel != null && p.SourceChannel.StatusUpdatesChannel != null)) + (0.10 * Profiles.Count(p => (p.SourceChannel == null || p.SourceChannel.StatusUpdatesChannel == null) && !p.IsSoft)) + (0.07 * Profiles.Count(p => (p.SourceChannel == null || p.SourceChannel.StatusUpdatesChannel == null) && p.IsSoft)), 1); var outgoingMessages = Messages.Count(m => m.MessageFolder == Folders.SentItems) + 1; score = socialScore * outgoingMessages; }
private double CalcWeight() { double weight = 0; foreach (var p in Profiles) { weight += p.Weight; } var usefulProfiles = Profiles.Where(x => x.Weight > 0).Count(); var usefulProfilesPercent = (double)usefulProfiles / Profiles.Count(); weight *= usefulProfilesPercent; return(weight); }
public void DocumentClosed(MonitorViewModel document) { Unsubscribe(document); document.RemoveAdorners(); document.SortedDico.Clear(); document.PanelNames.Clear(); document.Identities.Clear(); eventAggregator.Publish(new DisplayPropertiesEvent(null)); Profiles.Remove(document); eventAggregator.Publish(new MonitorViewEndedEvent(document)); if (Profiles.Count() > 0) { return; } ActiveDocument = null; // eventAggregator.Publish(new MonitorViewEndedEvent(document, true)); document = null; void Unsubscribe(object panel) { var container = (BindableCollection <IPluginModel>)panel.GetType().GetProperty("MyPluginsContainer").GetValue(panel, null); foreach (var pm in container.ToList()) { var ispanel = pm.ToString().EndsWith("Panel_ViewModel"); var layout = pm.GetType().GetProperty("Layout").GetValue(pm, null); var appearance = pm.GetType().GetProperty("Appearance").GetValue(pm, null); var behavior = pm.GetType().GetProperty("Behavior")?.GetValue(pm, null); //var eventAggregator = (IEventAggregator)target.GetType().GetField("eventAggregator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) // .GetValue(target); eventAggregator.Unsubscribe(layout); eventAggregator.Unsubscribe(appearance); eventAggregator.Unsubscribe(behavior); eventAggregator.Unsubscribe(pm); if (ispanel) { Unsubscribe(pm); } container.Remove(pm); } } }
/// <summary> /// Выбор профиля для дальнейшей работы /// </summary> public static int ChoiseProfile() { Start: if (Profiles.Count() == 0) { Auth.Login(); return(0); } else { var menuList = new List <string>(); for (int i = 0; i < Profiles.Count(); i++) { menuList.Add( $"{Profiles.GetUser(i).GetName()} [{Profiles.GetUser(i).GetId()}]"); } menuList.Add("Добавить профиль"); int pos = gMenu.Menu(menuList, "Для дальнейшей работы выберите профиль"); if (pos > 0) { pos--; } if (pos == Profiles.Count()) { if (Auth.Login()) { goto Start; } else { return(-1); } } else { return(pos); } } }
public async Task <SshProfile> SelectProfile() { if (Profiles.Count() == 0) { _dialogService.ShowMessageDialogAsnyc("SSH Profile Selection", "There are no saved SSH Profiles.", DialogButton.OK); return(null); } else { var result = await ShowAsync(); if (result == ContentDialogResult.Primary) { return(SelectedProfile); } return(null); } }
protected override Composite CreateBehavior() { return(new Sequence( new Action(ret => Initialize()), new Action(ret => Logger.Log("LoadOnce: Found {0} Total Profiles, {1} Used Profiles, {2} Unused Profiles", Profiles.Count(), UsedProfileCount, UnusedProfileCount)), new PrioritySelector( new Decorator(ret => AvailableProfiles.Length == 0, new Sequence( new Action(ret => Logger.Log("LoadOnce: All available profiles have been used!", true)), new Action(ret => LastUpdate = DateTime.UtcNow.Ticks.GetHashCode()), new Action(ret => _isDone = true) ) ), new Decorator(ret => AvailableProfiles.Length > 0, new Sequence( new PrioritySelector( new Decorator(ret => NoRandom, new Action(ret => _nextProfileName = AvailableProfiles[0]) ), new Action(ret => _nextProfileName = AvailableProfiles[_rand.Next(0, AvailableProfiles.Length)]) ), new Action(ret => _nextProfilePath = Path.Combine(_currentProfilePath, _nextProfileName)), new PrioritySelector( new Decorator(ret => File.Exists(_nextProfilePath), new Sequence( new Action(ret => Logger.Log("LoadOnce: Loading next profile: {0}", _nextProfileName)), new Action(ret => UsedProfiles.Add(_nextProfileName)), new Action(ret => ProfileManager.Load(_nextProfilePath)) ) ), new Action(ret => Logger.Log("LoadOnce: ERROR: Profile {0} does not exist!", _nextProfilePath)) ) ) ), new Action(ret => Logger.Log("LoadOnce: Unkown error", true)) ) )); }
public static void Save() { string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ZipVersionControl\\preferences.xml"); // Save profiles to file XmlDocument doc = new XmlDocument(); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); // Create xml declaration doc.AppendChild(docNode); XmlNode zipVersionControlNode = doc.CreateElement("ZipVersionControl"); // Create zip version control node doc.AppendChild(zipVersionControlNode); XmlNode profilesNode = doc.CreateElement("Profiles"); // Create profiles node zipVersionControlNode.AppendChild(profilesNode); for (int i = 0; i <= Profiles.Count() - 1; i++) { XmlNode profileNode = doc.CreateElement("Profile"); // Create profile node profileNode.Attributes.Append(doc.CreateAttribute("Name")).Value = Profiles[i].ProfileName; profileNode.Attributes.Append(doc.CreateAttribute("ZipFilePath")).Value = Profiles[i].ZipFilePath; profileNode.Attributes.Append(doc.CreateAttribute("RepositoryPath")).Value = Profiles[i].RepositoryPath; profileNode.Attributes.Append(doc.CreateAttribute("Username")).Value = Profiles[i].Username; profileNode.Attributes.Append(doc.CreateAttribute("EncryptedPassword")).Value = Convert.ToBase64String(Profiles[i].Password); profileNode.Attributes.Append(doc.CreateAttribute("LatestCommitTime")).Value = Profiles[i].LatestCommitTime.ToString(); profileNode.Attributes.Append(doc.CreateAttribute("ZipFileHash")).Value = Convert.ToBase64String(Profiles[i].ZipFileHash); profilesNode.AppendChild(profileNode); } XmlNode optionsNode = doc.CreateElement("Options"); // Create options node zipVersionControlNode.AppendChild(optionsNode); XmlNode gitNameNode = doc.CreateElement("GitName"); // Create git name node optionsNode.AppendChild(gitNameNode); gitNameNode.InnerText = GitName; XmlNode gitEmailNode = doc.CreateElement("GitEmail"); // Create git email node optionsNode.AppendChild(gitEmailNode); gitEmailNode.InnerText = GitEmail; doc.Save(filePath); }