public object Execute <T>(string url, T objectType, string method) { _url = url; _objectType = objectType; _method = method; JSONSerialization jsonSerialization = new JSONSerialization(); HttpWebRequest request = setWebRequest(); string responseString = string.Empty; var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (_cookiesCollection.Count == 0) { _cookiesCollection = response.Cookies; } } var result = jsonSerialization.DeserializeFromString <Common.Model.Result <object> >(responseString); if (result.IsSuccess) { return(result.Value); } else { throw result.ExceptionInfo; } }
public ClientContact Get(int clientId) { ClientContact clientContactObj = new ClientContact(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_CLIENT_CONTACT_API, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <Client>(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { clientContactObj = jsonSerialization.DeserializeFromString <ClientContact>(restResult.ToString()); } return(clientContactObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
public IList <FamilyMember> Get(int clientId) { IList <FamilyMember> employmentListObj = new List <FamilyMember>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_All_FAMAILYMEMBER_API, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <FamilyMember> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { employmentListObj = jsonSerialization.DeserializeFromString <IList <FamilyMember> >(restResult.ToString()); } return(employmentListObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
private Client getClientPersonalInfo(int clientId) { Client clientObj = new Client(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_CLIENT_PERSONAL_API, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <Client>(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { clientObj = jsonSerialization.DeserializeFromString <Client>(restResult.ToString()); } else { MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(clientObj); } catch (Exception ex) { Logger.LogDebug(ex); return(clientObj); } }
private void updateClient() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; ProspectClient prosCustomer = new ProspectClient() { Name = txtName.Text, Occupation = txtOccupation.Text, PhoneNo = txtPhoneNo.Text, Email = txtEmail.Text, Event = txtEvent.Text, EventDate = dtEventDate.Value, ReferedBy = txtRefBy.Text, IsConvertedToClient = chkIsConvertedToCustomer.Checked, StopSendingEmail = chkStopSendingEmail.Checked, Remarks = txtRemark.Text, CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; if (_prospectClient == null) { apiurl = Program.WebServiceUrl + "/" + ADD_PROSPECTCLIENT_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_PROSPECTCLIENT_API; prosCustomer.ID = _prospectClient.ID; } string DATA = jsonSerialization.SerializeToString <ProspectClient>(prosCustomer); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void getConversationDetails() { if (_dtConversation != null && _dtConversation.Rows.Count > 0) { _dtConversation.Clear(); } FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(CONVERSATIONBY_ID, _prospectClient.ID); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String prospClientResultJosn = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); prospClientResultJosn = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var prospClientConversationCollection = jsonSerialization.DeserializeFromString <Result <List <ProspectClientConversation> > >(prospClientResultJosn); if (prospClientConversationCollection.Value != null) { _prospectClient.ProspectClientConversationList = prospClientConversationCollection.Value; _dtConversation = ListtoDataTable.ToDataTable(prospClientConversationCollection.Value); dataGridConversation.DataSource = _dtConversation; gridDisplaySetting(); } }
public IList <Area> GetAll() { IList <Area> areaObj = new List <Area>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_All_API); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <Area> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { areaObj = jsonSerialization.DeserializeFromString <IList <Area> >(restResult.ToString()); } return(areaObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
public IList <NonFinancialAsset> GetAll(int plannerId) { IList <NonFinancialAsset> nonFinancialAssetObj = new List <NonFinancialAsset>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_NON_FINANCIAL_ASSET_API, plannerId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <NonFinancialAsset> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { nonFinancialAssetObj = jsonSerialization.DeserializeFromString <IList <NonFinancialAsset> >(restResult.ToString()); } return(nonFinancialAssetObj); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public CurrentStatusCalculation GetAllCurrestStatus(int plannerId) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_CURRENT_STATUS_API, plannerId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <CurrentStatusCalculation> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { csCal = jsonSerialization.DeserializeFromString <CurrentStatusCalculation>(restResult.ToString()); } return(csCal); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public DataTable GetAll(int planId) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GETALL_API, planId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String planerResultJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); planerResultJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var plannerCollection = jsonSerialization.DeserializeFromString <Result <List <PlanOption> > >(planerResultJson); if (plannerCollection.Value != null) { return(ListtoDataTable.ToDataTable(plannerCollection.Value)); } return(null); }
public CashFlow GetCashFlow(int optionId) { _optionId = optionId; FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GETALL_API, optionId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String cashFlowJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); cashFlowJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var cashFlowResult = jsonSerialization.DeserializeFromString <Result <CashFlow> >(cashFlowJson); if (cashFlowResult.Value != null) { return(cashFlowResult.Value); } return(null); }
internal Loan GetById(int id, int plannerId) { Loan loanObj = new Loan(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_BY_ID_API, id, plannerId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <Loan> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { loanObj = jsonSerialization.DeserializeFromString <Loan>(restResult.ToString()); } return(loanObj); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public Employment Get(int id) { Employment employmentObj = new Employment(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_EMPLOYMENT_API, id); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <Employment>(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { employmentObj = jsonSerialization.DeserializeFromString <Employment>(restResult.ToString()); } return(employmentObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
internal IList <ClientCRMGroup> Get(int clientId) { IList <ClientCRMGroup> ClientCRMGroupObj = new List <ClientCRMGroup>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GETALL_CLIENTFESTIVAL_API, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <ClientCRMGroup> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { ClientCRMGroupObj = jsonSerialization.DeserializeFromString <IList <ClientCRMGroup> >(restResult.ToString()); } return(ClientCRMGroupObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
private void Main_FormClosing(object sender, FormClosingEventArgs e) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + AUDITLOGCONTROLLER; Activities activity = new Activities(); activity.ActivityTypeValue = ActivityType.Logout; activity.EntryType = EntryStatus.Success; activity.SourceType = Source.Server; activity.HostName = Environment.MachineName; activity.UserName = Program.CurrentUser.UserName; string DATA = jsonSerialization.SerializeToString <Activities>(activity); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); } } catch (Exception ex) { Logger.LogDebug(ex.ToString()); } }
private ClientSpouse getSpousePersonalInfo(int clientId) { ClientSpouse clientSpouseObj = new ClientSpouse(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_SPOUSE_PERSONAL_API, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <Client>(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { clientSpouseObj = jsonSerialization.DeserializeFromString <ClientSpouse>(restResult.ToString()); } return(clientSpouseObj); } catch (Exception ex) { Logger.LogDebug(ex); return(null); } }
private void loadProspectCustomerData() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + PROSPECT_CLIENTS_GETALL; RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <List <ProspectClient> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { var prospClientCollection = jsonSerialization.DeserializeFromString <List <ProspectClient> >(restResult.ToString()); _dtProspClients = ListtoDataTable.ToDataTable(prospClientCollection); fillTreeviewData(_dtProspClients); } else { MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Logger.LogDebug(ex); } //HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); //request.Method = "GET"; //String prospClientResultJosn = String.Empty; //using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) //{ // Stream dataStream = response.GetResponseStream(); // StreamReader reader = new StreamReader(dataStream); // prospClientResultJosn = reader.ReadToEnd(); // reader.Close(); // dataStream.Close(); //} //var prospClientCollection = jsonSerialization.DeserializeFromString<Result<List<ProspectClient>>>(prospClientResultJosn); //if (prospClientCollection.Value != null) //{ // _dtProspClients = ListtoDataTable.ToDataTable(prospClientCollection.Value); // //dataGridProspClients.DataSource = _dtProspClients; // fillTreeviewData(_dtProspClients); // //gridDisplaySetting(); //} }
internal DataTable GetMFTransactionsInfo(int plannerId) { IList <MFTransactions> MFTransactionsObj = new List <MFTransactions>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL, plannerId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <MFTransactions> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { MFTransactionsObj = jsonSerialization.DeserializeFromString <IList <MFTransactions> >(restResult.ToString()); } if (MFTransactionsObj != null) { if (MFTransactionsObj.Count > 0) { dtMFTrans = ListtoDataTable.ToDataTable(MFTransactionsObj.ToList()); } else { return(defaultTableStructure()); } } return(dtMFTrans); } catch (System.Net.WebException webException) { if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized.")) { MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(null); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
private void loadRiskProfileData() { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + RISKPROFILE_GETALL; RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <List <RiskProfiledReturnMaster> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { _riskProfileMasters = jsonSerialization.DeserializeFromString <List <RiskProfiledReturnMaster> >(restResult.ToString()); } else { MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public IList <FinancialPlanner.Common.Model.PlanOptions.CurrentStatusToGoal> GetCurrentStatusToGoal(int optionID) { IList <FinancialPlanner.Common.Model.PlanOptions.CurrentStatusToGoal> currentStatusToGoals = new List <FinancialPlanner.Common.Model.PlanOptions.CurrentStatusToGoal>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_CURRENT_STATUS_TO_GOAL_BYID, optionID); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <Shares> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { currentStatusToGoals = jsonSerialization.DeserializeFromString <IList <FinancialPlanner.Common.Model.PlanOptions.CurrentStatusToGoal> >(restResult.ToString()); } if (currentStatusToGoals != null) { return(currentStatusToGoals); } else { return(null); } } catch (System.Net.WebException webException) { if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized.")) { MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(null); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public void FillInvestmentBifurcationData(int riskProfileId, string investmentType, DataGridView dataGrid) { if (_dtInvestmentSegment != null) { _dtInvestmentSegment.Clear(); } IList <InvestmentSegment> InvestmentSegmentObj = new List <InvestmentSegment>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL, riskProfileId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <InvestmentSegment> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { InvestmentSegmentObj = jsonSerialization.DeserializeFromString <IList <InvestmentSegment> >(restResult.ToString()); } if (InvestmentSegmentObj != null) { _dtInvestmentSegment = ListtoDataTable.ToDataTable(InvestmentSegmentObj.ToList()); } fillGrid(investmentType, dataGrid); } catch (System.Net.WebException webException) { if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized.")) { MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); } }
private void loadCustomerData() { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + CLIENTS_GETALL; RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <List <Client> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { var clientColleection = jsonSerialization.DeserializeFromString <List <Client> >(restResult.ToString()); _dtClient = ListtoDataTable.ToDataTable(clientColleection); fillTreeviewData(_dtClient); } else { MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void removeRecord(int selectedId) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + DELETE_CONVERSATION_API; ProspectClientConversation prosClientConv = new ProspectClientConversation() { ID = selectedId, ProspectClientId = _prospectClient.ID, MachineName = System.Environment.MachineName, UpdatedByUserName = Program.CurrentUser.UserName }; string DATA = jsonSerialization.SerializeToString <ProspectClientConversation>(prosClientConv); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "DELETE", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); DataRow[] dr = _dtConversation.Select("ID =" + selectedId); if (dr.Count() > 0) { dr[0].Delete(); } } } } catch (Exception ex) { MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal DataTable GetSchemes(int investmentsegmentId) { DataTable dtSchemes = new DataTable(); IList <RecommendedSchemes> recommendedSchemesObj = new List <RecommendedSchemes>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_RECOMMENDEDSCHEME, investmentsegmentId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <RecommendedSchemes> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { recommendedSchemesObj = jsonSerialization.DeserializeFromString <IList <RecommendedSchemes> >(restResult.ToString()); } if (recommendedSchemesObj != null) { dtSchemes = ListtoDataTable.ToDataTable(recommendedSchemesObj.ToList()); } } catch (System.Net.WebException webException) { if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized.")) { MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); } return(dtSchemes); }
public DataTable GetRiskProfileReturnById(int id) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(RISKPROFILERETURN_DETAIL_GETALL, id); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <List <RiskProfiledReturn> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { var riskProfileColleection = jsonSerialization.DeserializeFromString <List <RiskProfiledReturn> >(restResult.ToString()); _dtRiskProfileReturn.Clear(); _dtRiskProfileReturn = ListtoDataTable.ToDataTable(riskProfileColleection); } else { MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(_dtRiskProfileReturn); }
private void removeRecord(TreeNode selectedNode) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + DELETE_PROSPECT_CLIENTS_API; ProspectClient prospClient = convertSelectedRowDataToProspectCustomer(); string DATA = jsonSerialization.SerializeToString <ProspectClient>(prospClient); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "DELETE", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); trvList.SelectedNode.Remove(); DataRow[] dr = _dtProspClients.Select("ID =" + prospClient.ID); if (dr.Count() > 0) { dr[0].Delete(); } } } } catch (Exception ex) { MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal IList <Loan> GetAll(int plannerId) { IList <Loan> loanObj = new List <Loan>(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_LOAN_API, plannerId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <Loan> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { loanObj = jsonSerialization.DeserializeFromString <IList <Loan> >(restResult.ToString()); } return(loanObj); } catch (System.Net.WebException webException) { if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized.")) { MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(null); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }