Esempio n. 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(Constants.GetConfigFilePath());
                contactManagement = new CommonLibrary.ActiveDirectory.ContactManagement("LDAP://" + 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;
                txtIPPhone.Text       = contact.IPPhone;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(Constants.GetConfigFilePath());
            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");
                    CommonLibrary.Utilities.Log.Create("Invalid Path of Logo" + ex.Message);
                }
            }

            try
            {
                string hexColor = appConfig.GetValue("Background");
                if (!hexColor.Equals(""))
                {
                    this.Background = BusinessLayer.Convert.HexColor2Brush(hexColor);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Background value");
                CommonLibrary.Utilities.Log.Create("Invalid Background value" + ex.Message);
            }
        }
Esempio n. 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            formStart = false;
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(Constants.GetConfigFilePath());
            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");
                    CommonLibrary.Utilities.Log.Create("Invalid Path of Logo" + ex.Message);
                }
            }

            try
            {
                string hexColor = appConfig.GetValue("Background");
                if (!hexColor.Equals(""))
                {
                    this.Background = BusinessLayer.Convert.HexColor2Brush(hexColor);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Background value");
                CommonLibrary.Utilities.Log.Create("Invalid Background value" + ex.Message);
            }

            double width  = BusinessLayer.PersonalProfile.GetQuickSearchWindowWidth();
            double height = BusinessLayer.PersonalProfile.GetQuickSearchWindowHeight();

            if (width != 0)
            {
                this.Width = width;
            }
            if (height != 0)
            {
                this.Height = height;
            }

            this.Top  = System.Windows.SystemParameters.PrimaryScreenHeight - this.Height - 50;
            this.Left = System.Windows.SystemParameters.PrimaryScreenWidth - this.Width;

            txtName.Focus();
        }
        private void ViewData()
        {
            if (lbName.SelectedIndex != -1 && Constants.IsNotContain(lbName.SelectedItem.ToString()))
            {
                RemoveDetailsView();



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

                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(Constants.GetConfigFilePath());

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

                int itemIndex = lbName.SelectedIndex + 1;

                if (appConfig.GetValue("BusinessPhone").Equals("yes"))
                {
                    string business = 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("HomePhone").Equals("yes"))
                {
                    string home = 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 = 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("BusinessFax").Equals("yes"))
                {
                    string businessfax = 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 = 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 = 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;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Search all the contacts
        /// </summary>
        public void SearchAll()
        {
            CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(CommonLibrary.Constants.GetConfigFilePath());


            if (CommonLibrary.Constants.IsActiveDirectory())
            {
                //Active Directory Contact

                string domainName = CommonLibrary.Constants.GetADDomain();


                try
                {
                    CommonLibrary.ActiveDirectory.ContactManagement contactManagement = new CommonLibrary.ActiveDirectory.ContactManagement(domainName);
                    Dictionary <string, Contact> activeDirectoryContacts = contactManagement.RetrieveAllContact("(objectCategory=person)");

                    foreach (var k in activeDirectoryContacts)
                    {
                        string key = k.Key;
                        if (_contacts.ContainsKey(k.Key))
                        {
                            key = HandleDuplicateContact(k.Key, k.Value);
                        }

                        if (key != null)
                        {
                            _contacts.Add(key, k.Value);
                            backgroundWorker.ReportProgress(1, key);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (CommonLibrary.Constants.IsDebugMode())
                    {
                        MessageBox.Show("Check Domain Name  " + domainName + ";" + ex.Message);
                    }

                    CommonLibrary.Utilities.Log.Create("Check Domain Name  " + domainName + ";" + ex.Message);
                }
            }

            //Outlook contact
            if (CommonLibrary.Constants.IsOutlook())
            {
                try
                {
                    bool accessEmail = false;
                    if (appConfig.GetValue("Email").Equals("yes"))
                    {
                        accessEmail = true;
                    }

                    Dictionary <string, Contact> tmp_contacts = CommonLibrary.OutlookContact.ContactManagement.RetreiveAllContact(accessEmail);
                    foreach (var c in tmp_contacts)
                    {
                        string key = c.Key;
                        if (_contacts.ContainsKey(c.Key))
                        {
                            key = HandleDuplicateContact(c.Key, c.Value);
                        }

                        if (key != null)
                        {
                            _contacts.Add(key, c.Value);
                            backgroundWorker.ReportProgress(1, key);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (CommonLibrary.Constants.IsDebugMode())
                    {
                        MessageBox.Show("Outlook:" + ex.Message);
                    }
                    CommonLibrary.Utilities.Log.Create("Outlook:" + ex.Message);
                }
            }

            //Outlook Express
            if (CommonLibrary.Constants.IsOutlookExpress())
            {
                try
                {
                    Dictionary <string, Contact> tmp_contacts = CommonLibrary.OutlookExpress.ContactManagement.RetreiveAllContact();
                    foreach (var c in tmp_contacts)
                    {
                        string key = c.Key;
                        if (_contacts.ContainsKey(c.Key))
                        {
                            key = HandleDuplicateContact(c.Key, c.Value);
                        }

                        if (key != null)
                        {
                            _contacts.Add(key, c.Value);
                            backgroundWorker.ReportProgress(1, key);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (CommonLibrary.Constants.IsDebugMode())
                    {
                        MessageBox.Show("Outlook Express;" + ex.Message);
                    }
                    CommonLibrary.Utilities.Log.Create("Outlook Express;" + ex.Message);
                }
            }
            //return _contacts;
        }
Esempio n. 6
0
        public MainGUI()
        {
            InitializeComponent();



            NotifyMenu = new System.Windows.Forms.ContextMenuStrip();
            mnuAboutUs = new System.Windows.Forms.ToolStripMenuItem();
            mnuExit    = new System.Windows.Forms.ToolStripMenuItem();
            //mnuOptions = new System.Windows.Forms.ToolStripMenuItem();
            mnuRefresh              = new System.Windows.Forms.ToolStripMenuItem();
            mnuEditMyProfile        = new System.Windows.Forms.ToolStripMenuItem();
            mnuAddNewContact        = new System.Windows.Forms.ToolStripMenuItem();
            mnuEditMyProfile.Click += new EventHandler(mnuEditMyProfile_Click);
            mnuRefresh.Click       += new EventHandler(mnuRefresh_Click);
            mnuAddNewContact.Click += new EventHandler(mnuAddNewContact_Click);
            mnuAboutUs.Click       += new EventHandler(mnuAboutUs_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);


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

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

            //
            // mnuAddNewContact
            //
            mnuAddNewContact.Name = "mnuAddNewContact";
            mnuAddNewContact.Size = new System.Drawing.Size(152, 22);
            mnuAddNewContact.Text = "Add New Contact";

            //
            // NotifyMenu
            //
            NotifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                mnuAboutUs,
                mnuAddNewContact,
                mnuEditMyProfile,
                mnuRefresh,
                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  = "Telephone Directory";
            m_notifyIcon.Text             = "Telephone Directory";
            m_notifyIcon.Icon             = new System.Drawing.Icon(Constants.GetApplicationPath() + @"Icons\Icon.ico");
            m_notifyIcon.MouseClick      += new System.Windows.Forms.MouseEventHandler(m_notifyIcon_MouseClick);
            ShowTrayIcon(true);

            //Copy compulsory library for outllok to run
            try
            {
                CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(CommonLibrary.Constants.GetConfigFilePath());


                if (appConfig.GetValue("OutlookExpress").Equals("yes"))
                {
                    DirectoryInfo di = new DirectoryInfo("C:/Program files/NKTWab/bin");
                    if (!di.Exists)
                    {
                        di.Create();
                        File.Copy(Constants.GetApplicationPath() + "nktwab.dll", @"C:\Program files\NKTWab\bin\nktwab.dll");
                    }
                }
            }
            catch (Exception ex)
            {
                //System.Windows.Forms.MessageBox.Show(ex.Message);
                CommonLibrary.Utilities.Log.Create(ex.Message);
            }

            //Run the thread to load all contacts
            _QuickSearch = new QuickSearch();
            _QuickSearch.RunBackgroundWorker();
        }