checking in latest panacean to nas

This commit is contained in:
2016-08-31 12:20:26 -04:00
parent 859f6bc5e0
commit c88c7a04c0
5 changed files with 185 additions and 161 deletions

View File

@@ -28,11 +28,6 @@ namespace Advantage_Final
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
@@ -51,7 +46,7 @@ namespace Advantage_Final
private void btnExit_Click(object sender, EventArgs e) private void btnExit_Click(object sender, EventArgs e)
{ {
this.Hide(); this.Close();
} }
private void textBox1_Leave(object sender, EventArgs e) private void textBox1_Leave(object sender, EventArgs e)
@@ -100,7 +95,5 @@ namespace Advantage_Final
} }
} }
} }

View File

@@ -153,10 +153,9 @@ namespace Advantage_Final
{ {
} }
} }
} }
} }
@@ -177,11 +176,13 @@ namespace Advantage_Final
string value = item; string value = item;
int i = item.IndexOf('{') + 1; int i = item.IndexOf('{') + 1;
string d = Path.Combine(value.Substring(i) + "\\mwddf.add"); string d = Path.Combine(value.Substring(i) + "\\mwddf.add");
list.Add(d); list.Add(d);
} }
{ {
bool bSeparate = Options.GetBoolValue((string)Dicks.GetValue("Separate"));
bool bFileMDY = Options.GetBoolValue((string)Dicks.GetValue("FileMDY"));
if ((string)Dicks.GetValue("ReportFolder") == null) if ((string)Dicks.GetValue("ReportFolder") == null)
{ {
@@ -193,15 +194,12 @@ namespace Advantage_Final
} }
DialogResult result = reportFileDialog1.ShowDialog(); DialogResult result = reportFileDialog1.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
using (StreamReader sr = new StreamReader(reportFileDialog1.FileName)) using (StreamReader sr = new StreamReader(reportFileDialog1.FileName))
{ {
line = sr.ReadToEnd();
line = sr.ReadToEnd();
} }
foreach (string item in list) foreach (string item in list)
@@ -219,30 +217,30 @@ namespace Advantage_Final
conn.ConnectionString = "Data Source=" + item + conn.ConnectionString = "Data Source=" + item +
";User ID=user;Password=password;" + ";User ID=user;Password=password;" +
"ServerType=REMOTE|LOCAL;TrimTrailingSpaces=True"; "ServerType=REMOTE|LOCAL;TrimTrailingSpaces=True";
AdsDataAdapter da = new AdsDataAdapter(line, conn); AdsDataAdapter da = new AdsDataAdapter(line, conn);
DataSet ds = new DataSet(); DataSet ds = new DataSet();
da.SelectCommand.CommandTimeout = 0; da.SelectCommand.CommandTimeout = 0;
da.Fill(ds, "Dick"); da.Fill(ds, "Dick");
DataTable dt = ds.Tables[0]; DataTable dt = ds.Tables[0];
string filepath = (string)Dicks.GetValue("ReportOutput", "");
da.Dispose();
string filename = Path.GetFileNameWithoutExtension(reportFileDialog1.FileName);
string filepath = (string)Dicks.GetValue("ReportOutput", "");
if (String.IsNullOrEmpty(filepath))
filepath = @"C:\";
da.Dispose();
conn.Open(); conn.Open();
AdsDataReader reader; AdsDataReader reader;
AdsCommand PracticeName = conn.CreateCommand(); AdsCommand PracticeName = conn.CreateCommand();
PracticeName.CommandText = "SELECT [Practice Name] FROM [MWPRA]"; PracticeName.CommandText = "SELECT [Practice Name] FROM [MWPRA]";
reader = PracticeName.ExecuteReader(); reader = PracticeName.ExecuteReader();
while (reader.Read()) while (reader.Read())
{ {
PracticeFolder = reader.GetString(0); PracticeFolder = reader.GetString(0);
} }
dt.Columns.Add("Practice", typeof(string)); dt.Columns.Add("Practice", typeof(string));
foreach (DataRow dr in dt.Rows) foreach (DataRow dr in dt.Rows)
@@ -250,29 +248,32 @@ namespace Advantage_Final
dr["Practice"] = PracticeFolder; dr["Practice"] = PracticeFolder;
} }
conn.Close(); conn.Close();
AdsConnection.FlushConnectionPool(); AdsConnection.FlushConnectionPool();
string ReportExportPath1 = (Path.Combine((string)Dicks.GetValue("ReportOutput", ""))); string ReportExportPath = filepath;
//string ReportExportPath1 = (Path.Combine((string)Dicks.GetValue("ReportOutput", "") + newPracticeName)); if(bSeparate)
string ReportExportPath = ReportExportPath1.TrimEnd('\\'); ReportExportPath += "\\" + newPracticeName.Replace("\\","");
bool exists = System.IO.Directory.Exists(ReportExportPath);
bool exists = System.IO.Directory.Exists(ReportExportPath);
if (!exists) if (!exists)
System.IO.Directory.CreateDirectory(ReportExportPath); System.IO.Directory.CreateDirectory(ReportExportPath);
// String rFilePath = (ReportExportPath + "\\" + Path.GetFileNameWithoutExtension(reportFileDialog1.FileName) + ".xlsx"); string ReportFile = filename;
String rFilePath = (ReportExportPath + "\\" + "Test" + ".xlsx"); if(bFileMDY)
ReportFile += "_" + DateTime.Now.ToShortDateString().Replace('/','_');
// Ready to export
String rFilePath = (ReportExportPath + "\\" + ReportFile + ".xlsx");
dt.ExportToExcel(rFilePath); dt.ExportToExcel(rFilePath);
dt.Dispose(); dt.Dispose();
ds.Dispose(); ds.Dispose();
conn.Close(); conn.Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
string LogPath = ((Path.Combine((string)Dicks.GetValue("ReportOutput", "") + "\\" + "log.txt"))); string LogPath = ((Path.Combine((string)Dicks.GetValue("ReportOutput", "") + "\\" + "log.txt")));
bool fileExists = File.Exists(LogPath); bool fileExists = File.Exists(LogPath);
using (StreamWriter sw = File.AppendText(LogPath)) using (StreamWriter sw = File.AppendText(LogPath))
@@ -280,16 +281,10 @@ namespace Advantage_Final
sw.WriteLine(""); sw.WriteLine("");
sw.WriteLine(ex); sw.WriteLine(ex);
sw.WriteLine(""); sw.WriteLine("");
sw.WriteLine(oldPath); sw.WriteLine(oldPath);
} }
} }
continue; continue;
} }
@@ -299,7 +294,7 @@ namespace Advantage_Final
} }
} }
MessageBox.Show("All Done"); MessageBox.Show("All Done");
} }
/// <summary> /// <summary>

View File

@@ -28,27 +28,14 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.lblReportPath = new System.Windows.Forms.Label();
this.btnExit = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button();
this.lblReportOutput = new System.Windows.Forms.Label(); this.chkSeparate = new System.Windows.Forms.CheckBox();
this.reportFolder = new System.Windows.Forms.FolderBrowserDialog(); this.chkFileMDY = new System.Windows.Forms.CheckBox();
this.reportOutput = new System.Windows.Forms.FolderBrowserDialog();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// lblReportPath
//
this.lblReportPath.AutoSize = true;
this.lblReportPath.Location = new System.Drawing.Point(12, 38);
this.lblReportPath.Name = "lblReportPath";
this.lblReportPath.Size = new System.Drawing.Size(64, 13);
this.lblReportPath.TabIndex = 0;
this.lblReportPath.Text = "Report Path";
//
// btnExit // btnExit
// //
this.btnExit.Location = new System.Drawing.Point(683, 383); this.btnExit.Location = new System.Drawing.Point(71, 124);
this.btnExit.Name = "btnExit"; this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(114, 30); this.btnExit.Size = new System.Drawing.Size(114, 30);
this.btnExit.TabIndex = 1; this.btnExit.TabIndex = 1;
@@ -56,47 +43,38 @@
this.btnExit.UseVisualStyleBackColor = true; this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click); this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
// //
// lblReportOutput // chkSeparate
// //
this.lblReportOutput.AutoSize = true; this.chkSeparate.AutoSize = true;
this.lblReportOutput.Location = new System.Drawing.Point(12, 80); this.chkSeparate.Location = new System.Drawing.Point(26, 26);
this.lblReportOutput.Name = "lblReportOutput"; this.chkSeparate.Name = "chkSeparate";
this.lblReportOutput.Size = new System.Drawing.Size(74, 13); this.chkSeparate.Size = new System.Drawing.Size(109, 17);
this.lblReportOutput.TabIndex = 2; this.chkSeparate.TabIndex = 3;
this.lblReportOutput.Text = "Report Output"; this.chkSeparate.Text = "Separate Reports";
this.chkSeparate.UseVisualStyleBackColor = true;
this.chkSeparate.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
// //
// checkBox1 // chkFileMDY
// //
this.checkBox1.AutoSize = true; this.chkFileMDY.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(384, 66); this.chkFileMDY.Location = new System.Drawing.Point(26, 67);
this.checkBox1.Name = "checkBox1"; this.chkFileMDY.Name = "chkFileMDY";
this.checkBox1.Size = new System.Drawing.Size(109, 17); this.chkFileMDY.Size = new System.Drawing.Size(159, 17);
this.checkBox1.TabIndex = 3; this.chkFileMDY.TabIndex = 4;
this.checkBox1.Text = "Separate Reports"; this.chkFileMDY.Text = "Add MM-DD-YY to file name";
this.checkBox1.UseVisualStyleBackColor = true; this.chkFileMDY.UseVisualStyleBackColor = true;
// this.chkFileMDY.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(368, 146);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(158, 17);
this.checkBox2.TabIndex = 4;
this.checkBox2.Text = "Add Mm-DD-YY to file name";
this.checkBox2.UseVisualStyleBackColor = true;
// //
// Options // Options
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(846, 434); this.ClientSize = new System.Drawing.Size(228, 184);
this.Controls.Add(this.checkBox2); this.Controls.Add(this.chkFileMDY);
this.Controls.Add(this.checkBox1); this.Controls.Add(this.chkSeparate);
this.Controls.Add(this.lblReportOutput);
this.Controls.Add(this.btnExit); this.Controls.Add(this.btnExit);
this.Controls.Add(this.lblReportPath);
this.Name = "Options"; this.Name = "Options";
this.Text = "Form2"; this.Text = "Options";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -104,12 +82,8 @@
#endregion #endregion
private System.Windows.Forms.Label lblReportPath;
private System.Windows.Forms.Button btnExit; private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label lblReportOutput; private System.Windows.Forms.CheckBox chkSeparate;
private System.Windows.Forms.FolderBrowserDialog reportFolder; private System.Windows.Forms.CheckBox chkFileMDY;
private System.Windows.Forms.FolderBrowserDialog reportOutput;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
} }
} }

View File

@@ -13,12 +13,26 @@ namespace Advantage_Final
{ {
public partial class Options : Form public partial class Options : Form
{ {
public static bool GetBoolValue(string str)
{
bool b = false;
if (!String.IsNullOrEmpty(str))
b = (str == "True") ? true : false;
return b;
}
public Options() public Options()
{ {
InitializeComponent(); InitializeComponent();
//textReportOutput.Text = (string)Dicks.GetValue("ReportOutput", "");
//textBox1.Text = (string)Dicks.GetValue("ReportFolder", ""); string SEP = (string)Dicks.GetValue("Separate");
if(!String.IsNullOrEmpty(SEP))
chkSeparate.Checked = (SEP == "True")? true : false;
string FMDY = (string)Dicks.GetValue("FileMDY");
if (!String.IsNullOrEmpty(FMDY))
chkFileMDY.Checked = (FMDY == "True") ? true : false;
} }
public RegistryKey Dicks = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\PanaceanTech\\ReportRunner", true); public RegistryKey Dicks = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\PanaceanTech\\ReportRunner", true);
@@ -27,24 +41,110 @@ namespace Advantage_Final
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
string value = cb.Checked.ToString();
Dicks.SetValue("Separate", value);
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
string value = cb.Checked.ToString();
Dicks.SetValue("FileMDY", value);
}
/*
public ReportName()
{
*
InitializeComponent();
*
string FPN = (string)Form1.Dicks.GetValue("FolderPracticeName");
string FRFN = (string)Form1.Dicks.GetValue("FolderReportFolderName");
string FRN = (string)Form1.Dicks.GetValue("FolderReportName");
string FMDY = (string)Form1.Dicks.GetValue("FileMDY");
string FFPN = (string)Form1.Dicks.GetValue("FilePracticeName");
string FFRN = (string)Form1.Dicks.GetValue("FileReportName");
string SEP = (string)Form1.Dicks.GetValue("Separate");
if (FPN == "False")
{
checkFolderPracticeName.Checked = false;
}
else
checkFolderPracticeName.Checked = true;
if (FRFN == "False")
{
checkFolderReportFolder.Checked = false;
}
else
checkFolderReportFolder.Checked = true;
if (FRN == "False")
{
checkFolderReportName.Checked = false;
}
else checkFolderReportName.Checked = true;
if (FMDY == "False")
{
checkFileMDY.Checked = false;
}
else
checkFileMDY.Checked = true;
if (FFPN == "False")
{
checkFilePracticeName.Checked = false;
}
else checkFilePracticeName.Checked = true;
if (FFRN == "False")
{
checkFileReportName.Checked = false;
}
else checkFileReportName.Checked = true;
if (SEP == "False")
{
checkSeparate.Checked = false;
}
else
checkSeparate.Checked = true;
// checkFolderReportFolder.Checked = (Boolean)Form1.Dicks.GetValue("FolderReportFolderName");
// checkFolderReportName.Checked = (Boolean)Form1.Dicks.GetValue("FolderReportName");
// checkFileMDY.Checked = (Boolean)Form1.Dicks.GetValue("FileMDY");
// checkFilePracticeName.Checked = (Boolean)Form1.Dicks.GetValue("FilePracticeName");
// checkFileReportName.Checked = (Boolean)Form1.Dicks.GetValue("FileReportName");
// checkSeparate.Checked = (Boolean)Form1.Dicks.GetValue("Separate");
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
} }
private void checkBox6_CheckedChanged(object sender, EventArgs e)
{
private void button1_Click(object sender, EventArgs e) }
private void checkFilePracticeName_CheckedChanged(object sender, EventArgs e)
{ {
//
// This event handler was created by double-clicking the window in the designer.
// It runs on the program's startup routine.
//
//DialogResult result = reportFolder.ShowDialog();
//if (result == DialogResult.OK)
//{
// Dicks.SetValue("ReportFolder", reportFolder.SelectedPath);
// textBox1.Text = (string)Dicks.GetValue("ReportFolder");
//}
} }
private void btnExit_Click(object sender, EventArgs e) private void btnExit_Click(object sender, EventArgs e)
@@ -52,51 +152,19 @@ namespace Advantage_Final
this.Hide(); this.Hide();
} }
private void textBox1_Leave(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
//if (System.IO.Directory.Exists(textBox1.Text)) Form1.Dicks.SetValue("FolderPracticeName", checkFolderPracticeName.Checked.ToString());
//{ Form1.Dicks.SetValue("FolderReportName", checkFolderReportName.Checked.ToString());
// Dicks.SetValue("ReportFolder", textBox1.Text.TrimEnd('\\')); Form1.Dicks.SetValue("FolderReportFolderName", checkFolderReportName.Checked.ToString());
// textBox1.Text = (string)Dicks.GetValue("ReportFolder"); Form1.Dicks.SetValue("FileMDY", checkFileMDY.Checked.ToString());
//} Form1.Dicks.SetValue("FilePracticeName", checkFilePracticeName.Checked.ToString());
//else Form1.Dicks.SetValue("FileReportName", checkFileReportName.Checked.ToString());
//{ Form1.Dicks.SetValue("Separate", checkSeparate.Checked.ToString());
// MessageBox.Show("Enter a valid path. Quit trying to break shit"); this.Hide();
// textBox1.Text = ""; }
//} */
}
private void btnOutPath_Click(object sender, EventArgs e)
{
//DialogResult result = reportOutput.ShowDialog();
//if (result == DialogResult.OK)
//{
// Dicks.SetValue("ReportOutput", reportOutput.SelectedPath);
// textReportOutput.Text = (string)Dicks.GetValue("ReportOutput");
//}
}
private void textReportOutput_Leave(object sender, EventArgs e)
{
//if (System.IO.Directory.Exists(textReportOutput.Text))
//{
// Dicks.SetValue("ReportOutput", textReportOutput.Text.TrimEnd('\\'));
// textReportOutput.Text = (string)Dicks.GetValue("ReportOutput");
//}
//else
//{
// MessageBox.Show("Enter a valid path. Quit trying to break shit");
// textBox1.Text = "";
//}
}
private void textReportOutput_TextChanged(object sender, EventArgs e)
{
}
} }
} }

View File

@@ -117,10 +117,4 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="reportFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="reportOutput.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>137, 17</value>
</metadata>
</root> </root>