Inheritance: MonoBehaviour
Example #1
0
    protected void lbBasicAuth_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("GBP", 999);
        //working
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);
        //invalid
        //CreditCard card = new CreditCard("MC", "1234123412341234", "0118", "Phil McCracken", "123", 1);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        string autoSettle = "1";

        RealAuthTransactionResponse resp = RealAuthorisation.Auth(merchant, order, card, autoSettle, timestamp);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.ResultMessage;
    }
    //this doesnt work and I dont need it so tough
    protected void lb3DSecureReciept_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("transaction01", "EUR", 9999);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        string cardRef = "card1";
        string cvn = "123";
        string autoSettle = "1";

        RealVaultTransactionResponse resp = RealVault.RealVault3DSVerifyEnrolled(merchant, order, payer, cardRef, autoSettle, timestamp, new ArrayList());
        //TODO: Run RealAuth verify signed
        //TODO: Run Reciept-In with 3d secure details

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
Example #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Merchant merchant = new Merchant();
     
     ReportDataSource RD = new ReportDataSource("DataSet1", merchant.GetProducts());//DataSet1为建立报表时用到的数据集名称
     this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
     this.reportViewer1.LocalReport.ReportPath = @"..\..\BusinessObject.rdlc";
     this.reportViewer1.LocalReport.DataSources.Clear();
     this.reportViewer1.LocalReport.DataSources.Add(RD);
     this.reportViewer1.RefreshReport();
 }
 protected override Person CreatePerson(string personTypeString, string personNameString, Location personLocation)
 {
     Person person = null;
     switch (personTypeString)
     {
         case "merchant":
             person = new Merchant(personNameString, personLocation);
             break;
         default:
             person = base.CreatePerson(personTypeString, personNameString, personLocation);
             break;
     }
     return person;
 }
 public static ConsultationRequest create(String tid, Merchant merchant)
 {
     return new ConsultationRequest
     {
         id = Guid.NewGuid().ToString(),
         versao = Cielo.VERSION,
         tid = tid,
         dadosEc = new DadosEcElement
         {
             numero = merchant.id,
             chave = merchant.key
         }
     };
 }
        public static CancellationRequest create(string tid, Merchant merchant, int total)
        {
            var cancellationRequest = new CancellationRequest
            {
                id = Guid.NewGuid().ToString(),
                versao = Cielo.VERSION,
                tid = tid,
                dadosEc = new DadosEcElement
                {
                    numero = merchant.id,
                    chave = merchant.key
                },
                valor = total
            };

            return cancellationRequest;
        }
Example #7
0
    protected void lb3DSecureAuth_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("GBP", 999);
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        string autoSettle = "1";

        RealAuthTransactionResponse resp = RealAuthorisation.RealAuth3DSecureVerifyEnrolled(merchant, order, card, timestamp);

        //00 is enrolled
        //110 is not enrolled, should be sent to Attempt ACS server is available
        if (resp.ResultCode == 00 || resp.ResultCode == 110)
        {
            string paReq = resp.PaReq;
            string url = resp.URL;

            if(paReq != "" && url != "")
            {
                _3DSecure tdSecure = new _3DSecure("", "", "", paReq, url);
                //resp = RealAuthorisation.RealAuth3DSecureVerifySig(merchant, order, card, tdSecure, timestamp);
            }

        }

        string termUrlPrefix = Request.ServerVariables["HTTPS"] == "ON" ? "https://" : "http://";
        string termUrl = string.Format("{0}{1}",
        termUrlPrefix,
        Request.Url.Authority + "/3DSResponse.aspx");

        pnlACS.Visible = true;

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.ResultMessage;
    }
    protected void lbEditPayer_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        string timestamp = Common.GenerateTimestamp();

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("123123wdfsdf", "GBP", 00);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);

        RealVaultTransactionResponse resp = RealVault.PayerEdit(timestamp, merchant, order, payer, new ArrayList());

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
    protected void lbCancelCard_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "First", "Second", "", address, numbers, "", new ArrayList());

        string cardRef = "card1";

        string timestamp = Common.GenerateTimestamp();

        RealVaultTransactionResponse resp = RealVault.CardCancelCard(timestamp, cardRef, merchant, payer);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
        public static TokenRequest create(Merchant merchant, Holder holder)
        {
            var tokenRequest = new TokenRequest
            {
                id = Guid.NewGuid().ToString(),
                versao = Cielo.VERSION,
                dadosEc = new DadosEcElement
                {
                    numero = merchant.id,
                    chave = merchant.key
                },
                dadosPortador = new DadosPortadorElement
                {
                    numero = holder.number,
                    validade = holder.expiration,
                    nomePortador = holder.name
                }
            };

            return tokenRequest;
        }
Example #11
0
 private void button1_Click(object sender, EventArgs e)
 {
   
         DPrint<HisenseTemplate> dp = new DPrint<HisenseTemplate>();
         //Product p = new Product("lg", i);
         //Merchant<Product> merchant = new Merchant<Product>(p);
         HisenseTemplate ht = new HisenseTemplate("Germany/Hisense", "M142124", "1133597", "Bracket", @"\RSAG8.078.3573\HB\ROH\SKD", 10, "2014-09-03", @"Hisense co./LHD32D33SEU", "S3TE32M142SM142");
         Merchant<HisenseTemplate> merchant = new Merchant<HisenseTemplate>(ht);
         //ImagePrinter Argox CP-2140 PPLB
         double[] a=new double[6];
         a[0] = 12;
         a[1] = 7.4;
         a[2] = 0.05;
         a[3] = 0.05;
         a[4] = 0.05;
         a[5] = 0.05;
         dp.Run("ImagePrinter", @"..\..\HisenseTemplate.rdlc", merchant.GetProducts(),a);
     
     
     
 }
    protected void lblbRecieptIn_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("GBP", 9999);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        //only needed if
        //string cvn = "123";
        string cardRef = "card1";
        string autoSettle = "1";

        //not needed if not a recurring payment, use reciept in overload without recurring
        bool recurring = true;

        //fixed or variable
        //fixed - order amount is the same every transaction
        //variable - order amount is different in every transaction
        string recurringType = "variable";

        //first - first payment in a sequence
        //subsequent - any subsequent payments after the initial
        //final - no more payments in sequence will follow
        string recurringSequence = "first";

        RealVaultTransactionResponse resp = RealVault.RecieptIn(merchant, order, payer, cardRef, autoSettle, timestamp, new ArrayList(), recurring, recurringType, recurringSequence);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
Example #13
0
        //商户修改密码
        public int UpdMerchantPassword(Merchant m)
        {
            string sql = $"UPDATE Merchant SET Password='******' WHERE Mid={m.Mid}";

            return(DB.ExceuteNonQuery(sql));
        }
Example #14
0
        //商户登录
        public int MerchatLogin(Merchant m)
        {
            string sql = $"SELECT * FROM Merchant WHERE Accoun='{m.Accoun}' and Password='******'";

            return(Convert.ToInt32(DB.ExecuteScalar(sql)));
        }
    //    public void executeTaskWithRouting()  {
    //    MerchantUserTask task = new MerchantUserTask(2);
    //    Merchant merchant = new Merchant ();
    //    merchant.setId (2);
    //    HashSet<int?>  result =proxy.Execute(task,merchant);
    // Route the task to partion 2
    //    AsyncFuture<HashSet<Long>> result = proxy.execute(task, 2);
    //HashSet<Long> hashSet = result.get();
    //}
    public void executeTaskWithRoutingPOJO()
    {
        MerchantUserTask task = new MerchantUserTask(2);

        Merchant merchant = new Merchant();
        merchant.Id=2;

        HashSet<long?>  result = proxy.Execute(task,merchant);

        //	AsyncFuture<HashSet<Long>> result = proxy.execute(task, merchant);
        //HashSet<Long> hashSet = result.get();
    }
Example #16
0
 internal virtual void Execute <TModel, TResponse>(Merchant merchant, IRequest <TModel, TResponse> request)
     where TResponse : IResponse
     where TModel : IModel
 {
 }
Example #17
0
        //Calls map event and returns string
        public string DetermineEvent(int playerNum, Die die)
        {
            // Set the player GameObject and its Player script
            player = GameMaster.Instance.GetPlayerObject(playerNum);
            playerScript = GameMaster.Instance.GetPlayerScript(playerNum);

            // Set the Merchant entity for convienience
            playerMerchant = (Merchant)playerScript.Entity;

            // Get the inventory script
            inventory = GameObject.Find("Canvas").transform.Find("Inventory").GetComponent<Inventory>();

            // Get the tile at the player's position
            Vector3 tmp = player.transform.localPosition;

            // Fix the z-axis; change by Damien to get the tiles to work again.
            tmp.z = -0.01f;
            Tile currentTile = TileDictionary.GetTile(TileManager.ToPixels(tmp));

            // Was a tile found?
            if(currentTile == null)
            {
                // No tile found so return "This is not a valid \ntile. No event occured.";
                guiResult = "This is not a valid \ntile. No event occured.";
                return "Nothing";
            } // end if
            // Otherwise, was the tile a non-resource?
            else if (currentTile.ResourceType == ResourceType.None)
            {
                // Roll a die to get a number from 1-100
                if (die == null)
                {
                    Debug.LogError("ME: die is null!");
                }
                int dieResult = die.Roll (1, 100);

                // Check for an enemy
                if(dieResult < enemyChance)
                {
                    return ResolveFight(die);
                } // end if
                // Check for an ally
                else if (dieResult < allyChance + enemyChance && dieResult >= enemyChance)
                {
                    return "Ally";
                } // end else if
                // Check for an item
                else if(dieResult < itemChance + allyChance + enemyChance && dieResult >= allyChance + enemyChance)
                {
                    return ResolveItem(die);
                } // end else if
                else
                {
                    // The MapEvent was nothing
                    guiResult = "No map event occured.";
                    return "Nothing";
                } // end else
            } //end if
            // Otherwise, the tile is a resource
            else
            {
                // Get the resource from the database
                Item temp = ItemDatabase.Instance.Items.Find(resource => resource.Type == currentTile.ResourceType.ToString());

                // Pick up the resource
                playerMerchant.PickupResource((Resource)temp, 1);

                // Declare what was landed on
                guiResult = "You got a resource:\n" + temp.Name;

                // Play found for what was landed on
                if(temp.Name == "Fish")
                {
                    // Play fish sound
                    AudioManager.Instance.PlayFish();
                } // end if
                else if(temp.Name == "Wood")
                {
                    // Play wood sound
                    AudioManager.Instance.PlayWood();
                } // end else if
                else if(temp.Name == "Wool")
                {
                    // Play wool sound
                    AudioManager.Instance.PlayShear();
                } // end else if
                else
                {
                    // Play ore sound
                    AudioManager.Instance.PlayMine();
                } // end else
                return guiResult;
            } // end else
        }
 public void GetMerchant(int ID)
 {
     // Get the Merchant's reference
     merchant = (Merchant)EntityManager.Instance.GetEntity(ID);
 }
Example #19
0
        static private void ApplyVanillaStatModifier(ref float price, Item item, Character player, Merchant merchant, bool isSelling)
        {
            float vanillaModifierIncrease = isSelling ? player.GetItemSellPriceModifier(merchant, item) + merchant.GetItemSellPriceModifier(player, item)
                                                       : player.GetItemBuyPriceModifier(merchant, item) + merchant.GetItemBuyPriceModifier(player, item);

            price *= 1f + vanillaModifierIncrease;
        }
Example #20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var publicKey  = Configuration["Merchant:Public_Key"];
            var privateKey = Configuration["Merchant:Private_Key"];

            IMerchant merchant = new Merchant
            {
                PublicKey  = publicKey,
                PrivateKey = privateKey
            };

            services.AddDbContext <ETicketDataContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DatabaseConnectionString")));
            services.AddTransient <IUnitOfWork, UnitOfWork>(e => new UnitOfWork(e.GetService <ETicketDataContext>()));

            services.AddTransient <ITicketService, TicketService>();
            services.AddTransient <ITicketTypeService, TicketTypeService>();
            services.AddTransient <ICarrierService, CarrierService>();
            services.AddTransient <IUserService, UserService>();
            services.AddTransient <IMailService, MailService>();
            services.AddTransient <IDocumentTypesService, DocumentTypesService>();
            services.AddTransient <ITransactionService, TransactionService>();
            services.AddTransient <IPriceListService, PriceListService>();
            services.AddTransient <IAreaService, AreaService>();
            services.AddTransient <ITicketVerificationService, TicketVerificationService>();
            services.AddTransient <IPrivilegeService, PrivilegeService>();
            services.AddTransient <IDocumentService, DocumentService>();
            services.AddTransient <IRouteService, RouteService>();
            services.AddTransient <IStationService, StationService>();

            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddEntityFrameworkStores <ETicketDataContext>()
            .AddDefaultTokenProviders()
            .AddTokenProvider(AuthOptions.ISSUER, typeof(DataProtectorTokenProvider <IdentityUser>));

            services.AddIdentityCore <IdentityUser>(o =>
            {
                o.Password.RequireDigit           = false;
                o.Password.RequireLowercase       = false;
                o.Password.RequireUppercase       = false;
                o.Password.RequireNonAlphanumeric = false;
                o.Password.RequiredLength         = 4;
            });
            const string jwtSchemeName = "JwtBearer";

            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = jwtSchemeName;
                options.DefaultChallengeScheme    = jwtSchemeName;
            })
            .AddJwtBearer(jwtSchemeName, jwtBearerOptions =>
            {
                jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = AuthOptions.GetSymmetricSecurityKey(),

                    ValidateIssuer = true,
                    ValidIssuer    = AuthOptions.ISSUER,

                    ValidateAudience = true,
                    ValidAudience    = AuthOptions.AUDIENCE,

                    ValidateLifetime = true,

                    ClockSkew = TimeSpan.FromSeconds(5)
                };
            });

            services.AddControllers();
            services.AddSingleton <IMerchant>(merchant);

            services.AddTransient <IMailService, MailService>();
            services.AddTransient <IUserService, UserService>();
            services.AddTransient <ISecretCodeService, SecretCodeService>();


            services.AddSwaggerGen(c =>
            {
                c.EnableAnnotations();
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "ETicket API", Version = "v1"
                });
            });
        }
Example #21
0
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="merchant">The merchant.</param>
        /// <returns></returns>
        public MerchantResponse ConvertFrom(Merchant merchant,
                                            MerchantBalance merchantBalance = null)
        {
            if (merchant == null)
            {
                return(null);
            }

            MerchantResponse merchantResponse = new MerchantResponse
            {
                EstateId     = merchant.EstateId,
                MerchantId   = merchant.MerchantId,
                MerchantName = merchant.MerchantName,
            };

            if (merchant.Addresses != null && merchant.Addresses.Any())
            {
                merchantResponse.Addresses = new List <AddressResponse>();

                merchant.Addresses.ForEach(a => merchantResponse.Addresses.Add(new AddressResponse
                {
                    AddressId    = a.AddressId,
                    Town         = a.Town,
                    Region       = a.Region,
                    PostalCode   = a.PostalCode,
                    Country      = a.Country,
                    AddressLine1 = a.AddressLine1,
                    AddressLine2 = a.AddressLine2,
                    AddressLine3 = a.AddressLine3,
                    AddressLine4 = a.AddressLine4
                }));
            }

            if (merchant.Contacts != null && merchant.Contacts.Any())
            {
                merchantResponse.Contacts = new List <ContactResponse>();

                merchant.Contacts.ForEach(c => merchantResponse.Contacts.Add(new ContactResponse
                {
                    ContactId           = c.ContactId,
                    ContactPhoneNumber  = c.ContactPhoneNumber,
                    ContactEmailAddress = c.ContactEmailAddress,
                    ContactName         = c.ContactName
                }));
            }

            if (merchant.Devices != null && merchant.Devices.Any())
            {
                merchantResponse.Devices = new Dictionary <Guid, String>();

                foreach ((Guid key, String value) in merchant.Devices)
                {
                    merchantResponse.Devices.Add(key, value);
                }
            }

            if (merchant.Operators != null && merchant.Operators.Any())
            {
                merchantResponse.Operators = new List <MerchantOperatorResponse>();

                merchant.Operators.ForEach(a => merchantResponse.Operators.Add(new MerchantOperatorResponse
                {
                    Name           = a.Name,
                    MerchantNumber = a.MerchantNumber,
                    OperatorId     = a.OperatorId,
                    TerminalNumber = a.TerminalNumber
                }));
            }

            // Only include the balance if the dto fed in is not null
            if (merchantBalance != null)
            {
                merchantResponse.AvailableBalance = merchantBalance.AvailableBalance;
                merchantResponse.Balance          = merchantBalance.Balance;
            }

            return(merchantResponse);
        }
Example #22
0
 internal override void Execute(Merchant merchant)
 {
     GatewayData.Remove("notify_url");
     GatewayData.Remove("appid");
     GatewayData.Remove("sign_type");
 }
Example #23
0
        ProcessPaymentResult IPaymentMethod.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            //var model = new PaymentInfoModel
            //{
            //    CardholderName = processPaymentRequest.CreditCardName,
            //    CardNumber = processPaymentRequest.CreditCardNumber,
            //    CardCode = processPaymentRequest.CreditCardCvv2,
            //    ExpireMonth = processPaymentRequest.CreditCardExpireMonth.ToString(),
            //    ExpireYear = processPaymentRequest.CreditCardExpireYear.ToString(),
            //    ParcelsQtd = processPaymentRequest.ParcelsQtd.ToString()
            //};

            Merchant prd = new Merchant(
                Guid.Parse(_CieloPaymentSettings.MerchantID),
                _CieloPaymentSettings.MerchantKey);

            api = new CieloApi(CieloEnvironment.Production, prd);

            var customer = new Customer(name: processPaymentRequest.CreditCardName);

            DateTime dtExpire = new DateTime(processPaymentRequest.CreditCardExpireYear, processPaymentRequest.CreditCardExpireMonth, 01);

            var creditCard = new CreditCard(
                cardNumber: processPaymentRequest.CreditCardNumber,
                holder: processPaymentRequest.CreditCardName,
                expirationDate: dtExpire,
                securityCode: processPaymentRequest.CreditCardCvv2,
                brand: CardBrand.Visa);

            var payment = new ApiCielo.Payment(
                amount: processPaymentRequest.OrderTotal,
                currency: ApiCielo.Currency.BRL,
                installments: processPaymentRequest.ParcelsQtd,
                capture: true,
                softDescriptor: "ECommerce",
                creditCard: creditCard);

            /* store order number */
            var merchantOrderId = new Random().Next();

            var transaction = new Transaction(
                merchantOrderId: merchantOrderId.ToString(),
                customer: customer,
                payment: payment
                );

            Transaction          returnTransaction = api.CreateTransaction(Guid.NewGuid(), transaction);
            ProcessPaymentResult result            = new ProcessPaymentResult();

            switch (returnTransaction.Payment.Status)
            {
            case ApiCielo.Status.Aborted:

                break;

            case ApiCielo.Status.Authorized:
                result.NewPaymentStatus = PaymentStatus.Authorized;
                break;

            case ApiCielo.Status.Denied:
                result.NewPaymentStatus = PaymentStatus.Pending;
                break;

            case ApiCielo.Status.NotFinished:
                result.NewPaymentStatus = PaymentStatus.Pending;
                break;

            case ApiCielo.Status.PaymentConfirmed:
                result.NewPaymentStatus = PaymentStatus.Paid;
                break;

            case ApiCielo.Status.Pending:
                result.NewPaymentStatus = PaymentStatus.Pending;
                break;

            case ApiCielo.Status.Refunded:
                result.NewPaymentStatus = PaymentStatus.Refunded;
                break;

            case ApiCielo.Status.Scheduled:
                result.NewPaymentStatus = PaymentStatus.Pending;
                break;

            case ApiCielo.Status.Voided:
                result.NewPaymentStatus = PaymentStatus.Voided;
                break;

            default:
                result.AddError("Não Suportado");
                break;
            }

            result.AuthorizationTransactionId     = returnTransaction.Payment.PaymentId.ToString();
            result.AuthorizationTransactionCode   = returnTransaction.Payment.AuthorizationCode;
            result.AuthorizationTransactionResult = returnTransaction.Payment.ReturnMessage;

            //  result.CaptureTransactionId =

            return(result); // new ProcessPaymentResult { Errors = new[] { "Impmentar " } };
        }
Example #24
0
 public void Open()
 {
     Character.SetDialog(this);
     Merchant.OnDialogOpened(this);
     InventoryHandler.SendExchangeStartOkHumanVendorMessage(Character.Client, Merchant);
 }
Example #25
0
 static bool Item_GetSellValue_Pre(Item __instance, ref int __result, ref Character _player, ref Merchant _merchant)
 {
     __result = GetFinalModifiedPrice(__instance, _player, _merchant, true);
     return(false);
 }
Example #26
0
 public bool CanBuy(MerchantItem item, int amount) => Character.Inventory.Kamas >= item.Price * amount || !Merchant.CanBeSee(Character);
Example #27
0
        public BaseResponse Index([FromUri] RequestData model)
        {
            var watcher = new Stopwatch();

            watcher.Start();

            var          response   = new BaseResponse();
            BaseResponse exResponse = null;

            var         requestId             = string.Empty;
            var         requestDataJson       = string.Empty;
            var         userDataJson          = string.Empty;
            var         logMsg                = new ApiLogMessage();
            var         bizCode               = string.Empty;
            var         urlEncodedUserData    = string.Empty;
            var         urlEncodedRequestData = string.Empty;
            var         parmUserData          = string.Empty;
            var         parmRequestData       = string.Empty;
            BaseRequest baseRequest           = null;
            Merchant    merchant              = null;

            try
            {
                if (model.IsNull() || model.Cmd.IsNullOrWhiteSpace())
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "无效请求", null, 0));
                }
                bizCode = ProcessorUtil.GetBizCode(model.Cmd);
                if (bizCode.IsNullOrWhiteSpace())
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.无效交易类型, "无效交易类型", null, 0));
                }
                baseRequest = ProcessorUtil.GetRequest(bizCode, model.ToJson());
                if (baseRequest == null)
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "无效请求", null, 0));
                }
                //验证参数
                var errMsg = "";
                if (!ModelVerify(baseRequest, out errMsg))
                {
                    response = BaseResponse.Create(ApiEnum.ResponseCode.参数不正确, errMsg, null, 0);
                    return(response);
                }

                //商户校验
                if (!MerchantVerify(baseRequest, out merchant, out errMsg))
                {
                    response = BaseResponse.Create(ApiEnum.ResponseCode.处理失败, errMsg, null, 0);
                    return(response);
                }

                //验证签名
                if (!VerifySign(baseRequest, merchant))
                {
                    response = BaseResponse.Create(ApiEnum.ResponseCode.无效调用凭证, "签名不正确", null, 0);
                    return(response);
                }
                var processor = this.factory.Create(bizCode);
                response = processor.Process(baseRequest);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                response       = BaseResponse.Create(ApiEnum.ResponseCode.系统内部错误, "不好意思,程序开小差,正在重启" + ex.ToString(), 0);
                exResponse     = BaseResponse.Create(ApiEnum.ResponseCode.系统内部错误, ex.ToString(), 0);
                logMsg.IsError = true;
            }
            finally
            {
                //WriteRequestInfo(userData, requestData, requestId, bizCode);

                watcher.Stop();
                var duration = watcher.Elapsed.TotalMilliseconds;

                var logStr = string.Empty;
                logStr += string.Format("【请求报文】RequestId:{0}", requestId) + Environment.NewLine;
                logStr += string.Format("UserData:{0}", urlEncodedUserData) + Environment.NewLine;
                logStr += string.Format("RequestData:{0}", urlEncodedRequestData) + Environment.NewLine;
                logStr += string.Format("【响应报文】{0}", response.ToJson());
                logStr += string.Format("【耗时】{0}毫秒", duration);
                log.Info(logStr.ToString());


                logMsg.UserDataStr    = urlEncodedUserData;
                logMsg.RequestDataStr = urlEncodedRequestData;
                logMsg.RequestId      = requestId;
                logMsg.LogTime        = DateTime.Now;


                logMsg.RequestJson = requestDataJson;
                logMsg.Response    = exResponse.IsNull() ? response.ToJson() : exResponse.ToJson();
                logMsg.Duration    = duration;

                if (AppConfig.LogType == LogType.MQ)
                {
                    try
                    {
                        this.bus.Publish(logMsg);
                    }
                    catch (Exception ex)
                    {
                        log.Error("写入MQ失败,RequestId:{0}\r\n{1}".Fmt("", ex.ToString()));
                    }
                }
            }

            return(response);
        }
 public void Register(Merchant merchant)
 {
     controlledMerchant = merchant;
     ControlledBackpack[1] = merchant.Backpack;
     controlledMerchant.RegisterView(singleLogMerchant);
 }
Example #29
0
 internal abstract void Execute <TModel, TResponse>(Merchant merchant, Request <TModel, TResponse> request) where TResponse : IResponse;
Example #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Seller   = MerchantHelper.GetMerchant(Int32.Parse(SellerId));
     SignList = ParamHelper.PlatformCfgData.SignList;
     _Account = AccountHelper.GetUser(Seller.Id);
 }
Example #31
0
 internal override void Execute(Merchant merchant)
 {
     GatewayData.Remove("frontUrl");
 }
Example #32
0
 public static void EnterMerchantDialogue(Merchant merchant)
 {
     pc.EnterCutscene();
     inventory.currentMerchant = merchant;
     OpenInventory();
 }
Example #33
0
 public void AddMerchant(Merchant merchant)
 {
     merchant.id = NextMerchantId;
     merchantDict.Add(NextMerchantId, merchant);
     NextMerchantId++;
 }
Example #34
0
 internal override void Execute <TModel, TResponse>(Merchant merchant, Request <TModel, TResponse> request)
 {
 }
Example #35
0
    // Update is called once per frame
    void Update()
    {
        var merchant = GameObject.FindGameObjectWithTag("Merchant");
        bool just_added_merchant = false;
        if (merchant == null) {
            var currently_in = schedule.getLowerEntry(time.getHour(), time.getMinute());
            if (currently_in.world_id == tile_map.get_map_id()) {
                // spawn merchant, he should be here
                var going_to = schedule.getUpperEntry(time.getHour(), time.getMinute());
                var cur_min = time_to_min(time.getHour(), time.getMinute());
                var currently_in_min = time_to_min(currently_in.hour, currently_in.minute);
                var going_to_min = time_to_min(going_to.hour, going_to.minute);

                var spawn_point = new Vector3();
                if (going_to.world_id != currently_in.world_id) { // not on a path, no need to calculate percent along path
                    spawn_point = new Vector3(currently_in.x_pos, 1.0f, currently_in.y_pos);
                }
                else {
                    var path = path_finder.get_path(new int[] { currently_in.x_pos, currently_in.y_pos }, new int[] { going_to.x_pos, going_to.y_pos }, tile_map.get_raw_data(), false);
                    var percent_along_path = ((float)(cur_min - currently_in_min)) / (going_to_min - currently_in_min);
                    var path_pos = (int)(percent_along_path * path.Count);
                    path_pos = path_pos < 0 ? 0 : path_pos >= path.Count ? path.Count - 1 : path_pos;
                    var spawn_point_2d = path[path_pos];
                    spawn_point = new Vector3(spawn_point_2d.x, 1.0f, spawn_point_2d.y);
                }
                merchant = Instantiate(merchant_prefab, spawn_point, Quaternion.Euler(0.0f, 270.0f, 0.0f)) as GameObject;
                Debug.Log("no merchant, adding him in");
                just_added_merchant = true;
                set_merchant_collider(merchant, false);
            }
        }
        else if (!is_moving) {
            // merchant is here, should he still be?
            var should_be_in = schedule.getLowerEntry(time.getHour(), time.getMinute());
            if (should_be_in.world_id != tile_map.get_map_id()) {
                Destroy(merchant);
                close_merchant_shop();
                Debug.Log("removing merchant from scene");
            }
        }

        if (just_added_merchant || merchant == null) {
            return;
        }

        // if merchant is still here and we didn't just place him in
        if (!is_moving) {
            var coming_from = schedule.getLowerEntry(time.getHour(), time.getMinute());
            var destination = schedule.getUpperEntry(time.getHour(), time.getMinute());

            var same_entries = coming_from.world_id == destination.world_id &&
                coming_from.x_pos == destination.x_pos &&
                coming_from.y_pos == destination.y_pos;
            var different_worlds = coming_from.world_id != destination.world_id;
            if (at_point(merchant, coming_from) && (same_entries || different_worlds)) {
                // don't move, in waiting position
                Debug.Log(string.Format("merchant is waiting until {0}:{1}", destination.hour, destination.minute));
                merchant.GetComponent<Merchant>().set_sprite_from_movement(null, null);
                set_merchant_collider(merchant, true);
                return;
            }

            var merchant_grid_pos = new int[] { (int) merchant.transform.position.x, (int) merchant.transform.position.z };
            // var new_dest = at_point(merchant, coming_from) ? destination : coming_from;
            var new_dest = destination;
            var next_path = path_finder.get_path(merchant_grid_pos, new int[] { new_dest.x_pos, new_dest.y_pos }, tile_map.get_raw_data(), false);
            if (next_path.Count == 0) {
                return;
            }
            var path_index = next_path.Count == 1 ? 0 : 1;
            var next_move = next_path[path_index];
            iTween.MoveTo(merchant, iTween.Hash(
                "position", new Vector3( next_move.x, 1.0f, next_move.y),
                "name", "merchant_move_tween",
                "time", 0.9f,
                "oncomplete", "on_tween_complete",
                "oncompletetarget", gameObject,
                "easetype", iTween.EaseType.linear
            ));
            is_moving = true;
            merchant.GetComponent<Merchant>().set_sprite_from_movement(merchant_grid_pos, new int[] { next_move.x, next_move.y });
            set_merchant_collider(merchant, false);
            close_merchant_shop();
            //Debug.Log(string.Format("Moving from ({0}, {1}) to ({2}, {3})", merchant_grid_pos[0], merchant_grid_pos[1], next_move.x, next_move.y));
        }
        else {
            //Debug.Log("still moving");
        }
    }
        public bool CreateEntity(out int entID, EntityType type, GameObject gameObject, int playerNum = 0)
        {
            // The result of creation
            bool result = false;

            // Create the proper type of entity based upon the given type
            switch (type)
            {
                case EntityType.Merchant:
                    {
                        // Create the entity
                        Merchant merchant = new Merchant(nextId, gameObject, GameMaster.Instance.GetPlayerColor(playerNum), GameMaster.Instance.GetPlayerName(playerNum));

                        // Now try to add the entity to the manager
                        if (!EntityManager.Instance.AddEntity(merchant))
                        {
                            // The entity couldn't be added to the manager so return failure
                            result = false;
                        }

                        // Return success
                        result = true;

                        break;
                    } // end case Merchant
                case EntityType.Porter:
                    {
                        // Create the entity
                        Porter porter = new Porter(nextId, gameObject);

                        // Now try to add the entity to the manager
                        if (!EntityManager.Instance.AddEntity(porter))
                        {
                            // The entity coulnd't be added to the manager so return failure
                            result = false;
                        }

                        // Return success
                        result = true;

                        break;
                    } // end case Porter
                case EntityType.Mercenary:
                    {
                        // Create the entity
                        Mercenary mercenary = new Mercenary(nextId, gameObject);

                        // Now try to add the entity to the manager
                        if (!EntityManager.Instance.AddEntity(mercenary))
                        {
                            // The entity coulnd't be added to the manager so return failure
                            result = false;
                        }

                        // Return success
                        result = true;

                        break;
                    } // end Mercenary
                case EntityType.Bandit:
                    {
                        // Create the entity
                        Bandit bandit = new Bandit(nextId, gameObject);

                        // Now try to add the entity to the manager
                        if (!EntityManager.Instance.AddEntity(bandit))
                        {
                            // The entity coulnd't be added to the manager so return failure
                            result = false;
                        }

                        // Return success
                        result = true;

                        break;
                    } // end case Bandit
                case EntityType.Mimic:
                    {
                        // Create the entity
                        Mimic mimic = new Mimic(nextId, gameObject);

                        // Now try to add the entity to the manager
                        if (!EntityManager.Instance.AddEntity(mimic))
                        {
                            // The entity coulnd't be added to the manager so return failure
                            result = false;
                        }

                        // Return success
                        result = true;

                        break;
                    } // end Mimic
            } // end switch type

            // Set the out ID variable
            entID = nextId;

            // Increment to the next ID
            nextId++;

            // Return the result
            return result;
        }
Example #37
0
        /// <summary>
        /// Create a new Hybrasyl map from an XMLMap object.
        /// </summary>
        /// <param name="newMap">An XSD.Map object representing the XML map file.</param>
        /// <param name="theWorld">A world object where the map will be placed</param>
        public Map(Maps.Map newMap, World theWorld)
        {
            Init();
            World = theWorld;

            // TODO: refactor Map class to not do this, but be a partial which overlays
            // TODO: XSD.Map
            Id         = newMap.Id;
            X          = newMap.X;
            Y          = newMap.Y;
            Name       = newMap.Name;
            EntityTree = new QuadTree <VisibleObject>(0, 0, X, Y);
            Music      = newMap.Music;

            foreach (var warpElement in newMap.Warps)
            {
                var warp = new Warp(this);
                warp.X = warpElement.X;
                warp.Y = warpElement.Y;

                if (warpElement.MapTarget != null)
                {
                    var maptarget = warpElement.MapTarget as Maps.WarpMapTarget;
                    // map warp
                    warp.DestinationMapName = maptarget.Value;
                    warp.WarpType           = WarpType.Map;
                    warp.DestinationX       = maptarget.X;
                    warp.DestinationY       = maptarget.Y;
                }
                else
                {
                    var worldmaptarget = warpElement.WorldMapTarget;
                    // worldmap warp
                    warp.DestinationMapName = worldmaptarget;
                    warp.WarpType           = WarpType.WorldMap;
                }
                if (warpElement.Restrictions?.Level != null)
                {
                    warp.MinimumLevel = warpElement.Restrictions.Level.Min;
                    warp.MaximumLevel = warpElement.Restrictions.Level.Max;
                }
                if (warpElement.Restrictions?.Ab != null)
                {
                    warp.MinimumAbility = warpElement.Restrictions.Ab.Min;
                    warp.MaximumAbility = warpElement.Restrictions.Ab.Max;
                }
                warp.MobUse = warpElement.Restrictions?.NoMobUse ?? true;
                Warps[new Tuple <byte, byte>(warp.X, warp.Y)] = warp;
            }

            foreach (var npcElement in newMap.Npcs)
            {
                var npcTemplate = World.WorldData.Get <Creatures.Npc>(npcElement.Name);
                if (npcTemplate == null)
                {
                    Logger.Error("map ${Name}: NPC ${npcElement.Name} is missing, will not be loaded");
                    continue;
                }
                var merchant = new Merchant
                {
                    X         = npcElement.X,
                    Y         = npcElement.Y,
                    Name      = npcElement.Name,
                    Sprite    = npcTemplate.Appearance.Sprite,
                    Direction = (Enums.Direction)npcElement.Direction,
                    Portrait  = npcTemplate.Appearance.Portrait,
                };
                if (npcTemplate.Roles != null)
                {
                    if (npcTemplate.Roles.Post != null)
                    {
                        merchant.Jobs ^= MerchantJob.Post;
                    }
                    if (npcTemplate.Roles.Bank != null)
                    {
                        merchant.Jobs ^= MerchantJob.Bank;
                    }
                    if (npcTemplate.Roles.Repair != null)
                    {
                        merchant.Jobs ^= MerchantJob.Repair;
                    }
                    if (npcTemplate.Roles.Train != null)
                    {
                        merchant.Jobs ^= MerchantJob.Train;
                    }
                    if (npcTemplate.Roles.Vend != null)
                    {
                        merchant.Jobs ^= MerchantJob.Vend;
                    }
                }
                InsertNpc(merchant);
            }

            foreach (var reactorElement in newMap.Reactors)
            {
                // TODO: implement reactor loading support
            }
            if (newMap.Signs != null)
            {
                foreach (var postElement in newMap.Signs.Signposts)
                {
                    var signpostElement = postElement as Maps.Signpost;
                    var signpost        = new Objects.Signpost(signpostElement.X, signpostElement.Y, signpostElement.Message);
                    InsertSignpost(signpost);
                }
                foreach (var postElement in newMap.Signs.MessageBoards)
                {
                    var boardElement = postElement as Maps.MessageBoard;
                    var board        = new Objects.Signpost(boardElement.X, boardElement.Y, string.Empty, true, boardElement.Name);
                    InsertSignpost(board);
                    Logger.InfoFormat("{0}: {1} - messageboard loaded", this.Name, board.Name);
                }
            }
            Load();
        }
Example #38
0
 public CMD(Merchant navigator, ProfileLoader profileLoader)
 {
     Navigator     = navigator;
     ProfileLoader = profileLoader;
     InitializeComponent();
 }
    protected void lbNewPayer_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        //You need to generate the following to complete any process, the following order might be helpful as well.
        //Timestamp ==> Merchant ==> Order ==> Address ==> PhoneNumbers ==> Payer ==> CreditCard ==> SHA1Hash

        //Current timestamp
        string timestamp = Common.GenerateTimestamp();

        //New Merchant
        //merchant id
        //account
        //shared secret
        Merchant merchant = new Merchant(merchantId, account, sharedSecret);

        //New Order
        //order id (optional)
        //currency code
        //order amount
        Order order = new Order("123123wdfsdf", "GBP", 1099);

        //New Address (optional)
        //Line 1 (optional)
        //Line 2 (optional)
        //Line 3 (optional)
        //City (optional)
        //County (optional)
        //Postcode (optional)
        //Country Code (optional)
        //Country Name (optional)
        Address address = new Address("", "", "", "", "", "", "", "");

        //New Phone Numbers (optional)
        //home (optional)
        //work (optional)
        //fax (optional)
        //mobile (optional)
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");

        //New Payer
        //Payer type (default to 'Business')
        //Payer ref
        //Title (optional)
        //First Name
        //Surname
        //Company (optional)
        //Address (optional)
        //Numbers (optional)
        //email (optional)
        //comments (optional)
        Payer payer = new Payer("Business", "test", "", "First", "Second", "", address, numbers, "", new ArrayList());

        //New Credit Card
        //Card type
        //Card number
        //Expiry date
        //Cardholder name
        //cvn
        //Is cvn present
        //Issue number (optional)
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);

        //Create new payer
        //timestamp
        //SHA1Hash
        //merchant
        //order
        //payer
        //comments
        RealVaultTransactionResponse resp = RealVault.PayerNew(timestamp, merchant, order, payer, new ArrayList());

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
Example #40
0
        //商户注册
        public int Merchatregister(Merchant m)
        {
            string sql = $"Call Merchantregister ('{m.Accoun}','{m.Password}')";

            return(DB.ExceuteNonQuery(sql));
        }
Example #41
0
        // Sets the player's stats for the status panels
        public void SetStats(Merchant player)
        {
            // Set the title's value
            transform.GetChild(0).GetChild(0).GetComponent<Text>().text = player.Name + "'s Inventory";

            // Set the Health status line's value
            statusLeft.GetChild(0).GetChild(1).GetComponent<Text>().text = player.Health.ToString() + "/" + player.MaxHealth.ToString();

            // Set the Attack status line's value
            statusLeft.GetChild(1).GetChild(1).GetComponent<Text>().text = player.AttackPower.ToString();

            // Set the Defence status line's value
            statusLeft.GetChild(2).GetChild(1).GetComponent<Text>().text = player.DefencePower.ToString();

            // Set the Weight status line's value
            statusLeft.GetChild(3).GetChild(1).GetComponent<Text>().text = player.TotalWeight.ToString() + "/" + player.MaxWeight.ToString();

            // Set the Gold status line's value
            statusRight.GetChild(0).GetChild(1).GetComponent<Text>().text = player.Currency.ToString();

            // Set the Profit status line's value
            statusRight.GetChild(1).GetChild(1).GetComponent<Text>().text = player.TotalWorth.ToString();
        }
Example #42
0
 public MerchantShopDialog(Merchant merchant, Character character)
 {
     Merchant  = merchant;
     Character = character;
 }
Example #43
0
        public Merchant GetMerchantByUserID(Guid userID)
        {
            Merchant merchant = null;
            _log.DebugFormat("dbo.GetMerchantByUserID: userID={0}", userID);
            try
            {
                merchant = new Merchant();
                AddSQLParameter("@UserID", SqlDbType.UniqueIdentifier, userID);
                DataSet ds = GetDatasetByCommand("dbo.GetMerchantByUserID");
                DataRowCollection rows = ds.Tables[0].Rows;
                foreach (DataRow row in rows)
                {
                    merchant.ID = Convert.ToInt64(row["ID"]);
                    merchant.UserID = (Guid)row["UserID"];
                    merchant.MerchantName = (row["MerchantName"] == DBNull.Value) ? "" : Convert.ToString(row["MerchantName"]);
                    merchant.UserName = Convert.ToString(row["UserName"]);

                    merchant.FirstName = (row["FirstName"] == DBNull.Value) ? "" : Convert.ToString(row["FirstName"]);
                    merchant.LastName = (row["LastName"] == DBNull.Value) ? "" : Convert.ToString(row["LastName"]);
                    merchant.Email = (row["Email"] == DBNull.Value) ? "" : Convert.ToString(row["Email"]);
                    merchant.PhoneNumber = (row["PhoneNumber"] == DBNull.Value) ? "" : Convert.ToString(row["PhoneNumber"]);
                    merchant.Description = (row["Description"] == DBNull.Value) ? "" : Convert.ToString(row["Description"]);

                    merchant.FirstNameBilling = (row["FirstNameBilling"] == DBNull.Value) ? "" : Convert.ToString(row["FirstNameBilling"]);
                    merchant.LastNameBilling = (row["LastNameBilling"] == DBNull.Value) ? "" : Convert.ToString(row["LastNameBilling"]);
                    merchant.EmailBilling = (row["EmailBilling"] == DBNull.Value) ? "" : Convert.ToString(row["EmailBilling"]);
                    merchant.PhoneNumberBilling = (row["PhoneNumberBilling"] == DBNull.Value) ? "" : Convert.ToString(row["PhoneNumberBilling"]);
                    merchant.DescriptionBilling = (row["DescriptionBilling"] == DBNull.Value) ? "" : Convert.ToString(row["DescriptionBilling"]);
                    merchant.Address = (row["Address"] == DBNull.Value) ? "" : Convert.ToString(row["Address"]);
                    merchant.Address2 = (row["Address2"] == DBNull.Value) ? "" : Convert.ToString(row["Address2"]);
                    merchant.City = (row["City"] == DBNull.Value) ? "" : Convert.ToString(row["City"]);
                    merchant.State = (row["State"] == DBNull.Value) ? "" : Convert.ToString(row["State"]);
                    merchant.Zip = (row["Zip"] == DBNull.Value) ? "" : Convert.ToString(row["Zip"]);

                    merchant.CreatedDate = (row["CreatedDate"] == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["CreatedDate"]);
                    merchant.UpdatedDate = (row["UpdatedDate"] == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["UpdatedDate"]);
                    merchant.Deleted = Convert.ToBoolean(row["Deleted"]);
                }

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Exception Occured: Exception={0}", ex);
            }

            return merchant;
        }
Example #44
0
 public void Close()
 {
     InventoryHandler.SendExchangeLeaveMessage(Character.Client, DialogType, false);
     Character.CloseDialog(this);
     Merchant.OnDialogClosed(this);
 }
Example #45
0
        public bool AddMerchant(Merchant merchant)
        {
            bool success = false;
            _log.DebugFormat(@"dbo.AddMerchant: ID={0},
                            UserID={1},
                            FirstName{2},
                            LastName{3},
                            MerchantName={4}
                            Description={5},
                            Email={6},
                            PhoneNumber={7},
                            Address={8},
                            CreatedDate={9},
                            UpdatedDate={10},
                            Deleted={11}",
                             merchant.ID,
                             merchant.UserID,
                             merchant.FirstName,
                             merchant.LastName,
                             merchant.Description,
                             merchant.Email,
                             merchant.PhoneNumber,
                             merchant.Address,
                             merchant.CreatedDate,
                             merchant.UpdatedDate,
                             merchant.Deleted,
                             merchant.MerchantName
                             );
            try
            {
                AddSQLParameter("@UserID", SqlDbType.UniqueIdentifier, merchant.UserID);
                AddSQLParameter("@MerchantName", SqlDbType.NVarChar, merchant.MerchantName);

                AddSQLParameter("@FirstName", SqlDbType.NVarChar, merchant.FirstName);
                AddSQLParameter("@LastName", SqlDbType.NVarChar, merchant.LastName);
                AddSQLParameter("@Email", SqlDbType.NVarChar, merchant.Email);
                AddSQLParameter("@PhoneNumber", SqlDbType.NVarChar, merchant.PhoneNumber);
                AddSQLParameter("@Description", SqlDbType.NVarChar, merchant.Description);

                AddSQLParameter("@FirstNameBilling", SqlDbType.NVarChar, merchant.FirstNameBilling);
                AddSQLParameter("@LastNameBilling", SqlDbType.NVarChar, merchant.LastNameBilling);
                AddSQLParameter("@EmailBilling", SqlDbType.NVarChar, merchant.EmailBilling);
                AddSQLParameter("@PhoneNumberBilling", SqlDbType.NVarChar, merchant.PhoneNumberBilling);
                AddSQLParameter("@DescriptionBilling", SqlDbType.NVarChar, merchant.DescriptionBilling);
                AddSQLParameter("@Address", SqlDbType.NVarChar, merchant.Address);
                AddSQLParameter("@Address2", SqlDbType.NVarChar, merchant.Address2);
                AddSQLParameter("@City", SqlDbType.NVarChar, merchant.City);
                AddSQLParameter("@State", SqlDbType.NVarChar, merchant.State);
                AddSQLParameter("@Zip", SqlDbType.NVarChar, merchant.Zip);

                AddSQLParameter("@Deleted", SqlDbType.Bit, merchant.Deleted);
                GetExecuteNonQueryByCommand("dbo.AddMerchant");
                success = true;
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Exception Occured: Exception={0}", ex);
            }

            return success;
        }
Example #46
0
 public void InsertNpc(Merchant toInsert)
 {
     World.Insert(toInsert);
     Insert(toInsert, toInsert.X, toInsert.Y);
     toInsert.OnSpawn();
 }
        //Calls map event and returns string
        public string DetermineEvent(int playerNum, Die die)
        {
            // Set the player GameObject and its Player script
            player = GameMaster.Instance.GetPlayerObject(playerNum);
            playerScript = GameMaster.Instance.GetPlayerScript(playerNum);

            // Set the Merchant entity for convienience
            playerMerchant = (Merchant)playerScript.Entity;

            // Get the inventory script
            inventory = GameObject.Find("Canvas").transform.Find("PlayerInventory").GetComponent<PlayerInventory>();

            // Get the player's position
            Vector3 tmp = player.transform.localPosition;

            // Get the tile manager's reference
            TileManager tileManager = GameObject.Find("TileManager").GetComponent<TileManager>();

            // Get the resource type of the tile
            ResourceType resourceTileType = tileManager.GetResourceType(tmp);
            // Get the market type of the tile
            MarketType marketTileType = tileManager.GetMarketType(tmp);

            // Was the tile type a non-resource and non-market?
            if (resourceTileType == ResourceType.None && marketTileType == MarketType.None)
            {
                // Roll a die to get a number from 1-100
                if (die == null)
                {
                    Debug.LogError("ME: die is null!");
                }
                int dieResult = die.Roll (1, 100);

                // Check for an enemy
                if(dieResult < enemyChance)
                {
                    return ResolveFight(die);
                } // end if
                // Check for an ally
                else if (dieResult < allyChance + enemyChance && dieResult >= enemyChance)
                {
                    return "Ally";
                } // end else if
                // Check for an item
                else if(dieResult < itemChance + allyChance + enemyChance && dieResult >= allyChance + enemyChance)
                {
                    return ResolveItem(die);
                } // end else if
                else
                {
                    // The MapEvent was nothing
                    guiResult = "No map event occured.";
                    return "Nothing";
                } // end else
            } //end if
            // Otherwise, the tile type is a resource or market
            else
            {
                // Check if the tile is not a market
                if (marketTileType == MarketType.None)
                {
                    // Get the resource from the database
                    Item temp = ItemDatabase.Instance.Items.Find(resource => resource.Type == resourceTileType.ToString());

                    // Attempt to pick up the resource
                    if (playerMerchant.PickupResource((Resource)temp, 1))
                    {
                        // Declare what was landed on
                        guiResult = "You got a resource:\n" + temp.Name;
                    } // end if
                    else
                    {
                        // Otherwise, there is no space for the resource or it's too heavy
                        guiResult = "Unable to pickup the \n" + temp.Name;
                    } // end else

                    // Play found for what was landed on
                    if (temp.Name == "Fish")
                    {
                        // Play fish sound
                        AudioManager.Instance.PlayFish();
                    } // end if
                    else if (temp.Name == "Wood")
                    {
                        // Play wood sound
                        AudioManager.Instance.PlayWood();
                    } // end else if
                    else if (temp.Name == "Wool")
                    {
                        // Play wool sound
                        AudioManager.Instance.PlayShear();
                    } // end else if
                    else
                    {
                        // Play ore sound
                        AudioManager.Instance.PlayMine();
                    } // end else

                    return guiResult;
                } // end if
                // Otherwise the tile is a market
                else
                {
                    // Check which type of market the player is one
                    if (marketTileType == MarketType.Market)
                    {
                        // The player landed on regular market
                        return "Market";
                    } // end if
                    else
                    {
                        // The player landed on the end game village
                        return "Village";
                    } // end else
                } // end else
            } // end else
        }
 // Return a collection of Merchants
 public Merchant[] findAllMerchants()
 {
     Merchant template = new Merchant();
     return Proxy.ReadMultiple<Merchant>(template);
 }
Example #49
0
        public ActionResult ImportExcel(HttpPostedFileBase upload)
        {
            using (var stream = upload.InputStream)
            {
                IExcelDataReader reader;

                reader = ExcelDataReader.ExcelReaderFactory.CreateReader(stream);

                var conf = new ExcelDataSetConfiguration()
                {
                    ConfigureDataTable = _ => new ExcelDataTableConfiguration
                    {
                        UseHeaderRow = true
                    }
                };


                var dataSet   = reader.AsDataSet(conf);
                var dataTable = dataSet.Tables[0];
                int count     = 0;
                while (reader.Read())
                {
                    if (count > 0)
                    {
                        int chiTietDonHangID = Int32.Parse(reader.GetString(0)),
                            statusOrder      = (int)reader.GetDouble(7);
                        var ctdonhang        = db.ChiTietDonHangs.Find(chiTietDonHangID);

                        ctdonhang.TinhTrangDonHangID = statusOrder;
                        if (statusOrder == 4)
                        {
                            MailHelper.SendMailOrderReceived(ctdonhang.DonHang.Customer.Email, "KnowledgeStore thông báo tình trạng đơn hàng", ctdonhang.ChiTietDonHangID.ToString(), ctdonhang.DonHang.Customer.HoTen, "giao thành công!!!", System.DateTime.Now.ToString("dd/MM/yyyy"));
                            ctdonhang.NgayXuat = System.DateTime.Now;
                            if (db.ChiTietDonHangs.Where(m => m.MerchantID == ctdonhang.MerchantID & m.TinhTrangDonHangID == 4).Count() % 10 == 9)
                            {
                                Merchant mer = db.Merchants.Find(ctdonhang.MerchantID);
                                mer.SoLuongKIPXu += 10;
                                db.LichSuGiaoDichXuCuaMerchants.Add(new LichSuGiaoDichXuCuaMerchant()
                                {
                                    MerchantID = mer.MerchantID, NgayGiaoDich = System.DateTime.Now, PhuongThucSuDung = "Chương trinh khuyến mãi 10 đơn hàng", SoXu = 10
                                });
                            }
                        }
                        else if (statusOrder == 5)
                        {
                            MailHelper.SendMailOrderReceived(ctdonhang.DonHang.Customer.Email, "KnowledgeStore thông báo tình trạng đơn hàng", ctdonhang.ChiTietDonHangID.ToString(), ctdonhang.DonHang.Customer.HoTen, "đã giao thất bại, xu hoa hồng đc hoàn trả cho quí khách", System.DateTime.Now.ToString("dd/MM/yyyy"));
                            var xuHoaHong = db.LichSuHoaHongs.Where(m => m.ChiTietDonHangID == ctdonhang.ChiTietDonHangID).Select(m => m.GiaTriXu).FirstOrDefault();
                            db.LichSuHoaHongs.Add(new LichSuHoaHong()
                            {
                                ChiTietDonHangID = ctdonhang.ChiTietDonHangID, GiaTriXu = -xuHoaHong, ThoiDiem = System.DateTime.Now
                            });
                            Merchant mer = db.Merchants.Find(ctdonhang.MerchantID);
                            mer.SoLuongKIPXu   = mer.SoLuongKIPXu - (xuHoaHong);
                            ctdonhang.NgayXuat = System.DateTime.Now;
                        }
                        db.SaveChanges();
                    }
                    count++;
                }
                var result = db.ChiTietDonHangs.ToList();



                ViewBag.HoaHong        = db.HoaHongs.Where(p => p.TrangThai == true).First().PhanTranHoaHong;
                ViewBag.DropdownStatus = new SelectList(db.TinhTrangDonHangs, "TinhTrangDonHangID", "TinhTrangDonHang1");
                var listCTDH = db.ChiTietDonHangs.OrderByDescending(m => m.DonHang.NgayDat).ToList();
                return(View("Index", listCTDH));
            }
        }
        public override IList <Merchant> ImportVisaMidFile(Stream fileStream)
        {
            IList <Merchant> lstMerchants = new List <Merchant>();

            try
            {
                HashSet <string> visaMids    = new HashSet <string>();
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileStream);
                excelReader.IsFirstRowAsColumnNames = true;

                DataSet   storeDataSet   = excelReader.AsDataSet();
                DataTable storeDataTable = storeDataSet.Tables[0];
                if (storeDataTable != null)
                {
                    Log.Info("Total Rows in VisaMid File is {0}", storeDataTable.Rows.Count);
                    var lstMerchantData = GetDataFromSpecifiedColumns(storeDataTable, VisaImportList);
                    Log.Info("Total Rows read from VisaMid File is {0}", lstMerchantData.Count);

                    foreach (var merchantData in lstMerchantData)
                    {
                        Merchant existingMerchant = null;

                        //Check if we have already seen this merchant in this spreadsheet based on the PartnerMerchantId of the merchant
                        string partnerMerchantId = merchantData.ContainsKey(MerchantConstants.PartnerMerchantId) ? merchantData[MerchantConstants.PartnerMerchantId] : null;
                        if (!string.IsNullOrEmpty(partnerMerchantId))
                        {
                            existingMerchant = lstMerchants.FirstOrDefault(m => m.PartnerMerchantId == merchantData[MerchantConstants.PartnerMerchantId]);
                        }
                        if (existingMerchant == null)
                        {
                            Merchant merchant = CreateMerchant(merchantData);
                            merchant.PartnerMerchantId = partnerMerchantId;
                            Payment payment = CreateVisaPayment(merchantData, visaMids);
                            merchant.Payments = new List <Payment>();
                            merchant.Payments.Add(payment);

                            merchant.ExtendedAttributes = new Dictionary <string, string>();
                            string visaMidName = merchantData.ContainsKey(MerchantConstants.VisaMidName) ? merchantData[MerchantConstants.VisaMidName] : null;
                            string visaSidName = merchantData.ContainsKey(MerchantConstants.VisaSidName) ? merchantData[MerchantConstants.VisaSidName] : null;
                            if (!string.IsNullOrEmpty(visaMidName))
                            {
                                merchant.ExtendedAttributes.Add(MerchantConstants.VisaMidName, visaMidName);
                            }
                            if (!string.IsNullOrEmpty(visaSidName))
                            {
                                merchant.ExtendedAttributes.Add(MerchantConstants.VisaSidName, visaSidName);
                            }
                            lstMerchants.Add(merchant);
                        }
                        else
                        {
                            Payment payment = CreateVisaPayment(merchantData, visaMids);
                            existingMerchant.Payments.Add(payment);
                        }
                    }
                }

                Log.Info("Total unique merchants read from VisaMid file is {0} ", lstMerchants.Count);

                return(lstMerchants);
            }
            catch (Exception e)
            {
                Log.Error("Error in reading merchant data from excel stream " + e.Message);
                throw;
            }
        }
        public override IList <Merchant> ImportAmexMidFile(Stream fileStream)
        {
            IList <Merchant> merchants = new List <Merchant>();

            try
            {
                HashSet <string> amexMids    = new HashSet <string>();
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileStream);
                excelReader.IsFirstRowAsColumnNames = true;

                DataSet   storeDataSet   = excelReader.AsDataSet();
                DataTable storeDataTable = storeDataSet.Tables[0];
                if (storeDataTable != null)
                {
                    Log.Info("Total Rows in AmexMid File is {0}", storeDataTable.Rows.Count);
                    var merchantData = GetDataFromSpecifiedColumns(storeDataTable, AmexImportList);
                    Log.Info("Total Rows read from AmexMid File is {0}", merchantData.Count);

                    foreach (var data in merchantData)
                    {
                        Merchant existingMerchant = null;
                        //Check if we have already seen this merchant in this spreadsheet based on the PartnerMerchantId of the merchant
                        string merchantId = data.ContainsKey(MerchantConstants.Id) ? data[MerchantConstants.Id] : null;
                        if (!string.IsNullOrEmpty(merchantId))
                        {
                            existingMerchant = merchants.FirstOrDefault(m => m.Id == data[MerchantConstants.Id]);
                        }

                        if (existingMerchant == null)
                        {
                            Merchant merchant = new Merchant
                            {
                                Id       = data[MerchantConstants.Id],
                                Name     = data[MerchantConstants.Name],
                                Location = new Location
                                {
                                    Address = data[MerchantConstants.Address],
                                    City    = data[MerchantConstants.City],
                                    State   = data[MerchantConstants.State],
                                    Zip     = data[MerchantConstants.Zip]
                                },
                                PhoneNumber = data.ContainsKey(MerchantConstants.Phone)
                                    ? StringUtility.StripAllButDigits(data[MerchantConstants.Phone]) : string.Empty
                            };

                            // amexMids hashset is passed to validate duplication of SE numbers for different merchants
                            merchant.Payments = CreateAmexPayment(data, amexMids);
                            merchants.Add(merchant);
                        }
                        else
                        {
                            // if MerchantId appears multiple times in the list hence add to the list
                            var payments = CreateAmexPayment(data, amexMids);
                            if (payments != null && payments.Any())
                            {
                                foreach (var payment in payments)
                                {
                                    existingMerchant.Payments.Add(payment);
                                }
                            }
                        }
                    }
                }

                Log.Info("Total unique merchants read from AmexMid file is {0} ", merchants.Count);
                return(merchants);
            }
            catch (Exception e)
            {
                Log.Error("Error in reading merchant data from excel stream " + e.Message);
                throw;
            }
        }
        // Use this for initialization
        void Start()
        {
            // Init control
            playerTurn = true;
            playerNum = GameMaster.Instance.Turn;
            die = new Die ();
            die.Reseed (Environment.TickCount);
            damage = 0;

            // Init IDamageable objects
            // Create the enemy
            GameMaster.Instance.CreateEnemy(HostileType.Bandit, "Bandit");

            // Get the enemyID from the list of enemy IDs; since this a 1v1 fight there should only be a single ID
            enemyID = GameMaster.Instance.EnemyIdentifiers[0];

            // Get the enemy entity
            enemyEntity = (Bandit)EntityManager.Instance.GetEntity(enemyID);

            // Set the stats of the enemy
            enemyEntity.AttackPower = die.Roll(1, 9) + 5;
            enemyEntity.DefencePower = die.Roll(1, 9) + 5;

            // Set sprite of enemy
            if(enemyEntity.AttackPower > enemyEntity.DefencePower)
            {
                GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit1");
            } //end if
            else
            {
                GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit2");
            }

            // Set the enemy
            enemy = (IDamageable) enemyEntity;

            // Get the player's merchant
            GameMaster.Instance.LoadPlayers ();
            playerMerchant = (Merchant)GameMaster.Instance.GetPlayerScript(playerNum).Entity;
            playerAttack = playerMerchant.AttackPower;
            playerDefense = playerMerchant.DefencePower;
            GameObject.Find ("Battler1Sprite").GetComponent<Image> ().sprite = playerMerchant.GetSprite (2);

            // Set the player
            player = (IDamageable)playerMerchant;

            // Set background
            if(GameMaster.Instance.BattleMap == BattleMap.area01)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Desert");
            } //end if
            else if(GameMaster.Instance.BattleMap == BattleMap.area02)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Euro");
            } //end else if
            else if(GameMaster.Instance.BattleMap == BattleMap.area03)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Metro");
            } //end if
            else
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Snow");
            } //end else

            // Init and set HUD objects
            GameObject.Find("Canvas").transform.Find("PlayerInventory").gameObject.SetActive(false);
            GameObject.Find("Canvas").transform.Find("AllyInventory").gameObject.SetActive(false);
            GameObject.Find("Canvas").transform.Find("Tooltip").gameObject.SetActive(false);
            playerName = GameObject.Find ("Battler1Name").GetComponent<Text> ();
            playerName.text = GameMaster.Instance.GetPlayerName (playerNum);
            enemyName = GameObject.Find ("Battler2Name").GetComponent<Text> ();
            GameObject.Find ("Battler1Attack").GetComponent<Text> ().text = playerMerchant.AttackPower.ToString ();
            GameObject.Find ("Battler2Attack").GetComponent<Text> ().text = enemyEntity.AttackPower.ToString ();
            GameObject.Find ("Battler1Defense").GetComponent<Text> ().text = playerMerchant.DefencePower.ToString ();
            GameObject.Find ("Battler2Defense").GetComponent<Text> ().text = enemyEntity.DefencePower.ToString ();
            playerHealth = GameObject.Find ("Battler1Health").GetComponent<Text> ();
            playerHealth.text = player.Health.ToString ();
            enemyHealth = GameObject.Find ("Battler2Health").GetComponent<Text> ();
            enemyHealth.text = enemy.Health.ToString ();
            playerBar = GameObject.Find ("Battler1HealthLeft").GetComponent<RectTransform> ();
            enemyBar = GameObject.Find ("Battler2HealthLeft").GetComponent<RectTransform> ();
            fightBoxText = GameObject.Find ("FightText").GetComponent<Text> ();

            // Init fight box and flavor
            fightBoxText.text = "The battlers square off!";
            linesOfText = 1;
            verbs = new List<string>();
            verbs.Add ("attacked");
            verbs.Add ("retaliated against");
            verbs.Add ("hammered");
            verbs.Add ("struck");
            verbs.Add ("lashed at");

            // Check if the player is an AI
            if (playerMerchant.GameObj.GetComponent<Player>().IsAI)
            {
                // Disable the fight buttons
                GameObject.Find("AttackButtons/HeadButton").GetComponent<Button>().interactable = false;
                GameObject.Find("AttackButtons/TorsoButton").GetComponent<Button>().interactable = false;
                GameObject.Find("AttackButtons/FeintButton").GetComponent<Button>().interactable = false;
            }
        }
        public override IList <Merchant> ImportMasterCardClearingFile(Stream fileStream)
        {
            IList <Merchant> lstMerchants = new List <Merchant>();

            try
            {
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileStream);
                excelReader.IsFirstRowAsColumnNames = true;

                DataSet   storeDataSet   = excelReader.AsDataSet();
                DataTable storeDataTable = storeDataSet.Tables[0];
                if (storeDataTable != null)
                {
                    Log.Info("Total Rows in MasterCardClearingFile is {0}", storeDataTable.Rows.Count);
                    var lstMerchantData = GetDataFromSpecifiedColumns(storeDataTable, MCClearingFileImportColumnList);
                    Log.Info("Total Rows read from MasterCardClearingFile is {0}", lstMerchantData.Count);

                    foreach (var merchantData in lstMerchantData)
                    {
                        Merchant existingMerchant = null;

                        //Check if we have already seen this merchant in this spreadsheet based on the siteid of the merchant
                        string siteId = merchantData.ContainsKey(MerchantConstants.MCSiteId) ? merchantData[MerchantConstants.MCSiteId] : string.Empty;
                        if (!string.IsNullOrEmpty(siteId))
                        {
                            existingMerchant = lstMerchants
                                               .FirstOrDefault(m => (m.ExtendedAttributes != null && m.ExtendedAttributes.ContainsKey(MerchantConstants.MCSiteId) &&
                                                                     m.ExtendedAttributes[MerchantConstants.MCSiteId] == merchantData[MerchantConstants.MCSiteId]));
                        }

                        //if we have not seen the merchant, then create one
                        if (existingMerchant == null)
                        {
                            var merchant = CreateMerchant(merchantData);
                            merchant.ExtendedAttributes = new Dictionary <string, string>();
                            merchant.ExtendedAttributes.Add(MerchantConstants.MCSiteId, merchantData[MerchantConstants.MCSiteId]);
                            merchant.Payments = new List <Payment>();
                            Payment payment = new Payment();
                            payment.Processor   = PaymentProcessor.MasterCard;
                            payment.PaymentMids = new Dictionary <string, string>();
                            payment.PaymentMids.Add(MerchantConstants.MCLocationId, merchantData[MerchantConstants.MCLocationId]);
                            merchant.Payments.Add(payment);
                            lstMerchants.Add(merchant);
                        }
                        else
                        {
                            //else, update the payment info to the existing merchant
                            Payment payment = new Payment();
                            payment.Processor   = PaymentProcessor.MasterCard;
                            payment.PaymentMids = new Dictionary <string, string>();
                            payment.PaymentMids.Add(MerchantConstants.MCLocationId, merchantData[MerchantConstants.MCLocationId]);
                            existingMerchant.Payments.Add(payment);
                        }
                    }
                }

                Log.Info("Total unique merchants read from MasterCardClearing file is {0} ", lstMerchants.Count);

                return(lstMerchants);
            }
            catch (Exception e)
            {
                Log.Error("Error in reading merchant data from excel stream " + e.Message);
                throw;
            }
        }
Example #54
0
        public List<Merchant> GetMerchantsByFilter(int deleted)
        {
            List<Merchant> merchants = null;
            _log.DebugFormat("dbo.GetAllMerchants: deleted={0}", deleted);
            try
            {
                int? bitDeleted = null;
                if (deleted > -1) bitDeleted = deleted;
                AddSQLParameter("@Deleted", SqlDbType.Bit, bitDeleted);
                merchants = new List<Merchant>();
                DataSet ds = GetDatasetByCommand("dbo.GetAllMerchants");
                DataRowCollection rows = ds.Tables[0].Rows;
                foreach (DataRow row in rows)
                {
                    Merchant merchant = new Merchant();
                    merchant.ID = Convert.ToInt64(row["ID"]);
                    merchant.UserID = (Guid)row["UserID"];
                    merchant.MerchantName = (row["MerchantName"] == DBNull.Value) ? "" : Convert.ToString(row["MerchantName"]);

                    merchant.FirstName = (row["FirstName"] == DBNull.Value) ? "" : Convert.ToString(row["FirstName"]);
                    merchant.LastName = (row["LastName"] == DBNull.Value) ? "" : Convert.ToString(row["LastName"]);
                    merchant.Email = (row["Email"] == DBNull.Value) ? "" : Convert.ToString(row["Email"]);
                    merchant.PhoneNumber = (row["PhoneNumber"] == DBNull.Value) ? "" : Convert.ToString(row["PhoneNumber"]);
                    merchant.Description = (row["Description"] == DBNull.Value) ? "" : Convert.ToString(row["Description"]);

                    merchant.FirstNameBilling = (row["FirstNameBilling"] == DBNull.Value) ? "" : Convert.ToString(row["FirstNameBilling"]);
                    merchant.LastNameBilling = (row["LastNameBilling"] == DBNull.Value) ? "" : Convert.ToString(row["LastNameBilling"]);
                    merchant.EmailBilling = (row["EmailBilling"] == DBNull.Value) ? "" : Convert.ToString(row["EmailBilling"]);
                    merchant.PhoneNumberBilling = (row["PhoneNumberBilling"] == DBNull.Value) ? "" : Convert.ToString(row["PhoneNumberBilling"]);
                    merchant.DescriptionBilling = (row["DescriptionBilling"] == DBNull.Value) ? "" : Convert.ToString(row["DescriptionBilling"]);
                    merchant.Address = (row["Address"] == DBNull.Value) ? "" : Convert.ToString(row["Address"]);
                    merchant.Address2 = (row["Address2"] == DBNull.Value) ? "" : Convert.ToString(row["Address2"]);
                    merchant.City = (row["City"] == DBNull.Value) ? "" : Convert.ToString(row["City"]);
                    merchant.State = (row["State"] == DBNull.Value) ? "" : Convert.ToString(row["State"]);
                    merchant.Zip = (row["Zip"] == DBNull.Value) ? "" : Convert.ToString(row["Zip"]);

                    merchant.CreatedDate = (row["CreatedDate"] == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["CreatedDate"]);
                    merchant.UpdatedDate = (row["UpdatedDate"] == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["UpdatedDate"]);
                    merchant.Deleted = Convert.ToBoolean(row["Deleted"]);
                    merchants.Add(merchant);
                }

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Exception Occured: Exception={0}", ex);
            }

            return merchants;
        }
Example #55
0
        public static Merchant Parse(string record, char delimiter, MerchantFileType merchantFileType, int lineNumber)
        {
            Merchant merchant = null;

            if (string.IsNullOrWhiteSpace(record))
            {
                Log.Error($"Invalid {merchantFileType.ToString()} detail record. Empty record at line numnber {lineNumber}");
                return(null);
            }

            string[] recordParts = record.Split(new char[] { delimiter });
            if (recordParts.Length != 39)
            {
                Log.Error($"Invalid {merchantFileType.ToString()} detail record. Number of fields did not equate to 39 at line numnber {lineNumber}");
                return(null);
            }

            string actionCode = recordParts[2];

            if (merchantFileType == MerchantFileType.MasterCardProvisioning && actionCode != "A")
            {
                Log.Error($"Invalid {merchantFileType.ToString()} detail record at line number {lineNumber}.Detail record has an action code other than Add. This cannot be handled");
                return(null);
            }

            string mcId     = recordParts[33];
            string mcSiteId = recordParts[3];

            if (merchantFileType == MerchantFileType.MasterCardAuth || merchantFileType == MerchantFileType.MasterCardClearing)
            {
                if (actionCode != MerchantMatchedActionCode && actionCode != MerchantNonMatchedActionCode &&
                    actionCode != ValidatedMatchActionCode)
                {
                    Log.Error($"Invalid {merchantFileType.ToString()} detail record at line number {lineNumber}. Detail record has an action code other than Match/NonMatch/ValidatedMatch. This cannot be handled");
                    return(null);
                }
                if (actionCode == MerchantNonMatchedActionCode)
                {
                    Log.Warn($"No match found for MID in {merchantFileType.ToString()} at line number {lineNumber}");
                    return(null);
                }
                if (!string.IsNullOrEmpty(mcId) && mcId.Length != MCIDLENGTH)
                {
                    Log.Error($"Invalid {merchantFileType.ToString()} detail record at line number {lineNumber}. Invalid length for MasterCard Microsoft Unique Identifier");
                    return(null);
                }
                if (string.IsNullOrEmpty(mcId) && string.IsNullOrEmpty(mcSiteId))
                {
                    Log.Error($"Invalid {merchantFileType.ToString()} detail record at line number {lineNumber}. Both MCID and MCSiteId is missing");
                    return(null);
                }
            }

            Payment payment = ParseForPayment(recordParts, merchantFileType, lineNumber);

            if (payment != null)
            {
                merchant = new Merchant
                {
                    IsActive    = true,
                    PhoneNumber = recordParts[20],
                    Location    = new Location
                    {
                        Address = !string.IsNullOrWhiteSpace(recordParts[10]) ? recordParts[10] : recordParts[11],
                        City    = !string.IsNullOrWhiteSpace(recordParts[12]) ? recordParts[12] : recordParts[13],
                        State   = !string.IsNullOrWhiteSpace(recordParts[14]) ? recordParts[14] : recordParts[15],
                        Zip     = !string.IsNullOrWhiteSpace(recordParts[16]) ? recordParts[16] : recordParts[17]
                    },
                    Payments = new List <Payment> {
                        payment
                    },
                    ExtendedAttributes = new Dictionary <string, string>
                    {
                        { MerchantConstants.MCSiteId, mcSiteId },
                        { MCBeginDate, recordParts[29] },
                        { MCFileDate, recordParts[38] }
                    }
                };
                merchant.Name = ParseForMerchantName(recordParts, merchantFileType);
                if (!string.IsNullOrWhiteSpace(mcId))
                {
                    merchant.ExtendedAttributes.Add(MerchantConstants.MCID, mcId);
                }
            }

            return(merchant);
        }
        public void UnregisterAll()
        {
            if(controlledMerchant != null)
            {
                controlledMerchant.UnregisterListener(singleLogMerchant);
            }

            controlledPg = null;
            controlledMerchant = null;

            for (int i = 0; i < controlledBackpack.Length; i++)
            {
                controlledBackpack[i] = null;
                descriptionList[i].Items.Clear();
            }
        }
Example #57
0
 public void PropagateMerchantInfo(Merchant merchant)
 {
     merchantPortrait.sprite = merchant.merchantPortrait;
     merchantName.text       = merchant.merchantName;
     merchantLine.text       = merchant.greetingDialogue;
 }
 public void Unregister(Merchant merchant)
 {
     if (controlledMerchant == merchant)
     {
         controlledMerchant.UnregisterListener(singleLogMerchant);
         controlledMerchant = null;
         ControlledBackpack[1] = null;
     }
 }
Example #59
0
 public void InsertNpc(npc toinsert)
 {
     var merchant = new Merchant(toinsert);
     World.Insert(merchant);
     Insert(merchant, merchant.X, merchant.Y);
     merchant.OnSpawn();
 }