public MainSettingsDialog()
        {
            InitializeComponent();

            // create dictionary of application process names
            processNameDictionary = new Dictionary<string, string>();
            processNameDictionary.Add("Task Manager", "taskmgr");
            processNameDictionary.Add("AIM", "aim6");
            processNameDictionary.Add("Firefox", "firefox");
            processNameDictionary.Add("Google Chrome", "chrome");
            processNameDictionary.Add("Google Talk", "googletalk");
            processNameDictionary.Add("Internet Explorer", "iexplore");
            processNameDictionary.Add("Microsoft Outlook", "OUTLOOK");
            processNameDictionary.Add("MSN Messenger", "msmsgs");
            processNameDictionary.Add("Safari", "Safari");
            processNameDictionary.Add("Thunderbird", "thunderbird");

            // initialize PressedOkay to be false
            _pressedOkay = false;

            // instantiate settings variables
            _restrictLevel = new RestrictionLevel();
            _timeLimit = new TimeLimit();
            _unblockEvent = new UnblockEvent();

            // initialize timeLimMins, password, and the hacker settings to default values
            _timeLimMins = 0;
            _password = string.Empty;

            // instantiate a blockedApps List
            blockedApps = new List<string>();
        }
Exemple #2
0
 public DataType([NotNull] string name, RestrictionLevel restrictionLevel = RestrictionLevel.WEAK, CobolLanguageLevel cobolLanguageLevel = CobolLanguageLevel.Cobol85)
 {
     Name = name;
     if (name == null)
     {
         throw new ArgumentNullException();
     }
     this.RestrictionLevel   = restrictionLevel;
     this.CobolLanguageLevel = cobolLanguageLevel;
 }
Exemple #3
0
 public static DataType CreateCustom(string name, RestrictionLevel restrictionLevel = RestrictionLevel.STRONG, CobolLanguageLevel cobolLanguageLevel = CobolLanguageLevel.Cobol2002)
 {
     foreach (var builtin in BuiltInCustomTypes)
     {
         if (builtin.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
         {
             return(builtin);
         }
     }
     return(new DataType(name, restrictionLevel, cobolLanguageLevel));
 }
        private void btnOkay_Click(object sender, EventArgs e)
        {
            // event handler for Okay button

            // proceed only if there are no input errors

            // if inputted time is zero and want to set time limit, display error
            if (limitTimeRadioButton.Checked == true &&
                limitTimeHrsNumericUpDown.Value == 0 && limitTimeMinsNumericUpDown.Value == 0)
            {
                ErrorZeroTime errTime = new ErrorZeroTime();
                errTime.ShowDialog();
            }

            // if passwords do not match, display error
            else if (unblockPswdRadioButton.Checked == true &&
                     string.Compare(pswd1TextBox.Text.ToString(), pswd2TextBox.Text.ToString()) != 0)
            {
                ErrorPswdMismatch errPswd = new ErrorPswdMismatch();
                errPswd.ShowDialog();
            }

            // if want to limit applications but none are selected, display error
            else if (levelAppsRadioButton.Checked == true &&
                     aimCheckBox.Checked == false &&
                     chromeCheckBox.Checked == false &&
                     firefoxCheckBox.Checked == false &&
                     iexplorerCheckBox.Checked == false &&
                     msnCheckBox.Checked == false &&
                     gtalkCheckBox.Checked == false &&
                     outlookCheckBox.Checked == false &&
                     safariCheckBox.Checked == false &&
                     thunderbirdCheckBox.Checked == false)
            {
                ErrorZeroApplications errNoApps = new ErrorZeroApplications();
                errNoApps.ShowDialog();
            }

            else
            {
                // indicate that options were submitted
                _pressedOkay = true;

                // instantiate variables in which to store options
                _restrictLevel = new RestrictionLevel();
                _timeLimit = new TimeLimit();
                _unblockEvent = new UnblockEvent();

                // initialize timeLim and password to default values
                _timeLimMins = 0;
                _password = string.Empty;

                // get restriction level option from radio buttons, and add to blockedApps if relevant
                if (levelAppsRadioButton.Checked == true)
                {
                    _restrictLevel = RestrictionLevel.Applications;

                    // add applications one by one to blockedApps, according to check boxes
                    if (aimCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["AIM"]);
                    if (firefoxCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Firefox"]);
                    if (chromeCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Google Chrome"]);
                    if (gtalkCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Google Talk"]);
                    if (outlookCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Microsoft Outlook"]);
                    if (msnCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["MSN Messenger"]);
                    if (safariCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Safari"]);
                    if (thunderbirdCheckBox.Checked == true)
                        blockedApps.Add(processNameDictionary["Thunderbird"]);
                }

                // get time limit option from radio buttons, and set timeLim if relevant
                if (limitTimeRadioButton.Checked == true)
                {
                    _timeLimit = TimeLimit.Time;
                    _timeLimMins = (uint) (limitTimeHrsNumericUpDown.Value * 60 + limitTimeMinsNumericUpDown.Value);
                }
                else if (limitEventRadioButton.Checked == true)
                {
                    _timeLimit = TimeLimit.Event;
                }

                // get unblock event option from radio buttons, and set password if relevant
                if (unblockBtnRadioButton.Checked == true)
                {
                    _unblockEvent = UnblockEvent.Button;
                }
                else if (unblockMathRadioButton.Checked == true)
                {
                    _unblockEvent = UnblockEvent.Math;
                }
                else if (unblockPswdRadioButton.Checked == true)
                {
                    _unblockEvent = UnblockEvent.Password;
                    _password = pswd1TextBox.Text.ToString();
                }
                else if (unblockNeverRadioButton.Checked == true)
                {
                    _unblockEvent = UnblockEvent.Never;
                }

                // copy blockedApps List to an AppArrayIndexer
                localAppsArray = new string[blockedApps.Count];
                blockedApps.CopyTo(localAppsArray);
                _blockedAppsIndexer = new AppArrayIndexer(this);

                Hide();
            }
        }
 /// <summary>
 /// 远程执行一个程序
 /// </summary>
 /// <param name="command">若为系统程序,直接填入程序名,如g++,若为某File,则在程序名前加"./",如./code</param>
 /// <param name="argv">程序的命令行参数,如new[]{"-o","code","code.cpp"}</param>
 /// <param name="memoryLimit">运行时内存限制,单位为字节。-1为不限制。</param>
 /// <param name="timeLimit">运行时用户态时间限制,单位为毫秒。-1为不限制。</param>
 /// <param name="outputLimit">程序输出大小限制,单位为字节。-1为不限制。</param>
 /// <param name="restriction">程序限制级别</param>
 /// <param name="inputBlob">输入文件的Blob名称,null为没有输出文件。</param>
 /// <returns>程序运行结果</returns>
 public ExecuteResult Execute(string command, IEnumerable<string> argv, long memoryLimit, int timeLimit, long outputLimit, RestrictionLevel restriction, string inputBlob)
 {
     session.Send(new Exec()
     {
         ArgumentCount = argv.Count(),
         Arguments = argv,
         Command = command,
         InputBlob = inputBlob ?? "",
         MemoryLimit = memoryLimit,
         OutputLimit = outputLimit,
         Restriction = restriction,
         TimeLimit = timeLimit
     }.ToMessage());
     var reply = session.Receive(MessageType.ExecuteReply);
     return new ExecuteResult(reply);
 }
 public void SetRestrictionLevel(Child child, RestrictionLevel restrictionLevel)
 {
     SetRestrictionLevelInternal(child, restrictionLevel);
 }
 protected static void SetRestrictionLevelInternal(Person person, RestrictionLevel restrictionLevel)
 {
     person.RestrictionLevel = restrictionLevel;
 }
 public RestrictionLevelAttribute(RestrictionLevel restrictionLevel)
 {
     RestrictionLevel = restrictionLevel;
 }