Example #1
0
        public ActionResult Index()
        {
            DatabaseService   service    = new DatabaseService();
            ProfileCollection collection = new ProfileCollection(service);

            return(View(collection));
        }
Example #2
0
 public GameCore()
 {
     Application.EnableVisualStyles();
     runColor    = FigureColor.WHITE;
     pState      = new PlayersState();
     pCollection = new ProfileCollection("Users.db");
 }
Example #3
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            var deserializer = new DeserializerBuilder()
                               .WithNamingConvention(CamelCaseNamingConvention.Instance)
                               .Build();

            var regex = new Regex(@"\${([^}]+)}", RegexOptions.Compiled);

            // Load api config
            Config = deserializer.Deserialize <ApiConfig>(File.ReadAllText("api-config.yaml"));

            // Replace the environment variables.
            Config.ApiBasePath             = ReplaceVar(regex, Config.ApiBasePath);
            Config.ApiHost                 = ReplaceVar(regex, Config.ApiHost);
            Config.ServiceUrl              = ReplaceVar(regex, Config.ServiceUrl);
            Config.DataSource              = ReplaceVar(regex, Config.DataSource);
            Config.DocIndexKeyName         = ReplaceVar(regex, Config.DocIndexKeyName);
            Config.StagingDocType          = ReplaceVar(regex, Config.StagingDocType);
            Config.Authentication.Username = ReplaceVar(regex, Config.Authentication.Username);
            Config.Authentication.Password = ReplaceVar(regex, Config.Authentication.Password);

            foreach (var c in Config.Profiles.Values)
            {
                c.Username = ReplaceVar(regex, c.Username);
                c.Password = ReplaceVar(regex, c.Password);
            }

            // Load profiles
            Profiles = new ProfileCollection(Config.Profiles);

            SetTimer();
        }
Example #4
0
 public GameCore()
 {
     Application.EnableVisualStyles();
     runColor = FigureColor.WHITE;
     pState = new PlayersState();
     pCollection = new ProfileCollection("Users.db");
 }
Example #5
0
        public ActionResult Create(FormCollection fc)
        {
            try
            {
                Profile newProfile = new Profile();
                var     fullName   = fc["FullName"];


                string firstName = fullName.Substring(0, fullName.IndexOf(' '));
                //Treat everything after first white space as Last Name
                string lastName = fullName.Substring(fullName.IndexOf(' ') + 1);
                newProfile.FirstName = firstName;
                newProfile.LastName  = lastName;
                newProfile.Company   = fc["Company"];
                newProfile.JobTitle  = fc["JobTitle"];
                newProfile.role      = ProfileRoles.USER;
                newProfile.SPIERole  = "SPIE Member";
                //In future builds, add validation check if username already exists
                newProfile.username = fc["Username"];
                //In future builds, add validation check if password meets password requirements
                newProfile.username = fc["Password"];
                //Next two lines would be replaced with a database call if user passes all validation checks
                ProfileCollection collection = new ProfileCollection();
                collection.ProfileList.Add(newProfile);

                //After database call is successful, send the user to profileView with newly created ID
                //otherwise, for assignment demo purpose, just go back home
                return(RedirectToAction(actionName: "Index", controllerName: "Home"));
            }
            catch
            {
                return(RedirectToAction(actionName: "Index", controllerName: "Home"));
            }
        }
Example #6
0
        public ActionResult EditProfileCollection(int profileCollectionId)
        {
            //Get all profiles
            IOrderedEnumerable <ProfileDetails> allProfiles = _reader.GetProfiles().OrderBy(x => x.Name);

            ProfileCollection profileCollection = _reader.GetProfileCollection(profileCollectionId);

            profileCollection.ProfileCollectionItems = new List <ProfileCollectionItem>();

            profileCollection.Id = profileCollectionId;
            IList <ProfileCollectionItem> profileCollectionItems = _reader.GetProfileCollectionItems(profileCollectionId);

            foreach (ProfileDetails profile in allProfiles)
            {
                profileCollection.ProfileCollectionItems.Add(new ProfileCollectionItem
                {
                    ProfileId      = profile.Id,
                    profileDetails = profile,
                    Selected       = profileCollectionItems.Any(x => x.ProfileId == profile.Id),
                    DisplayDomains =
                        profileCollectionItems.Where(x => x.ProfileId == profile.Id)
                        .Select(x => x.DisplayDomains)
                        .FirstOrDefault()
                });
            }

            if (HttpContext.Request.UrlReferrer != null)
            {
                profileCollection.ReturnUrl = HttpContext.Request.UrlReferrer.ToString();
            }

            return(View("EditProfileCollection", profileCollection));
        }
Example #7
0
        // GET: SearchResults
        public ActionResult SearchResults(string txtSearch)
        {
            if (!String.IsNullOrEmpty(txtSearch))
            {
                //Validation
                string[] names = txtSearch.Split(' ');
                //Retrieve profiles
                ProfileCollection collection = new ProfileCollection();
                List <Profile>    profiles   = new List <Profile>();

                //Partial Name Search
                if (names.Length == 1)
                {
                    profiles = collection.GetProfilesByFirstNameOrLastName(txtSearch);
                }
                //Full Name Search
                if (names.Length > 1)
                {
                    string firstName = txtSearch.Substring(0, txtSearch.IndexOf(' '));
                    //Treat everything after first white space as Last Name
                    string lastName = txtSearch.Substring(txtSearch.IndexOf(' ') + 1);
                    profiles = collection.GetProfilesByFullName(firstName, lastName);
                }
                if (profiles.Count > 0)
                {
                    return(View(profiles));
                }
            }
            return(RedirectToAction(actionName: "Index", controllerName: "Home"));
        }
Example #8
0
 public ProfileWindow(ProfileCollection lst)
 {
     pCollection = lst;
     InitializeComponent();
     foreach (Profile item in pCollection)
     {
         ProfileData.Rows.Add(item.NickName, item.eMail, item.Score, item.WinCount, item.LossCount);
     }
 }
Example #9
0
 public ProfileWindow(ProfileCollection lst)
 {
     pCollection = lst;
     InitializeComponent();
     foreach (Profile item in pCollection)
     {
         ProfileData.Rows.Add(item.NickName, item.eMail, item.Score, item.WinCount, item.LossCount);
     }
 }
        private void LoadPlayers()
        {
            WebClient wc            = new WebClient();
            string    playersString = wc.DownloadString("http://users.nik.uni-obuda.hu/siposm/db/players_v2.json");

            JsonConvert
            .DeserializeObject <List <Profile> >(playersString)
            .ForEach(x => ProfileCollection.Insert(x, false));
        }
Example #11
0
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            try
            {
                WindowsPrincipal wp      = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                Person           sPerson = new Person(wp.Identity.Name);
                if (sPerson.PersonID == -1)
                {
                    MessageBox.Show("Your Login ID is not associated with a person record in Arena.  In order to import tag members, you must have a valid person record in Arena.");
                    Application.Exit();
                }
                else
                {
                    ProfileCollection pColl = new ProfileCollection();

                    // Load Current User's Personal Tags
                    pColl.LoadPrivateProfiles(
                        Int32.Parse(ConfigurationSettings.AppSettings["Organization"]),
                        sPerson.PersonID,
                        true);

                    // Load Current User's Subscribed Tags
                    pColl.LoadSubscribedProfiles(
                        Int32.Parse(ConfigurationSettings.AppSettings["Organization"]),
                        sPerson.PersonID);

                    // Remove any duplicate tag names
                    for (int i = pColl.Count - 1; i >= 0; i--)
                    {
                        for (int j = 0; j < pColl.Count; j++)
                        {
                            if (j != i && pColl[j].ProfileID == pColl[i].ProfileID)
                            {
                                pColl.RemoveAt(i);
                                break;
                            }
                        }
                    }

                    // Add each tag to the checkbox list
                    foreach (Profile profile in pColl)
                    {
                        clbTags.Items.Add(new CheckItem(profile.Title, profile.ProfileID), CheckState.Checked);
                    }
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show("An error occurred while attempting to retrieve your private tags:\n\n" + ex.Message, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #12
0
        private void ReadProfileListFromDataFile()
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(ProfileCollection));
            XDocument     doc           = GetDataFileXDocument();

            using (var reader = doc.Root.CreateReader())
            {
                profileCollection = (ProfileCollection)xmlSerializer.Deserialize(reader);
            }
        }
 private AccountDomainObject CreateAccount(AccountName accountName, IEnumerable<Profile> profiles)
 {
     var profileDomainObjects = profiles.Select(p => _profileFactory.Create(p, accountName)).ToList();
     var profileCollection = new ProfileCollection(accountName, profileDomainObjects)
                                 {
                                     EventAggregator = _eventAggregator,
                                     ProfileRepository = _profileRepository
                                 };
     return new AccountDomainObject(accountName, profileCollection);
 }
Example #14
0
        private void InitDataFile(string dataFilePath)
        {
            profileCollection = new ProfileCollection();
            XmlSerializer xmlSerializer = new XmlSerializer(profileCollection.GetType());

            using (TextWriter writer = new StreamWriter(dataFilePath))
            {
                xmlSerializer.Serialize(writer, profileCollection);
            }
        }
Example #15
0
        public ActionResult SearchForm(SearchModel searchModel)
        {
            // Instantiate profile collection and set filter text
            DatabaseService   service    = new DatabaseService();
            ProfileCollection collection = new ProfileCollection(service);

            collection.FilterText = searchModel.SearchText;

            return(View("Index", collection));
        }
 private void ValidateUniqueness(PluginProfileDto pluginProfile, PluginProfileErrorCollection errors)
 {
     if (
         ProfileCollection.Any(
             x => string.Equals(x.Name.Value, pluginProfile.Name, StringComparison.InvariantCultureIgnoreCase)))
     {
         errors.Add(new PluginProfileError {
             FieldName = "Name", Message = "Profile name should be unique for plugin"
         });
     }
 }
        public void CreateProfile(string accountName, string profileName)
        {
            ObjectFactory.GetInstance <PluginContextMock>().AccountName = accountName;
            ProfileCollection.Add(new ProfileCreationArgs(profileName, new object()));

            Bus.ResetExpectations();
            NServiceBusMockRegistry.Setup(Bus);

            Context.AccountName = accountName;
            Context.ProfileName = profileName;
        }
Example #18
0
        private AccountDomainObject CreateAccount(AccountName accountName, IEnumerable <Profile> profiles)
        {
            var profileDomainObjects = profiles.Select(p => _profileFactory.Create(p, accountName)).ToList();
            var profileCollection    = new ProfileCollection(accountName, profileDomainObjects)
            {
                EventAggregator   = _eventAggregator,
                ProfileRepository = _profileRepository
            };

            return(new AccountDomainObject(accountName, profileCollection));
        }
Example #19
0
 public InviteWindow(ProfileCollection profileCollection)
 {
     pCollection = profileCollection;
     InitializeComponent();
     label1.Visible = false;
     IPBox.Visible = false;
     ConnectButton.Visible = false;
     CancelButton.Visible = false;
     StartServerButton.Visible = false;
     StartClientButton.Visible = false;
     loading = new LoadingDelegate(Loading);
 }
Example #20
0
        public ActionResult InsertProfileCollection(ProfileCollection profileCollection, string assignedProfiles)
        {
            var newProfileCollection = new ProfileCollection
            {
                CollectionName      = profileCollection.CollectionName,
                CollectionSkinTitle = profileCollection.CollectionSkinTitle
            };

            _profileRepository.CreateProfileCollection(newProfileCollection, assignedProfiles);

            return(RedirectToAction("ManageProfileCollections"));
        }
Example #21
0
 public InviteWindow(ProfileCollection profileCollection)
 {
     pCollection = profileCollection;
     InitializeComponent();
     label1.Visible            = false;
     IPBox.Visible             = false;
     ConnectButton.Visible     = false;
     CancelButton.Visible      = false;
     StartServerButton.Visible = false;
     StartClientButton.Visible = false;
     loading = new LoadingDelegate(Loading);
 }
        public ProfileModel(int ID)
        {
            ProfileCollection collection = new ProfileCollection();

            Profiles.Business.Profile userProfile = collection.GetProfile(ID);

            FullName        = userProfile.FirstName + " " + userProfile.LastName;
            SPIERole        = userProfile.SPIERole;
            Company         = userProfile.Company;
            JobTitle        = userProfile.JobTitle;
            PictureFileName = userProfile.PictureFileName;
        }
        private static void SetCurrentPluginContext(AccountName accountName, ProfileName profileName, string pluginName)
        {
            var context = ObjectFactory.GetInstance <PluginContextMock>();

            context.AccountName = accountName;
            context.PluginName  = pluginName;
            context.ProfileName = profileName;

            var profile = ProfileCollection.First(x => x.Name == profileName);

            Bus.SetIn(accountName);
            Bus.SetIn(profile.Name);
        }
Example #24
0
        public Contracts.GenericListResult<Contracts.ProfileMember> GetPersonProfileMembership(int id, int type, string inactive, int start, int max)
        {
            Contracts.GenericListResult<Contracts.ProfileMember> list = new Contracts.GenericListResult<Contracts.ProfileMember>();
            ProfileCollection pmc = new ProfileCollection();
            bool activeOnly = true;

            //
            // Check if they want to include inactive records.
            //
            try
            {
                if (Convert.ToInt32(inactive) == 1)
                    activeOnly = false;
            }
            catch { }

            //
            // Check general.
            //
            if (type == (int)Enums.ProfileType.Ministry && RestApi.PersonFieldOperationAllowed(ArenaContext.Current.Person.PersonID, PersonFields.Activity_Ministry_Tags, OperationType.View) == false)
                throw new Exception("Access denied");
            else if (type == (int)Enums.ProfileType.Serving && RestApi.PersonFieldOperationAllowed(ArenaContext.Current.Person.PersonID, PersonFields.Activity_Serving_Tags, OperationType.View) == false)
                throw new Exception("Access denied");
            else if (type != (int)Enums.ProfileType.Personal && type != (int)Enums.ProfileType.Ministry && type != (int)Enums.ProfileType.Serving)
                throw new Exception("Access denied");

            //
            // If they are requesting membership in their own personal profiles
            // then retrieve those, otherwise retrieve the general profile
            // information.
            //
            if (type == (int)Enums.ProfileType.Personal)
                pmc.LoadMemberPrivateProfiles(RestApi.DefaultOrganizationID(), ArenaContext.Current.Person.PersonID, id, activeOnly);
            else
                pmc.LoadMemberProfiles(RestApi.DefaultOrganizationID(), (Enums.ProfileType)type, id, activeOnly);

            list.Items = new List<Contracts.ProfileMember>();
            list.Start = start;
            list.Max = max;
            foreach (Profile p in pmc)
            {
                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, p.ProfileID, OperationType.View) == false)
                    continue;

                if (list.Total >= start && list.Items.Count < max)
                    list.Items.Add(new Contracts.ProfileMember(new ProfileMember(p.ProfileID, id)));
                list.Total += 1;
            }

            return list;
        }
Example #25
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ProfileCollection myProfiles = new ProfileCollection();
            SqlDataReader     rdr        = new Arena.DataLayer.Core.ProfileData().GetProfileByOwnerID(CurrentOrganization.OrganizationID, CurrentPerson.PersonID, true);

            while (rdr.Read())
            {
                myProfiles.Add(new Profile(rdr));
            }
            rdr.Close();

            rptTags.DataSource = myProfiles;
            rptTags.DataBind();
        }
Example #26
0
        private void InitData()
        {
            // Aircraft data
            profiles = new ProfileCollection();
            var err = profiles.Initialize().ToList();

            if (err.Count > 0)
            {
                this.ShowWarning(string.Join("\n", err), "Performance file loading warning");
            }

            try
            {
                // Load options.
                var o = OptionManager.ReadOrCreateFile();

                appOptionsLocator = new Locator <AppOptions>()
                {
                    Instance = OptionManager.TryDetectSimulatorPathsAndSave(o)
                };
            }
            catch (Exception ex)
            {
                Log(ex);
                this.ShowError("Cannot load options. The application will quit now.");
                Environment.Exit(1);
            }

            try
            {
                InitAirportAndWaypoints();
            }
            catch (Exception ex)
            {
                Log(ex);
                failedToLoadNavDataAtStartUp = true;

                countryCodesLocator = new Locator <CountryCodeManager>(null);
                airwayNetwork       = new AirwayNetwork(
                    new DefaultWaypointList(), new DefaultAirportManager(),
                    new MultiMap <string, Navaid>());
            }

            procFilter       = new ProcedureFilter();
            windTableLocator = new Locator <IWxTableCollection>()
            {
                Instance = new DefaultWxTableCollection()
            };
            updater = new Updater();
        }
Example #27
0
        public JsonResult getProfile()
        {
            ProfileCollection collection = new ProfileCollection();

            collection.Items = new List <object>
            {
                new ProfileModel()
                {
                    Name           = "Serguei Fedorov",
                    AboutText      = "I will admit, I didn't understand anything in programming when I started. It's certainly been a very long journey with many abitious projects before I actually started to understand what I was doing. The field of software development is so vast and I just wanted to know it all. <br />",
                    ProfilePicture = "Content/SergueiFedorov.png"
                }
            };

            return(Json(collection, JsonRequestBehavior.AllowGet));
        }
Example #28
0
        public ProfileModel(int ID, string filter = "")
        {
            DatabaseService   service    = new DatabaseService();
            ProfileCollection collection = new ProfileCollection(service)
            {
                FilterText = filter
            };

            Profiles.Business.Profile userProfile = collection.GetProfile(ID);

            FullName        = userProfile.FirstName + " " + userProfile.LastName;
            SPIERole        = userProfile.SPIERole;
            Company         = userProfile.Company;
            JobTitle        = userProfile.JobTitle;
            PictureFileName = userProfile.PictureFileName;
        }
        private void Add()
        {
            NewPlayerWindow npw        = new NewPlayerWindow();
            Profile         newProfile = new Profile();

            npw.DataContext = newProfile;
            if (npw.ShowDialog() == true)
            {
                newProfile.Image  = "https://randomuser.me/api/portraits/men/";
                newProfile.Image += new Random().Next(0, 60).ToString() + ".jpg";
                ProfileCollection.Insert(newProfile, false);
            }

            // alapból a lista végére rakunk (false)
            // itt most jól is jön ki mert a GUI-nál trükközni kéne, hogy a lista elejére való beszúráskor ott is jelenjen meg
            // eddig ez nem jött elő, mert list és obscoll esetén is a végére rak a .Add
        }
Example #30
0
        /// <summary>
        /// Retrieve the profile for the specified user. If the profile is cached in the database
        /// it returns the full details immediately. Otherwise it creates and returns an empty
        /// profile.
        /// </summary>
        /// <param name="username">The user whose profile is requested</param>
        /// <returns>A profile for the specified user. May be incomplete if the full profile
        /// is not cached in the database.</returns>
        public static Profile ProfileForUser(string username)
        {
            // Enforce lowercase usernames
            username = username.ToLower();

            ProfileCollection prc     = CIX.ProfileCollection;
            Profile           profile = prc.Get(username);

            if (profile == null)
            {
                profile = new Profile
                {
                    Username = username,
                };
                prc.Add(profile);
            }

            return(profile);
        }
Example #31
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (CurrentPerson == null || CurrentPerson.PersonID == -1)
            {
                throw new ArenaApplicationException("SpeedDialer module requires that a user be logged in.  Please configure security so that only 'registered' users have access to this page.");
            }

            if (CurrentPerson.Peers.Count > 0)
            {
                string phoneTagName = CurrentOrganization.Settings["PBXPersonalListTagName"];
                if (phoneTagName != null)
                {
                    ProfileCollection personalTags = new ProfileCollection();
                    personalTags.LoadChildProfileHierarchy(-1, CurrentOrganization.OrganizationID, ProfileType.Personal, CurrentPerson.PersonID);
                    Arena.Core.Profile contactList = GetContactList(personalTags, phoneTagName.Trim().ToLower());

                    if (contactList != null)
                    {
                        lTagName.Text = contactList.Title;

                        extensionRules = new LookupType(SystemLookupType.PhoneInternalExtensionRules).Values;
                        PBXSystem      = PBXHelper.DefaultPBXSystem(CurrentOrganization);
                        manager        = PBXHelper.GetPBXClass(PBXSystem);

                        lvContacts.DataSource = contactList.Members;
                        lvContacts.DataBind();
                    }
                    else
                    {
                        this.Visible = false;
                    }
                }
                else
                {
                    this.Visible = false;
                }
            }
            else
            {
                this.Visible = false;
            }
        }
Example #32
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                LoadProfiles();
            }
            catch { }
            if (_profiles == null)
            {
                _profiles = new ProfileCollection();
                _profiles.Add(new Profile()
                {
                    Name = "Default"
                });
                _profiles.DefaultProfile = "Default";
            }
            cmbProfiles.ItemsSource = _profiles;
        }
        public ProfileModel(int ID)
        {
            //Retrieve current selection of profiles
            ProfileCollection collection = new ProfileCollection();

            //Determine if queried profile exists
            Profiles.Business.Profile userProfile = collection.GetProfile(ID);
            if (userProfile != null)
            {
                FullName        = userProfile.FirstName + " " + userProfile.LastName;
                SPIERole        = userProfile.SPIERole;
                Company         = userProfile.Company;
                JobTitle        = userProfile.JobTitle;
                PictureFileName = userProfile.PictureFileName;
            }
            else
            {
                throw new Exception("Profile doesn't exist");
            }
        }
Example #34
0
        protected Profile GetContactList(ProfileCollection profiles, string tagName)
        {
            foreach (Profile profile in profiles)
            {
                if (profile.Name.Trim().ToLower() == tagName)
                {
                    return(profile);
                }
            }

            foreach (Profile profile in profiles)
            {
                Arena.Core.Profile contactList = GetContactList(profile.ChildProfiles, tagName);
                if (contactList != null)
                {
                    return(contactList);
                }
            }

            return(null);
        }
Example #35
0
        public ActionResult CreateProfileCollection()
        {
            //Get all profiles
            IOrderedEnumerable <ProfileDetails> allProfiles = _reader.GetProfiles().OrderBy(x => x.Name);
            var profileCollection = new ProfileCollection {
                ProfileCollectionItems = new List <ProfileCollectionItem>()
            };

            foreach (ProfileDetails profileDetails in allProfiles)
            {
                profileCollection.ProfileCollectionItems.Add(new ProfileCollectionItem {
                    profileDetails = profileDetails
                });
            }

            if (HttpContext.Request.UrlReferrer != null)
            {
                profileCollection.ReturnUrl = HttpContext.Request.UrlReferrer.ToString();
            }

            return(View("CreateProfileCollection", profileCollection));
        }
Example #36
0
        public ActionResult Logon(FormCollection collection)
        {
            try
            {
                string username = collection["Username"].Trim();
                string password = collection["Password"].Trim();

                ProfileCollection profiles = new ProfileCollection();
                foreach (Profile profile in profiles.ProfileList)
                {
                    if (profile.username.Equals(username) &&
                        profile.password.Equals(password))
                    {
                        HttpCookie userID = new HttpCookie("User");
                        userID.Value = profile.ID.ToString();
                        HttpCookie userNm = new HttpCookie("Username");
                        userNm.Value = profile.FirstName;
                        HttpCookie role = new HttpCookie("Role");
                        role.Value = profile.role;
                        this.ControllerContext.HttpContext.Response.Cookies.Add(userID);
                        this.ControllerContext.HttpContext.Response.Cookies.Add(userNm);
                        this.ControllerContext.HttpContext.Response.Cookies.Add(role);
                    }
                }

                if (Request.Cookies["User"] != null)
                {
                    return(RedirectToAction(actionName: "Index", controllerName: "Home"));
                }
                else
                {
                    return(RedirectToAction(actionName: "Logon", controllerName: "Profile"));
                }
            }
            catch
            {
                return(RedirectToAction(actionName: "Index", controllerName: "Home"));
            }
        }
		public AccountDomainObject(AccountName accountName, ProfileCollection profileCollection)
		{
			_accountName = accountName;
			_profileCollection = profileCollection;
		}
		public AccountDomainObject(AccountDomainObject other)
		{
			_accountName = other._accountName;
			_profileCollection = new ProfileCollection(other._profileCollection);
		}
        private void CompleteQuery()
        {
            if (startDateCalendar.SelectedDate.Value.Date.Equals(DateTime.Today))
            {
                _query.TimePeriod = (TimePeriod)Enum.Parse(typeof(TimePeriod), TimeSpanBoxesColl.Where(p => (bool)p.IsChecked).First().Tag.ToString());
                _query.SelectDates = false;
            }
            else
            {
                _query.EndDate = (DateTime)endDateCalendar.SelectedDate;
                _query.SelectDates = true;
            }

            if (_query.Ids.Count == 0)
            {
                Item pItem = new Item(_query.ProfileId.First().Value, _query.ProfileId.First().Key);
                ProfileCollection multipleProfile = new ProfileCollection();
                multipleProfile.Add(pItem);
                _query.Ids = multipleProfile;
            }

            if (dimensionsMayHaveChanged)
                _query.Dimensions = GetCheckedItems(DimensionsView.tree.Items[0] as SizeViewModel);
            if (metricsMayHaveChanged)
                _query.Metrics = GetCheckedItems(MetricsView.tree.Items[0] as SizeViewModel);
            // If the user have not entered a interval of hits to view, then set them static here before calling GA.
            //            if (startIndexTextBox.Text.Equals(""))
            //                startIndexTextBox.Text = "0";
            if (maxResultsTextBox.Text.Equals("0"))
                maxResultsTextBox.Text = "10000";

            _query.StartIndex = int.Parse(startIndexTextBox.Text);
            _query.MaxResults = int.Parse(maxResultsTextBox.Text);

            if (sortBycomboBox.SelectedIndex != -1)
            {
                queryNotCompleted = false;
                ListSortOrder();
            }

            //            _query.Ids.Clear();
            //            _query.Ids.Add((comboBoxProfile.SelectedItem as Entry).Title, (comboBoxProfile.SelectedItem as Entry).ProfileId);
        }
Example #40
0
 internal ProfileManager()
 {
     profiles = new ProfileCollection();
 }
        private void BindProfileListBox()
        {
            ProfileCollection multiProfiles = new ProfileCollection();
            Binding profileBinding = new Binding();
            ProfileCollection multipleProfiles = new ProfileCollection();
            Item pItem;
            if (_query.Ids.Count == 0)
            {
                pItem = new Item(_query.ProfileId.First().Value, _query.ProfileId.First().Key);
                multipleProfiles.Add(pItem);
                _query.Ids = multipleProfiles;
            }

            foreach (Item item in _query.Ids)
            {
                // make sure item's Value is set
                string value = (item.Key.IndexOf("ga:") == 0 ? "" : "ga:") + item.Key;
                if (_query.ProfileId.ContainsValue(value))
                {
                    item.Value = _query.ProfileId.GetKeyByValue(value);
                }
                multiProfiles.Add(item);
            }

            _query.Ids = multiProfiles;
            profileBinding.Source = multiProfiles;
            profileBox.SetBinding(ListBox.ItemsSourceProperty, profileBinding);
        }
Example #42
0
        private void LoadProfiles()
        {
            string path = App.AppDataPath + "\\Profiles.dat";

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                _profiles = ProfileCollection.FromStream(fs);
            }
        }
Example #43
0
        public Object GetProfileList(String profileID, String profileType, int start, int max, String fields)
        {
            ProfileCollection profiles = null;
            Contracts.ProfileMapper mapper = null;
            Contracts.GenericListResult<Contracts.Profile> listP = new Contracts.GenericListResult<Contracts.Profile>();
            Contracts.GenericListResult<Contracts.GenericReference> listR = new Contracts.GenericListResult<Contracts.GenericReference>();
            int i;

            if (profileType != null)
            {
                profiles = new ProfileCollection();
                profiles.LoadChildProfiles(-1, RestApi.DefaultOrganizationID(), (Arena.Enums.ProfileType)Convert.ToInt32(profileType), ArenaContext.Current.Person.PersonID);
            }
            else if (profileID != null)
            {
                Profile profile;

                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(profileID), OperationType.View) == false)
                    throw new Exception("Access denied.");

                profile = new Profile(Convert.ToInt32(profileID));
                profiles = profile.ChildProfiles;
            }
            else
                throw new Exception("Required parameters not provided.");

            //
            // Sort the list of profiles and determine if we are going to
            // be returning references or full objects.
            //
            profiles.Sort(delegate(Profile p1, Profile p2) { return p1.Name.CompareTo(p2.Name); });
            mapper = (string.IsNullOrEmpty(fields) ? null : new Contracts.ProfileMapper(new List<string>(fields.Split(','))));

            //
            // Prepare the appropraite list object.
            //
            if (mapper != null)
            {
                listP.Start = start;
                listP.Max = max;
                listP.Total = 0;
                listP.Items = new List<Contracts.Profile>();
            }
            else
            {
                listR.Start = start;
                listR.Max = max;
                listR.Total = 0;
                listR.Items = new List<Contracts.GenericReference>();
            }
            for (i = 0; i < profiles.Count; i++)
            {
                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, profiles[i].ProfileID, OperationType.View) == false)
                    continue;

                if (mapper != null)
                {
                    if (listP.Total >= start && (max <= 0 ? true : listP.Items.Count < max))
                        listP.Items.Add(mapper.FromArena(profiles[i]));
                    listP.Total += 1;
                }
                else
                {
                    if (listR.Total >= start && (max <= 0 ? true : listR.Items.Count < max))
                       listR.Items.Add(new Contracts.GenericReference(profiles[i]));
                    listR.Total += 1;
                }
            }

            return (mapper != null ? (Object)listP : (Object)listR);
        }