Exemplo n.º 1
0
    void OnGUI()
    {
        GUIStyle style = new GUIStyle(skin.label);

        style.font      = skin.font;
        style.fontSize  = 22;
        style.alignment = TextAnchor.UpperRight;

        string title = mode == 0 ? "Your Scores" : "Top Scores";

        GUI.BeginGroup(new Rect(Screen.width - 210, 10, 200, 300));

        ExtraMethods.DrawOutline(new Rect(0, 0, 200, 50), title, style, Color.black, Color.white);

        if (mode == 0)
        {
            ShowYourScores();
        }
        else
        {
            ShowTopScores();
        }

        GUI.EndGroup();
    }
Exemplo n.º 2
0
        public string UpdateUser(User user)
        {
            User userToUpdate = context.Users.Find(user.UserId);

            user.FirstName = ExtraMethods.TitleString(user.FirstName);
            user.LastName  = ExtraMethods.TitleString(user.LastName);

            if (userToUpdate != null)
            {
                if (user.EmailAddress != userToUpdate.EmailAddress && GetUserByEmail(user.EmailAddress) != null)
                {
                    return("Email Taken");
                }

                userToUpdate.FirstName    = user.FirstName;
                userToUpdate.LastName     = user.LastName;
                userToUpdate.EmailAddress = user.EmailAddress;

                context.SaveChanges();
                return("Updated User With ID " + user.UserId);
            }
            else
            {
                return("There Is No User With ID Of " + user.UserId);
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> ConfirmTransaction(CreditDebitBindingModel creditDebit)
        {
            //_context.Transaction.Add(transaction);
            //await _context.SaveChangesAsync();

            var user = _context.Kaedcuser.Where(u => u.BrinqaccountNumber == creditDebit.BrinqAccountNumber).FirstOrDefault();

            if (creditDebit.serviceId == 3 && user != null)
            {
                ExtraMethods.CreditUser(creditDebit.BrinqAccountNumber, creditDebit.Amount);
                await _context.SaveChangesAsync();
            }
            else if (creditDebit.serviceId == 4)
            {
                ExtraMethods.DebitUser(creditDebit.BrinqAccountNumber, creditDebit.Amount);
                await _context.SaveChangesAsync();
            }
            else
            {
                //ViewData["PaymentMethodId"] = new SelectList(_context.Paymentmethod, "Id", "Name", transaction.PaymentMethodId);
                ViewData["ServiceId"]        = new SelectList(_context.Service, "Id", "Name");
                ViewData["CreditsAndDebits"] = _context.Transaction.Where(t => t.ServiceId == 3 && t.ServiceId == 4).Include(t => t.PaymentMethod).Include(t => t.Service);
                return(View(creditDebit));
            }


            //return RedirectToAction(nameof(Index));
            return(RedirectToAction(nameof(BalanceUpdated), creditDebit));
        }
Exemplo n.º 4
0
    // Save best score to local binary file.
    private void SaveLocalScore(int score)
    {
        Save save = new Save();

        save.bestScore = score;
        ExtraMethods.SaveFile(save, Application.persistentDataPath, "SAVE");
    }
Exemplo n.º 5
0
    void OnGUI()
    {
        GUIStyle style = new GUIStyle(skin.label);

        style.font     = skin.font;
        style.fontSize = 18;

        ExtraMethods.DrawOutline(new Rect(130, 10, 200, 50), playerList.Count + " Player(s) Online", style, Color.black, Color.white);
    }
Exemplo n.º 6
0
 void Start()
 {
     // Checks if a guest ID has been assigned.
     if (PlayerPrefs.HasKey("GuestID"))
     {
         guestID = PlayerPrefs.GetString("GuestID");
     }
     else
     {
         guestID = "Guest " + ExtraMethods.GenerateRandomString(10);
         PlayerPrefs.SetString("GuestID", guestID);
     }
 }
Exemplo n.º 7
0
        public ActionResult Save(PetFormViewModel viewModel, HttpPostedFileBase file)
        {
            //// shit happens
            //if (!ModelState.IsValid)
            //{
            //    var viewModel = new PetFormViewModel()
            //    {
            //        Pet = pet
            //    };

            //    return View("PetForm", viewModel);
            //}
            //Add
            if (viewModel.Id == 0)
            {
                var identityId = User.Identity.GetUserId();

                if (identityId == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var PersonToUpdate = context.Persons.Where(s => s.IdentityUserId == identityId).SingleOrDefault();
                var kindToUpdate   = context.Kinds.Single(s => s.Id == viewModel.KindId);

                context.Pets.Add(new Pet(viewModel.Name, viewModel.KindId, kindToUpdate, viewModel.Age, ExtraMethods.UploadPhoto(file), PersonToUpdate));

                TempData["PetAdd"] = "Added";
            }
            else //Update
            {
                var petInDb  = context.Pets.Single(m => m.Id == viewModel.Id);
                var kindInDb = context.Kinds.Single(s => s.Id == viewModel.KindId);


                petInDb.Modify(viewModel.Name, viewModel.KindId, kindInDb, viewModel.Age);

                if (!(file is null))
                {
                    petInDb.Modify(ExtraMethods.UploadPhoto(file));
                }


                TempData["PetUpdate"] = "Updated";
            }
            context.SaveChanges();

            return(RedirectToAction("ShowPets"));
        }
        public PageSudokuSolver()
        {
            InitializeComponent();
            buttonBoard = new Button[9, 9];

            for (int i = 0; i < 9; i++)
            {
                gridBoard.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5.0, GridUnitType.Star)
                });
                gridBoard.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5.0, GridUnitType.Star)
                });
                if ((i + 1) % 3 == 0)
                {
                    gridBoard.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    });
                    gridBoard.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1.0, GridUnitType.Star)
                    });
                }
            }

            for (int i = 0; i < 11; i++)
            {
                for (int j = 0; j < 11; j++)
                {
                    if (!(i == 3 || i == 7 || j == 3 || j == 7))
                    {
                        Button b = new Button();
                        b.Click += ExtraMethods.ChooseNumberWindow(9);
                        Binding binding = new Binding("boardFontSize");
                        binding.Source = Properties.Settings.Default;
                        b.SetBinding(Button.FontSizeProperty, binding);
                        b.Content = "";
                        Grid.SetRow(b, i);
                        Grid.SetColumn(b, j);
                        gridBoard.Children.Add(b);
                        buttonBoard[i - i / 4, j - j / 4] = b;
                    }
                }
            }
        }
Exemplo n.º 9
0
    void OnGUI()
    {
        GUIStyle style = new GUIStyle(skin.label);

        style.font      = skin.font;
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperCenter;

        GUI.BeginGroup(new Rect(Screen.width / 2 - 75, 10, 150, 150));

        ExtraMethods.DrawOutline(new Rect(0, 0, 150, 50), "Year " + year, style, Color.black, Color.white);
        ExtraMethods.DrawOutline(new Rect(0, 25, 150, 50), DateTimeFormatInfo.CurrentInfo.GetMonthName(month), style, Color.black, Color.white);
        ExtraMethods.DrawOutline(new Rect(0, 50, 150, 50), "Day " + day, style, Color.black, Color.white);

        GUI.EndGroup();
    }
Exemplo n.º 10
0
    public void ShowTopScores()
    {
        GUIStyle style = new GUIStyle(skin.label);

        style.font      = skin.font;
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperRight;

        GUIStyle scoreStyle = new GUIStyle(skin.label);

        scoreStyle.font      = skin.font;
        scoreStyle.fontSize  = 18;
        scoreStyle.alignment = TextAnchor.UpperRight;

        {
            Rect rect = new Rect(0, 30, 200, 50);
            ExtraMethods.DrawOutline(rect, "High Score", style, Color.black, new Color(1.0f, 0.93f, 0.73f, 1.0f));

            for (int i = 0; i < highScoreList.Length; i++)
            {
                string scoreText = highScoreList[i] == 0 ? "-" : highScoreList[i].ToString("n0");
                ExtraMethods.DrawOutline(new Rect(rect.x, rect.y + 20 + i * 20, 200, 50), scoreText, scoreStyle, Color.black, Color.white);
            }
        }

        {
            Rect rect = new Rect(0, 120, 200, 50);
            ExtraMethods.DrawOutline(rect, "Total Score", style, Color.black, new Color(1.0f, 0.93f, 0.73f, 1.0f));

            for (int i = 0; i < totalScoreList.Length; i++)
            {
                string scoreText = totalScoreList[i] == 0 ? "-" : totalScoreList[i].ToString("n0");
                ExtraMethods.DrawOutline(new Rect(rect.x, rect.y + 20 + i * 20, 200, 50), scoreText, scoreStyle, Color.black, Color.white);
            }
        }

        {
            Rect rect = new Rect(0, 200, 200, 50);
            ExtraMethods.DrawOutline(rect, "Current Score", style, Color.black, new Color(1.0f, 0.93f, 0.73f, 1.0f));

            for (int i = 0; i < currentScoreList.Length; i++)
            {
                string scoreText = currentScoreList[i] == 0 ? "-" : currentScoreList[i].ToString("n0");
                ExtraMethods.DrawOutline(new Rect(rect.x, rect.y + 20 + i * 20, 200, 50), scoreText, scoreStyle, Color.black, Color.white);
            }
        }
    }
Exemplo n.º 11
0
 // Get local score save from local binary file.
 private void GetLocalScore(System.Action <bool> callback = null, System.Action <int> score = null)
 {
     if (localScore < 0)
     {
         Save saveFile = ExtraMethods.LoadFile <Save>(Application.persistentDataPath, "SAVE");
         if (saveFile != null)
         {
             score(saveFile.bestScore);
             saveFile = null;
         }
         callback(true);
     }
     else
     {
         score(localScore);
         callback(true);
     }
 }
Exemplo n.º 12
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(Screen.width / 2 - 100, 85, 200, 100));
        GUIStyle style = new GUIStyle(skin.label);

        style.font      = skin.font;
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperCenter;

        Color color = new Color(1.0f, 0.93f, 0.73f, 1.0f);

        ExtraMethods.DrawOutline(new Rect(0, 0, 200, 50), "Environment Score", style, Color.black, color);

        style           = new GUIStyle(skin.label);
        style.font      = skin.font;
        style.fontSize  = 24;
        style.alignment = TextAnchor.UpperCenter;

        ExtraMethods.DrawOutline(new Rect(0, 25, 200, 50), score.ToString("n0"), style, Color.black, Color.white);
        GUI.EndGroup();
    }
Exemplo n.º 13
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(Screen.width * 0.75f - 200, 10, 400, 100));

        GUIStyle style = new GUIStyle(skin.label);

        style.font      = skin.font;
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperRight;

        ExtraMethods.DrawOutline(new Rect(-170, 0, 400, 50), credits.ToString("n0") + " Credits", style, Color.black, Color.green);

        style           = new GUIStyle(skin.label);
        style.font      = skin.font;
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperRight;

        ExtraMethods.DrawOutline(new Rect(-170, 20, 400, 50), coins.ToString("n0") + " Coins", style, Color.black, Color.yellow);

        GUI.EndGroup();
    }
Exemplo n.º 14
0
        public int AddUser(User user, string fileType)
        {
            try
            {
                user.FirstName  = ExtraMethods.TitleString(user.FirstName);
                user.LastName   = ExtraMethods.TitleString(user.LastName);
                user.DateJoined = DateTime.Now;
                context.Users.Add(user);
                context.SaveChanges();

                if (fileType != null)
                {
                    user.ImageUrl = "User_ID_" + user.UserId + fileType;
                    context.SaveChanges();
                }
                return(user.UserId);
            }
            catch
            {
                return(0);
            }
        }
Exemplo n.º 15
0
        public ActionResult Save(Person person, HttpPostedFileBase file)
        {
            // shit happens
            if (!ModelState.IsValid)
            {
                return(HttpNotFound());
            }

            var personInDb = context.Persons.Single(m => m.Id == person.Id);

            personInDb.Modify(person.Name, person.LastName, person.BirthDate, person.Description);

            if (!(file is null))
            {
                personInDb.Modify(ExtraMethods.UploadPhoto(file));
            }

            context.SaveChanges();
            TempData["UpdatePerson"] = "Added";


            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 16
0
        public void OnCommand(SendingRemoteAdminCommandEventArgs ev)
        {
            string[] args = ev.Arguments.ToArray();

            foreach (string str in args)
            {
                str.ToLower();
            }
            string command = ev.Name.ToLower();

            if (command == "givemask" && ScanMod.config.enable096Mask)
            {
                Exiled.API.Features.Player target = Exiled.API.Features.Player.Get(args[0]);
                if (target != null)
                {
                    if (target.Inventory.items.Count < 8)
                    {
                        if (!target.HasMaskInInventory())
                        {
                            target.Inventory.AddNewItem(ItemType.WeaponManagerTablet, 69);
                            target.Broadcast(5, "Вам была выдана маска для SCP 096");
                            ev.CommandSender.RaReply("Игроку с id " + args[0] + " успешно выдана маска для SCP 096", true, true, string.Empty);
                        }
                        else
                        {
                            ev.CommandSender.RaReply("У данного игрока уже есть маска для SCP 096", false, true, string.Empty);
                        }
                    }
                    else
                    {
                        ev.CommandSender.RaReply("В инвентаре данного игрока нет свободного места", false, true, string.Empty);
                    }
                }
                else
                {
                    ev.CommandSender.RaReply("Не существует игрока c id " + args[0], false, true, string.Empty);
                }
            }
            else if (command == "scan" && ScanMod.config.enableScanning)
            {
                if (args.Length == 0)
                {
                    ev.CommandSender.RaReply("Введите команду в формате scan scp/humans", false, true, string.Empty);
                }
                else if (args[0] == "scp")
                {
                    ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                    ExtraMethods.TryScanSCP(null);
                }
                else if (args[0] == "humans")
                {
                    ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                    ExtraMethods.TryScanPersonnel(null);
                }
                else
                {
                    ev.CommandSender.RaReply("Введите команду в формате scan scp/humans", false, true, string.Empty);
                }
            }
            else if (command == "protocol" && ScanMod.config.enableProtocols)
            {
                if (args.Length == 0)
                {
                    ev.CommandSender.RaReply("Введите команду в формате protocol название протокола", false, true, string.Empty);
                }
                else
                {
                    switch (args[0])
                    {
                    case "pl1":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryBlockGates(ev.Sender);
                        break;

                    case "pl2":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryBlockCheckpointAndGates(ev.Sender);
                        break;

                    case "pl3":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryBlockDoors(ev.Sender);
                        break;

                    case "pb2":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryLCZDecontain(ev.Sender);
                        break;

                    case "pb3":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryHCZDecontain(ev.Sender);
                        break;

                    case "pb4":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryLCZAndHCZDecontain(ev.Sender);
                        break;

                    case "pb5":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryNuke(ev.Sender);
                        break;

                    case "ps5":
                        ev.CommandSender.RaReply("Команда применена успешно", true, true, string.Empty);
                        ExtraMethods.TryBlackout(ev.Sender, 30f);
                        break;

                    default:
                        ev.CommandSender.RaReply("Введите команду в формате protocol название протокола", false, true, string.Empty);
                        break;
                    }
                }
            }
            else if (command == "infect" && ScanMod.config.enable008)
            {
                try
                {
                    Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(args[0]);
                    if (player != null)
                    {
                        player.Infect();
                        ev.CommandSender.RaReply("Игрок " + args[0] + " успешно заражён", true, true, string.Empty);
                    }
                    else
                    {
                        ev.CommandSender.RaReply("На сервере нет игрока " + args[0], false, true, string.Empty);
                    }
                }
                catch
                {
                    ev.CommandSender.RaReply("Введите команду в формате infect id/nickname", false, true, string.Empty);
                }
            }
        }
Exemplo n.º 17
0
        public async Task <IActionResult> GetMeterInfoAsync([FromBody] MeterInfoModel model)
        {
            string vendor_code       = _configuration["Irecharge:VendorCode"];
            string pubkey            = _configuration["Irecharge:PublicKey"];
            string privKey           = _configuration["Irecharge:PrivateKey"];
            string baseUri_MeterInfo = _configuration["Irecharge:MeterInfoURL"];

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid parameters"));
            }

            //get user details
            var username = HttpContext.User.Identity.Name;
            var user     = _userManager.FindByEmailAsync(username).Result;

            if (user.MainBalance <= Convert.ToDecimal(model.Amount))
            {
                return(Ok("Insufficient Balance"));
            }

            string meter_number = model.MeterNumber;
            //string disco = transaction.Service.Name;
            string disco;
            int    serviceId = 0;

            if (model.Service == "KAEDC_Prepaid")
            {
                disco     = "Kaduna_Electricity_Disco";
                serviceId = 1;
            }
            else if (model.Service == "KAEDC_Postpaid")
            {
                disco     = "Kaduna_Electricity_Disco_Postpaid";
                serviceId = 2;
            }
            else
            {
                return(BadRequest("Invalid Service"));
            }

            string ref_id         = ExtraMethods.GenerateRandomNumber();
            string combinedstring = vendor_code + "|" + ref_id + "|" + meter_number + "|" + disco + "|" + pubkey;

            byte[] key  = Encoding.ASCII.GetBytes(privKey);
            string hash = ExtraMethods.GenerateHash(combinedstring, key);


            WebClient webClient = new WebClient();

            webClient.QueryString.Add("vendor_code", vendor_code);
            webClient.QueryString.Add("meter", meter_number);
            webClient.QueryString.Add("reference_id", ref_id);
            webClient.QueryString.Add("disco", disco);
            webClient.QueryString.Add("response_format", "json");
            webClient.QueryString.Add("hash", hash);

            try
            {
                string response = webClient.DownloadString(baseUri_MeterInfo);

                var jsonresult  = JsonConvert.DeserializeObject <iRechargeMeterInfo>(response);
                var transaction = new Transaction();

                transaction.Id                   = ExtraMethods.GenerateId();
                transaction.PayerIp              = ExtraMethods.GetLocalIPAddress();
                transaction.PaymentMethodId      = 1;
                transaction.MeterName            = jsonresult.customer.name;
                transaction.Statuscode           = Convert.ToInt32(jsonresult.status);
                transaction.StatusMessage        = jsonresult.message;
                transaction.ApiUniqueReference   = ref_id;
                transaction.Service              = _db.Service.Where(s => s.Id == serviceId).FirstOrDefault();
                transaction.PhcnUnique           = jsonresult.access_token;
                transaction.Hash                 = hash;
                transaction.transactionsStatus   = "initiated";
                transaction.Datetime             = DateTime.Now;
                transaction.KaedcUserNavigation  = user;
                transaction.KaedcUser            = user.Id;
                transaction.Amount               = model.Amount + 100;
                transaction.PayersName           = user.Surname + " " + user.Firstname;
                transaction.Meternumber          = meter_number;
                transaction.RecipientPhoneNumber = model.PhoneNumber;

                _db.Transaction.Add(transaction);
                await _db.SaveChangesAsync();

                return(Ok(new {
                    ID = transaction.Id,
                    SERVICE = transaction.Service.Name,
                    AMOUNT = transaction.Amount,
                    METERNUMBER = transaction.Meternumber,
                    METERNAME = transaction.MeterName,
                    PAYER = transaction.PayersName,
                    PHONENUMBER = transaction.RecipientPhoneNumber,
                    STATUS = transaction.transactionsStatus,
                    DATE = transaction.Datetime
                }));
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                {
                    var resp = (HttpWebResponse)ex.Response;
                    if (resp.StatusCode == HttpStatusCode.NotFound) // HTTP 404
                    {
                        return(Ok("Unable to retrieve meter details"));
                    }
                }
                throw;
            }
        }
Exemplo n.º 18
0
        public async Task <IActionResult> VendMeter(int id, VendModel model)
        {
            //var transaction = db.Transaction.Where(t => t.Id == id).FirstOrDefault();
            string vendor_code       = _configuration["Irecharge:VendorCode"];
            string pubkey            = _configuration["Irecharge:PublicKey"];
            string privKey           = _configuration["Irecharge:PrivateKey"];
            string baseUri_VendPower = _configuration["Irecharge:VendPowerURL"];

            if (model.TransactionId != id)
            {
                return(BadRequest("Invalid Transaction"));
            }

            //get existing data from DB
            var transact = _db.Transaction.Where(t => t.Id == model.TransactionId).FirstOrDefault();

            //get user details
            var username = HttpContext.User.Identity.Name;
            var user     = _userManager.FindByEmailAsync(username).Result;

            if (user.MainBalance <= Convert.ToDecimal(transact.Amount))
            {
                return(Ok("Insufficient Balance"));
            }


            string disco;
            int    serviceId = 0;

            if (model.Service == "KAEDC_Prepaid")
            {
                disco     = "Kaduna_Electricity_Disco";
                serviceId = 1;
            }
            else if (model.Service == "KAEDC_Postpaid")
            {
                disco     = "Kaduna_Electricity_Disco_Postpaid";
                serviceId = 2;
            }
            else
            {
                return(BadRequest("Invalid Service"));
            }

            string meter_number = transact.Meternumber;
            string ref_id       = transact.ApiUniqueReference;
            string access_token = transact.PhcnUnique;
            string amount       = Convert.ToString(transact.Amount);
            string phone        = transact.RecipientPhoneNumber;
            string email        = user.Email;

            string combinedstring = vendor_code + "|" + ref_id + "|" + meter_number + "|" + disco + "|" + amount + "|" + access_token + "|" + pubkey;

            byte[] key  = Encoding.ASCII.GetBytes(privKey);
            string hash = ExtraMethods.GenerateHash(combinedstring, key);

            try
            {
                WebClient webClient = new WebClient();
                webClient.QueryString.Add("vendor_code", vendor_code);
                webClient.QueryString.Add("meter", meter_number);
                webClient.QueryString.Add("reference_id", ref_id);
                webClient.QueryString.Add("response_format", "json");
                webClient.QueryString.Add("disco", disco);
                webClient.QueryString.Add("access_token", access_token);
                webClient.QueryString.Add("amount", amount);
                webClient.QueryString.Add("phone", phone);
                webClient.QueryString.Add("email", email);
                webClient.QueryString.Add("hash", hash);

                string response = webClient.DownloadString(baseUri_VendPower);

                var jsonresult = JsonConvert.DeserializeObject <iRechargeVendPower>(response);

                transact.PayerIp                = ExtraMethods.GetLocalIPAddress();
                transact.PaymentMethodId        = 1;
                transact.Statuscode             = Convert.ToInt32(jsonresult.status);
                transact.StatusMessage          = jsonresult.message;
                transact.ApiUniqueReference     = ref_id;
                transact.GatewayresponseMessage = response;
                transact.Token       = jsonresult.meter_token;
                transact.BrinqProfit = ExtraMethods.BrinqProfit(model.Amount, serviceId);
                transact.TopUpValue  = jsonresult.units;

                if (jsonresult.status != "00")
                {
                    transact.transactionsStatus = "pending";
                }
                else
                {
                    transact.transactionsStatus = "completed";
                    user.MainBalance            = user.MainBalance - Convert.ToDecimal(transact.Amount);
                    ExtraMethods.AddProfit(user, transact);
                    transact.AgentProfit = 0.005M * Convert.ToDecimal(transact.Amount);
                }

                //db.Entry(transaction).State = EntityState.Modified;
                _db.Update(transact);
                _db.SaveChanges();

                //return Ok(transact);
                return(Ok(new
                {
                    ID = transact.Id,
                    SERVICE = model.Service,
                    AMOUNT = transact.Amount,
                    METERNUMBER = transact.Meternumber,
                    METERNAME = transact.MeterName,
                    PAYER = transact.PayersName,
                    PHONENUMBER = transact.RecipientPhoneNumber,
                    STATUS = transact.transactionsStatus,
                    TOKEN = transact.Token,
                    DATE = transact.Datetime
                }));
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                {
                    var resp = (HttpWebResponse)ex.Response;
                    if (resp.StatusCode == HttpStatusCode.NotFound) // HTTP 404
                    {
                        return(Ok("Transaction could not be completed"));
                    }
                }

                throw;
            }
        }
Exemplo n.º 19
0
        public void OnConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            string[] args = ev.Arguments.ToArray();
            foreach (string str in args)
            {
                str.ToLower();
            }

            string command = ev.Name.ToLower();

            switch (command)
            {
            case "ps1":
                if (ScanMod.config.enableScanning)
                {
                    ExtraMethods.TryScanSCP(ev.Player, ev);
                }
                break;

            case "ps4":
                if (ScanMod.config.enableScanning)
                {
                    ExtraMethods.TryScanPersonnel(ev.Player, ev);
                }
                break;

            case "ps5":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlackout(ev.Player, 30f, ev);
                }
                break;

            case "pl1":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockGates(ev.Player, ev);
                }
                break;

            case "pl2":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockCheckpointAndGates(ev.Player, ev);
                }
                break;

            case "pl3":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryBlockDoors(ev.Player, ev);
                }
                break;

            case "pb2":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryLCZDecontain(ev.Player, ev);
                }
                break;

            case "pb3":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryHCZDecontain(ev.Player, ev);
                }
                break;

            case "pb4":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryLCZAndHCZDecontain(ev.Player, ev);
                }
                break;

            case "pb5":
                if (ScanMod.config.enableProtocols)
                {
                    ExtraMethods.TryNuke(ev.Player, ev);
                }
                break;

            case "106":
            {
                if (ScanMod.config.enable106overhaul)
                {
                    if (args[0].Equals("help"))
                    {
                        ev.ReturnMessage = "Для SCP 106 доступны следующие команды:\n.106 help - вывод доступных команд\n.106 damage урон задержка и .106 damage default - для установления своего урона в КИ и возвращения его к стандартному";
                    }
                    else if (args[0].Equals("damage"))
                    {
                        if (args[1].Equals("default"))
                        {
                            PocketProperties.customDamageEnabled = false;
                            PocketProperties.customDamage        = 1f;
                            PocketProperties.customDelay         = 1f;
                            ev.ReturnMessage = "Урон в КИ успешно изменён на стандартный";
                        }
                        else
                        {
                            if (float.TryParse(args[1], out float damage) && float.TryParse(args[2], out float delay))
                            {
                                PocketProperties.customDamage        = damage;
                                PocketProperties.customDelay         = delay;
                                PocketProperties.customDamageEnabled = true;
                                ev.ReturnMessage = "Урон в КИ успешно изменён";
                            }
                            else
                            {
                                ev.ReturnMessage = "Ошибка. Введите команду в формате .106 damage урон задержка";
                            }
                        }
                    }
                    else if (args[0].Equals("escape"))
                    {
                        int exits;
                        try
                        {
                            exits = int.Parse(args[2]);
                        }
                        catch
                        {
                            ev.ReturnMessage = "Ошибка. Введите команду в формате .106 escape кол-во выходов";
                            break;
                        }
                        if (exits > -1 && exits < 9)
                        {
                            ExtraMethods.SetPocketExits(exits);
                            ev.ReturnMessage = "Количество выходов из КИ установлено на " + exits;
                        }
                        else
                        {
                            ev.ReturnMessage = "Ошибка. Кол-во выходов должно быть от 0 до 8";
                        }
                    }
                    else if (args[0].Equals("cycle"))
                    {
                        if (PocketProperties.cycledPocket)
                        {
                            ev.ReturnMessage = "Замена смерти на обманный побег в КИ отключена";
                            PocketProperties.cycledPocket = false;
                        }
                        else
                        {
                            ev.ReturnMessage = "Замена смерти на обманный побег в КИ включена";
                            PocketProperties.cycledPocket = true;
                        }
                    }
                    else
                    {
                        ev.ReturnMessage = "Чтобы получить список команд введите .106 help";
                    }
                }
                break;
            }

            case "173":
            {
                if (ScanMod.config.enableRPItems)
                {
                    AdditionalPlayerAbilities abilities = ev.Player.GameObject.GetComponentInParent <AdditionalPlayerAbilities>();
                    if (abilities == null)
                    {
                        ev.ReturnMessage = "Player doesn't have abilities component";
                        Log.Error("Player doesn't have abilities component");
                    }
                    else
                    {
                        if (abilities.has173ammo)
                        {
                            abilities.Charge173Ammo();
                            ev.ReturnMessage = "Вы зарядили спец-патрон для SCP 173";
                            ev.Player.Broadcast(5, "Вы зарядили спец-патрон для SCP 173");
                        }
                        else
                        {
                            ev.ReturnMessage = "У вас нет спец-патрона для SCP 173";
                            ev.Player.Broadcast(5, "У вас нет спец-патрона для SCP 173");
                        }
                    }
                }
                break;
            }
            }
        }
Exemplo n.º 20
0
    void OnGUI()
    {
        GUI.skin = skin;

        GUI.BeginGroup(new Rect(Screen.width / 2 - 100, 145, 200, 100));
        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.font      = (Font)Resources.Load("coopbl", typeof(Font));
        style.fontSize  = 20;
        style.alignment = TextAnchor.UpperCenter;

        if (!currentlyOnChallenge)
        {
            ExtraMethods.DrawOutline(new Rect(0, 0, 200, 50), "Current Biomass", style, Color.black, new Color(1.0f, 0.93f, 0.73f, 1.0f));

            style.font      = (Font)Resources.Load("coopbl", typeof(Font));
            style.fontSize  = 24;
            style.alignment = TextAnchor.UpperCenter;

            ExtraMethods.DrawOutline(new Rect(0, 25, 200, 50), biomass.ToString("n0"), style, Color.black, Color.white);
        }
        GUI.EndGroup();

        // Display challenge info
        if (tutorialIndex >= challengeStartIndex && tutorialIndex <= challengeEndIndex)
        {
            if (!objectiveCompleted && !failedChallenge)
            {
                Rect rect1  = new Rect(Screen.width - 250, 145, 240, 40);
                Rect rect2  = new Rect(Screen.width - 255, 175, 200, 40);
                Rect rect3  = new Rect(Screen.width - 145, 175, 200, 40);
                Rect rect4  = new Rect(Screen.width - 245, 205, 200, 40);
                Rect rect5  = new Rect(Screen.width - 135, 205, 200, 40);
                Rect rect6  = new Rect(Screen.width - 288, 235, 200, 40);
                Rect rect7  = new Rect(Screen.width - 145, 238, 200, 40);
                Rect rect8  = new Rect(Screen.width - 285, 265, 200, 40);
                Rect rect9  = new Rect(Screen.width - 145, 268, 200, 40);
                Rect rect10 = new Rect(Screen.width - 295, 295, 200, 40);
                Rect rect11 = new Rect(Screen.width - 155, 298, 200, 40);

                style.normal.textColor = Color.red;
                style.font             = (Font)Resources.Load("coopbl", typeof(Font));
                style.fontSize         = 21;
                ExtraMethods.DrawOutline(rect1, "Current Challenge:  " + currentChallenge, style, Color.black, new Color(1.0f, 0.93f, 0.73f, 1.0f));
                style.fontSize = 17;
                ExtraMethods.DrawOutline(rect2, "Days remaining: ", style, Color.black, Color.white);
                ExtraMethods.DrawOutline(rect3, daysLeft.ToString(), style, Color.white, Color.red);
                ExtraMethods.DrawOutline(rect4, "Credits Remaining: ", style, Color.black, Color.white);
                ExtraMethods.DrawOutline(rect5, currentTutorialCredits.ToString(), style, Color.black, Color.green);
                ExtraMethods.DrawOutline(rect6, "Species: ", style, Color.black, Color.white);

                if (speciesNumber >= challengeMinimumSpecies)
                {
                    GUI.Label(rect7, "<color=#008000ff><b> " + speciesNumber.ToString() + "/" + challengeMinimumSpecies.ToString() + "</b></color>");
                }
                else
                {
                    GUI.Label(rect7, "<color=#000000><b> " + speciesNumber.ToString() + "/" + challengeMinimumSpecies.ToString() + "</b></color>");
                }

                ExtraMethods.DrawOutline(rect8, "Biomass:", style, Color.black, Color.white);

                if (biomass >= challengeRequiredBiomass)
                {
                    GUI.Label(rect9, "<color=#008000ff><b>   " + biomass.ToString("n0") + "/" + challengeRequiredBiomass.ToString("n0") + "</b></color>");
                }
                else
                {
                    GUI.Label(rect9, "<color=#000000><b>   " + biomass.ToString("n0") + "/" + challengeRequiredBiomass.ToString("n0") + "</b></color>");
                }

                ExtraMethods.DrawOutline(rect10, "Score: ", style, Color.black, Color.white);

                if (score >= challengeRequiredEnvironmentScore)
                {
                    GUI.Label(rect11, "<color=#008000ff><b> " + score.ToString("n0") + "/" + challengeRequiredEnvironmentScore.ToString("n0") + "</b></color>");
                }
                else
                {
                    GUI.Label(rect11, "<color=#000000><b> " + score.ToString("n0") + "/" + challengeRequiredEnvironmentScore.ToString("n0") + "</b></color>");
                }
            }
            else if (objectiveCompleted && !instantiatedPics)
            {
                showVictoryPics();
            }
        }

        Rect increaseScore = new Rect(Screen.width - 220, 360, 200, 35);

        if (GUI.Button(increaseScore, "Env Score += 1000 (Debug)"))
        {
            score += 1000;
            GetComponent <EnvironmentScore>().SetScore(score);
        }

        resetTutorial = new Rect(Screen.width - 220, 400, 200, 35);
        if (GUI.Button(resetTutorial, "Reset Tutorial (Debug)"))
        {
            tutorialIndex        = 0;
            tutorialText         = Strings.ecosystemTutorialStrings[0];
            tutorialComplete     = false;
            objectiveCompleted   = false;
            readyForNextTutorial = Strings.ecosystemTutorialStringIsNextable[0];
            initializedShop      = false;
            currentlyOnChallenge = false;
            failedChallenge      = false;
            removeVictoryPics();
            resetSpecies();
            initializeShopAll();
            ConnectionManager cManager = mainObject.GetComponent <ConnectionManager>();
            if (cManager)
            {
                cManager.Send(RequestUpdateCurTut(Constants.USER_ID, 0));
            }
        }

        Rect failTheChallenge = new Rect(Screen.width - 220, 440, 200, 35);

        if (currentlyOnChallenge && GUI.Button(failTheChallenge, "Fail The Challenge (Debug)"))
        {
            daysPassed = 0;
            initializeDay();
            resetSpecies();
            failedChallenge = true;
            tutorialText    = failedChallengeMsg;
            if (instantiatedPics)
            {
                removeVictoryPics();
                instantiatedPics = false;
            }
        }

        Rect completeChallengeButtonRect = new Rect(Screen.width - 220, 480, 200, 35);

        if (tutorialIndex >= challengeStartIndex && tutorialIndex <= challengeEndIndex &&
            GUI.Button(completeChallengeButtonRect, "Complete Challenge(Debug)"))
        {
            objectiveCompleted   = true;
            readyForNextTutorial = true;
            tutorialText         = objectiveCompletedMsg;
        }

        if (isHidden && (failedChallenge || objectiveCompleted))
        {
            isHidden = !isHidden;
        }

        GUIStyle btnStyle = new GUIStyle(GUI.skin.button);

        btnStyle.font = (Font)Resources.Load("coopbl", typeof(Font));

        if (!isHidden)
        {
            GUI.backgroundColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); // black color
            Color color = GUI.color;
            color.a   = 1f;                                          // transparency
            GUI.color = color;

            windowRect = GUI.Window((int)Constants.GUI_ID.Tutorial, windowRect, MakeWindow, Strings.tutorialTitles[tutorialIndex]);
        }

        else if (GUI.Button(new Rect(Screen.width - 260, Screen.height - 40, 120, 30), "Tutorial", btnStyle))
        {
            isHidden = !isHidden;
        }

        /*if (Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return) {
         *      SendMessage();
         * }*/
    }