public GeneralAnswerData getDailyCategoryExpensesOverview(GeneralParameterData generalParameterData) { GeneralAnswerData generalAnswerData = new GeneralAnswerData(generalParameterData); Console.WriteLine("getDailyCategoryExpensesOverview"); Stream dataStream; WebRequest request; string url = HostName + "?q=webservice/daily_overview&sessionid=" + SessionId; string datastr = "&relative_month=" + generalParameterData.SummaryOfDailyCategoryExpensesRequest.RelativeMonth; url += datastr; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "GET"; request.Timeout = 10000; using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SummaryOfDailyCategoryExpensesResponse)); using (dataStream = response.GetResponseStream()) { SummaryOfDailyCategoryExpensesResponse resp = (SummaryOfDailyCategoryExpensesResponse)serializer.ReadObject(dataStream); generalAnswerData.SummaryOfDailyCategoryExpensesResults = resp.SummaryOfDailyCategoryExpensesResults; return(generalAnswerData); } } }
public GeneralAnswerData destoryPlan(GeneralParameterData toDestroy) { Console.WriteLine("destoryPlan"); GeneralAnswerData generalAnswerData = new GeneralAnswerData(toDestroy); Stream dataStream; WebRequest request; string datastr; UTF8Encoding encoding = new UTF8Encoding(); string url = HostName + "?q=webservice/planitem_destroy&sessionid=" + SessionId; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Timeout = 10000; datastr = "planitemid=" + toDestroy.Plan.Id; using (dataStream = request.GetRequestStream()) { string urlencoded = Uri.EscapeUriString(datastr); byte[] data = encoding.GetBytes(urlencoded); dataStream.Write(data, 0, data.Length); } using (WebResponse response = request.GetResponse()) { //DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(CategoriesResponse)); //using (dataStream = response.GetResponseStream()) //{ // CategoriesResponse resp = (CategoriesResponse)serializer.ReadObject(dataStream); //} } return(generalAnswerData); }
public GeneralAnswerData getPlansAndExpensesSummary(GeneralParameterData generalParameterData) { GeneralAnswerData generalAnswerData = new GeneralAnswerData(generalParameterData); Console.WriteLine("getPlansAndExpensesSummary"); Stream dataStream; WebRequest request; string url = HostName + "?q=webservice/balance_stats&sessionid=" + SessionId; string datastr = "&categoryid=" + generalParameterData.SummaryOfPlansAndExpensesRequest.Categoryid + "&granulation=" + generalParameterData.SummaryOfPlansAndExpensesRequest.Granulation + "&year=" + generalParameterData.SummaryOfPlansAndExpensesRequest.Year; url += datastr; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "GET"; request.Timeout = 10000; using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SummaryOfPlansAndExpensesResponse)); using (dataStream = response.GetResponseStream()) { SummaryOfPlansAndExpensesResponse resp = (SummaryOfPlansAndExpensesResponse)serializer.ReadObject(dataStream); generalAnswerData.SummaryOfPlansAndExpensesResults = resp.SummaryOfPlansAndExpensesResults; return(generalAnswerData); } } }
public GeneralAnswerData getListsOfThings(bool getItems, bool getCategories, bool getPlans) { GeneralAnswerData generalAnswerData = new GeneralAnswerData(); if (getItems) { GeneralAnswerData itemsAnswer = this.getItems(); generalAnswerData.Items = itemsAnswer.Items; } if (getCategories) { GeneralAnswerData categoriesAnswer = this.getCategories(); generalAnswerData.Categories = categoriesAnswer.Categories; } if (getPlans) { GeneralAnswerData plansAnswer = this.getPlans(); generalAnswerData.Plans = plansAnswer.Plans; } if (generalAnswerData.Items == null && generalAnswerData.Categories == null && generalAnswerData.Plans == null) { return(null); } return(generalAnswerData); }
public GeneralAnswerData updatePlan(GeneralParameterData toUpdate) { Console.WriteLine("updatePlan"); GeneralAnswerData generalAnswerData = new GeneralAnswerData(toUpdate); Stream dataStream; WebRequest request; string datastr; UTF8Encoding encoding = new UTF8Encoding(); string url = HostName + "?q=webservice/planitem_edit&sessionid=" + SessionId; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Timeout = 10000; datastr = "planitemid=" + toUpdate.Plan.Id + "&amount=" + toUpdate.Plan.Amount + "&description=" + toUpdate.Plan.Description + "&categoryid=" + toUpdate.Plan.CategoryId; using (dataStream = request.GetRequestStream()) { string urlencoded = Uri.EscapeUriString(datastr); byte[] data = encoding.GetBytes(urlencoded); dataStream.Write(data, 0, data.Length); } using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PlanResponse)); using (dataStream = response.GetResponseStream()) { PlanResponse resp = (PlanResponse)serializer.ReadObject(dataStream); } } return(generalAnswerData); }
public GeneralAnswerData getCategories() { GeneralAnswerData generalAnswerData = new GeneralAnswerData(); Console.WriteLine("getCategories"); Stream dataStream; WebRequest request; string url = HostName + "?q=webservice/categories&sessionid=" + SessionId; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "GET"; //krequest.KeepAlive = true; request.Timeout = 10000; using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(CategoriesResponse)); using (dataStream = response.GetResponseStream()) { CategoriesResponse resp = (CategoriesResponse)serializer.ReadObject(dataStream); generalAnswerData.Categories = resp.Categories; return(generalAnswerData); } } }
private void onSummariesQuerried(GeneralAnswerData result) { if (result != null && result.Categories != null) { Categories = result.Categories; Application.Current.Dispatcher.Invoke((Action)(() => Locator.SummariesViewModel.initTabContentViewModel())); } }
private void onPlansAndExpensesSummaryQuerried(GeneralAnswerData generalAnswerData) { SummariesOfPlansAndExpensesResult = new Collection <SummaryOfPlansAndExpensesResult>(generalAnswerData.SummaryOfPlansAndExpensesResults); SummariesOfPlansAndExpensesTitle = "Income and Expenses \n(on category " + CategoryViewModels.Where(x => x.Id == PlansAndExpensesSelectedCategoryViewModel.Id).FirstOrDefault().CategoryName + " by granulation " + generalAnswerData.SummaryOfPlansAndExpensesRequest.Granulation + " in year " + generalAnswerData.SummaryOfPlansAndExpensesRequest.Year + ")"; }
private void onItemSaved(GeneralAnswerData result) { clearExistingItem(); Locator.MainViewModel.reloadData(); string msgLog = "SAVE ITEM REQUEST: \n\tItem Description: " + result.Item.Description + " \n\tItem Amount: " + result.Item.Amount + " \n\tItem Id: " + result.Item.Id; string msgBar = "Save item request: \t\tDescription: " + result.Item.Description + " \tAmount: " + result.Item.Amount; Locator.MainViewModel.updateStatusBarAndLog(msgBar, msgLog); }
private void onPlanSaved(GeneralAnswerData result) { clearExistingPlan(); Locator.MainViewModel.reloadData(); string msgLog = "UPDATE PLAN REQUEST: \n\tDescription: " + result.Plan.Description + " \n\tAmount: " + result.Plan.Amount + " \n\tPlan Id: " + result.Plan.Id; string msgBar = "Update plan request: \t\tDescription: " + result.Plan.Description + " \tAmount: " + result.Plan.Amount; Locator.MainViewModel.updateStatusBarAndLog(msgBar, msgLog); }
private void onPlanAdded(GeneralAnswerData result) { cancelNewPlan(); Locator.MainViewModel.reloadData(); string msgLog = "NEW PLAN REQUEST: \n\tPlan Description: " + result.Plan.Description + " \n\tPlan Amount: " + result.Plan.Amount + " \n\tPlan's category Id: " + result.Plan.CategoryId; string msgBar = "New plan request: \t\tDescription: " + result.Plan.Description + " \tAmount: " + result.Plan.Amount; Locator.MainViewModel.updateStatusBarAndLog(msgBar, msgLog); }
private void onCategoryDeleted(GeneralAnswerData result) { clearExistingCategory(); Locator.MainViewModel.reloadData(); string msgLog = "DELETE CATEGORY REQUEST: \n\tCategory Name: " + result.Category.CategoryName + " \n\tCategory Description: " + result.Category.Description + " \n\tCategory Id: " + result.Category.Id; string msgBar = "Delete category request: \t\tName: " + result.Category.CategoryName + " \tDescription: " + result.Category.Description; Locator.MainViewModel.updateStatusBarAndLog(msgBar, msgLog); }
private void onItemAdded(GeneralAnswerData result) { cancelNewItem(); Locator.MainViewModel.reloadData(); string msgLog = "NEW ITEM REQUEST: \n\tItem Name: " + result.Item.Description + " \n\tItem Description: " + result.Item.Amount + " \n\tItem's category Id: " + result.Item.CategoryId; string msgBar = "New item request: \t\tName: " + result.Item.Description + " \tAmount: " + result.Item.Amount; Locator.MainViewModel.updateStatusBarAndLog(msgBar, msgLog); }
public GeneralAnswerData updateCategory(GeneralParameterData toUpdate) { Console.WriteLine("updateCategory"); GeneralAnswerData generalAnswerData = new GeneralAnswerData(toUpdate); Stream dataStream; WebRequest request; string datastr; UTF8Encoding encoding = new UTF8Encoding(); string url = HostName + "?q=webservice/category_edit&sessionid=" + SessionId; request = WebRequest.Create(Uri.EscapeUriString(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Timeout = 10000; datastr = "categoryid=" + toUpdate.Category.Id + "&name=" + toUpdate.Category.CategoryName + "&description=" + toUpdate.Category.Description; using (dataStream = request.GetRequestStream()) { string urlencoded = Uri.EscapeUriString(datastr); byte[] data = encoding.GetBytes(urlencoded); dataStream.Write(data, 0, data.Length); } using (WebResponse response = request.GetResponse()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(CategoryResponse)); using (dataStream = response.GetResponseStream()) { CategoryResponse resp = (CategoryResponse)serializer.ReadObject(dataStream); Console.WriteLine("Status : " + resp.Status); Console.WriteLine("Success: " + resp.Success); Console.WriteLine("Name : " + resp.Category.CategoryName); Console.WriteLine("Descr : " + resp.Category.Description); Console.WriteLine("Id : " + resp.Category.Id); Console.WriteLine("CreTime: " + resp.Category.CreationTime); Console.WriteLine("ModTime: " + resp.Category.ModificationTime); } } return(generalAnswerData); }
private void onDailyCategoryExpensesSummaryQuerried(GeneralAnswerData generalAnswerData) { ColumnConfig = new ColumnConfig(); //Category actualCategory = null; //foreach (SummaryOfDailyCategoryExpensesResult summaryOfDailyCategoryExpensesResult in generalAnswerData.SummaryOfDailyCategoryExpensesResults) //{ // if (actualCategory == null || actualCategory.Id != summaryOfDailyCategoryExpensesResult.Category.Id) // { // actualCategory = summaryOfDailyCategoryExpensesResult.Category; // ColumnConfig.Columns.Add(new Column { Header = actualCategory.CategoryName, DataField = "Name" }); // } //} SummariesOfDailyCategoryExpensesResult = new Collection <SummaryOfDailyCategoryExpensesResult>(generalAnswerData.SummaryOfDailyCategoryExpensesResults); SummariesOfPlansAndExpensesTitle = "Daily expenses by category \n(on category " + " in month " + generalAnswerData.SummaryOfDailyCategoryExpensesRequest.SelectedMonthStr + ")"; }