private void MonitoringDataReceived(ChargeDataReceivedEventArgs e) { ChargeData chargeData = e.Message; if (ChargeChart.InvokeRequired) { try { ChargeChart.Invoke(new Action(() => { if (BatteryMonitoringService.Instance.ChargeDataSet.Count > MAX_GRAPH_ITEMS) { ChargeChart.DataSource = BatteryMonitoringService.Instance.ChargeDataSet.GetRange(BatteryMonitoringService.Instance.ChargeDataSet.Count - MAX_GRAPH_ITEMS, MAX_GRAPH_ITEMS); } else { ChargeChart.DataSource = BatteryMonitoringService.Instance.ChargeDataSet; } ChargeChart.DataBind(); } )); } catch { // Catch and kill and exception that sometimes occurs on shotdown of the form. } } }
protected override void OnCharge(Vector3 center, ChargeData data, UnityAction onComplete) { base.OnCharge(center, data, onComplete); if (data.type == "氯化铁") { SetColor(fecl2Color); } else if (data.type == "硫酸亚铁") { SetColor(feso4Color); } else if (data.type == "氢氧化钠") { if (lastType == "氯化铁") { targetColor.Enqueue(feoh3Color); StartCoroutine(ColorChange(info1)); } else if (lastType == "硫酸亚铁") { targetColor.Enqueue(feohso4Color1); targetColor.Enqueue(feohso4Color2); StartCoroutine(ColorChange(info2)); } } lastType = data.type; }
public async Task CreateChargeAsync(ChargeData chargeData, Action <ChargeResponse> chargeAction) { ChargeResponse deserializedCharge = await CreateChargeAsync(chargeData); logger.Debug("CreateChargeAsync[RES]:" + deserializedCharge.Data.Id); chargeAction(deserializedCharge); }
public async Task <ChargeResponse> CreateChargeAsync(ChargeData chargeData) { var jsonSettings = new JsonSerializerSettings(); jsonSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; jsonSettings.NullValueHandling = NullValueHandling.Ignore; logger.Debug("CreateChargeAsync [REQ]:" + chargeData.Description); try { string bodyJson = JsonConvert.SerializeObject(chargeData, jsonSettings); StringContent httpContent = new StringContent(bodyJson, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync(zebedeeUrl + "charges", httpContent); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); //Deserialize ChargeResponse deserializedCharge = JsonConvert.DeserializeObject <ChargeResponse>(responseBody, jsonSettings); logger.Debug("createInvoiceAsync[RES]:" + deserializedCharge.Data.Id); return(deserializedCharge); } catch (Exception e) { logger.Error(string.Format("Error :{0} ", e.Message)); throw e; } }
public CheckRecentChargePageViewModel(params MonthCharge[] mcs) { foreach (MonthCharge mc in mcs) { ChargeData.Add(mc); } }
public void ChargeSerialize_Test() { /* * { * "name": "Purchased game item #MASA001", * "description": "Description of the Charge by Masa", * "amount": "1000", * "callbackUrl": "http://localhost/callback", * "internalId": "MASA001" * } */ //test text string testMessage = "TEST MESSAGE"; string testPaymentName = "Purchased game item #MASA001"; ChargeResponse charge = new ChargeResponse(); charge.Message = testMessage; ChargeData data = new ChargeData(); data.Name = testPaymentName; charge.Data = data; //Serialize string output = JsonConvert.SerializeObject(charge); Assert.Contains(testMessage, output); //Deserialize ChargeResponse deserializedCharge = JsonConvert.DeserializeObject <ChargeResponse>(output); Assert.NotNull(deserializedCharge.Data); Assert.Equal(deserializedCharge.Data.Name, testPaymentName); }
public void ChargeDeserialize_Test() { //test text string testJson = @" { ""message"": ""Successfully retrieved Charge."", ""data"": { ""id"": ""773cc63c-8e4a-437d-87f1-c89049e4d076"", ""name"": ""Purchased game item #MASA001"", ""description"": ""Description of the Charge by Masa"", ""createdAt"": ""2019-12-28T20:45:39.575Z"", ""successUrl"": ""http://localhost/success"", ""callbackUrl"": ""http://localhost/callback"", ""internalId"": ""MASA001"", ""amount"": ""1000"", ""status"": ""expired"", ""invoice"": { ""expiresAt"": ""2019-12-28T20:55:39.594Z"", ""request"": ""lnbc10n1p0q00hnpp5ce8yksx5455eh7rtmmx7f6jm0gs4wy3n3794mywm78sm06kwr7tqdp4g3jhxcmjd9c8g6t0dcsx7e3qw35x2gzrdpshyem9yp38jgzdv9ekzcqzpgxqzjcfppj7j3tfup9ph0g0g6hkf5ykh0scw87ffnz9qy9qsqsp5zqeu32n0khtpejtcep2wkavwqxvnvp09wh8fx5k28cdfs4hv8mqs7x426zqdg0wmhy2ta6hz4kdej7hh9rx2alkn7qsdfn3vgq7g2x4n09amt0d6duxpk9znurlwxrz676zyrceghla7yux0p7vpn6ymekcpn5ypxj"" } } }"; var jsonSettings = new JsonSerializerSettings(); jsonSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //Deserialize ChargeResponse deserializedCharge = JsonConvert.DeserializeObject <ChargeResponse>(testJson, jsonSettings); //1st level Assert.Equal("Successfully retrieved Charge.", deserializedCharge.Message); Assert.NotNull(deserializedCharge.Data); ChargeData data = deserializedCharge.Data; //2nd level Assert.Equal("773cc63c-8e4a-437d-87f1-c89049e4d076", data.Id); Assert.Equal("Purchased game item #MASA001", data.Name); Assert.Equal("Description of the Charge by Masa", data.Description); // Assert.Equal(DateTime.Parse("2019-12-28T20:45:39.575Z"), data.CreatedAt); Assert.Equal("http://localhost/callback", data.CallbackUrl); Assert.Equal("MASA001", data.InternalId); Assert.Equal(1000, data.Amount); Assert.Equal("expired", data.Status); Assert.NotNull(data.Invoice); Invoice invoice = data.Invoice; //3rd level Assert.Equal(DateTime.Parse("2019-12-28T20:55:39.594Z"), invoice.ExpiresAt, TimeSpan.FromSeconds(1)); Assert.Equal("lnbc10n1p0q00hnpp5ce8yksx5455eh7rtmmx7f6jm0gs4wy3n3794mywm78sm06kwr7tqdp4g3jhxcmjd9c8g6t0dcsx7e3qw35x2gzrdpshyem9yp38jgzdv9ekzcqzpgxqzjcfppj7j3tfup9ph0g0g6hkf5ykh0scw87ffnz9qy9qsqsp5zqeu32n0khtpejtcep2wkavwqxvnvp09wh8fx5k28cdfs4hv8mqs7x426zqdg0wmhy2ta6hz4kdej7hh9rx2alkn7qsdfn3vgq7g2x4n09amt0d6duxpk9znurlwxrz676zyrceghla7yux0p7vpn6ymekcpn5ypxj", invoice.Request); }
private void MonitoringDataReceived(ChargeDataReceivedEventArgs e) { ChargeData chargeData = e.Message; if (ChargeChart.InvokeRequired) { ChargeChart.Invoke(new Action(() => { ChargeChart.DataSource = BatteryMonitoringService.Instance.ChargeDataSet; ChargeChart.DataBind(); } )); } }
/// <summary> ///Create Invoice asynchronously , returning ChargeDetail Reponse /// </summary> public async Task <ChargeResponse> CreateInvoiceAsync(Charge charge) { ChargeData chargeData = new ChargeData(); chargeData.Amount = charge.AmountInSatoshi * 1000; chargeData.Description = charge.Description; chargeData.Name = charge.Description; logger.Debug("CreateInvoice with amount:" + chargeData.Amount); ChargeResponse chargeDetail = await zbdService.CreateChargeAsync(chargeData); return(chargeDetail); }
/// <summary> ///Create Invoice asynchronously with Callback function handling ChargeDetail Response ///<param name="invoice">invoice reques containing amount in milli satoshi and description</param> /// </summary> public async Task CreateChargeAsync(Charge charge, Action <ChargeResponse> chargeAction) { //Conver from SDK class to API class ChargeData chargeData = new ChargeData(); chargeData.Amount = charge.AmountInSatoshi * 1000; chargeData.Description = charge.Description; chargeData.Name = charge.Description; logger.Debug("CreateInvoice with amount:" + chargeData.Amount); await zbdService.CreateChargeAsync(chargeData, chargeResponse => { chargeAction(chargeResponse); }); }
void chargeGrid_LoadingRow(object sender, Microsoft.Windows.Controls.DataGridRowEventArgs e) { // Get the DataRow corresponding to the DataGridRow that is loading. ChargeData item = e.Row.Item as ChargeData; if (item != null) { if (item.state == 0) { e.Row.Foreground = new SolidColorBrush(Colors.Blue); } else if (item.state == 2) { e.Row.Foreground = new SolidColorBrush(Colors.Red); } } }
public void SaveChargeData(ChargeData chargeData) { if (chargeData == null) { throw new ArgumentNullException(nameof(chargeData)); } string newLine = ""; newLine += CanUtilities.AlignLeft(chargeData.DateTime.ToString("HH:mm:ss"), 14, false); newLine += CanUtilities.AlignLeft(chargeData.SOCAsInt.ToString(), 7, true); newLine += CanUtilities.AlignLeft(chargeData.ChargeCurrentmA.ToString(), 17, true); newLine += CanUtilities.AlignLeft(chargeData.ChargeVoltagemV.ToString(), 16, true); newLine += CanUtilities.AlignLeft(chargeData.PackmA.ToString(), 9, true); newLine += CanUtilities.AlignLeft(chargeData.PackmV.ToString(), 9, true); newLine += CanUtilities.AlignLeft(chargeData.MinCellmV.ToString(), 13, true); newLine += CanUtilities.AlignLeft(chargeData.MaxCellmV.ToString(), 13, true); newLine += CanUtilities.AlignLeft(chargeData.MinCellTemp.ToString(), 15, true); newLine += CanUtilities.AlignLeft(chargeData.MaxCellTemp.ToString(), 15, true); newLine += CanUtilities.AlignLeft(chargeData.BalanceVoltageThresholdRising.ToString(), 11, true); newLine += CanUtilities.AlignLeft(chargeData.BalanceVoltageThresholdFalling.ToString(), 11, true); newLine += CanUtilities.AlignLeft(chargeData.ChargeCellVoltageError.ToString(), 22, true); newLine += CanUtilities.AlignLeft(chargeData.DischargeCellVoltageError.ToString(), 25, true); if (chargeData.CellVoltages != null) { foreach (uint?[] array in chargeData.CellVoltages) { newLine += CanUtilities.AlignLeft(array[8].ToString(), 8, true); newLine += CanUtilities.AlignLeft(array[0].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[1].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[2].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[3].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[4].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[5].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[6].ToString(), 9, true); newLine += CanUtilities.AlignLeft(array[7].ToString(), 9, true); } } fileStream.WriteLine(newLine); }
private void UpdateChargeData(object sender, EventArgs e) { Battery battery = BatteryChargeService.Instance.BatteryService.BatteryData; ChargeData chargeData = new ChargeData { DateTime = DateTime.Now, SOC = battery.SOCPercentage, ChargeCurrentA = BatteryChargeService.Instance.ChargerActualCurrent, ChargeVoltagemV = BatteryChargeService.Instance.ChargerActualVoltage, PackmA = battery.BatteryCurrent, PackmV = battery.BatteryVoltage, MinCellmV = battery.MinCellVoltage, MaxCellmV = battery.MaxCellVoltage, MinCellTemp = battery.MinCellTemp, MaxCellTemp = battery.MaxCellTemp, BalanceVoltageThresholdFalling = battery.BalanceVoltageThresholdFalling, BalanceVoltageThresholdRising = battery.BalanceVoltageThresholdRising, ChargeCellVoltageError = battery.MinChargeCellVoltageError, DischargeCellVoltageError = battery.MinDischargeCellVoltageError }; if (BatteryChargeService.Instance.IsCharging && BatteryDischargeService.Instance.IsDischarging) { chargeData.State = ChargeData.STATE_ERROR; } else if (BatteryChargeService.Instance.IsCharging) { chargeData.State = ChargeData.STATE_CHARGE; } else if (BatteryDischargeService.Instance.IsDischarging) { chargeData.State = ChargeData.STATE_DISCHARGE; } else { chargeData.State = ChargeData.STATE_IDLE; } chargeDataSet.Add(chargeData); BatteryMonitorUpdateEventHandler?.Invoke(new ChargeDataReceivedEventArgs(chargeData)); }
/// <summary> /// Outputs the report data files. /// </summary> /// <returns></returns> protected override bool OutputDataFiles() { try { var directoryPath = Path.Combine(BaseDataDirectoryPath, "medicare", "drg"); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } foreach (var dataTable in _datatables.ToList()) { var hositalFileName = Path.Combine(directoryPath, "hospital", dataTable.TableName, "summary.js"); var tableData = new TableData(); foreach (DataRow row in dataTable.Rows) { var rowToSerialize = new ChargeData { DRGID = row["DRG_Id"].ToString(), TotalDischarges = row["TotalDischarges"].ToString(), AverageCoveredCharges = row["AverageCoveredCharges"].ToString(), MeanCostInDollars = row["MeanCostInDollars"].ToString(), AverageTotalPayments = row["AverageTotalPayments"].ToString() }; tableData.Rows.Add(rowToSerialize); } GenerateJsonFile(tableData, hositalFileName, JSON_DOMAIN); } return(true); } catch (Exception ex) { Logger.Write(ex, "Error writing data file for Medicare Provider Charge report"); return(false); } }
/// <summary> /// Gets the aggregate battery status /// </summary> private void GetAggregateBatteryStatus(BatteryReport report) { // Check if the aggregate report object is null if (report == null) { return; } // Set properties DesignCap = report.DesignCapacityInMilliwattHours; FullChargeCap = report.FullChargeCapacityInMilliwattHours; RemainingCap = report.RemainingCapacityInMilliwattHours; ChargeRate = report.ChargeRateInMilliwatts; BatteryStatus = report.Status; // Add to charge data ChargeData.Add(new ChargeDetail() { Time = DateTime.Now, Value = report.ChargeRateInMilliwatts }); }
private void GetAllCharges() { List <ChargeData> _charge = new List <ChargeData>(); string filePath = Path.Combine(Application.streamingAssetsPath, chargefilename + (chargefilename.EndsWith(".json") ? "" : ".json")); string dataJsonAsString = File.ReadAllText(filePath); Debug.Log(dataJsonAsString); if (!string.IsNullOrEmpty(dataJsonAsString)) { //var loadedData = JsonConvert.DeserializeObject<Dictionary<string, int>>(dataJsonAsString); dico = JsonConvert.DeserializeObject <Dictionary <string, string>[]>(dataJsonAsString); } foreach (Dictionary <string, string> dic in dico) { ChargeData chargeData = new ChargeData(); chargeData.description = dic["text"]; chargeData.points = int.Parse(dic["score"]); chargeDatas.Add(chargeData); } }
private void UpdateChargeData(object sender, EventArgs e) { Battery battery = BatteryChargeService.Instance.BatteryService.BatteryData; ChargeData chargeData = new ChargeData { DateTime = DateTime.Now, SOC = battery.SOCPercentage, ChargeCurrentA = BatteryChargeService.Instance.ChargerActualCurrent, ChargeVoltagemV = BatteryChargeService.Instance.ChargerActualVoltage, PackmA = battery.BatteryCurrent, PackmV = battery.BatteryVoltage, MinCellmV = battery.MinCellVoltage, MaxCellmV = battery.MaxCellVoltage, MinCellTemp = battery.MinCellTemp, MaxCellTemp = battery.MaxCellTemp, BalanceVoltageThresholdFalling = battery.BalanceVoltageThresholdFalling, BalanceVoltageThresholdRising = battery.BalanceVoltageThresholdRising, ChargeCellVoltageError = battery.MinChargeCellVoltageError, DischargeCellVoltageError = battery.MinDischargeCellVoltageError }; if (BatteryChargeService.Instance.IsCharging && BatteryDischargeService.Instance.IsDischarging) { chargeData.State = ChargeData.STATE_ERROR; } else if (BatteryChargeService.Instance.IsCharging) { chargeData.State = ChargeData.STATE_CHARGE; } else if (BatteryDischargeService.Instance.IsDischarging) { chargeData.State = ChargeData.STATE_DISCHARGE; } else { chargeData.State = ChargeData.STATE_IDLE; } // Add all of the CMU voltages foreach (BMU bmu in battery.GetActiveBMUs()) { foreach (CMU cmu in bmu.GetActiveCMUs()) { if (cmu.State == CanReceivingNode.STATE_ON) { uint?[] voltages = new uint?[9]; voltages[0] = cmu.Cell0mV; voltages[1] = cmu.Cell1mV; voltages[2] = cmu.Cell2mV; voltages[3] = cmu.Cell3mV; voltages[4] = cmu.Cell4mV; voltages[5] = cmu.Cell5mV; voltages[6] = cmu.Cell6mV; voltages[7] = cmu.Cell7mV; voltages[8] = (uint?)cmu.SerialNumber; if (chargeData.CellVoltages == null) { chargeData.CellVoltages = new List <uint?[]>(); } chargeData.CellVoltages.Add(voltages); } } } chargeDataSet.Add(chargeData); if (IsSavingCharge) { SaveChargeData(chargeData); } BatteryMonitorUpdateEventHandler?.Invoke(new ChargeDataReceivedEventArgs(chargeData)); }
public void SimpleInvoiceCreationTest() { var server = FluentMockServer.Start(); ///////////////////////////// Create Invoice string testJson = @" { ""message"": ""Successfully retrieved Charge."", ""data"": { ""id"": ""773cc63c-8e4a-437d-87f1-c89049e4d076"", ""name"": ""Purchased game item #MASA001"", ""description"": ""Description of the Charge by Masa"", ""createdAt"": ""2019-12-28T20:45:39.575Z"", ""successUrl"": ""http://localhost/success"", ""callbackUrl"": ""http://localhost/callback"", ""internalId"": ""MASA001"", ""amount"": ""1000"", ""status"": ""expired"", ""invoice"": { ""expiresAt"": ""2019-12-28T20:55:39.594Z"", ""request"": ""lnbc10n1p0q00hnpp5ce8yksx5455eh7rtmmx7f6jm0gs4wy3n3794mywm78sm06kwr7tqdp4g3jhxcmjd9c8g6t0dcsx7e3qw35x2gzrdpshyem9yp38jgzdv9ekzcqzpgxqzjcfppj7j3tfup9ph0g0g6hkf5ykh0scw87ffnz9qy9qsqsp5zqeu32n0khtpejtcep2wkavwqxvnvp09wh8fx5k28cdfs4hv8mqs7x426zqdg0wmhy2ta6hz4kdej7hh9rx2alkn7qsdfn3vgq7g2x4n09amt0d6duxpk9znurlwxrz676zyrceghla7yux0p7vpn6ymekcpn5ypxj"" } } }"; server .Given( Request.Create().WithPath("/v0/charges").UsingPost() ) .RespondWith( WireMock.ResponseBuilders.Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBody(testJson) .WithDelay(TimeSpan.FromSeconds(1)) ); //service setup string zebedeeUrl = zebedeeStubHost + ":" + server.Ports[0] + "/v0/"; ZbdLnService zbdLnService = new ZbdLnService(zebedeeUrl, apikey); ///////////////////////////// Create Invoice ChargeData chargeData = new ChargeData(); //Countdown Latch CountdownEvent cde = new CountdownEvent(1); // initial count = 1 String bolt = ""; //Call the API Task task = zbdLnService.CreateChargeAsync(chargeData, charge => { try { Assert.NotNull(charge.Data); Assert.NotNull(charge.Data.Invoice); Assert.NotNull(charge.Data.Invoice.Request); Assert.Equal("Description of the Charge by Masa", charge.Data.Description); Assert.StartsWith("lnbc10n1", charge.Data.Invoice.Request); output.WriteLine("in action bolt:" + charge.Data.Invoice.Request); output.WriteLine("in action amount:" + charge.Data.Amount); bolt = charge.Data.Invoice.Request; } finally { cde.Signal(); } }); //Latch wait cde.Wait(5000); if (cde.CurrentCount != 0) { Assert.True(false, "charge call timeout "); } output.WriteLine("outside:" + bolt); }
/* * PAYMENT */ public ChargeModel ChargeCreate( string token_card, string customer_id, string doc_type, string doc_number, string name, string last_name, string email, string bill, string description, string value, string tax, string tax_base, string ico, string currency, string dues, string address, string phone, string cell_phone, string url_response, string url_confirmation, string method_confirmation, string ip, string extra1 = "N/A", string extra2 = "N/A", string extra3 = "N/A", string extra4 = "N/A", string extra5 = "N/A", string extra6 = "N/A", string extra7 = "N/A", string extra8 = "N/A", string extra9 = "N/A", string extra10 = "N/A", SplitModel split_details = null) { ENDPOINT = Constants.url_charge; PARAMETER = body.getBodyChargeCreate(token_card, customer_id, doc_type, doc_number, name, last_name, email, bill, description, value, tax, tax_base, ico, currency, dues, address, phone, cell_phone, url_response, url_confirmation, method_confirmation, ip, extra1, extra2, extra3, extra4, extra5, extra6, extra7, extra8, extra9, extra10); if (split_details != null) { string split_req_body = body.getBodySplitPayments(split_details, false); PARAMETER = Auxiliars.ConcatBodyStrings(PARAMETER, split_req_body); } string content = _request.Execute( ENDPOINT, "POST", _auxiliars.ConvertToBase64(_PUBLIC_KEY), PARAMETER); ChargeModel payment = new ChargeModel(); if (content.Contains("errorMessage")) { ChargeDataListError response = JsonConvert.DeserializeObject <ChargeDataListError>(content); ChargeData data = new ChargeData { status = response.data.status, description = response.data.description, errors = response.data.errors }; payment.status = response.status; payment.message = response.message; payment.data = data; } else { payment = JsonConvert.DeserializeObject <ChargeModel>(content); } return(payment); }