Разработка системы рассылки СМС сообщений

Автор работы: Пользователь скрыл имя, 29 Января 2013 в 17:29, курсовая работа

Краткое описание

Целью курсовой работы является автоматизация рассылки SMS сообщений, для ускорения и облегчения работы по оповещению студентов.
Задачей, для достижения данной цели является создание приложения SmsMessenger, которое будет производить автоматизацию рассылки SMS.

Содержание

Введение 2
1. Описание предметной области 3
1.1. Предметная область курсового проекта 3
1.2. Информационно-логическая модель предметной области 3
2. Создание приложения SmsMessenger 6
2.1. Логическое проектирование 6
2.2. Модель данных 7
2.3. Описание представлений и представителей 8
3. Тестирование программы 17
Заключение 25
Список литературы 26
Пиложение А. Задание на курсовой проект 27
Приложение Б. Структура исходных файлов 28
Приложение В. XAML код всех представлений и библиотек ресурсов 30
Приложение Г. Код классов программы. 62

Вложенные файлы: 1 файл

Kursovik.docx

— 6.63 Мб (Скачать файл)

        }

        public string Address

        {

            get { return _address; }

            set

            {

                _address = value;

                OnPropertyChanged("Address");

            }

 

        }

        public string Photo

        {

            get

            {

                string defaultFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Photos", "Default.png");

                if (string.IsNullOrEmpty(_photo))

                    return defaultFileName;

                else

                {

                    string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Photos", _photo);

                    if (!File.Exists(fileName))

                        return defaultFileName;

                    else return fileName;

                }

            }

            set

            {

                _photo = value;

                OnPropertyChanged("Photo");

            }

 

        }

        public bool Checked

        {

            get { return _checked; }

            set

            {

                _checked = value;

                OnPropertyChanged("Checked");

            }

 

        }

        public Guid GroupId

        {

            get { return _groupId; }

            set

            {

                _groupId = value;

                OnPropertyChanged("GroupId");

            }

 

        }

        public Group Group

        {

            get { return _group; }

            set

            {               

                _group = value;

                if (value != null)

                    GroupId = value.Id;

                OnPropertyChanged("Group");

                OnPropertyChanged("GroupId");

            }

 

        }

        public DateTime? BirthDay

        {

            get { return _birthDay; }

            set

            {

                _birthDay = value;

                OnPropertyChanged("BirthDay");

            }

 

        }

 

        public Contact()

        {

            Id = Guid.NewGuid();

            /*if (BirthDay == null)

             *

                BirthDay = DateTime.Parse("01.01.1990");*/

        }

 

        public override bool Equals(object obj)

        {

            Contact other = obj as Contact;

            return other != null && Id == other.Id;

        }

 

        public override string ToString()

        {

            return Fio;

        }

    }

}

 

 

DistributionList.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class DistributionList:Notifer

    {

        private Guid _id;

        private string _title;

        private Guid _smsTemplateId;

        private List<Guid> _contactsId;

        [NonSerialized]

        private List<Contact> _contacts;

        private List<Group> _groups;

 

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

        }

        public string Title

        {

            get { return _title; }

            set

            {

                _title = value;

                OnPropertyChanged("Title");

            }

 

        }

        public Guid SmsTemplateId

        {

            get { return _smsTemplateId; }

            set

            {

                _smsTemplateId = value;

                OnPropertyChanged("SmsTemplateId");

            }

 

        }

        public List<Guid> ContactsId

        {

            get { return _contactsId; }

            set

            {

                _contactsId = value;

                OnPropertyChanged("ContactsId");

            }

 

        }

        public List<Contact> Contacts

        {

            get { return _contacts; }

            set

            {

                _contacts = value;

                OnPropertyChanged("Contacts");

                OnPropertyChanged("ContactsId");

 

                ContactsId.Clear();

                foreach (var item in Contacts)

                {

                    ContactsId.Add(item.Id);

                }

            }

        }

        public List<Group> Groups

        {

            get { return _groups; }

            set

            {

                _groups = value;

                OnPropertyChanged("Groups");

            }

 

        }

 

        public DistributionList()

        {

            _contacts = new List<Contact>();

            _contactsId = new List<Guid>();

            _groups = new List<Group>();

        }

 

        public DistributionList(List<Contact> contacts,string groupTitlte)

        {

            _contacts = contacts;

            _contactsId = (from c in contacts select c.Id).ToList();

            _groups = new List<Group>();

            _groups.Add(new Group { Title = groupTitlte, Contacts = contacts });

        }

 

        public override string ToString()

        {

            return Title;

        }

 

        public static List<Group> BuildGroupsByContacts(List<Contact> contacts)

        {

            List<Group> result = new List<Group>();

 

            if (contacts == null) return null;

            if (contacts.Count == 0) return null;

 

            //Setup groups in distribution list

            //Выбираем из контактов все возможные ID групп и названия

            List<Group> grs = (from c in contacts

                               group c by c.Group into grps

                               orderby grps.Key

                               select grps.Key).ToList();

            if (grs.Count > 1 || (grs.Count == 1 && grs[0] != null))

                foreach (var g in grs)

                {

                    if (g == null) continue;

                    //Сохдаем новую группу с аналогичным названием и новым ID

                    Group group = new Group()

                    {

                        Title = g.Title,

                        Id = Guid.NewGuid()

                    };

                    //Добавляем в группу все контакты в которых ID группы соответствует текущей

                    group.Contacts = new List<Contact>();

                    foreach (Contact c in contacts)

                        if (c.GroupId == g.Id) group.Contacts.Add(c);

 

                    //создаем засовываем группу в группы списка рассылки

                    result.Add(group);

                }

            //Если в текущей рассылки есть контакты у которых нет группы то засовываем их в кастомную группу

            List<Contact> nonGroupContacts = (from c in contacts where c.Group == null select c).ToList();

            if (nonGroupContacts.Count() != 0)

            {

                Group group = new Group()

                {

                    Title = "Без группы",

                    Id = Guid.NewGuid()

                };

                group.Contacts = nonGroupContacts;

                result.Add(group);

            }

 

            return result;

        }

 

        public override bool Equals(object obj)

        {

            if ((obj as DistributionList) == null) return false;

            return obj != null && (obj as DistributionList).Id == Id;

        }

    }

}

 

 

Group.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class Group : Notifer, IComparable

    {

        private string _title;

        private Guid _id;

        private int _firstYear;

        private int _lastYear;

        [NonSerialized]

        private List<Contact> _contacts;

        [NonSerialized]

        private bool _checked;

       

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

        }

        public string Title

        {

            get { return _title; }

            set

            {

                _title = value;

                OnPropertyChanged("Title");

            }

 

        }

        public int FirstYear

        {

            get { return _firstYear; }

            set

            {

                _firstYear = value;

                OnPropertyChanged("FirstYear");

            }

 

        }

        public int LastYear

        {

            get { return _lastYear; }

            set

            {

                _lastYear = value;

                OnPropertyChanged("LastYear");

            }

 

        }

        public virtual List<Contact> Contacts

        {

            get { return _contacts; }

            set

            {

                _contacts = value;

                OnPropertyChanged("Contacts");

            }

        }

        public bool Checked

        {

            get { return _checked; }

            set

            {

                _checked = value;

                OnPropertyChanged("Checked");

            }

        }

 

 

        public Group()

        {

            Contacts = new List<Contact>();

        }

 

        public override string ToString()

        {

            return Title;

        }

 

        public override bool Equals(object obj)

        {

            if (obj as Group == null) return false;

            return (obj as Group).Id == Id;

        }

 

        public int CompareTo(object obj)

        {

            return string.Compare((obj as Group).Title, Title);

        }

 

       

    }

}

 

 

LogEvent.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class LogEvent:Notifer

    {

        private Guid _id;

        private DateTime _date;

        private string _text;

        private string _miniImage;

 

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

        }

        public DateTime Date

        {

            get { return _date; }

            set

            {

                _date = value;

                OnPropertyChanged("Date");

            }

 

        }

        public string Text

        {

            get { return _text; }

            set

            {

                _text = value;

                OnPropertyChanged("Text");

            }

 

        }

        public string MiniImage

        {

            get

            {

                string result = string.Empty;

                string shortName = Enum.Format(typeof(SmsMessanger.LogImages),int.Parse(_miniImage),"g");

                result = string.Format("/images/LogIcons/{0}.png",shortName);

                return result;

            }

            set

            {

                _miniImage = value;

                OnPropertyChanged("MiniImage");

            }

 

        }       

    }

}

 

SendSmsReport.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class SendSmsReport:Notifer

    {

        private Guid _id;

        private string _message;

        private List<Contact> _successContacts;

        private List<Contact> _failContacts;

 

 

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

        }

        public string Message

        {

            get { return _message; }

            set

            {

                _message = value;

                OnPropertyChanged("Message");

            }

 

        }

        public List<Contact> SuccessContacts

        {

            get

            {

                return _successContacts;

            }

            set

            {

                _successContacts = value;

                OnPropertyChanged("SuccessContacts");

            }

        }

        public List<Contact> FailContacts

        {

            get

            {

                return _failContacts;

            }

            set

            {

                _failContacts = value;

                OnPropertyChanged("FailContacts");

            }

        }

 

        public void AddFail(Contact contact)

        {

            FailContacts.Add(contact);

        }

        public void AddSuccess(Contact contact)

        {

            SuccessContacts.Add(contact);

        }

 

        public SendSmsReport()

        {

            SuccessContacts = new List<Contact>();

            FailContacts = new List<Contact>();

        }

    }

}

 

 

SmsTemplate.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class SmsTemplate:Notifer

    {

        private Guid _id;

        private string _title;

        private string _text;

        [NonSerialized]

        private SmsTemplateGroup _parentGroup;

 

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

        }

        public string Title

        {

            get { return _title; }

            set

            {

                _title = value;

                OnPropertyChanged("Title");

            }

 

        }

        public string Text

        {

            get { return _text; }

            set

            {

                _text = value;

                OnPropertyChanged("Text");

            }

 

        }

        public SmsTemplateGroup ParentGroup

        {

            get { return _parentGroup; }

            set

            {

                _parentGroup = value;

                OnPropertyChanged("ParentGroup");

            }

 

        }

 

        public override string ToString()

        {

            return Title;

        }

 

        public override bool Equals(object obj)

        {

            if ((obj as SmsTemplate)==null) return false;

            return obj != null && (obj as SmsTemplate).Id == Id;

        }

    }

}

 

SmsTemplateGroup.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Model

{

    [Serializable]

    public class SmsTemplateGroup:Notifer

    {

        private Guid _id;

        private string _title;

        private List<SmsTemplate> _smsTemplates;

 

        public Guid Id

        {

            get { return _id; }

            set

            {

                _id = value;

                OnPropertyChanged("Id");

            }

 

Информация о работе Разработка системы рассылки СМС сообщений