diff --git a/PROMS/DataLoader/LibDoc.cs b/PROMS/DataLoader/LibDoc.cs index fa533350..765e2576 100644 --- a/PROMS/DataLoader/LibDoc.cs +++ b/PROMS/DataLoader/LibDoc.cs @@ -31,6 +31,7 @@ namespace DataLoader private void MigrateLibDocs(OleDbConnection cn, string pth) { + frmMain.AddInfo("Before MigrateLibDocs\r\n{0}", VEPROMS.CSLA.Library.CSLACache.UsageAll); // Get all of the library documents - the first list has the entire list of files // found within the rtffiles folder, the second list contains usages from the 'tran' // file. During processing for procedures/sections occurs, the used library documents @@ -64,6 +65,7 @@ namespace DataLoader dicLibDocRef[key] = dicLibDocSect[dr_doc["TONUMBER"].ToString().ToUpper()]; } da_doc.Dispose(); + frmMain.AddInfo("After MigrateLibDocs\r\n{0}", VEPROMS.CSLA.Library.CSLACache.UsageAll); } private int MigrateLibDoc(FileInfo fi) { diff --git a/PROMS/DataLoader/PROMS2010.SQL b/PROMS/DataLoader/PROMS2010.SQL index e03b76f1..0b7181f6 100644 --- a/PROMS/DataLoader/PROMS2010.SQL +++ b/PROMS/DataLoader/PROMS2010.SQL @@ -7378,6 +7378,42 @@ IF (@@Error = 0) PRINT 'Procedure Creation: getFormat Succeeded' ELSE PRINT 'Procedure Creation: getFormat Error on Creation' GO +/****** Object: StoredProcedure [getJustFormat] ******/ +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getJustFormat]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [getJustFormat]; +GO + +CREATE PROCEDURE [dbo].[getJustFormat] + +( + @FormatID int +) +WITH EXECUTE AS OWNER +AS + SELECT + [FormatID], + [ParentID], + [Name], + [Description], + [Data], + [GenMac], + [DTS], + [UserID], + [LastChanged], + (SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formats].[FormatID]) [ContentCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formats].[FormatID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formats].[FormatID]) [FolderCount], + (SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formats].[FormatID]) [ChildCount] + FROM [Formats] + WHERE [FormatID]=@FormatID + + RETURN +GO +-- Display the status of Proc creation +IF (@@Error = 0) PRINT 'Procedure Creation: getJustFormat Succeeded' +ELSE PRINT 'Procedure Creation: getJustFormat Error on Creation' +GO + /****** Object: StoredProcedure [getFormat] ******/ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getFormatByName]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) DROP PROCEDURE [getFormatByName]; diff --git a/PROMS/DataLoader/Procedures.cs b/PROMS/DataLoader/Procedures.cs index 2ae21c45..fcc4e591 100644 --- a/PROMS/DataLoader/Procedures.cs +++ b/PROMS/DataLoader/Procedures.cs @@ -41,7 +41,9 @@ namespace DataLoader ProcFileName = dr["Entry"].ToString(); ProcNumber = dr["Number"].ToString(); frmMain.Status = "Processing Procedure " + ProcNumber + " - " + ProcFileName; - + GC.Collect(); + frmMain.AddInfo("Processing Procedure {0} {1}", ProcNumber, GC.GetTotalMemory(true)); + //frmMain.MyInfo = CSLACache.UsageNotFinalized; DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString()); @@ -223,7 +225,6 @@ namespace DataLoader frmMain.AddError(ex, "MigrateProcedure - {0}", ProcFileName); } da.Dispose(); - // dicSecCount is dictionary to track number of subsections for the parent at a level // dicSecID is the parent at that level Dictionary dicSecCount = new Dictionary(); @@ -286,6 +287,8 @@ namespace DataLoader } } dv.Dispose(); + //foreach (Item secItm in dicSecParentItem.Values) + // secItm.Dispose(); // need section start if (EditSectId != 0) { @@ -378,8 +381,22 @@ namespace DataLoader { if (OKtoProcessDBF(dr)) // look for duplicate SET file info - jsj 2/11/10 { + List cacheContentInfo = ContentInfo.CacheList; + List cacheItemInfo = ItemInfo.CacheList; + List cacheEntryInfo = EntryInfo.CacheList; + List cachePdfInfo = PdfInfo.CacheList; + List cacheDocVersionInfo = DocVersionInfo.CacheList; + List cachePartInfo = PartInfo.CacheList; FrItm = MigrateProcedure(cn, dr, FrItm, pth, docver, convertProcedures, activeFormat); if (FirstItm == null) FirstItm = FrItm; + frmMain.MyInfo = string.Format("Before Restore {0}", GC.GetTotalMemory(true)); + ContentInfo.RestoreCacheList(cacheContentInfo); + PartInfo.RestoreCacheList(cachePartInfo); + ItemInfo.RestoreCacheList(cacheItemInfo); + EntryInfo.RestoreCacheList(cacheEntryInfo); + PdfInfo.RestoreCacheList(cachePdfInfo); + DocVersionInfo.RestoreCacheList(cacheDocVersionInfo); + frmMain.MyInfo = string.Format("After Restore {0}", GC.GetTotalMemory(true)); } } //GC.Collect(); @@ -391,6 +408,10 @@ namespace DataLoader _MyLog.ErrorFormat("MigrateProcedures - {0} - {1}\r\n\r\n{2}", pth,ex.Message, ex.InnerException); //throw new Exception("Error in MigrateProcedures: " + pth, ex); } + frmMain.MyInfo = CSLACache.UsageAll; + frmMain.AddInfo(Content.MyStack); + frmMain.AddInfo(ContentInfo.MyStack); + frmMain.AddInfo(DocVersionInfo.MyStack); return FirstItm; } private void DbtOk(string fname, string pth) diff --git a/PROMS/DataLoader/Sections.cs b/PROMS/DataLoader/Sections.cs index cfa9c8e4..0234c1fd 100644 --- a/PROMS/DataLoader/Sections.cs +++ b/PROMS/DataLoader/Sections.cs @@ -117,7 +117,10 @@ namespace DataLoader string thenum = num.ToString("d2"); fname = string.Format("{0}\\rtffiles\\{1}.A{2}", pth, ProcFileName, thenum); Application.DoEvents(); - SaveSectionDocument(fname, stpseq, SecType, ref Documentid, procitem.DisplayNumber + ":" + (Number == string.Empty ? Title : Number)); + string procnum = ""; + using (ItemInfo ii = ItemInfo.Get(procitem.ItemID)) + procnum = ii.DisplayNumber; + SaveSectionDocument(fname, stpseq, SecType, ref Documentid, procnum + ":" + (Number == string.Empty ? Title : Number)); if (Documentid == 0) { if (MissingDocument == null) @@ -136,11 +139,11 @@ namespace DataLoader // test for performance Content cont; - using(Format fmt2 = format == null ? null : format.Get()) + Format fmt2 = format == null ? null : format.Get(); cont = Content.New(Number, Title, 10000+docstyleindx, fmt2, ci==null?null:ci.ToString(), Dts, Userid); - Entry entry = cont.MyEntry; if (needEntry) { + Entry entry = cont.MyEntry; entry.MyDocument = Document.Get(Documentid); entry.DTS = Dts; entry.UserID = Userid; @@ -560,7 +563,7 @@ namespace DataLoader { if (seciteminfo.MyContent.ContentEntryCount != 0) { - using (DocumentInfo di = DocumentInfo.Get(secitem.MyContent.MyEntry.DocID)) + using (DocumentInfo di = seciteminfo.MyContent.MyEntry.MyDocument) { bool success = MSWordToPDF.UpdateDocPdf(di, OverrideColor, seciteminfo); if (!success) diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index abc99382..9b9a56ec 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -180,14 +180,17 @@ namespace DataLoader } if (frType > 0) { - parentItem.MyContent.ContentParts.Add(frType, item); - if (!parentItem.MyContent.IsSavable) ErrorRpt.ErrorReport(parentItem.MyContent); - parentItem.MyContent.Save(); + using (Content c = Content.Get(parentItem.ContentID)) + { + c.ContentParts.Add(frType, item); + if (!c.IsSavable) ErrorRpt.ErrorReport(c); + c.Save(); + } } // Remove styles that user entered but are automatically done via the format string tstr = null; - using (ItemInfo myInfo = item.MyItemInfo) // do this so that ItemInfo doesn't stay in cashe + using (ItemInfo myInfo = item.MyItemInfo) // do this so that ItemInfo doesn't stay in cache tstr = myInfo.RemoveRtfStyles(content.Text, fmt); if (tstr != content.Text) { diff --git a/PROMS/DataLoader/TransitionFixer.cs b/PROMS/DataLoader/TransitionFixer.cs index 008e444d..a727bb9c 100644 --- a/PROMS/DataLoader/TransitionFixer.cs +++ b/PROMS/DataLoader/TransitionFixer.cs @@ -5,7 +5,6 @@ using Volian.Controls.Library; using VEPROMS.CSLA.Library; using System.Text.RegularExpressions; using Volian.Base.Library; -using Volian.Controls.Library; using System.Xml; using System.IO; diff --git a/PROMS/DataLoader/Transitions.cs b/PROMS/DataLoader/Transitions.cs index dd4b21db..7beae8a3 100644 --- a/PROMS/DataLoader/Transitions.cs +++ b/PROMS/DataLoader/Transitions.cs @@ -170,7 +170,7 @@ namespace DataLoader } } if (userid == null || userid == "") userid = "Migration"; - Transition tr = null; + string results = null; try { int isRange = 0; @@ -178,15 +178,21 @@ namespace DataLoader isRange = 1; else if (itype == 2) isRange = 2; - tr = Transition.New(fromCon, toItem, toItem2, isRange, itype, ci != null ? ci.ToString() : null, dts, userid); - //if (otranskey != null) - // tr.MyZTransition.Oldto = otranskey; // info to finish outside transition processing later - //else - tr.MyZTransition.Oldto = dr["OLDTO"].ToString(); - if (!tr.IsSavable) ErrorRpt.ErrorReport(tr); - tr.Save(); - if (migrationErrors.Count > 0) - _ContentMigrationErrors.Add(fromCon.ContentID, migrationErrors); + using (Transition tr = Transition.New(fromCon, toItem, toItem2, isRange, itype, ci != null ? ci.ToString() : null, dts, userid)) + { + //if (otranskey != null) + // tr.MyZTransition.Oldto = otranskey; // info to finish outside transition processing later + //else + tr.MyZTransition.Oldto = dr["OLDTO"].ToString(); + if (!tr.IsSavable) ErrorRpt.ErrorReport(tr); + tr.Save(); + if (migrationErrors.Count > 0) + _ContentMigrationErrors.Add(fromCon.ContentID, migrationErrors); + if (toItem.ItemID == toItem2.ItemID && itype != 2) + results = string.Format(@"\v \v0 ", tr.TranType, tr.TransitionID, tr.ToID); + else + results = string.Format(@"\v \v0 ", tr.TranType, tr.TransitionID, tr.ToID, tr.RangeID); + } } catch (Exception ex) { @@ -194,11 +200,6 @@ namespace DataLoader log.Error("Error addition transition record"); log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); } - string results = null; - if (toItem.ItemID == toItem2.ItemID && itype != 2) - results = string.Format(@"\v \v0 ", tr.TranType, tr.TransitionID, tr.ToID); - else - results = string.Format(@"\v \v0 ", tr.TranType, tr.TransitionID, tr.ToID, tr.RangeID); return results; } diff --git a/PROMS/DataLoader/frmLoader.Designer.cs b/PROMS/DataLoader/frmLoader.Designer.cs index 7f637005..7daf4869 100644 --- a/PROMS/DataLoader/frmLoader.Designer.cs +++ b/PROMS/DataLoader/frmLoader.Designer.cs @@ -228,7 +228,7 @@ namespace DataLoader // this.tsslError.AutoSize = false; this.tsslError.Name = "tsslError"; - this.tsslError.Size = new System.Drawing.Size(300, 40); + this.tsslError.Size = new System.Drawing.Size(150, 40); this.tsslError.Text = "No Errors"; this.tsslError.TextAlign = System.Drawing.ContentAlignment.TopLeft; // diff --git a/PROMS/DataLoader/frmLoader.cs b/PROMS/DataLoader/frmLoader.cs index 1b6d9cc3..4febd3fd 100644 --- a/PROMS/DataLoader/frmLoader.cs +++ b/PROMS/DataLoader/frmLoader.cs @@ -95,18 +95,18 @@ namespace DataLoader get { return tsslError.Text; } set { - MyFrmErrors.Add(value); + MyFrmErrors.Add(value, MessageType.Error); _MyLog.ErrorFormat(value); - tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count); } + tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount); } } public string MyWarning { get { return tsslError.Text; } set { - MyFrmErrors.Add(value); + MyFrmErrors.Add(value, MessageType.Warning); _MyLog.WarnFormat(value); - tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count); + //tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount); } } public string MyInfo @@ -114,9 +114,9 @@ namespace DataLoader get { return tsslError.Text; } set { - MyFrmErrors.Add(value); - _MyLog.InfoFormat(value); - tsslError.Text = string.Format("{0} Errors", MyFrmErrors.MyErrors.Count); + MyFrmErrors.Add(value, MessageType.Information); + _MyLog.Info(value); + //tsslError.Text = string.Format("{0} Errors", MyFrmErrors.ErrorCount); } } public void AddError(string format, params object[] objs) @@ -595,6 +595,11 @@ namespace DataLoader } private void btnFixTransitions_Click(object sender, EventArgs e) { + List cacheContentInfo = ContentInfo.CacheList; + List cacheItemInfo = ItemInfo.CacheList; + //List cacheEntryInfo = EntryInfo.CacheList; + //List cachePdfInfo = PdfInfo.CacheList; + //List cacheDocVersionInfo = DocVersionInfo.CacheList; //if (!CheckLogPath()) return; StepRTB rtb = new StepRTB(); TransitionFixer myFixer = new TransitionFixer(rtb,MySettings.LogFilePath); @@ -605,6 +610,12 @@ namespace DataLoader if(!ProcessComplete) MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", TransFixTime, howlong.TotalSeconds)); //MessageBox.Show(string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds, howlong.TotalSeconds)); CreateBackupRestoreBatchFiles(); + ItemInfo.RestoreCacheList(cacheItemInfo); + ContentInfo.RestoreCacheList(cacheContentInfo); + //EntryInfo.RestoreCacheList(cacheEntryInfo); + //PdfInfo.RestoreCacheList(cachePdfInfo); + //DocVersionInfo.RestoreCacheList(cacheDocVersionInfo); + MyInfo = CSLACache.UsageAll; } void myFixer_StatusChanged(object sender, TransitionFixerEventArgs args) @@ -641,7 +652,7 @@ namespace DataLoader if (TextConvert.MyGlitches.Glitches.Count > 0) TextConvert.MyGlitches.Save(MySettings.LogFilePath + @"\ConversionGlitches.xml"); // Save the Error Log - if (_MyFrmErrors.ItemCount() > 0) + if (_MyFrmErrors.ErrorCount > 0) _MyFrmErrors.Save(MySettings.LogFilePath + @"\ConversionErrors.txt"); } @@ -731,6 +742,8 @@ namespace DataLoader mb.Append("Backup Complete"); Status = "Processing Complete"; ProcessComplete = false; + Clipboard.Clear(); + Clipboard.SetText(mb.ToString()); MessageBox.Show(mb.ToString(), "Processing Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void ConvertToChangeManager() @@ -885,12 +898,14 @@ namespace DataLoader } public void Append(string format, params object [] args) { - string msg = "\r\n" + string.Format(format,args); + string msg = string.Format(format,args); DateTime now = DateTime.Now; TimeSpan ts = TimeSpan.FromTicks(now.Ticks - _LastTime.Ticks); string timestamp = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); _LastTime = now; - _MyStringBulider.Append("\r\n" + timestamp + " " + msg); + GC.Collect(); + long memUse = GC.GetTotalMemory(true); + _MyStringBulider.Append("\r\n" + timestamp + "\t" + memUse.ToString() + "\t" + msg); } public override string ToString() {