updfate 20250919
This commit is contained in:
@@ -295,8 +295,9 @@ namespace OnDoc.Versandstrasse
|
||||
private bool Verify_Couvert(TreeNodeAdv node)
|
||||
{
|
||||
errors.Clear();
|
||||
|
||||
bool hastattachment = false;
|
||||
errormessage = "";
|
||||
errors.Clear();
|
||||
lblerror.Visible = false;
|
||||
Versandpaket vp = node.TagObject as Versandpaket;
|
||||
if (vp.isSerienbrief)
|
||||
@@ -381,6 +382,17 @@ namespace OnDoc.Versandstrasse
|
||||
|
||||
foreach (TreeNodeAdv dokumentnode in node.Nodes)
|
||||
{
|
||||
if (dokumentnode.Tag.ToString().Contains("ATT"))
|
||||
{
|
||||
hastattachment = true;
|
||||
if (nodecounter == 0)
|
||||
{
|
||||
versandbereit = false;
|
||||
add_errormessage(11, "Ein externes Dokument kann nicht als erstes Dokument im Couvert sein");
|
||||
break;
|
||||
}
|
||||
else { versandbereit = true; break; }
|
||||
}
|
||||
//node.LeftImageIndices = new int[] { 0 };
|
||||
db.Get_Tabledata("SELECT dbo.dokument.nrpar00, dbo.dokument.dokumentid, isnull(dbo.dokumenttyp.Versandstrasse_moeglich,0) as vsm, isnull(dbo.dokumenttyp.versandstrasse_firstdoc,0) as firstdoc, isnull(postzustellung,0) as postzustellung FROM dbo.dokument INNER JOIN " +
|
||||
" dbo.dokumenttyp ON dbo.dokument.dokumenttypnr = dbo.dokumenttyp.dokumenttypnr where dbo.dokument.dokumentid='" + dokumentnode.Tag + "'", false, true);
|
||||
@@ -450,9 +462,13 @@ namespace OnDoc.Versandstrasse
|
||||
}
|
||||
if (node.Nodes.Count < 1) { versandbereit = false; add_errormessage(1, "Im Versand-Couvert liegen keine Dokumente"); }
|
||||
if (anzbp > 1) { versandbereit = false; }
|
||||
if (hastattachment) { lblAttachment.Visible = true; } else { lblAttachment.Visible = false; }
|
||||
if (versandbereit == true)
|
||||
{
|
||||
richTextBox1.Clear();
|
||||
richTextBox1.SelectionBullet = false;
|
||||
lblerror.Visible = false;
|
||||
lblerror.Text = "";
|
||||
set_nodeimage(node, 1);
|
||||
return true;
|
||||
}
|
||||
@@ -507,25 +523,33 @@ namespace OnDoc.Versandstrasse
|
||||
dokumentnode.Text = paket.Dokument[i].Bezeichnung + " (" + paket.Dokument[i].Partnernr + ")";
|
||||
dokumentnode.Tag = paket.Dokument[i].DokumentID;
|
||||
dokumentnode.TagObject = paket.Dokument[i];
|
||||
reserve_vs_dokument(dokumentnode.Tag.ToString(), 3);
|
||||
db.Get_Tabledata("SELECT dbo.dokument.dokumentid, isnull(dbo.dokumenttyp.Versandstrasse_moeglich,0) as vsm, isnull(dbo.dokumenttyp.versandstrasse_firstdoc,0) as firstdoc FROM dbo.dokument INNER JOIN " +
|
||||
" dbo.dokumenttyp ON dbo.dokument.dokumenttypnr = dbo.dokumenttyp.dokumenttypnr where dbo.dokument.dokumentid='" + dokumentnode.Tag + "'", false, true);
|
||||
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["firstdoc"]) == 0)
|
||||
// Attachment
|
||||
if (dokumentnode.Tag.ToString().Contains("ATT"))
|
||||
{
|
||||
set_nodeimage(dokumentnode, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_nodeimage(dokumentnode, 3);
|
||||
}
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["vsm"]) == 0)
|
||||
{
|
||||
set_nodeimage(dokumentnode, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//dokumentnode.LeftImageIndices = new int[] { 3};
|
||||
reserve_vs_dokument(dokumentnode.Tag.ToString(), 3);
|
||||
db.Get_Tabledata("SELECT dbo.dokument.dokumentid, isnull(dbo.dokumenttyp.Versandstrasse_moeglich,0) as vsm, isnull(dbo.dokumenttyp.versandstrasse_firstdoc,0) as firstdoc FROM dbo.dokument INNER JOIN " +
|
||||
" dbo.dokumenttyp ON dbo.dokument.dokumenttypnr = dbo.dokumenttyp.dokumenttypnr where dbo.dokument.dokumentid='" + dokumentnode.Tag + "'", false, true);
|
||||
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["firstdoc"]) == 0)
|
||||
{
|
||||
set_nodeimage(dokumentnode, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_nodeimage(dokumentnode, 3);
|
||||
}
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["vsm"]) == 0)
|
||||
{
|
||||
set_nodeimage(dokumentnode, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//dokumentnode.LeftImageIndices = new int[] { 3};
|
||||
}
|
||||
}
|
||||
|
||||
parentnode.Nodes.Add(dokumentnode);
|
||||
@@ -536,6 +560,45 @@ namespace OnDoc.Versandstrasse
|
||||
#region "Treeview"
|
||||
private void treeViewAdv1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
TreeViewAdv FiletreeView = sender as TreeViewAdv;
|
||||
TreeNodeAdv FilesourceNode = (TreeNodeAdv)e.Data.GetData(typeof(TreeNodeAdv));
|
||||
TreeNodeAdv FiledestinationNode = this.treeViewDragHighlightTracker.HighlightNode;
|
||||
TreeViewDropPositions FiledropPosition = this.treeViewDragHighlightTracker.DropPosition;
|
||||
Point ptInTree = FiletreeView.PointToClient(new Point(e.X, e.Y));
|
||||
FiledestinationNode = FiletreeView.GetNodeAtPoint(ptInTree);
|
||||
if (FiledestinationNode == null) { FiledestinationNode=treeViewAdv1.Nodes[0]; }
|
||||
|
||||
|
||||
Versandpaket DestPaket;
|
||||
if (FiledestinationNode.Level == 1)
|
||||
{
|
||||
DestPaket = FiledestinationNode.TagObject as Versandpaket;
|
||||
}
|
||||
else
|
||||
{
|
||||
DestPaket = FiledestinationNode.Parent.TagObject as Versandpaket;
|
||||
}
|
||||
int partnernr = DestPaket.partnernr;
|
||||
|
||||
string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; // get all files droppeds
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (System.IO.Path.GetExtension(file.ToUpper()) == ".PDF")
|
||||
{
|
||||
Add_Attachment(file, partnernr,DestPaket.PaketNr);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch { e.Effect = DragDropEffects.None;return; }
|
||||
try
|
||||
{
|
||||
TreeViewAdv treeView = sender as TreeViewAdv;
|
||||
@@ -599,6 +662,38 @@ namespace OnDoc.Versandstrasse
|
||||
|
||||
private void treeViewAdv1_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
bool Filedroppable = true;
|
||||
TreeNodeAdv FiledestinationNode = null;
|
||||
TreeViewAdv FiletreeView = sender as TreeViewAdv;
|
||||
Point FileptInTree = FiletreeView.PointToClient(new Point(e.X, e.Y));
|
||||
FiledestinationNode = FiletreeView.GetNodeAtPoint(FileptInTree);
|
||||
try
|
||||
{
|
||||
if (FiledestinationNode.Nodes.Count == 0)
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
}
|
||||
string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; // get all files droppeds
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (System.IO.Path.GetExtension(file.ToUpper()) == ".PDF")
|
||||
{
|
||||
e.Effect = DragDropEffects.Link;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
bool droppable = true;
|
||||
TreeNodeAdv destinationNode = null;
|
||||
TreeViewAdv treeView = sender as TreeViewAdv;
|
||||
@@ -606,9 +701,28 @@ namespace OnDoc.Versandstrasse
|
||||
this.currentSourceNode = null;
|
||||
if (e.Data.GetDataPresent(typeof(TreeNodeAdv)))
|
||||
{
|
||||
|
||||
destinationNode = treeView.GetNodeAtPoint(ptInTree);
|
||||
TreeNodeAdv sourceNode = (TreeNodeAdv)e.Data.GetData(typeof(TreeNodeAdv));
|
||||
this.currentSourceNode = sourceNode;
|
||||
|
||||
try
|
||||
{
|
||||
Versanddokument vd = sourceNode.TagObject as Versanddokument;
|
||||
if (vd.DokumentID.Contains("ATT"))
|
||||
{
|
||||
TreeNodeAdv destnodetop = destinationNode;
|
||||
if (destnodetop.Level > 1) { destnodetop = destnodetop.Parent; }
|
||||
if (destnodetop != sourceNode.Parent)
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
droppable = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
droppable = this.CanDrop(sourceNode, destinationNode);
|
||||
//if (droppable == true) { if (destinationNode.Tag.ToString() != "Druckpaket") { droppable = false; } }
|
||||
}
|
||||
@@ -777,11 +891,18 @@ namespace OnDoc.Versandstrasse
|
||||
{
|
||||
foreach (Versanddokument vsdok in paket.Dokument)
|
||||
{
|
||||
|
||||
if (vsdok.DokumentID == tn.Tag.ToString())
|
||||
{
|
||||
clsVersandstrasse vs = new clsVersandstrasse();
|
||||
vsdok.dokument = vs.Prepare_PDF(vsdok.DokumentID.ToString(), AppParams.tempdir, AppParams.connectionstring, AppParams.RESTURI, AppParams.apikey, Application.StartupPath);
|
||||
if (vsdok.DokumentID.Contains("ATT") && vsdok.dokument != "")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
clsVersandstrasse vs = new clsVersandstrasse();
|
||||
vsdok.dokument = vs.Prepare_PDF(vsdok.DokumentID.ToString(), AppParams.tempdir, AppParams.connectionstring, AppParams.RESTURI, AppParams.apikey, Application.StartupPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -817,7 +938,14 @@ namespace OnDoc.Versandstrasse
|
||||
//}
|
||||
|
||||
string stapel = save_stapel(ref streams);
|
||||
if (stapel == "File too large")
|
||||
{
|
||||
MessageBox.Show("Das Versandpaket ist zu gross. Es können max. "+ String.Format("{0:0.0}", AppParams.MaxFileSize/(1024*1024)) + " MB versendet werden.","Versandstrasse", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
panelPrepare.Visible = false;
|
||||
Cursor = Cursors.Default;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
paket.finaldoc = stapel;
|
||||
|
||||
@@ -840,7 +968,7 @@ namespace OnDoc.Versandstrasse
|
||||
if (Properties.Settings.Default.GASSize == "True")
|
||||
{
|
||||
if (Convert.ToInt32(txtAnzahlSeiten.Text) > 30)
|
||||
|
||||
|
||||
{
|
||||
if (chkGAS.Checked && rbc5mini.Checked)
|
||||
{
|
||||
@@ -872,8 +1000,14 @@ namespace OnDoc.Versandstrasse
|
||||
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
finalDoc.Save(outputStream);
|
||||
var size = outputStream.ToArray().Length;
|
||||
byte[] bytes;
|
||||
bytes = outputStream.ToArray();
|
||||
|
||||
if (size > AppParams.MaxFileSize)
|
||||
{
|
||||
return "File too large";
|
||||
}
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
catch { return ""; }
|
||||
@@ -980,8 +1114,15 @@ namespace OnDoc.Versandstrasse
|
||||
List<Versanddokument> vdl = new List<Versanddokument>();
|
||||
if (Properties.Settings.Default.GASSize == "True")
|
||||
{
|
||||
if (rbc5mini.Checked) { vp.GASSize = "C5mini"; }
|
||||
if (rbc5normal.Checked) { vp.GASSize = "C5normal"; }
|
||||
if (chkGAS.Checked)
|
||||
{
|
||||
if (rbc5mini.Checked) { vp.GASSize = "C5mini"; }
|
||||
if (rbc5normal.Checked) { vp.GASSize = "C5normal"; }
|
||||
}
|
||||
else
|
||||
{
|
||||
vp.GASSize = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1249,7 +1390,16 @@ namespace OnDoc.Versandstrasse
|
||||
}
|
||||
else
|
||||
{
|
||||
dok = vs.Prepare_PDF(node.Tag.ToString(), AppParams.tempdir, AppParams.connectionstring, AppParams.RESTURI, AppParams.apikey, Application.StartupPath, null, null, "", this.ribbonchkadresse.Checked);
|
||||
Versanddokument vd = node.TagObject as Versanddokument;
|
||||
if (vd.DokumentID.Contains("ATT") && vd.dokument != "")
|
||||
{
|
||||
dok = vd.dokument;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
dok = vs.Prepare_PDF(node.Tag.ToString(), AppParams.tempdir, AppParams.connectionstring, AppParams.RESTURI, AppParams.apikey, Application.StartupPath, null, null, "", this.ribbonchkadresse.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
var stream = new MemoryStream(Convert.FromBase64String(dok));
|
||||
@@ -1600,12 +1750,12 @@ namespace OnDoc.Versandstrasse
|
||||
int a = 0;
|
||||
}
|
||||
|
||||
public void add_doc(Versanddokument vs)
|
||||
public void add_doc(Versanddokument vs, string paketnr="")
|
||||
{
|
||||
bool zugewiesen = false;
|
||||
foreach (Versandpaket vp in pakete)
|
||||
{
|
||||
if (vp.partnernr.ToString() == vs.Partnernr)
|
||||
if (vp.partnernr.ToString() == vs.Partnernr && (paketnr=="" || paketnr==vp.PaketNr))
|
||||
{
|
||||
vp.Dokument.Add(vs);
|
||||
zugewiesen = true;
|
||||
@@ -1648,5 +1798,111 @@ namespace OnDoc.Versandstrasse
|
||||
{
|
||||
this.panelVerify.Visible = false;
|
||||
}
|
||||
|
||||
private void externesPDFHinzufügenToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
TreeNodeAdv node = treeViewAdv1.SelectedNode;
|
||||
if (node.Level != 1)
|
||||
{
|
||||
node = node.Parent;
|
||||
}
|
||||
if (node.Nodes.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Bitte zuerst ein reguläres OnDoc-Dokument zum Paket hinzufügen, "+Environment.NewLine+"bevor ein Anhang zugefügt wird.", "PDF-Datei hinzufügen", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Versandpaket vp = node.TagObject as Versandpaket;
|
||||
int partnernr = vp.partnernr;
|
||||
|
||||
Random random = new Random(19);
|
||||
openFileDialog1.FileName = "";
|
||||
openFileDialog1.Filter = "PDF-Dokumente (*.pdf)|*.pdf|Alle Dokumente (*.*)|*.*";
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (System.IO.Path.GetExtension(openFileDialog1.FileName).ToLower() != ".pdf")
|
||||
{
|
||||
MessageBox.Show("Es können lediglich PDF-Dateien hinzugefügt werden.","PDF-Datei hinzufügen",MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
Add_Attachment(openFileDialog1.FileName, partnernr,vp.PaketNr);
|
||||
}
|
||||
}
|
||||
private void Add_Attachment(string filename,int partnernr, string paketnr)
|
||||
{
|
||||
Helper.FileHelper fh = new Helper.FileHelper();
|
||||
string att = fh.Base64FromFile(filename);
|
||||
clsVersandstrasse vs = new clsVersandstrasse();
|
||||
att = vs.check_pdf_pages(att);
|
||||
string gid = "ATT" + RandomString(19);
|
||||
vs = null;
|
||||
Versanddokument attachment = new Versanddokument(gid, "Externe Datei: " + filename, partnernr.ToString());
|
||||
attachment.dokument = att;
|
||||
add_doc(attachment,paketnr );
|
||||
|
||||
}
|
||||
|
||||
public string RandomString(int size, bool lowerCase = false)
|
||||
{
|
||||
var builder = new StringBuilder(size);
|
||||
|
||||
// Unicode/ASCII Letters are divided into two blocks
|
||||
// (Letters 65–90 / 97–122):
|
||||
// The first group containing the uppercase letters and
|
||||
// the second group containing the lowercase.
|
||||
|
||||
// char is a single Unicode character
|
||||
char offset = lowerCase ? 'a' : 'A';
|
||||
const int lettersOffset = 26; // A...Z or a..z: length=26
|
||||
|
||||
for (var i = 0; i < size; i++)
|
||||
{
|
||||
var @char = (char)_random.Next(offset, offset + lettersOffset);
|
||||
builder.Append(@char);
|
||||
}
|
||||
|
||||
return lowerCase ? builder.ToString().ToLower() : builder.ToString();
|
||||
}
|
||||
private readonly Random _random = new Random();
|
||||
|
||||
// Generates a random number within a range.
|
||||
public int RandomNumber(int min, int max)
|
||||
{
|
||||
return _random.Next(min, max);
|
||||
}
|
||||
|
||||
private void ribbonAddPDF_Click(object sender, EventArgs e)
|
||||
{
|
||||
externesPDFHinzufügenToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void contextMenuStrip2_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
int id = Convert.ToInt32(treeViewAdvCouverts.SelectedNode.Tag);
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
try
|
||||
{
|
||||
db.Get_Tabledata("Select versendet, aktiv from Ondoc_Versandstrasse_Paket where id = " + id.ToString(), false, true);
|
||||
if (Convert.ToBoolean(db.dsdaten.Tables[0].Rows[0][0]) == true)
|
||||
{
|
||||
MessageBox.Show("Das Paket wurde zwischenzeitlich versendet. Bitte die Ansicht aktualisieren.", "Versandcouvert", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
e.Cancel = true;
|
||||
}
|
||||
if (Convert.ToBoolean(db.dsdaten.Tables[0].Rows[0][1]) == false)
|
||||
{
|
||||
MessageBox.Show("Das Paket wurde zwischenzeitlich gelöscht. Bitte die Ansicht aktualisieren.", "Versandcouvert", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
finally { db = null; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ribbonbtnAktualisieren_Click(object sender, EventArgs e)
|
||||
{
|
||||
Refresh_VersandCouverts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user