Example #1
0
 public ServerCommandForm(Authority rcAuthority, IEnumerable <KeyValuePair <RCProcess, RCClient> > commandBridges)
 {
     this.InitializeComponent();
     this.groupBoxCommand.Text = LocalizeText.Get(519);
     this.groupBoxServer.Text  = LocalizeText.Get(518);
     this.groupBoxArgList.Text = LocalizeText.Get(485);
     this.checkSchedule.Text   = LocalizeText.Get(520);
     this.buttonCancel.Text    = LocalizeText.Get(12);
     this.buttonOK.Text        = LocalizeText.Get(244);
     this.textBox1.Text        = LocalizeText.Get(522);
     this.Text            = LocalizeText.Get(521);
     this.commandBridges  = new Dictionary <int, RCProcess>();
     this.schedulesByTime = new Dictionary <string, Dictionary <string, RCProcessScheduler> >();
     this.schedulesOther  = new Dictionary <string, Dictionary <string, RCProcessScheduler> >();
     this.commandDict     = new Dictionary <string, HashSet <ServerCommandForm.ServerGroupItem> >();
     this.controlArgs     = new List <Control>();
     this.clientAuthority = rcAuthority;
     foreach (KeyValuePair <RCProcess, RCClient> keyValuePair in commandBridges)
     {
         string key = this.MakeKey(keyValuePair.Value.ID, keyValuePair.Key.Name);
         this.commandBridges.Add(keyValuePair.Value.ID, keyValuePair.Key.Clone());
         this.schedulesOther.Add(key, new Dictionary <string, RCProcessScheduler>());
         this.schedulesByTime.Add(key, new Dictionary <string, RCProcessScheduler>());
         if (keyValuePair.Key.State == RCProcess.ProcessState.On)
         {
             IEnumerable <string> commandBridgeServer = RCUserHandler.GetCommandBridgeServer(keyValuePair.Key);
             foreach (RCProcess.CustomCommandParser customCommandParser in RCProcess.CustomCommandParser.GetFromRawString(keyValuePair.Key.CustomCommandString))
             {
                 HashSet <ServerCommandForm.ServerGroupItem> hashSet;
                 if (this.commandDict.ContainsKey(customCommandParser.RawCommand))
                 {
                     hashSet = this.commandDict[customCommandParser.RawCommand];
                 }
                 else
                 {
                     this.listBoxCommand.Items.Add(new CommandForm.CommandItem(customCommandParser));
                     hashSet = new HashSet <ServerCommandForm.ServerGroupItem>();
                     this.commandDict.Add(customCommandParser.RawCommand, hashSet);
                 }
                 foreach (string serverGroup in commandBridgeServer)
                 {
                     ServerCommandForm.ServerGroupItem item = new ServerCommandForm.ServerGroupItem(serverGroup, keyValuePair.Key.Name, keyValuePair.Value.ID);
                     if (!hashSet.Contains(item))
                     {
                         hashSet.Add(item);
                     }
                 }
             }
         }
         foreach (RCProcessScheduler rcprocessScheduler in keyValuePair.Key.Schedules)
         {
             if (rcprocessScheduler.ExeType == RCProcessScheduler.EExeType.StdInput && rcprocessScheduler.ScheduleType == RCProcessScheduler.EScheduleType.Once)
             {
                 this.AddSchedule(key, rcprocessScheduler.ScheduleTime, rcprocessScheduler.Name, rcprocessScheduler.Command);
             }
             else
             {
                 this.schedulesOther[key].Add(rcprocessScheduler.Name, rcprocessScheduler);
             }
         }
     }
 }
Example #2
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     CommandForm.CommandItem commandItem = this.listBoxCommand.SelectedItem as CommandForm.CommandItem;
     if (!this.ScheduleModified || this.checkSchedule.Checked)
     {
         if (commandItem == null)
         {
             Utility.ShowErrorMessage(LocalizeText.Get(247));
             return;
         }
         if (this.checkedListBoxServer.CheckedItems.Count == 0)
         {
             Utility.ShowErrorMessage(LocalizeText.Get(535));
             return;
         }
         if (this.clientAuthority == Authority.UserKicker)
         {
             string text = commandItem.ToString();
             if (!text.Equals("Kick Character") && !text.Equals("Kick Account"))
             {
                 Utility.ShowErrorMessage(LocalizeText.Get(229));
                 return;
             }
         }
     }
     this.Command = new List <KeyValuePair <int, StandardInProcessMessage> >();
     if (commandItem.Command.Command.Equals("announce", StringComparison.CurrentCultureIgnoreCase) && MessageBox.Show(string.Format("\"{0}\"\r\n{1}", this.GetArgument(1, commandItem.Command.Arguments.ElementAt(1)), LocalizeText.Get(546)), "Announce to client Check", MessageBoxButtons.YesNo) != DialogResult.Yes)
     {
         return;
     }
     foreach (object obj in this.checkedListBoxServer.CheckedItems)
     {
         ServerCommandForm.ServerGroupItem serverGroupItem = (ServerCommandForm.ServerGroupItem)obj;
         this.currentServer = serverGroupItem.ServerGroup;
         string text2 = base.GetFromArgPanel(commandItem.Command);
         if (text2 == null)
         {
             return;
         }
         if (commandItem.Command.Command.Equals("console", StringComparison.CurrentCultureIgnoreCase) && text2.StartsWith("event reg ", StringComparison.CurrentCultureIgnoreCase))
         {
             text2 = text2.Substring(0, text2.Length - 1);
             text2 = text2 + " username " + MainForm.Instance.GetCurrentUserID() + "'";
         }
         if (this.checkSchedule.Checked)
         {
             string name = string.Format("{0} {1}", serverGroupItem.ServerGroup, commandItem.ToString());
             string key  = this.MakeKey(serverGroupItem.ID, serverGroupItem.Process);
             this.AddSchedule(key, this.dateTimePicker.Value, name, text2);
             this.ScheduleModified = true;
         }
         else
         {
             this.Command.Add(new KeyValuePair <int, StandardInProcessMessage>(serverGroupItem.ID, new StandardInProcessMessage(serverGroupItem.Process, text2)));
         }
     }
     if (!this.checkSchedule.Checked)
     {
         if (this.ScheduleModified)
         {
             foreach (KeyValuePair <int, RCProcess> keyValuePair in this.commandBridges)
             {
                 string key2 = this.MakeKey(keyValuePair.Key, keyValuePair.Value.Name);
                 keyValuePair.Value.Schedules.Clear();
                 foreach (RCProcessScheduler item in this.schedulesByTime[key2].Values)
                 {
                     keyValuePair.Value.Schedules.Add(item);
                 }
                 foreach (RCProcessScheduler item2 in this.schedulesOther[key2].Values)
                 {
                     keyValuePair.Value.Schedules.Add(item2);
                 }
             }
         }
         base.DialogResult = DialogResult.OK;
         base.Close();
         return;
     }
     this.checkSchedule.Checked = false;
     this.checkedListBoxServer.ClearSelected();
     this.listBoxCommand.ClearSelected();
 }