protected BaseApiResponse GetCategoriesInPos(int posId, OnBalance.Models.ApiRequestParameters rp) { ApiCategoriesListReponse resp = new ApiCategoriesListReponse(); resp.categories = _categoryRepository.GetCategoriesBy(posId, 0, rp.Offset, rp.Limit).ToList(); resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.Ok); return resp; }
private async void PayAccount() { try { var invoice = (vwInvoicedPayments)dgInvoices.SelectedItem; AccountKey accountKey = (AccountKey)tvWallet.SelectedItem; PayAccountWindow payAccount = new PayAccountWindow(tcBitcoin, accountKey, invoice); if (payAccount.ShowDialog() == true) { Cursor = Cursors.Wait; SpendTx spendTx = await tcBitcoin.PayOutTx(accountKey, payAccount.PaymentAddress, payAccount.AmountToPay, payAccount.MinerRate, payAccount.TxMessage); if (!spendTx.IsSatisfied) { MessageBox.Show(Properties.Resources.UnsatisfiedPayment, payAccount.Title, MessageBoxButton.OK, MessageBoxImage.Error); tcBitcoin.PayOutCancel(spendTx); } else { Cursor = Cursors.Arrow; SpendConfirmWindow spendDialog = new SpendConfirmWindow(spendTx); if (spendDialog.ShowDialog() == true) { Cursor = Cursors.Wait; bool broadcast = await spendTx.Send(); if (broadcast) { if (tcBitcoin.PayAccountBalanceNode(spendTx, invoice.AccountCode, payAccount.CashCodeForChange)) { Refresh(); OnBalance?.Invoke(this, new EventArgs()); } } } else { tcBitcoin.PayOutCancel(spendTx); } } } } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Cursor = Cursors.Arrow; } }
private void MenuItemProperties_Click(object sender, RoutedEventArgs e) { fnChangeResult change = (fnChangeResult)dgChange.SelectedItem; ChangePropertiesWindow propertiesWindow = new ChangePropertiesWindow(change, tcBitcoin); if (propertiesWindow.ShowDialog() == true) { Refresh(); OnBalance?.Invoke(this, new EventArgs()); } }
public BalanceItem(OnBalance.Domain.Entities.BalanceItem x) { Id = x.Id; InternalCode = x.InternalCode; PosId = x.PosId; Price = x.Price; PriceOfRelease = x.PriceOfRelease; ProductName = x.ProductName; SizeName = x.SizeName; Quantity = x.Quantity; StatusId = x.StatusId; IsChangedLocally = x.ChangedFrom.Equals('L') || x.ChangedFrom.Equals('l'); }
private void MenuItemDelete_Click(object sender, RoutedEventArgs e) { try { fnChangeResult change = (fnChangeResult)dgChange.SelectedItem; if (tcBitcoin.DeleteReceiptKey(change.PaymentAddress)) { Refresh(); OnBalance?.Invoke(this, new EventArgs()); } } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
public BaseController(OnBalance.Core.IObLogger logger) { if (logger == null) { throw new ArgumentNullException("logger"); } _logger = logger; _isDebugEnabled = false; //Logger.IsDebugEnabled; _isInfoEnabled = true; //Logger.IsInfoEnabled; _isWarnEnabled = false;// Logger.IsWarnEnabled; _isErrorEnabled = false; // Logger.IsErrorEnabled; //Info("Calling SetTempMessagesToViewBag() in BaseController..."); //// Prepare messages and errors in TempData for use in views //SetTempMessagesToViewBag(); }
private void MenuItemSync_Click(object sender, RoutedEventArgs e) { try { Cursor = Cursors.Wait; fnChangeResult change = (fnChangeResult)dgChange.SelectedItem; tcBitcoin.GetStatement(change.FullHDPath); Refresh(); OnBalance?.Invoke(this, new EventArgs()); } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Cursor = Cursors.Arrow; } }
private void MenuItemPayIn_Click(object sender, RoutedEventArgs e) { try { fnTxResult txId = (fnTxResult)dgTx.SelectedItem; PayInWindow payIn = new PayInWindow(tcBitcoin, txId); if (payIn.ShowDialog() == true) { if (tcBitcoin.TxPayIn(txId.PaymentAddress, txId.TxId, payIn.AccountCode, payIn.CashCode, payIn.PaidOn, payIn.PaymentReference)) { Refresh(); OnBalance?.Invoke(this, new EventArgs()); } } } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
protected ApiPosListReponse GetListOfPos(OnBalance.Models.ApiRequestParameters rp) { ApiPosListReponse resp = new ApiPosListReponse(); rp.SetLimitIfNotPositive(10); //if(rp.ParentId > 0) //{ // resp.listOfPos = new OrganizationRepository().GetByParentId(rp.ParentId); // resp.message = string.Concat("List of POS by parent ", rp.ParentId); // InfoFormat("Got list of POS by parent ID: {0}, offset {1}, limit: {2}. Total POS are {3}", rp.ParentId, rp.Offset, rp.Limit, resp.total); //} else //{ // resp.listOfPos = new OrganizationRepository().GetListOfLastPos(rp.Offset, rp.Limit); // InfoFormat("Got list of POS, offset {0}, limit: {1}. Total POS are {2}", rp.Offset, rp.Limit, resp.total); //} resp.listOfPos = _organizationRepository.GetByParentId(rp.ParentId, true); resp.message = string.Concat("List of POS by parent ", rp.ParentId); InfoFormat("Got list of POS by parent ID: {0}, offset {1}, limit: {2}. Total POS are {3}", rp.ParentId, rp.Offset, rp.Limit, resp.total); resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.Ok); return resp; }
public void SaveScore() { OnBalance?.Invoke(score, specialCoin); if (GameRecord.Instance.maxScore[GameRecord.Instance.currentLevelIndex - 1] < maxScore) { GameRecord.Instance.maxScore[GameRecord.Instance.currentLevelIndex - 1] = maxScore; } if (GameRecord.Instance.specialCoin[GameRecord.Instance.currentLevelIndex - 1] < specialCoin) { GameRecord.Instance.specialCoin[GameRecord.Instance.currentLevelIndex - 1] = specialCoin; } if (GameRecord.Instance.currentLevelIndex == GameRecord.Instance.beingPassedLevel) { GameRecord.Instance.beingPassedLevel++; } GameRecord.Instance.currentLevelIndex++; GameRecord.Instance.Save(GameRoot.GameRecordJsonSavePath); }
public Product(OnBalance.Domain.Entities.Product product) { Id = product.Id; CategoryId = product.CategoryId; CreatedAt = product.CreatedAt; InternalCode = product.InternalCode; Name = product.Name; PosId = product.PosId; Price = product.Price; StatusId = product.StatusId; Uid = product.Uid; UserId = product.UserId; ProductDetails = product.ProductDetails.Select(x => new OnBalance.Models.ProductDetail { id = x.Id, parameter_value = x.ParameterValue, quantity = x.Quantity, price_minor = x.PriceMinor, price_release_minor = x.PriceReleaseMinor, product_id = x.ProductId, DataJson = x.DataJson, }).ToList(); }
private void MenuItemAssignReceipt_Click(object sender, RoutedEventArgs e) { try { AccountKey extendedKey = (AccountKey)tvWallet.SelectedItem; var invoice = (vwInvoicedReceipts)dgInvoices.SelectedItem; AssignKeyWindow assignKey = new AssignKeyWindow(); assignKey.InvoiceNumber = invoice.InvoiceNumber; assignKey.dgReceiptKeys.ItemsSource = tcBitcoin.NodeCash.fnChangeUnassigned(tcBitcoin.CashAccountCode); if (assignKey.ShowDialog() == true) { if (tcBitcoin.AssignReceiptKey(assignKey.KeyName, assignKey.PaymentAddress, assignKey.InvoiceNumber, assignKey.Note)) { Refresh(); OnBalance?.Invoke(this, new EventArgs()); } } } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
// // GET: /balance/dosend //[HttpPost] public ActionResult DoSend(OnBalance.Models.BalanceItem[] items) { try { InfoFormat("Balance/DoSend [{0}] was called...", Request.HttpMethod); InfoFormat("Got {0} items to post to POS...", items == null ? -1 : items.Length); foreach(string key in Request.Form.AllKeys) { DebugFormat(" {0}: {1}", key, Request.Form[key]); } string callback = Request["callback"] as string; PostBalanceViewModel bal = new PostBalanceViewModel(); bal.Results = items; NameValueCollection nvc = new NameValueCollection(); nvc.Add("_token", bal._token); nvc.Add("Total", bal.Total.ToString()); for(int i = 0; i < bal.Total; i++) { nvc.Add(string.Format("Results[{0}][InternalCode]", i), bal.Results[i].InternalCode); nvc.Add(string.Format("Results[{0}][Name]", i), bal.Results[i].ProductName); nvc.Add(string.Format("Results[{0}][Price]", i), (bal.Results[i].Price * 100).ToString("#####")); nvc.Add(string.Format("Results[{0}][Details]['39']", i), "1"); nvc.Add(string.Format("Results[{0}][Details]['41']", i), "2"); } //WebClient wc = new WebClient(); //string posBalanceUrl = "http://gjsportland.com/test.php/lt/product/dobalance"; //byte[] ba = wc.UploadValues(posBalanceUrl, "POST", nvc); ////return Json(bal, JsonRequestBehavior.AllowGet); //Log.InfoFormat("Got response from POS: {0}", Encoding.ASCII.GetString(ba)); //return Content("Got: " + Encoding.ASCII.GetString(ba)); if(string.IsNullOrEmpty(callback)) { return Json(new { Status = Status.Completed }, JsonRequestBehavior.AllowGet); } return Content(string.Format("{0}({{ \"Status\": \"{1}\" }})", callback, Status.Completed)); } catch(Exception ex) { Error("Error sending local changes to POS!", ex); throw ex; } }
public BaseApiResponse(OnBalance.Models.ApiResponseCodes responseCode) { SetResponseCode(responseCode); }
public ActionResult Create(OnBalance.Domain.Entities.Product model) { try { InfoFormat("User #{0} saving new product", User.Identity.Name); SetTempOkMessage("New product '{0}' was created", model.Name); return RedirectToAction("edit", new { id = model.Id }); } catch(Exception ex) { Error("Error creating product!", ex); ModelState.AddModelError("", ex.Message); } return View(model); }
public CategoryListItem(OnBalance.Domain.Entities.Category model) { }
protected ApiProductsListResponse GetProductsInPos(int posId, OnBalance.Models.ApiRequestParameters rp) { ApiProductsListResponse resp = new ApiProductsListResponse(); if(posId < 1) { ErrorFormat("Bad ID of POS (ID: {0}) to retrieve products!", posId); resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.BadRequest); } var pos = _organizationRepository.GetById(posId); if(pos == null) { ErrorFormat("Could not retrieve products for non-existing POS (ID: {0})!", posId); resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.NotFound); resp.message = MyMessages.Products.PosIsNotFound; return resp; } rp.SetLimitIfNotPositive(10); InfoFormat("API: getting list of product in POS #{0}, parameters: {1}", posId, rp); var products = _productRepository.GetLastInPos(posId, rp.Offset, rp.Limit); resp.products = products.ToList(); return resp; }
public void SetResponseCode(OnBalance.Models.ApiResponseCodes responseCode) { _responseCode = responseCode; message = ""; }
public ActionResult Edit(OnBalance.Domain.Entities.Product model) { if( ModelState.IsValid ) { model = _productRepository.GetById(model.Id); UpdateModel<OnBalance.Domain.Entities.Product>(model); _productRepository.Update(model); _productRepository.SubmitChanges(); return RedirectToAction("Edit", new { id = model.Id }); } return View(model); }
// // GET: /parser/preview public ActionResult Preview(string id, OnBalance.ViewModels.Parsers.ParserOptions options) { string data = Request["Data"]; string productType = Request["ProductType"].Trim().ToLower(); string[] lines = data.Split("\n".ToCharArray()); IBalanceParser p = productType == "gjdress" ? new GjExcelParserDress() : new GjExcelParserShoes(); p.AllowEmptyPrice = options.AllowEmptyPrice; var items = p.ParseFileContent(lines); // Pass statistics ViewBag.ProcessedNonEmptyLines = p.TotalProcessedNonEmptyLines; ViewBag.CategoryLines = p.TotalCategoryLines; if (p.Errors.Count > 0 && options.RedirectToErrors) { TempData["ParserErrors"] = p.Errors.ToList(); TempData["TotalProcessedNonEmptyLines"] = p.TotalProcessedNonEmptyLines; return RedirectToAction("errors", new { id = id }); } var notFound = FindNonExistingCategories(items); if (notFound.Count > 0 && options.RedirectToCategories) { TempData["NotFound"] = notFound; return RedirectToAction("NotFoundCategories"); } // Just to beautify grid ViewBag.SizeNames = ExtractAvailableSizes(items); if (options.PrepareInsertSql) { ViewBag.CategoryNames = items.Select(x => x.CategoryName) .Distinct() .ToList(); PrepareInsertSql(items, 110000); } if (items.Count > 0) { items = items.OrderBy(x => x.CategoryName).ToList(); TempData["ExchangeItems"] = items; //StringBuilder sb = new StringBuilder(); //foreach (var e in p.Errors) //{ // sb.AppendFormat("#{0}\t{1}", e.LineNr, e.Line); // sb.AppendLine("<br />"); // Response.Write(sb.ToString()); // Response.End(); //} } return View("Preview", "_LayoutLogin", items); }