public int Operation(OperationType operationType, string operand1, string operand2) { var parsed1 = int.TryParse(operand1, out int operandOneParsed); var parsed2 = int.TryParse(operand2, out int operandTwoParsed); if (parsed1 && parsed2) { if (operationType.Equals(OperationType.Div)) { return(operandOneParsed / operandTwoParsed); } if (operationType.Equals(OperationType.Mul)) { return(operandOneParsed * operandTwoParsed); } if (operationType.Equals(OperationType.Sub)) { return(operandOneParsed - operandTwoParsed); } return(operandOneParsed + operandTwoParsed); } return(0); }
/// <summary> /// Commit or rollback nested transaction groups /// </summary> /// <param name="operationType">The operation type determines whether to commit or to rollback transaction groups</param> private void HandleNestedTransactionGroups(OperationType operationType) { while (m_transactionGroup != null) { if (operationType.Equals(OperationType.CommitTransactionGroup)) { m_transactionGroup.Commit(); } else { m_transactionGroup.RollBack(); } if (m_transactionGroup.HasEnded()) { m_transGroupNode = m_transGroupNode.Parent; if (m_transGroupNode.Equals(m_rootNode)) { m_transactionGroup = null; } else { m_transactionGroup = m_transGroupNode.Tag as TransactionGroup; } } else { throw new System.ApplicationException("Could not end a transaction group"); } } }
private static void PerformOperation(AccountType accType, OperationType oppType) { switch (accType) { case AccountType.Active: Console.WriteLine(" True"); Console.WriteLine(" Active"); break; case AccountType.Operative: if (oppType.Equals(OperationType.BalanceEnquiry)) { Console.WriteLine(" True"); Console.WriteLine(" InOperative"); } else { Console.WriteLine(" True"); Console.WriteLine(" Active"); } break; case AccountType.Closed: Console.WriteLine(" False"); Console.WriteLine(" Closed"); break; } }
/// <summary> /// Creates intance of IGeneratorServiceBase based on operation type /// </summary> /// <param name="operation">Operation type</param> /// <param name="eventHandler">Event handler that provides showing progress informations on UI</param> /// <returns>Instance of IGeneratorServiceBase</returns> public static IGeneratorServiceBase CreateService(OperationType operation, EventHandler <string> eventHandler) { if (operation.Equals(OperationType.Unit_Test_Results_From_Tessy)) { _generatorService = new GeneratorServiceForUnitResults(eventHandler); } else if (operation.Equals(OperationType.Module_Integration_Test_Results_From_Tessy)) { _generatorService = new GeneratorServiceForIntegrationResults(eventHandler); } else { _generatorService = new GeneratorServiceForMtsTestSpec(eventHandler); } return(_generatorService); }
private bool LimitCheck(OperationType operationType, BigInteger targetAmount, BigInteger userTotalAmount, Currency targetCurrency) { if (operationType.Equals(OperationType.Purchase)) { return((userTotalAmount + targetAmount) > targetCurrency.PurchaseLimit); } return((userTotalAmount + targetAmount) > targetCurrency.SellingRate); }
public bool Equals(AbstractOperation op) { // If parameter is null return false: if ((object)op == null) { return(false); } // Return true if the operation types match: return(OperationType.Equals(op.OperationType)); }
public void GetBill(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); if (saveFileDialog.ShowDialog() == DialogResult.OK) { using (Stream s = File.Open(saveFileDialog.FileName, FileMode.CreateNew)) using (StreamWriter sw = new StreamWriter(s)) { sw.WriteLine($"Кассир {cashier.ToString()}"); sw.WriteLine($"Покупатель {userNameBox.Text} {userSurnameBox.Text}"); sw.WriteLine($"Покупатель {userNameBox.Text} {userSurnameBox.Text}"); string action = lastOperationType.Equals(OperationType.Purchase) ? "Купил" : "Продал"; string firstAmount = lastOperationType.Equals(OperationType.Purchase) ? targetCurrencyBox.Text : userCurrencyBox.Text; string firstCurrency = lastOperationType.Equals(OperationType.Purchase) ? ((Currency)targetCurrency.SelectedItem).CurrencyName : ((Currency)userCurrency.SelectedItem).CurrencyName; string secondAmount = lastOperationType.Equals(OperationType.Selling) ? targetCurrencyBox.Text : userCurrencyBox.Text; string secondCurrency = lastOperationType.Equals(OperationType.Selling) ? ((Currency)targetCurrency.SelectedItem).CurrencyName : ((Currency)userCurrency.SelectedItem).CurrencyName; sw.WriteLine($"{action} {firstAmount} {firstCurrency} за {secondAmount} {secondCurrency}"); } } }
/// <summary> /// Contains the id of the manipulated entity. (null if not necessary) /// </summary> // public int? ManipulatedId { get; set; } // for new feature: put payload into cache after insertion /// <summary> /// Gets the manipulated amount of entities by the entity and the operation /// </summary> public int ManipulatedAmount(Type entity, OperationType op) { // linear search through list foreach (var element in _manipulatedEntities) { if (entity.Equals(element.Entity) && op.Equals(element.OperationType)) { return(element.AffectedEntries); } } return(0); }
private BigInteger GetTargetAmount(Currency targetCurrency, Currency userCurrency, BigInteger userAmount, OperationType operationType) { if (targetCurrency.Equals(userCurrency)) { return(userAmount); } if (operationType.Equals(OperationType.Purchase)) { return(userAmount * targetCurrency.PurchaseRate / userCurrency.SellingRate); } return(userAmount * targetCurrency.SellingRate / userCurrency.PurchaseRate); }
private string GenerateMessage(bool success, OperationType operation, List <int> ids = null) { string result = success ? "Successfully" : "Unsuccessfully"; string action = operation.Equals(OperationType.Assign) ? "assigned" : "removed"; string idToString = ids != null?GenerateIdString(ids) : string.Empty; var builder = new StringBuilder(); builder .Append(result) .Append(action) .Append("permissions. ") .Append(idToString); return(builder.ToString()); }
public override bool Equals(object obj) { if (obj is OperationDefinition operationDefinition) { return (OperationType.Equals(operationDefinition.OperationType) && ( Name == null && operationDefinition.Name == null || Name != null && operationDefinition.Name != null && Name.Equals(operationDefinition.Name) ) && ( VariableDefinitions == null && operationDefinition.VariableDefinitions == null || VariableDefinitions != null && operationDefinition.VariableDefinitions != null && VariableDefinitions.SequenceEqual(operationDefinition.VariableDefinitions) ) && ( Directives == null && operationDefinition.Directives == null || Directives != null && operationDefinition.Directives != null && Directives.SequenceEqual(operationDefinition.Directives) ) && ( SelectionSet == null && operationDefinition.SelectionSet == null || SelectionSet != null && operationDefinition.SelectionSet != null && SelectionSet.SequenceEqual(operationDefinition.SelectionSet) )); } return(base.Equals(obj)); }
/// <summary> /// 不传type时对 observer进行检查,实现了几种接口就监听几种 /// 传入type时 只监听对应接口 /// </summary> /// <param name="observer"></param> /// <param name="type"></param> public void RegisterObserver(IOperationObserver observer, OperationType type0, OperationType type1 = OperationType.Default, OperationType type2 = OperationType.Default) { if (observer == null) { return; } if (type0.Equals(OperationType.Default)) { return; } var observerItem = new ObserverItem(observer, type0); if (!observerItems.Contains(observerItem)) { observerItems.Add(observerItem); } if (!type1.Equals(OperationType.Default)) { observerItem = new ObserverItem(observer, type1); if (!observerItems.Contains(observerItem)) { observerItems.Add(observerItem); } } if (!type2.Equals(OperationType.Default)) { observerItem = new ObserverItem(observer, type2); if (!observerItems.Contains(observerItem)) { observerItems.Add(observerItem); } } }
/// <summary> /// Commit or rollback nested transaction groups /// </summary> /// <param name="operationType">The operation type determines whether to commit or to rollback transaction groups</param> private void HandleNestedTransactionGroups(OperationType operationType) { while (m_transactionGroup != null) { if (operationType.Equals(OperationType.CommitTransactionGroup)) { m_transactionGroup.Commit(); } else { m_transactionGroup.RollBack(); } if (m_transactionGroup.HasEnded()) { m_transGroupNode = m_transGroupNode.Parent; if (m_transGroupNode.Equals(m_rootNode)) { m_transactionGroup = null; } else { m_transactionGroup = m_transGroupNode.Tag as TransactionGroup; } } else { throw new System.ApplicationException("Could not end a transaction group"); } } }
bool EnviarPreAdvice() { TransDepotProxy proxy = new TransDepotProxy(); RequestPreAdvice request = new RequestPreAdvice(); request.YardCode = ConfigurationManager.AppSettings["DepSanAgustin"].ToString(); request.ActionType = "P"; request.OperationTypeMovementCode = ""; request.VoyageStopExternalCode = txtOrdenServicio.Text.Trim(); request.VesselIMO = ""; request.VoyageNumber = ""; request.OceanCarrier = OceanCarrier; if (OperationType != null) { if (OperationType.Equals("E")) { request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBK"].ToString(); } else { request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBL"].ToString(); } } request.OperationType = OperationType; request.ReferenceNumber = ReferenceNumber; request.PlaceOfReceipt = PlaceOfReceipt; request.PortOfLoading = PortOfLoading; request.PortOfDischarge = PortOfDischarge; request.PlaceOfDelivery = PlaceOfDelivery; request.CustomerERPCode = CustomerERPCode; request.ShipmentType = ""; request.Equipments.Add(new PreAdviceEquipment() { EquipmentNumber = EquipmentNumber, EquipmentTypeSizeISOCode = EquipmentTypeSizeISOCode, IsEmpty = (IsEmpty.Equals("S")) ? true : false, IsHazardous = (IsHazardous.Equals("S")) ? true : false, RequiresReview = false, SetPoint = (SetPoint.Trim() != "") ? Convert.ToDouble(SetPoint) : 0.0, SetPointUnitOfMeasure = SetPointUnitOfMeasure, Ventilation = 0.0, RelativeHumidityLevel = 0.0, O2Level = 0.0, CO2Level = 0.0, RequiresPlug = (RequiresPlug.Equals("S")) ? true : false, Technology = "" }); ResponsePreAdvice resp = new ResponsePreAdvice(); resp = proxy.PreAdvice(request); if (!resp.isValid) { List <string> listaDestinatarios = new List <string>(); List <string> listaCopia = new List <string>(); List <string> listaCopiaOculta = new List <string>(); string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString(); if (destinatarios != "" && destinatarios.Contains(";")) { var correosDestino = destinatarios.Split(';'); foreach (string item in correosDestino) { listaDestinatarios.Add(item); } } else { listaDestinatarios.Add(destinatarios); } string copia = ConfigurationManager.AppSettings["ConCopia"].ToString(); if (copia != "" && copia.Contains(";")) { var correosCopia = copia.Split(';'); foreach (string item in correosCopia) { listaCopia.Add(item); } } else { listaCopia.Add(copia); } string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString(); if (copiaOculta != "" && copiaOculta.Contains(";")) { var correosCopiaOculta = copiaOculta.Split(';'); foreach (string item in correosCopiaOculta) { listaCopiaOculta.Add(item); } } else { listaCopiaOculta.Add(copiaOculta); } new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta); } return(true); }