Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

                int i = username.IndexOf(@"\");
                if (i != -1)
                {
                    username = username.Substring(i + 1, username.Length - i - 1);
                }
                txtUsername.Text = username;

                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);
                contactManagement = new CommonLibrary.ActiveDirectory.ContactManagement(appConfig.GetValue("DomainName"));
                contact           = contactManagement.GetUserProfile(username);
                contact.Username  = username;

                txtHomePhone.Text     = contact.HomePhone;
                txtMobilePhone.Text   = contact.MobilePhone;
                txtBusinessPhone.Text = contact.BusinessPhone;
                txtBusinessFax.Text   = contact.BusinessFax;
                txtEmail.Text         = contact.Email;
                txtAddress.Text       = contact.Address;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);
            lbOrganisationName.Text = appConfig.GetValue("OrganisationName");
            try
            {
                Uri         imageUri = new Uri(appConfig.GetValue("OrganisationLogo"));
                BitmapImage bi       = new BitmapImage(new Uri(appConfig.GetValue("OrganisationLogo"), UriKind.RelativeOrAbsolute));
                imgLogo.Source = bi;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Path of Logo");
            }



            contacts = searcher.SearchAll();

            var x = from u in contacts select u.Key;

            foreach (string st in x)
            {
                lbName.Items.Add(st);
            }
        }
Пример #3
0
        private static string GetDomain()
        {
            string domainName = "";

            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(CommonLibrary.Constants.GetConfigFilePath());
            domainName = appConfig.GetValue("DomainName");


            return(domainName);
        }
Пример #4
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);
         if (appConfig.GetValue("FirstRun").Equals("yes"))
         {
             appConfig.SaveValue("FirstRun", "No");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Options - closing  " + ex.Message);
     }
 }
Пример #5
0
        /// <summary>
        /// Search all the contacts
        /// </summary>
        public Dictionary <string, Contact> SearchAll()
        {
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(Constants.CONGIF_FILE);

            //Outlook contact
            if (appConfig.GetValue("Outlook").Equals("yes"))
            {
                try
                {
                    _contacts = CommonLibrary.OutlookContact.ContactManagement.RetreiveAllContact();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Outlook not available " + ex.Message);
                }
            }


            if (appConfig.GetValue("ActiveDirectory").Equals("yes"))
            {
                //Active Directory Contact
                string domainName = appConfig.GetValue("DomainName");
                try
                {
                    CommonLibrary.ActiveDirectory.ContactManagement contactManagement = new CommonLibrary.ActiveDirectory.ContactManagement(domainName);
                    Dictionary <string, Contact> activeDirectoryContacts = contactManagement.RetrieveAllContact("(objectCategory=person)");

                    foreach (var k in activeDirectoryContacts)
                    {
                        if (_contacts.ContainsKey(k.Key))
                        {
                            _contacts.Add(k.Key + " (AD)", k.Value);
                        }
                        else
                        {
                            _contacts.Add(k.Key, k.Value);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Wrong Domain Name  " + domainName);
                }
            }

            return(_contacts);
        }
Пример #6
0
        public MainGUI()
        {
            InitializeComponent();

            try
            {
                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);

                if (appConfig.GetValue("FirstRun").Equals("yes"))
                {
                    Options _Options = new Options();
                    _Options.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MainGUI:" + ex.Message);
            }
        }
Пример #7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);
            lbOrganisationName.Text = appConfig.GetValue("OrganisationName");
            if (appConfig.GetValue("DefaultLogo").Equals("no"))
            {
                try
                {
                    Uri         imageUri = new Uri(appConfig.GetValue("OrganisationLogo"));
                    BitmapImage bi       = new BitmapImage(new Uri(appConfig.GetValue("OrganisationLogo"), UriKind.RelativeOrAbsolute));
                    imgLogo.Source = bi;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Invalid Path of Logo");
                }
            }

            try
            {
                string hexColor = appConfig.GetValue("Background");
                if (!hexColor.Equals(""))
                {
                    this.Background = BusinessLayer.Convert.HexColor2Brush(hexColor);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Background value");
            }
            //t = new Thread(new ThreadStart(SearchAllContact));
            //Thread.Sleep(1);
            //t.Start();

            SearchAllContact();
        }
Пример #8
0
        private void ViewData()
        {
            if (lbName.SelectedIndex != -1 && BusinessLayer.Constants.IsNotContain(lbName.SelectedItem.ToString()))
            {
                RemoveDetailsView();



                Contact contact = contacts[lbName.SelectedItem.ToString().Trim()];

                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);

                Brush itemColor = new SolidColorBrush(Color.FromRgb(235, 235, 235));

                int itemIndex = lbName.SelectedIndex + 1;
                if (appConfig.GetValue("HomePhone").Equals("yes"))
                {
                    string home = BusinessLayer.Constants.HOME_PHONE + " " + contact.HomePhone;
                    contacts.Add(home, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = home;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                if (appConfig.GetValue("MobilePhone").Equals("yes"))
                {
                    string mobile = BusinessLayer.Constants.MOBILE_PHONE + " " + contact.MobilePhone;
                    contacts.Add(mobile, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = mobile;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                if (appConfig.GetValue("BusinessPhone").Equals("yes"))
                {
                    string business = BusinessLayer.Constants.BUSINESS_PHONE + " " + contact.BusinessPhone;
                    contacts.Add(business, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = business;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                if (appConfig.GetValue("BusinessFax").Equals("yes"))
                {
                    string businessfax = BusinessLayer.Constants.BUSINESS_FAX + " " + contact.BusinessFax;
                    contacts.Add(businessfax, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = businessfax;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                if (appConfig.GetValue("Email").Equals("yes"))
                {
                    string email = BusinessLayer.Constants.EMAIL + " " + contact.Email;
                    contacts.Add(email, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = email;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                if (appConfig.GetValue("Address").Equals("yes"))
                {
                    string address = BusinessLayer.Constants.ADDRESS + " " + contact.Address;
                    contacts.Add(address, contact);
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.FontWeight = FontWeights.Bold;
                    lbi.Background = itemColor;
                    lbi.Content    = address;
                    lbName.Items.Insert(itemIndex++, lbi);
                }

                oldSelectedIndex = lbName.SelectedIndex;
            }
        }
Пример #9
0
        private void ViewData()
        {
            if (lbName.SelectedIndex != -1 && BusinessLayer.Constants.IsNotContain(lbName.SelectedItem.ToString()))
            {
                var x =
                    from u in contacts
                    where BusinessLayer.Constants.IsContain(u.Key)
                    select u.Key;

                string[] st = x.ToArray();

                for (int k = 0; k < st.Count(); k++)
                {
                    contacts.Remove(st[k]);
                    lbName.Items.Remove(st[k]);
                }


                int     i       = lbName.SelectedIndex;
                Contact contact = contacts[lbName.SelectedItem.ToString().Trim()];

                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);

                if (appConfig.GetValue("HomePhone").Equals("yes"))
                {
                    string home = BusinessLayer.Constants.HOME_PHONE + " " + contact.HomePhone;
                    contacts.Add(home, contact);
                    lbName.Items.Insert(i + 1, home);
                }

                if (appConfig.GetValue("MobilePhone").Equals("yes"))
                {
                    string mobile = BusinessLayer.Constants.MOBILE_PHONE + " " + contact.MobilePhone;
                    contacts.Add(mobile, contact);
                    lbName.Items.Insert(i + 2, mobile);
                }

                if (appConfig.GetValue("BusinessPhone").Equals("yes"))
                {
                    string business = BusinessLayer.Constants.BUSINESS_PHONE + " " + contact.BusinessPhone;
                    contacts.Add(business, contact);
                    lbName.Items.Insert(i + 3, business);
                }

                if (appConfig.GetValue("BusinessFax").Equals("yes"))
                {
                    string businessfax = BusinessLayer.Constants.BUSINESS_FAX + " " + contact.BusinessFax;
                    contacts.Add(businessfax, contact);
                    lbName.Items.Insert(i + 4, businessfax);
                }

                if (appConfig.GetValue("Email").Equals("yes"))
                {
                    string email = BusinessLayer.Constants.EMAIL + " " + contact.Email;
                    contacts.Add(email, contact);
                    lbName.Items.Insert(i + 5, email);
                }

                if (appConfig.GetValue("Address").Equals("yes"))
                {
                    string address = BusinessLayer.Constants.ADDRESS + " " + contact.Address;
                    contacts.Add(address, contact);
                    lbName.Items.Insert(i + 6, address);
                }



                //lbName.SelectedIndex = i;
            }
        }
Пример #10
0
        public MainGUI()
        {
            InitializeComponent();

            try
            {
                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(BusinessLayer.Constants.CONGIF_FILE);

                if (appConfig.GetValue("FirstRun").Equals("yes"))
                {
                    Options _Options = new Options();
                    _Options.Show();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("MainGUI:" + ex.Message);
            }

            NotifyMenu              = new System.Windows.Forms.ContextMenuStrip();
            mnuAboutUs              = new System.Windows.Forms.ToolStripMenuItem();
            mnuExit                 = new System.Windows.Forms.ToolStripMenuItem();
            mnuOptions              = new System.Windows.Forms.ToolStripMenuItem();
            mnuEditMyProfile        = new System.Windows.Forms.ToolStripMenuItem();
            mnuEditMyProfile.Click += new EventHandler(mnuEditMyProfile_Click);
            mnuOptions.Click       += new EventHandler(mnuOptions_Click);

            //
            // mnuAboutUs
            //
            mnuAboutUs.Name = "mnuAboutUs";
            mnuAboutUs.Size = new System.Drawing.Size(152, 22);
            mnuAboutUs.Text = "About Us";

            //
            // mnuExit
            //
            mnuExit.Name   = "mnuExit";
            mnuExit.Size   = new System.Drawing.Size(152, 22);
            mnuExit.Text   = "Exit";
            mnuExit.Click += new EventHandler(mnuExit_Click);


            //
            // mnuOptions
            //
            mnuOptions.Name = "mnuOptions";
            mnuOptions.Size = new System.Drawing.Size(152, 22);
            mnuOptions.Text = "Options";

            //
            // mnuOptions
            //
            mnuEditMyProfile.Name = "mnuEditMyProfile";
            mnuEditMyProfile.Size = new System.Drawing.Size(152, 22);
            mnuEditMyProfile.Text = "Edit My Profile";

            //
            // NotifyMenu
            //
            NotifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                mnuOptions,
                mnuEditMyProfile,
                mnuAboutUs,
                mnuExit
            });
            NotifyMenu.Name = "NotifyMenu";
            NotifyMenu.Size = new System.Drawing.Size(153, 92);



            // NotifyIcon
            m_notifyIcon = new System.Windows.Forms.NotifyIcon();
            m_notifyIcon.ContextMenuStrip = NotifyMenu;
            m_notifyIcon.BalloonTipText   = "The app has been minimised. Click the tray icon to show.";
            m_notifyIcon.BalloonTipTitle  = "The App";
            m_notifyIcon.Text             = "The App";
            m_notifyIcon.Icon             = new System.Drawing.Icon(@"Icons\Icon.ico");
            m_notifyIcon.MouseClick      += new System.Windows.Forms.MouseEventHandler(m_notifyIcon_MouseClick);
            ShowTrayIcon(true);
        }