public void AddEntry(int entryId, int userId, string name, long timestamp) { var operation = Operation.Add(entryId, userId, timestamp, name); RecordOperation(operation); UpdateEntryName(entryId); }
public void Add() { Key key = new Key(args.ns, args.set, "addkey"); string binName = args.GetBinName("addbin"); // Delete record if it already exists. client.Delete(null, key); // Perform some adds and check results. Bin bin = new Bin(binName, 10); client.Add(null, key, bin); bin = new Bin(binName, 5); client.Add(null, key, bin); Record record = client.Get(null, key, bin.name); AssertBinEqual(key, record, bin.name, 15); // Test add and get combined. bin = new Bin(binName, 30); record = client.Operate(null, key, Operation.Add(bin), Operation.Get(bin.name)); AssertBinEqual(key, record, bin.name, 45); }
/// <summary> /// Demonstrate multiple operations on a single record in one call. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { // Write initial record. Key key = new Key(args.ns, args.set, "opkey"); Bin bin1 = new Bin("optintbin", 7); Bin bin2 = new Bin("optstringbin", "string value"); console.Info("Put: namespace={0} set={1} key={2} binname1={3} binvalue1={4} binname1={5} binvalue1={6}", key.ns, key.setName, key.userKey, bin1.name, bin1.value, bin2.name, bin2.value); client.Put(args.writePolicy, key, bin1, bin2); // Add integer, write new string and read record. Bin bin3 = new Bin(bin1.name, 4); Bin bin4 = new Bin(bin2.name, "new string"); console.Info("Add: " + bin3.value); console.Info("Write: " + bin4.value); console.Info("Read:"); Record record = client.Operate(args.writePolicy, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get()); if (record == null) { throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}", key.ns, key.setName, key.userKey)); } ValidateBin(key, record, bin3.name, 11L, record.GetValue(bin3.name)); ValidateBin(key, record, bin4.name, bin4.value.ToString(), record.GetValue(bin4.name)); }
public void TestMethodAdd(int i, int j, int result) { var testOpertaion = new Operation(); var actual = testOpertaion.Add(1, 2); Assert.AreEqual(result, actual); }
public void Add_Operation() { Operation o = new Operation(100, 1); o.Add(); Assert.IsTrue(o.Id > 0); }
public static void Run() { AerospikeClient client = new AerospikeClient("172.28.128.3", 3000); WritePolicy policy = new WritePolicy(); policy.SetTimeout(50); Key key = new Key("test", "MultiOps", "opkey"); Bin bin1 = new Bin("optintbin", 7); Bin bin2 = new Bin("optstringbin", "string value"); client.Put(policy, key, bin1, bin2); Bin bin3 = new Bin(bin1.name, 4); Bin bin4 = new Bin(bin2.name, "new string"); Record record = client.Operate(policy, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get()); var rec = client.Operate(policy, key, Operation.Get(), Operation.Delete()); }
public void WantToTestAddFunctionality() { var operation = new Operation(); int sum = operation.Add(2, 2); Assert.AreEqual(4, sum); }
// GET: Operation public ActionResult Index(int?fnum, int?secnum, string op) { int FNum = fnum != null ? fnum.Value : 0; int SecNum = secnum != null ? secnum.Value : 0; Operation operation = new Operation(); int result = 0; if (op != null) { if (op == "Add") { result = operation.Add(FNum, SecNum); } if (op == "Divide") { result = operation.Divide(FNum, SecNum); } if (op == "Multiply") { result = operation.Multiply(FNum, SecNum); } if (op == "Subtract") { result = operation.Subtract(FNum, SecNum); } } ViewData["result"] = result; return(View(result)); }
static void Deposer() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("---------Dépot---------"); Console.ResetColor(); Console.Write("Numéro de compte : "); string numero = Console.ReadLine(); Compte compte = new Compte(numero); if (compte.Id > 0) { Client c = new Client(compte.ClientId); Console.Write("Montant du dépot : "); decimal depot = Convert.ToDecimal(Console.ReadLine()); Operation o = new Operation(depot, compte.Id); o.Add(); if (o.Id > 0) { compte.Solde += depot; compte.Update(); Console.WriteLine("Opération effectuée"); } } else { Console.WriteLine("Aucun compte avec ce numero"); } }
/// <summary> /// Add integer values. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { Key key = new Key(args.ns, args.set, "addkey"); string binName = args.GetBinName("addbin"); // Delete record if it already exists. client.Delete(args.writePolicy, key); // Perform some adds and check results. Bin bin = new Bin(binName, 10); console.Info("Initial add will create record. Initial value is " + bin.value + '.'); client.Add(args.writePolicy, key, bin); bin = new Bin(binName, 5); console.Info("Add " + bin.value + " to existing record."); client.Add(args.writePolicy, key, bin); Record record = client.Get(args.policy, key, bin.name); if (record == null) { throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}", key.ns, key.setName, key.userKey)); } // The value received from the server is an unsigned byte stream. // Convert to an integer before comparing with expected. int received = record.GetInt(bin.name); int expected = 15; if (received == expected) { console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}", key.ns, key.setName, key.userKey, bin.name, received); } else { console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received); } // Demonstrate add and get combined. bin = new Bin(binName, 30); console.Info("Add " + bin.value + " to existing record."); record = client.Operate(args.writePolicy, key, Operation.Add(bin), Operation.Get(bin.name)); expected = 45; received = record.GetInt(bin.name); if (received == expected) { console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}", key.ns, key.setName, key.userKey, bin.name, received); } else { console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received); } }
public void TestMethod1() { Operation operation = new Operation(); int xpectedR = 13; int actualR; actualR = operation.Add(8, 5); Assert.AreEqual(xpectedR, actualR); }
public long IncrementSingle(string counterName, long by) { Key recordKey = new Key(NAMESPACE, SINGLE_SET, counterName); Bin incrementCounter = new Bin(SINGLE_COUNTER_BIN, by); Record record = asClient.Operate(null, recordKey, Operation.Add(incrementCounter), Operation.Get(SINGLE_COUNTER_BIN)); return(record.GetLong(SINGLE_COUNTER_BIN)); }
public Tuple <Int64, Int64> IncrementMultiple(string counterName, string firstCounter, long firstBy, string secondCounter, long secondBy) { Key recordKey = new Key(NAMESPACE, MULTI_SET, counterName); Bin incrementCounter1 = new Bin(firstCounter, firstBy); Bin incrementCounter2 = new Bin(secondCounter, secondBy); Record record = asClient.Operate(null, recordKey, Operation.Add(incrementCounter1), Operation.Add(incrementCounter2), Operation.Get(firstCounter), Operation.Get(secondCounter)); return(Tuple.Create <Int64, Int64>(record.GetLong(firstCounter), record.GetLong(secondCounter))); }
public static T Set(T left, T right, bool addOrRemove) { if (addOrRemove) { return(Operation.Add(left, right)); } else { return(Operation.Remove(left, right)); } }
static void Main(string[] args) { Console.WriteLine("Hello! Do you want to do operation on integers or doubles?"); string answer = Console.ReadLine(); Operation op = new Operation(answer); Console.WriteLine("This calculator can show you result of sum, substraction, division, multiplication and modulo"); Console.WriteLine("Result of sum 1 + 2 = " + Operation.Add(1, 2)); Console.WriteLine("Result of sum 1,3 + 2,5 = " + Operation.Add(1.3, 2.5)); Console.ReadKey(); }
} //updateUser private void updateUserUsingOperate(AerospikeClient client, Key userKey, WritePolicy policy, long ts) { // TODO: Initiate operate passing in policy, user record key, // .Add operation incrementing tweet count, .Put operation updating timestamp // and .Get operation to read the user record. // Exercise K6 Record record = client.Operate(policy, userKey, Operation.Add(new Bin("tweetcount", 1)), Operation.Put(new Bin("lasttweeted", ts)), Operation.Get()); // TODO: Output the most recent tweetcount // Exercise K6 Console.WriteLine("INFO: The tweet count now is: " + record.GetValue("tweetcount")); } //updateUserUsingOperate
private void TsmPutFinished_Click(object sender, EventArgs e) { if ((sender as ToolStripMenuItem).Name == "tsmPutFinished1") { Operation.Add(string.Format("手动点击{0}放盘完成", Current.Blanker.Stations[0].Name)); Current.Blanker.SetPutClampFinish(0); } else { Operation.Add(string.Format("手动点击{0}放盘完成", Current.Blanker.Stations[1].Name)); Current.Blanker.SetPutClampFinish(1); } }
public OperationWindow(Compte c, ListView l, TypeOperation t) { InitializeComponent(); compte = c; listViewComptes = l; type = t; Title = type.ToString() + " N° : " + compte.NumeroCompte; bOperation.Click += (sender, e) => { if (type == TypeOperation.Depot) { Operation o = new Operation(Convert.ToDecimal(montant.Text), compte.Id); o.Add(); if (o.Id > 0) { compte.Solde += o.Montant; compte.Update(); message.Content = "Opération effectuée"; listViewComptes.ItemsSource = Compte.GetComptes(); } else { message.Content = "Erreur operation"; } } else if (type == TypeOperation.Retrait) { Operation o = new Operation(Convert.ToDecimal(montant.Text) * -1, compte.Id); if (compte.Solde >= o.Montant * -1) { o.Add(); if (o.Id > 0) { compte.Solde += o.Montant; compte.Update(); message.Content = "Opération effectuée"; listViewComptes.ItemsSource = Compte.GetComptes(); } else { message.Content = "Erreur operation"; } } else { message.Content = "pas de solde"; } } }; }
private void BtnOpenAllNetControl_Click(object sender, EventArgs e) { Operation.Add("点击打开全部网控"); Current.ovens.Where(o => o.IsAlive).ToList().ForEach(o => { o.Floors.ForEach(f => { if (!f.IsNetControlOpen) { f.toOpenNetControl = true; } }); }); }
public TableDic <TV, T> HighlightValue(HighlightOperator operation) { if (!Operation.ContainsKey(operation.Field)) { Operation.Add(operation.Field, new List <HighlightOperator> { operation }); } else { Operation[operation.Field].Add(operation); } return(this); }
public User IncrementVisits(String userId, String name) { Key recordKey = new Key(NAMESPACE, RECORD_SET, userId); Bin nameBin = new Bin(NAME_BIN, name); Bin visitBin = new Bin(VISIT_BIN, 1); Record record = asClient.Operate(null, recordKey, Operation.Add(visitBin), Operation.Put(nameBin), Operation.Get(NAME_BIN), Operation.Get(VISIT_BIN)); return(new User(userId, record.GetString(NAME_BIN), record.GetLong(VISIT_BIN))); }
private static void MultiOps(AerospikeClient client, WritePolicy writePolicy, Key key) { Console.WriteLine("Multiops"); var bin1 = new Bin("optintbin", 7); var bin2 = new Bin("optstringbin", "string value"); client.Put(writePolicy, key, bin1, bin2); var bin3 = new Bin(bin1.name, 4); var bin4 = new Bin(bin2.name, "new string"); var record = client.Operate(writePolicy, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get()); Console.WriteLine("Record: " + record); }
public void Operate() { // Write initial record. Key key = new Key(args.ns, args.set, "opkey"); Bin bin1 = new Bin("optintbin", 7); Bin bin2 = new Bin("optstringbin", "string value"); client.Put(null, key, bin1, bin2); // Add integer, write new string and read record. Bin bin3 = new Bin(bin1.name, 4); Bin bin4 = new Bin(bin2.name, "new string"); Record record = client.Operate(null, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get()); AssertBinEqual(key, record, bin3.name, 11); AssertBinEqual(key, record, bin4); }
private void LoadOperations() { foreach (var operation in ctx.CodingStyle.GetOperations(Type)) { try { if (Operation.ContainsKey(operation.Name)) { Operation[operation.Name].AddGroup(operation); } else { Operation.Add(operation.Name, new DomainOperation(ctx, operation)); } } catch (TypeNotConfiguredException) { } catch (ReturnTypesDoNotMatchException) { } catch (ParameterTypesDoNotMatchException) { } catch (IdenticalSignatureAlreadyAddedException) { } } }
public static void Run() { AerospikeClient client = new AerospikeClient("172.28.128.3", 3000); // Initialize policy. WritePolicy policy = new WritePolicy(); policy.SetTimeout(50); // 50 millisecond timeout Key key = new Key("test", "Add", "mykey"); string binName = "addbin"; // Delete record if it already exists. client.Delete(null, key); // Perform some adds and check results. Bin bin = new Bin(binName, 10); client.Add(null, key, bin); bin = new Bin(binName, 5); client.Add(null, key, bin); Record record = client.Get(null, key, bin.name); //AssertBinEqual(key, record, bin.name, 15); Console.WriteLine(record.GetInt(binName)); // test add and get combined. bin = new Bin(binName, 30); record = client.Operate(null, key, Operation.Add(bin), Operation.Get(bin.name)); Console.WriteLine(record.GetInt(binName)); client.Close(); }
static void Retirer() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("---------Retrait---------"); Console.ResetColor(); Console.Write("Numéro de compte : "); string numero = Console.ReadLine(); Compte compte = new Compte(numero); if (compte.Id > 0) { Client c = new Client(compte.ClientId); Console.Write("Montant du retrait : "); decimal retrait = Convert.ToDecimal(Console.ReadLine()); if (retrait <= compte.Solde) { Operation o = new Operation(retrait * -1, compte.Id); o.Add(); if (o.Id > 0) { compte.Solde += retrait * -1; compte.Update(); Console.WriteLine("Opération effectuée"); } } else { Console.WriteLine("Solde insuffisant"); } } else { Console.WriteLine("Aucun compte avec ce numero"); } }
/// <summary> /// Update the configuration for ALL deployed AuditAgents /// </summary> public void ScannerUpdate() { // Get the list of computers which currently have the AuditAgent deployed (running or not) AssetDAO lwDataAccess = new AssetDAO(); AssetList listAssets = new AssetList(lwDataAccess.EnumerateDeployedAssets(), true); //if (listAssets.Count == 0) //{ // MessageBox.Show("Found no assets which already have an AuditAgent deployed.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} FormLoadScannerConfiguration form = new FormLoadScannerConfiguration(true, "Select a configuration file to update all assets."); if (form.ShowDialog() == DialogResult.OK) { try { // Use the Deserialize method to restore the object's state. //auditScannerDefinition = AuditWizardSerialization.DeserializeObject(form.FileName); string agentIniFileName = Path.Combine(AuditAgentStrings.AuditAgentFilesPath, AuditAgentStrings.AuditAgentIni); File.Copy(form.FileName, agentIniFileName, true); } catch (System.IO.FileNotFoundException) { MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error); // JML TODO log this exception return; } catch (System.IO.IOException) { MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error); // JML TODO log this exception return; } catch { MessageBox.Show("An error has occurred whilst updating the AuditAgent, please see the log file for further information.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error); // JML TODO log this exception return; } } else { return; } // Ensure that we at least have a data path //if (auditScannerDefinition.DeployPathData == "") //{ // MessageBox.Show("The audit scanner configuration has not been configured yet", "Audit Scanner Configuration Not Defined"); // return; //} // Write the Agent Ini File to the Agent folder as this will combine the scanner configuration // with data taken from the Application Definitions File (publisher mappings etc) //string agentIniFileName = Path.Combine(AuditAgentStrings.AuditAgentFilesPath, AuditAgentStrings.AuditAgentIni); //if (auditScannerDefinition.WriteTo(agentIniFileName) != 0) //{ // MessageBox.Show("Error : Failed to write the AuditAgent configuration file", "Deploy Error"); // return; //} // We will pend the operation by adding it to the Operations queue in the database // The AuditWizard service works on this queue foreach (Asset asset in listAssets) { Operation newOperation = new Operation(asset.AssetID, Operation.OPERATION.updateconfiguration); newOperation.Add(); } MessageBox.Show("The AuditAgent Update Request has been queued for " + listAssets.Count.ToString() + " PC(s) and will be actioned by the AuditWizard Service\n\nYou can check its progress by viewing the Operations Log", "Operations Queued", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public object DispatchPost(RequestModel obj, string name) { return(name == null ? "Give a name" : Operation.Add(name, obj.FindCorrectDTO(), User.Identity.GetUserId())); }
public void AddTest() { Operation op = new Operation(); Assert.AreEqual(5, op.Add(2, 3)); }
} //updateUser private void updateUserUsingOperate(AerospikeClient client, Key userKey, WritePolicy policy, long ts) { Record record = client.Operate(policy, userKey, Operation.Add(new Bin("tweetcount", 1)), Operation.Put(new Bin("lasttweeted", ts)), Operation.Get()); Console.WriteLine("INFO: The tweet count now is: " + record.GetValue("tweetcount")); } //updateUserUsingOperate