159 lines
4.7 KiB
C#
159 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using VEPROMS.CSLA.Library;
|
|
using Volian.Base.Library;
|
|
//using Volian.Pipe.Library;
|
|
using System.Xml;
|
|
using System.Diagnostics;
|
|
using JR.Utils.GUI.Forms;
|
|
|
|
namespace VEPROMS
|
|
{
|
|
public partial class frmAnnotationsCleanup : Form
|
|
{
|
|
Label mylab = new Label();
|
|
string procList = "";
|
|
string docvList = "";
|
|
int AnnotationTyp;
|
|
List<ProcedureInfo> pil2 = new List<ProcedureInfo>();
|
|
List<DocVersionInfo> dvil2 = new List<DocVersionInfo>();
|
|
private frmBatchRefresh mainForm = null;
|
|
// frmAnnotationsCleanup constructor passes users procedure and docversion selections from frmBatchRefresh
|
|
public frmAnnotationsCleanup(Form callingForm, List<ProcedureInfo> pil, List<DocVersionInfo> dvil)
|
|
|
|
{ // Set up link back to parent form.
|
|
mainForm = callingForm as frmBatchRefresh;
|
|
InitializeComponent();
|
|
|
|
pil2 = pil;
|
|
dvil2 = dvil;
|
|
|
|
// Get list of annotation types for plant.
|
|
myAnnotationTypeInfoList = AnnotationTypeInfoList.Get();
|
|
lbAnnotationTypes.DataSource = myLocalAnnotationTypeInfoList = new LocalAnnotationTypeInfoList(myAnnotationTypeInfoList);
|
|
|
|
Dictionary<string, string> AnnotationsList = new Dictionary<string, string>();
|
|
|
|
// Add name and type ID to form.
|
|
foreach (LocalAnnotationTypeInfo lati in myLocalAnnotationTypeInfoList)
|
|
{
|
|
AnnotationsList.Add(lati.TypeID.ToString(), lati.Name);
|
|
//cbAnnotationTypes.Items.Add(new { Name = lati.Name, Value = lati.TypeID });
|
|
}
|
|
|
|
lbAnnotationTypes.DataSource = new BindingSource(AnnotationsList, null);
|
|
lbAnnotationTypes.DisplayMember = "Value";
|
|
lbAnnotationTypes.ValueMember = "Key";
|
|
lbAnnotationTypes.SelectedIndexChanged += lbAnnotationTypes_SelectedIndexChanged;
|
|
|
|
}
|
|
// create comma delimited string of procedures selected by user.
|
|
private string getAnnotationProcItems(List<ProcedureInfo> pil2)
|
|
{
|
|
procList = "";
|
|
foreach (var p in pil2)
|
|
{
|
|
if (p.IsProcedure)
|
|
{
|
|
if (procList == "")
|
|
{
|
|
procList = procList + p.ItemID.ToString();
|
|
}
|
|
else
|
|
{
|
|
procList = procList + "," + p.ItemID.ToString();
|
|
}
|
|
}
|
|
}
|
|
return procList;
|
|
}
|
|
|
|
// create comma delimited string of doc versions selected by user.
|
|
private string getAnnotationDocvItems(List<DocVersionInfo> dvil2)
|
|
{
|
|
docvList = "";
|
|
foreach (var d in dvil2)
|
|
{
|
|
if (d.IsDocVersion)
|
|
{
|
|
if (docvList == "")
|
|
{
|
|
docvList = docvList + d.VersionID.ToString();
|
|
}
|
|
else
|
|
{
|
|
docvList = docvList + "," + d.VersionID.ToString();
|
|
}
|
|
}
|
|
}
|
|
return docvList;
|
|
}
|
|
|
|
private AnnotationTypeInfoList myAnnotationTypeInfoList = null;
|
|
private LocalAnnotationTypeInfoList myLocalAnnotationTypeInfoList = null;
|
|
|
|
// Process used to cleanup annotations "(Proceed?" button)
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
foreach (var p in pil2)
|
|
{
|
|
if (p.IsProcedure)
|
|
{
|
|
TextBox frm2 = mainForm.GettxtProcess();
|
|
frm2.AppendText(p.DisplayNumber + ' ' + p.DisplayText);
|
|
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
|
|
Annotation.DeleteAnnotationProcByType(AnnotationTyp, p.ItemID.ToString());
|
|
lblCountNumber.Text = "0";
|
|
}
|
|
|
|
}
|
|
foreach (var d in dvil2)
|
|
{
|
|
if (d.IsDocVersion)
|
|
{
|
|
TextBox frm2 = mainForm.GettxtProcess();
|
|
frm2.AppendText(d.ActiveParent.ToString());
|
|
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
|
|
Annotation.DeleteAnnotationDocvByType(AnnotationTyp, d.VersionID.ToString());
|
|
lblCountNumber.Text = "0";
|
|
}
|
|
}
|
|
}
|
|
// Retrieve number of annotations that will be deleted.
|
|
private void lbAnnotationTypes_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
btnClean.Enabled = false;
|
|
lblCountNumber.Text = "";
|
|
int deletecountProc = 0;
|
|
int deletecountDocv = 0;
|
|
if (pil2.Count > 0)
|
|
{
|
|
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
|
|
deletecountProc = Annotation.getAnnotationProcCnt(AnnotationTyp, getAnnotationProcItems(pil2));
|
|
}
|
|
|
|
if (dvil2.Count > 0)
|
|
{
|
|
AnnotationTyp = System.Convert.ToInt32(((KeyValuePair<string, string>)lbAnnotationTypes.SelectedItem).Key);
|
|
deletecountDocv = Annotation.getAnnotationCountDocv(AnnotationTyp, getAnnotationDocvItems(dvil2));
|
|
}
|
|
lblCountNumber.Text = (deletecountProc + deletecountDocv).ToString();
|
|
btnClean.Enabled = true;
|
|
|
|
}
|
|
// Close form.
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
}
|
|
}
|