Ejemplo n.º 1
0
        private void CreateTweet(object sender, EventArgs e)
        {
            try
            {
                var    window     = sender as TweetWindow;
                string tweet      = window.TweetText.Trim();
                var    parameters = Tweetinvi.Tweet.CreatePublishTweetOptionalParameters();

                if (window.FileName != "")
                {
                    try
                    {
                        // Load picture
                        byte[] file  = File.ReadAllBytes(window.FileName);
                        var    image = Upload.UploadImage(file);
                        parameters.Medias = new List <Tweetinvi.Core.Interfaces.DTO.IMedia> {
                            image
                        };
                    }
                    catch (Exception)
                    {
                        ErrorDialog errorDialog = new ErrorDialog("Unable load the file");
                        return;
                    }
                }

                Tweetinvi.Tweet.PublishTweet(tweet, parameters);
                SuccessDialog successDialog = new SuccessDialog("Your tweet was sent successfully.");
            }
            catch (Exception)
            {
                ErrorDialog errorDialog = new ErrorDialog("Unable to send tweet.");
            }
        }
Ejemplo n.º 2
0
        private void GoNext()
        {
            _playerManager.SavePlayerInfo(selectedWeapon, selectedSkin);
            Window window = new SuccessDialog("Успіх!");

            window.Show();
        }
Ejemplo n.º 3
0
        private void Window_btnSaveClicked(object sender, EventArgs e)
        {
            // Load selected timeline
            Tweets tweets = (from i in TimeLines where i.Name == Window.SelectedTimeLine select i).First().GetTweets();

            // Load se;ected parser
            Parser.Parser parser = (from i in Parsers where i.Name == Window.SelectedParser select i).First();

            if (parser == null)
            {
                new ErrorDialog("There is no parser with this name");
                return;
            }

            if (tweets == null)
            {
                new ErrorDialog("There was a problem loading the list");
                return;
            }

            try
            {
                string path;
                if (Window.Path.EndsWith(parser.Extension))
                {
                    path = Window.Path;
                }
                else
                {
                    // Add proper extension
                    path = String.Concat(Window.Path, parser.Extension);
                }

                FileManager.FileWriter fileManager = new FileManager.FileWriter(path);
                parser.Save(tweets, fileManager.Stream);
                fileManager.Dispose();

                SuccessDialog successDialog = new SuccessDialog("The backup was successfully performed");
                Window.Hide();
            }
            catch (Exception ex)
            {
                new ErrorDialog(ex.Message);
            }
        }
Ejemplo n.º 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtTitle.Text.Trim() != "")
     {
         if (strFilePath == "")
         {
             if (ImageByteArray.Length != 0)
             {
                 ImageByteArray = new byte[] { }
             }
             ;
         }
         else
         {
             Image        temp = new Bitmap(strFilePath);
             MemoryStream strm = new MemoryStream();
             temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
             ImageByteArray = strm.ToArray();
         }
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sqlCmd = new SqlCommand("ImageAddOrEdit", sqlcon)
         {
             CommandType = CommandType.StoredProcedure
         };
         sqlCmd.Parameters.Add("@ImageID", ImageID);
         sqlCmd.Parameters.Add("@Title", txtTitle.Text.Trim());
         sqlCmd.Parameters.Add("@Image", ImageByteArray);
         sqlCmd.ExecuteNonQuery();
         sqlcon.Close();
         SuccessDialog f = new SuccessDialog();
         Clear();
         RefreshImageGrid();
     }
     //else
     //{
     //    MessageBox.Show("Please enter image title");
     //}
 }
Ejemplo n.º 5
0
        private void ShowSuccessDialog(string message)
        {
            var success = new SuccessDialog(message);

            success.ShowAsync().GetAwaiter();
        }
Ejemplo n.º 6
0
        private void TaskCompletion(BioSeqTask task, string taskName, string successMsg)
        {
            // Called by the user from the Push button when task status is Ready.
            Cursor.Current = Cursors.WaitCursor;

            TimeSpan duration = task.TaskComplete - task.TaskTime;

            string db      = string.IsNullOrEmpty(task.TaskDB) ? string.Empty : "Sequence database: " + task.TaskDB;
            string memo    = string.IsNullOrEmpty(task.TaskMemo) ? string.Empty : "Memo: " + task.TaskMemo;
            string subject = "Task completed: " + taskName + " at " + task.TaskComplete.ToString("MMM d, yyyy HH:mm") + " after " +
                             duration.TotalMinutes.ToString("#.0") + " minutes." + Environment.NewLine + (db + " " + Environment.NewLine + memo).Trim();
            string message = subject + Environment.NewLine + AppConfigHelper.LastCommand + Environment.NewLine;

            subject = subject.Replace(Environment.NewLine, "  ");
            List <string> attachments = new List <string>();
            string        output      = task.StandardOutput + Environment.NewLine + task.LastError;

            message += "Standard output: " + output + Environment.NewLine;

            // Read and delete the output file from the command.
            string linuxCapture = string.Empty;
            string filename     = AppConfigHelper.NormalizePathToWindows(AppConfigHelper.LinuxHomeDirectory + "/output" + task.TaskID);

            if (DirectoryHelper.FileExists("[S]" + filename))
            {
                linuxCapture = BioSeqDBModel.Instance.ReadAllText(filename, AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // We know it is on the server.
                int residual = 6000;
                if (linuxCapture.Length > residual)
                {
                    // Write the whole thing to a log file that can be opened separately.
                    string tasklog = "C:\\Temp\\TaskLog.txt";
                    File.WriteAllText(tasklog, linuxCapture);
                    linuxCapture = "[Full text truncated; see saved log file " + tasklog + "]" + Environment.NewLine + Environment.NewLine +
                                   linuxCapture.Substring(linuxCapture.Length - residual);         // Display the last residual chars.
                    Process.Start(tasklog);
                    attachments.Add(tasklog);
                }
            }

            SuccessDialog.MainInstruction = successMsg;
            SuccessDialog.Content         = output;
            if (linuxCapture.Length > 0 && output.IndexOf(linuxCapture) == -1)
            {
                SuccessDialog.Content += (output.Length > 0 ? Environment.NewLine : string.Empty) + linuxCapture;
            }

            if (task.LastExitCode != 0 && task.LastExitCode != -999) // We handle -999 elsewhere (lost task status after completion, likely because BioSeqDB was restarted).
            {
                SuccessDialog.WindowTitle     = "ERROR";
                SuccessDialog.MainInstruction = taskName + " completed with error code " + task.LastExitCode.ToString() + ".";
                message += SuccessDialog.MainInstruction + Environment.NewLine;
            }
            SuccessDialog.ShowDialog(this);

            RemoveTask(false);                     // Do this as soon as possible to reflect the user's closing of the dialog.
            StatusChangeEvent?.Invoke(this, null); // Notify parent we have a potential status change.

            message += linuxCapture;
            User user = AppConfigHelper.seqdbConfigGlobal.Users[AppConfigHelper.LoggedOnUser];

            if (user.EmailNotifications)
            {
                string s1 = Emailer.SendEmail(AppConfigHelper.LoggedOnUser + "@mail.usask.ca", "BioSeqDB User: "******" " + subject, message, attachments, null);
                if (!string.IsNullOrEmpty(s1))
                {
                    Logger.Log.Debug("Email error: " + s1);
                    //MessageBox.Show(s1, "ERROR", MessageBoxButtons.OK);
                }
            }

            if (File.Exists(filename)) // Must do after email since it might be attached.
            {
                File.Delete(filename);
            }
            Cursor.Current = Cursors.Default;
        }