public void cvnPbsfiles() { string ModelName = "Pbsfiles"; var qry = from r in Program.dbData3060.Tblpbsfiles select r; foreach (var r in qry) { clsRest objRest = new clsRest(); XElement xml = new XElement(ModelName); Type objectType = r.GetType(); PropertyInfo[] properties = objectType.GetProperties(); foreach (PropertyInfo property in properties) { string Name = property.Name; object Val = property.GetValue(r, null); //string NamePropertyType = property.GetValue(r, null).GetType().Name; xml.Add(new XElement(Name, Val)); } string strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); string retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Convert", strxml); if (retur != "Status: 404") { clsSQLite.insertStoreXML(Program.AppEngName, false, "sync/Convert", strxml, retur); } var qry2 = from r2 in Program.dbData3060.Tblpbsfile where r2.Pbsfilesid == r.Id orderby r2.Seqnr ascending select r2; string TilPBSFile = ""; int i = 0; foreach (var rec_pbsfile in qry2) { if (i++ > 0) { TilPBSFile += "\r\n"; } TilPBSFile += rec_pbsfile.Data; } //char[] c_TilPBSFile = TilPBSFile.ToCharArray(); //byte[] b_TilPBSFile = System.Text.Encoding.GetEncoding("windows-1252").GetBytes(c_TilPBSFile); XElement xml2 = new XElement("Pbsfile"); xml2.Add(new XElement("Id", r.Id)); xml2.Add(new XElement("Pbsfilesid", r.Id)); xml2.Add(new XElement("Data", TilPBSFile)); string strxml2 = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml2.ToString(); string retur2 = objRest.HttpPost2(clsRest.urlBaseType.sync, "Convert", strxml2); if (retur2 != "Status: 404") { clsSQLite.insertStoreXML(Program.AppEngName, false, "sync/Convert", strxml2, retur2); } } }
public void save() { string ModelName = "Kreditor"; var qry = from r in Program.memKreditor select r; foreach (var r in qry) { clsRest objRest = new clsRest(); XElement xml = new XElement(ModelName); Type objectType = r.GetType(); PropertyInfo[] properties = objectType.GetProperties(); foreach (PropertyInfo property in properties) { string Name = property.Name; object Val = property.GetValue(r, null); xml.Add(new XElement(Name, Val)); } string strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); string retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Convert", strxml); if (retur != "Status: 404") { clsSQLite.insertStoreXML(Program.AppEngName, false, "sync/Convert", strxml, retur); } } }
public void saveMedlog() { foreach (tblMedlogRow l in tabletblMedlog.Rows) { clsRest objRest = null; XElement xml = null; string retur = null; string strxml = null; switch (l.RowState) { case DataRowState.Added: objRest = new clsRest(); int Id = clsPbs.nextval("Medlogid"); xml = new XElement("Medlog"); xml.Add(new XElement("Id", Id)); xml.Add(new XElement("Source_id", Id)); xml.Add(new XElement("Source", "Medlog")); xml.Add(new XElement("Nr", l.Nr)); xml.Add(new XElement("Logdato", l.Logdato)); xml.Add(new XElement("Akt_id", l.Akt_id)); xml.Add(new XElement("Akt_dato", l.Akt_dato)); strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Medlog", strxml); l.AcceptChanges(); break; } } }
public void cvnMedlog() { string ModelName = "Medlog"; var qry = from r in Program.dbData3060.TblMedlemLog select r; foreach (var r in qry) { clsRest objRest = new clsRest(); XElement xml = new XElement(ModelName); Type objectType = r.GetType(); PropertyInfo[] properties = objectType.GetProperties(); foreach (PropertyInfo property in properties) { string Name = property.Name; object Val = property.GetValue(r, null); //string NamePropertyType = property.GetValue(r, null).GetType().Name; xml.Add(new XElement(Name, Val)); if (Name == "Id") { xml.Add(new XElement("Source_id", Val)); xml.Add(new XElement("Source", "Medlog")); } } string strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); string retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Convert", strxml); if (retur != "Status: 404") { clsSQLite.insertStoreXML(Program.AppEngName, false, "sync/Convert", strxml, retur); } } }
public void savePerson() { foreach (tblPersonRow p in tabletblPerson.Rows) { clsRest objRest = null; XElement xml = null; string retur = null; string strxml = null; switch (p.RowState) { case DataRowState.Added: objRest = new clsRest(); xml = new XElement("Medlem", new XElement("Nr", p.Nr)); xml.Add(new XElement("Navn", p.Navn)); xml.Add(new XElement("Kaldenavn", p.Kaldenavn)); xml.Add(new XElement("Adresse", p.Adresse)); xml.Add(new XElement("Postnr", p.Postnr)); xml.Add(new XElement("Bynavn", p.Bynavn)); xml.Add(new XElement("Telefon", p.Telefon)); xml.Add(new XElement("Email", p.Email)); xml.Add(new XElement("Kon", p.Kon)); xml.Add(new XElement("FodtDato", ((DateTime)p.FodtDato).ToString("yyyy-MM-dd"))); xml.Add(new XElement("Bank", p.Bank)); strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Medlem", strxml); p.AcceptChanges(); break; case DataRowState.Deleted: objRest = new clsRest(); retur = objRest.HttpDelete2(clsRest.urlBaseType.sync, "Medlem/" + p.Nr); p.AcceptChanges(); break; case DataRowState.Modified: objRest = new clsRest(); xml = new XElement("Medlem", new XElement("Nr", p.Nr)); xml.Add(new XElement("Navn", p.Navn)); xml.Add(new XElement("Kaldenavn", p.Kaldenavn)); xml.Add(new XElement("Adresse", p.Adresse)); xml.Add(new XElement("Postnr", p.Postnr)); xml.Add(new XElement("Bynavn", p.Bynavn)); xml.Add(new XElement("Telefon", p.Telefon)); xml.Add(new XElement("Email", p.Email)); xml.Add(new XElement("Kon", p.Kon)); xml.Add(new XElement("FodtDato", ((DateTime)p.FodtDato).ToString("yyyy-MM-dd"))); xml.Add(new XElement("Bank", p.Bank)); strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Medlem", strxml); p.AcceptChanges(); break; } } }
public void cvnPerson() { string ModelName = "Person"; var qry_medlemmer = from h in Program.karMedlemmer join d1 in Program.dbData3060.TblMedlem on h.Nr equals d1.Nr into details1 from x in details1.DefaultIfEmpty(new TblMedlem { Nr = -1, Kon = null, FodtDato = (DateTime?)null }) //where x.Nr == -1 select new { h.Nr, h.Navn, h.Kaldenavn, h.Adresse, h.Postnr, h.Bynavn, h.Telefon, h.Email, XNr = x == null ? (int?)null : x.Nr, Kon = x == null ? null : x.Kon, FodtDato = x == null ? (DateTime?)null : x.FodtDato, h.Bank }; //var qry = from r in Program.dsMedlemGlobal.Kartotek.AsEnumerable() // select new {r.Nr, r.Navn, r.Kaldenavn, r.Adresse, r.Postnr, r.Bynavn, r.Telefon, r.Email, r.FodtDato, r.Kon, r.Bank}; foreach (var r in qry_medlemmer) { clsRest objRest = new clsRest(); XElement xml = new XElement(ModelName); Type objectType = r.GetType(); PropertyInfo[] properties = objectType.GetProperties(); foreach (PropertyInfo property in properties) { string Name = property.Name; object Val = property.GetValue(r, null); //string NamePropertyType = property.GetValue(r, null).GetType().Name; xml.Add(new XElement(Name, Val)); } string strxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xml.ToString(); string retur = objRest.HttpPost2(clsRest.urlBaseType.sync, "Convert", strxml); if (retur != "Status: 404") { clsSQLite.insertStoreXML(Program.AppEngName, false, "sync/Convert", strxml, retur); } } }
public int OrderFaknrUpdate() { clsRest objRest = new clsRest(); string strxmldata = objRest.HttpGet2(clsRest.urlBaseType.data, "orderfaknrupdate"); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status != "True") { var qry_fak = from h in xmldata.Descendants("Fak") select new { Key = clsPassXmlDoc.attr_val_string(h, "Key"), Id = clsPassXmlDoc.attr_val_int(h, "Id"), SFakID = clsPassXmlDoc.attr_val_int(h, "SFakID"), SFaknr = clsPassXmlDoc.attr_val_int(h, "SFaknr"), }; var qry = from k in Program.karFakturaer_s where k.faknr > 0 join f in qry_fak on k.fakid equals f.SFakID where f.SFaknr == null select new { f.Key, f.Id, SFaknr = k.faknr, }; int AntalFakturaer = qry.Count(); if (AntalFakturaer > 0) { XElement SFaknrupdatexml = new XElement("SFaknrupdate"); foreach (var k in qry) { XElement fakxml = new XElement("Fak"); fakxml.Add(new XElement("Key", k.Key)); fakxml.Add(new XElement("Id", k.Id)); fakxml.Add(new XElement("SFaknr", k.SFaknr)); SFaknrupdatexml.Add(new XElement(fakxml)); } string strSFaknrupdatexml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + SFaknrupdatexml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "orderfaknrupdate", strSFaknrupdatexml); } return(AntalFakturaer); } return(0); }
private void cmdFakturer_Click(object sender, EventArgs e) { string TilPBSFilename = "Unknown"; //int AntalFakturaer; int imax; string keyval; DateTime fradato; DateTime tildato; bool tilmeldtpbs; bool indmeldelse; double advisbelob; if ((this.cmdFakturer.Text == "Afslut")) { this.Close(); } this.cmdForslag.Visible = false; this.cmdCancel.Visible = false; imax = lvwKontingent.Items.Count; this.pgmFaktura.Maximum = (imax * 4); this.pgmFaktura.Minimum = 0; this.pgmFaktura.Value = 0; this.pgmFaktura.Visible = true; if ((imax == 0)) { this.Label_Fakturatekst.Text = "Der ikke noget at fakturere"; this.Label_Fakturatekst.Visible = true; } else { XElement headxml = new XElement("TempKontforslag"); headxml.Add(new XElement("Betalingsdato", clsUtil.bankdageplus(this.DatoKontingentForfald.Value, 0))); headxml.Add(new XElement("Bsh", this.DelsystemBSH.Checked)); var i = 0; foreach (ListViewItem lvi in lvwKontingent.Items) { this.pgmFaktura.Value = ++i; keyval = lvi.Name; fradato = DateTime.Parse(lvi.SubItems[4].Text); advisbelob = double.Parse(lvi.SubItems[5].Text); tildato = DateTime.Parse(lvi.SubItems[6].Text); indmeldelse = (lvi.SubItems[7].Text == "J") ? true : false; tilmeldtpbs = (lvi.SubItems[8].Text == "J") ? true : false; XElement linxml = new XElement("TempKontforslaglinie"); linxml.Add(new XElement("Nr", int.Parse(keyval))); linxml.Add(new XElement("Advisbelob", (decimal)advisbelob)); linxml.Add(new XElement("Fradato", fradato)); linxml.Add(new XElement("Tildato", tildato)); linxml.Add(new XElement("Indmeldelse", indmeldelse)); linxml.Add(new XElement("Tilmeldtpbs", tilmeldtpbs)); headxml.Add(new XElement(linxml)); } clsRest objRest = new clsRest(); string strheadxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + headxml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "pbs601", strheadxml); /* * clsPbs601 objPbs601 = new clsPbs601(); * nsPuls3060.clsPbs601.SetLobnr += new nsPuls3060.clsPbs601.Pbs601DelegateHandler(On_clsPbs601_SetLobnr); * * AntalFakturaer = objPbs601.kontingent_fakturer_bs1(); * this.pgmFaktura.Value = imax * 2; * if ((AntalFakturaer > 0)) * { * objPbs601.faktura_og_rykker_601_action(m_lobnr, fakType.fdfaktura); * this.pgmFaktura.Value = (imax * 3); * clsSFTP objSFTP = new clsSFTP(); * TilPBSFilename = objSFTP.WriteTilSFtp(m_lobnr); * objSFTP.DisconnectSFtp(); * objSFTP = null; * } */ this.pgmFaktura.Value = (imax * 4); cmdFakturer.Text = "Afslut"; this.DelsystemBSH.Visible = false; this.Label_Fakturatekst.Text = ("Leverance til PBS i filen " + TilPBSFilename); this.Label_Fakturatekst.Visible = true; this.pgmFaktura.Visible = false; } }
public int ReadFraSFtp() { string homedir = m_sftp.RealPath(".", ""); // Open a directory on the server... string handle = m_sftp.OpenDir(m_Outbound); if (handle == null) { throw new Exception(m_sftp.LastErrorText); } // Download the directory listing: Chilkat.SFtpDir dirListing = null; dirListing = m_sftp.ReadDir(handle); if (dirListing == null) { throw new Exception(m_sftp.LastErrorText); } Program.memPbsnetdir = null; //opret ny memPbsnetdir // Iterate over the files. int i; int n = dirListing.NumFilesAndDirs; if (n > 0) { for (i = 0; i <= n - 1; i++) { Chilkat.SFtpFile fileObj = null; fileObj = dirListing.GetFileObject(i); if (!fileObj.IsDirectory) { DateTime testLastAccessTime = fileObj.LastAccessTime; recPbsnetdir rec = new recPbsnetdir { Type = 8, Path = dirListing.OriginalPath, Filename = fileObj.Filename, Size = (int)fileObj.Size32, Atime = Unspecified2Utc(fileObj.LastAccessTime), Mtime = Unspecified2Utc(fileObj.LastModifiedTime), Gid = fileObj.Gid, Uid = fileObj.Uid, Perm = fileObj.Permissions.ToString() }; Program.memPbsnetdir.Add(rec); } } } // Close the directory bool success = m_sftp.CloseHandle(handle); if (!success) { throw new Exception(m_sftp.LastErrorText); } var leftqry_pbsnetdir = from h in Program.memPbsnetdir select h; int AntalFiler = leftqry_pbsnetdir.Count(); if (leftqry_pbsnetdir.Count() > 0) { foreach (var rec_pbsnetdir in leftqry_pbsnetdir) { // Open a file on the server: string fullpath = rec_pbsnetdir.Path + "/" + rec_pbsnetdir.Filename; string filehandle = m_sftp.OpenFile(fullpath, "readOnly", "openExisting"); if (filehandle == null) { throw new Exception(m_sftp.LastErrorText); } int numBytes = (int)rec_pbsnetdir.Size; if (numBytes < 0) { throw new Exception(m_sftp.LastErrorText); } byte[] b_data = null; b_data = m_sftp.ReadFileBytes(handle, numBytes); if (b_data == null) { throw new Exception(m_sftp.LastErrorText); } sendAttachedFile(rec_pbsnetdir.Filename, b_data, false); char[] c_data = System.Text.Encoding.GetEncoding("windows-1252").GetString(b_data).ToCharArray(); string filecontens = new string(c_data); string filecontens2 = filecontens.TrimEnd('\n'); string filecontens3 = filecontens2.TrimEnd('\r'); string filecontens4 = filecontens3.TrimEnd('\n'); XElement xmlPbsfilesAdd = new XElement("Pbsfiles"); xmlPbsfilesAdd.Add(new XElement("Type", rec_pbsnetdir.Type)); xmlPbsfilesAdd.Add(new XElement("Path", rec_pbsnetdir.Path)); xmlPbsfilesAdd.Add(new XElement("Filename", rec_pbsnetdir.Filename)); xmlPbsfilesAdd.Add(new XElement("Size", rec_pbsnetdir.Size)); xmlPbsfilesAdd.Add(new XElement("Atime", rec_pbsnetdir.Atime)); xmlPbsfilesAdd.Add(new XElement("Mtime", rec_pbsnetdir.Mtime)); xmlPbsfilesAdd.Add(new XElement("Transmittime", DateTime.Now)); xmlPbsfilesAdd.Add(new XElement("Data", filecontens4)); string strxmlPbsfilesAdd = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xmlPbsfilesAdd.ToString(); Guid id1 = clsSQLite.insertStoreXML(Program.AppEngName, false, Program.sftpName, strxmlPbsfilesAdd, ""); clsRest objRest = new clsRest(); string strxmldata = objRest.HttpPost2(clsRest.urlBaseType.data, "frapbs", strxmlPbsfilesAdd); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status == "True") { clsSQLite.updateStoreXML(id1, true); } // Close the file. success = m_sftp.CloseHandle(filehandle); if (success != true) { throw new Exception(m_sftp.LastErrorText); } } } return(AntalFiler); }
public bool WriteTilSFtp(XDocument xdoc) { Guid id1 = clsSQLite.insertStoreXML(Program.sftpName, false, Program.AppEngName, xdoc.ToString(), ""); m_SendqueueId = xdoc.Descendants("Sendqueue").Descendants("Id").First().Value; m_PbsfileId = xdoc.Descendants("Pbsfile").Descendants("Id").First().Value; m_TilPBSFilename = xdoc.Descendants("Pbsfile").Descendants("TilPBSFilename").First().Value; m_Transmisionsdato = DateTime.Parse(xdoc.Descendants("Pbsfile").Descendants("Transmisionsdato").First().Value); m_SendData = xdoc.Descendants("Pbsfile").Descendants("SendData").First().Value; bool success; string TilPBSFilename = m_TilPBSFilename; string TilPBSFile = m_SendData; char[] c_TilPBSFile = TilPBSFile.ToCharArray(); byte[] b_TilPBSFile = System.Text.Encoding.GetEncoding("windows-1252").GetBytes(c_TilPBSFile); int FilesSize = b_TilPBSFile.Length; sendAttachedFile(TilPBSFilename, b_TilPBSFile, true); string fullpath = m_Inbound + "/" + TilPBSFilename; string handle = m_sftp.OpenFile(fullpath, "writeOnly", "createTruncate"); if (handle == null) { throw new Exception(m_sftp.LastErrorText); } success = m_sftp.WriteFileBytes(handle, b_TilPBSFile); if (!success) { throw new Exception(m_sftp.LastErrorText); } success = m_sftp.CloseHandle(handle); if (success != true) { throw new Exception(m_sftp.LastErrorText); } clsSQLite.updateStoreXML(id1, true); XElement xmlPbsfilesUpdate = new XElement("Pbsfiles"); xmlPbsfilesUpdate.Add(new XElement("SendqueueId", m_SendqueueId)); xmlPbsfilesUpdate.Add(new XElement("Id", m_PbsfileId)); xmlPbsfilesUpdate.Add(new XElement("Type", 8)); xmlPbsfilesUpdate.Add(new XElement("Path", m_Inbound)); xmlPbsfilesUpdate.Add(new XElement("Filename", TilPBSFilename)); xmlPbsfilesUpdate.Add(new XElement("Size", FilesSize)); xmlPbsfilesUpdate.Add(new XElement("Atime", DateTime.Now)); xmlPbsfilesUpdate.Add(new XElement("Mtime", DateTime.Now)); xmlPbsfilesUpdate.Add(new XElement("Transmittime", m_Transmisionsdato)); string strxmlPbsfilesUpdate = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + xmlPbsfilesUpdate.ToString();; Guid id2 = clsSQLite.insertStoreXML(Program.AppEngName, false, Program.sftpName, strxmlPbsfilesUpdate, ""); clsRest objRest = new clsRest(); string strxmldata = objRest.HttpPost2(clsRest.urlBaseType.data, "tilpbs", strxmlPbsfilesUpdate); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status == "True") { clsSQLite.updateStoreXML(id2, true); return(true); } else { return(false); } }
public int BogforIndBetalinger() { clsRest objRest = new clsRest(); string strxmldata = objRest.HttpGet2(clsRest.urlBaseType.data, "bogforindbetalinger"); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status != "True") { int saveBetid = 0; var qry_bet = from h in xmldata.Descendants("BogforIndBetalinger") select new { Frapbsid = clsPassXmlDoc.attr_val_int(h, "Frapbsid"), Betid = (int)clsPassXmlDoc.attr_val_int(h, "Betid"), Fakid = clsPassXmlDoc.attr_val_int(h, "Fakid"), Betlinid = clsPassXmlDoc.attr_val_int(h, "Betlinid"), Nr = clsPassXmlDoc.attr_val_int(h, "Nr"), Leverancespecifikation = clsPassXmlDoc.attr_val_string(h, "Leverancespecifikation"), GruppeIndbetalingsbelob = (decimal)clsPassXmlDoc.attr_val_double(h, "GruppeIndbetalingsbelob"), Betalingsdato = clsPassXmlDoc.attr_val_date(h, "Betalingsdato"), Indbetalingsdato = clsPassXmlDoc.attr_val_date(h, "Indbetalingsdato"), Indbetalingsbelob = (decimal)clsPassXmlDoc.attr_val_double(h, "Indbetalingsbelob"), SFakID = (int)clsPassXmlDoc.attr_val_int(h, "SFakID"), SFaknr = clsPassXmlDoc.attr_val_int(h, "SFaknr"), }; var bogf = from s in Program.karFakturaer_s //where s.saldo != 0 join f in qry_bet on s.fakid equals f.SFakID where f.SFaknr != null join m in Program.karMedlemmer on f.Nr equals m.Nr orderby f.Frapbsid, f.Betid, f.Betlinid select new { f.Frapbsid, f.Leverancespecifikation, f.Betid, f.GruppeIndbetalingsbelob, f.Betlinid, f.Fakid, f.Betalingsdato, f.Indbetalingsdato, m.Navn, f.Indbetalingsbelob, f.SFaknr }; int AntalBetalinger = bogf.Count(); if (bogf.Count() > 0) { DateTime nu = DateTime.Now; DateTime ToDay = new DateTime(nu.Year, nu.Month, nu.Day);; int BS1_SidsteNr = 0; try { recStatus rec_Status = (from s in Program.karStatus where s.key == "BS1_SidsteNr" select s).First(); BS1_SidsteNr = int.Parse(rec_Status.value); } catch (System.InvalidOperationException) { } Program.karKladde = null; XElement SummabogfortUpdatexml = new XElement("SummabogfortUpdate"); foreach (var b in bogf) { if (saveBetid != b.Betid) // ny gruppe { saveBetid = b.Betid; recKladde gkl = new recKladde { Dato = ToDay, //(b.Betalingsdato > b.Indbetalingsdato) ? (DateTime)b.Betalingsdato : (DateTime)b.Indbetalingsdato, Bilag = ++BS1_SidsteNr, Tekst = "Indbetalingskort K 81131945-" + ((DateTime)b.Indbetalingsdato).Day + "." + ((DateTime)b.Indbetalingsdato).Month, Afstemningskonto = "Bank", Belob = b.GruppeIndbetalingsbelob, Kontonr = null, Faknr = null }; Program.karKladde.Add(gkl); XElement betxml = new XElement("Bet"); betxml.Add(new XElement("Id", b.Betid)); betxml.Add(new XElement("Summabogfort", true)); SummabogfortUpdatexml.Add(new XElement(betxml)); } recKladde kl = new recKladde { Dato = ToDay, //(b.Betalingsdato > b.Indbetalingsdato) ? (DateTime)b.Betalingsdato : (DateTime)b.Indbetalingsdato, Bilag = BS1_SidsteNr, Tekst = "F" + b.SFaknr + " " + b.Navn, Afstemningskonto = null, Belob = b.Indbetalingsbelob, Kontonr = 56100, Faknr = b.SFaknr }; Program.karKladde.Add(kl); } string strSummabogfortUpdatexml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + SummabogfortUpdatexml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "bogforindbetalinger", strSummabogfortUpdatexml); Program.karStatus.save(); Program.karKladde.save(); } return(AntalBetalinger); } return(0); }
public int Order2Summa() { var rec_regnskab = Program.qryAktivRegnskab(); if (rec_regnskab.Afsluttet == true) { return(0); } DateTime?Startdato = rec_regnskab.Start; DateTime?Slutdato = rec_regnskab.S**t; if (rec_regnskab.DatoLaas != null) { if (rec_regnskab.DatoLaas > Startdato) { Startdato = rec_regnskab.DatoLaas; } } int AntalOrdre = 0; clsRest objRest = new clsRest(); string strxmldata = objRest.HttpGet2(clsRest.urlBaseType.data, "order2summa"); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status != "True") { return(AntalOrdre); } var qry_ord = from forslag in xmldata.Descendants("Fak") select forslag; AntalOrdre = qry_ord.Count(); if (AntalOrdre > 0) { DateTime nu = DateTime.Now; DateTime ToDay = new DateTime(nu.Year, nu.Month, nu.Day);; int SidsteSFakID; int SidsteRec_no; try { SidsteSFakID = (from f in Program.karFakturaer_s select f.fakid).Max(); } catch (System.InvalidOperationException) { SidsteSFakID = 0; } try { SidsteRec_no = (from f in Program.karFakturaer_s select f.rec_no).Max(); } catch (System.InvalidOperationException) { SidsteRec_no = 0; } Program.karFakturastr_s = null; Program.karFakturavarer_s = null; XElement SFakIDupdatexml = new XElement("SFakIDupdate"); foreach (var o in qry_ord) { string Key = o.Descendants("Key").First().Value; string strval = o.Descendants("Id").First().Value; int Id = int.Parse(strval); strval = o.Descendants("Nr").First().Value; int Nr = int.Parse(strval); strval = o.Descendants("Advisbelob").First().Value; double Advisbelob = double.Parse(strval.Replace('.', ',')); strval = o.Descendants("Pbsfaknr").First().Value; int Pbsfaknr = int.Parse(strval); strval = o.Descendants("Vnr").First().Value; int Vnr = int.Parse(strval); strval = o.Descendants("Bogfkonto").First().Value; int Bogfkonto = int.Parse(strval); SidsteSFakID++; SidsteRec_no++; int orebelob = (int)Advisbelob * 100; ordtype_s ord = new ordtype_s ( SidsteSFakID, //fakid ToDay, //(o.Betalingsdato > o.Indbetalingsdato) ? (DateTime)o.Betalingsdato : (DateTime)o.Indbetalingsdato, //dato ToDay, //(DateTime)o.Betalingsdato, //forfaldsdato orebelob, //fakbeløb i øre (int)Nr2Debktonr(Nr) //debitornr ); recFakturaer_s rec = new recFakturaer_s { rec_no = SidsteRec_no, rec_data = ord }; Program.karFakturaer_s.Add(rec); var m_rec = (from m in Program.karMedlemmer where m.Nr == Nr select m).First(); recFakturastr_s rec_Fakturastr_s = new recFakturastr_s { Fakid = SidsteSFakID.ToString(), Navn = m_rec.Navn, Adresse = m_rec.Adresse, Postnr = m_rec.Postnr, Bynavn = m_rec.Bynavn, Faknr = (int)Pbsfaknr, Email = m_rec.Email }; Program.karFakturastr_s.Add(rec_Fakturastr_s); recFakturavarer_s rec_Fakturavarer_s = new recFakturavarer_s { Fakid = SidsteSFakID.ToString(), Varenr = (int)Vnr, VareTekst = "Puls 3060 kontingent", Bogfkonto = (int)Bogfkonto, Antal = 1, Fakturabelob = (double)Advisbelob }; Program.karFakturavarer_s.Add(rec_Fakturavarer_s); try { XElement fakxml = new XElement("Fak"); fakxml.Add(new XElement("Key", Key)); fakxml.Add(new XElement("Id", Id)); fakxml.Add(new XElement("SFakID", SidsteSFakID)); SFakIDupdatexml.Add(new XElement(fakxml)); } catch (System.InvalidOperationException) { throw; } } string strSFakIDupdatexml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + SFakIDupdatexml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "order2summa", strSFakIDupdatexml); Program.karFakturaer_s.save(); Program.karFakturastr_s.save(); Program.karFakturavarer_s.save(); try { recStatus rec_Status = (from s in Program.karStatus where s.key == "SidsteSFakID" select s).First(); rec_Status.value = SidsteSFakID.ToString(); } catch (System.InvalidOperationException) { recStatus rec_Status = new recStatus { key = "SidsteSFakID", value = SidsteSFakID.ToString() }; Program.karStatus.Add(rec_Status); } Program.karStatus.save(); } return(AntalOrdre); }
private void cmdRykkere_Click(object sender, EventArgs e) { string TilPBSFilename; int imax; string keyval; int faknr; double advisbelob; if ((this.cmdRykkere.Text == "Afslut")) { this.Close(); } this.cmdForslag.Visible = false; this.cmdCancel.Visible = false; imax = lvwRykker.Items.Count; this.pgmRykker.Maximum = (imax * 4); this.pgmRykker.Minimum = 0; this.pgmRykker.Value = 0; this.pgmRykker.Visible = true; if ((imax == 0)) { this.Label_Rykkertekst.Text = "Der ikke noget at rykkere"; this.Label_Rykkertekst.Visible = true; } else { XElement headxml = new XElement("TempRykkerforslag"); headxml.Add(new XElement("Betalingsdato", clsUtil.bankdageplus(DateTime.Today, 5))); headxml.Add(new XElement("Bsh", this.DelsystemBSH.Checked)); var i = 0; foreach (ListViewItem lvi in lvwRykker.Items) { this.pgmRykker.Value = ++i; keyval = lvi.Name; advisbelob = double.Parse(lvi.SubItems[5].Text); faknr = int.Parse(lvi.SubItems[6].Text); XElement linxml = new XElement("TempRykkerforslaglinie"); linxml.Add(new XElement("Nr", int.Parse(keyval))); linxml.Add(new XElement("Advisbelob", (decimal)advisbelob)); linxml.Add(new XElement("Faknr", faknr)); headxml.Add(new XElement(linxml)); } clsRest objRest = new clsRest(); string strheadxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + headxml.ToString(); string strxmldata = objRest.HttpPost2(clsRest.urlBaseType.data, "pbs601", strheadxml); XDocument xmldata = XDocument.Parse(strxmldata); string Status = xmldata.Descendants("Status").First().Value; if (Status == "True") { if (this.DelsystemBSH.Checked) //RYKKERE med Indbetalingskort { //objPbs601.faktura_og_rykker_601_action(m_lobnr, fakType.fdrykker); //this.pgmRykker.Value = (imax * 3); //clsSFTP objSFTP = new clsSFTP(); //objSFTP.WriteTilSFtp(m_lobnr); //objSFTP.DisconnectSFtp(); //objSFTP = null; } else //RYKKERE som emails { var qry_email = from rykkeremail in xmldata.Descendants("RykkerEmail") select new { Navn = clsPassXmlDoc.attr_val_string(rykkeremail, "Navn"), Email = clsPassXmlDoc.attr_val_string(rykkeremail, "Email"), Emne = clsPassXmlDoc.attr_val_string(rykkeremail, "Emne"), Tekst = clsPassXmlDoc.attr_val_string(rykkeremail, "Tekst"), }; foreach (var rykkeremail in qry_email) { sendRykkerEmail(rykkeremail.Navn, rykkeremail.Email, rykkeremail.Emne, rykkeremail.Tekst); } } this.pgmRykker.Value = (imax * 3); } } this.pgmRykker.Value = (imax * 4); cmdRykkere.Text = "Afslut"; TilPBSFilename = "PBSNotFound.lst"; this.Label_Rykkertekst.Text = ("Leverance til PBS er gemt i filen " + TilPBSFilename); this.Label_Rykkertekst.Visible = true; this.pgmRykker.Visible = false; }
public void overfoersel_mail(int lobnr) { Chilkat.MailMan mailman = new Chilkat.MailMan(); bool success; success = mailman.UnlockComponent("HAFSJOMAILQ_9QYSMgP0oR1h"); if (success != true) { throw new Exception(mailman.LastErrorText); } // Use the GMail SMTP server mailman.SmtpHost = Program.Smtphost; mailman.SmtpPort = int.Parse(Program.Smtpport); mailman.SmtpSsl = bool.Parse(Program.Smtpssl); // Set the SMTP login/password. mailman.SmtpUsername = Program.Smtpuser; mailman.SmtpPassword = Program.Smtppasswd; XElement headxml = new XElement("OverforselMail"); headxml.Add(new XElement("Lobnr", lobnr)); clsRest objRest = new clsRest(); string strheadxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + headxml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "overforselmail", strheadxml); XDocument xmldata = XDocument.Parse(result); string Status = xmldata.Descendants("Status").First().Value; if (Status == "True") { var qry_email = from overforselemail in xmldata.Descendants("OverforselEmail") select new { Navn = clsPassXmlDoc.attr_val_string(overforselemail, "Navn"), Email = clsPassXmlDoc.attr_val_string(overforselemail, "Email"), Tekst = clsPassXmlDoc.attr_val_string(overforselemail, "Tekst"), }; foreach (var msg in qry_email) { // Create a new email object Chilkat.Email email = new Chilkat.Email(); #if (DEBUG) email.Subject = "TEST Bankoverførsel fra Puls 3060: skal sendes til " + Program.MailToName + " " + Program.MailToAddr; email.AddTo(Program.MailToName, Program.MailToAddr); #else email.Subject = "Bankoverførsel fra Puls 3060"; if (msg.Email.Length > 0) { email.AddTo(msg.Navn, msg.Email); email.AddBcc(Program.MailToName, Program.MailToAddr); } else { email.Subject += ": skal sendes til " + msg.Navn; email.AddTo(Program.MailToName, Program.MailToAddr); } #endif email.Body = msg.Tekst; email.From = Program.MailFrom; email.ReplyTo = Program.MailReply; success = mailman.SendEmail(email); if (success != true) { throw new Exception(email.LastErrorText); } } } }
private void cmdBetal_Click(object sender, EventArgs e) { string TilPBSFilename = "Unknown"; int imax; string keyval; int Nr; int faknr; decimal advisbelob; string Bank; if ((this.cmdBetal.Text == "Afslut")) { this.Close(); } this.cmdForslag.Visible = false; this.cmdCancel.Visible = false; imax = lvwKrdFaktura.Items.Count; this.pgmBetal.Maximum = (imax * 4); this.pgmBetal.Minimum = 0; this.pgmBetal.Value = 0; this.pgmBetal.Visible = true; if ((imax == 0)) { this.Label_Betaltekst.Text = "Der ikke noget at betale"; this.Label_Betaltekst.Visible = true; } else { XElement headxml = new XElement("TempBetalforslag"); headxml.Add(new XElement("Betalingsdato", DateTime.Now)); var i = 0; foreach (ListViewItem lvi in lvwKrdFaktura.Items) { this.pgmBetal.Value = ++i; keyval = lvi.Name; Nr = int.Parse(lvi.SubItems[1].Text); faknr = int.Parse(lvi.SubItems[4].Text); advisbelob = decimal.Parse(lvi.SubItems[5].Text); Bank = lvi.SubItems[6].Text; XElement linxml = new XElement("TempBetalforslaglinie"); linxml.Add(new XElement("Nr", Nr)); linxml.Add(new XElement("Fakid", int.Parse(keyval))); linxml.Add(new XElement("Advisbelob", (decimal)advisbelob)); linxml.Add(new XElement("Bankregnr", Bank.Substring(0, 4))); linxml.Add(new XElement("Bankkontonr", Bank.Substring(5, 10))); linxml.Add(new XElement("Faknr", faknr)); headxml.Add(new XElement(linxml)); } clsRest objRest = new clsRest(); string strheadxml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> " + headxml.ToString(); string result = objRest.HttpPost2(clsRest.urlBaseType.data, "overforsel", strheadxml); XDocument xmldata = XDocument.Parse(result); string Status = xmldata.Descendants("Status").First().Value; this.pgmBetal.Value = imax * 2; if (Status == "True") { this.pgmBetal.Value = (imax * 3); int lobnr = int.Parse(xmldata.Descendants("Lobnr").First().Value); int antal = int.Parse(xmldata.Descendants("Antal").First().Value); int sendqueueid = int.Parse(xmldata.Descendants("Sendqueueid").First().Value); string strxmldata = objRest.HttpGet2(clsRest.urlBaseType.data, "tilpbs/" + sendqueueid.ToString()); XDocument xmldata2 = XDocument.Parse(strxmldata); string Status2 = xmldata2.Descendants("Status").First().Value; if (Status2 == "True") { clsSFTP objAppEngSFTP = new clsSFTP(); bool bSendt = objAppEngSFTP.WriteTilSFtp(xmldata2); if (bSendt) { overfoersel_mail(lobnr); } objAppEngSFTP.DisconnectSFtp(); objAppEngSFTP = null; } clsSumma objSumma = new clsSumma(); objSumma.BogforUdBetalinger(lobnr); } this.pgmBetal.Value = (imax * 4); cmdBetal.Text = "Afslut"; this.Label_Betaltekst.Text = ("Leverance til PBS i filen " + TilPBSFilename); this.Label_Betaltekst.Visible = true; this.pgmBetal.Visible = false; } }