Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 public LoginForm(IAuthorizer authorizer)
 {
     InitializeComponent();
     AuthorizationResult = new AuthorizationResult();
     this.authorizer = authorizer;
     this.textBoxUseName.Text = "supakull";
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
 public MainForm()
 {
     InitializeComponent();
     AuthorizationResult = new AuthorizationResult();
 }