public static void ChangeFolderForSync(String newPath, AuthorizationResult currentUser) { String userID = String.Format("FolderPathForSynchronizationFor.{0}", currentUser.AuthorizedUser.UserID); try { XDocument userSettingsFile = XDocument.Load(String.Format("{0}\\MyConfig.xml", Directory.GetCurrentDirectory())); XElement elementToEdit = userSettingsFile.Element(XName.Get("appSettings")); XElement result = (from addElment in elementToEdit.Descendants() where addElment.Attribute(XName.Get("key")).Value == userID select addElment).SingleOrDefault<XElement>(); XElement elementForAdding = new XElement("add", new XAttribute("key", userID), new XAttribute("value", newPath)); if (result == null) { elementToEdit.AddFirst(elementForAdding); } else { result.ReplaceWith(elementForAdding); } userSettingsFile.Save("MyConfig.xml"); folderPathForSynchronization = newPath; } catch (Exception ex) { log.Error(ex); System.Windows.Forms.MessageBox.Show(ex.Message); return; } }
public LoginForm(IAuthorizer authorizer) { InitializeComponent(); AuthorizationResult = new AuthorizationResult(); this.authorizer = authorizer; this.textBoxUseName.Text = "supakull"; }
public ExcelSynchronizer(AuthorizationResult user) { currentUser = user; timerForLaterUdate = new Timer(new TimerCallback(LaterAutoUpdate), null, 30000, 30000); listOfLockedFiles = new List<String>(); excelAccounts = new List<ExcelAccountSettings>(); folderPathForSynchronization = TryOpenOrCreateFolderForUser(); fileWatcher = CreateAndSetUpWarcher(); UpdateExcelAccountsList(); CheckAllTrackFiles(); }
private void Authorize() { CredentialInfo credentialInfo = new CredentialInfo(textBoxUseName.Text); AuthorizationResult = authorizer.Authorize(credentialInfo); if (AuthorizationResult.Authorized) { this.DialogResult = DialogResult.OK; } else { labelMessageForUser.Text = "User name is incorrect. Try again."; textBoxUseName.Focus(); } }
private void StartApplication_Load(object sender, EventArgs e) { IAuthorizer authorizer = new Authorizer(); LoginProviderWinForm loginProvider = new LoginProviderWinForm(authorizer); AuthorizationResult = loginProvider.Login(); if (AuthorizationResult.Authorized) { PrepareApplication(); } else { Application.Exit(); } }
public MainForm() { InitializeComponent(); AuthorizationResult = new AuthorizationResult(); }