public bool TestCheckingStringWithNull()
 {
     if (Email1 == null || Email1.Trim() == "")
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private string pop3recievecontent(string gmailuid)
        {
            Pop3Client pop3Client = null;

            pop3Client = new Pop3Client();
            pop3Client.Connect("pop.gmail.com", 995, true);
            pop3Client.Authenticate("*****@*****.**", "chp@2015", AuthenticationMethod.TryBoth);
            int count = pop3Client.GetMessageCount();

            this.Emails = new List <Email1>();
            int counter = 0;

            for (int j = count; j >= 1; j--)
            {
                Message message = pop3Client.GetMessage(j);
                string  hh1     = pop3Client.GetMessageUid(j);

                if (gmailuid == hh1)
                {
                    Email1 email1 = new Email1()
                    {
                        MessageNumber = j,
                        Subject       = message.Headers.Subject,
                        DateSent      = message.Headers.DateSent,

                        From = string.Format("<a href = 'mailto:{1}'>{0}</a>", message.Headers.From.DisplayName, message.Headers.From.Address),
                    };

                    MessagePart body = message.FindFirstHtmlVersion();

                    if (body != null)
                    {
                        email1.Body = body.GetBodyAsText();
                        return(email1.Body);
                    }
                    else
                    {
                        body = message.FindFirstPlainTextVersion();

                        if (body != null)
                        {
                            email1.Body = body.GetBodyAsText();
                            return(email1.Body);
                        }
                    }

                    this.Emails.Add(email1);
                }
                counter++;
            }
            return("");
        }
예제 #3
0
 /// <summary>
 /// Compares two EmailAddress objects
 /// </summary>
 public static bool operator !=(EmailAddress Email1, EmailAddress Email2)
 {
     if ((object)Email1 == null && (object)Email2 != null)
     {
         return(true);
     }
     if ((object)Email2 == null && (object)Email1 != null)
     {
         return(true);
     }
     if ((object)Email1 == null && (object)Email2 == null)
     {
         return(false);
     }
     return(Email1.ToString() != Email2.ToString());
 }
예제 #4
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            Email1 email1 = new Email1(Email.Text, Title1.Text, Content.Text);

            LV.Items.Add(email1.toString());
        }
        private string pop3recievecontent(string gmailuid)
        {
            Pop3Client pop3Client = null;
            pop3Client = new Pop3Client();
            pop3Client.Connect("pop.gmail.com", 995, true);
            pop3Client.Authenticate("*****@*****.**", "chp@2015", AuthenticationMethod.TryBoth);
            int count = pop3Client.GetMessageCount();
            this.Emails = new List<Email1>();
            int counter = 0;
            for (int j = count; j >= 1; j--)
            {
                Message message = pop3Client.GetMessage(j);
                string hh1 = pop3Client.GetMessageUid(j);

                if (gmailuid == hh1)
                {
                    Email1 email1 = new Email1()
                    {
                        MessageNumber = j,
                        Subject = message.Headers.Subject,
                        DateSent = message.Headers.DateSent,

                        From = string.Format("<a href = 'mailto:{1}'>{0}</a>", message.Headers.From.DisplayName, message.Headers.From.Address),
                    };

                    MessagePart body = message.FindFirstHtmlVersion();

                    if (body != null)
                    {
                        email1.Body = body.GetBodyAsText();
                        return email1.Body;
                    }
                    else
                    {
                        body = message.FindFirstPlainTextVersion();

                        if (body != null)
                        {
                            email1.Body = body.GetBodyAsText();
                            return email1.Body;
                        }
                    }

                    this.Emails.Add(email1);
                }
                counter++;
            }
            return "";
        }
예제 #6
0
        public string GetAllProperties()
        {
            string fullName = (Name.Trim() == "" ? ("") : Name.Trim())
                              + (MiddleName.Trim() == "" ? ("") : " " + MiddleName.Trim())
                              + (Surname.Trim() == "" ? ("") : " " + Surname.Trim());

            string generalInfo = (fullName == "" ? ("") : fullName + "\r\n")
                                 + (Nickname == "" ? ("") : Nickname.Trim() + "\r\n")
                                 + (Title == "" ? ("") : Title.Trim() + "\r\n")
                                 + (Company == "" ? ("") : Company.Trim() + "\r\n")
                                 + (Address.Trim() == "" ? ("") : Address.Trim() + "\r\n");

            string phones = (HomePhone == "" ? ("") : "H: " + HomePhone.Trim() + "\r\n")
                            + (MobilePhone == "" ? ("") : "M: " + MobilePhone.Trim() + "\r\n")
                            + (WorkPhone == "" ? ("") : "W: " + WorkPhone.Trim() + "\r\n")
                            + (Fax == "" ? ("") : "F:" + Fax.Trim() + "\r\n");

            string emails = (Email1 == "" ? ("") : "" + Email1.Trim() + "\r\n")
                            + (Email2 == "" ? ("") : "" + Email2.Trim() + "\r\n")
                            + (Email3 == "" ? ("") : "" + Email3.Trim() + "\r\n")
                            + (Homepage == "" ? ("") : "Homepage:" + "\r\n" + Homepage.Trim() + "\r\n");

            string dateOfBirth = "";

            if (DayOfBirth != "-" && DayOfBirth != "0" || MonthOfBirth != "-" ||
                YearOfBirth != "")
            {
                dateOfBirth = "Birthday "
                              + (DayOfBirth == "-" || DayOfBirth == "0" ? ("") : DayOfBirth + ". ")
                              + (MonthOfBirth == "-" ? ("") : MonthOfBirth + " ")
                              + (YearOfBirth == "" ? ("") : YearOfBirth + " (" +
                                 (DateTime.Now.Year - Convert.ToInt32(YearOfBirth)).ToString() + ")" + "\r\n");
            }

            string dateOfAnn = "";

            if (DayOfAnn != "-" && DayOfAnn != "0" || MonthOfAnn != "-" ||
                YearOfAnn != "")
            {
                dateOfAnn = "Anniversary "
                            + (DayOfAnn == "-" ? ("") : DayOfAnn + ". ")
                            + (MonthOfAnn == "-" ? ("") : MonthOfAnn + " ")
                            + (YearOfAnn == "" ? ("") : YearOfAnn + " (" +
                               (DateTime.Now.Year - Convert.ToInt32(YearOfAnn)).ToString() + ")\r\n");
            }

            string dates = (dateOfBirth == "" ? ("") : dateOfBirth)
                           + (dateOfAnn == "" ? ("") : dateOfAnn);

            string additional = (Address2 == "" ? ("") : Address2.Trim() + "\r\n")
                                + (Phone2 == "" ? ("") : "\r\nP: " + Phone2.Trim() + "\r\n")
                                + (Notes == "" ? ("") : "\r\n" + Notes.Trim());

            string allProperties = ((generalInfo == "" ? ("") : generalInfo)
                                    + (phones == "" ? ("") : "\r\n" + phones)
                                    + (emails == "" ? ("") : "\r\n" + emails)
                                    + (dates == "" ? ("") : "\r\n" + dates)
                                    + (additional == "" ? ("") : "\r\n" + additional)).Trim();

            return(allProperties);
        }
예제 #7
0
        /// <summary>
        /// Get the GEDCOM 5.5 lines for the data in this object.
        /// Lines start at the given level
        /// </summary>
        /// <param name="sw">
        /// A <see cref="TextWriter"/>
        /// </param>
        /// <param name="level">
        /// A <see cref="int"/>
        /// </param>
        public void Output(TextWriter sw, int level)
        {
            sw.Write(Environment.NewLine);
            sw.Write(Util.IntToString(level));
            sw.Write(" ADDR");

            if (!string.IsNullOrEmpty(AddressLine))
            {
                sw.Write(" ");

                Util.SplitLineText(sw, AddressLine, level, 60, 3, true);
            }

            string levelStr     = null;
            string levelPlusOne = null;

            if (!string.IsNullOrEmpty(AddressLine1))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR1 ");
                if (line.Length <= 60)
                {
                    sw.Write(AddressLine1);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine1");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine2))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR2 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine2");
                }
            }

            if (!string.IsNullOrEmpty(AddressLine3))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = AddressLine3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" ADR3 ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating AddressLine3");
                }
            }

            if (!string.IsNullOrEmpty(City))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = City.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CITY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating City");
                }
            }

            if (!string.IsNullOrEmpty(State))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = State.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" STAE ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating State");
                }
            }

            if (!string.IsNullOrEmpty(PostCode))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = PostCode.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" POST ");
                if (line.Length <= 10)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 10));
                    System.Diagnostics.Debug.WriteLine("Truncating PostCode");
                }
            }

            if (!string.IsNullOrEmpty(Country))
            {
                if (levelPlusOne == null)
                {
                    levelPlusOne = Util.IntToString(level + 1);
                }

                string line = Country.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelPlusOne);
                sw.Write(" CTRY ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Country");
                }
            }

            if (!string.IsNullOrEmpty(Phone1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone1");
                }
            }

            if (!string.IsNullOrEmpty(Phone2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone2");
                }
            }

            if (!string.IsNullOrEmpty(Phone3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Phone3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" PHON ");
                if (line.Length <= 25)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 25));
                    System.Diagnostics.Debug.WriteLine("Truncating Phone3");
                }
            }

            if (!string.IsNullOrEmpty(Fax1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax1");
                }
            }

            if (!string.IsNullOrEmpty(Fax2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax2");
                }
            }

            if (!string.IsNullOrEmpty(Fax3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Fax3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" FAX ");
                if (line.Length <= 60)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 60));
                    System.Diagnostics.Debug.WriteLine("Truncating Fax3");
                }
            }

            if (!string.IsNullOrEmpty(Email1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email1");
                }
            }

            if (!string.IsNullOrEmpty(Email2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email2");
                }
            }

            if (!string.IsNullOrEmpty(Email3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Email3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" EMAIL ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Email3");
                }
            }

            if (!string.IsNullOrEmpty(Www1))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www1.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www1");
                }
            }

            if (!string.IsNullOrEmpty(Www2))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www2.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www2");
                }
            }

            if (!string.IsNullOrEmpty(Www3))
            {
                if (levelStr == null)
                {
                    levelStr = Util.IntToString(level);
                }

                string line = Www3.Replace("@", "@@");

                sw.Write(Environment.NewLine);
                sw.Write(levelStr);
                sw.Write(" WWW ");
                if (line.Length <= 120)
                {
                    sw.Write(line);
                }
                else
                {
                    sw.Write(line.Substring(0, 120));
                    System.Diagnostics.Debug.WriteLine("Truncating Www3");
                }
            }
        }
 public bool TestStringWithEquals()
 {
     return(Email1.Equals(Email2));
 }
예제 #9
0
        //check for validation of Contacts fields
        public bool ContactsValidation()
        {
            bool result = false;

            //if (!NotEmptyFieldCheck(Phone1) && PhoneNumberValidationCheck(Phone1) == null &&
            //    !NotEmptyFieldCheck(Phone2) && PhoneNumberValidationCheck(Phone2) == null &&
            //    !NotEmptyFieldCheck(Phone3) && PhoneNumberValidationCheck(Phone3) == null &&
            //    !NotEmptyFieldCheck(Email1) && !Email1.Contains("@") &&
            //    !NotEmptyFieldCheck(Email2) && !Email2.Contains("@") &&
            //    !NotEmptyFieldCheck(VK) && !NotEmptyFieldCheck(FaceBook))
            //    //if (Phone1 == "+380" && Phone2 == "---" && Phone3 == "---" && Email1 == "---" && Email2 == "---" && VK == "---" && FaceBook == "---")
            //    return false;
            //else
            //{
            if (NotEmptyFieldCheck(Phone1) && PhoneNumberValidationCheck(Phone1) != null)
            {
                Phone1 = PhoneNumberValidationCheck(Phone1);
                result = true;
            }
            else
            {
                Phone1 = "+380";
            }

            if (NotEmptyFieldCheck(Phone2) && PhoneNumberValidationCheck(Phone2) != null)
            {
                Phone2 = PhoneNumberValidationCheck(Phone2);
                result = true;
            }
            else
            {
                Phone2 = "---";
            }
            if (NotEmptyFieldCheck(Phone3) && PhoneNumberValidationCheck(Phone3) != null)
            {
                Phone3 = PhoneNumberValidationCheck(Phone3);
                result = true;
            }
            else
            {
                Phone3 = "---";
            }
            if (!result)
            {
                dialogService.ShowMessage("Хотя бы одно из полей номера телефона нужно заполнить корректно");
                return(false);
            }
            if (Email1 != "---" && !Email1.Contains("@"))
            {
                dialogService.ShowMessage("Поле Email1 в контактных данных заполнено не корректно");
                return(false);
            }
            if (Email2 != "---" && !Email2.Contains("@"))
            {
                dialogService.ShowMessage("Поле Email2 в контактных данных заполнено не корректно");
                return(false);
            }

            return(true);

            //}
        }