Added File extension parameter to Make Document

Support for DocX and correction of Import Word Doc file
Change button from Print to Report
Support opening a Library Document that does not have any usages.
This commit is contained in:
Rich 2015-10-27 13:32:33 +00:00
parent d452b2f5b3
commit e22458bd1a
3 changed files with 243 additions and 241 deletions

View File

@ -272,7 +272,7 @@ namespace Volian.Controls.Library
private void InitializeWordDocument(LBDocumentClass doc) private void InitializeWordDocument(LBDocumentClass doc)
{ {
if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "") if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "" && MyDocumentInfo.DocumentEntryCount > 0)
{ {
DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle; DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle;
// this will cause an error and goto the Catch if the family or size is null, // this will cause an error and goto the Catch if the family or size is null,

View File

@ -186,7 +186,7 @@ namespace Volian.Controls.Library
this.btnPrint.Name = "btnPrint"; this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(75, 30); this.btnPrint.Size = new System.Drawing.Size(75, 30);
this.btnPrint.TabIndex = 15; this.btnPrint.TabIndex = 15;
this.btnPrint.Text = "Print"; this.btnPrint.Text = "Report";
this.btnPrint.UseVisualStyleBackColor = true; this.btnPrint.UseVisualStyleBackColor = true;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click); this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
// //

View File

@ -38,7 +38,7 @@ namespace Volian.Controls.Library
InitializeComponent(); InitializeComponent();
btnOpenLibDoc.Enabled = false; btnOpenLibDoc.Enabled = false;
btnDelLibDoc.Enabled = false; btnDelLibDoc.Enabled = false;
btnPrint.Enabled = false; btnPrint.Enabled = listBoxLibDocs.Items.Count > 0;
saveGroupPanelUsages = groupPanelUsages.Style.BackColor; saveGroupPanelUsages = groupPanelUsages.Style.BackColor;
} }
DisplayTabControl _DisplayTabControl; DisplayTabControl _DisplayTabControl;
@ -60,6 +60,7 @@ namespace Volian.Controls.Library
_DisplayTabControl = tc; _DisplayTabControl = tc;
listBoxUsages.Items.Clear(); listBoxUsages.Items.Clear();
_InitializingLibDocList = false; _InitializingLibDocList = false;
btnPrint.Enabled = listBoxLibDocs.Items.Count > 0;
} }
public void SetSelectedLibDoc() public void SetSelectedLibDoc()
{ {
@ -125,7 +126,7 @@ namespace Volian.Controls.Library
if (ii.MyDocVersion != null) if (ii.MyDocVersion != null)
listBoxUsages.Items.Add(ii.MyProcedure.ToString() + " - " + ii.MyContent.Number + " " + ii.MyContent.Text); listBoxUsages.Items.Add(ii.MyProcedure.ToString() + " - " + ii.MyContent.Number + " " + ii.MyContent.Text);
} }
btnPrint.Enabled = listBoxUsages.Items.Count > 0 ? true : false; btnPrint.Enabled = listBoxLibDocs.Items.Count > 0 ? true : false;
} }
private void btnDelLibDoc_Click(object sender, EventArgs e) private void btnDelLibDoc_Click(object sender, EventArgs e)
{ {
@ -204,7 +205,7 @@ namespace Volian.Controls.Library
OpenFileDialog openFileDialog1 = new OpenFileDialog(); OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Word files (*.doc;*.rtf)|*.doc;*.rtf|All files (*.*)|*.*"; openFileDialog1.Filter = "Word files (*.doc;*.rtf;*.docx)|*.doc;*.rtf;*.docx|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0; openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true; openFileDialog1.RestoreDirectory = true;
@ -239,13 +240,14 @@ namespace Volian.Controls.Library
{ {
try try
{ {
FileInfo fi = new FileInfo(temppath);
FileStream fs = File.Open(temppath, FileMode.Open, FileAccess.Read, FileShare.None); FileStream fs = File.Open(temppath, FileMode.Open, FileAccess.Read, FileShare.None);
long len = fs.Length + 1; long len = fs.Length;
byte[] ByteArray = new byte[len]; byte[] ByteArray = new byte[len];
int nBytesRead = fs.Read(ByteArray, 0, (int)len); int nBytesRead = fs.Read(ByteArray, 0, (int)len);
fs.Close(); fs.Close();
string t1 = (title == null || title == "") ? null : title; string t1 = (title == null || title == "") ? null : title;
Document doc = Document.MakeDocument(t1, ByteArray, null, null); //, DateTime.Now, "Migration"); Document doc = Document.MakeDocument(t1, ByteArray, null, null, fi.Extension); //, DateTime.Now, "Migration");
return doc.DocID; return doc.DocID;
} }
// for an io exception, keep trying // for an io exception, keep trying