public void TestAddGetRemoveCurrencyAccount() { using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false)) if (lServerAccess.Logon("*****@*****.**", "davinci", "test")) { var lControl = CurrencyControl.GetCurrencyControl(); var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test"); var lAdvocacy = lControl.GetCryptoCurrency(1, ""); lAdvocacy.RootSeed = lRootSeed; lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(10)); lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(11)); var lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyAccount[]>(lServerAccess.GetMonitoredAcccounts(1, 0)); foreach (var lItem in lList) { Assert.IsTrue(lServerAccess.RemoveMonitoredAcccounts(lItem.Id)); } lList = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyAccount[]>(lServerAccess.GetMonitoredAcccounts(1, 0)); Assert.IsTrue(lList.Length == 0, "Not all accounts were removed."); lServerAccess.Logoff(); } else { throw new Exception("Basic Logon and log off failed."); } }
public void TestAddCreateTransaction() { using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false)) if (lServerAccess.Logon("*****@*****.**", "davinci", "test")) { var lControl = CurrencyControl.GetCurrencyControl(); var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test"); var lAdvocacy = lControl.GetCryptoCurrency(1, ""); lAdvocacy.RootSeed = lRootSeed; lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(10)); var lTransaction = new CurrencyTransaction(); var s = lServerAccess.GetTransactionRecords(1, 0); var lTxList = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter()); var lTx = lTxList[0]; lTransaction.AddInput(lTx.Outputs[0]); lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "mzqD8sEGXfRMvcnNnkoGn6wyMN9AGUxaAB"); lTransaction.CurrencyId = 1; lTransaction.TxFee = 1000; var lTxData = lServerAccess.CreateTransaction(lTransaction); lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction); //lServerAccess.SendTransaction(1, lTxData); lServerAccess.Logoff(); } else { throw new Exception("Basic Logon and log off failed."); } }
public CurrencySelectPage(Currencies availableCurrencies, Currencies preSelectedCurrencies, StackLayout stackLayout, CurrencyControl btczControl) { _btczControl = btczControl; _stackLayout = stackLayout; conversionUri = availableCurrencies.ConversionUri; selectedCurrencies = preSelectedCurrencies; var addedCurrencies = new List <Currency>(selectedCurrencies.CurrencyList.ToList()); AvailableCurrencies = availableCurrencies.CurrencyList; filteredCurrencies = availableCurrencies.CurrencyList.Select(x => x).ToList(); InitializeComponent(); currencyList.ItemsSource = FilteredCurrencies; NavigationPage.SetHasNavigationBar(this, false); if (selectedCurrencies != null) { foreach (var ccy in addedCurrencies) { ccy.ConversionUri = String.Format("{0}{1}", conversionUri, ccy.Code); AddCurrencyControl(ccy); } } }
private void AddCurrencyControl(Currency ccy) { if (!selectedCurrencies.CurrencyList.Contains(ccy)) { selectedCurrencies.CurrencyList.Add(ccy); } var ccyControl = new CurrencyControl(ccy, selectedCurrencies, _stackLayout, _btczControl); _stackLayout.Children.Add(ccyControl); }
/// <summary> /// Adding new record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ADDNewRecord(object sender, DirectEventArgs e) { panelRecordDetails.ActiveIndex = 0; ApprovalsGridPanel.Disabled = true; //Reset all values of the relative object BasicInfoTab.Reset(); CurrencyControl.setCurrency(_systemService.SessionHelper.GetDefaultCurrency()); FillBranch(); FillDepartment(); //if (!string.IsNullOrEmpty(_systemService.SessionHelper.GetEmployeeId())) //{ // EmployeeQuickViewRecordRequest req = new EmployeeQuickViewRecordRequest(); // req.RecordID = _systemService.SessionHelper.GetEmployeeId(); // req.asOfDate = DateTime.Now; // RecordResponse<EmployeeQuickView> resp = _employeeService.ChildGetRecord<EmployeeQuickView>(req); // if (!resp.Success) // { // Common.errorMessage(resp); // return; // } // branchId.Select(resp.result.branchId); // departmentId.Select(resp.result.departmentId); // employeeId.GetStore().Add(new object[] // { // new // { // recordId =_systemService.SessionHelper.GetEmployeeId(), // fullName =resp.result.name.fullName // } // }); //} //employeeId.SetValue(_systemService.SessionHelper.GetEmployeeId()); status.Select("1"); status.SetValue("1"); qty.SetValue(1); currentPurchaseOrderId.Text = ""; date.SelectedDate = DateTime.Now; apStatus.setApprovalStatus("1"); status.SetValue("1"); status.Select("1"); this.EditRecordWindow.Title = Resources.Common.AddNewRecord; //timeZoneCombo.Select(timeZoneOffset.Text); this.EditRecordWindow.Show(); }
private IClientCurrencyAdvocacy GetAdvocacy(uint aCurrencyId) { if (string.IsNullOrEmpty(FSeed)) { throw new InvalidOperationException("A seed must be assign before asking for an advocacy"); } IClientCurrencyAdvocacy lAdvocacy; lock (FCurrencyAdvocacies) { if (!FCurrencyAdvocacies.ContainsKey(aCurrencyId)) { CurrencyItem lCurrency = FWalletPandoraServer.GetCurrency(aCurrencyId); FCurrencyAdvocacies.Add(aCurrencyId, CurrencyControl.GetCurrencyControl().GetClientCurrencyAdvocacy(aCurrencyId, lCurrency.ChainParamaters)); FCurrencyAdvocacies[aCurrencyId].RootSeed = FSeed; } lAdvocacy = FCurrencyAdvocacies[aCurrencyId]; } if (!FAddresses.ContainsKey(aCurrencyId)) { while (!FAddresses.TryAdd(aCurrencyId, new List <string>())) { ; } } if (FAddresses[aCurrencyId].Count < AddressNumberSetting) { FAddresses[aCurrencyId].Clear(); for (uint it = 1; it <= AddressNumberSetting; it++) { FAddresses[aCurrencyId].Add(lAdvocacy.GetAddress(it)); #if DEBUG System.Diagnostics.Debug.WriteLine(string.Format("Currency: {0}, Address: {1}, PrivateKey: {2}", aCurrencyId, lAdvocacy.GetAddress(it), lAdvocacy.GetPrivateKey(it))); #endif } } return(lAdvocacy); }
public void TestMyKey() { var lAdvocacy = CurrencyControl.GetClientCurrencyAdvocacy(1, new ChainParams(ChainParams.NetworkType.MainNet), GetSeed); var lSeed = CurrencyControl.GenerateRootSeed("*****@*****.**", "davincij", new Guid("9DB7353AF6EA48350FFD7127BF65CC95").ToByteArray()); if (lSeed != "AC1946EC73DB3A6C5BFB34E23300AF92") { throw new Exception(); } var lTestAddress = lAdvocacy.GetAddress(0); var lTestKey = lAdvocacy.GetPrivateKey(0); var lTestKey2 = lAdvocacy.GetPrivateKey(1); var lTestAdderss2 = lAdvocacy.GetAddress(1); Assert.AreEqual(lTestAddress, "16G1qvnTRXdNcf7we1rHTWCKZd7Lbpbh39"); Assert.AreEqual(lTestKey, "KxqP92g4DtsvBs9hkz32qZCEvD7p2MkCrMeBNngEDh3guVsvsj5p"); Assert.AreEqual(lTestAdderss2, "36Q3MhZhcMz69YE6QJpeKRAJDW32DrV3yx"); Assert.AreEqual(lTestKey2, "L2zFMfmB1harosR6wF3MGrkhphBKHmpHoJ3mGqkXPfHhaavEy2Yz"); }
public void InitializeRootSeed(bool aForceSeed = false) { UserStatus lUserStatus = FWalletPandoraServer.GetUserStatus(); DateTime lLockDate = new DateTime(2019, 4, 8, 23, 59, 59); string lEmail = FWalletPandoraServer.Email; string lUsername = FWalletPandoraServer.Username; if (FSeed == null || aForceSeed) { FSeed = FKeyManager.GetSecretRootSeed(lEmail.ToLower(), lUsername.ToLower()); if (lUserStatus.StatusDate <= lLockDate) { string lStatusMessage = lUserStatus.ExtendedInfo; if (lUserStatus.ExtendedInfo.Contains("Actual Case is:")) { int lStart = lStatusMessage.IndexOf(":", StringComparison.Ordinal) + 1; string[] lSubstring = lStatusMessage.Substring(lStart, lStatusMessage.Length - lStart).Split(new string[] { "***" }, StringSplitOptions.RemoveEmptyEntries); lEmail = lSubstring[0].Trim(); lUsername = lSubstring[1].Trim(); FSeed = FKeyManager.GetSecretRootSeed(lEmail, lUsername); } else { FSeed = FKeyManager.GetSecretRootSeed(lEmail, lUsername); CurrencyItem lCurrency = FWalletPandoraServer.GetCurrency(1); IClientCurrencyAdvocacy lAdvocacy = CurrencyControl.GetCurrencyControl().GetClientCurrencyAdvocacy((uint)lCurrency.Id, lCurrency.ChainParamaters); lAdvocacy.RootSeed = FSeed; string lComparationAddress = lAdvocacy.GetAddress(1); string lAddress = GetCoinAddress(1); if (lComparationAddress != lAddress) { string lMessage = string.Format("Please contact support at [email protected] about Ontime Issue #1344"); throw new Exception(lMessage); } FWalletPandoraServer.MarkOldUser(lEmail, lUsername); } } } }
public void TestSendTransaction() { using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false)) if (lServerAccess.Logon("*****@*****.**", "davinci", "test")) { var lTransaction = new CurrencyTransaction(); lTransaction.CurrencyId = 3; var lControl = CurrencyControl.GetCurrencyControl(); var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test"); var lAdvocacy = lControl.GetCryptoCurrency(lTransaction.CurrencyId, ""); lAdvocacy.RootSeed = lRootSeed; var lAddress = lAdvocacy.GetAddress(10); lServerAccess.AddMonitoredAccount(lTransaction.CurrencyId, lAddress); var s = lServerAccess.GetTransactionRecords(lTransaction.CurrencyId, 0); var lTxList = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter()); var lTx = lTxList[0]; lTransaction.AddInput(lTx.Outputs[0]); lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "yPueC9mAxBj7yrPxj4M2vNY3rn4Yz3thrY"); lTransaction.TxFee = 1000; var lTxData = lServerAccess.CreateTransaction(lTransaction); lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction); var lHandle = lServerAccess.SendTransaction(lTransaction.CurrencyId, lTxData); System.Threading.Thread.Sleep(5000); if (lServerAccess.IsTransactionSent(lHandle)) { var lTxId = lServerAccess.GetTransactionId(lHandle); } lServerAccess.Logoff(); } else { throw new Exception("Basic Logon and log off failed."); } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; AssetManagementPurchaseOrder b = JsonConvert.DeserializeObject <AssetManagementPurchaseOrder>(obj); b.supplierId = supplierId.GetSupplierId() == "0" ? null : supplierId.GetSupplierId(); b.categoryId = categoryId.GetCategoryId(); b.currencyId = CurrencyControl.getCurrency() == "0"?null : CurrencyControl.getCurrency(); b.apStatus = apStatus.GetApprovalStatus() == "0" ? null : apStatus.GetApprovalStatus(); b.recordId = id; // Define the object to add or edit as null if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <AssetManagementPurchaseOrder> request = new PostRequest <AssetManagementPurchaseOrder>(); request.entity = b; PostResponse <AssetManagementPurchaseOrder> resp = _assetManagementService.ChildAddOrUpdate <AssetManagementPurchaseOrder>(request); b.recordId = resp.recordId; //check if the insert failed if (!resp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(resp); return; } else { Store1.Reload(); this.EditRecordWindow.Close(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); //Add this record to the store } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { PostRequest <AssetManagementPurchaseOrder> request = new PostRequest <AssetManagementPurchaseOrder>(); b.recordId = id; request.entity = b; PostResponse <AssetManagementPurchaseOrder> r = _assetManagementService.ChildAddOrUpdate <AssetManagementPurchaseOrder>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { Store1.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); // this.EditRecordWindow.Close(); } AssetPOReception POReception = JsonConvert.DeserializeObject <AssetPOReception>(obj); POReception.recordId = id; POReception.supplierId = supplierId.GetSupplierId() == "0" ? null : supplierId.GetSupplierId(); POReception.categoryId = categoryId.GetCategoryId(); POReception.currencyId = CurrencyControl.getCurrency() == "0" ? null : CurrencyControl.getCurrency(); POReception.apStatus = apStatus.GetApprovalStatus() == "0" ? null : apStatus.GetApprovalStatus(); if (b.status == 2) { PostRequest <AssetPOReception> req = new PostRequest <AssetPOReception>(); req.entity = POReception; PostResponse <AssetPOReception> resp = _assetManagementService.ChildAddOrUpdate <AssetPOReception>(req); if (!resp.Success)//it maybe another check { Common.errorMessage(resp); return; } AssetManagementAssetListRequest request1 = new AssetManagementAssetListRequest(); request1.branchId = "0"; request1.departmentId = "0"; request1.positionId = "0"; request1.categoryId = "0"; request1.employeeId = "0"; request1.supplierId = "0"; request1.PurchaseOrderId = b.poRef; request1.Filter = ""; ListResponse <AssetManagementAsset> resp1 = _assetManagementService.ChildGetAll <AssetManagementAsset>(request1); if (!resp1.Success)//it maybe another check { Common.errorMessage(resp1); return; } FillCondition(); AssetPOReceptionStore.DataSource = resp1.Items; AssetPOReceptionStore.DataBind(); AssetPOReceptionWindow.Show(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
protected void PoPuP(object sender, DirectEventArgs e) { FillBranch(); FillDepartment(); BasicInfoTab.Reset(); panelRecordDetails.ActiveIndex = 0; ApprovalsGridPanel.Disabled = false; int id = Convert.ToInt32(e.ExtraParams["id"]); currentPurchaseOrderId.Text = id.ToString(); string type = e.ExtraParams["type"]; switch (type) { case "imgEdit": ApprovalStore.Reload(); //Step 1 : get the object from the Web Service RecordRequest r = new RecordRequest(); r.RecordID = id.ToString(); RecordResponse <AssetManagementPurchaseOrder> response = _assetManagementService.ChildGetRecord <AssetManagementPurchaseOrder>(r); if (!response.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } //Step 2 : call setvalues with the retrieved object employeeId.GetStore().Add(new object[] { new { recordId = response.result.employeeId, fullName = response.result.employeeName } }); employeeId.SetValue(response.result.employeeId); this.BasicInfoTab.SetValues(response.result); supplierId.setSupplier(response.result.supplierId); categoryId.setCategory(response.result.categoryId); if (!string.IsNullOrEmpty(response.result.currencyId)) { CurrencyControl.setCurrency(response.result.currencyId); } //if (response.result.status == null) //{ // status.Select("1"); // status.SetValue("1"); //} apStatus.setApprovalStatus("1"); this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditRecordWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "imgAttach": //Here will show up a winow relatice to attachement depending on the case we are working on break; default: break; } }
public void CreateObjectTest() { Assert.IsTrue(CurrencyControl.GetClientCurrencyAdvocacy(1000, FEthChainParams, () => "6A41F49D98D83DF2EEB89F8E895D2269") is EthereumCurrencyAdvocacy, "Error EthereumCurrencyAdvocacy not returned"); }
public ICryptoCurrencyAdvocacy GetCurrencyAdvocacy(long aCurrencyId, ChainParams aChainParams) { ICryptoCurrencyAdvocacy lAdvocacy = CurrencyControl.GetClientCurrencyAdvocacy(aCurrencyId, aChainParams, GetStringRootSeed); return(lAdvocacy); }
public static void Register() { CurrencyControl.GetCurrencyControl().AddCurrencyAdvocacy(EthGetCurrencyAdvocacy); }