update 20241029
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
209
Database/db.cs
209
Database/db.cs
@@ -14,6 +14,7 @@ using System.Diagnostics.Eventing.Reader;
|
||||
using Logging;
|
||||
using System.Configuration;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NLog.LayoutRenderers;
|
||||
|
||||
|
||||
|
||||
@@ -279,14 +280,14 @@ namespace Database
|
||||
}
|
||||
public string get_vorlage_to_file(string nr, string tempdir, string dokumentid)
|
||||
{
|
||||
|
||||
string filename = "";
|
||||
SqlConnection conn = new SqlConnection(connectionstring);
|
||||
SqlCommand sc = new SqlCommand("Select vorlage from office_vorlage_datei where dbo.office_vorlage_datei.office_vorlage_dateinr=" + nr, conn);
|
||||
conn.Open();
|
||||
SqlDataReader sqldr = sc.ExecuteReader();
|
||||
while (sqldr.Read())
|
||||
{
|
||||
string filename = tempdir + @"\" + dokumentid;
|
||||
filename = tempdir + @"\" + dokumentid;
|
||||
byte[] attachment = (byte[])sqldr.GetValue(0);
|
||||
FileStream fs = new FileStream(filename, FileMode.Create);
|
||||
fs.Write(attachment, 0, attachment.Length);
|
||||
@@ -294,7 +295,7 @@ namespace Database
|
||||
}
|
||||
conn.Close();
|
||||
|
||||
return "";
|
||||
return filename;
|
||||
}
|
||||
|
||||
public DataTable Get_ApplicationType_from_Vorlage(int vorlagenr)
|
||||
@@ -1184,7 +1185,52 @@ namespace Database
|
||||
scmCmdToExecute.Dispose();
|
||||
}
|
||||
|
||||
public int Save_Serienbrief(serienbrief sb)
|
||||
public serienbrief Load_Serienbrief(serienbrief sb, string temppath)
|
||||
{
|
||||
clsEdex_sb_serienbrief dbsb = new clsEdex_sb_serienbrief();
|
||||
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
||||
edoka_conn.sConnectionString = this.connectionstring;
|
||||
dbsb.cpMainConnectionProvider = edoka_conn;
|
||||
dbsb.iSerienbriefnr=sb.serienbriefnr;
|
||||
dbsb.SelectOne();
|
||||
|
||||
sb.bezeichnung = dbsb.sBezeichnung.ToString();
|
||||
sb.serienbriefnr = Convert.ToInt32(dbsb.iSerienbriefnr.Value);
|
||||
sb.verantwortlich = Convert.ToInt32(dbsb.iVerantwortlich.Value);
|
||||
sb.postzustellung = Convert.ToInt32(dbsb.iPostzustellung.Value);
|
||||
sb.dokumentdatum = Convert.ToDateTime(dbsb.daDokumentdatum.Value);
|
||||
sb.zustaendig = Convert.ToInt32(dbsb.iZustaendig.Value);
|
||||
sb.unterschriftlinks = Convert.ToInt32(dbsb.iUnterschriftlinks.Value);
|
||||
sb.unterschriftrechts = Convert.ToInt32(dbsb.iUnterschriftrechts.Value);
|
||||
sb.team = Convert.ToInt32(dbsb.iTeam.Value);
|
||||
sb.archivdatum = Convert.ToDateTime(dbsb.daArchivdatum.Value);
|
||||
try { sb.termin = Convert.ToDateTime(dbsb.daTermin.Value); } catch { }
|
||||
sb.bemerkung = dbsb.sBemerkung.ToString();
|
||||
sb.erstellt_am = Convert.ToDateTime(dbsb.daErstellt_am.Value);
|
||||
sb.mutiert_am = Convert.ToDateTime(dbsb.daMutiert_am.Value);
|
||||
sb.team = Convert.ToInt32(dbsb.iMutierer.Value);
|
||||
sb.aktiv = Convert.ToBoolean(dbsb.bAktiv.Value);
|
||||
sb.status = Convert.ToInt32( dbsb.iStatus.Value);
|
||||
sb.dokumenttypnr = Convert.ToInt32(dbsb.iDokumenttypnr.Value);
|
||||
sb.windowwidth = Convert.ToInt32(dbsb.iWindowwidth.Value);
|
||||
sb.windowheight = Convert.ToInt32(dbsb.iWindowwidth.Value);
|
||||
sb.treewidth = Convert.ToInt32(dbsb.iTreewidth.Value);
|
||||
sb.inBearbeitung = Convert.ToInt32(dbsb.iInBearbeitung.Value);
|
||||
sb.fehlerhaft = Convert.ToInt32(dbsb.iFehlerhaft.Value);
|
||||
sb.erstellt = Convert.ToInt32(dbsb.iErstellt.Value);
|
||||
sb.gedruckt = Convert.ToInt32(dbsb.iGedruckt.Value);
|
||||
sb.bestaetigt = Convert.ToInt32(dbsb.iBestaetigt.Value);
|
||||
sb.ausgeloest = Convert.ToInt32(dbsb.iAusgeloest.Value);
|
||||
try {sb.bldossier = Convert.ToInt32(dbsb.iBldossier.Value); } catch { };
|
||||
string fn = read_empfaengerdata(sb.serienbriefnr, temppath);
|
||||
if (fn != "") {
|
||||
sb.dsempfaenger.Tables.Clear();
|
||||
sb.dsempfaenger.ReadXml(fn);
|
||||
System.IO.File.Delete(fn);
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
public int Save_Serienbrief(serienbrief sb, string temppath)
|
||||
{
|
||||
clsEdex_sb_serienbrief dbsb = new clsEdex_sb_serienbrief();
|
||||
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
||||
@@ -1236,13 +1282,164 @@ namespace Database
|
||||
dbsb.Update();
|
||||
|
||||
}
|
||||
save_empfaengerdata(sb.serienbriefnr,temppath,sb.dsempfaenger);
|
||||
edoka_conn.CloseConnection(true);
|
||||
|
||||
|
||||
return sb.serienbriefnr;
|
||||
}
|
||||
|
||||
public string read_empfaengerdata(int serienbriefnr, string temppath)
|
||||
{
|
||||
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
||||
|
||||
|
||||
Get_Tabledata("Select dbo.BinaryToBase64(xmldata) from edex_sb_empfaenger where serienbriefnr=" + serienbriefnr.ToString(), false, true);
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(filename, Convert.FromBase64String(dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
}
|
||||
catch
|
||||
{
|
||||
filename = "";
|
||||
}
|
||||
return filename;
|
||||
|
||||
}
|
||||
public Boolean save_empfaengerdata(int serienbriefnr, string temppath, DataSet empf)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
||||
empf.WriteXml(filename);
|
||||
|
||||
|
||||
SqlConnection Connection = new SqlConnection();
|
||||
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_empfaenger where serienbriefnr=" + serienbriefnr.ToString() + "", Connection);
|
||||
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
||||
DataSet ds = new DataSet();
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
byte[] mydata = new byte[fs.Length];
|
||||
try
|
||||
{
|
||||
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
||||
fs.Close();
|
||||
Connection.ConnectionString = connectionstring;
|
||||
Connection.Open();
|
||||
DA.Fill(ds, "empfaenger");
|
||||
DataRow myRow;
|
||||
if (ds.Tables[0].Rows.Count == 0)
|
||||
{
|
||||
myRow = ds.Tables[0].NewRow();
|
||||
myRow[1] = serienbriefnr.ToString();
|
||||
myRow[2] = mydata;
|
||||
ds.Tables[0].Rows.Add(myRow);
|
||||
DA.Update(ds, "empfaenger");
|
||||
}
|
||||
else
|
||||
{
|
||||
myRow = ds.Tables[0].Rows[0];
|
||||
myRow[2] = mydata;
|
||||
DA.Update(ds, "empfaenger");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fs = null;
|
||||
cb = null;
|
||||
ds = null;
|
||||
DA = null;
|
||||
Connection.Close();
|
||||
Connection = null;
|
||||
System.IO.File.Delete(filename);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public string save_sb_vorlage_to_db(string filename, string doctype, int serienbriefnr)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlConnection Connection = new SqlConnection();
|
||||
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_vorlage where serienbriefnr=" + serienbriefnr.ToString() , Connection);
|
||||
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
||||
DataSet ds = new DataSet();
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
byte[] mydata = new byte[fs.Length];
|
||||
try
|
||||
{
|
||||
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
||||
fs.Close();
|
||||
Connection.ConnectionString = connectionstring;
|
||||
Connection.Open();
|
||||
DA.Fill(ds, "vorlage");
|
||||
DataRow myRow;
|
||||
if (ds.Tables[0].Rows.Count == 0)
|
||||
{
|
||||
myRow = ds.Tables[0].NewRow();
|
||||
myRow[0] = serienbriefnr.ToString();
|
||||
myRow[1] = mydata;
|
||||
myRow[2] = doctype;
|
||||
ds.Tables[0].Rows.Add(myRow);
|
||||
DA.Update(ds, "vorlage");
|
||||
}
|
||||
else
|
||||
{
|
||||
myRow = ds.Tables[0].Rows[0];
|
||||
myRow[1] = mydata;
|
||||
DA.Update(ds, "vorlage");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fs = null;
|
||||
cb = null;
|
||||
ds = null;
|
||||
DA = null;
|
||||
Connection.Close();
|
||||
Connection = null;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public string get_sb_vorlage(int serienbriefnr, string temppath)
|
||||
{
|
||||
|
||||
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
||||
|
||||
|
||||
Get_Tabledata("Select dbo.BinaryToBase64(vorlage), doctype from edex_sb_vorlage where serienbriefnr=" + serienbriefnr.ToString(), false, true);
|
||||
try
|
||||
{
|
||||
filename = temppath + serienbriefnr.ToString() + "." + dsdaten.Tables[0].Rows[0][1].ToString();
|
||||
File.WriteAllBytes(filename, Convert.FromBase64String(dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
}
|
||||
catch
|
||||
{
|
||||
filename = "";
|
||||
}
|
||||
return filename;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user