internal void ShowSelectedSalesOrderItem(string salesorderkey)
{
Logger.Log(Severity.Verbose, Categories.Outlook_RelatedEntity, "AssociatedEntitiesTabMediator::ShowSelectedSalesOrderItem(salesorderkey="+salesorderkey+")");
GWDEMO.GWDEMO serviceContext = null;
try
{
this.dgvEPM_SalesOrderItem.Rows.Clear();
serviceContext = new GWDEMO.GWDEMO(new Uri(this.businessApplication.ServiceUrl));
string associatedEntityUrl = string.Format("{0}/SalesOrderCollection('{1}')/salesorderlineitems",this.businessApplication.ServiceUrl,salesorderkey);
Logger.Log(Severity.Info, Categories.Outlook_RelatedEntity, "Fetching SalesOrderItem records by querying {0}",associatedEntityUrl.Replace(businessApplication.ServiceUrl,""));
DataServiceQueryContinuation<GWDEMO.SalesOrderLineItem> token = null;
QueryOperationResponse<GWDEMO.SalesOrderLineItem> serviceresponse = serviceContext.Execute<GWDEMO.SalesOrderLineItem>(new Uri(associatedEntityUrl)) as QueryOperationResponse<GWDEMO.SalesOrderLineItem>;
do
{
if (token != null)
{
Logger.Log(Severity.Info, Categories.Outlook_RelatedEntity, "Server side paging enabled . Fetching next set of records for ShowSelectedSalesOrderItem");
serviceresponse = serviceContext.Execute<GWDEMO.SalesOrderLineItem>(token);
}
foreach (GWDEMO.SalesOrderLineItem entity in serviceresponse)
{
DataGridViewRow dataGridRow = new DataGridViewRow();
AddPropertyToGridRow(dataGridRow, entity.ProductID,"ProductID");
AddPropertyToGridRow(dataGridRow, entity.ProductName,"ProductName");
AddPropertyToGridRow(dataGridRow, entity.NetSum,"NetSum");
AddPropertyToGridRow(dataGridRow, entity.Tax,"Tax");
AddPropertyToGridRow(dataGridRow, entity.TotalSum,"TotalSum");
AddPropertyToGridRow(dataGridRow, entity.CurrencyCodeDescription,"CurrencyCodeDescription");
AddPropertyToGridRow(dataGridRow, entity.Availability,"Availability");
AddPropertyToGridRow(dataGridRow, entity.Note,"Note");
this.dgvEPM_SalesOrderItem.Rows.Add(dataGridRow);
}
SAP.IW.SSO.Supportability.SingleActivityTraceUtil.Instance.UpdateRequestForSAT(serviceresponse.Headers, serviceresponse.StatusCode, serviceresponse.Query.RequestUri.ToString());
}
while ((token = serviceresponse.GetContinuation()) != null);
}
catch (SSOException ex)
{
ExceptionHandler.ShowMessage(ResourceManager.GetLocalizedText("UserAuthentication_Error", Constants.ErrorMessages));
Logger.Log(Severity.Error, Categories.Outlook_RelatedEntity, "SSOException raised during fetching SalesOrderItems from backend for salesorederkey="+salesorderkey+".");
Logger.LogException(Severity.Error, Categories.Outlook_RelatedEntity, ex);
}
catch (DataServiceQueryException queryEx)
{
ExceptionHandler.LogAndShowException(queryEx, "DataServiceQueryException raised during fetching SalesOrderItems from backend for salesorderkey="+salesorderkey+".");
}
catch (DataServiceRequestException requestEx)
{
ExceptionHandler.LogAndShowException(requestEx, "DataServiceRequestException raised during fetching SalesOrderItems from backendfor salesorderkey="+salesorderkey+".");
}
catch(System.Net.WebException webEx)
{
ExceptionHandler.LogAndShowException(webEx, "WebException raised during fetching SalesOrderItems from backend for salesorderkey="+salesorderkey+".");
}
catch (System.Exception ex)
{
if (ExceptionHandler.IsFatalException(ex))
{
throw;
}
Logger.Log(Severity.Error, Categories.Outlook_RelatedEntity, "Error while fetching the SalesOrderItems from backend and populating the grid");
Logger.LogException(Severity.Error, Categories.Outlook_RelatedEntity, ex);
}
}