/// <summary> /// Checks to see if a path can become an iFolder. /// </summary> /// <param name="path">The path that is tested.</param> /// <returns>The method returns <b>true</b> if the specified path can become an ifolder; otherwise, <b>false</b>.</returns> public bool CanBeiFolder([MarshalAs(UnmanagedType.LPWStr)] string path) { try { // Make sure the user has read/write access to the directory. if (Win32Security.AccessAllowed(path)) { connectToWebService(); if (ifWebService != null) { return(ifWebService.CanBeiFolder(path)); } } } catch (WebException e) { ifWebService = null; if (e.Status == WebExceptionStatus.ProtocolError) { LocalService.ClearCredentials(); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Caught exception - " + e.Message); } return(false); }
/// <summary> /// Function to resolve the conflict /// </summary> /// <param name="localCopy"></param> private void enhancedConflictResolve(bool localCopy) { string path = null; foreach (ListViewItem lvi in conflictsView.SelectedItems) { Conflicts conflicts = (Conflicts)lvi.Tag; if (!conflicts.ServerConflict.IsNameConflict) { try { // Display a warning and return if the user has not specified the conflict bin path if (conflictBinEnable.Checked) { if (pathTxtBox.Text == "") { MyMessageBox mmb = new MyMessageBox(resources.GetString("emptyConflictBinMsg"), resources.GetString("emptyConflictBinTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); return; } path = pathTxtBox.Text; if (!path.EndsWith(resources.GetString("pathSeparator"))) { path = path + resources.GetString("pathSeparator"); } if (!Directory.Exists(path)) { try { Directory.CreateDirectory(path); } catch { MyMessageBox mmb = new MyMessageBox(resources.GetString("invalidConflictBinMsg"), resources.GetString("invalidConflictBinTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); return; } } // Check to make sure the user has rights to this directory. if (!Win32Security.AccessAllowed(path)) { MyMessageBox mmb = new MyMessageBox(resources.GetString("accessDenied"), resources.GetString("accessDeniedTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); return; } else { ifWebService.ResolveEnhancedFileConflict(ifolder.ID, conflicts.ServerConflict.ConflictID, localCopy, path); } //ifWebService.ResolveEnhancedFileConflict(ifolder.ID, conflicts.ServerConflict.ConflictID, localCopy, path); } else { ifWebService.ResolveEnhancedFileConflict(ifolder.ID, conflicts.ServerConflict.ConflictID, localCopy, string.Empty); } lvi.Remove(); } catch (Exception ex) { MyMessageBox mmb = new MyMessageBox(conflictErrorMsg, conflictErrorTitle, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); } } } if (conflictsView.Items.Count == 0) { // If all the conflicts have been resolved, fire the ConflictsResolved event. InvokeConflictResolvedEvent(this, new EventArgs()); } }
/// <summary> /// Event Handler for OK button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ok_Click(object sender, System.EventArgs e) { successful = true; if (GetDriveType(Path.GetPathRoot(iFolderLocation.Text)) == DRIVE_FIXED) { if (!Directory.Exists(iFolderLocation.Text)) { // If a leaf node is specified, the directory will be created // under the current working directory ... display this path. bool parentExists = false; string parent = Path.GetDirectoryName(iFolderLocation.Text); while ((parent != null) && !parent.Equals(string.Empty)) { if (Directory.Exists(parent)) { iFolderLocation.Text = iFolderLocation.Text.Replace(parent, CreateiFolder.FixPath(parent)); parentExists = true; break; } parent = Path.GetDirectoryName(parent); } if (!parentExists) { iFolderLocation.Text = Path.Combine(Environment.CurrentDirectory, iFolderLocation.Text); } // The directory doesn't exist ... if (MessageBox.Show(resourceManager.GetString("createDirectoryMessage"), resourceManager.GetString("createDirectoryTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { // Create the directory. try { Directory.CreateDirectory(iFolderLocation.Text); } catch (Exception ex) { MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("createDirectoryError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); successful = false; } } else { iFolderLocation.Focus(); successful = false; } } if (successful) { // Check to make sure the user has rights to this directory. if (Win32Security.AccessAllowed(iFolderLocation.Text)) { try { // Display wait cursor. Cursor = Cursors.WaitCursor; // Accept the invitation. ifWebService.AcceptiFolderInvitation(ifolder.DomainID, ifolder.ID, iFolderLocation.Text); Cursor = Cursors.Default; } catch (Exception ex) { Cursor = Cursors.Default; MyMessageBox mmb; if (ex.Message.IndexOf("PathExists") != -1) { mmb = new MyMessageBox(resourceManager.GetString("pathExistsError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); } else if (ex.Message.IndexOf("AtOrInsideStorePath") != -1) { mmb = new MyMessageBox(resourceManager.GetString("pathInStoreError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); } else if (ex.Message.IndexOf("AtOrInsideCollectionPath") != -1) { mmb = new MyMessageBox(resourceManager.GetString("pathIniFolderError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); } else if (ex.Message.IndexOf("IncludesWinDirPath") != -1) { mmb = new MyMessageBox(resourceManager.GetString("pathIncludesWinDirError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); } else if (ex.Message.IndexOf("IncludesProgFilesPath") != -1) { mmb = new MyMessageBox(resourceManager.GetString("pathIncludesProgFilesDirError"), resourceManager.GetString("pathInvalidErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); iFolderLocation.Focus(); } else { mmb = new MyMessageBox(resourceManager.GetString("acceptError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); } successful = false; } } else { successful = false; MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("accessDenied"), string.Empty, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); } } } else { MessageBox.Show(resourceManager.GetString("networkPath"), resourceManager.GetString("pathInvalidErrorTitle")); iFolderLocation.Focus(); successful = false; } }