public static TasksViewModel ConvertToDisplay(DataForNotification inputData)
        {
            TasksViewModel displayData = new TasksViewModel();

            displayData.Name    = inputData.Name;
            displayData.Date    = inputData.DateAndTime.ToShortDateString();
            displayData.Time    = inputData.DateAndTime.ToShortTimeString();
            displayData.Comment = inputData.Comment;
            displayData.Group   = inputData.Group;

            if (inputData.Priority == 0)
            {
                displayData.Priority = "Низкий";
            }
            if (inputData.Priority == 1)
            {
                displayData.Priority = "Средний";
            }
            if (inputData.Priority == 2)
            {
                displayData.Priority = "Высокий";
            }

            displayData.Status = inputData.Status == true? "Выполнено":"";

            return(displayData);
        }
Beispiel #2
0
        public void WriteToFileEnrypted(DataForNotification dataForNotification, TaskType taskType)
        {
            string fileName;

            fileName = taskType == TaskType.Notification ? NotificationfileName : TaskfileName;

            FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);

            DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();

            cryptic.Key = ASCIIEncoding.ASCII.GetBytes("02052018");
            cryptic.IV  = ASCIIEncoding.ASCII.GetBytes("02052018");

            CryptoStream crStream = new CryptoStream(stream,
                                                     cryptic.CreateEncryptor(), CryptoStreamMode.Write);

            byte[] data = ASCIIEncoding.ASCII.GetBytes(dataForNotification.Name + "/"
                                                       + dataForNotification.DateAndTime + "/"
                                                       + dataForNotification.Comment + "/"
                                                       + dataForNotification.Group + "/"
                                                       + dataForNotification.Priority
                                                       + dataForNotification
                                                       .DateandTimeOfNotification + "/"
                                                       + dataForNotification.Status
                                                       + dataForNotification.IsNotification + "/"
                                                       + dataForNotification.Sound);


            crStream.Write(data, 0, data.Length);

            crStream.Close();
            stream.Close();
        }
Beispiel #3
0
        public AddNotificationWindow(ServiceController serviceController, DataForNotification data)
        {
            //todo add sounds to notif

            InitializeComponent();
            _data = data;
            _serviceController = serviceController;
        }
        public AddTask(/*ServiceController serviceController*/)
        {
            // todo return  _serviceController = serviceController;
            _data = new DataForNotification();

            InitializeComponent();

            // Default values
            NotificationDatePicker.SelectedDate = DateTime.Now;
            PriorityComboBox.SelectedIndex      = 0;

            //AddNotificationButton.IsEnabled = false;
        }
Beispiel #5
0
        public List <DataForNotification> ReadFileEncrypted(TaskType taskType)
        {
            List <DataForNotification> result = new List <DataForNotification>();

            string fileName;

            fileName = taskType == TaskType.Notification ? NotificationfileName : TaskfileName;

            FileStream stream = new FileStream(fileName,
                                               FileMode.Open, FileAccess.Read);

            DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();

            cryptic.Key = ASCIIEncoding.ASCII.GetBytes("02052018");
            cryptic.IV  = ASCIIEncoding.ASCII.GetBytes("02052018");

            CryptoStream crStream = new CryptoStream(stream,
                                                     cryptic.CreateDecryptor(), CryptoStreamMode.Read);

            StreamReader reader = new StreamReader(crStream);

            while (!reader.EndOfStream)
            {
                string data = reader.ReadLine();

                string[] array = data.Split('/');

                DataForNotification dataFromArray = new DataForNotification();

                dataFromArray.Name        = array[0];
                dataFromArray.DateAndTime = DateTime.Parse(array[1]);
                dataFromArray.Comment     = array[2];
                dataFromArray.Group       = array[3];
                dataFromArray.Priority    = Byte.Parse(array[4]);
                dataFromArray.DateandTimeOfNotification = DateTime.Parse(array[5]);
                dataFromArray.Status         = Boolean.Parse(array[6]);
                dataFromArray.IsNotification = Boolean.Parse(array[7]);
                dataFromArray.Sound          = array[8];

                result.Add(dataFromArray);
            }

            reader.Close();
            stream.Close();

            return(result);
        }
Beispiel #6
0
        public void WriteToFileEnrypted(DataForNotification dataForNotification)
        {
            FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);

            DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();

            cryptic.Key = ASCIIEncoding.ASCII.GetBytes("0205201800058");
            cryptic.IV  = ASCIIEncoding.ASCII.GetBytes("020520180");

            CryptoStream crStream = new CryptoStream(stream,
                                                     cryptic.CreateEncryptor(), CryptoStreamMode.Write);

            byte[] data = ASCIIEncoding.ASCII.GetBytes(dataForNotification.Name + "/"
                                                       + dataForNotification.DateAndTime + "/"
                                                       + dataForNotification.Comment + "/"
                                                       + dataForNotification.Group + "/"
                                                       + dataForNotification.Priority);

            crStream.Write(data, 0, data.Length);

            crStream.Close();
            stream.Close();
        }
Beispiel #7
0
 public NotificationForm(DataForNotification dataForNotifications)
 {
     _dataForNotification = dataForNotifications;
     InitializeComponent();
 }