Exemplo n.º 1
0
 private void SetDefaultSettings()
 {
     DestinationEmail  = "*****@*****.**";
     MaxFileSize       = 2048;
     StartInNormalMode = true;
     FilesOperations.Write(FullPath, Crypter.Encrypt(FileContent), false);
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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();
            }
        }