private SingleTraderCreditProviderEndApplyResponse EndApply(SingleTraderCreditProviderEndApplyRequest request)
        {
            var response = new SingleTraderCreditProviderEndApplyResponse();
            var args     = new
            {
                Result         = CommandParameter.Output(System.Data.SqlDbType.VarChar, 80),
                TransactionKey = request.TransactionKey
            };
            var dbr = Db.ExecuteNonQuery("usp1_Credit_singletrader_end_apply", args);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = Auditor.Audit(request.AuditCode, $"{{trnk:{request.TransactionKey}}}");
                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded();
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 2
0
        public MultiTraderCreditProviderEndTransferResponse EndTransfer(MultiTraderCreditProviderEndTransferRequest request)
        {
            var response = new MultiTraderCreditProviderEndTransferResponse();
            var args     = new
            {
                Result         = CommandParameter.Output(System.Data.SqlDbType.VarChar, 80),
                TraderKey      = request.TraderKey,
                TransactionKey = request.TransactionKey
            };
            var dbr = Db.ExecuteNonQuery("usp1_CreditTransaction_end_transfer", args);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = Auditor.Audit("CRD_ENDTRNSFR", $"{{tk:{request.TraderKey},trnk:{request.TransactionKey}}}");
                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded();
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 3
0
        private async Task <PaymentManagerReversalPaymentResponse> SaveReversalPaymentAsync(ReversalRequest request, PaymentProviderReversalPaymentResponse providerResponse, CancellationToken cancellation)
        {
            var result = new PaymentManagerReversalPaymentResponse();

            result.Request = request;

            var dbOk = false;

            Logger.LogCategory("SaveReversalPaymentAsync");

            if (providerResponse.Succeeded || !Config.SaveOnlySuccessfulOperations)
            {
                Logger.Log("Start saving in the database");

                var args = new
                {
                    Result        = CommandParameter.Output(SqlDbType.VarChar, 50),
                    PaymentCode   = request.PaymentCode,
                    BankType      = providerResponse.ProviderType,
                    StepStatus    = SafeClrConvert.ToString(providerResponse.Status),
                    StepDate      = providerResponse.Date,
                    StepSucceeded = providerResponse.Succeeded,
                    @StepData     = ""
                };
                var cmd = _db.GetCommand("usp1_Payment_save_reversal_step");

                result.DbResult = await _db.ExecuteNonQueryAsync(cmd, args, cancellation);

                if (result.DbResult.Success)
                {
                    result.Status = args.Result.Value.ToString();

                    Logger.Log("DbStatus = " + result.Status);

                    dbOk = result.Status == "Success";

                    if (!dbOk)
                    {
                        result.Status = "SaveError";
                    }
                }
                else
                {
                    Logger.Log("Failed: " + result.DbResult.Exception.ToString(","));

                    result.Failed(result.DbResult.Exception);
                }
            }
            else
            {
                dbOk = true;
            }

            if (providerResponse.Succeeded && dbOk)
            {
                result.Succeeded();
            }

            return(result);
        }
        public override void Test()
        {
            var _args = new { a = "alireza", b = CommandParameter.Output(SqlDbType.NVarChar, -1) };
            var dbr   = DA.DefaultDb.ExecuteNonQuery("ust_test2", _args);

            if (dbr.Success)
            {
                var s = SafeClrConvert.ToString(_args.b.Value);
                System.Console.WriteLine("b: " + s);
            }
            else
            {
                System.Console.WriteLine(dbr.Exception.Message);
            }
        }
Exemplo n.º 5
0
        public override void Test()
        {
            var guid  = Guid.NewGuid();
            var _args = new { p1 = CommandParameter.Guid(guid), p2 = CommandParameter.Output(SqlDbType.UniqueIdentifier) };
            var dbr   = DA.DefaultDb.ExecuteNonQuery("ust_test1", _args);

            if (dbr.Success)
            {
                var s = SafeClrConvert.ToString(_args.p2.Value);
                System.Console.WriteLine("p2: " + s);
            }
            else
            {
                System.Console.WriteLine(dbr.Exception.Message);
            }
        }
Exemplo n.º 6
0
        public DbResult <bool> _RoleExists(string roleName)
        {
            var cmd  = db.GetCommand("usp1_Role_exists");
            var args = new
            {
                roleName,
                Result = CommandParameter.Output(SqlDbType.Bit)
            };
            var dbr    = db.ExecuteNonQuery(cmd, args);
            var result = dbr.Copy <bool>();

            if (dbr.Success)
            {
                result.Data = SafeClrConvert.ToBoolean(args.Result.Value);
            }

            return(result);
        }
Exemplo n.º 7
0
        public DbResult <string[]> _GetAllRoles()
        {
            var cmd  = db.GetCommand("usp1_Role_get_all");
            var args = new
            {
                roles = CommandParameter.Output(SqlDbType.VarChar, 4000)
            };
            var dbr    = db.ExecuteNonQuery(cmd, args);
            var result = dbr.Copy <string[]>();

            if (dbr.Success)
            {
                var roles = SafeClrConvert.ToString(args.roles.Value);

                result.Data = roles.Split(new char[] { ',' });
            }

            return(result);
        }
Exemplo n.º 8
0
        public DbResult <bool> _IsUserInRole(string username, string roleName)
        {
            var cmd  = db.GetCommand("usp1_User_is_in_role");
            var args = new
            {
                username,
                roleName,
                Result = CommandParameter.Output(SqlDbType.Bit)
            };
            var dbr    = db.ExecuteNonQuery(cmd, args);
            var result = dbr.Copy <bool>();

            if (dbr.Success)
            {
                result.Data = SafeClrConvert.ToBoolean(args.Result.Value);
            }

            return(result);
        }
Exemplo n.º 9
0
        public async Task <MultiTraderCreditProviderBeginTransferResponse> BeginTransferAsync(MultiTraderCreditProviderBeginTransferRequest request, CancellationToken cancellation)
        {
            var response = new MultiTraderCreditProviderBeginTransferResponse();
            var args     = new
            {
                Result    = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                Key       = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                TraderKey = request.TraderKey,
                request.FromUserName,
                request.ToUserName,
                request.Amount,
                request.FromInfo,
                request.ToInfo
            };
            var dbr = await Db.ExecuteNonQueryAsync("usp1_CreditTransaction_begin_transfer", args, cancellation);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = await Auditor.AuditAsync("CRD_BGNTRNSFR", $"{{tk:{request.TraderKey},fu:{request.FromUserName},tu:{request.ToUserName},m:{request.Amount}}}");

                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded(args.Key.Value);
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
        public SingleTraderCreditProviderBeginTransferResponse BeginTransfer(SingleTraderCreditProviderBeginTransferRequest request)
        {
            var response = new SingleTraderCreditProviderBeginTransferResponse();
            var args     = new
            {
                Result = CommandParameter.Output(System.Data.SqlDbType.VarChar, 80),
                Key    = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                request.FromUserName,
                request.ToUserName,
                request.Amount,
                request.FromInfo,
                request.ToInfo
            };
            var dbr = Db.ExecuteNonQuery("usp1_Credit_singletrader_begin_transfer", args);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = Auditor.Audit("CRD_BGNTRNSFR", $"{{fu:{request.FromUserName},tu:{request.ToUserName},m:{request.Amount}}}");
                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded(args.Key.Value);
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 11
0
        private async Task <MultiTraderCreditProviderBeginApplyResponse> BeginApplyAsync(MultiTraderCreditProviderBeginApplyRequest request, CancellationToken cancellation)
        {
            var response = new MultiTraderCreditProviderBeginApplyResponse();
            var args     = new
            {
                Result    = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                Key       = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                TraderKey = request.TraderKey,
                UserName  = request.UserName,
                Amount    = request.Amount,
                Info      = request.Info
            };
            var dbr = await Db.ExecuteNonQueryAsync("usp1_CreditTransaction_begin_apply", args, cancellation);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = await Auditor.AuditAsync(request.AuditCode, $"{{tk:{request.TraderKey},u:{request.UserName},m:{request.Amount}}}");

                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded(args.Key.Value);
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 12
0
        private MultiTraderCreditProviderApplyResponse Apply(MultiTraderCreditProviderApplyRequest request)
        {
            var response = new MultiTraderCreditProviderApplyResponse();
            var args     = new
            {
                Result    = CommandParameter.Output(System.Data.SqlDbType.VarChar, 80),
                TraderKey = request.TraderKey,
                UserName  = request.UserName,
                Amount    = request.Amount,
                Info      = request.Info
            };
            var dbr = Db.ExecuteNonQuery("usp1_CreditTransaction_apply", args);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = Auditor.Audit(request.AuditCode, $"{{tk:{request.TraderKey},u:{request.UserName},m:{request.Amount}}}");
                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded();
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 13
0
        void test2()
        {
            var args = new Dictionary <string, object>();

            args.Add("Result", CommandParameter.Output(SqlDbType.VarChar, 50));
            args.Add("Args", CommandParameter.Output(SqlDbType.NVarChar, 1000));
            args.Add("execMode", 0);
            args.Add("ClientKey", CommandParameter.Guid("F9FA3F42-7568-4FDC-AF12-A88994997596"));
            //(args["ClientKey"] as GuidCommandParameter).Value = "F9FA3F42-7568-4FDC-AF12-A88994997596";
            var dbr = DA.DefaultDb.ExecuteSingle("usp1_ApiClient_GetByKey", (IDataReader reader) =>
            {
                var result = new Locust.Modules.Api.Model.ApiClient.Full();
                result.Read(reader);
                return(result);
            }, args);

            if (dbr.Success)
            {
                switch (dbr.MessageType)
                {
                case MessageType.SingleSuccess:
                    //Console.WriteLine(dbr.Data.ClientKey);
                    //Console.WriteLine(JsonConvert.SerializeObject(dbr.Data));
                    Console.WriteLine(dbr.Data.ToJson());
                    break;

                case MessageType.SingleNotFound:
                    Console.WriteLine("Not found");
                    break;
                }
            }
            else
            {
                Console.WriteLine("Error: {0}", dbr.Exception.Message);
            }
        }
        public async Task <SingleTraderCreditProviderEndTransferResponse> EndTransferAsync(SingleTraderCreditProviderEndTransferRequest request, CancellationToken cancellation)
        {
            var response = new SingleTraderCreditProviderEndTransferResponse();
            var args     = new
            {
                Result         = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                Key            = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50),
                TransactionKey = request.TransactionKey
            };
            var dbr = await Db.ExecuteNonQueryAsync("usp1_Credit_singletrader_end_transfer", args, cancellation);

            if (dbr.Success)
            {
                response.Status = args.Result.Value?.ToString();
                var ar = await Auditor.AuditAsync("CRD_ENDTRNSFR", $"{{trnk:{request.TransactionKey}}}");

                if (ar.IsSucceeded())
                {
                    if (response.Status == "Success")
                    {
                        response.Succeeded();
                    }
                }
                else
                {
                    response.Exception = ar.Exception;
                    response.Status    = "AuditError";
                }
            }
            else
            {
                response.Failed(dbr.Exception);
            }

            return(response);
        }
Exemplo n.º 15
0
 public ApiClientCustomerEnrolRequest()
 {
     ApiClientCustomerId = CommandParameter.Output(SqlDbType.Int) as CommandOutputParameter;
     ActivationCode      = CommandParameter.Output(SqlDbType.VarChar, 15) as CommandOutputParameter;
 }
Exemplo n.º 16
0
 public ApiDeleteRequest()
 {
     AppId = CommandParameter.Output(SqlDbType.Int);
     Path  = CommandParameter.Output(SqlDbType.VarChar, 100);
 }
Exemplo n.º 17
0
 public AppCrossOriginUpdateRequest()
 {
     AppId = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 18
0
 public ApplicationUpdateRequest()
 {
     OldShortName = CommandParameter.Output(SqlDbType.VarChar, 20);
 }
Exemplo n.º 19
0
 public ApiClientDeleteByKeyRequest()
 {
     //ClientKey = CommandParameter.Guid("");
     Id = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 20
0
 public DateNowRequest()
 {
     Now = CommandParameter.Output(SqlDbType.DateTime);
 }
Exemplo n.º 21
0
 public ApiSettingDeleteRequest()
 {
     ApiId = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 22
0
 public ApiClientUpdateRequest()
 {
     OldClientKey = CommandParameter.Output(SqlDbType.UniqueIdentifier);
 }
Exemplo n.º 23
0
 public AppCrossOriginAddRequest()
 {
     Id = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 24
0
 public ApiClientCustomerDeleteRequest()
 {
     AccessToken = CommandParameter.Output(SqlDbType.UniqueIdentifier);
 }
Exemplo n.º 25
0
 public ApiClientCustomerHubAddRequest()
 {
     Id = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 26
0
 public void AddOutput(string name, SqlDbType type, int size = 0)
 {
     OutputParameters.Add(name, CommandParameter.Output(type, size));
 }
Exemplo n.º 27
0
 public ApplicationAddRequest()
 {
     Id = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 28
0
        private PaymentManagerBeginPaymentResponse SaveBeginPayment(BeginPaymentRequest request, PaymentProviderBeginPaymentResponse providerResponse)
        {
            var result = new PaymentManagerBeginPaymentResponse();

            result.Request          = request;
            result.ProviderResponse = providerResponse;

            var dbOk = false;

            Logger.LogCategory("SaveBeginPayment");

            if (providerResponse.Succeeded || !Config.SaveOnlySuccessfulOperations)
            {
                Logger.Log("Start saving in the database");

                var args = new
                {
                    Result        = CommandParameter.Output(SqlDbType.VarChar, 50),
                    PaymentId     = CommandParameter.Output(SqlDbType.Int),
                    PaymentCode   = request.PaymentCode,
                    BankType      = request.BankType,
                    Amount        = request.Amount,
                    Info          = request.Info,
                    Data          = request.Data,
                    StepCode      = SafeClrConvert.ToString(providerResponse.Code),
                    StepStatus    = SafeClrConvert.ToString(providerResponse.Status),
                    StepDate      = providerResponse.Date,
                    StepSucceeded = providerResponse.Succeeded,
                    @StepData     = ""
                };
                var cmd = _db.GetCommand("usp1_Payment_save_begin_step");

                result.DbResult = _db.ExecuteNonQuery(cmd, args);

                if (result.DbResult.Success)
                {
                    Logger.Log("DbStatus = " + result.Status);

                    dbOk = result.Status == "Success";

                    if (dbOk)
                    {
                        result.Status = args.Result.Value.ToString();
                        result.Data   = result.DbResult.Data = (int)args.PaymentId.Value;
                    }
                    else
                    {
                        result.Status = "SaveError";
                    }
                }
                else
                {
                    Logger.Log("Failed: " + result.DbResult.Exception.ToString(","));

                    result.Failed(result.DbResult.Exception);
                }
            }
            else
            {
                dbOk = true;
            }

            if (providerResponse.Succeeded && dbOk)
            {
                result.Succeeded();
            }

            return(result);
        }
Exemplo n.º 29
0
 public CountryAddRequest()
 {
     CountryId = CommandParameter.Output(SqlDbType.Int);
 }
Exemplo n.º 30
0
 public BaseServicePageRequest()
 {
     Count = CommandParameter.Output(SqlDbType.Int);
 }