/// <summary> /// This is the general method to handle the message and send along as appopriate /// </summary> /// <param name="channel">The serialized channel information object.</param> /// <returns>A message the service wishes to return</returns> public string SendMessage(string channel) { ChannelInformation channelInformation = null; try { ChannelInformation ci = (ChannelInformation)GeneralFunctions.Deserialize <ChannelInformation>(channel); if (ci == null) { Logging.Error("MailChannel", "ChannelInformation is null"); } // Call out to get data CustomerClient customer = new CustomerClient(); CustomerProviderCustomerRecord custrec = customer.GetCustomerByID(ci.CustomerID); customer.Close(); ci.City = custrec.City; // = "Redmond"; ci.Country = custrec.Country; // = "USA"; ci.CustomerID = custrec.CustomerID; // = "1"; ci.FirstName = custrec.FirstName; // = "Maeve"; ci.LastName = custrec.LastName; // = "Elizabeth"; ci.PhoneHome = custrec.PhoneHome; // = "4252210456"; ci.PhoneMobile = custrec.PhoneMobile; // = "4252210456"; ci.PhoneWork = custrec.PhoneWork; // = "4252210456"; ci.State = custrec.State; // = "WA"; ci.Street = custrec.Street; // = "Rainy Street"; ci.ZipCode = custrec.ZipCode; // = "98008"; AgentClientData agent = RetrieveAgentClient(ci.Agent); Uri toUri = new Uri(String.Format("http://{0}:{1}/", agent.IPAddress.Trim(), agent.Port.Trim())); EndpointAddress address = new EndpointAddress(toUri.ToString()); string retValue = string.Empty; MultichannelSubsystemClient mcssclient = new MultichannelSubsystemClient(); try { mcssclient.Endpoint.Address = address; mcssclient.ClientCredentials.Windows.ClientCredential = AgentCredentialUtilities.GetCurrentCredential(); retValue = mcssclient.Call(GeneralFunctions.Serialize <ChannelInformation>(ci)); } catch (Exception ex) { Console.Write(ex.Message); } } catch (Exception ex) { Logging.Error(this.ToString(), ex.Message); return(ex.Message); } return(GeneralFunctions.Serialize(channelInformation)); } // SendMessage
public async Task <ResponseBase <List <CustomerModel> > > ReadCustomers() { var response = new ResponseBase <List <CustomerModel> >(); var list = new List <CustomerModel>(); var service = new CustomerClient(); try { var callback = await service.ReadCustomersAsync(); var data = callback.Data; foreach (var item in data) { list.Add(new CustomerModel() { Id = item.Id, Name = item.Name, Address = item.Address, BirthDate = item.BirthDate, CityId = item.CityId, CityName = item.CityName, CountryId = item.CountryId, CountryName = item.CountryName, DepartmentId = item.DepartmentId, DepartmentName = item.DepartmentName, DocumentId = item.DocumentId, DocumentType = item.DocumentType, DocumentTypeName = item.DocumentTypeName, }); } response.Code = callback.Code; response.Data = list; response.Message = callback.Message; } catch (Exception ex) { response.Code = StatusCode.ServiceUnavailable; response.Message = $"Ups! no se pudieron listar los usuario: {ex.Message}"; } service.Close(); return(response); }
public async Task <ResponseBase <CustomerModel> > ReadCustomerByIdOrName(long id = 0, string name = "") { var response = new ResponseBase <CustomerModel>(); var service = new CustomerClient(); try { var callback = await service.ReadCustomerByIdOrNameAsync(id, !string.IsNullOrWhiteSpace(name)?name : null); var data = callback.Data; var customer = new CustomerModel() { Id = data.Id, Name = data.Name, Address = data.Address, BirthDate = data.BirthDate, CityId = data.CityId, CityName = data.CityName, CountryId = data.CountryId, CountryName = data.CountryName, DepartmentId = data.DepartmentId, DepartmentName = data.DepartmentName, DocumentId = data.DocumentId, DocumentType = data.DocumentType, DocumentTypeName = data.DocumentTypeName, }; response.Code = callback.Code; response.Data = customer; response.Message = callback.Message; } catch (Exception ex) { response.Code = StatusCode.ServiceUnavailable; response.Message = $"Ups! no se pudieron listar los usuario: {ex.Message}"; } service.Close(); return(response); }
public async Task <ResponseBase <bool> > DeleteCustomer(long id) { var response = new ResponseBase <bool>(); var service = new CustomerClient(); try { var callback = await service.DeleteCustomerAsync(id); response.Code = callback.Code; response.Data = callback.Data; response.Message = callback.Message; } catch (Exception ex) { response.Code = StatusCode.ServiceUnavailable; response.Message = $"Ups! no se pudo crear el usuario: {ex.Message}"; } service.Close(); return(response); }
public async Task <ResponseBase <bool> > UpdateCustomer(CustomerModel data) { var response = new ResponseBase <bool>(); var service = new CustomerClient(); try { var callback = await service.UpdateCustomerAsync(new CustomerContract() { Id = data.Id, Name = data.Name, Address = data.Address, BirthDate = data.BirthDate, CityId = data.CityId, CityName = data.CityName, CountryId = data.CountryId, CountryName = data.CountryName, DepartmentId = data.DepartmentId, DepartmentName = data.DepartmentName, DocumentId = data.DocumentId, DocumentType = data.DocumentType, DocumentTypeName = data.DocumentTypeName, }); response.Code = callback.Code; response.Data = callback.Data; response.Message = callback.Message; } catch (Exception ex) { response.Code = StatusCode.ServiceUnavailable; response.Message = $"Ups! no se pudo crear el usuario: {ex.Message}"; } service.Close(); return(response); }