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

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

                return true;

            else

                return false;

        }

 

        public void SetPeriod(DateTime? begin, DateTime? end)

        {

            BeginDate = begin;

            EndDate = end;

        }

    }

 

}

 

 

PresenterBase.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace SmsMessanger.Presenters

{

    public class PresenterBase<T> : Notifer

    {

        private readonly T _view;

        private string _tabHeaderPath;

 

        public PresenterBase(T view)

        {

            _view = view;

        }

       

        public PresenterBase(T view, string tabHeaderPath)

        {

            _view = view;

            _tabHeaderPath = tabHeaderPath;

        }

        

 

        public T View

        {

            get { return _view; }

        }

 

        public string TabHeaderPath

        {

            get { return _tabHeaderPath; }

        }

    }

}

 

 

SendSmsByListPresenter.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 SendSmsByListPresenter : PresenterBase<SendSmsByListView>

    {

        private readonly Contact _contact;

        private readonly ApplicationPresenter _applicationPresenter;

        private readonly List<SmsTemplateGroup> _avalableSmsTemplates;

        private SmsTemplate _selectedTemplate;

        private DistributionList _distributionList;

        public string MessageText { get; set; }

 

        private VMDistributionTreeEdit _model;

 

        public VMDistributionTreeEdit Model

        {

            get { return _model; }

            set

            {

                _model = value;

                OnPropertyChanged("Model");

            }

        }

 

        public SendSmsByListPresenter(ApplicationPresenter applicationPresenter, SendSmsByListView view, DistributionList distributionList,

            List<SmsTemplateGroup> avalableSmsTemplates, SmsTemplate template)

            : base(view, "TabHeader")

        {

            _applicationPresenter = applicationPresenter;

            _avalableSmsTemplates = avalableSmsTemplates;

            DistributionList = distributionList;

 

            Model = new VMDistributionTreeEdit();

            Model.SetupGroups(DistributionList.Groups);

            Model.CheckedAll();

 

            if (template != null)

                MessageText = template.Text;

        }

 

        public List<SmsTemplateGroup> AvalableSmsTemplates

        {

            get { return _avalableSmsTemplates; }

        }

        public string TabHeader

        {

            get { return string.Format("Отправка SMS по списку {0}",DistributionList.Title); }

        }

        public SmsTemplate SelectedTemplate

        {

            get

            {

                return _selectedTemplate;

            }

            set

            {

                _selectedTemplate = value;

                OnPropertyChanged("SelectedTemplate");

            }

        }

        public DistributionList DistributionList

        {

            get

            {

                return _distributionList;

            }

            set

            {

                _distributionList = value;

                OnPropertyChanged("DistributionList");

            }

        }

        public void SendSmsList()

        {

            List<Guid> selectedContacts = new List<Guid>();

            foreach (var ContactsGroup in Model.Groups)

                foreach (var contact in ContactsGroup.Contacts)

                    selectedContacts.Add(contact.Id);

           

            List<Contact> contacts = _applicationPresenter.FindContactsById(selectedContacts.ToArray());

 

            _applicationPresenter.SendSmsByList(contacts, View.SmsMessage.Text);

        }

        public void Cancel()

        {

            _applicationPresenter.CloseTab(this);

        }

        public void SaveSmsTemplate(string title, string text, SmsTemplateGroup group)

        {

            SmsTemplate template = new SmsTemplate { Text = text, Title = title, ParentGroup = group };

            _applicationPresenter.SaveSmsTemplate(template);

        }

 

 

        public override bool Equals(object obj)

        {

            SendSmsByListPresenter presenter = obj as SendSmsByListPresenter;

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

        }

 

       

    }

}

 

 

SmsSendReportPresenter.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SmsMessanger.Views;

using SmsMessanger.Model;

 

namespace SmsMessanger.Presenters

{

    public class SmsSendReportPresenter:PresenterBase<SmsSendReportView>

    {

 

 

        private SmsSendReportView View { get; set; }

        private ApplicationPresenter ApplicationPresenter { get; set; }

        private readonly SendSmsReport _report;

        public string HeaderText { get { return "Отчет"; } }

 

        public SendSmsReport Report { get { return _report; } }

 

        public SmsSendReportPresenter(ApplicationPresenter appPresenter, SmsSendReportView view, SendSmsReport report)

            :base(view,"HeaderText")

        {

            View = view;

            ApplicationPresenter = appPresenter;

            _report = report;

        }

    }

}

 

DistributionTreeBar.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using SmsMessanger.Presenters;

using SmsMessanger.Model;

 

namespace SmsMessanger.UserControls

{

    /// <summary>

    /// Interaction logic for SmsTemplateBar.xaml

    /// </summary>

    public partial class DistributionTreeBar : UserControl

    {

        public DistributionTreeBar()

        {

            InitializeComponent();

        }

 

        private ApplicationPresenter Presenter { get { return DataContext as ApplicationPresenter; } }

 

        private void EditContactButtonClick(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

                Presenter.OpenContact(button.DataContext as Contact);

        }

 

        private void EditDistributionButtin_click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button!=null)

                Presenter.OpenDistributionList(button.DataContext as DistributionList);

        }

 

        private void AddDistributionList_click(object sender, RoutedEventArgs e)

        {

            Presenter.OpenDistributionList(new DistributionList() { Title="Новый список рассылки" });

        }

 

        private void SendSmsButton_click(object sender, RoutedEventArgs e)

        {

            Button button =  sender as Button;

            if (button != null)

                Presenter.SendSmsByDistributionList(button.DataContext as DistributionList,null);

        }

 

        private void distributionList_drop(object sender, DragEventArgs e)

        {

            string[] formats = e.Data.GetFormats();

            if (formats.Contains("SmsTemplate"))

            {

                Presenter.SendSmsByDistributionList((sender as Border).DataContext as DistributionList,

                    e.Data.GetData("SmsTemplate") as SmsTemplate);

            }

 

           

        }

 

        private void dropToStudent(object sender, DragEventArgs e)

        {

            string[] formats = e.Data.GetFormats();

            if (formats.Contains("SmsTemplate"))

            {

                Presenter.SendSmsByContact((sender as Border).DataContext as Contact,

                    e.Data.GetData("SmsTemplate") as SmsTemplate);

            }

        }

 

        private void deleteDistributionListButton_click(object sender, RoutedEventArgs e)

        {

            if (MessageBox.Show("Вы уверены, что хотите удалить список рассылки", "Удаление списка рассылки", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)

                return;

            Button button = sender as Button;

            if (button!=null)

                Presenter.DeleteDistributionList(button.DataContext as DistributionList);

        }

 

       

    }

}

 

 

Menu.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using SmsMessanger.Presenters;

 

namespace SmsMessanger.UserControls

{

    /// <summary>

    /// Interaction logic for Menu.xaml

    /// </summary>

    public partial class Menu : UserControl

    {

 

        private bool _isHelpShowing;

 

        public Menu()

        {

            _isHelpShowing = false;

            InitializeComponent();

        }

 

        private ApplicationPresenter Presenter { get { return DataContext as ApplicationPresenter; } }

 

        private void OpenLog_click(object sender, RoutedEventArgs e)

        {

            Presenter.OpenLog();

        }

 

        private void ShowHelp_click(object sender, RoutedEventArgs e)

        {

            ShowHelp();

        }

 

 

        public void ShowHelp()

        {

            if (!_isHelpShowing)

            {

                _isHelpShowing = true;

                Help helpwindow = new Help();

                helpwindow.Show();

                helpwindow.Closed += (s, arg) =>

                {

                    _isHelpShowing = false;

                };

            }

        }

 

        private void OpenSettings_click(object sender, RoutedEventArgs e)

        {

            Presenter.OpenSettings();

        }

 

        private void exitMenuClick(object sender, RoutedEventArgs e)

        {

            Presenter.CloseApp();

        }

    }

}

 

 

SideBar.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using SmsMessanger.Presenters;

using SmsMessanger.Model;

using System.Windows.Controls.Primitives;

 

namespace SmsMessanger.UserControls

{

    /// <summary>

    /// Interaction logic for SideBar.xaml

    /// </summary>

    public partial class SideBar : UserControl

    {

        public SideBar()

        {

            InitializeComponent();

        }

 

        private ApplicationPresenter Presenter { get { return DataContext as ApplicationPresenter; } }

 

        private void newContactButton_Click(object sender, RoutedEventArgs e)

        {

            Presenter.OpenContact(new Model.Contact());

        }

 

        private void editContactButton_Click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

                Presenter.OpenContact(button.DataContext as Contact);

        }

 

        private void deleteContactButton_click(object sender, RoutedEventArgs e)

        {

            if (MessageBox.Show("Уверены?", "Удаление контакта", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)

                return;

            Button button = sender as Button;

            if (button != null)

                Presenter.DeleteContact(button.DataContext as Contact);

        }

 

        private void newGroupButton_Click(object sender, RoutedEventArgs e)

        {

            Presenter.OpenGroup(new Group() { Title = "Новая группа" });

        }

 

        private void editGroupButton_Click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

                Presenter.OpenGroup(button.DataContext as Group);

        }

 

        private void TooGleUsersButton_checked(object sender, RoutedEventArgs e)

        {

            ToggleButton button = sender as ToggleButton;

            if (button != null)

                Presenter.AddCheckedGroup(button.DataContext as Group);

        }

 

        private void TooGleUsersButton_unChecked(object sender, RoutedEventArgs e)

        {

            ToggleButton button = sender as ToggleButton;

            if (button != null)

                Presenter.RemoveCheckedGroup(button.DataContext as Group);

        }

 

        private void deleteGroupButton_click(object sender, RoutedEventArgs e)

        {

            if (MessageBox.Show("Уверены?", "Удаление группы", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)

                return;

            Button button = sender as Button;

            if (button != null)

                Presenter.DeleteGroup(button.DataContext as Group);

        }

 

        private void addUserToGroupButton_Click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

            {

                Group group = (button.DataContext as Group);

                Presenter.OpenContact(new Model.Contact() { Group = group });

            }

        }

 

        private void sendSmsToContact_button(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button!=null)

                Presenter.SendSmsByContact(button.DataContext as Contact, null);

        }

 

        private void dropToStudent(object sender, DragEventArgs e)

        {

            string[] formats = e.Data.GetFormats();

            if (formats.Contains("SmsTemplate"))

            {

                Presenter.SendSmsByContact((sender as Border).DataContext as Contact,

                    e.Data.GetData("SmsTemplate") as SmsTemplate);

            }

        }

 

       

       

    }

}

 

 

SmsTemplateBar.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using SmsMessanger.Presenters;

using SmsMessanger.Model;

 

namespace SmsMessanger.UserControls

{

    /// <summary>

    /// Interaction logic for SmsTemplateBar.xaml

    /// </summary>

    public partial class SmsTemplateBar : UserControl

    {

        public bool MousePressedOnTreeItem = false;

        Point lastMouseDown;

 

        public SmsTemplateBar()

        {

            InitializeComponent();

        }

 

        private ApplicationPresenter Presenter { get { return DataContext as ApplicationPresenter; } }

 

        private void editSmsTemplateButton_click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

                Presenter.OpenSmsTemplate(button.DataContext as SmsTemplate);

        }

 

        private void DeleteSmsTemplateButton_click(object sender, RoutedEventArgs e)

        {

            if (MessageBox.Show("Уверены?", "Удаление шаблона SMS", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)

                return;

            Button button = sender as Button;

            if (button != null)

                Presenter.DeleteSmsTemplate(button.DataContext as SmsTemplate);

        }

 

        private void AddSmsTemplateButton_click(object sender, RoutedEventArgs e)

        {

            Button button = sender as Button;

            if (button != null)

                Presenter.OpenSmsTemplate(new SmsTemplate() { ParentGroup = button.DataContext as SmsTemplateGroup, Title="Новый шаблон"});

        }

 

        private void smsTemplate_mouseDown(object sender, MouseButtonEventArgs e)

        {

            if (e.ChangedButton == MouseButton.Left)

                lastMouseDown = e.GetPosition(sender as Border);

        }

 

        private void smsTemplate_mouseMove(object sender, MouseEventArgs e)

        {

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