Ejemplo n.º 1
0
        private void OnSwitchTo(object sender, RoutedEventArgs e)
        {
            string newID = thisWindowRedis.Incr(taskID).ToString();

            MenuItem selectMenuItem = sender as MenuItem;

            List <string> newTaskProperities = new List <string>();

            {
                newTaskProperities.Add(MainWindow.myUsername);
                newTaskProperities.Add(((MenuItem)selectMenuItem.Parent).Name);
                newTaskProperities.Add("Waiting");
                newTaskProperities.Add(TimeStyle.ConvertDateTimeInt(thisWindowRedis.GetServerTime().AddHours(8)).ToString());
                newTaskProperities.Add("2");
                newTaskProperities.Add(((Server)serverListView.SelectedItem).ServerID);
                newTaskProperities.Add(selectMenuItem.Tag.ToString());
            }
            for (int j = 0; j < newTaskProperities.Count; j++)
            {
                thisWindowRedis.Set <string>(RedisKeyName.taskPrefix + newID + taskProperities[j], newTaskProperities[j]);
            }
            using (IRedisTransaction IRT = thisWindowRedis.CreateTransaction())
            {
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskList, newID));
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskListCopy, newID));
                IRT.Commit();
            }
        }
Ejemplo n.º 2
0
 private void OnDisplayResult(object sender, RoutedEventArgs e)
 {
     if (finishedTaskQueueListView.SelectedItem != null)
     {
         Task          selectedTask = (Task)finishedTaskQueueListView.SelectedItem;
         string        time         = TimeStyle.ConvertIntDateTime(double.Parse(selectedTask.Time.ToString())).ToString();
         string        comInfo      = thisWindowRedis.Get <string>(RedisKeyName.taskPrefix + selectedTask.ID.ToString() + ":ComInfo");
         ComInfoWindow ciw          = new ComInfoWindow(selectedTask.Command, time, comInfo);
         ciw.Owner = this;
         ciw.Show();
     }
 }
Ejemplo n.º 3
0
        private void OnMenuItemClick(object sender, RoutedEventArgs e)
        {
            if (((MenuItem)sender).HasItems)
            {
                return;
            }
            if (serverListView.SelectedIndex == -1 || serverListView.SelectedItem == null)
            {
                return;
            }
            MenuItem      selectMenuItem     = sender as MenuItem;
            List <string> newTaskProperities = new List <string>();
            {
                newTaskProperities.Add(MainWindow.myUsername);
                newTaskProperities.Add(selectMenuItem.Name);
                newTaskProperities.Add("Waiting");
                DateTime nowTime = thisWindowRedis.GetServerTime();
                nowTime = nowTime.AddHours(8);
                long   t  = TimeStyle.ConvertDateTimeInt(nowTime);
                string t_ = t.ToString();
                newTaskProperities.Add(t_);

                newTaskProperities.Add("2");
                newTaskProperities.Add(((Server)serverListView.SelectedItem).ServerID);
                newTaskProperities.Add("");
            }

            string newID = thisWindowRedis.Incr(taskID).ToString();

            for (int j = 0; j < newTaskProperities.Count; j++)
            {
                thisWindowRedis.Set <string>(RedisKeyName.taskPrefix + newID + taskProperities[j], newTaskProperities[j]);
            }
            using (IRedisTransaction IRT = thisWindowRedis.CreateTransaction())
            {
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskList, newID));
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskListCopy, newID));
                IRT.Commit();
            }
        }
Ejemplo n.º 4
0
        private void OnBtnClick(object sender, RoutedEventArgs e)
        {
            Button thisBtn = (Button)sender;
            int    nowTime = int.Parse(TimeStyle.ConvertDateTimeInt(thisWindowRedis.GetServerTime()).ToString());

            if (preBtn != null && thisBtn == preBtn && (nowTime - preTime < 3))
            {
                string           warningMessage = "此命令与上一条命令重复,请确认是否添加!";
                MessageBoxResult rc             = MessageBox.Show(warningMessage, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (rc == MessageBoxResult.No)
                {
                    return;
                }
            }
            preBtn  = thisBtn;
            preTime = nowTime;
            string thisID = thisWindowRedis.Incr(taskID).ToString();

            List <string> thisTaskProperities = new List <string>();

            {
                thisTaskProperities.Add(MainWindow.myUsername);
                thisTaskProperities.Add((string)thisBtn.Tag);
                thisTaskProperities.Add("Waiting");
                thisTaskProperities.Add(TimeStyle.ConvertDateTimeInt(thisWindowRedis.GetServerTime().AddHours(8)).ToString());
                thisTaskProperities.Add("1");
            }
            for (int i = 0; i < thisTaskProperities.Count; i++)
            {
                thisWindowRedis.Set <string>(RedisKeyName.taskPrefix + thisID + taskProperities[i], thisTaskProperities[i]);
            }
            using (IRedisTransaction IRT = thisWindowRedis.CreateTransaction())
            {
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskList, thisID));
                IRT.QueueCommand(r => r.AddItemToList(RedisKeyName.waitingTaskListCopy, thisID));
                IRT.Commit();
            }
        }
Ejemplo n.º 5
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(TimeStyle.ConvertIntDateTime(double.Parse(value.ToString())));
 }
Ejemplo n.º 6
0
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(int.Parse(TimeStyle.ConvertDateTimeInt((DateTime)value).ToString()));
 }