public void SetUI(EmailDataModel item)
 {
     
      this.IndividualName.Content = "Name : " + item.SenderName;
      this.IndividualDepartment.Content = "Department : " + item.SenderGroup;
      this.IndividualCount.Content = "Number of Email Conversation: " + item.SenderParticipation.ToString();
 }
 void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     var winFabSortedList = winFabInterest;
     ListBox lstBx = new ListBox();
     lstBx.Height = this.MainPanel.Height;
     lstBx.Width = this.MainPanel.Width;
     this.MainPanel.Children.Add(lstBx);
     if (winFabSortedList.Count == 0)
     {
         MessageBox.Show("No Records Found.Try changing the folder option.");
     }
     else
     {
         foreach (var itm in winFabSortedList)
         {
             EmailDataModel emailObj = new EmailDataModel();
             emailObj.SenderName = itm.SenderName;
             emailObj.SenderGroup = itm.SenderGroup;
             emailObj.SenderParticipation = itm.SenderParticipation;
             emailObj.SenderContact = itm.SenderContact;
             InterestControl intControl = new InterestControl();
             intControl.SetUI(emailObj);
             lstBx.Items.Add(intControl);
         }
     }
     this.EllipseAnimate.Visibility = Visibility.Collapsed;
     this.EllipseAnimate.Visibility = Visibility.Collapsed;
     this.UpdateLayout();
 }
Beispiel #3
0
        public List<EmailDataModel> GetIndividualInterest(int count, List<string> searchInFolders)
        {
            Dictionary<string, EmailDataModel> filterDictionary = new Dictionary<string, EmailDataModel>();
            List<EmailDataModel> filterList = new List<EmailDataModel>();
            List<MAPIFolder> searchFolders = new List<MAPIFolder>();
            string department = String.Empty;
            string name = String.Empty;
            string picturePath = String.Empty;
            string contact = String.Empty;
            RuleDataModel ruleObj = new RuleDataModel();
            Rules readRulesObj = new Rules();
            string filter = String.Empty;
            DateTime date = DateTime.Now.AddDays(-count);
            string filterDate = date.ToString("MM/dd/yyyy hh:mm t", CultureInfo.InvariantCulture);
            try
            {
                outlookFolders.Clear();
                ruleObj = readRulesObj.ReadCustomRules();
                searchFolders = SearchSelectedFolders(searchInFolders);
                filter = "[ReceivedTime]>='" + filterDate + "'";
                foreach (MAPIFolder folder in searchFolders)
                {
                    var outlookItems = folder.Items.Restrict(filter);
                    for (int i = 1; i <= outlookItems.Count; i++)
                    {
                        try
                        {
                            MailItem itm = (MailItem)outlookItems[i];
                            if (itm.SentOn > DateTime.Now.AddDays(-count) || count == 0)
                            {
                                if (itm.Body.ContainsAny(ruleObj.SearchForBodyTags) ||
                                   itm.To.ContainsAny(ruleObj.SearchForToRecepients))
                                {

                                    department = itm.Sender.GetExchangeUser().Department;

                                    if (!department.ContainsAny(ruleObj.SearchForDenyDepartments) &&
                                        !itm.Body.ContainsAny(ruleObj.SearchForDenyBodyTags) &&
                                        !itm.Subject.ContainsAny(ruleObj.SearchForDenySubject))
                                    {
                                        contact = itm.Sender.GetExchangeUser().MobileTelephoneNumber;
                                        name = itm.Sender.Name;
                                        if (filterDictionary.ContainsKey(name))
                                        {
                                            filterDictionary[name].SenderParticipation++;
                                        }
                                        else
                                        {
                                            EmailDataModel emailObj = new EmailDataModel();
                                            emailObj.SenderName = name;
                                            emailObj.SenderGroup = department;
                                            emailObj.SenderImage = contact;
                                            emailObj.SenderParticipation = 1;
                                            filterDictionary.Add(name, emailObj);
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            LoggerClass.WriteException(DateTime.Now, "Logic", ex.Message);
                        }

                    }

                }
                foreach (var itm in filterDictionary)
                {
                    filterList.Add(itm.Value);
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                Console.WriteLine(ex.ToString());
                LoggerClass.WriteException(DateTime.Now, "Logic", ex.Message);
            }
            catch (System.Exception ex)
            {
                LoggerClass.WriteException(DateTime.Now, "Logic", ex.Message);
            }
            

            filterList = filterList.OrderByDescending(e => e.SenderParticipation).ToList();
            CreateIndividualCSV(filterList);
            return filterList;
        }