コード例 #1
0
ファイル: LoginForm.cs プロジェクト: brunaldotoshkezi/CcFTest
 /// <summary>
 /// Runs when user fills the login details and presses submit
 /// </summary>
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         btnSubmit.Enabled = false;
         lblError.Text     = "";
         if ((txtUsername.Text == String.Empty) || (txtPassword.Text == String.Empty) || (txtDomain.Text == String.Empty))
         {
             lblError.Text     = localize.DESKTOP_MSG_EMPTY_LOGIN_DETAILS;
             btnSubmit.Enabled = true;
             return;
         }
         // validate the login details and keep a copy on client for all further communication with server
         AgentCredentialUtilities.ValidateAndSetCCFAgentCredential(txtUsername.Text, txtPassword.Text, txtDomain.Text);
         this.Close();
     }
     // We can not log these exceptions as we dont have enough priviledges yet to write in the logs
     catch (WebserviceConfigurationException wce)
     {
         lblError.Text     = localize.DESKTOP_MSG_WEBSERVICE_CLIENT_MISCONFIGURED;
         btnSubmit.Enabled = true;
     }
     catch (Exception ex)
     {
         lblError.Text     = localize.DESKTOP_MSG_INVALID_LOGIN_DETAILS;
         btnSubmit.Enabled = true;
     }
 }
コード例 #2
0
        /// <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
コード例 #3
0
        public override void Initialize()
        {
            //wc.Url = this.configurationReader.ReadSettings("Microsoft_Ccf_Samples_InstantMessaging_WebchatServer_WebchatServer");
            //wc.Credentials = System.Net.CredentialCache.DefaultCredentials;
            //wc.PreAuthenticate = true;
            string Url = this.configurationReader.ReadSettings("Microsoft_Ccf_Samples_InstantMessaging_WebchatServer_WebchatServer");

            System.ServiceModel.EndpointAddress wcAddress = new System.ServiceModel.EndpointAddress(Url);
            wc.Endpoint.Address = wcAddress;
            wc.ClientCredentials.Windows.ClientCredential = AgentCredentialUtilities.GetCurrentCredential();

            this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            //this.timer.Tick+=new EventHandler(timer_Tick);
            this.timer.Enabled  = false;
            this.timer.Interval = 2000;
            base.Initialize();
        }
コード例 #4
0
        private void AddressBookDlg_Load(object sender, System.EventArgs e)
        {
            bool defaultSearch = false;

            try
            {
                //book = new AddressBook.AddressBook();
                client = new AddressBook.AddressBookClient();
                string Url = UIConfiguration.ConfigurationReader.ReadSettings("AgentDesktop_AddressBook_AddressBook");
                System.ServiceModel.EndpointAddress addressBookServiceAddress = new System.ServiceModel.EndpointAddress(Url);
                client.Endpoint.Address = addressBookServiceAddress;
                client.ClientCredentials.Windows.ClientCredential = AgentCredentialUtilities.GetCurrentCredential();

                //book.Url = UIConfiguration.ConfigurationReader.ReadSettings("AgentDesktop_AddressBook_AddressBook");
                //book.Credentials  = Utils.GetCredentials();
                //book.PreAuthenticate = true;

                // Either init to the last search or to the first entries alphabetically
                if (lastNameSearchedFor != null)
                {
                    nameToFind.Text = lastNameSearchedFor;
                }
                else
                {
                    defaultSearch   = true;
                    nameToFind.Text = localize.AGENT_DESKTOP_ADDR_BOOK_DLG_NAME_TO_FIND;
                }

                find_Click(this, null);

                // remove text if using default search
                if (defaultSearch)
                {
                    nameToFind.Text = "";
                }

                tip.Active = false;
                tip.SetToolTip(addressList, "");
            }
            catch (Exception exp)
            {
                Logging.Error(Application.ProductName, localize.AGENT_DESKTOP_ADDR_BOOK_DLG_ERR_INITIALIZING_ADDR_BOOK, exp);
            }
        }