/// <summary> /// /// </summary> /// <param name="category"></param> public void Remove(OperationCategory category) { try { // create sql parameters SqlParameter prmCode = new SqlParameter("@OperationCode", SqlDbType.Int, 50); prmCode.Direction = ParameterDirection.Input; prmCode.Value = category.OperationCode; SqlParameter prmErrNum = new SqlParameter("@ErrorNumber", SqlDbType.Int, 4); prmErrNum.Direction = ParameterDirection.Output; SqlParameter prmErrMsg = new SqlParameter("@ErrorMessage", SqlDbType.NVarChar, 150); prmErrMsg.Direction = ParameterDirection.Output; // execute procedure to create a new operation code Database.ExecuteNonQuery("UspRemoveOperationCategory", CommandType.StoredProcedure, prmCode, prmErrNum, prmErrMsg); int errorCode = int.Parse(prmErrNum.Value.ToString()); if (errorCode > 0) { string errorMessage = prmErrMsg.Value.ToString(); SecurityException customEx = new SecurityException(errorMessage); throw customEx; } } catch (Exception ex) { throw ex; } }
public string GetApiStatsAsXml() { XElement xelement = new XElement("ApiStats"); IOrderedEnumerable <KeyValuePair <OperationCategory, PerformanceEntry.ApiMeasure> > orderedEnumerable = from kvp in this.ApiMap orderby kvp.Value.Latency.Max descending select kvp; foreach (KeyValuePair <OperationCategory, PerformanceEntry.ApiMeasure> keyValuePair in orderedEnumerable) { OperationCategory key = keyValuePair.Key; PerformanceEntry.ApiMeasure value = keyValuePair.Value; XElement content = new XElement("Api", new object[] { new XAttribute("Name", key), new XAttribute("Succeeded", value.Succeeded), new XAttribute("Failed", value.Failed), new XAttribute("Average", value.Latency.Average.ToString(".00")), new XAttribute("Max", value.Latency.Max), new XAttribute("MaxMinusOne", value.Latency.MaxMinusOne), new XAttribute("Min", value.Latency.Min), new XAttribute("MinPlusOne", value.Latency.MinPlusOne) }); xelement.Add(content); } return(xelement.ToString()); }
public T ExecuteRequest <T>(DistributedStoreKey key, OperationCategory operationCategory, OperationType operationType, string dbgInfo, Func <IDistributedStoreKey, bool, StoreKind, T> func) { RequestInfo req = new RequestInfo(operationCategory, operationType, dbgInfo); this.EnqueueShadowAction <T>(key, req, func); return(this.PerformAction <T>(key, req, true, func)); }
private void GetOperations() { try { if (Request["id"] != null) { int resourceID = int.Parse(Request["id"]); OperationManager opMan = new OperationManager(); OperationCollection ops = opMan.FindOperationsByResources(resourceID); cbxListOperation.Items.Clear(); foreach (Operation op in ops) { OperationCategoryManager opCatMan = new OperationCategoryManager(); OperationCategory opCat = opCatMan.GetOperationCategory(op.OperationCode); ListItem cbxOperation = new ListItem(opCat.Name, op.OperationCode.ToString()); ListItem cbxDenyOperation = new ListItem(opCat.Name, op.OperationCode.ToString()); cbxListOperation.Items.Add(cbxOperation); cbxListDenyOperation.Items.Add(cbxDenyOperation); } } } catch (Exception ex) { ucErrorBox.Message = ex.Message; CurrentFormState = FormState.ErrorState; } }
public async Task <IActionResult> PutProductCategorie([FromRoute] Guid Id, [FromBody] OperationCategory obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != obj.Id) { return(BadRequest()); } _context.Entry(obj).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public OperationCategoryCollection GetOperationCategoriesByResourceTypeCode(string ResourceTypeCode) { try { OperationCategoryCollection collection = new OperationCategoryCollection(); // create sql parameters SqlParameter prmResourceTypeCode = new SqlParameter("@ResourceTypeCode", SqlDbType.VarChar, 10); prmResourceTypeCode.Direction = ParameterDirection.Input; prmResourceTypeCode.Value = ResourceTypeCode; using (IDataReader dr = Database.ExecuteReader("UspGetOperationCatByResourceType", CommandType.StoredProcedure, prmResourceTypeCode)) { while (dr.Read()) { OperationCategory operationCat = Populate(dr); collection.Add(operationCat); } } return(collection); } catch (Exception ex) { throw ex; } }
protected void OnRemoving(OperationCategory category, int operationsCount) { if (Removing != null) { Removing(category, operationsCount); } }
private void InitializeExpenseCategories() { if (_dataContext.Categories.Collection.Any(x => x.Type == Entities.Enums.OperationType.Expense)) { return; } var foodIcon = _iconsService.Icons.First(x => x.Name.Equals("ForkAndKnife")); var transportIcon = _iconsService.Icons.First(x => x.Name.Equals("Taxi")); var foodCategory = new OperationCategory() { Name = Resources.AppResources.FoodCategoryName, Type = Entities.Enums.OperationType.Expense, IconSource = foodIcon }; var transportCategory = new OperationCategory() { Name = Resources.AppResources.TransportCategoryName, Type = Entities.Enums.OperationType.Expense, IconSource = transportIcon }; _dataContext.Categories.Add(foodCategory); _dataContext.Categories.Add(transportCategory); }
/// <summary> /// /// </summary> /// <returns></returns> public OperationCategoryCollection GetAllOperationCategories() { try { OperationCategoryCollection collection = new OperationCategoryCollection(); collection.Clear(); using (IDataReader dr = Database.ExecuteReader("UspGetAllOperationCategories", CommandType.StoredProcedure)) { while (dr.Read()) { OperationCategory category = Populate(dr); collection.Add(category); } } return(collection); } catch (Exception ex) { throw ex; } }
public void CreateOneWalletOperation(int personId, int walletId, int operationCategoryId, decimal balance, string description, DateTime?date) { CheckArgument.CheckForNull(description, nameof(description)); Person person = this.UnitOfWork.PersonRepository.GetById(personId) ?? throw new InvalidForeignKeyException(typeof(Person).Name); Wallet wallet = this.UnitOfWork.WalletRepository.GetById(walletId) ?? throw new InvalidForeignKeyException(typeof(Wallet).Name); OperationCategory operationCategory = this.UnitOfWork.OperationCategoryRepository.GetById(operationCategoryId) ?? throw new InvalidForeignKeyException(typeof(OperationCategory).Name); PersonWallet personWallet = this.UnitOfWork.PersonWalletRepository.GetPersonWalletByPersonAndWallet(personId, walletId) ?? throw new InvalidPropertyException(typeof(PersonWallet).Name); wallet.Balance = balanceCalculator.CountNewWalletBalance(wallet.Balance, balance, operationCategory.Type); this.UnitOfWork.WalletRepository.Update(wallet); OperationInfo operationInfo = new OperationInfo() { Balance = balance, Description = description, Date = date ?? DateTime.Now }; this.UnitOfWork.OperationInfoRepository.Add(operationInfo); Operation operation = new Operation() { OperationCategoryID = operationCategory.ID, OperationInfoID = operationInfo.ID, PersonWalletID = personWallet.ID }; this.GetRepository().Add(operation); this.UnitOfWork.SaveChanges(); }
protected Transfer(OperationCategory category, Currency currency, decimal amount) : base(category) { Argument.NotNull(currency, "currency"); Argument.Satisfies(amount, x => x > 0, "amount", "Amount should be greater than zero."); Currency = currency; Amount = amount; }
/// <summary> /// /// </summary> /// <param name="operationCode"></param> /// <returns></returns> public OperationCategory GetOperationCategory(int operationCode) { try { // create sql parameters SqlParameter prmCode = new SqlParameter("@OperationCode", SqlDbType.Int, 4); prmCode.Direction = ParameterDirection.Input; prmCode.Value = operationCode; using (IDataReader dr = Database.ExecuteReader("UspGetOperationCategory", CommandType.StoredProcedure, prmCode)) { if (dr.Read()) { OperationCategory operationCategory = new OperationCategory( int.Parse(dr["OperationCode"].ToString()) , dr["Name"].ToString(), dr["Description"].ToString()); return(operationCategory); } } return(null); } catch (Exception ex) { throw ex; } }
// Token: 0x060005E6 RID: 1510 RVA: 0x000163C8 File Offset: 0x000145C8 public void RunOperationAndTranslateException(OperationCategory operationCategory, string keyName, Action action) { this.RunOperationAndTranslateException <int>(operationCategory, keyName, delegate() { action(); return(0); }, false); }
public RequestInfo(OperationCategory operationCategory, OperationType operationType, string debugStr) { this.ClientRequestId = Guid.NewGuid(); this.OperationCategory = operationCategory; this.OperationType = operationType; this.DebugStr = debugStr; this.InitiatedTime = DateTimeOffset.Now; }
protected Transfer(OperationCategory category, Account from, Account to, Currency currency, decimal amount) : this(category, currency, amount) { Argument.NotNull(from, "from"); Argument.NotNull(to, "to"); From = from; To = to; }
public void ExecuteRequest(DistributedStoreKey key, OperationCategory operationCategory, OperationType operationType, string dbgInfo, Action <IDistributedStoreKey, bool, StoreKind> action) { this.ExecuteRequest <int>(key, operationCategory, operationType, dbgInfo, delegate(IDistributedStoreKey storeKey, bool isPrimary, StoreKind storeKind) { action(storeKey, isPrimary, storeKind); return(0); }); }
private void OnRemoving(OperationCategory category, int operationsCount) { var result = MessageBox.Show(string.Format( AppResources.RemoveCategoryMessage, category.Name, operationsCount), AppResources.AttentionCaption, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { _viewModel.KeepRemoving(category); } }
public async Task <IActionResult> Add([FromBody] OperationCategory obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.OperationCategories.Add(obj); await _context.SaveChangesAsync(); return(CreatedAtAction("GetById", new { Id = obj.Id }, obj)); }
/// <summary> /// /// </summary> /// <param name="operationCode"></param> /// <param name="name"></param> /// <returns></returns> public OperationCategory Create(string name, string description) { try { // create sql parameters SqlParameter prmCode = new SqlParameter("@OperationCode", SqlDbType.Int, 4); prmCode.Direction = ParameterDirection.Output; SqlParameter prmName = new SqlParameter("@Name", SqlDbType.NVarChar, 250); prmName.Direction = ParameterDirection.Input; prmName.Value = name; SqlParameter prmDesc = new SqlParameter("@Description", SqlDbType.NVarChar, 500); prmDesc.Direction = ParameterDirection.Input; prmDesc.Value = description; SqlParameter prmErrNum = new SqlParameter("@ErrorNumber", SqlDbType.Int, 4); prmErrNum.Direction = ParameterDirection.Output; SqlParameter prmErrMsg = new SqlParameter("@ErrorMessage", SqlDbType.NVarChar, 150); prmErrMsg.Direction = ParameterDirection.Output; // execute procedure to create a new operation code Database.ExecuteNonQuery("UspCreateOperationCategory", CommandType.StoredProcedure, prmCode, prmName, prmDesc, prmErrNum, prmErrMsg); int errorCode = int.Parse(prmErrNum.Value.ToString()); switch (errorCode) { case 0: // create success int operationCode = int.Parse(prmCode.Value.ToString()); OperationCategory operationCategory = new OperationCategory(operationCode, name, description); return(operationCategory); default: // error string errorMessage = prmErrMsg.Value.ToString(); SecurityException customEx = new SecurityException(errorMessage); throw customEx; } } catch (Exception ex) { throw ex; } }
private string GetHierarchicalName() { OperationCategory category = this; var categories = new List <OperationCategory>(); while (category != null) { categories.Add(category); category = category.Parent; } categories.Reverse(); return(string.Join(" / ", categories.Select(x => x.Name))); }
protected void LoadOperationCat() { if (Request.QueryString["code"] == string.Empty) { return; } OperationCategoryManager operationCatManager = new OperationCategoryManager(); OperationCategory operationCat = new OperationCategory(); operationCat = operationCatManager.GetOperationCategory(int.Parse(Request.QueryString["code"])); txtName.Text = operationCat.Name; txtDescription.Text = operationCat.Description; }
public LimitInfo GetLimitInfo(OperationCategory category, IEnumerable <Operation> operations, CurrencyName currency, CashAccount account) { if (category.Limited == false || category.Limit == 0 || !operations.Any()) { return(null); } var date = DateTime.Now; var filtered = operations.ByType(account, OperationType.Expense).ByCurrency(currency).ByCategory(category).ByMonth(date); var info = CalculateLimitInfo(filtered, date, category.Limit, category.Name, currency); return(info); }
/// <summary> /// /// </summary> /// <param name="dr"></param> /// <returns></returns> private OperationCategory Populate(IDataReader dr) { try { OperationCategory operationCategory = new OperationCategory( int.Parse(dr["OperationCode"].ToString()) , dr["Name"].ToString(), dr["Description"].ToString()); return(operationCategory); } catch (Exception ex) { throw ex; } }
private CategoryInfo GetCategoryInfo(IEnumerable <Operation> operations, OperationCategory category, CurrencyName currency) { var categorized = operations.ByCategory(category); var amountTotal = operations.ByType(category.Type).Sum(x => x.Amount); var amountCategorized = categorized.Sum(x => x.Amount); var iterations = categorized.Count(); var persentage = amountTotal > 0 ? amountCategorized * 100 / amountTotal : 0; return(new CategoryInfo() { Name = category.Name, Amount = amountCategorized, Iterations = iterations, Persentage = Math.Round(persentage, 1), BaseCurrency = currency.ToString() }); }
private void InitializeIncomeCategories() { if (_dataContext.Categories.Collection.Any(x => x.Type == Entities.Enums.OperationType.Income)) { return; } var salaryIcon = _iconsService.Icons.First(x => x.Name.Equals("Briefcase")); var salaryCategory = new OperationCategory() { Name = Resources.AppResources.SalaryCategoryName, Type = Entities.Enums.OperationType.Income, IconSource = salaryIcon }; _dataContext.Categories.Add(salaryCategory); }
private void RecordApiResult(OperationCategory category, bool isSuccess, long latencyInMs) { PerformanceEntry.ApiMeasure apiMeasure; if (!this.ApiMap.TryGetValue(category, out apiMeasure) || apiMeasure == null) { apiMeasure = new PerformanceEntry.ApiMeasure(); this.ApiMap[category] = apiMeasure; } if (isSuccess) { apiMeasure.Succeeded++; } else { apiMeasure.Failed++; } apiMeasure.Latency.Update(latencyInMs); }
internal CardTransfer(OperationCategory category, UserCard source, UserCard destination, decimal amount) : base(category, source.Account, destination.Account, source.Account.Currency, amount) { Argument.NotNull(source, "from"); Argument.Satisfies(source, x => x.Account != null, "from", "Source card should be bound to a bank account."); Argument.NotNull(destination, "to"); Argument.Satisfies(destination, x => x.Account != null, "to", "Destination card should be bound to a bank account."); Argument.Satisfies(destination, x => x.Id != source.Id, "to", "Destination card can't be the same as source card."); From = source.Account; To = destination.Account; Currency = source.Account.Currency; SourceCard = source; DestinationCard = destination; Amount = amount; Type = source.Owner.Id == destination.Owner.Id ? CardTransferType.Personal : CardTransferType.Interbank; }
public NameIdClassModel GetCategoryWithCurrentName(string nameParam, DBModelManagers.Abstract.OperationType operationTypeParam) { using (_unitOfWork = DIManager.UnitOfWork) { int operationTypeId = Convert.ToInt32(operationTypeParam); OperationCategory contextCategory = _unitOfWork.PersonalAccountantContext.Set <OperationCategory>(). FirstOrDefault <OperationCategory>(x => x.Name.ToUpper() == nameParam.ToUpper() && x.OperationTypeId == operationTypeId); if (contextCategory == null) { int Id = 0; contextCategory = Int32.TryParse(nameParam, out Id) ? _unitOfWork.PersonalAccountantContext.Set <OperationCategory>().FirstOrDefault(x => x.Id == Id && x.OperationTypeId == operationTypeId) : CreateNewCategory(nameParam, operationTypeParam); } return(_mapperManager.MapModel <OperationCategory, NameIdClassModel>(contextCategory)); } }
protected void btnSave_Click(object sender, EventArgs e) { OperationCategoryManager OperationCatManager = new OperationCategoryManager(); try { OperationCategory operationCat = new OperationCategory(int.Parse(Request.QueryString["code"]), txtName.Text.Trim(), txtDescription.Text.Trim()); OperationCatManager.Update(operationCat); Response.Redirect("../Manage/"); } catch (Exception ex) { uctErrorBox.Visible = true; uctErrorBox.Message = "Hệ thống có lỗi: " + ex.Message; this.SaveErrorLog(ex); } }
// Token: 0x060005A5 RID: 1445 RVA: 0x0001507C File Offset: 0x0001327C private IDistributedStoreKey OpenKeyFinal(string subKeyName, DxStoreKeyAccessMode mode, bool isIgnoreIfNotExist, ReadWriteConstraints constraints) { OperationCategory operationCategory = OperationCategory.OpenKey; OperationType operationType = OperationType.Read; if (mode == DxStoreKeyAccessMode.CreateIfNotExist) { operationCategory = OperationCategory.OpenOrCreateKey; operationType = OperationType.Write; } DistributedStoreKey compositeKey = new DistributedStoreKey(this.FullKeyName, subKeyName, mode, this.Context); IDistributedStoreKey result; try { result = (DistributedStore.Instance.ExecuteRequest <bool>(this, operationCategory, operationType, string.Format("SubKey: [{0}] Mode: [{1}] IsBestEffort: [{2}] IsConstrained: [{3}]", new object[] { subKeyName, mode, isIgnoreIfNotExist, constraints != null }), delegate(IDistributedStoreKey key, bool isPrimary, StoreKind storeKind) { this.ThrowIfKeyIsInvalid(key); IDistributedStoreKey distributedStoreKey = key.OpenKey(subKeyName, mode, isIgnoreIfNotExist, ReadWriteConstraints.Copy(constraints)); if (distributedStoreKey != null) { DistributedStore.Instance.SetKeyByRole(compositeKey, isPrimary, distributedStoreKey); return(true); } return(false); }) ? compositeKey : null); } finally { if (compositeKey.PrimaryStoreKey == null) { compositeKey.CloseKey(); } } return(result); }