コード例 #1
0
 public object CreateScheme(Scheme model)
 {
     object result = null;
        try
        {
        var scheme = _db.Get<Scheme>().FirstOrDefault(x => x.Name == model.Name);
        if (scheme == null)
        {
           result =  _db.Create(model);
        }
        else
        {
            throw new Exception("This Scheme Already Exist");
        }
        if(result!=null)
        {
            return true;
        }
        }
        catch (Exception)
        {
        _db.Rollback();
        throw;
        }
        return result;
 }
コード例 #2
0
 public object UpdateScheme(Scheme model)
 {
     object result = null;
        var scheme = _db.Get<Scheme>().FirstOrDefault(x => x.Id==model.Id);
        if (scheme != null)
        {
        scheme.Name = model.Name;
        scheme.Route = model.Route;
        foreach(var item in model.TransactionTypeChannelFees)
        {
            item.Scheme = scheme;
        }
      result = _db.UpdateScheme(model);
        }
        return result;
 }
コード例 #3
0
 public object UpdateScheme(Scheme model)
 {
     object result = null;
        using (var session = DataAccess.OpenSession())
        {
        using (var trnx = session.BeginTransaction())
        {
            try
            {
         result = session.Merge(model);
            trnx.Commit();
            }
            catch (Exception)
            {
                trnx.Rollback();
                throw;
            }
            return result;
        }
        }
 }
コード例 #4
0
        public object Create(Scheme model)
        {
            object result = null;
               try
               {
               using (ISession session = _Session.SessionFactory.OpenSession())
               {
                   using (_Session.BeginTransaction())
                   {
                       Scheme scheme = new Scheme
                       {
                           Name = model.Name,
                           Route = model.Route,
                           Description = model.Description,
                       };
                       //session.SaveOrUpdate(scheme);

                       IList<TransactionTypeChannelFee> tcf = model.TransactionTypeChannelFees;
                       scheme.TransactionTypeChannelFees = tcf;

                       foreach (var item in tcf)
                       {
                           item.Scheme = scheme;
                           //session.Save(item);
                       }
                    result = session.Save(scheme);

                   }
               }
               return result;
               }
               catch (Exception)
               {
               _Session.Transaction.Rollback();
               throw;
               }
        }
コード例 #5
0
        public static void LogTransaction(Iso8583Message incomingMessage, SourceNode sourceNode = null, Scheme scheme = null, Fee fee = null, bool needReversal = false)
        {
            var instCode = incomingMessage.Fields[2].ToString().Substring(0, 6);
               string transactionTypeCode = (incomingMessage.Fields[3].ToString().Substring(0, 2));
               string channelCode = incomingMessage.Fields[123].ToString().Substring(13, 2);
               string cardPan = incomingMessage.Fields[2].ToString();
               string response = string.Empty;
               string responseCode = string.Empty;
               DateTime transmissionDate = DateTime.UtcNow;

               TransactionLog transactionLog = new TransactionLog();
               try
               {
               transactionLog.MTI = incomingMessage.MessageTypeIdentifier.ToString();
               transactionLog.STAN = incomingMessage.Fields[11].ToString();
               transactionLog.Amount = Convert.ToDouble(incomingMessage.Fields[4].ToString());
               transactionLog.CardPAN = cardPan;
               var channel = new ChannelManager().GetByCode(channelCode);
               if (channel != null)
               {
                   transactionLog.Channel = channel.Name;
               }
               var trnx = new TransactionTypeManager().GetByCode(transactionTypeCode);
               if (trnx != null)
               {
                   transactionLog.TransactionType = trnx.Name;
               }
               transactionLog.SourceNode = sourceNode.Name;
               transactionLog.TransactionDate = transmissionDate;
               transactionLog.DateCreated = DateTime.Now;
               transactionLog.DateModified = DateTime.Now;

               string orDataElt = incomingMessage.Fields[90].ToString();
               int length = orDataElt.Length;
               transactionLog.OriginalDataElement = orDataElt.Length > 19 ? orDataElt.Remove(0, (length - 19)) : orDataElt;

               try
               {
                   responseCode = incomingMessage.Fields[39].Value.ToString();
               }
               catch (Exception) { }

               if (scheme != null)
               {
                   transactionLog.Scheme = scheme.Name;
                   transactionLog.Route = scheme.Route.Name;

                   transactionLog.SinkNode = scheme.Route.SinkNode.Name;
               }

               try
               {
                   string value = incomingMessage.Fields[28].Value.ToString();
                   decimal result = 0;
                   if (Decimal.TryParse(value, out result))
                   {
                       transactionLog.Charge = result;
                   }
               }
               catch (Exception) { }
               if (fee != null)
               {
                   transactionLog.Fee = fee.Name;
               }
               if (responseCode != null)
               {
                   transactionLog.ResponseCode = responseCode;
               }
               if (responseCode != null)
               {
                   transactionLog.ResponseDescription = MessageDefinition.GetResponseDescription(responseCode);
               }
               string acc1 = incomingMessage.Fields[102].Value.ToString();
               string acc2 = incomingMessage.Fields[103].Value.ToString();
               transactionLog.Account1 = acc1;
               transactionLog.Account2 = acc2;
               transactionLog.IsReversePending = needReversal;

               if (incomingMessage.MessageTypeIdentifier.ToString() == "430" && responseCode == "00")
               {
                   transactionLog.IsReversed = true;
                   // SetReversalStatus(incomingMsg, responseCode);  //here
               }

               if (new TransactionLogManager().AddTransactionLog(transactionLog))
               {
                   Log("Transaction log::: " + transactionLog.STAN + " " + transactionLog.TransactionDate);
               }
               else
               {
                   Log("Transaction log::: not successful");
               }
               }
               catch (Exception ex)
               {
               Log("Error occurred while logging transaction \n" + ex.Message);
               Console.ForegroundColor = ConsoleColor.Red;
               }
        }
コード例 #6
0
        private Fee GetFeeIfTransactionIsAllowed(TransactionType transactionType, Channel channel, Scheme scheme)
        {
            try
               {
               foreach (var item in scheme.TransactionTypeChannelFees)
               {
                   if (channel != null)
                   {
                       if (item.TransactionType.Code == transactionType.Code && item.Channel.Code == channel.Code)
                       {
                           return item.Fee;
                       }
                   }
               }

               return null;
               }
               catch (Exception ex)
               {
               Logger.Log("Error: while checking if transaction is allowed \n" + ex.Message);
               return null;
               }
        }