private bool AddToCache(RTTrackingProfile profile, Type serviceType, bool resetNoProfiles)
 {
     if (null == serviceType)
     {
         return false;
     }
     lock (this._cacheLock)
     {
         Dictionary<Type, ProfileList> dictionary = null;
         if (!this._cacheLookup.TryGetValue(serviceType, out dictionary))
         {
             dictionary = new Dictionary<Type, ProfileList>();
             this._cacheLookup.Add(serviceType, dictionary);
         }
         ProfileList list = null;
         if (!dictionary.TryGetValue(profile.WorkflowType, out list))
         {
             list = new ProfileList();
             dictionary.Add(profile.WorkflowType, list);
         }
         if (resetNoProfiles)
         {
             list.NoProfile = false;
         }
         return list.Profiles.TryAdd(new CacheItem(profile));
     }
 }
Пример #2
0
 public ProfileListResponse Get(ProfileList items)
 {
     var profiles = db.ListProfiles();
     var result = new ProfileListResponse() {
         Items = profiles.Select(p => p.ToProfileResponse()).ToList()
     };
     return (result);
 }
Пример #3
0
 public static void Load()
 {
     BinaryFormatter bf = new BinaryFormatter ();
     FileStream file = File.Open (Application.persistentDataPath + "/" + fileName, FileMode.Open);
     SaveLoad.list = (ProfileList)bf.Deserialize (file);
     file.Close ();
     Debug.Log ("Loaded");
 }
        private bool TryGetFromCache(Type serviceType, Type workflowType, Version versionId, out RTTrackingProfile profile)
        {
            profile = null;
            CacheItem item = null;

            lock (this._cacheLock)
            {
                Dictionary <Type, ProfileList> dictionary = null;
                if (this._cacheLookup.TryGetValue(serviceType, out dictionary))
                {
                    ProfileList list = null;
                    if (!dictionary.TryGetValue(workflowType, out list))
                    {
                        return(false);
                    }
                    if (versionId.Major == 0)
                    {
                        if (!list.NoProfile)
                        {
                            if ((list.Profiles == null) || (list.Profiles.Count == 0))
                            {
                                return(false);
                            }
                            int num = list.Profiles.Count - 1;
                            if (list.Profiles[num] == null)
                            {
                                return(false);
                            }
                            profile = list.Profiles[num].TrackingProfile;
                        }
                        return(true);
                    }
                    if (((list.Profiles != null) && (list.Profiles.Count != 0)) && list.Profiles.TryGetValue(new CacheItem(workflowType, versionId), out item))
                    {
                        profile = item.TrackingProfile;
                        return(true);
                    }
                }
                return(false);
            }
        }
Пример #5
0
        public ActionResult AllProfiles(ProfileList model)
        {
            var profiles = _usersProvider.GetAllProfilesOderBy();

            foreach (var profile in profiles)
            {
                var profileViewModel = new ProfileViewModel
                {
                    Surname     = profile.Surname,
                    Name        = profile.Name,
                    Middle_name = profile.MiddleName,
                    Email       = profile.Email,
                    Comments    = profile.Comments,
                    Phone       = profile.Phone,
                    Password    = profile.Password,
                    Upload      = profile.PhotoURL
                };
                model.ProfilesList.Add(profileViewModel);
            }
            return(View(model));
        }
Пример #6
0
        public void LoadProfiles(string selectprofile)
        {
            string     profiles    = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ProfileIDs", "0");
            List <int> profileints = profiles.RestoreIntListFromString(1, 0); // default is length 1, value 0

            foreach (int profileid in profileints)
            {
                StringParser sp = new StringParser(EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(ProfilePrefix(profileid) + "Settings", ""));

                string name          = sp.NextQuotedWordComma();
                string tripcondition = sp.NextQuotedWordComma();
                string backcondition = sp.NextQuotedWord();

                if (name != null && tripcondition != null && backcondition != null)
                {
                    Profile p = new Profile(profileid, name, tripcondition, backcondition);
                    System.Diagnostics.Debug.WriteLine("Profile {0} {1} {2}", name, tripcondition, backcondition);
                    ProfileList.Add(p);
                }
            }

            if (ProfileList.Count == 0)
            {
                ProfileList.Add(new Profile(DefaultId, "Default", "Condition AlwaysFalse", "Condition AlwaysFalse"));
            }

            int curid = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ProfilePowerOnID", DefaultId);

            if (selectprofile != null)
            {
                int found = ProfileList.FindIndex(x => x.Name.Equals(selectprofile, StringComparison.InvariantCultureIgnoreCase));
                if (found >= 0)
                {
                    curid = ProfileList[found].Id;
                }
            }

            PowerOn = Current = ProfileList.Find(x => x.Id == curid) ?? ProfileList[0];
            History.Push(Current.Id);
        }
Пример #7
0
        /// <summary>
        /// Fetch ProfileList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public ProfileList Fetch(ProfileCriteria criteria)
        {
            ProfileList item = (ProfileList)Activator.CreateInstance(typeof(ProfileList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Profile_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_IsAnonymousHasValue", criteria.IsAnonymousHasValue);
                    command.Parameters.AddWithValue("@p_LastActivityDateHasValue", criteria.LastActivityDateHasValue);
                    command.Parameters.AddWithValue("@p_LastUpdatedDateHasValue", criteria.LastUpdatedDateHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new ProfileFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
Пример #8
0
        public bool CopyProfile(string name)
        {
            Profile profile = (Profile)CurrentProfile.Clone();

            profile.Name = name;

            if (ProfileList.ContainsKey(profile.Name))
            {
                return(false);
            }

            ProfileList.Add(profile.Name, profile);

            if (!_profileHandler.Save(profile, AppDomain.CurrentDomain.BaseDirectory + "profiles\\" + profile.Name))
            {
                EventOnIOProfileFail.Invoke("Cannot save profile file: <" + profile.Name + ">",
                                            "Load profile exception");
                return(false);
            }

            return(true);
        }
Пример #9
0
    public void CreateNewProfile()
    {
        Button but = Instantiate(profilebuttonPrefab);

        but.transform.SetParent(content.transform);
        Text text = but.transform.GetChild(0).gameObject.GetComponent <Text>();

        text.text = inputNewProfileName.text;

        // добавление в список профилей, либо создание нового списка, если такой отсутствует
        if (!File.Exists(Application.persistentDataPath + "/profilelist.json"))
        {
            ProfileList _profiles = new ProfileList(new List <string>()
            {
            });
            JsonData _jsonDataProfiles = JsonMapper.ToJson(_profiles);
            File.WriteAllText(Application.persistentDataPath + "/profilelist.json", _jsonDataProfiles.ToString());
        }

        string   jsonstring       = File.ReadAllText(Application.persistentDataPath + "/profilelist.json");
        JsonData jsonDataProfiles = JsonMapper.ToObject(jsonstring);

        List <string> newlist = new List <string>();

        for (int i = 0; i < jsonDataProfiles["profilesnames"].Count; i++)
        {
            newlist.Add(jsonDataProfiles["profilesnames"][i].ToString());
        }

        newlist.Add(text.text);

        ProfileList profiles = new ProfileList(newlist);

        jsonDataProfiles = JsonMapper.ToJson(profiles);
        File.WriteAllText(Application.persistentDataPath + "/profilelist.json", jsonDataProfiles.ToString());

        SaveManager.CreateEmptyProfile(text.text);
    }
        /// <summary>
        /// Fetch ProfileList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public ProfileList Fetch(ProfileCriteria criteria)
        {
            ProfileList item = (ProfileList)Activator.CreateInstance(typeof(ProfileList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            string commandText = String.Format("SELECT [UniqueID], [Username], [ApplicationName], [IsAnonymous], [LastActivityDate], [LastUpdatedDate] FROM [dbo].[Profiles] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new ProfileFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
Пример #11
0
    public static void Load()
    {
        if (!File.Exists(Application.persistentDataPath + "/" + SaveLoad.fileName))
        {
            Game.current = new Game();
            Game.current.currentProfile.profileName = "Default";
            list.latestGame = "Default";

            list.savedGames.Add(Game.current);
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(Application.persistentDataPath + "/" + fileName);
            bf.Serialize(file, SaveLoad.list);
            file.Close();
        }

        BinaryFormatter bfOpen   = new BinaryFormatter();
        FileStream      fileOpen = File.Open(Application.persistentDataPath + "/" + fileName, FileMode.Open);

        SaveLoad.list = (ProfileList)bfOpen.Deserialize(fileOpen);

        fileOpen.Close();
        Debug.Log("Loaded");
    }
Пример #12
0
        public static (bool, string) GenerateSettings(string file)
        {
            if (!File.Exists(file))
            {
                Log.Warning("Skipped terminal settings update because '{file}' doesn't exist", file);
                return(false, string.Empty); // If the file doesn't exist that's okay
            }
            var json  = File.ReadAllText(file);
            var cfg   = TerminalConfig.FromJson(json);
            var hosts = SSHParser.MapHosts();

            if (cfg.Profiles.HasValue)
            {
                var profileMaster = cfg.Profiles.Value;
                var profiles      = profileMaster.ProfilesObject;

                foreach (var host in hosts)
                {
                    var name = $"{host.Key} (SSH)";
                    if (profiles.List.Any((x) => x.Name == name))
                    {
                        continue;
                    }
                    var list = new ProfileList()
                    {
                        Guid        = "{" + Guid.NewGuid().ToString() + "}",
                        Commandline = $"ssh {host.Key}",
                        Name        = name,
                        CloseOnExit = CloseOnExitEnum.Always
                    };
                    profiles.List.Add(list);
                }
                cfg.Profiles = profiles;
            }

            return(true, cfg.ToJson());
        }
Пример #13
0
 public void LoadConfig(Config config)
 {
     if (config.SourceServer.UseProfile)
     {
         Isprofile      = true;
         IspST          = false;
         OutlookProfile = config.SourceServer.Profile;
         if (ProfileList.Count > 0)
         {
             CurrentProfileSelection = (OutlookProfile == null) ? 0 : ProfileList.IndexOf(
                 OutlookProfile);
         }
         else
         {
             ProfileList.Add(OutlookProfile);
         }
     }
     else
     {
         Isprofile = false;
         IspST     = true;
         PSTFile   = config.SourceServer.DataFile;
     }
 }
Пример #14
0
        public ActionResult ExternalProfiles(int pageIndex = 0, int pageSize = 4)
        {
            var profiles = _externalProfilesService.GetExternalProfiles();

            var profileListItems = profiles.SelectMany(a => a.Profiles);
            var pageCount        = ((int)profileListItems.Count()) / pageSize;

            if (profileListItems.Count() % pageSize != 0)
            {
                pageCount += 1;
            }

            var profileItems = Mapper.Map <IEnumerable <ProfileListItem> >(profileListItems);

            var viewModel = new ProfileList()
            {
                PageCount = pageCount,
                PageSize  = pageSize,
                PageIndex = pageIndex,
                Profiles  = profileItems.Skip(pageIndex * pageSize).Take(pageSize)
            };

            return(View("Index", viewModel));
        }
Пример #15
0
 public int IndexOf(int id)
 {
     return(ProfileList.FindIndex(x => x.Id == id));
 }
Пример #16
0
 public List <string> Names()
 {
     return(ProfileList.Select(x => x.Name).ToList());
 }
Пример #17
0
 /// <summary>
 /// Возвращает профиль для указанного класса.
 /// </summary>
 /// <param name="wowClass">Класс персонажа.</param>
 /// <returns>Профиль ротаций <see cref="YanittaProfile"/>.</returns>
 public Profile this[WowClass wowClass]
 {
     get { return(ProfileList.FirstOrDefault(n => n.Class == wowClass)); }
 }
Пример #18
0
        /// <summary>
        ///     Calls LiveAuthClient.Initialize to get the user login status.
        ///     Retrieves user profile information if user is already signed in.
        /// </summary>
        private async void InitializeSignInAsync()
        {
            try
            {
                this.authClient          = new LiveAuthClient(Config.LiveAuthClientId);
                m_ProgressBar.Visibility = System.Windows.Visibility.Visible;
                LiveLoginResult loginResult = await this.authClient.LoginAsync(scopes);

                if (loginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    this.liveClient = new LiveConnectClient(loginResult.Session);
                    AccessToken     = loginResult.Session.AccessToken;
                    RefreshToken    = loginResult.Session.RefreshToken;
                    LiveOperationResult operationResult = await this.liveClient.GetAsync("me");

                    dynamic properties = operationResult.Result;
                    LiveIdTextBox.Text            = properties.emails.account;
                    LiveAuthTokenPanel.Visibility = System.Windows.Visibility.Visible;
                    WaitTextBlock.Visibility      = System.Windows.Visibility.Collapsed;

                    if (NameTextBox.Text.Trim() == string.Empty && properties.name != null)
                    {
                        NameTextBox.Text = properties.name;
                    }

                    //LiveLoginButton.Visibility = Visibility.Collapsed;
                    //Save Email to Local Storage
                    Globals.User.Name       = NameTextBox.Text;
                    Globals.User.LiveEmail  = LiveIdTextBox.Text;
                    Globals.User.LiveAuthId = loginResult.Session.AuthenticationToken;
                    App.CurrentUser.UpdateUser(Globals.User);


                    //If user already exists, get all his info and store locally. Delete any local profile //TODO
                    ProfileList profiles = null;
                    try
                    {
                        profiles = await MembershipServiceWrapper.GetProfilesForLiveId();
                    }
                    catch (Exception ex)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToConnectService, "basicWrap", "Information!"));
                        return;
                    }
                    if (profiles != null && profiles.List.Count > 0)
                    {
                        //Load all profiles to Local Storage
                        // + Assign first profile as CurrentProfile

                        //If atleast one buddy, retain the profile. Else delete!
                        //Globals.CurrentProfile.MobileNumber = "0000000000";

                        profiles.List[0].IsSOSOn      = Globals.CurrentProfile.IsSOSOn;
                        profiles.List[0].IsTrackingOn = Globals.CurrentProfile.IsTrackingOn;
                        //profiles.List[0].SessionID = Globals.CurrentProfile.SessionToken;

                        App.MyProfiles.DeleteOfflineProfile();

                        UserViewModel.RestoreAllProfiles(profiles.List);

                        Globals.Load2CurrentProfile(profiles.List[0].ProfileID.ToString());

                        Globals.IsAutoUpgradeFailed = false;
                        //if (NavigationService.BackStack != null && NavigationService.BackStack.Count() > 0)
                        //    NavigationService.RemoveBackEntry();

                        if (Globals.CurrentProfile.CountryCode != null)
                        {
                            Globals.SetEmergencyNumbers(Globals.AllCountryCodes.First(c => c.IsdCode == Globals.CurrentProfile.CountryCode));
                        }

                        //Allow change of Current Profile in Settings
                        NavigationService.Navigate(new Uri("/Pages/Settings.xaml?FromPage=Register", UriKind.Relative));
                        Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.ProfileLoadedSuccessfullyText, "basicWrap", "Info!"));
                    }
                    else
                    {
                        WaitTextBlock.Visibility            = System.Windows.Visibility.Collapsed;
                        ProfilePanel.Visibility             = Visibility.Visible;
                        CountryCodeListPicker.SelectedIndex = CountryCodeListPicker.Items.IndexOf(CountryCodeListPicker.Items.First(c => ((c as CountryCodes).IsdCode == Constants.CountryCode)));
                    }
                }
                else if (loginResult.Status == LiveConnectSessionStatus.NotConnected || loginResult.Status == LiveConnectSessionStatus.Unknown)
                {
                    NavigationService.Navigate(new Uri("/Pages/Settings.xaml?FromPage=Register", UriKind.Relative));
                }
                else
                {
                    WaitTextBlock.Text = CustomMessage.UnableToGetLoginInfoText;
                }
            }
            catch (LiveAuthException authExp)
            {
                if (authExp.ErrorCode == "access_denied")
                {
                    IsComingFromBackground = true;
                }
                WaitTextBlock.Text = CustomMessage.UnableToGetLoginInfoText;
                //TODO: Authentication Token Expired!
            }
            catch (LiveConnectException ex)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.LiveConnectExceptionText, "basicWrap", "Connection error."));
                WaitTextBlock.Text = CustomMessage.UnableToGetLoginInfoText;
            }
            finally
            {
                m_ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
 public async Task AddAsync(ProfileType profileType, string name, System.Version version, string launchArgs = "")
 {
     ProfileList.Add(new Profile(profileType, name, version, launchArgs));
     await SaveAsync();
 }
 public async Task AddAsync(Profile profile)
 {
     ProfileList.Add(profile);
     await SaveAsync();
 }
 protected override ProfilesYaml ToYaml()
 {
     ProfileList.Remove(Latest);
     return(new ProfilesYaml(SelectedProfileIndex, ProfileList.Select(Profile.ToYaml).ToList()));
 }
 public IEnumerator <Profile> GetEnumerator() => ProfileList.GetEnumerator();
Пример #23
0
        public SpecialActionEditor(int deviceNum, ProfileList profileList,
                                   DS4Windows.SpecialAction specialAction = null)
        {
            InitializeComponent();

            triggerBoxes = new List <CheckBox>()
            {
                crossTrigCk, circleTrigCk, squareTrigCk, triangleTrigCk,
                optionsTrigCk, shareTrigCk, upTrigCk, downTrigCk,
                leftTrigCk, rightTrigCk, psTrigCk, l1TrigCk,
                r1TrigCk, l2TrigCk, r2TrigCk, l3TrigCk,
                r3TrigCk, leftTouchTrigCk, upperTouchTrigCk, multitouchTrigCk,
                rightTouchTrigCk, lsuTrigCk, lsdTrigCk, lslTrigCk,
                lsrTrigCk, rsuTrigCk, rsdTrigCk, rslTrigCk,
                rsrTrigCk, swipeUpTrigCk, swipeDownTrigCk, swipeLeftTrigCk,
                swipeRightTrigCk, tiltUpTrigCk, tiltDownTrigCk, tiltLeftTrigCk,
                tiltRightTrigCk,
            };

            unloadTriggerBoxes = new List <CheckBox>()
            {
                unloadCrossTrigCk, unloadCircleTrigCk, unloadSquareTrigCk, unloadTriangleTrigCk,
                unloadOptionsTrigCk, unloadShareTrigCk, unloadUpTrigCk, unloadDownTrigCk,
                unloadLeftTrigCk, unloadRightTrigCk, unloadPsTrigCk, unloadL1TrigCk,
                unloadR1TrigCk, unloadL2TrigCk, unloadR2TrigCk, unloadL3TrigCk,
                unloadR3TrigCk, unloadLeftTouchTrigCk, unloadUpperTouchTrigCk, unloadMultitouchTrigCk,
                unloadRightTouchTrigCk, unloadLsuTrigCk, unloadLsdTrigCk, unloadLslTrigCk,
                unloadLsrTrigCk, unloadRsuTrigCk, unloadRsdTrigCk, unloadRslTrigCk,
                unloadRsrTrigCk, unloadSwipeUpTrigCk, unloadSwipeDownTrigCk, unloadSwipeLeftTrigCk,
                unloadSwipeRightTrigCk, unloadTiltUpTrigCk, unloadTiltDownTrigCk, unloadTiltLeftTrigCk,
                unloadTiltRightTrigCk,
            };

            specialActVM      = new SpecialActEditorViewModel(deviceNum, specialAction);
            macroActVM        = new MacroViewModel();
            launchProgVM      = new LaunchProgramViewModel();
            loadProfileVM     = new LoadProfileViewModel(profileList);
            pressKeyVM        = new PressKeyViewModel();
            disconnectBtVM    = new DisconnectBTViewModel();
            checkBatteryVM    = new CheckBatteryViewModel();
            multiActButtonVM  = new MultiActButtonViewModel();
            saSteeringWheelVM = new SASteeringWheelViewModel();

            // Hide tab headers. Tab content will still be visible
            blankActTab.Visibility              = Visibility.Collapsed;
            macroActTab.Visibility              = Visibility.Collapsed;
            launchProgActTab.Visibility         = Visibility.Collapsed;
            loadProfileTab.Visibility           = Visibility.Collapsed;
            pressKetActTab.Visibility           = Visibility.Collapsed;
            disconnectBTTab.Visibility          = Visibility.Collapsed;
            checkBatteryTab.Visibility          = Visibility.Collapsed;
            multiActTab.Visibility              = Visibility.Collapsed;
            sixaxisWheelCalibrateTab.Visibility = Visibility.Collapsed;

            if (specialAction != null)
            {
                LoadAction(specialAction);
            }

            actionTypeTabControl.DataContext = specialActVM;
            actionTypeCombo.DataContext      = specialActVM;
            actionNameTxt.DataContext        = specialActVM;
            triggersListView.DataContext     = specialActVM;

            macroActTab.DataContext              = macroActVM;
            launchProgActTab.DataContext         = launchProgVM;
            loadProfileTab.DataContext           = loadProfileVM;
            pressKetActTab.DataContext           = pressKeyVM;
            disconnectBTTab.DataContext          = disconnectBtVM;
            checkBatteryTab.DataContext          = checkBatteryVM;
            multiActTab.DataContext              = multiActButtonVM;
            sixaxisWheelCalibrateTab.DataContext = saSteeringWheelVM;

            SetupLateEvents();
        }
Пример #24
0
 public void Add(IProfile p)
 {
     ProfileList.Add(p);
 }
Пример #25
0
        private ICollectionView GetList()
        {
            ProfileList profiles = (ProfileList)FindResource("profileList");

            return(CollectionViewSource.GetDefaultView(profiles));
        }
Пример #26
0
        public async void OnEditTap()
        {
            await _repository.DeleteAsync(SelectedItem);

            ProfileList.Remove(SelectedItem);
        }
 private void RemoveProfile(Type workflowType, Type serviceType)
 {
     lock (this._cacheLock)
     {
         Dictionary<Type, ProfileList> dictionary = null;
         if (!this._cacheLookup.TryGetValue(serviceType, out dictionary))
         {
             dictionary = new Dictionary<Type, ProfileList>();
             this._cacheLookup.Add(serviceType, dictionary);
         }
         ProfileList list = null;
         if (!dictionary.TryGetValue(workflowType, out list))
         {
             list = new ProfileList();
             dictionary.Add(workflowType, list);
         }
         list.NoProfile = true;
     }
 }
Пример #28
0
        public bool UpdateProfiles(List <Profile> newset, int poweronindex)        // true reload - Current is invalid if true, must reload to new profile
        {
            List <Profile> toberemoved = new List <Profile>();

            foreach (Profile p in ProfileList)
            {
                Profile c = newset.Find(x => x.Id == p.Id);

                if (c == null)         // if newset does not have this profile ID
                {
                    toberemoved.Add(p);
                }
                else
                {                             // existing in both, update
                    System.Diagnostics.Debug.WriteLine("Update ID " + p.Id);
                    p.Name          = c.Name; // update name and condition
                    p.TripCondition = c.TripCondition;
                    p.BackCondition = c.BackCondition;
                }
            }

            bool removedcurrent = false;

            foreach (Profile p in toberemoved)
            {
                if (Object.ReferenceEquals(Current, p))
                {
                    removedcurrent = true;
                }

                System.Diagnostics.Debug.WriteLine("Delete ID " + p.Id);
                EliteDangerousCore.DB.UserDatabase.Instance.DeleteKey(ProfilePrefix(p.Id) + "%");       // all profiles string
                ProfileList.Remove(p);
            }

            foreach (Profile p in newset.Where((p) => p.Id == -1))
            {
                int[] curids = (from x in ProfileList select x.Id).ToArray();

                int id = DefaultId + 1;
                for (; id < 10000; id++)
                {
                    if (Array.IndexOf(curids, id) == -1)
                    {
                        break;
                    }
                }

                System.Diagnostics.Debug.WriteLine("Make ID " + id);
                p.Id = id;
                ProfileList.Add(p);
            }

            poweronindex = poweronindex >= 0 ? poweronindex : 0;
            EliteDangerousCore.DB.UserDatabase.Instance.PutSettingInt("ProfilePowerOnID", ProfileList[poweronindex].Id);
            PowerOn = ProfileList[poweronindex];

            SaveProfiles();
            History.Clear();        // because an ID may have gone awol

            return(removedcurrent);
        }
Пример #29
0
    IEnumerator getPaginationData(string rowPerPage)
    {
        if (rowPerPage != "")
        {
            string          url      = "http://wamp.mobilist.com.tr/challenge/index.php?start=" + rowPerPage;
            UnityWebRequest request2 = UnityWebRequest.Get(url);
            request2.chunkedTransfer = false;
            yield return(request2.Send());

            if (request2.isDone)
            {
                //  Debug.Log("Oldu" + request2.responseCode);
                profileList = JsonUtility.FromJson <ProfileList>(request2.downloadHandler.text);


                //Date'a göre sıralama
                if (dateBool)
                {
                    profileList.feed.Sort((f1, f2) => System.DateTime.Parse(f1.CreatedAt).CompareTo(System.DateTime.Parse(f2.CreatedAt)));

                    profileList.feed.Reverse();
                }

                //Follower'a göre sıralama
                if (followerBool)
                {
                    profileList.feed.Sort((f1, f2) => Convert.ToInt32(f1.FollowerCount).CompareTo(Convert.ToInt32(f2.FollowerCount)));

                    profileList.feed.Reverse();
                }

                for (int i = 0; i < profileList.feed.ToArray().Length; i++)
                {
                    totalFeedList.Add(profileList.feed[i]);
                }
            }
        }

        Debug.Log("length = " + profileList.feed.ToArray().Length);
        for (int i = 1; i <= profileList.feed.ToArray().Length; i++)
        {
            membersPP = scrollItemPrefab.transform.GetChild(0).FindChild("Pp").GetComponent <RawImage>();
            //  Debug.Log(membersPP);
            membersUserName = scrollItemPrefab.transform.GetChild(0).FindChild("UserName").GetComponent <Text>();
            // Debug.Log(membersUserName);
            membersFollowers = scrollItemPrefab.transform.GetChild(0).FindChild("Followers").GetComponent <Text>();
            // Debug.Log(membersFollowers);
            membersTime = scrollItemPrefab.transform.GetChild(0).FindChild("Time").GetComponent <Text>();
            // Debug.Log(membersTime);

            UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(profileList.feed[i - 1].photo);
            yield return(uwr.SendWebRequest());

            membersPP.texture     = DownloadHandlerTexture.GetContent(uwr);
            membersUserName.text  = profileList.feed[i - 1].Name;
            membersFollowers.text = profileList.feed[i - 1].FollowerCount;
            membersTime.text      = profileList.feed[i - 1].CreatedAt;


            if (i > 1)
            {
                GameObject SIP = scrollItemPrefab.transform.GetChild(1).gameObject;
                SIP.SetActive(false);
            }

            generateItem();
        }

        //scrollView.verticalNormalizedPosition = 1;
    }