private void buttonEdit_Click(object sender, EventArgs e)
        {
            HMEntities.UserProfiles.User selectedUser = new HM.Entities.HattrickManager.UserProfiles.User();
            int selectedIndex = listBoxUserProfiles.SelectedIndex;

            foreach (HMEntities.UserProfiles.User currentUser in userProfiles.userListField)
            {
                if (listBoxUserProfiles.SelectedItem.ToString() == currentUser.accessToken)
                {
                    selectedUser = currentUser;
                    break;
                }
            }

            using (FormAddEditUser formAddEditUser = new FormAddEditUser(selectedUser)) {
                formAddEditUser.ShowDialog(this);

                if (formAddEditUser.DialogResult == DialogResult.OK)
                {
                    ReloadUsers();
                    // restore selection
                    listBoxUserProfiles.SelectedIndex = selectedIndex;
                }
            }
        }
Beispiel #2
0
 public FormAddEditUser()
 {
     InitializeComponent();
     formMode    = FormMode.Add;
     userProfile = new HM.Entities.HattrickManager.UserProfiles.User();
     oAuth       = new HM.ChppInterface.OAuthInterface();
     bwOAuth.RunWorkerAsync();
 }
 public FormAddEditUser()
 {
     InitializeComponent();
     formMode = FormMode.Add;
     userProfile = new HM.Entities.HattrickManager.UserProfiles.User();
     oAuth = new HM.ChppInterface.OAuthInterface();
     bwOAuth.RunWorkerAsync();
 }
Beispiel #4
0
 public FormAddEditUser(HMEntities.UserProfiles.User selectedUser)
 {
     InitializeComponent();
     formMode                = FormMode.Edit;
     this.userProfile        = selectedUser;
     this.buttonTest.Enabled = true;
     oAuth = new HM.ChppInterface.OAuthInterface();
     LoadControls();
 }
 public FormAddEditUser(HMEntities.UserProfiles.User selectedUser)
 {
     InitializeComponent();
     formMode = FormMode.Edit;
     this.userProfile = selectedUser;
     this.buttonTest.Enabled = true;
     oAuth = new HM.ChppInterface.OAuthInterface();
     LoadControls();
 }
Beispiel #6
0
 public FormDownload(HMEntities.UserProfiles.User currentUser)
 {
     InitializeComponent();
     this.currentUser     = currentUser;
     this.downloadManager = new DownloadManager(currentUser);
     this.entityManager   = new EntityManager(currentUser);
     this.dataManager     = new DataManager(currentUser);
     downloadManager.ChppDownloadProgressChanged += new ChppDownloadProgressChangedEventHandler(OnChppDownloadProgressChanged);
 }
 public FormDownload(HMEntities.UserProfiles.User currentUser)
 {
     InitializeComponent();
     this.currentUser = currentUser;
     this.downloadManager = new DownloadManager(currentUser);
     this.entityManager = new EntityManager(currentUser);
     this.dataManager = new DataManager(currentUser);
     downloadManager.ChppDownloadProgressChanged += new ChppDownloadProgressChangedEventHandler(OnChppDownloadProgressChanged);
 }
        public void ExchangeRequestTokenForAccessToken(String verifier, out HMEntities.UserProfiles.User currentUser)
        {
            currentUser = new HMEntities.UserProfiles.User();

            OAuthSession oauthSession = GetOAuthSession(Chpp.ConsumerKey, Chpp.ConsumerSecret);
            IToken accessToken = oauthSession.ExchangeRequestTokenForAccessToken(requestToken, verifier);

            currentUser.accessToken = accessToken.Token;
            currentUser.accessTokenSecret = accessToken.TokenSecret;
        }
        public void ExchangeRequestTokenForAccessToken(String verifier, out HMEntities.UserProfiles.User currentUser)
        {
            currentUser = new HMEntities.UserProfiles.User();

            OAuthSession oauthSession = GetOAuthSession(Chpp.ConsumerKey, Chpp.ConsumerSecret);
            IToken       accessToken  = oauthSession.ExchangeRequestTokenForAccessToken(requestToken, verifier);

            currentUser.accessToken       = accessToken.Token;
            currentUser.accessTokenSecret = accessToken.TokenSecret;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="currentUser">Current active user</param>
 /// <param name="commonFolder">Common files download folder</param>
 public ChppManager(HMEntities.UserProfiles.User currentUser)
 {
     this.oAuth = new OAuthInterface();
     this.currentUser = currentUser;
     this.dataManager = new HM.DataAccess.DataManager(System.IO.Path.Combine(Directory.GetCurrentDirectory(), FolderNames.CommonDataFolder));
     this.currentDate = DateTime.Now.ToString(HM.Resources.Constants.Chpp.HMDateFormat);
     this.filesDownloaded = 0;
     this.totalFilesToDownload = 0;
     this.path = System.IO.Path.Combine(currentUser.dataFolderField, currentUser.teamIdField.ToString());
     this.downloadExistingFiles = false;
 }
Beispiel #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="currentUser">Current active user</param>
 /// <param name="commonFolder">Common files download folder</param>
 public ChppManager(HMEntities.UserProfiles.User currentUser)
 {
     this.oAuth                = new OAuthInterface();
     this.currentUser          = currentUser;
     this.dataManager          = new HM.DataAccess.DataManager(System.IO.Path.Combine(Directory.GetCurrentDirectory(), FolderNames.CommonDataFolder));
     this.currentDate          = DateTime.Now.ToString(HM.Resources.Constants.Chpp.HMDateFormat);
     this.filesDownloaded      = 0;
     this.totalFilesToDownload = 0;
     this.path = System.IO.Path.Combine(currentUser.dataFolderField, currentUser.teamIdField.ToString());
     this.downloadExistingFiles = false;
 }
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string selectedLoginname = listBoxUserProfiles.SelectedItem.ToString();

            foreach (HMEntities.UserProfiles.User currentUser in userProfiles.userListField)
            {
                if (currentUser.username == selectedLoginname)
                {
                    this.selectedUser = currentUser;
                    break;
                }
            }
        }
        public String AccessProtectedResource(HMEntities.UserProfiles.User currentUser, String parameters)
        {
            String       URL          = Chpp.ResourcesURL + "?" + parameters;
            OAuthSession oAuthSession = GetOAuthSession(Chpp.ConsumerKey, Chpp.ConsumerSecret);

            oAuthSession.AccessToken = new TokenBase()
            {
                ConsumerKey = Chpp.ConsumerKey, Token = currentUser.accessToken, TokenSecret = currentUser.accessTokenSecret
            };

            IConsumerRequest request = oAuthSession.Request().Get().ForUrl(URL);

            return(request.ToString());
        }
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            HMEntities.UserProfiles.User selectedUser = new HM.Entities.HattrickManager.UserProfiles.User();
            int selectedIndex = listBoxUserProfiles.SelectedIndex;

            foreach (HMEntities.UserProfiles.User currentUser in userProfiles.userListField) {
                if (listBoxUserProfiles.SelectedItem.ToString() == currentUser.accessToken) {
                    selectedUser = currentUser;
                    break;
                }
            }

            using (FormAddEditUser formAddEditUser = new FormAddEditUser(selectedUser)) {
                formAddEditUser.ShowDialog(this);

                if (formAddEditUser.DialogResult == DialogResult.OK) {
                    ReloadUsers();
                    // restore selection
                    listBoxUserProfiles.SelectedIndex = selectedIndex;
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Reads the UserSettings file and return it's content
        /// </summary>
        /// <returns>HattrickSettings for the selected user</returns>
        public HMEntities.Settings.HattrickSettings ReadUserSettingsFile(HM.Entities.HattrickManager.UserProfiles.User selectedUser)
        {
            try {
                HMEntities.Settings.HattrickSettings settings = new HMEntities.Settings.HattrickSettings();
                string path = System.IO.Path.Combine(selectedUser.dataFolderField, selectedUser.teamIdField.ToString());
                path = System.IO.Path.Combine(path, FolderNames.UserSettings);

                string fileName = Path.Combine(path, FileNames.UserSettings);

                if (File.Exists(fileName))
                {
                    settings = dataManager.ReadUserSettingsFile(GetFileStream(fileName));
                }
                else
                {
                    settings = dataManager.ReadUserSettingsFile(HM.Resources.GenericFunctions.GetDefaultSettings(HM.Resources.SettingTypes.All));
                }

                return(settings);
            } catch (Exception ex) {
                throw ex;
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="currentUser">Current active user</param>
 /// <param name="commonFolder">Common files download folder</param>
 public DownloadManager(HMEntities.UserProfiles.User currentUser)
 {
     this.chppManager = new HM.ChppInterface.ChppManager(currentUser);
     chppManager.ChppDownloadProgressChanged += new ChppDownloadProgressChangedEventHandler(OnChppDownloadProgressChanged);
 }
Beispiel #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="commonFolder">Common files folder</param>
 public DataManager(HMEntities.UserProfiles.User currentUser)
 {
     this.commonFolder = Path.Combine(Directory.GetCurrentDirectory(), FolderNames.CommonDataFolder);
     this.currentUser  = currentUser;
     dataManager       = new HM.DataAccess.DataManager(commonFolder);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="commonFolder">Common files folder</param>
 public DataManager(HMEntities.UserProfiles.User currentUser)
 {
     this.commonFolder = Path.Combine(Directory.GetCurrentDirectory(), FolderNames.CommonDataFolder);
     this.currentUser = currentUser;
     dataManager = new HM.DataAccess.DataManager(commonFolder);
 }