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

Автор работы: Пользователь скрыл имя, 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 Мб (Скачать файл)

        {

            if (!_checkedGroups.Contains(group))

            {

                _checkedGroups.Add(group);

                ApplyFilters();

            }

        }

 

        public void RemoveCheckedGroup(Group group)

        {

            if (_checkedGroups.Contains(group))

            {

                _checkedGroups.Remove(group);

                ApplyFilters();

            }

        }

 

        public void DeleteGroup(Group group)

        {

            _groupRepository.DeleteGroup(group);

            if (CurrentGroups.Contains(group))

                CurrentGroups.Remove(group);

        }

        #endregion

 

        #region Работа с логом

        public void OpenLog()

        {           

            View.AddTab(

                    new LogPresenter(this,new LogView(),_logEventRepository.FindAll())

                        );

        }

        #endregion

 

        public void CloseTab<T>(PresenterBase<T> presenter)

        {

            View.RemoveTab(presenter);

        }

 

        public void CloseApp()

        {

            App.Current.Shutdown();

        }

    }

}

 

 

EditConfigPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using System.Windows;

 

namespace SmsMessanger.Presenters

{

    public class EditConfigPresenter:PresenterBase<EditConfigView>

    {

        private string _smscPassword;

        private string _smscLogin;

        private string _oldPassword;

        private bool _combatMode;

 

        public string SmscLogin

        {

            get { return _smscLogin;}

            set

            {

                _smscLogin = value;

                OnPropertyChanged("SmscLogin");

            }

        }

        public string SmscPassword

        {

            get { return _smscPassword; }

            set

            {

                _smscPassword = value;

                OnPropertyChanged("SmscPassword");

            }

        }

        public bool CombatMode

        {

            get { return _combatMode; }

            set

            {

                _combatMode = value;

                OnPropertyChanged("CombatMode");

            }

        }

 

        public string HeaderText { get { return "Настройки"; } }

       

        private ApplicationPresenter _applicationPresenter;

        private EditConfigView _view;

 

        public EditConfigPresenter(ApplicationPresenter appPresenter, EditConfigView view):base(view,"HeaderText")

        {

            _applicationPresenter = appPresenter;

            _view = view;

 

            //Загрузка текущих настроек

            SmscLogin = Configurator.SmscLogin;

            SmscPassword = Configurator.SmscPassword;

            CombatMode = Configurator.CombatMode;

 

            _view.passwordBox.Password = SmscPassword;

 

            _oldPassword = string.Copy(_smscPassword);

        }

 

        public void SaveSettings()

        {

            SmscPassword = View.passwordBox.Password;

            if (SmscPassword != _oldPassword)

                if (MessageBox.Show("Сохранить изменения в пароле к SMSC?", "", MessageBoxButton.YesNo) != MessageBoxResult.Yes)

                    SmscPassword = _oldPassword;

            Configurator.SmscLogin = SmscLogin;

            Configurator.SmscPassword = SmscPassword;

            Configurator.CombatMode = CombatMode;

           

            _applicationPresenter.SaveSettings(this);

        }

        public override bool Equals(object obj)

        {

            if ((obj as EditConfigPresenter)!=null)

                return true;

            else

                return false;

 

        }

    }

 

}

 

 

EditContactPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

using Microsoft.Win32;

using System.IO;

using System.Windows.Data;

using System.Windows;

 

namespace SmsMessanger.Presenters

{

    public class EditContactPresenter:PresenterBase<EditContactView>

    {

        private readonly Contact _contact;

        private readonly ApplicationPresenter _applicationPresenter;

        private readonly List<Group> _avalableGroups;

 

        public EditContactPresenter(ApplicationPresenter applicationPresenter, EditContactView view, Contact contact,List<Group> groups):base(view,"Contact.Fio")

        {

            _applicationPresenter = applicationPresenter;

            _contact = contact;

            _avalableGroups = groups;

        }

 

        public Contact Contact

        {

            get { return _contact; }

        }

 

        public List<Group> AvalableGroups

        {

            get

            {

                return _avalableGroups;

            }

        }

 

        public void SaveImage()

        {

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Jpeg files|*.jpg|PNG files|*.png";

            if (dlg.ShowDialog() == true)

            {

                string oldPhoto = Contact.Photo;

 

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

                if(!Directory.Exists(PhotoDirectory))

                    Directory.CreateDirectory(PhotoDirectory);               

               

                string newShortName = Guid.NewGuid().ToString()+Path.GetExtension(dlg.FileName);

                string newFileName = Path.Combine("Photos",newShortName);

                if (!File.Exists(newFileName))

                    File.Copy(dlg.FileName,newFileName,true);

 

                Contact.Photo = newShortName;

            }

        }

 

        public void SaveContact()

        {

            if (View.groupList.SelectedItem != null)

                Contact.GroupId = (View.groupList.SelectedItem as Group).Id;

            else

            {

                MessageBox.Show("Необходимо выбрать группу");

                return;

            }

            Loger.Write(string.Format("Сохранение контакта {0}", Contact.Fio), LogImages.Save);

            _applicationPresenter.SaveContact(_contact);

        }

 

        public override bool Equals(object obj)

        {

            EditContactPresenter presenter = obj as EditContactPresenter;

            return presenter != null && presenter.Contact.Equals(Contact);

        }

    }

}

 

 

EditDistributionListPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

using Microsoft.Win32;

using System.IO;

using System.Windows.Data;

using System.Windows;

using SmsMessanger.Model.ViewModels;

 

namespace SmsMessanger.Presenters

{

    public class EditDistributionListPresenter:PresenterBase<EditDistributionListView>

    {

        private readonly ApplicationPresenter _applicationPresenter;

        private readonly DistributionList _distributionList;

        private VMDistributionTreeEdit _viewModel;

 

        public DistributionList DistributionList

        {

            get { return _distributionList; }

        }

        public VMDistributionTreeEdit ViewModel

        {

            get { return _viewModel; }

            set

            {

                _viewModel = value;

                OnPropertyChanged("ViewModel");

            }

        }

 

 

        public EditDistributionListPresenter(ApplicationPresenter applicationPresenter,

            EditDistributionListView view,

            DistributionList distributionList,

            List<Group> groups)

            : base(view, "DistributionList.Title")

        {

            _applicationPresenter = applicationPresenter;

            ViewModel = new VMDistributionTreeEdit();

 

            ViewModel.SetupGroups(groups);

 

            _distributionList = distributionList;

 

            //Получаем все id контактов списка

            List<Guid> DistributionContacts = (from c in DistributionList.Contacts select c.Id).ToList();

 

            //Устанавливаем чекед для каждого контакта модели если он в списке рассылки

            foreach (var group in ViewModel.Groups)

                foreach (var contact in group.Contacts)

                    if (DistributionContacts.Contains(contact.Id))

                    {

                        contact.IsChecked = true;

                        group.IsChecked = true;

                    }

        }

 

       

        public void SaveDistributionList()

        {

            if (_distributionList.Contacts != null)

            {

                _distributionList.ContactsId.Clear();

                _distributionList.Contacts.Clear();

            }

            if(_distributionList.Groups!=null)

                _distributionList.Groups.Clear();

           

            //Заполняем новые контакты

            foreach (DistributionTreeGroup g in ViewModel.Groups)

                foreach (var contact in g.Contacts)

                    if(contact.IsChecked)

                    DistributionList.ContactsId.Add(contact.Id);

           

           

            //Заполняем контакты по контактам

            DistributionList.Contacts = _applicationPresenter.FindContactsById(DistributionList.ContactsId.ToArray());

            DistributionList.Groups = DistributionList.BuildGroupsByContacts(DistributionList.Contacts);

 

            Loger.Write(string.Format("Сохранение списка рассылки: {0}", DistributionList.Title), LogImages.Save);

 

            _applicationPresenter.SaveDistributionList(DistributionList);

        }

 

        public override bool Equals(object obj)

        {

            EditDistributionListPresenter presenter = obj as EditDistributionListPresenter;

            return presenter != null && presenter.DistributionList.Equals(DistributionList);

        }

    }

}

 

 

EditGroupPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

using Microsoft.Win32;

using System.IO;

using System.Windows.Data;

using System.Windows;

 

namespace SmsMessanger.Presenters

{

    public class EditGroupPresenter:PresenterBase<EditGroupView>

    {

        private readonly Group _group;

        private readonly ApplicationPresenter _applicationPresenter;

        private readonly List<Group> _avalableGroups;

 

        public EditGroupPresenter(ApplicationPresenter applicationPresenter, EditGroupView view, Group contact)

            : base(view, "Group.Title")

        {

            _applicationPresenter = applicationPresenter;

            _group = contact;

        }

 

        public Group Group

        {

            get { return _group; }

        }

 

        public void SaveGroup()

        {

            Loger.Write(string.Format("Сохранение группы: {0}", _group.Title), LogImages.Save);

            _applicationPresenter.SaveGroup(_group);

        }

 

        public override bool Equals(object obj)

        {

            EditGroupPresenter presenter = obj as EditGroupPresenter;

            return presenter != null && presenter.Group.Equals(Group);

        }

    }

}

 

 

EditSmsTemplateGroupPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

 

namespace SmsMessanger.Presenters

{

    class EditSmsTemplateGroupPresenter:PresenterBase<EditSmsTemplateGroupView>

    {

        private SmsTemplateGroup _smsTemplateGroup;

        private readonly ApplicationPresenter _appPresenter;

        private readonly EditSmsTemplateGroupView _view;

 

        public SmsTemplateGroup SmsTemplateGroup

        {

            get { return _smsTemplateGroup; }

            set

            {

                _smsTemplateGroup = value;

                OnPropertyChanged("SmsTemplateGroup");

            }

        }

        public ApplicationPresenter AppPresenter

        {

            get { return _appPresenter; }

        }

        public EditSmsTemplateGroupView View

        {

            get { return _view; }

        }

 

       

 

        public EditSmsTemplateGroupPresenter(ApplicationPresenter appPresenter, EditSmsTemplateGroupView view, SmsTemplateGroup smsTemplateGroup):base(view,"SmsTemplateGroup.Title")

        {

            SmsTemplateGroup = smsTemplateGroup;

            _appPresenter = appPresenter;

        }

 

        public void Save()

        {

            AppPresenter.SaveSmsTemplateGroup(SmsTemplateGroup);

        }

 

        public override bool Equals(object obj)

        {

            EditSmsTemplateGroupPresenter other = obj as EditSmsTemplateGroupPresenter;

            if (other == null) return false;

            return other.SmsTemplateGroup == SmsTemplateGroup;

        }

    }

}

 

 

EditSmsTemplatePresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

using Microsoft.Win32;

using System.IO;

using System.Windows.Data;

using System.Windows;

 

namespace SmsMessanger.Presenters

{

    public class EditSmsTemplatePresenter:PresenterBase<EditSmsView>

    {

        private readonly SmsTemplate _smsTemplate;

        private readonly ApplicationPresenter _applicationPresenter;

 

        public EditSmsTemplatePresenter(ApplicationPresenter applicationPresenter, EditSmsView view, SmsTemplate smsTemplate)

            : base(view, "SmsTemplate.Title")

        {

            _applicationPresenter = applicationPresenter;

            _smsTemplate = smsTemplate;

        }

 

        public SmsTemplate SmsTemplate

        {

            get { return _smsTemplate; }

        }

 

        public void SaveSmsTemplate()

        {

            Loger.Write(string.Format("Сохранение шаблона SMS: {0}", _smsTemplate.Title), LogImages.Save);

            _applicationPresenter.SaveSmsTemplate(_smsTemplate);

        }

 

        public override bool Equals(object obj)

        {

            EditSmsTemplatePresenter presenter = obj as EditSmsTemplatePresenter;

            return presenter != null && presenter.SmsTemplate.Equals(SmsTemplate);

        }

    }

}

 

 

LogPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

 

namespace SmsMessanger.Presenters

{

    public class LogPresenter:PresenterBase<LogView>

    {

        private List<LogEvent> _logEvents;

        private DateTime? _beginDate;

        private DateTime? _endDate;

 

        public DateTime? BeginDate

        {

            get

            {

                return _beginDate;

            }

            set

            {

                _beginDate = value;

                OnPropertyChanged("BeginDate");

                OnPropertyChanged("CurrentLogEvents");

            }

 

        }

        public DateTime? EndDate

        {

            get

            {

                return _endDate;

            }

            set

            {

                _endDate = value;

                OnPropertyChanged("EndDate");

                OnPropertyChanged("CurrentLogEvents");

            }

 

        }

 

        public List<LogEvent> CurrentLogEvents

        {

            get

            {

                if (_beginDate == null || _endDate == null)

                    return _logEvents;

                else

                    return (from l in _logEvents where l.Date >= _beginDate && l.Date <= _endDate select l).ToList();

            }

 

        }

 

        public string TabHeader { get { return "Лог событий"; } }

       

        public LogPresenter(ApplicationPresenter appPresenter, LogView view, List<LogEvent> log)

            : base(view, "TabHeader")

        {

            _logEvents = log;

            SetPeriod(DateTime.Now.AddDays(-1), DateTime.Now);

        }

        public override bool Equals(object obj)

        {

            if ((obj as LogPresenter)!=null)

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