/// <summary> /// Group the components by the filename of the prototype /// </summary> /// <param name="component">The current component</param> private void GroupComponentByPartName(TxComponent component) { TxStorage storage = component.StorageObject as TxStorage; if (storage is TxLibraryStorage && component.Visibility != TxDisplayableObjectVisibility.CannotBeDisplayed && rules != null && rules.Length > 0) { string filename = RwFileAndDirectoryUtilities.GetFilenameWithoutExtension((storage as TxLibraryStorage).FullPath).ToUpper(); foreach (string rule in rules) { if (filename.Contains(rule)) { AddToDictionary(rule, component); return; } } AddToDictionary("EMPTY", component); } }
public bool CreateTransaction(string sender, string receiver, IncentiveAssigned incentiveAssgined, out string transactionID) { watch.Start(); Wallet senderWallet; Wallet receiverWallet; transactionID = null; try { if (!GetUserWallet(sender, out senderWallet)) { log.DebugFormat("Invalid UserId: [{0}]", sender); return(false); } if (!GetUserWallet(receiver, out receiverWallet)) { log.DebugFormat("Invalid UserId: [{0}]", receiver); return(false); } //calc sender balance senderWallet.Balance[incentiveAssgined.IncentiveName] -= incentiveAssgined.IncentiveQty; //calc receiver balance receiverWallet.Balance[incentiveAssgined.IncentiveName] += incentiveAssgined.IncentiveQty; //generate transaction if (!TxStorage.GenerateTransaction(sender, receiver, incentiveAssgined, out transactionID)) { Log.Error("ERROR. Cannot Generate Transaction!"); return(false); } senderWallet.AssociateTransaction(transactionID); receiverWallet.AssociateTransaction(transactionID); watch.Stop(); Log.DebugFormat("Execution Time: [{0}] in milliseconds to register transaction", watch.ElapsedMilliseconds); watch.Reset(); return(true); } catch (Exception ex) { Log.ErrorFormat(ex.Message); return(false); } }