/// <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
Beispiel #2
0
        /// <summary>
        /// Retrieve client (agent desktop) information for the given agent.
        /// </summary>
        /// <param name="agentID">The agent id whose client information is needed.</param>
        /// <returns>AgentClientData structure</returns>
        protected static AgentClientData RetrieveAgentClient(int agentID)
        {
            //ArrayList IPAddressPorts = new ArrayList();
            AgentClientData agent = new AgentClientData();

            string        connString = System.Configuration.ConfigurationManager.AppSettings["DBConnectionStringAif"];
            SqlConnection conn       = new SqlConnection(connString);

            SqlCommand sqlCommand = new SqlCommand("GetRegistrationByID", conn);

            sqlCommand.CommandType = CommandType.StoredProcedure;
            SqlParameter sqlParam = new SqlParameter("@agentid", SqlDbType.Int);

            sqlParam.Value = agentID;

            sqlCommand.Parameters.Add(sqlParam);
            conn.Open();

            using (SqlDataReader dr = sqlCommand.ExecuteReader(System.Data.CommandBehavior.Default))
            {
                try
                {
                    while (dr.Read())
                    {
                        //IPAddressPorts.Add( new IpAddressPort( dr.GetString(0), dr.GetString(1) ) );
                        agent.AgentID   = dr.GetInt32(0);
                        agent.ClientID  = dr.GetGuid(1);
                        agent.IPAddress = dr.GetString(2);
                        agent.Port      = dr.GetString(3);
                    }
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
            }
            return(agent);
        }