コード例 #1
0
        protected override void OnStart(string[] args)
        {
            string outputDirectory       = Settings.Default.outputDirectory;
            string sqlConnectionString   = Settings.Default.sqlConnectionString;
            int    sendMessageCount      = Settings.Default.sendMessageCount;
            int    sendDelayInHour       = Settings.Default.sendDelayInHour;
            int    checkIntervalInSecond = Settings.Default.checkIntervalInSecond;
            string logPath        = Settings.Default.logPath;
            int    maxLogSizeInKb = Settings.Default.maxLogSizeInKb;

            var log = new FileInfo(logPath);

            if (log.Exists && log.Length > maxLogSizeInKb)
            {
                File.Delete(logPath);
            }

            _timer.Interval = checkIntervalInSecond * 100;
            _timer.Start();

            _timer.Elapsed += (sender, eventArgs) =>
            {
                try
                {
                    MT103.Send(sqlConnectionString, new DirectoryInfo(outputDirectory), sendMessageCount, sendDelayInHour);
                }
                catch (Exception e)
                {
                    File.AppendAllText(logPath, DateTime.Now + "    " + e.ToString() + "\n\n");
                }
            };
        }
コード例 #2
0
        /// <summary>
        /// Возвращает коллекцию всех филиалов из БД
        /// </summary>
        public static IEnumerable <ProvincialBranch> GetAllProvincialBranch(string sqlConnectionString)
        {
            using (var db = MT103.GetDatabase(sqlConnectionString))
            {
                var result = db.China_ICBC_ProvincialBranch.ToList();

                return(result.Select(r => new ProvincialBranch(r.Name, r.Address, new SwiftCode(r.SWIFT))));
            }
        }
コード例 #3
0
 public void MT103Callback(MT103 message)
 {
     try
     {
         var account = _accounts.Single(acc => acc.AccountNumber == message.RecipientAccount);
         account.Balance += (double)message.Ammount;
     }
     catch
     {
     }
 }
コード例 #4
0
 public void SendTestSingle()
 {
     try
     {
         MT103.Send(CONNECTION_STRING, new DirectoryInfo(OUTPUT_DIRECTORY), "ССС140118000001");
         Assert.IsTrue(true);
     }
     catch (Exception e)
     {
         Assert.Fail(e.ToString());
     }
 }
コード例 #5
0
        /// <summary>
        /// Возвращает варианты иероглифов с кодами, для заданного имени
        /// </summary>
        public static List <NameWithHieroglyph> GetHieroglyphList(string sqlConnectionString, string name)
        {
            using (var db = MT103.GetDatabase(sqlConnectionString))
            {
                name = name.ToLower();

                var result = from r in db.China_ICBC_Hieroglyphs.Where(r => r.Name == name).ToList()
                             select new NameWithHieroglyph(r.Name, r.Hieroglyph, r.HieroglyphCode);

                return(result.ToList());
            }
        }
コード例 #6
0
        public void SendTestMany()
        {
            try
            {
                //for (int i = 0; i < 100; i++)
                //{
                //Thread.Sleep(new TimeSpan(0, 0, 0));
                MT103.Send(CONNECTION_STRING, new DirectoryInfo(OUTPUT_DIRECTORY), 1000, 1);
                //}

                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
コード例 #7
0
        public MT900 RTGS(MT103 mt103)
        {
            Banka bankaDuznika  = DAO.GetBanka(mt103.RacunDuznika);
            Banka bankaPrimaoca = DAO.GetBanka(mt103.RacunPoverioca);

            Firma duznik   = DAO.GetFirmaBrojRacuna(mt103.RacunDuznika);
            Firma primalac = DAO.GetFirmaBrojRacuna(mt103.RacunPoverioca);

            MT900 rt900 = new MT900("idPoruka",
                                    bankaDuznika.Swift,
                                    bankaDuznika.Racun,
                                    mt103.IdPoruke,
                                    mt103.DatumValute,
                                    mt103.Iznos,
                                    mt103.SifraValute
                                    );

            MT910 mt910 = new MT910(
                "idPoruke",
                bankaPrimaoca.Swift,
                bankaPrimaoca.Racun,
                mt103.IdPoruke,
                mt103.DatumValute,
                mt103.Iznos,
                mt103.SifraValute
                );

            ChannelFactory <IBank> factory = new ChannelFactory <IBank>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/" + bankaPrimaoca.Naziv));
            IBank proxy = factory.CreateChannel();

            try
            {
                proxy.ObradiRTGS(mt103, mt910);
            }
            catch (Exception e)
            { }

            Izvod izvod = new Izvod(mt103.SvrhaPlacanja, mt103.DuznikNalogodavac, mt103.PrimalacPoverilac, mt103.DatumNaloga,
                                    mt103.DatumValute, mt103.RacunDuznika, mt103.ModelZaduzenja, mt103.PozivNaBrZaduzenja,
                                    mt103.RacunPoverioca, mt103.ModelOdobrenja, mt103.PozivNaBrOdobrenja, mt103.Iznos);

            DAO.InsertIzvod(izvod, 1);

            return(rt900);
        }
コード例 #8
0
        private void RTGS(NalogPrenos prenos, Common.Model.Banka bankaDuznik, Common.Model.Banka bankaPrimaoca)
        {
            Firma duznik   = DAO.GetFirmaBrojRacuna(prenos.RacunDuznika);
            Firma primalac = DAO.GetFirmaBrojRacuna(prenos.RacunPrimalac);

            Racun racunDuznika = DAO.GetRacunBrojRacuna(prenos.RacunDuznika);

            DAO.UpdateStanjeRacuna(racunDuznika.BrojRacun, racunDuznika.Stanje - prenos.Iznos);

            MT103 mt103 = new MT103(
                "id",
                bankaDuznik.Swift,
                bankaDuznik.Racun,
                bankaPrimaoca.Swift,
                bankaPrimaoca.Racun,
                duznik.Naziv,
                prenos.SvrhaPlacanja,
                primalac.Naziv,
                prenos.DatumNaloga,
                prenos.DatumValute,
                prenos.RacunDuznika,
                prenos.ModelZaduzenja,
                prenos.PozivNaBrZaduzenja,
                prenos.RacunPrimalac,
                prenos.ModelOdobrenja,
                prenos.PozivNaBrOdobrenja.ToString(),
                prenos.Iznos,
                "RSD"
                );


            ChannelFactory <ICentralnaBanka> factory = new ChannelFactory <ICentralnaBanka>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/CB"));
            ICentralnaBanka proxy = factory.CreateChannel();

            MT900 mt900 = null;

            try
            {
                mt900 = proxy.RTGS(mt103);
            }
            catch (Exception)
            { }
        }
コード例 #9
0
        public void RTGSRequest(MT103 requestMessage)
        {
            Console.WriteLine("REQUEST");
            try
            {
                var recipientBank = _banks[requestMessage.RecipientAccount.Substring(0, 3)];
                recipientBank.MT103Callback(requestMessage);
            }
            catch
            {
                return;
            }
            var payerBank = _banks[requestMessage.PayerAccount.Substring(0, 3)];

            if (payerBank != null)
            {
                payerBank.MT900CallBack(new MT900()
                {
                    PayerBankAccountNumber = requestMessage.PayerBankAccountNumber, Ammount = requestMessage.Ammount
                });
            }
        }
コード例 #10
0
        public void PaymentAction(PaymentActionRequest request)
        {
            var account = request.RecipientAccountNumber;

            if (account.Substring(0, 3) == _bankId)
            {
                DoInternalBilling(request);
            }
            else
            {
                var mt103 = new MT103()
                {
                    Ammount                    = request.Ammount,
                    PayerAccount               = request.PayerAccountNumber,
                    PayerBankAccountNumber     = request.PayerAccountNumber,
                    RecipientAccount           = request.RecipientAccountNumber,
                    RecipientBankAccountNumber = request.RecipientAccountNumber
                };

                _centralBankServiceClient.RTGSRequestAsync(mt103);
            }

            return;
        }
コード例 #11
0
        public void ObradiRTGS(MT103 mt103, MT910 mt910)
        {
            Racun racunPrimaoca = DAO.GetRacunBrojRacuna(mt910.ObracunskiBankePoverioca);

            DAO.UpdateStanjeRacuna(racunPrimaoca.BrojRacun, racunPrimaoca.Stanje + mt910.Iznos);
        }