public async Task <UsageResult> GetUsageAsync() { using (var response = await Api.CallAsync(HttpMethod.Get, Api.ApiUrlV.Action("usage").BuildUrl(), null, null, null)) { return(await UsageResult.Parse(response)); } }
public ActionResult UsageResult() { var result = new UsageResult { Result = _repository.UsageInformation() }; return(View(result)); }
public UsageResult GetUsage() { string uri = m_api.ApiUrlV.Action("usage").BuildUrl(); using (HttpWebResponse response = m_api.Call(HttpMethod.GET, uri, null, null)) { return(UsageResult.Parse(response)); } }
private void AssertUsageResult(UsageResult result) { var plans = new List <string>() { "Free", "Advanced" }; Assert.True(plans.Contains(result.Plan)); Assert.True(result.Resources > 0); Assert.True(result.Objects.Used < result.Objects.Limit); Assert.True(result.Bandwidth.Used < result.Bandwidth.Limit); }
public async Task UseItemAsync(string dataId, [Remainder] string input = null) { ItemData data = ItemHelper.GetItemData(Context.Account, dataId); if (data == null) { await Context.Channel.SendMessageAsync(Format.Warning("Could not find a data reference.")); return; } UsageResult result = ItemHelper.UseItem(Context.Account, data, input); if (result.Message != null) { await Context.Channel.SendMessageAsync(Context.Account, result.Message); return; } await Context.Channel.SendMessageAsync(Format.Warning($"You have used **{ItemHelper.NameOf(data.Id)}**.")); }
private void GotoUsage(UsageResult result) { VisualStudio.Goto(result.SyntaxTree.CodeFile, result.Location.Line, result.Location.Offset + 1); }
public string SaveUsage(List <UsageData> jsUsage, string sSessionID) { //don't allow iOS 6 (or any browsers) to cache responses System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); if (!ValidateSession(sSessionID)) { return(sInvalidSession); } UsageResult oResult = new UsageResult(); oResult.bSuccess = false; try { //Convert JSON string to object list using (SqlConnection oCN = new SqlConnection(ConfigurationManager.ConnectionStrings["CN_INSIDER"].ConnectionString)) { oCN.Open(); using (SqlCommand oCMD = new SqlCommand()) { oCMD.Connection = oCN; oResult.sMessage = jsUsage.Count.ToString(); foreach (UsageData oUsage in jsUsage) { oCMD.CommandText = ""; oCMD.Parameters.Clear(); //delete existing if selected to be deleteed if ((oUsage.bDelete ?? "0") == "1" && oUsage.iID.Length > 0) { oCMD.CommandText = "DELETE FROM SKUP2_FutureUsage WHERE iID = @iID"; oCMD.Parameters.AddWithValue("@iID", oUsage.iID); } //update existing if changes were made else if (oUsage.iID.Length > 0 && (oUsage.iUnits != oUsage.iUnits_Init || oUsage.sType != oUsage.sType_Init || oUsage.dtTran != oUsage.dtTran_Init || oUsage.dtRequired != oUsage.dtRequired_Init)) { oCMD.CommandText = "UPDATE SKUP2_FutureUsage" + " SET sItemCode = @sItemCode" + ", sType = @sType" + ", dtTran = @dtTran" + ", dtRequired = @dtRequired" + ", iUnits = @iUnits" + ", sNotes = @sNotes" + " WHERE iID = @iID"; oCMD.Parameters.AddWithValue("@iID", oUsage.iID); oCMD.Parameters.AddWithValue("@sItemCode", oUsage.sItemCode); oCMD.Parameters.AddWithValue("@sType", oUsage.sType); oCMD.Parameters.AddWithValue("@dtTran", oUsage.dtTran); oCMD.Parameters.AddWithValue("@dtRequired", oUsage.dtRequired); oCMD.Parameters.AddWithValue("@iUnits", oUsage.iUnits); oCMD.Parameters.AddWithValue("@sNotes", oUsage.sNotes); } //insert new else if ((oUsage.bDelete ?? "0") == "0" && oUsage.iID.Length == 0) { oCMD.CommandText = "INSERT INTO SKUP2_FutureUsage (sItemCode, sType, dtTran, dtRequired, iUnits, sNotes)" + " VALUES (@sItemCode, @sType, @dtTran, @dtRequired, @iUnits, @sNotes)"; oCMD.Parameters.AddWithValue("@sItemCode", oUsage.sItemCode); oCMD.Parameters.AddWithValue("@sType", oUsage.sType); oCMD.Parameters.AddWithValue("@dtTran", oUsage.dtTran); oCMD.Parameters.AddWithValue("@dtRequired", oUsage.dtRequired); oCMD.Parameters.AddWithValue("@iUnits", oUsage.iUnits); oCMD.Parameters.AddWithValue("@sNotes", oUsage.sNotes); } //only execute if we have command text if (oCMD.CommandText.Length > 0) { oResult.sMessage = oCMD.ExecuteNonQuery().ToString() + " records affected."; } oResult.bSuccess = true; } } } } catch (Exception ex) { oResult.bSuccess = false; oResult.sMessage = "WS Error: " + ex.Message.ToString(); } //return proper status return(new JavaScriptSerializer().Serialize(oResult)); }
private static void AssertUsageResult(UsageResult result) { Assert.NotNull(result.LastUpdated); Assert.IsNull(result.Error?.Message); }
private void AssertUsageResult(UsageResult result) { Assert.NotNull(result); }