示例#1
0
        public KarBankkontoudtogDanskebank(dbData3060DataContext p_dbData3060, CrudAPI p_api, int bankkontoid, action act)
        {
            m_bankkontoid = bankkontoid;
            m_dbData3060  = p_dbData3060;
            m_api         = p_api;
            string csvfile;

            if (act == action.import)
            {
                try
                {
                    csvfile = (from w in p_dbData3060.tblkontoudtogs where w.pid == m_bankkontoid select w).First().savefile;
                    csvfile = Environment.ExpandEnvironmentVariables(csvfile);
                }
                catch
                {
                    csvfile = "NoFile";
                }
                m_path = csvfile;
                open();
            }
            if (act == action.export)
            {
                export();
            }
        }
示例#2
0
        private void BeregnKontingent(dbData3060DataContext p_dbData3060, DateTime startdato)
        {
            decimal  kont = 0;
            DateTime KontingentFradato = startdato;
            DateTime KontingentTildato = KontingentFradato.AddYears(1).AddDays(-1);

            var qry1 = from k in p_dbData3060.tblKontingents
                       where k.startdato.Date >= KontingentFradato.Date || k.slutdato.Date >= KontingentFradato.Date
                       orderby k.startdato
                       select k;

            int antal = qry1.Count();

            int n = 1;

            foreach (var k in qry1)
            {
                if (n == 1)
                {
                    kont += k.aarskontingent;
                }
                n++;
            }
            this.Kontingent        = kont;
            this.KontingentTildato = KontingentTildato;
        }
示例#3
0
        public void readaftale042(dbData3060DataContext p_dbData3060, string sektion, string transkode, string rec)
        {
            // --  pbssektionnr
            // --  pbstranskode
            // - transkode 0230, aktiv aftale
            // - transkode 0231, tilgang af ny betalingsaftale
            // - transkode 0232, aftale afmeldt af pengeinstitut
            // - transkode 0233, aftale afmeldt af kreditor
            // - transkode 0234, aftale afmeldt af betalingsservice
            m_rec_aftalelin = new tblaftalelin
            {
                pbssektionnr = sektion,
                pbstranskode = transkode
            };

            //  Medlem Nr
            try
            {
                m_rec_aftalelin.Nr = int.Parse(rec.Substring(33, 7));
            }
            catch
            {
                m_rec_aftalelin.Nr = 0;
            }
            //  debitorkonto
            m_rec_aftalelin.debitorkonto = rec.Substring(25, 15);

            //  debgrpnr
            m_rec_aftalelin.debgrpnr = rec.Substring(20, 5);

            //  aftalenr
            m_rec_aftalelin.aftalenr = int.Parse(rec.Substring(40, 9));

            //  aftalestartdato
            if (rec.Substring(49, 6) != "000000")
            {
                m_rec_aftalelin.aftalestartdato = DateTime.Parse("20" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
            }
            else
            {
                m_rec_aftalelin.aftalestartdato = null;
            };

            //  aftaleslutdato
            if (rec.Substring(55, 6) != "000000")
            {
                m_rec_aftalelin.aftaleslutdato = DateTime.Parse("20" + rec.Substring(59, 2) + "-" + rec.Substring(57, 2) + "-" + rec.Substring(55, 2));
            }
            else
            {
                m_rec_aftalelin.aftaleslutdato = null;
            };

            if ((from h in p_dbData3060.tblMedlems where h.Nr == m_rec_aftalelin.Nr select h).Count() == 1)
            {
                // Add tblaftalelin
                m_rec_frapbs.tblaftalelins.Add(m_rec_aftalelin);
            }
        }
示例#4
0
        public Tuple <int, int> kreditor_fakturer_os1(dbData3060DataContext p_dbData3060)
        {
            int    lobnr;
            string wadvistekst;
            int    wantalfakturaer;

            wantalfakturaer = 0;

            tbltilpb rec_tilpbs = new tbltilpb
            {
                delsystem     = "OS1",
                leverancetype = null,
                udtrukket     = DateTime.Now
            };

            p_dbData3060.tbltilpbs.InsertOnSubmit(rec_tilpbs);
            p_dbData3060.SubmitChanges();
            lobnr = rec_tilpbs.id;

            var rstmedlems = from l in p_dbData3060.tempBetalforslaglinies
                             join h in p_dbData3060.tempBetalforslags on l.Betalforslagid equals h.id
                             select new
            {
                l.Nr,
                l.Navn,
                l.Kaldenavn,
                l.Email,
                h.betalingsdato,
                l.advisbelob,
                l.fakid,
                l.bankregnr,
                l.bankkontonr,
                l.faknr,
            };

            foreach (var rstmedlem in rstmedlems)
            {
                wadvistekst = "Puls3060-" + rstmedlem.faknr;
                tbloverforsel rec_krdfak = new tbloverforsel
                {
                    Nr            = rstmedlem.Nr,
                    Navn          = rstmedlem.Navn,
                    Kaldenavn     = rstmedlem.Kaldenavn,
                    Email         = rstmedlem.Email,
                    advistekst    = wadvistekst,
                    advisbelob    = rstmedlem.advisbelob,
                    SFakID        = rstmedlem.fakid,
                    SFaknr        = rstmedlem.faknr,
                    bankregnr     = rstmedlem.bankregnr,
                    bankkontonr   = rstmedlem.bankkontonr,
                    betalingsdato = clsOverfoersel.bankdageplus(rstmedlem.betalingsdato, 0)
                };
                rec_tilpbs.tbloverforsels.Add(rec_krdfak);
                wantalfakturaer++;
            }
            p_dbData3060.SubmitChanges();
            return(new Tuple <int, int>(wantalfakturaer, lobnr));
        }
示例#5
0
        public int OpdateringAfSlettet_rsmembership_transaction(int p_trans_id, dbData3060DataContext p_dbData3060)
        {
            int out_trans_id = p_trans_id;
            puls3060_dkEntities dbPuls3060_dk = new puls3060_dkEntities();

            var qry1 = from s1 in dbPuls3060_dk.ecpwt_rsmembership_transactions where s1.id == p_trans_id select s1;
            int c1   = qry1.Count();

            if (c1 == 0)
            {
                var qry2 = from s2 in p_dbData3060.tblrsmembership_transactions where s2.trans_id == p_trans_id select s2;
                try
                {
                    tblrsmembership_transaction t2 = qry2.First();
                    int?subscriber_id = t2.subscriber_id;
                    var qry3          = from s3 in dbPuls3060_dk.ecpwt_rsmembership_membership_subscribers where s3.id == subscriber_id select s3;
                    int c3            = qry3.Count();
                    if (c3 == 1)
                    {
                        ecpwt_rsmembership_transactions t1 = new ecpwt_rsmembership_transactions
                        {
                            user_id      = t2.user_id,
                            user_email   = t2.user_email,
                            user_data    = t2.user_data,
                            type         = t2.type,
                            @params      = t2.@params,
                            date         = t2.date,
                            ip           = t2.ip,
                            price        = t2.price,
                            coupon       = t2.coupon,
                            currency     = t2.currency,
                            hash         = t2.hash,
                            custom       = t2.custom,
                            gateway      = t2.gateway,
                            status       = t2.status,
                            response_log = t2.response_log
                        };
                        dbPuls3060_dk.ecpwt_rsmembership_transactions.Add(t1);
                        dbPuls3060_dk.SaveChanges();

                        ecpwt_rsmembership_transactions rec_trans = (from t in dbPuls3060_dk.ecpwt_rsmembership_transactions where t.custom == t2.custom select t).First();
                        out_trans_id = rec_trans.id;
                    }
                    else
                    {
                        out_trans_id = 0;
                    }
                }
                catch
                {
                    out_trans_id = 0;
                }
            }
            return(out_trans_id);
        }
示例#6
0
        public string AddPbcnetRecords(dbData3060DataContext p_dbData3060, string delsystem, int leveranceid, int pbsfilesid)
        {
            int      antal;
            int      pbcnetrecords;
            DateTime transmisionsdato;
            int      idlev;
            string   filename;
            string   rec;

            pbcnetrecords = (from h in p_dbData3060.tblpbsfiles
                             where h.pbsfilesid == pbsfilesid & (h.seqnr == 0 | h.seqnr == 9999)
                             select h).Count();

            if (pbcnetrecords == 0)
            {
                // Find antal records
                antal = (from h in p_dbData3060.tblpbsfiles
                         where h.pbsfilesid == pbsfilesid & h.seqnr != 0 & h.seqnr != 9999
                         select h).Count();
                transmisionsdato = DateTime.Now;

                idlev = (int)(from r in p_dbData3060.nextval("idlev") select r.id).First();

                tblpbsfilename rec_pbsfiles = (from h in p_dbData3060.tblpbsfilenames where h.id == pbsfilesid select h).First();

                rec = write00(delsystem, transmisionsdato, idlev, leveranceid);
                tblpbsfile rec_pbsfile = new tblpbsfile {
                    seqnr = 0, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                rec         = write90(delsystem, transmisionsdato, idlev, leveranceid, antal);
                rec_pbsfile = new tblpbsfile {
                    seqnr = 9999, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                p_dbData3060.SubmitChanges();

                filename  = "D";
                filename += lpad(String.Format("{0:yyMMdd}", transmisionsdato), 6, '?');
                filename += lpad(idlev, 2, '0');
                filename += ".";
                filename += rpad(delsystem, 3, '_');
            }
            else
            {
                filename = "Unknown";
            }

            return(filename);
        }
示例#7
0
        public clsKontingent(dbData3060DataContext p_dbData3060, DateTime startdato, int?Nr)
        {
            DateTime?fodtdato;

            try
            {
                fodtdato = (from m in p_dbData3060.tblMedlems where m.Nr == Nr select m.FodtDato).First();
            }
            catch
            {
                fodtdato = null;
            }
            this.BeregnKontingent(p_dbData3060, startdato, fodtdato);
        }
示例#8
0
        public clsUniconta(dbData3060DataContext p_dbData3060, CrudAPI api)
        {
            m_dbData3060 = p_dbData3060;
            m_api        = api;
            var task = api.Query <CompanyFinanceYear>();

            task.Wait();
            var cols = task.Result;

            foreach (var col in cols)
            {
                if (col._Current)
                {
                    m_CurrentCompanyFinanceYear = col;
                }
            }
        }
示例#9
0
 private static void getPuls3060Medlem(string dbConnectionString)
 {
     m_statusdata.bdbPuls3060Medlem_Online = false;
     try
     {
         dbData3060DataContext m_dbData3060 = new dbData3060DataContext(dbConnectionString);
         var qry   = from b in m_dbData3060.tblbankkontos select b;
         int antal = qry.Count();
         m_statusdata.bdbPuls3060Medlem_Online = true;
         Program.Log("Medlem3060Service getPuls3060Medlem() OK");
     }
     catch
     {
         m_statusdata.bdbPuls3060Medlem_Online = false;
         Program.Log("Medlem3060Service getPuls3060Medlem() ERROR");
     }
 }
示例#10
0
        public void sendAttachedFile(dbData3060DataContext p_dbData3060, string filename, byte[] data, bool bTilPBS)
        {
            string local_filename = filename.Replace('.', '_') + ".txt";

            string SmtpUsername = p_dbData3060.GetSysinfo("SMTPUSER");
            string SmtpPassword = p_dbData3060.GetSysinfo("SMTPPASSWD");
            var    smtp         = new SmtpClient
            {
                Host                  = p_dbData3060.GetSysinfo("SMTPHOST"),
                Port                  = int.Parse(p_dbData3060.GetSysinfo("SMTPPORT")),
                EnableSsl             = bool.Parse(p_dbData3060.GetSysinfo("SMTPSSL")),
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(SmtpUsername, SmtpPassword)
            };

            MailMessage email = new MailMessage();

            if (bTilPBS)
            {
#if (DEBUG)
                email.Subject = "Test Til PBS: " + local_filename;
                email.Body    = "Test Til PBS: " + local_filename;
#else
                email.Subject = "Til PBS: " + local_filename;
                email.Body    = "Til PBS: " + local_filename;
#endif
            }
            else
            {
#if (DEBUG)
                email.Subject = "Test Fra PBS: " + local_filename;
                email.Body    = "Test Fra PBS: " + local_filename;
#else
                email.Subject = "Fra PBS: " + local_filename;
                email.Body    = "Fra PBS: " + local_filename;
#endif
            }

            email.To.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILTOADDR"), p_dbData3060.GetSysinfo("MAILTONAME")));
            email.From = new MailAddress(p_dbData3060.GetSysinfo("MAILFROM"));
            email.ReplyToList.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILREPLY")));
            email.Attachments.Add(new Attachment(new MemoryStream(data), local_filename, "text/plain"));
            smtp.Send(email);
        }
示例#11
0
        public clsSFTP(string dbConnectionString)
        {
            m_dbData3060 = new dbData3060DataContext(dbConnectionString);
#if (DEBUG)
            //m_rec_sftp = (from s in m_dbData3060.tblsftps where s.navn == "TestHD36" select s).First();
            m_rec_sftp = (from s in m_dbData3060.tblsftps where s.navn == "Test" select s).First();
            //m_rec_sftp = (from s in m_dbData3060.tblsftps where s.navn == "Produktion" select s).First();
#else
            m_rec_sftp = (from s in m_dbData3060.tblsftps where s.navn == "Test" select s).First();
            //m_rec_sftp = (from s in m_dbData3060.tblsftps where s.navn == "Produktion" select s).First();
#endif

            byte[]         bPK = Encoding.UTF8.GetBytes(m_rec_sftp.certificate);
            MemoryStream   mPK = new MemoryStream(bPK);
            PrivateKeyFile PK  = new PrivateKeyFile(mPK, m_rec_sftp.pincode);
            m_sftp = new SftpClient(m_rec_sftp.host, int.Parse(m_rec_sftp.port), m_rec_sftp.user, PK);
            m_sftp.Connect();
        }
示例#12
0
        public clsSFTP(dbData3060DataContext p_dbData3060)
        {
#if (DEBUG)
            m_rec_sftp = (from s in p_dbData3060.tblsftps where s.navn == "TestHD36" select s).First();
            //m_rec_sftp = (from s in p_dbData3060.tblsftps where s.navn == "Test" select s).First();
            //m_rec_sftp = (from s in p_dbData3060.tblsftps where s.navn == "Produktion" select s).First();
#else
            //m_rec_sftp = (from s in p_dbData3060.tblsftps where s.navn == "Test" select s).First();
            m_rec_sftp = (from s in p_dbData3060.tblsftps where s.navn == "Produktion" select s).First();
#endif
            Program.Log(string.Format("host={0}, port={1}, user={2}", m_rec_sftp.host, int.Parse(m_rec_sftp.port), m_rec_sftp.user), "SFTP ConnectionString");
            byte[]         bPK = Encoding.UTF8.GetBytes(m_rec_sftp.certificate);
            MemoryStream   mPK = new MemoryStream(bPK);
            PrivateKeyFile PK  = new PrivateKeyFile(mPK, m_rec_sftp.pincode);
            m_sftp = new SftpClient(m_rec_sftp.host, int.Parse(m_rec_sftp.port), m_rec_sftp.user, PK);
            m_sftp.Connect();
            Program.Log("SFTP Connected");
        }
示例#13
0
        public string getinfotekst(dbData3060DataContext dbData3060)
        {
            string[] crlf     = { "\r\n" };
            string   infotext = null;

            try { infotext = (from i in dbData3060.tblinfoteksts where i.id == infotekst_id select i).First().msgtext; }
            catch (System.InvalidOperationException) { }

            RegexOptions options    = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
            Regex        regexParam = new Regex(@"(\#\#[^\#]+\#\#)", options);

            string MsgtextSub = "";

            if (infotext != null)
            {
                MsgtextSub = regexParam.Replace(infotext, delegate(Match match)
                {
                    string v = match.ToString();
                    switch (v.ToLower())
                    {
                    case "##navn_medlem##":
                        if (navn_medlem != null)
                        {
                            return(navn_medlem);
                        }
                        break;

                    case "##kaldenavn##":
                        if (kaldenavn != null)
                        {
                            return(kaldenavn);
                        }
                        if (navn_medlem != null)
                        {
                            return(navn_medlem);
                        }
                        break;

                    case "##fradato##":
                        if (fradato != null)
                        {
                            return(string.Format("{0:d. MMMM yyyy}", fradato));
                        }
                        break;

                    case "##tildato##":
                        if (tildato != null)
                        {
                            return(string.Format("{0:d. MMMM yyyy}", tildato));
                        }
                        break;

                    case "##betalingsdato##":
                        if (betalingsdato != null)
                        {
                            return(string.Format("{0:dddd}", betalingsdato) + " den " + string.Format("{0:d. MMMM}", betalingsdato));
                        }
                        break;

                    case "##advisbelob##":
                        if (advisbelob != null)
                        {
                            return(String.Format("{0:###0.00}", advisbelob).Replace('.', ','));
                        }
                        break;

                    case "##ocrstring##":
                        if (ocrstring != null)
                        {
                            return(ocrstring);
                        }
                        break;

                    case "##underskrift_navn##":
                        if (underskrift_navn != null)
                        {
                            return(underskrift_navn);
                        }
                        break;

                    case "##bankkonto##":
                        if (bankkonto != null)
                        {
                            return(bankkonto);
                        }
                        break;

                    case "##advistekst##":
                        if (advistekst != null)
                        {
                            return(advistekst);
                        }
                        break;

                    case "##sendtsom##":
                        if (sendtsom != null)
                        {
                            return(sendtsom);
                        }
                        break;

                    case "##kundenr##":
                        if (sendtsom != null)
                        {
                            return(kundenr);
                        }
                        break;
                    }
                    return(v);
                });

                if (numofcol == null)
                {
                    return(MsgtextSub);
                }
                else
                {
                    return(splittextincolumns(MsgtextSub, (int)numofcol));
                }
            }
            return("");
        }
示例#14
0
        public void readgirokort042(dbData3060DataContext p_dbData3060, string sektion, string transkode, string rec)
        {
            // --  pbssektionnr
            // --  pbstranskode

            decimal belobmun;
            int     belob;

            m_rec_indbetalingskort = new tblindbetalingskort
            {
                pbssektionnr = sektion,
                pbstranskode = transkode
            };

            //  Medlem Nr
            try
            {
                m_rec_indbetalingskort.Nr = int.Parse(rec.Substring(33, 7));
            }
            catch
            {
                m_rec_indbetalingskort.Nr = 0;
            }

            //  debitorkonto
            m_rec_indbetalingskort.debitorkonto = rec.Substring(25, 15);

            //  debgrpnr
            m_rec_indbetalingskort.debgrpnr = rec.Substring(20, 5);

            //  Kortartkode
            m_rec_indbetalingskort.kortartkode = rec.Substring(40, 2);

            //  FI-kreditor
            m_rec_indbetalingskort.fikreditornr = rec.Substring(42, 8);

            //  Indbetalerident
            m_rec_indbetalingskort.indbetalerident = rec.Substring(50, 19);

            //  dato
            if (rec.Substring(55, 6) != "000000")
            {
                m_rec_indbetalingskort.dato = DateTime.Parse("20" + rec.Substring(73, 2) + "-" + rec.Substring(71, 2) + "-" + rec.Substring(69, 2));
            }
            else
            {
                m_rec_indbetalingskort.dato = null;
            };

            //  Beløb
            belob    = int.Parse(rec.Substring(75, 13));
            belobmun = ((decimal)belob) / 100;
            m_rec_indbetalingskort.belob = belobmun;

            //  Faknr
            m_rec_indbetalingskort.faknr = int.Parse(rec.Substring(88, 9));

            if ((from h in p_dbData3060.tblMedlems where h.Nr == m_rec_indbetalingskort.Nr select h).Count() == 1)
            {
                if ((from k in p_dbData3060.tblindbetalingskorts where k.Nr == m_rec_indbetalingskort.Nr && k.indbetalerident == m_rec_indbetalingskort.indbetalerident select k).Count() == 0)
                {
                    // Add tblindbetalingskort
                    m_rec_frapbs.tblindbetalingskorts.Add(m_rec_indbetalingskort);
                }
            }
        }
示例#15
0
        public int aftaleoplysninger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            int      dummy = 0;
            string   rec;
            string   leverance;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;


            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0603" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            int DebugCount = qrypbsfiles.Count();

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                //try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverance = "";
                    sektion   = "";
                    leverancespecifikation = "";


                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        //  Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance Start
                                leverance = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse("20" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            };

                            if (leverance == "0603")
                            {
                                // -- Leverance 0603
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0603",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0603",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                            ;
                        }
                        ;

                        if (leverance == "0603")
                        { //  Leverance 0603
                            //  Bestem Sektions Type
                            if (sektion == "")
                            {
                                if (rec.Substring(0, 5) == "BS012")
                                {  //  Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else
                                {
                                    if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                    {
                                        throw new Exception("243 - Første record er ikke en Sektions start record");
                                    }
                                    ;
                                };
                            }
                            ;

                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance start
                                //  BEHANDL: Leverance start
                                dummy = 1;
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0210")
                            {     //  Sektion 0210 Aktive aftaler
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0210"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0230"))
                                {  //  Aktive aftaler
                                    //  BEHANDL: Aktive aftaler
                                    readaftale042(p_dbData3060, sektion, "0230", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0210"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0212")
                            {     //  Sektion 0212 Til- og afgang af betalingsaftaler
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0212"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0231"))
                                {  //  Tilgang af nye betalingsaftaler
                                    //  BEHANDL: Tilgang af nye betalingsaftaler
                                    readaftale042(p_dbData3060, sektion, "0231", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0232"))
                                {  //  Aftale afmeldt af pengeinstitut
                                    //  BEHANDL: aftale afmeldt af pengeinstitut
                                    readaftale042(p_dbData3060, sektion, "0232", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0233"))
                                {  //  Aftaler afmeldt af kreditor
                                    //  BEHANDL: aftaler afmeldt af kreditor
                                    readaftale042(p_dbData3060, sektion, "0233", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0234"))
                                {  //  Aftaler afmeldt af betalingsservice
                                    //  BEHANDL: aftaler afmeldt af betalingsservice
                                    readaftale042(p_dbData3060, sektion, "0234", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0212"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0214")
                            {     //  Sektion 0214 Forfaldsoplysninger
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0214"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0235"))
                                {  //  Forfald automatisk betaling
                                    //  BEHANDL: Forfald automatisk betaling
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0295"))
                                {  //  Forfald manuel betaling
                                    //  BEHANDL: Forfald manuel betaling
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0214"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0215")
                            {     //  Sektion 0215 Debitornavn/-adresse
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(14 - 1, 4) == "0215"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS022") && (rec.Substring(13, 4) == "0240"))
                                {  //  Navn/adresse på debitor
                                    //  BEHANDL: Navn/adresse på debitor
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(14 - 1, 4) == "0215"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0217")
                            {     //  Sektion 0217 Oplysninger fra indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0217"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0295"))
                                {  //  Oplysninger fra indbetalingskort
                                    //  BEHANDL: Oplysninger fra indbetalingskort
                                    readgirokort042(p_dbData3060, sektion, "0295", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0217"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("248 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0219")
                            {     //  Sektion 0219 Aktive aftaler om Elektronisk Indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0219"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0230"))
                                {  //  Aktiv aftale om Elektronisk Indbetalingskort
                                    //  BEHANDL: Aktiv aftale om Elektronisk Indbetalingskort
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(14 - 1, 4) == "0219"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("249 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (rec.Substring(0, 5) == "BS992")
                            {  //  Leverance s**t
                                //  BEHANDL: Leverance S**t
                                leverance = "";
                            }
                            else
                            {
                                throw new Exception("250 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            };
                        }

                        else
                        {
                            throw new Exception("251 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        };
                    }
                }

                /*
                 * catch (Exception e)
                 * {
                 *  switch (e.Message.Substring(0, 3))
                 *  {
                 *      case "241":   //241 - Første record er ikke en Leverance start record
                 *      case "242":   //242 - Leverancen er indlæst tidligere
                 *      case "243":   //243 - Første record er ikke en Sektions start record
                 *      case "244":   //244 - Record ukendt
                 *      case "245":   //245 - Record ukendt
                 *      case "246":   //246 - Record ukendt
                 *      case "247":   //247 - Record ukendt
                 *      case "248":   //248 - Record ukendt
                 *      case "249":   //249 - Record ukendt
                 *      case "250":   //250 - Record ukendt
                 *      case "251":   //251 - Record ukendt
                 *          AntalFiler--;
                 *          break;
                 *
                 *      default:
                 *          throw;
                 *  }
                 * }
                 */
            }
            if (dummy == 1)
            {
                dummy = 2;
            }
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
示例#16
0
        public string WriteTilSFtp(dbData3060DataContext p_dbData3060, int lobnr)
        {
            string TilPBSFilename = "Unknown";
            int    FilesSize;

            var qry_selectfiles =
                from h in p_dbData3060.tblpbsforsendelses
                join d1 in p_dbData3060.tblpbsfilenames on h.id equals d1.pbsforsendelseid into details1
                from d1 in details1.DefaultIfEmpty()
                where d1.id != null && d1.filename == null
                join d2 in p_dbData3060.tbltilpbs on h.id equals d2.pbsforsendelseid into details2
                from d2 in details2.DefaultIfEmpty()
                where d2.id == lobnr
                select new
            {
                tilpbsid = (int?)d2.id,
                d2.leverancespecifikation,
                d2.delsystem,
                d2.leverancetype,
                Bilagdato        = (DateTime?)d2.bilagdato,
                Pbsforsendelseid = (int?)d2.pbsforsendelseid,
                Udtrukket        = (DateTime?)d2.udtrukket,
                pbsfilesid       = (int?)d1.id,
                Leveranceid      = (int)h.leveranceid
            };

            int antal = qry_selectfiles.Count();

            if (antal > 0)
            {
                var rec_selecfiles = qry_selectfiles.First();

                var qry_pbsfiles = from h in p_dbData3060.tblpbsfilenames
                                   where h.id == rec_selecfiles.pbsfilesid
                                   select h;
                if (qry_pbsfiles.Count() > 0)
                {
                    tblpbsfilename m_rec_pbsfiles = qry_pbsfiles.First();
                    TilPBSFilename = AddPbcnetRecords(p_dbData3060, rec_selecfiles.delsystem, rec_selecfiles.Leveranceid, m_rec_pbsfiles.id);

                    var qry_pbsfile =
                        from h in m_rec_pbsfiles.tblpbsfiles
                        orderby h.seqnr
                        select h;

                    string TilPBSFile = "";
                    int    i          = 0;
                    foreach (var rec_pbsfile in qry_pbsfile)
                    {
                        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);
                    FilesSize = b_TilPBSFile.Length;

                    sendAttachedFile(p_dbData3060, TilPBSFilename, b_TilPBSFile, true);

                    string       fullpath      = m_rec_sftp.inbound + "/" + TilPBSFilename;
                    MemoryStream ms_TilPBSFile = new MemoryStream(b_TilPBSFile);

                    Program.Log(string.Format("Start Upload of {0}", fullpath));
                    m_sftp.UploadFile(ms_TilPBSFile, fullpath);
                    Program.Log(string.Format("{0} Upload Completed", fullpath));

                    m_rec_pbsfiles.type         = 8;
                    m_rec_pbsfiles.path         = m_rec_sftp.inbound;
                    m_rec_pbsfiles.filename     = TilPBSFilename;
                    m_rec_pbsfiles.size         = FilesSize;
                    m_rec_pbsfiles.atime        = DateTime.Now;
                    m_rec_pbsfiles.mtime        = DateTime.Now;
                    m_rec_pbsfiles.transmittime = DateTime.Now;
                    p_dbData3060.SubmitChanges();
                }
            }
            return(TilPBSFilename);
        }
示例#17
0
        public void krdfaktura_overfoersel_action(dbData3060DataContext p_dbData3060, int lobnr)
        {
            string   rec;
            int      seq = 0;
            int      wleveranceid;
            DateTime wdispositionsdato;
            int      whour;
            int      wbankdage;

            // Betalingsoplysninger
            int belobint;

            // Tællere
            int antalos5;        // Antal OS5: Antal foranstående OS5 records
            int belobos5;        // Beløb: Nettobeløb i OS5 records

            int antalsek;        // Antal sektioner i leverancen
            int antalos5tot;     // Antal OS5: Antal foranstående OS5 records
            int belobos5tot;     // Beløb: Nettobeløb i OS5 records

            whour = DateTime.Now.Hour;
            if (whour > 17)
            {
                wbankdage = 3;
            }
            else
            {
                wbankdage = 2;
            }
            wdispositionsdato = clsOverfoersel.bankdageplus(DateTime.Now, wbankdage);

            antalos5 = 0;
            belobos5 = 0;

            antalsek    = 0;
            antalos5tot = 0;
            belobos5tot = 0;



            {
                var antal = (from c in p_dbData3060.tbltilpbs
                             where c.id == lobnr
                             select c).Count();
                if (antal == 0)
                {
                    throw new Exception("101 - Der er ingen PBS forsendelse for id: " + lobnr);
                }
            }
            {
                var antal = (from c in p_dbData3060.tbltilpbs
                             where c.id == lobnr && c.pbsforsendelseid != null
                             select c).Count();
                if (antal > 0)
                {
                    throw new Exception("102 - Pbsforsendelse for id: " + lobnr + " er allerede sendt");
                }
            }
            {
                var antal = (from c in p_dbData3060.tbloverforsels
                             where c.tilpbsid == lobnr
                             select c).Count();
                if (antal == 0)
                {
                    throw new Exception("103 - Der er ingen pbs transaktioner for tilpbsid: " + lobnr);
                }
            }

            var rsttil = (from c in p_dbData3060.tbltilpbs
                          where c.id == lobnr
                          select c).First();

            if (rsttil.udtrukket == null)
            {
                rsttil.udtrukket = DateTime.Now;
            }
            if (rsttil.bilagdato == null)
            {
                rsttil.bilagdato = rsttil.udtrukket;
            }
            if (rsttil.delsystem == null)
            {
                rsttil.delsystem = "OS1";
            }
            if (rsttil.leverancetype != null)
            {
                rsttil.leverancetype = null;
            }
            p_dbData3060.SubmitChanges();


            wleveranceid = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
            tblpbsforsendelse rec_pbsforsendelse = new tblpbsforsendelse
            {
                delsystem     = rsttil.delsystem,
                leverancetype = rsttil.leverancetype,
                oprettetaf    = "Udb",
                oprettet      = DateTime.Now,
                leveranceid   = wleveranceid
            };

            p_dbData3060.tblpbsforsendelses.InsertOnSubmit(rec_pbsforsendelse);
            rec_pbsforsendelse.tbltilpbs.Add(rsttil);

            tblpbsfilename rec_pbsfiles = new tblpbsfilename();

            rec_pbsforsendelse.tblpbsfilenames.Add(rec_pbsfiles);

            tblkreditor krd = (from k in p_dbData3060.tblkreditors
                               where k.delsystem == rsttil.delsystem
                               select k).First();


            // -- Leverance Start - OS1
            // - rstkrd.Datalevnr - Dataleverandørnr.: Dataleverandørens SE-nummer
            // - wleveranceid     - Leveranceidentifikation: Løbenummer efter eget valg
            rec = writeOS1(krd.datalevnr, wleveranceid);
            tblpbsfile rec_pbsfile = new tblpbsfile {
                seqnr = ++seq, data = rec
            };

            rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

            var qrydeb = from h in p_dbData3060.tbloverforsels
                         where h.tilpbsid == lobnr
                         select h;

            // Start loop over betalinger i tbloverforsel
            int testantal = qrydeb.Count();

            foreach (tbloverforsel rec_overfoersel in qrydeb)
            {
                DateTime Betalingsdato = (rec_overfoersel.betalingsdato == null) ? wdispositionsdato : (DateTime)rec_overfoersel.betalingsdato;
                if (Betalingsdato < wdispositionsdato)
                {
                    Betalingsdato = wdispositionsdato;
                }
                rec_overfoersel.betalingsdato = Betalingsdato; //opdater aktuel betalingsdato

                // Sektion start – (OS2)
                antalos5 = 0;
                belobos5 = 0;

                // -- OS2
                // - Betalingsdato  - Dispositionsdato
                // - krd.regnr      - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr    - Kontonr.: Overførselskontonummer
                // - krd.datalevnr  - Dataleverandørnr.: Dataleverandørens SE-nummer
                rec         = writeOS2(Betalingsdato, krd.regnr, krd.kontonr, krd.datalevnr);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                ++antalsek;

                // -- Forfald betaling
                if (rec_overfoersel.advisbelob > 0)
                {
                    belobint    = (int)(rec_overfoersel.advisbelob * ((decimal)100));
                    belobos5    = belobos5 + belobint;
                    belobos5tot = belobos5tot + belobint;
                }
                else
                {
                    belobint = 0;
                }

                // -- OS5
                // - debinfo.bankregnr   - Betalingsmodtager registreringsnummer
                // - debinfo.bankkontonr - Betalingsmodtager kontonummer
                // - belobint            - Beløb: Beløb i øre uden fortegn
                // - Betalingsdato       - Dispositionsdato
                // - krd.regnr           - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr         - Kontonr.: Overførselskontonummer
                // - deb.advistekst      - Tekst på Betalingsmodtagers kontoudtog
                // - deb.SFakID          - Ref til betalingsmodtager til eget brug
                rec         = writeOS5(rec_overfoersel.bankregnr, rec_overfoersel.bankkontonr, belobint, Betalingsdato, krd.regnr, krd.kontonr, rec_overfoersel.advistekst, (int)rec_overfoersel.SFakID);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                antalos5++;
                antalos5tot++;


                // -- Sektion s**t – (OS8)
                // - OS8
                // - antalos5          - Antal 042: Antal foranstående 042 records
                // - belobos5          - Beløb: Nettobeløb i 042 records
                // - Betalingsdato     - Dispositionsdato
                // - krd.regnr         - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr       - Kontonr.: Overførselskontonummer
                // - krd.datalevnr     - Dataleverandørnr.: Dataleverandørens SE-nummer
                rec         = writeOS8(antalos5, belobos5, Betalingsdato, krd.regnr, krd.kontonr, krd.datalevnr);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);
            }

            // -- Leverance s**t - (OS9)

            // --OS9
            // - antalos5tot    - Antal 042: Antal foranstående 042 records
            // - belobos5tot    - Beløb: Nettobeløb i 042 records
            // - krd.datalevnr  - Dataleverandørnr.: Dataleverandørens SE-nummer
            rec         = writeOS9(antalos5tot, belobos5tot, krd.datalevnr);
            rec_pbsfile = new tblpbsfile {
                seqnr = ++seq, data = rec
            };
            rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

            rsttil.udtrukket = DateTime.Now;
            rsttil.leverancespecifikation = wleveranceid.ToString();
            p_dbData3060.SubmitChanges();
        }
示例#18
0
        public int ReadFraSFtp(dbData3060DataContext p_dbData3060)
        {
            m_memPbsnetdir = new MemPbsnetdir(); //opret ny memPbsnetdir

            //  Iterate over the files.
            foreach (SftpFile fileObj in m_sftp.ListDirectory(m_rec_sftp.outbound))
            {
                if (fileObj.Name != "." && fileObj.Name != "..")
                {
                    recPbsnetdir rec = new recPbsnetdir
                    {
                        Type     = 8,
                        Path     = m_rec_sftp.outbound,
                        Filename = fileObj.Name,
                        Size     = (int)fileObj.Length,
                        Atime    = fileObj.LastAccessTime,
                        Mtime    = fileObj.LastWriteTime,
                        Gid      = fileObj.GroupId,
                        Uid      = fileObj.UserId,
                        Perm     = ""
                    };
                    m_memPbsnetdir.Add(rec);
                }
            }

            var leftqry_pbsnetdir =
                from h in m_memPbsnetdir
                //join d1 in p_dbData3060.Tblpbsfiles on new { h.Path, h.Filename } equals new { d1.Path, d1.Filename } into details
                //from d1 in details.DefaultIfEmpty(new Tblpbsfiles { Id = -1, Type = (int?)null, Path = null, Filename = null, Size = (int?)null, Atime = (DateTime?)null, Mtime = (DateTime?)null, Perm = null, Uid = (int?)null, Gid = (int?)null })
                //where d1.Path == null && d1.Filename == null
                select h;

            int AntalFiler = leftqry_pbsnetdir.Count();

            if (leftqry_pbsnetdir.Count() > 0)
            {
                foreach (var rec_pbsnetdir in leftqry_pbsnetdir)
                {
                    tblpbsfilename m_rec_pbsfiles = new tblpbsfilename
                    {
                        type     = rec_pbsnetdir.Type,
                        path     = rec_pbsnetdir.Path,
                        filename = rec_pbsnetdir.Filename,
                        size     = rec_pbsnetdir.Size,
                        atime    = rec_pbsnetdir.Atime,
                        mtime    = rec_pbsnetdir.Mtime,
                        perm     = rec_pbsnetdir.Perm,
                        uid      = rec_pbsnetdir.Uid,
                        gid      = rec_pbsnetdir.Gid
                    };
                    p_dbData3060.tblpbsfilenames.InsertOnSubmit(m_rec_pbsfiles);

                    //***********************************************************************
                    //  Open a file on the server:
                    string fullpath = rec_pbsnetdir.Path + "/" + rec_pbsnetdir.Filename;
                    int    numBytes = (int)rec_pbsnetdir.Size;

                    byte[]       b_data = new byte[numBytes];
                    MemoryStream stream = new MemoryStream(b_data, true);

                    Program.Log(string.Format("Start Download of {0}", fullpath));
                    m_sftp.DownloadFile(fullpath, stream);
                    Program.Log(string.Format("{0} Download Completed", fullpath));

                    sendAttachedFile(p_dbData3060, 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');

                    string[] lines = filecontens4.Split('\n');
                    string   ln    = null;
                    int      seqnr = 0;
                    string   ln0_6;
                    for (int idx = 0; idx < lines.Count(); idx++)
                    {
                        ln = lines[idx].TrimEnd('\r');
                        try { ln0_6 = ln.Substring(0, 6); }
                        catch { ln0_6 = ""; }
                        if (((seqnr == 0) && !(ln0_6 == "PBCNET")) || (seqnr > 0))
                        {
                            seqnr++;
                        }
                        if (ln.Length > 0)
                        {
                            m_rec_pbsfile = new tblpbsfile
                            {
                                seqnr = seqnr,
                                data  = ln
                            };
                            m_rec_pbsfiles.tblpbsfiles.Add(m_rec_pbsfile);
                        }
                    }

                    m_rec_pbsfiles.transmittime = DateTime.Now;
                    var cb = new SqlConnectionStringBuilder(p_dbData3060.Connection.ConnectionString);
                    Program.Log(string.Format("Start Write {0} to SQL Database {1} on {2}", rec_pbsnetdir.Filename, cb.InitialCatalog, cb.DataSource));
                    p_dbData3060.SubmitChanges();
                    Program.Log(string.Format("{0} Write to SQL Database Completed", rec_pbsnetdir.Filename));
                }
            }
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
示例#19
0
        public void readindbetalingskort042(dbData3060DataContext p_dbData3060, string sektion, string transkode, string rec)
        {
            // --  pbssektionnr
            // ---  sektion 0195, indbetalingskort til e-Boks
            // ---  sektion 0196, elektronisk indbetalingskort i netbank
            // ---  sektion 0197, papirindbetalingskort
            // --  pbstranskode

            decimal belobmun;
            int     belob;

            m_rec_indbetalingskort = new tblindbetalingskort
            {
                pbssektionnr = sektion,
                pbstranskode = transkode
            };

            //  Medlem Nr
            try
            {
                m_rec_indbetalingskort.Nr = int.Parse(rec.Substring(35, 7));
            }
            catch
            {
                m_rec_indbetalingskort.Nr = 0;
            }

            //  debitorkonto
            m_rec_indbetalingskort.debitorkonto = rec.Substring(27, 15);

            //  debgrpnr
            m_rec_indbetalingskort.debgrpnr = rec.Substring(22, 5);

            //  Kortartkode
            m_rec_indbetalingskort.kortartkode = rec.Substring(128, 2);

            //  FI-kreditor
            m_rec_indbetalingskort.fikreditornr = rec.Substring(130, 8);

            //  Indbetalerident
            m_rec_indbetalingskort.indbetalerident = "000" + rec.Substring(82, 16);  //Tidligere 19 lang i 217 record

            //  dato
            if (rec.Substring(51, 8) != "00000000")
            {
                m_rec_indbetalingskort.dato = DateTime.Parse(rec.Substring(55, 4) + "-" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2));
            }
            else
            {
                m_rec_indbetalingskort.dato = null;
            };

            //  Beløb
            belob    = int.Parse(rec.Substring(60, 13));
            belobmun = ((decimal)belob) / 100;
            m_rec_indbetalingskort.belob = belobmun;

            //  Faknr
            m_rec_indbetalingskort.faknr = int.Parse(rec.Substring(73, 9));

            //  Netbank regnr
            if (sektion == "0196")
            {
                m_rec_indbetalingskort.regnr = rec.Substring(138, 4);
            }

            if ((from h in p_dbData3060.tblfaks where h.faknr == m_rec_indbetalingskort.faknr select h).Count() == 1)
            {
                if ((from k in p_dbData3060.tblindbetalingskorts where k.Nr == m_rec_indbetalingskort.Nr && k.indbetalerident == m_rec_indbetalingskort.indbetalerident select k).Count() == 0)
                {
                    // Add tblindbetalingskort
                    m_rec_frapbs.tblindbetalingskorts.Add(m_rec_indbetalingskort);
                }
            }
        }
示例#20
0
        public void PbsAutoKontingent(dbData3060DataContext m_dbData3060)
        {
            //DateTime Nu = new DateTime(2016, 7, 10);
            DateTime Nu  = DateTime.Now;
            int      Dag = Nu.Day;

            if (Dag > 12)
            {
                return;
            }

            DateTime Nu_plus_1 = Nu.AddMonths(1);
            DateTime p_DatoKontingentForfald   = new DateTime(Nu_plus_1.Year, Nu_plus_1.Month, 1);
            DateTime p_DatoBetaltKontingentTil = Nu.AddMonths(2);

            puls3060_dkEntities jdbd       = new puls3060_dkEntities();
            clsPbs601           objPbs601d = new clsPbs601();
            List <string[]>     items      = objPbs601d.RSMembership_KontingentForslag(p_DatoBetaltKontingentTil, m_dbData3060);
            int AntalForslag = items.Count();

            if (AntalForslag > 0)
            {
                Program.Log(string.Format("Medlem3060Service {0} begin", "Send Kontingent File til PBS"));
                Memkontingentforslag memKontingentforslag = new Memkontingentforslag();
                foreach (string[] item in items)
                {
                    string   user_id     = item[0];
                    DateTime fradato     = DateTime.Parse(item[4]);
                    double   advisbelob  = double.Parse(item[5]);
                    DateTime tildato     = DateTime.Parse(item[6]);
                    bool     indmeldelse = (item[7] == "J") ? true : false;
                    bool     tilmeldtpbs = (item[8] == "J") ? true : false;

                    recKontingentforslag rec_Kontingentforslag = new recKontingentforslag
                    {
                        betalingsdato = clsOverfoersel.bankdageplus(p_DatoKontingentForfald, 0),
                        bsh           = false,
                        user_id       = int.Parse(user_id),
                        membership_id = 6,
                        advisbelob    = (decimal)advisbelob,
                        fradato       = fradato,
                        tildato       = tildato,
                        indmeldelse   = indmeldelse,
                        tilmeldtpbs   = tilmeldtpbs,
                    };
                    memKontingentforslag.Add(rec_Kontingentforslag);
                }

                Tuple <int, int> tresulte = objPbs601d.rsmembeshhip_kontingent_fakturer_bs1(m_dbData3060, jdbd, memKontingentforslag);
                int AntalFakturaer        = tresulte.Item1;
                int lobnr = tresulte.Item2;
                if ((AntalFakturaer > 0))
                {
                    objPbs601d.faktura_og_rykker_601_action(m_dbData3060, lobnr, fakType.fdrsmembership);
                    clsSFTP objSFTPd = new clsSFTP(m_dbData3060);
                    objSFTPd.WriteTilSFtp(m_dbData3060, lobnr);
                    objSFTPd.DisconnectSFtp();
                    objSFTPd = null;
                }
                Program.Log(string.Format("Medlem3060Service {0} end", "Send Kontingent File til PBS"));
            }
        }
示例#21
0
        public int betalinger_til_rsmembership(dbData3060DataContext p_dbData3060, puls3060_dkEntities p_dbPuls3060_dk)
        {
            int saveBetid = 0;
            var rsmbrshp  = from bl in p_dbData3060.tblbetlins
                            where (bl.pbstranskode == "0236" || bl.pbstranskode == "0297")
                            join b in p_dbData3060.tblbets on bl.betid equals b.id
                            where b.rsmembership == null || b.rsmembership == false
                            join p in p_dbData3060.tblfrapbs on b.frapbsid equals p.id
                            orderby p.id, b.id, bl.id
                select new
            {
                Frapbsid = p.id,
                p.leverancespecifikation,
                Betid    = b.id,
                Betlinid = bl.id,
                bl.betalingsdato,
                bl.indbetalingsdato,
                bl.indbetalingsbelob,
                bl.faknr,
                bl.debitorkonto
            };

            int AntalBetalinger = rsmbrshp.Count();

            Program.Log(string.Format("betalinger_til_rsmembership - AntalBetalinger {0}", AntalBetalinger));
            if (rsmbrshp.Count() > 0)
            {
                clsPbsHelper objPbsHelperd = new clsPbsHelper();
                foreach (var b in rsmbrshp)
                {
                    if (saveBetid != b.Betid) // ny gruppe
                    {
                        saveBetid = b.Betid;
                        var rec_bet = (from ub in p_dbData3060.tblbets where ub.id == b.Betid select ub).First();
                        rec_bet.rsmembership = true;
                    }

                    // Do somthing here
                    var qry = from f in p_dbData3060.tblfaks
                              where f.faknr == b.faknr
                              join m in p_dbData3060.tblrsmembership_transactions on f.id equals m.id
                              select new tblmembershippayment
                    {
                        rsmembership_transactions_id = m.trans_id,
                    };
                    if (qry.Count() == 1)
                    {
                        tblmembershippayment rec_membershippayment = qry.First();
                        //*********************************************************
                        int new_rsmembership_transactions_id = objPbsHelperd.OpdateringAfSlettet_rsmembership_transaction(rec_membershippayment.rsmembership_transactions_id, p_dbData3060);
                        Program.Log(string.Format("betalinger_til_rsmembership - transactions_id {0} --> {1}", rec_membershippayment.rsmembership_transactions_id, p_dbData3060, new_rsmembership_transactions_id));
                        rec_membershippayment.rsmembership_transactions_id = new_rsmembership_transactions_id;
                        //*********************************************************
                        p_dbPuls3060_dk.tblmembershippayments.Add(rec_membershippayment);
                        p_dbPuls3060_dk.SaveChanges();
                        Program.Log(string.Format("betalinger_til_rsmembership - faknr {0} betalt", b.faknr));
                    }
                }
                p_dbData3060.SubmitChanges();
            }
            return(AntalBetalinger);
        }
示例#22
0
        public int betalinger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            string   rec;
            string   leverancetype;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;
            //  wpbsfilesid = 3450  //'--test test
            //  leverancetype = "0602"
            //  sektion = "0211"
            //  rec = "BS0420398564402360000000100000000001231312345678910120310000000012755000000125                         3112031112030000000012755"

            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0602" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverancetype          = "";
                    sektion                = "";
                    leverancespecifikation = "";

                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        // -- Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if ((rec.Substring(0, 5) == "BS002"))
                            {
                                // -- Leverance Start
                                leverancetype          = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse("20" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            }
                            if ((leverancetype == "0602"))
                            {
                                // -- Leverance 0602
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0602",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0602",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                        }
                        if ((leverancetype == "0602"))
                        {
                            // -- Leverance 0602*********
                            // -- Bestem Sektions Type
                            if ((sektion == ""))
                            {
                                if ((rec.Substring(0, 5) == "BS012"))
                                {
                                    // -- Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                {
                                    throw new Exception("243 - Første record er ikke en Sektions start record");
                                }
                            }
                            if ((rec.Substring(0, 5) == "BS002"))
                            {
                                // -- Leverance start
                                // -- BEHANDL: Leverance start
                            }
                            else if ((sektion == "0211"))
                            {
                                // -- Sektion 0211 Betalingsinformation
                                if (((rec.Substring(0, 5) == "BS012") &&
                                     (rec.Substring(13, 4) == "0211")))
                                {
                                    // -- Sektion Start
                                    // -- BEHANDL: Sektion Start
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0236")))
                                {
                                    // -- Gennemf?rt automatisk betaling
                                    // -- BEHANDL: Gennemf?rt automatisk betaling
                                    read042(sektion, "0236", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0237")))
                                {
                                    // -- Afvist betaling
                                    // -- BEHANDL: Afvist betaling
                                    read042(sektion, "0237", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0238")))
                                {
                                    // -- Afmeldt betaling
                                    // -- BEHANDL: Afmeldt betaling
                                    read042(sektion, "0238", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0239")))
                                {
                                    // -- Tilbagef?rt betaling
                                    // -- BEHANDL: Tilbagef?rt betaling
                                    read042(sektion, "0239", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS092") &&
                                          (rec.Substring(13, 4) == "0211")))
                                {
                                    // -- Sektion S**t
                                    // -- BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                }
                            }
                            else if ((sektion == "0215"))
                            {
                                // -- Sektion 0215 FI-Betalingsinformation
                                if (((rec.Substring(0, 5) == "BS012") &&
                                     (rec.Substring(13, 4) == "0215")))
                                {
                                    // -- Sektion Start
                                    // -- BEHANDL: Sektion Start
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0297")))
                                {
                                    // -- Gennemf?rt FI-betaling
                                    // -- BEHANDL: Gennemf?rt FI-betaling
                                    read042(sektion, "0297", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0299")))
                                {
                                    // -- Tilbagef?rt FI-betaling
                                    // -- BEHANDL: Tilbagef?rt FI-betaling
                                    read042(sektion, "0299", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS092") &&
                                          (rec.Substring(13, 4) == "0215")))
                                {
                                    // -- Sektion S**t
                                    // -- BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                }
                            }
                            else if ((rec.Substring(0, 5) == "BS992"))
                            {
                                // -- Leverance s**t
                                // -- BEHANDL: Leverance S**t
                                leverancetype = "";
                            }
                            else
                            {
                                throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            }
                        }
                        else
                        {
                            throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        }
                    }  // s**t rstpbsfile

                    // -- Update indbetalingsbelob
                    foreach (tblbet rec_bet in m_rec_frapbs.tblbets)
                    {
                        var SumIndbetalingsbelob = (
                            from c in rec_bet.tblbetlins
                            group c by c.betid into g
                            select new { Betid = g.Key, SumIndbetalingsbelob = g.Sum(c => c.indbetalingsbelob) }
                            ).First().SumIndbetalingsbelob;

                        rec_bet.indbetalingsbelob = SumIndbetalingsbelob;
                    }
                }
                catch (Exception e)
                {
                    switch (e.Message.Substring(0, 3))
                    {
                    case "241":       //241 - Første record er ikke en Leverance start record
                    case "242":       //242 - Leverancen er indlæst tidligere
                    case "243":       //243 - Første record er ikke en Sektions start record
                    case "244":       //244 - Record ukendt
                    case "245":       //245 - Record ukendt
                    case "246":       //246 - Record ukendt
                    case "247":       //247 - Record ukendt
                        AntalFiler--;
                        break;

                    default:
                        throw;
                    }
                }
            }  // s**t rstpbsfiles
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
示例#23
0
 public void JobQMaintenance(dbData3060DataContext p_dbData3060)
 {
     var result = p_dbData3060.ExecuteQuery <dynamic>(@"DELETE FROM dbo.tblJobqueue WHERE starttime < DATEADD(DAY,-2,GETDATE())");
 }
示例#24
0
        public int ReadFromLocalFile(dbData3060DataContext p_dbData3060, string FilePath)
        {
            FileInfo file;

            try
            {
                file = new FileInfo(FilePath);
                if (!(file.Exists))
                {
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }

            //***********************************************************************
            //  Open a local file:
            string fullpath = file.FullName;
            int    numBytes = (int)file.Length;

            byte[] b_data = new byte[numBytes];

            Program.Log(string.Format("Start Reading of {0}", fullpath));
            using (FileStream ts = file.Open(FileMode.Open, FileAccess.Read, FileShare.None))
            {
                ts.Read(b_data, 0, numBytes);
            }
            Program.Log(string.Format("{0} Reading Completed", fullpath));

            sendAttachedFile(p_dbData3060, file.Name, 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');

            string[] lines = filecontens4.Split('\n');
            string   ln    = null;
            int      seqnr = 0;
            string   ln0_6;

            tblpbsfilename m_rec_pbsfiles = new tblpbsfilename
            {
                type     = 8,
                path     = file.Directory.FullName,
                filename = file.Name,
                size     = (int)file.Length,
                atime    = file.LastAccessTime,
                mtime    = file.LastWriteTime
            };

            p_dbData3060.tblpbsfilenames.InsertOnSubmit(m_rec_pbsfiles);
            for (int idx = 0; idx < lines.Count(); idx++)
            {
                ln = lines[idx].TrimEnd('\r');
                try { ln0_6 = ln.Substring(0, 6); }
                catch { ln0_6 = ""; }
                if (((seqnr == 0) && !(ln0_6 == "PBCNET")) || (seqnr > 0))
                {
                    seqnr++;
                }
                if (ln.Length > 0)
                {
                    m_rec_pbsfile = new tblpbsfile
                    {
                        seqnr = seqnr,
                        data  = ln
                    };
                    m_rec_pbsfiles.tblpbsfiles.Add(m_rec_pbsfile);
                }
            }

            m_rec_pbsfiles.transmittime = DateTime.Now;
            var cb = new SqlConnectionStringBuilder(p_dbData3060.Connection.ConnectionString);

            Program.Log(string.Format("Start Write {0} to SQL Database {1} on {2}", file.Name, cb.InitialCatalog, cb.DataSource));
            p_dbData3060.SubmitChanges();
            Program.Log(string.Format("{0} Write to SQL Database Completed", file.Name));
            return(1);
        }
示例#25
0
 public clsKontingent(dbData3060DataContext p_dbData3060, DateTime startdato, DateTime?fodtdato)
 {
     this.BeregnKontingent(p_dbData3060, startdato, fodtdato);
 }
示例#26
0
        public void overfoersel_mail(dbData3060DataContext p_dbData3060, int lobnr)
        {
            var antal = (from c in p_dbData3060.tbltilpbs
                         where c.id == lobnr
                         select c).Count();

            if (antal == 0)
            {
                throw new Exception("101 - Der er ingen PBS forsendelse for id: " + lobnr);
            }

            var qrykrd = from h in p_dbData3060.tbloverforsels
                         where h.tilpbsid == lobnr
                         select new
            {
                h.Nr,
                h.Email,
                h.Kaldenavn,
                h.Navn,
                h.betalingsdato,
                h.advistekst,
                h.advisbelob,
                h.bankregnr,
                h.bankkontonr,
            };


            // Start loop over betalinger i tbloverforsel
            int testantal = qrykrd.Count();

            using (var smtp_client = new MailKit.Net.Smtp.SmtpClient())
            {
                smtp_client.Connect("smtp.gigahost.dk", 587, false);
                smtp_client.AuthenticationMechanisms.Remove("XOAUTH2");
                smtp_client.Authenticate("*****@*****.**", "1234West+");

                using (var imap_client = new ImapClient())
                {
                    imap_client.Connect("imap.gigahost.dk", 993, true);
                    imap_client.AuthenticationMechanisms.Remove("XOAUTH");
                    imap_client.Authenticate("*****@*****.**", "1234West+");

                    var SendtPost = imap_client.GetFolder("Sendt post");
                    SendtPost.Open(FolderAccess.ReadWrite);


                    foreach (var krd in qrykrd)
                    {
                        //  Create a new email object
                        var message = new MimeMessage();
#if (DEBUG)
                        message.Subject = "TEST Bankoverførsel fra Puls 3060: skal sendes til " + "Regnskab Puls3060" + " - " + "*****@*****.**";
                        message.To.Add(new MailboxAddress("Regnskab Puls3060", "*****@*****.**"));
#else
                        message.Subject = "Bankoverførsel fra Puls 3060";
                        if (krd.Email.Length > 0)
                        {
                            message.To.Add(new MailboxAddress(krd.Navn, krd.Email));
                        }
                        else
                        {
                            message.Subject += ": skal sendes til " + krd.Navn;
                            message.To.Add(new MailboxAddress("Regnskab Puls3060", "*****@*****.**"));
                        }
#endif
                        message.From.Add(new MailboxAddress("Regnskab Puls3060", "*****@*****.**"));
                        message.Body = new TextPart("plain")
                        {
                            Text = new clsInfotekst
                            {
                                infotekst_id     = 40,
                                numofcol         = null,
                                kaldenavn        = krd.Kaldenavn,
                                betalingsdato    = krd.betalingsdato,
                                advisbelob       = krd.advisbelob,
                                bankkonto        = krd.bankregnr + "-" + krd.bankkontonr,
                                advistekst       = krd.advistekst,
                                underskrift_navn = "\r\nMogens Hafsjold\r\nRegnskabsfører"
                            }.getinfotekst(p_dbData3060)
                        };
                        SendtPost.Append(message);
                        smtp_client.Send(message);
                    }
                    SendtPost.Close();
                    imap_client.Disconnect(true);
                }
                smtp_client.Disconnect(true);
            }
        }
示例#27
0
        public int aftaleoplysninger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            int      dummy = 0;
            string   rec;
            string   leverance;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;


            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0686" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            int DebugCount = qrypbsfiles.Count();

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                //try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverance = "";
                    sektion   = "";
                    leverancespecifikation = "";


                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        //  Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance Start
                                leverance = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse(rec.Substring(53, 4) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            };

                            if (leverance == "0686")
                            {
                                // -- Leverance 0686
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0686",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0686",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                            ;
                        }
                        ;

                        if (leverance == "0686")
                        { //  Leverance 0686
                            //  Bestem Sektions Type
                            if (sektion == "")
                            {
                                if (rec.Substring(0, 5) == "BS012")
                                {  //  Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else
                                {
                                    if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                    {
                                        throw new Exception("243 - Første record er ikke en Sektions start record");
                                    }
                                    ;
                                };
                            }
                            ;

                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance start
                                //  BEHANDL: Leverance start
                                dummy = 1;
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0195")
                            {     //  Sektion 0195 Indbetalingskort til e-Boks
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0195"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  Indbetalingskort til e-Boks
                                    //  BEHANDL: Indbetalingskort til e-Boks
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0195"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0196")
                            {     //  Sektion 0196 elektronisk indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0196"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  elektronisk indbetalingskort
                                    //  BEHANDL: elektronisk indbetalingskort
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0196"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0197")
                            {     //  Sektion 0197 papirindbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0197"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  papirindbetalingskort
                                    //  BEHANDL: papirindbetalingskort
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0197"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0198")
                            {     //  Sektion 0198 ej placerbare
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0198"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  ej placerbare
                                    //  BEHANDL: ej placerbare
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0198"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0199")
                            {     //  Sektion 0199 uanbringelig
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0199"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0275"))
                                {  //  uanbringelig
                                    //  BEHANDL: uanbringelig
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0199"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("248 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (rec.Substring(0, 5) == "BS992")
                            {  //  Leverance s**t
                                //  BEHANDL: Leverance S**t
                                leverance = "";
                            }
                            else
                            {
                                throw new Exception("249 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            };
                        }

                        else
                        {
                            throw new Exception("250 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        };
                    }
                }

                /*
                 * catch (Exception e)
                 * {
                 *  switch (e.Message.Substring(0, 3))
                 *  {
                 *      case "241":   //241 - Første record er ikke en Leverance start record
                 *      case "242":   //242 - Leverancen er indlæst tidligere
                 *      case "243":   //243 - Første record er ikke en Sektions start record
                 *      case "244":   //244 - Record ukendt
                 *      case "245":   //245 - Record ukendt
                 *      case "246":   //246 - Record ukendt
                 *      case "247":   //247 - Record ukendt
                 *      case "248":   //248 - Record ukendt
                 *      case "249":   //249 - Record ukendt
                 *      case "250":   //250 - Record ukendt
                 *          AntalFiler--;
                 *          break;
                 *
                 *      default:
                 *          throw;
                 *  }
                 * }
                 */
            }
            if (dummy == 1)
            {
                dummy = 2;
            }
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
示例#28
0
        private void BeregnKontingent(dbData3060DataContext p_dbData3060, DateTime startdato, DateTime?fodtdato)
        {
            int alder;

            if (fodtdato == null)
            {
                alder = 40;
            }
            else
            {
                try
                {
                    alder = startdato.Subtract((DateTime)fodtdato).Days / 365;
                }
                catch
                {
                    alder = 40;
                }
            }

            decimal  kont = 0;
            bool     HalfPlusNextYear;
            DateTime KontingentFradato;
            DateTime KontingentTildato;

            switch (startdato.Month)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                KontingentFradato = new DateTime(startdato.Year, 1, 1);
                KontingentTildato = new DateTime(startdato.Year, 12, 31);
                HalfPlusNextYear  = false;
                break;

            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
                KontingentFradato = new DateTime(startdato.Year, 7, 1);
                KontingentTildato = new DateTime(startdato.Year + 1, 12, 31);
                HalfPlusNextYear  = true;
                break;

            default:
                KontingentFradato = new DateTime(startdato.Year + 1, 1, 1);
                KontingentTildato = new DateTime(startdato.Year + 1, 12, 31);
                HalfPlusNextYear  = false;
                break;
            }

            var qry1 = from k in p_dbData3060.tblKontingents
                       where (k.startalder <= alder && k.slutalder >= alder) && (k.startdato.Date >= KontingentFradato.Date || k.slutdato.Date >= KontingentFradato.Date)
                       select k;

            int antal = qry1.Count();

            var qry2 = from k in qry1
                       where k.slutdato.Date <= KontingentTildato
                       orderby k.startdato
                       select k;

            int antal2 = qry2.Count();

            int n = 1;

            foreach (var k in qry2)
            {
                if ((n == 1) && (HalfPlusNextYear))
                {
                    kont += k.aarskontingent / 2;
                }
                else
                {
                    kont += k.aarskontingent;
                }

                n++;
            }
            this.Kontingent        = kont;
            this.KontingentTildato = KontingentTildato;
        }
示例#29
0
        public void overfoersel_mail(dbData3060DataContext p_dbData3060, int lobnr)
        {
            var antal = (from c in p_dbData3060.tbltilpbs
                         where c.id == lobnr
                         select c).Count();

            if (antal == 0)
            {
                throw new Exception("101 - Der er ingen PBS forsendelse for id: " + lobnr);
            }

            string SmtpUsername = p_dbData3060.GetSysinfo("SMTPUSER");
            string SmtpPassword = p_dbData3060.GetSysinfo("SMTPPASSWD");
            var    smtp         = new SmtpClient
            {
                Host                  = p_dbData3060.GetSysinfo("SMTPHOST"),
                Port                  = int.Parse(p_dbData3060.GetSysinfo("SMTPPORT")),
                EnableSsl             = bool.Parse(p_dbData3060.GetSysinfo("SMTPSSL")),
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(SmtpUsername, SmtpPassword)
            };


            var qrykrd = from k in p_dbData3060.tblMedlems
                         join h in p_dbData3060.tbloverforsels on k.Nr equals h.Nr
                         where h.tilpbsid == lobnr
                         select new
            {
                k.Nr,
                k.Email,
                k.Kaldenavn,
                k.Navn,
                h.betalingsdato,
                h.advistekst,
                h.advisbelob,
                h.bankregnr,
                h.bankkontonr,
            };


            // Start loop over betalinger i tbloverforsel
            int testantal = qrykrd.Count();

            foreach (var krd in qrykrd)
            {
                //  Create a new email object
                MailMessage email = new MailMessage();

#if (DEBUG)
                email.Subject = "TEST Bankoverførsel fra Puls 3060: skal sendes til " + p_dbData3060.GetSysinfo("MAILTONAME") + " - " + p_dbData3060.GetSysinfo("MAILTOADDR");
                email.To.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILTOADDR"), p_dbData3060.GetSysinfo("MAILTONAME")));
#else
                email.Subject = "Bankoverførsel fra Puls 3060";
                if (krd.Email.Length > 0)
                {
                    email.To.Add(new MailAddress(krd.Email, krd.Navn));
                    email.Bcc.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILTOADDR"), p_dbData3060.GetSysinfo("MAILTONAME")));
                }
                else
                {
                    email.Subject += ": skal sendes til " + krd.Navn;
                    email.To.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILTOADDR"), p_dbData3060.GetSysinfo("MAILTONAME")));
                }
#endif
                email.Body = new clsInfotekst
                {
                    infotekst_id     = 40,
                    numofcol         = null,
                    kaldenavn        = krd.Kaldenavn,
                    betalingsdato    = krd.betalingsdato,
                    advisbelob       = krd.advisbelob,
                    bankkonto        = krd.bankregnr + "-" + krd.bankkontonr,
                    advistekst       = krd.advistekst,
                    underskrift_navn = "\r\nMogens Hafsjold\r\nRegnskabsfører"
                }.getinfotekst(p_dbData3060);

                email.From = new MailAddress(p_dbData3060.GetSysinfo("MAILFROM"));
                email.ReplyToList.Add(new MailAddress(p_dbData3060.GetSysinfo("MAILREPLY")));

                smtp.Send(email);
            }
        }
示例#30
0
        public void imapSaveAttachedFile(dbData3060DataContext p_dbData3060, string filename, byte[] data, bool bTilPBS)
        {
            string local_filename = filename.Replace('.', '_') + ".txt";

            MimeMessage message = new MimeMessage();
            TextPart    body;

            message.To.Add(new MailboxAddress(@"*****@*****.**", @"Regnskab Puls3060"));
            message.From.Add(new MailboxAddress(@"*****@*****.**", @"Regnskab Puls3060"));

            if (bTilPBS)
            {
#if (DEBUG)
                message.Subject = "Test Til PBS: " + local_filename;
                body            = new TextPart("plain")
                {
                    Text = @"Test Til PBS: " + local_filename
                };
#else
                message.Subject = "Til PBS: " + local_filename;
                body            = new TextPart("plain")
                {
                    Text = @"Til PBS: " + local_filename
                };
#endif
            }
            else
            {
#if (DEBUG)
                message.Subject = "Test Fra PBS: " + local_filename;
                body            = new TextPart("plain")
                {
                    Text = @"Test Fra PBS: " + local_filename
                };
#else
                message.Subject = "Fra PBS: " + local_filename;
                body            = new TextPart("plain")
                {
                    Text = @"Fra PBS: " + local_filename
                };
#endif
            }

            var attachment = new MimePart("text", "plain")
            {
                ContentObject           = new ContentObject(new MemoryStream(data), ContentEncoding.Default),
                ContentDisposition      = new ContentDisposition(ContentDisposition.Attachment),
                ContentTransferEncoding = ContentEncoding.Base64,
                FileName = local_filename
            };

            var multipart = new Multipart("mixed");
            multipart.Add(body);
            multipart.Add(attachment);

            message.Body = multipart;

            using (var client = new ImapClient())
            {
                client.Connect("imap.gigahost.dk", 993, true);
                client.AuthenticationMechanisms.Remove("XOAUTH");
                client.Authenticate(@"*****@*****.**", "1234West+");

                var PBS = client.GetFolder("INBOX.PBS");
                PBS.Open(FolderAccess.ReadWrite);
                PBS.Append(message);
                PBS.Close();

                client.Disconnect(true);
            }
        }