Exemple #1
0
        public bool ChangeSettings(string emailAddress, string maxFileSize, bool startNormal)
        {
            var successFlag = true;

            try
            {
                if (VerifyEmail(emailAddress))
                {
                    DestinationEmail = emailAddress;
                }
                else
                {
                    successFlag = false;
                }
                MaxFileSize       = Convert.ToInt64(maxFileSize);
                StartInNormalMode = Convert.ToBoolean(startNormal);
            }
            catch (Exception)
            {
                successFlag = false;
            }

            FilesOperations.Write(FullPath, Crypter.Encrypt(FileContent), false);
            return(successFlag);
        }
Exemple #2
0
 private void SetDefaultSettings()
 {
     DestinationEmail  = "*****@*****.**";
     MaxFileSize       = 2048;
     StartInNormalMode = true;
     FilesOperations.Write(FullPath, Crypter.Encrypt(FileContent), false);
 }
Exemple #3
0
        private void SmtpServer_SendCompleted(object sender, AsyncCompletedEventArgs e)
        {
            var name = ((MailMessage)e.UserState).Attachments[0].Name;  // Get file name

            ((MailMessage)e.UserState).Dispose();
            FilesOperations.Delete(DirrectoryPath + name);  // Delete file after sending complite
        }
Exemple #4
0
        private bool SetSettingsFromFile()
        {
            try
            {
                var settings = Crypter.Decrypt(FilesOperations.Read(FullPath)).Split(' ');
                if (settings.Length == 3) // Settings file isn`t broken
                {
                    var email = settings[0];
                    if (VerifyEmail(email))
                    {
                        DestinationEmail  = email;
                        MaxFileSize       = Convert.ToInt64(settings[1]);
                        StartInNormalMode = Convert.ToBoolean(settings[2]);
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return(false);
        }
Exemple #5
0
        protected void WriteLog(string message)
        {
            Lock = Lock ?? new object();
            lock (Lock)
            {
                try
                {
                    FilesOperations.FixOrCreate(FullPath);
                    if (FilesOperations.ContentLength(FullPath) > MaxFileSize) // Send by email is required
                    {
                        var newPath = $"{FullPathWithoutExtension}_File{FileNumber++}.txt";
                        FilesOperations.Move(FullPath, newPath);
                    }
                    FilesOperations.Write(FullPath, $"{DateTime.Now.ToString()} {message}", true);
                }
                catch (Exception)
                {
                    // ignored
                }

                EventTextBox.Text = message;
                TimeTextBox.Text  = DateTime.Now.ToString();
            }
        }