/[AnywhereTS-MSSQL]/trunk/TSAdminTool/frmAddTFTP.cs
ViewVC logotype

Annotation of /trunk/TSAdminTool/frmAddTFTP.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations) (download)
Thu Jul 12 14:17:14 2012 UTC (7 years, 11 months ago) by william
File size: 3301 byte(s)
+ add logging across ATSAdmin Tool project

1 william 4 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Text;
7     using System.Windows.Forms;
8     using System.IO;
9    
10     namespace AnywhereTS
11     {
12     public partial class frmAddTFTP : Form
13     {
14     public string inputstring; // The text in the input box
15     public frmAddTFTP()
16     {
17     InitializeComponent();
18     }
19    
20     private void btnOk_Click(object sender, EventArgs e)
21     {
22     inputstring = textInput.Text.Trim();
23    
24     // Check that user entered something
25     if (inputstring.Length == 0)
26     {
27     this.Cursor = Cursors.Default;
28     MessageBox.Show("You must specifiy a directory.");
29     textInput.Focus();
30     return;
31     }
32    
33     // Check if path is relative
34     if (inputstring.StartsWith(".") || (inputstring.StartsWith(@"\") && !inputstring.StartsWith(@"\\")))
35     {
36     this.Cursor = Cursors.Default;
37     MessageBox.Show("Invalid path.");
38 william 46 using (log4net.NDC.Push(string.Format("path={0}", inputstring)))
39     {
40     Logging.ATSAdminLog.Warn("Invalid path.");
41     }
42 william 4 textInput.Focus();
43     return;
44     }
45    
46     // Validate directory
47     if (!Directory.Exists(inputstring))
48     {
49     MessageBox.Show("Cannot find or access directory '" + inputstring + "' Please check spelling and rights!");
50    
51 william 46 using (log4net.NDC.Push(string.Format("path={0}", inputstring)))
52     {
53     Logging.ATSAdminLog.Warn("Cannot find or access directory.");
54     }
55 william 4 textInput.SelectAll();
56     textInput.Focus();
57     return;
58     }
59    
60     DialogResult = DialogResult.OK;
61     }
62    
63     private void btnBrowse_Click(object sender, EventArgs e)
64     {
65     // Show the FolderBrowserDialog.
66    
67     Rebrowse:
68     DialogResult result = folderBrowserDialog.ShowDialog();
69     if (result == DialogResult.OK)
70     {
71 william 46 string strPath = string.Empty; // The path provided by the user
72 william 4
73     // Browse to a folder by displaying the folder browse Dialog
74     try
75     {
76     strPath = folderBrowserDialog.SelectedPath.Trim();
77     }
78     catch (NotSupportedException)
79     { // User has browsed to a non folder
80     MessageBox.Show("Object is not a file folder.");
81 william 46 using (log4net.NDC.Push(string.Format("path={0}", strPath)))
82     {
83     Logging.ATSAdminLog.Warn("Object is not a file folder.");
84     }
85 william 4 goto Rebrowse;
86     }
87     textInput.Text = strPath;
88     textInput.Select();
89     }
90    
91     }
92    
93     private void frmAddTFTP_Load(object sender, EventArgs e)
94     {
95     helpProvider.HelpNamespace = ATSGlobals.strHelpFilePath; // Initiate helpProvider
96     }
97     }
98     }

  ViewVC Help
Powered by ViewVC 1.1.22