public void ApproveRequest(string reqKey) { if (!TryGetEnvelope(reqKey, out ApprovalEnvelope <T> env)) { throw Bad.Arg("Request Key", reqKey); } SendResponse(env, true); }
public JObject ToJson() { JObject json = new JObject(); json["unconnected"] = new JArray(Unconnected.Select(p => p.ToJson())); json["bad"] = new JArray(Bad.Select(p => p.ToJson())); json["connected"] = new JArray(Connected.Select(p => p.ToJson())); return(json); }
public void PrepareForRethrowPreservesStackTrace() { var e = Assert.Throws <Exception>(() => Bad.Foo(ex => { throw ex.PrepareForRethrow(); })); Console.WriteLine(e.StackTrace); Assert.Contains("Baz", e.StackTrace); }
private void Button_Click(object sender, RoutedEventArgs e) { Abiturient[] A = new Abiturient[3]; for (int i = 0; i < A.Length; i++) { A[i] = new Abiturient(); A[i].InputInfo(i + 1); Console.WriteLine(); } // 1. Список абитуриентов, имеющих неудовлетворительные оценки; Console.WriteLine("Неудовлетворительные оценки у: "); int BadPoint = 2; var BadPoints = A.Where(x => x.ratings.Split().Select(n => int.Parse(n, CultureInfo.InvariantCulture)).Contains(BadPoint)).Select(s => s); foreach (var Bad in BadPoints) { Console.WriteLine(Bad.ToString()); } Console.WriteLine(); // 2. Список абитуриентов, у которых сумма баллов выше заданной; Console.Write("Введите общий балл: "); int S = Convert.ToInt16(Console.ReadLine()); Console.Write($"Сумма всех баллов выше, чем {S} у: "); var PointsScoreMore = A.Where(x => x.ratings.Split().Select(n => int.Parse(n, CultureInfo.InvariantCulture)).Aggregate((a, b) => a + b) > S).Select(s => s); foreach (var Row in PointsScoreMore) { Console.WriteLine(Row.ToString()); } Console.WriteLine(); // 3) Заданное число n абитуриентов, имеющих самую высокую сумму баллов; Console.Write($"Самая большая сумма баллов: "); int PointsScoreMax = A.Max(x => x.ratings.Split().Select(n => int.Parse(n, CultureInfo.InvariantCulture)).Aggregate((a, b) => a + b)); Console.Write(PointsScoreMax); var ScoreMaxAbiturient = A.Where(x => x.ratings.Split().Select(n => int.Parse(n, CultureInfo.InvariantCulture)).Aggregate((a, b) => a + b) == PointsScoreMax).Select(s => s); Console.Write($" у: "); foreach (var Row in ScoreMaxAbiturient) { Console.WriteLine(Row.ToString()); } Console.WriteLine(); }
protected override decimal GetRegularDue(LeaseDTO lse, DateTime date) { if (!lse.IsActive(date)) return 0; if (date.Date < lse.FirstRentDueDate.Date) return 0; switch (lse.Rent.Interval) { case BillInterval.Daily : return GetDailyDue (lse, date); case BillInterval.Monthly: return GetMonthlyDue (lse, date); default: throw Bad.Arg("Rent.Interval", lse.Rent.Interval); } }
private static void EditStallTemplate(MarketStateDbBase mkt, int secId) { var repo = mkt.Sections; var sec = repo.Find(secId, true); sec.StallTemplate.DefaultRent .PenaltyRule = RentPenalty.ZeroBackrent; if (!repo.Update(sec)) { throw Bad.Data("Update(sec) did NOT return true."); } }
public void InsertClearedCheque(ChequeVoucherDTO cheque, DateTime clearedDate) { var whyNot = cheque.WhyInvalidForSetAsCleared(BankAccountID); if (!whyNot.IsBlank()) { throw Bad.Insert(cheque, whyNot); } var repo = FindRepo(clearedDate); var row = cheque.ToPassbookRow(clearedDate); repo.Insert(row); }
private void GenerateFrom(ITenantDBsDir dir) { BranchName = dir.MarketState.BranchName; FillMainList(dir); FillLookups(dir); FillSectionTotals(dir); FillOtherTotals(dir); if (TotalCollections != TotalDeposits) { throw Bad.Data($"Total collections ({TotalCollections:N2}) does not match total deposits ({TotalDeposits:N2})."); } }
protected override void ValidateRuleName(LeaseDTO lse) { if (lse?.Rent == null) { throw Null.Ref("Lease Rent Params"); } if (lse.Rent.PenaltyRule != RuleName) { throw Bad.Key <LeaseDTO>(RuleName, lse.Rent.PenaltyRule, nameof(lse.Rent.PenaltyRule)); } }
protected List <dynamic> PickOneWithDate(DateTime date, IEnumerable <string> filePaths) { foreach (var file in filePaths) { var lines = File.ReadAllText(file); var list = JsonConvert.DeserializeObject <List <dynamic> >(lines); DateTime dateObj = list[0].Date; if ((DateTime)list[0].Date == date) { return(list); } } throw Bad.Data($"No cached json file dated [{date}]."); }
public static InactiveLeaseDTO DeactivateLease(this MarketStateDbBase mkt, LeaseDTO lse, string reason, DateTime deactivationDate) { if (lse is InactiveLeaseDTO) { throw Bad.State <LeaseDTO>("Inactive", "Active"); } var inactv = new InactiveLeaseDTO(lse, reason, deactivationDate, mkt.CurrentUser); mkt.InactiveLeases.Insert(inactv); return(inactv); }
public void InsertDepositedColxn(BankDepositDTO deposit, DateTime colxnDate) { var whyNot = deposit.WhyInvalidForColxnDeposit(BankAccountID); if (!whyNot.IsBlank()) { throw Bad.Insert(deposit, whyNot); } var repo = FindRepo(deposit.DepositDate); var row = deposit.ToPassbookRow(colxnDate); repo.Insert(row); }
public LeaseDTO GetOccupant(StallDTO stall) { var matches = ActiveLeases.GetAll() .Where(_ => _.Stall.Id == stall.Id); if (!matches.Any()) { return(null); } if (matches.Count() > 1) { throw Bad.Data($"1 occupant for [{stall}] but found [{matches.Count()}]"); } return(matches.Single()); }
private void RunAdHoc(int taskNumber) { Action adhocJob; string desc; bool canRun; switch (taskNumber) { case 1: adhocJob = ForActiveLeases.RebuildSoA(_dir, out desc, out canRun); break; case 2: adhocJob = SectionNight.SetNoBackRent(_dir, out desc, out canRun); break; case 3: adhocJob = StallsJob.SetStallDefaults(_dir, out desc, out canRun); break; case 4: adhocJob = ForActiveLeases.Reprocess3DaysBack(_dir, out desc, out canRun); break; case 5: adhocJob = RateIncrease.ApplyTo("BALAGTAS", _dir, out desc, out canRun); break; default: throw Bad.Data($"Task #: [{taskNumber}]"); } if (!canRun) { var creds = _dir.Credentials; Alert.ShowModal("Not Authorized to Execute", $"“{creds.HumanName}” ({creds.Roles}) {L.f} is not allowed to {L.f} “{desc}”."); return; } Alert.Confirm($"Run Ad Hoc job “{desc}”?", async() => { _main.StartBeingBusy("Running Ad Hoc task ..."); await Task.Run(() => adhocJob.Invoke()); _main.StopBeingBusy(); _main.ClickRefresh(); }); }
protected override void ExecuteAfterSave(InactiveLeaseDTO lse, bool operationIsDelete) { if (operationIsDelete) { return; } _db.ActiveLeases.Delete(lse.Id); if (_db.ActiveLeases.HasId(lse.Id)) { throw Bad.State <LeaseDTO>("Deactivated", "Exists-As-Active"); } _db.Balances.GetRepo(lse.Id) .RecomputeFrom(lse.DeactivatedDate); }
IEnumerator ending() { inGame.SetActive(false); if (playerHP >= 150) { Good.SetActive(true); yield return(new WaitForSecondsRealtime(3f)); } else if (playerHP > 0) { Bad.SetActive(true); yield return(new WaitForSecondsRealtime(3f)); } ResultCanvas.SetActive(true); ThisCanvas.SetActive(false); }
// 게임 결과 창 뜨게 하기 public void Result() { RemoveCanvas.SetActive(false); mode = enemyMode.End; Time.timeScale = 0; Result_Screen.SetActive(true); if (playerHP >= 250) { Good.SetActive(true); Bad.SetActive(false); } else { Good.SetActive(false); Bad.SetActive(true); } }
private void GenerateFrom(ITenantDBsDir dir) { if (Date > dir.Collections.LastPostedDate()) { throw Bad.Arg("Daily Colxns Date", $"{Date:d MMM yyyy}"); } FillSectionCollections(dir); FillOtherCollections(dir); DepositsSum = GetTotalDeposits(dir); if (CollectionsSum != DepositsSum) { throw Bad.Data($"Collections sum ({CollectionsSum:N2}) for [{Date:d-MMM-yyyy}] does not match deposits sum ({DepositsSum:N2})."); } this.SetSummary(SectionColxnsRow.GetSummary(this)); }
private GLAcctType GetAcctType(int acctTypeTid) { switch (acctTypeTid) { case 33: return(GLAcctType.Asset); case 34: return(GLAcctType.Liability); case 35: return(GLAcctType.Equity); case 36: return(GLAcctType.Income); case 37: return(GLAcctType.Expense); default: throw Bad.Data($"Invalid GL Acct type tid: [{acctTypeTid}]"); } }
private void LaunchReport(AppArguments args) { switch (args.Param1.ToUpper()) { case "OVERDUES": WithOverduesReport.Show(args); break; case "COLXNSMRY": ColxnSummaryExcelWriter.Launch(args); break; case "DAILYSTATUS": DailyStatusReportVM.Launch(args); break; case "GLRECAP": GLRecapExcelWriter.Launch(args); break; case "COLLECTORS": CollectorsMainVM.Launch(args); break; case "CHKVOUCHERS": CheckVouchersReporter.Launch(args); break; default: throw Bad.Arg("Param1", args.Param1); } }
public static int GetGLId(this OtherColxnDTO dto) { if (dto.GLAccount != null) { return(dto.GLAccount.Id); } switch (dto.OtherCode) { case OtherCode.CR_Fee: return(56); case OtherCode.Parking: return(55); case OtherCode.Processing_Fee: return(57); case OtherCode.Other: return(60); default: throw Bad.Arg("OtherColxnDTO.OtherCode", dto.OtherCode); } }
public void TakePopulationDamage(int damage) { Debug.Log("TakingDamage"); population -= damage; CivWorld.SetActive(false); ThrivingWorld.SetActive(false); Fertile.SetActive(false); Broken.SetActive(false); Bad.SetActive(false); Apocalyptic.SetActive(false); if (population > 2000) { CivWorld.SetActive(true); } if (population > 1500) { ThrivingWorld.SetActive(true); } if (population > 1200) { Fertile.SetActive(true); } if (population > 900) { Broken.SetActive(true); } if (population > 600) { Bad.SetActive(true); } if (population > 0) { Apocalyptic.SetActive(true); } if (population < 0) { GameOver(); } }
IEnumerator ending() { if (playerHP >= 250) { Good.SetActive(true); yield return(new WaitForSecondsRealtime(3f)); story.SetActive(true); talkingEnemy.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/two"); yield return(new WaitForSecondsRealtime(3f)); for (int i = 1; i <= 8; i++) { talk.SetActive(true); talk.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/two_good" + i); yield return(new WaitForSecondsRealtime(3f)); } } else if (playerHP > 0) { Bad.SetActive(true); yield return(new WaitForSecondsRealtime(3f)); story.SetActive(true); talkingEnemy.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/two"); yield return(new WaitForSecondsRealtime(3f)); for (int i = 1; i <= 6; i++) { talk.SetActive(true); talk.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/two_bad" + i); yield return(new WaitForSecondsRealtime(3f)); } } SceneManager.LoadScene(4); }
private static List <JournalVoucherDTO> CastAsAllByfs(List <dynamic> byfHeadrs, List <dynamic> byfItems, MainWindowVM2 main) { var headrs = byfHeadrs.Select(_ => (JournalVoucherDTO)CastAsVoucherDTO(_)).ToList(); var itemsDict = GroupItemsByHeader(byfItems, main.RntCache); foreach (var kvp in itemsDict) { var headr = headrs.SingleOrDefault(_ => _.Id == kvp.Key); if (headr == null) { throw No.Match <JournalVoucherDTO>("Id", kvp.Key); } if (!headr.IsBalanced) { throw Bad.State <JournalVoucherDTO>("balanced", "not balanced"); } headr.Allocations = kvp.Value; headr.Amount = headr.TotalCredit; } return(headrs); }
private decimal GetAmount(dynamic byf, out BillCode billCode) { if (TryGetValue(byf.rent, billCode = BillCode.Rent, out decimal val)) { return(val); } if (TryGetValue(byf.surcharge, billCode = BillCode.Rent, out val)) { return(val); } if (TryGetValue(byf.rights, billCode = BillCode.Rights, out val)) { return(val); } if (TryGetValue(byf.electric, billCode = BillCode.Electric, out val)) { return(val); } if (TryGetValue(byf.water, billCode = BillCode.Water, out val)) { return(val); } throw Bad.Data("Balance Adj. has no valid amount"); }
public async Task <string> GetMacIP(string mac, string ip) { string keyMac = "at_w29Gb2QzjVe6mkhoh8lvY934dQcV2"; string urlMac = $"https://api.macaddress.io/v1?apiKey={keyMac}&output=json&search={mac}"; string urlIp = $"http://free.ipwhois.io/json/{ip}"; try { using (HttpClient htMac = new HttpClient()) { htMac.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage responseMac = await htMac.GetAsync(urlMac); HttpResponseMessage responseIp = await htMac.GetAsync(urlIp); string jsonMac = await responseMac.Content.ReadAsStringAsync(); string jsonIp = await responseIp.Content.ReadAsStringAsync(); Mac m = JsonConvert.DeserializeObject <Mac>(jsonMac); Ip i = JsonConvert.DeserializeObject <Ip>(jsonIp); MacIp macIp = new MacIp(m, i); string jsonMacIp = JsonConvert.SerializeObject(macIp); return(jsonMacIp); } } catch { Bad bad = new Bad(); string jsonBad = JsonConvert.SerializeObject(bad); return(jsonBad); } }
private static bool IsUpdateConfirmed(out DailyBillDTO dtoForUpdate, SoaViewerVM vm) { var day1 = vm?.Rows?.LastOrDefault(); if (day1 == null) { throw Bad.Data("Day 1 row"); } dtoForUpdate = day1.DTO; var origVal = day1.Rights.OpeningBalance; var suggVal = GetSuggestedVal(day1.Rights, vm); var dte = $"{day1.Date:d-MMM-yyyy}"; var msg = $"[{dte}] Starting Rights (orig.val: {origVal:N2})"; var ok = PopUpInput.TryGetDecimal(msg, out decimal newVal, suggVal); if (!ok) { return(false); } EditBillRow(dtoForUpdate, newVal, vm); return(true); }
public async Task <string> GetIp(string ip) { string urlIp = $"http://free.ipwhois.io/json/{ip}"; try { using (HttpClient htIp = new HttpClient()) { htIp.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await htIp.GetAsync(urlIp); string jsonIp = await response.Content.ReadAsStringAsync(); return(jsonIp); } } catch { Bad bad = new Bad(); string jsonBad = JsonConvert.SerializeObject(bad); return(jsonBad); } }
public async Task <string> GetGmail(string gmail) { string urlGmail = $"https://api.2ip.ua/email.json?email={gmail}"; try { using (HttpClient htGmail = new HttpClient()) { htGmail.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await htGmail.GetAsync(urlGmail); string jsonGmail = await response.Content.ReadAsStringAsync(); return(jsonGmail); } } catch { Bad bad = new Bad(); string jsonBad = JsonConvert.SerializeObject(bad); return(jsonBad); } }
public int CompareTo(Bad rhs) { return 100; }
public static decimal Decimal(dynamic dynamic) => (decimal?)Decimal_(dynamic) ?? throw Bad.Cast <decimal>((string)dynamic);