122 lines
3.8 KiB
C#

/*********************************************************************************************
* Copyright 2005 - Volian Enterprises, Inc. All rights reserved.
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
* ------------------------------------------------------------------------------
* $Workfile: RefList.cs $ $Revision: 3 $
* $Author: Jsj $ $Date: 7/21/06 2:59p $
*
* $History: RefList.cs $
*
* ***************** Version 3 *****************
* User: Jsj Date: 7/21/06 Time: 2:59p
* Updated in $/LibSource/VEObject
* The File for Edit Depenencies was being created in the wrong place for
* VFW to find.
*
* ***************** Version 2 *****************
* User: Kathy Date: 3/22/05 Time: 10:11a
* Updated in $/LibSource/VEObject
* clean up code
*
* ***************** Version 1 *****************
* User: Kathy Date: 3/08/05 Time: 1:51p
* Created in $/LibSource/VEObject
* Approval
*********************************************************************************************/
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Utils;
namespace VEObject
{
/// <summary>
/// Summary description for RefList.
///
/// The RefList class creates, reads, writes, and deletes a file
/// of the 'input' name to hold procedure numbers/sequence numbers that
/// represent dependencies that need to be addressed (i.e. removed) by
/// the user in the editor. This is either for resolving approve selected
/// conflicts or deleting a procedure with transitions. (actual current use is
/// for approve selected conflicts).
/// The contents of this file is read in and listed via the TranRefsDlg in vfw
/// for now, i.e. as long as vfw is the editor.
/// The 'input' file is created in the user's Temp directory when in multi-user
/// mode or in the procedure directory when a lock is set or when in single user \
/// mode.
/// </summary>
public class RefList
{
private string FileName;
private string FromProcNum;
private FileStream FSRef;
private BinaryWriter BWRef;
private UserRunTime usrRunTime;
private long HeaderOffset;
private Int16 NumRefs;
public RefList(string frmProcNum, string fname, UserRunTime urt)
{
FileName = fname;
usrRunTime=urt;
FromProcNum=frmProcNum;
NumRefs=0;
BWRef = null;
}
public bool Create()
{
try
{
// Bug fix B2006-034
// Note that ExeAdjust() needs to check for a lock set.
// When a lock is set, the xE7 char would act like the xE2 char in
// the ExeAdjust() function.
// This bug fix is taking advantage of the fact that lock must be set
// at the time the approval code reaches this logic.
//
// FSRef = new FileStream(usrRunTime.ExeAdjust("\xE7" + FileName),FileMode.Create,FileAccess.Write,FileShare.ReadWrite);
FSRef = new FileStream(usrRunTime.ExeAdjust("\xE2" + FileName),FileMode.Create,FileAccess.Write,FileShare.ReadWrite);
BWRef = new BinaryWriter(FSRef);
BWRef.Write(NumRefs); // Temporary holding for number of references
Int16 len = (Int16)FromProcNum.Length;
BWRef.Write(len);
byte[] btmp = Encoding.ASCII.GetBytes(FromProcNum);
BWRef.Write(btmp,0,len);
HeaderOffset = FSRef.Length;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
return true;
}
public void CloseFile()
{
if (BWRef != null) BWRef.Close();
FSRef=null;
BWRef=null;
NumRefs=0;
HeaderOffset=0;
}
public void WriteTotalNumRefs()
{
FSRef.Seek(0,System.IO.SeekOrigin.Begin);
BWRef.Write(NumRefs);
FSRef.Seek(0,System.IO.SeekOrigin.End);
}
public void WriteRefLine(string refline)
{
byte[] btmp = Encoding.ASCII.GetBytes(refline);
BWRef.Write(btmp,0,100);
NumRefs++;
}
}
}