You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(128) |
Jun
(97) |
Jul
(13) |
Aug
(40) |
Sep
(50) |
Oct
(27) |
Nov
(7) |
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(18) |
Feb
(47) |
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(14) |
Oct
(22) |
Nov
|
Dec
|
From: <br...@us...> - 2008-12-08 11:06:29
|
Revision: 438 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=438&view=rev Author: brus07 Date: 2008-12-08 11:06:24 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Fixed bug with multiple times add to queue of submits. Added new log SystemMessage in SocketServerGate. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-12-07 21:57:19 UTC (rev 437) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-12-08 11:06:24 UTC (rev 438) @@ -37,11 +37,8 @@ if (message.IsType("TestingSubmit") == true) { Submit submit = Submit.CreateFromXml(message.Message); - if (dataContainer.Add(submit) == true) - { - OnLogMessage("Send", submit.id + " to " + clientIndex); - base.DataSender(message, clientIndex); - } + OnLogMessage("Send", submit.id + " to " + clientIndex); + base.DataSender(message, clientIndex); return; } @@ -71,11 +68,16 @@ for (int index = 0; index < submitList.Items.Length; index++) { - if (dataContainer.Contains(submitList.Items[index]) == false) + if (dataContainer.Add(submitList.Items[index]) == true) { SystemMessage sysMes = new SystemMessage(submitList.Items[index].ToString(), "TestingSubmit"); + OnLogMessage("SystemSend", submitList.Items[index].id + " to Pool"); pool.Send(sysMes); } + else + { + OnLogMessage("SystemReceive", submitList.Items[index].id + "is in queue"); + } } return true; } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs 2008-12-07 21:57:19 UTC (rev 437) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs 2008-12-08 11:06:24 UTC (rev 438) @@ -2,13 +2,14 @@ using AcmContester.Library.LibraryExtention; using System.Collections.Generic; using System.Threading; +using AcmContester.Library.LibraryExtention.Data; namespace AcmContester.Plugins.MediatorPlugins.SocketServerGatePlugin { class WorkingPool { - internal delegate bool SebdDataDelegate(SystemMessage s); - internal event SebdDataDelegate onSendData; + internal delegate bool SendDataDelegate(SystemMessage s); + internal event SendDataDelegate onSendData; private bool OnSendData(SystemMessage sysMes) { @@ -18,7 +19,7 @@ return false; } - private Dictionary<SystemMessage, object> poolWork = new Dictionary<SystemMessage, object>(); + private Dictionary<int, SystemMessage> poolWork = new Dictionary<int, SystemMessage>(); private bool poolWorking = false; private void runPool() @@ -33,12 +34,13 @@ { if (poolWork.Count == 0) break; - foreach (SystemMessage sysMes in poolWork.Keys) + foreach (int key in poolWork.Keys) { + SystemMessage sysMes = poolWork[key]; //TODO: potribno zrobyty, shob pry posylci "poolWork" ne buv zalokanyj if (OnSendData(sysMes) == true) { - poolWork.Remove(sysMes); + poolWork.Remove(key); break; } } @@ -63,7 +65,13 @@ { lock (poolWork) { - poolWork.Add(sysMes, null); + if (sysMes.IsType("TestingSubmit")) + { + //TODO: \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE1\xF3\xE4\xE5 \xF6\xE5 \xE7\xE2\xB3\xE4\xF1\xE8 \xE7\xE0\xE1\xF0\xE0\xF2\xE8 + Submit submit = Submit.CreateFromXml(sysMes.Message); + if (poolWork.ContainsKey(submit.id) == false) + poolWork.Add(submit.id, sysMes); + } } startPool(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pan...@us...> - 2008-12-07 22:02:07
|
Revision: 437 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=437&view=rev Author: panzaboi Date: 2008-12-07 21:57:19 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Archive: Added results, moved form info into the form class User: Created register and activate actions with email activation Tester: Added methods to communicate with tester, send and receive data Mail: Added setBodyTemplate to add bodyHtml as rendered file DB: Updated Skeleton. Modified Paths: -------------- website/application/modules/acm/controllers/ArchieveController.php website/application/modules/acm/controllers/IndexController.php website/application/modules/acm/models/Archieve.php website/application/modules/acm/models/Form/Login.php website/application/modules/acm/models/Form/Submit.php website/config/config.ini website/library/Application.php website/library/Ostacium/Controller/Action.php website/library/Ostacium/Controller/Plugin/ErrorHandler.php website/library/Ostacium/Controller/Router/Route/Language.php Added Paths: ----------- website/application/modules/acm/controllers/TesterController.php website/application/modules/acm/controllers/UserController.php website/application/modules/acm/models/Form/Register.php website/application/modules/acm/models/Tester.php website/application/modules/acm/models/User.php website/application/modules/acm/views/helpers/State.php website/application/modules/acm/views/scripts/archieve/result.phtml website/application/modules/acm/views/scripts/archieve/results.phtml website/application/modules/acm/views/scripts/emails/ website/application/modules/acm/views/scripts/emails/register.phtml website/application/modules/acm/views/scripts/tester/ website/application/modules/acm/views/scripts/tester/entry.phtml website/application/modules/acm/views/scripts/tester/submits.phtml website/application/modules/acm/views/scripts/user/ website/application/modules/acm/views/scripts/user/activated.phtml website/application/modules/acm/views/scripts/user/notactivated.phtml website/application/modules/acm/views/scripts/user/registered.phtml website/library/Ostacium/Mail.php website/library/Ostacium/View/Helper/Date.php website/other/dq.sql website/other/submits/3 website/other/submits/4 website/other/submits/5 Removed Paths: ------------- website/application/modules/acm/views/scripts/archieve/submit.phtml website/other/db.sql Modified: website/application/modules/acm/controllers/ArchieveController.php =================================================================== --- website/application/modules/acm/controllers/ArchieveController.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/controllers/ArchieveController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -22,11 +22,7 @@ { $this->_helper->getHelper('viewRenderer')->setNoRender(true); - $form = $this->_model->getSubmitForm(array( - 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), - 'method' => 'post', - 'name' => 'submitform', - )); + $form = new Form_Submit(); $this->view->dojo()->addOnLoad('function(){ changeEditor('.$form->type->getValue().'); }'); @@ -36,11 +32,7 @@ public function uploadAction() { $this->_helper->getHelper('viewRenderer')->setNoRender(true); - $form = $this->_model->getSubmitForm(array( - 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), - 'method' => 'post', - 'name' => 'submitform', - )); + $form = new Form_Submit(); if (!$this->getRequest()->isPost()) { @@ -80,11 +72,16 @@ if ($values['type'] == 0) { - file_put_contents(Application::getDocRoot().'/other/submits/'.$id.'.cpp', $values['code']); + file_put_contents(Application::getDocRoot().'/other/submits/'.$id, $values['code']); } elseif ($values['type'] == 1) { - rename($form->codefile->getFileName(), Application::getDocRoot().'/other/submits/'.$id.'.cpp'); + rename($form->codefile->getFileName(), Application::getDocRoot().'/other/submits/'.$id); } } + + public function resultsAction() + { + $this->view->submits = $this->_model->getSubmits(); + } } \ No newline at end of file Modified: website/application/modules/acm/controllers/IndexController.php =================================================================== --- website/application/modules/acm/controllers/IndexController.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/controllers/IndexController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -4,12 +4,13 @@ { public function indexAction() { - echo $this->getLoginForm(); + $form = new Form_Login(); + echo $form; } public function loginAction() { - $form = $this->getLoginForm(); + $form = new Form_Login(); if (!$this->getRequest()->isPost()) { @@ -54,13 +55,4 @@ { Zend_Auth::getInstance()->clearIdentity(); } - - protected function getLoginForm() - { - return new Form_Login(array( - 'action' => $this->view->url(array('action' => 'login'), null), - 'method' => 'post', - 'name' => 'loginform', - )); - } } \ No newline at end of file Added: website/application/modules/acm/controllers/TesterController.php =================================================================== --- website/application/modules/acm/controllers/TesterController.php (rev 0) +++ website/application/modules/acm/controllers/TesterController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,36 @@ +<?php + +class Acm_TesterController extends Ostacium_Controller_Action +{ + public function init() + { + parent::init(); + $this->_helper->getHelper('Layout')->disableLayout(); + } + + public function submitsAction() + { + $this->getResponse()->setHeader('Content-Type', 'application/xml'); + $this->view->submits = $this->_model->getSubmits(); + } + + public function resultAction() + { + $id = $this->_getParam('id'); + $data['tests'] = (int)$this->_getParam('tests'); + $data['runtime'] = (int)$this->_getParam('runtime'); + $data['memory'] = (int)$this->_getParam('memory'); + $data['state'] = (int)$this->_getParam('state'); + + if ($data['tests'] && $data['runtime'] && $data['memory'] && $data['state']) + { + echo ($this->_model->updateSubmit($id, $data) ? "success" : "error"); + } + else + { + echo "error"; + } + + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + } +} \ No newline at end of file Added: website/application/modules/acm/controllers/UserController.php =================================================================== --- website/application/modules/acm/controllers/UserController.php (rev 0) +++ website/application/modules/acm/controllers/UserController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,76 @@ +<?php + +class Acm_UserController extends Ostacium_Controller_Action +{ + public function registerAction() + { + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + + $form = new Form_Register(); + + if (!$this->getRequest()->isPost()) + { + echo $form; + return; + } + + if (!$form->isValid($this->getRequest()->getPost())) + { + echo $form; + return; + } + + // check cpassword == password + + $values = $form->getValues(); + $values['ip'] = $this->getRequest()->getIp(); + $code = substr(md5(time()), mt_rand(0, 27), 5); + $result = $this->_model->registerUser($values, $code); + + if (!$result) + { + $form->setDescription($this->view->translate('wrongEmailPwd')); + + echo $form; + } + else + { + $arguments = array('code' => $code, 'fullname' => $values['name'].' '.$values['surname'], 'username' => $values['username']); + $mail = new Ostacium_Mail(); + $mail->setFrom($this->_config->email->from.'@'.$_SERVER["SERVER_NAME"], $this->_config->general->title.' Staff') + ->addTo($values['email'], $values['name'].' '.$values['surname']) + ->setSubject($this->_('registration_email')) + ->setBodyTemplate(array('template' => 'register.phtml', 'arguments' => $arguments)) + ->send(); + + return $this->_redirect($this->view->url(array('action' => 'registered'))); + } + } + + public function registeredAction() + { + + } + + public function activateAction() + { + $username = $this->_getParam('username'); + $code = $this->_getParam('code'); + + $result = $this->_model->activateUser($username, $code); + + if ($result) + { + return $this->render('activated'); + } + else + { + return $this->render('notactivated'); + } + } + + public function viewAction() + { + + } +} \ No newline at end of file Modified: website/application/modules/acm/models/Archieve.php =================================================================== --- website/application/modules/acm/models/Archieve.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Archieve.php 2008-12-07 21:57:19 UTC (rev 437) @@ -8,42 +8,34 @@ return $challenges->getAll(); } + public function getSubmits() + { + $submits = new Submits(); + return $submits->getAll(); + } + public function get($id) { $challenges = new Challenges(); return $challenges->get($id); } - public function getCodeLanguages() - { - return $this->_db->fetchPairs($this->_db->select()->from('code_languages', array('id', 'name'))); - } - public function addSubmit($values) { $data = array( 'username' => Zend_Auth::getInstance()->getStorage()->read()->username, - 'challengeid' => $values['id'], - 'languageid' => $values['languageid'], + 'challengeid' => (int)$values['id'], + 'codelangid' => $values['languageid'], 'firsttest' => $values['firsttest'], 'when' => time() ); + $challenges = new Challenges(); + $challenges->update(array('tries' => 'tries + 1'), $this->_db->quoteInto('id = ?', $data['challengeid'])); + $submits = new Submits(); return $submits->insert($data); } - - public function getSubmitForm($options = array()) - { - $form = new Form_Submit($options); - $user = Zend_Auth::getInstance()->getStorage()->read(); - - $languageid = $form->getElement('languageid'); - $languageid->addMultiOptions($this->getCodeLanguages()); - $languageid->setValue($user->codelangid); - - return $form; - } } class Challenges extends Ostacium_Db_Table @@ -66,4 +58,9 @@ { protected $_name = 'archieve_submits'; protected $_primary = 'id'; + + public function getAll() + { + return $this->select()->from($this)->setIntegrityCheck(false)->joinLeft('code_languages', 'code_languages.id = archieve_submits.codelangid', array('codelang' => 'name'))->order('id DESC')->query()->fetchAll(); + } } \ No newline at end of file Modified: website/application/modules/acm/models/Form/Login.php =================================================================== --- website/application/modules/acm/models/Form/Login.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Form/Login.php 2008-12-07 21:57:19 UTC (rev 437) @@ -16,8 +16,12 @@ public function init() { $translate = Zend_Registry::get('Zend_Translate'); - //$this->addElementPrefixPath('Ostacium_Form', 'Ostacium/Form/'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + $this->setAction($router->assemble(array('action' => 'login'), null)); + $this->setMethod('post'); + $this->setName('loginform'); + $this->addElement('ValidationTextBox', 'username', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim', 'StringToLower'), @@ -29,14 +33,12 @@ 'trim' => true, 'lowercase' => true, 'style' => 'height: 18px; width: 100px;', - 'regExp' => '[\S]{5,50}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 50), + 'regExp' => '[\w]{5,50}', + 'invalidMessage' => sprintf($translate->_('wordErrorBetween'), 5, 50), 'title' => 'Username', 'label' => 'Username:', )); - - $this->addElement('PasswordTextBox', 'password', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), @@ -47,7 +49,7 @@ 'required' => true, 'trim' => true, 'style' => 'height: 18px; width: 100px;', - 'regExp' => '^[a-z0-9]{5,32}$', + 'regExp' => '[\S]{5,32}', 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), 'title' => 'Password', 'label' => 'Password:', Added: website/application/modules/acm/models/Form/Register.php =================================================================== --- website/application/modules/acm/models/Form/Register.php (rev 0) +++ website/application/modules/acm/models/Form/Register.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,314 @@ +<?php + +class Form_Register extends Zend_Dojo_Form +{ + public $elementDecorators = array( + 'DijitElement', + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $simpleDecorators = array( + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $buttonDecorators = array( + 'DijitElement', + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + + $this->setAction($router->assemble(array('action' => 'register'), null)); + $this->setMethod('post'); + $this->setName('registerform'); + + $this->addElement('ValidationTextBox', 'username', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => true, + 'regExp' => '[\w]{5,50}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 50), + 'title' => $translate->_('username'), + 'label' => $translate->_('username').': ', + )); + + $this->addElement('PasswordTextBox', 'password', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 32)), + ), + 'maxlength' => 32, + 'trim' => true, + 'required' => true, + 'regExp' => '[\S]{5,32}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), + 'title' => $translate->_('password'), + 'label' => $translate->_('password').': ', + )); + + $this->addElement('PasswordTextBox', 'cpassword', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 32)), + ), + 'maxlength' => 32, + 'trim' => true, + 'propercase' => true, + 'required' => true, + 'regExp' => '[\S]{5,32}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), + 'title' => $translate->_('confirm_password'), + 'label' => $translate->_('confirm_password').': ', + )); + + $this->addElement('ValidationTextBox', 'email', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + 'EmailAddress', + array('StringLength', false, 1) + ), + 'filters' => array('StringToLower'), + 'trim' => true, + 'lowercase' => true, + 'required' => true, + 'regExp' => '.{1,}', + 'invalidMessage' => $translate->_('errorEmpty'), + 'title' => $translate->_('email'), + 'label' => $translate->_('email').': ', + )); + + $this->addElement('Checkbox', 'hideemail', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('hideemail'), + 'label' => $translate->_('hideemail').': ', + 'multiOptions' => array($translate->_('no'), $translate->_('yes')), + )); + + $this->addElement('ValidationTextBox', 'name', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('name'), + 'label' => $translate->_('name').': ', + )); + + $this->addElement('ValidationTextBox', 'surname', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('surname'), + 'label' => $translate->_('surname').': ', + )); + + $this->addElement('ValidationTextBox', 'study', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('study'), + 'label' => $translate->_('study').': ', + )); + + $this->addElement('DateTextBox', 'birthday', array( + 'decorators' => $this->elementDecorators, + 'required' => false, + 'invalidMessage' => $translate->_('invalidDate'), + 'title' => $translate->_('birthday'), + 'label' => $translate->_('birthday').': ', + 'formatLength' => 'short' + )); + + $this->addElement('ValidationTextBox', 'aim', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('aim'), + 'label' => $translate->_('aim').': ', + )); + + $this->addElement('ValidationTextBox', 'icq', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('icq'), + 'label' => $translate->_('icq').': ', + )); + + $this->addElement('ValidationTextBox', 'msn', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 100)), + ), + 'maxlength' => 100, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,100}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 100), + 'title' => $translate->_('msn'), + 'label' => $translate->_('msn').': ', + )); + + $this->addElement('ValidationTextBox', 'skype', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('skype'), + 'label' => $translate->_('skype').': ', + )); + + $this->addElement('ValidationTextBox', 'yahoo', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('yahoo'), + 'label' => $translate->_('yahoo').': ', + )); + + $this->addElement('ValidationTextBox', 'web', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 100)), + ), + 'maxlength' => 200, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,100}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 100), + 'title' => $translate->_('web'), + 'label' => $translate->_('web').': ', + )); + + $this->addElement('ValidationTextBox', 'topcoder', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('topcoder'), + 'label' => $translate->_('topcoder').': ', + )); + + $this->addElement('ValidationTextBox', 'timus', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('timus'), + 'label' => $translate->_('timus').': ', + )); + + $offset = array(-12 => -12, -11 => -11, -10 => -10, -9 => -9, -8 => -8, -7 => -7, -6 => -6, -5 => -5, -4 => -4, -3 => -3, -2 => -2, -1 => -1, 0 => 0, '+1' => '+1', '+2' => '+2', '+3' => '+3', '+4' => '+4', '+5' => '+5', '+6' => '+6', '+7' => '+7', '+8' => '+8', '+9' => '+9', '+10' => '+10', '+11' => '+11', '+12' => '+12', '+13' => '+13'); + + $this->addElement('FilteringSelect', 'timeoffset', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('timeoffset'), + 'label' => $translate->_('timeoffset').': ', + 'multiOptions' => $offset, + 'value' => 0 + )); + + $this->addElement('FilteringSelect', 'codelangid', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('code_language'), + 'label' => $translate->_('code_language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), + )); + + $this->addElement('FilteringSelect', 'language', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('language'), + 'label' => $translate->_('language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('languages', array('code', 'name'))), + 'value' => Zend_Registry::get('config')->lang->default + )); + + $this->addElement('FilteringSelect', 'tshirtsize', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('tshirtsize'), + 'label' => $translate->_('tshirtsize').': ', + 'multiOptions' => array('S' => 'Small', 'M' => 'Medium', 'L' => 'Large'), + )); + + $this->addElement('SubmitButton', 'registerbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('register'), + )); + } + + public function loadDefaultDecorators() + { + $this->setDecorators(array( + 'FormElements', + 'DijitForm', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + )); + } +} \ No newline at end of file Modified: website/application/modules/acm/models/Form/Submit.php =================================================================== --- website/application/modules/acm/models/Form/Submit.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Form/Submit.php 2008-12-07 21:57:19 UTC (rev 437) @@ -22,8 +22,14 @@ public function init() { $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + $request = Zend_Controller_Front::getInstance()->getRequest(); $this->setAttrib('enctype', 'multipart/form-data'); + $this->setAction($router->assemble(array('action' => 'upload', 'id' => $request->getParam('id')), null)); + $this->setMethod('post'); + $this->setName('submitform'); $this->addElement('FilteringSelect', 'languageid', array( 'decorators' => $this->elementDecorators, @@ -31,6 +37,8 @@ 'style' => 'height: 18px; width: 100px;', 'title' => $translate->_('code_language'), 'label' => $translate->_('code_language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), + 'value' => (Zend_Auth::getInstance()->getStorage()->read()->codelangid) )); $this->addElement('RadioButton', 'type', array( Added: website/application/modules/acm/models/Tester.php =================================================================== --- website/application/modules/acm/models/Tester.php (rev 0) +++ website/application/modules/acm/models/Tester.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,27 @@ +<?php + +class Tester extends Ostacium_Model +{ + public function getSubmits() + { + $submits = new Submits(); + return $submits->getUntested(); + } + + public function updateSubmit($id, $data) + { + $submits = new Submits(); + return $submits->update($data, $this->_db->quoteInto('id = ? AND state = 0', $id)); + } +} + +class Submits extends Ostacium_Db_Table +{ + protected $_name = 'archieve_submits'; + protected $_primary = 'id'; + + public function getUntested() + { + return $this->select()->from($this)->setIntegrityCheck(false)->joinLeft('code_languages', 'code_languages.id = archieve_submits.codelangid', array('codelang' => 'name'))->where('state = 0')->order('id ASC')->query()->fetchAll(); + } +} \ No newline at end of file Added: website/application/modules/acm/models/User.php =================================================================== --- website/application/modules/acm/models/User.php (rev 0) +++ website/application/modules/acm/models/User.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,51 @@ +<?php + +class User extends Ostacium_Model +{ + public function registerUser($data, $code) + { + $data['registered'] = time(); + $data['online'] = $data['registered']; + $data['roleid'] = Zend_Registry::get('config')->general->roleid; + $data['activated'] = $code; + $data['password'] = md5($data['password']); + + $users = new Users(); + $users->insert($data); + + $usersdetails = new UsersDetails(); + $usersdetails->insert($data); + + $usersstats = new UsersStats(); + $usersstats->insert($data); + + return true; + } + + public function activateUser($username, $code) + { + $where = $this->_db->quoteInto('username = ?', $username).' AND activated = ?'; + $where = $this->_db->quoteInto($where, $code); + + $users = new Users(); + return $users->update(array('activated' => null), $where); + } +} + +class Users extends Ostacium_Db_Table +{ + protected $_name = 'users'; + protected $_primaty = 'username'; +} + +class UsersDetails extends Ostacium_Db_Table +{ + protected $_name = 'usersdetails'; + protected $_primaty = 'username'; +} + +class UsersStats extends Ostacium_Db_Table +{ + protected $_name = 'usersstats'; + protected $_primaty = 'username'; +} \ No newline at end of file Added: website/application/modules/acm/views/helpers/State.php =================================================================== --- website/application/modules/acm/views/helpers/State.php (rev 0) +++ website/application/modules/acm/views/helpers/State.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,39 @@ +<?php + +class Acm_View_Helper_State extends Zend_View_Helper_Abstract +{ + public function state($stateid) + { + switch ($stateid) { + case 0: + $return = 'in_que'; + break; + case 1: + $return = 'AC'; + break; + case 2: + $return = 'TL'; + break; + case 3: + $return = 'ML'; + break; + case 4: + $return = 'OL'; + break; + case 5: + $return = 'CE'; + break; + case 6: + $return = 'RE'; + break; + case 7: + $return = 'WA'; + break; + case 8: + $return = 'DF'; + break; + } + + return $this->view->translate($return); + } +} \ No newline at end of file Added: website/application/modules/acm/views/scripts/archieve/result.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/result.phtml (rev 0) +++ website/application/modules/acm/views/scripts/archieve/result.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,10 @@ +<tr> + <td align="center"><?= $this->id ?></td> + <td align="center"><?= $this->date($this->when) ?></td> + <td align="center"><?= $this->username ?></td> + <td align="center"><a href="<?= $this->url( array('action' => 'view', 'id' => $this->challengeid), null) ?>"><?= $this->challengeid ?></a></td> + <td align="center"><?= $this->codelang ?></td> + <td align="center"><?= $this->state($this->state) ?></td> + <td align="center"><?= ($this->tests == 0 ? '-' : $this->tests) ?></td> + <td align="center"><?= ($this->runtime == 0 ? '-' : $this->runtime) ?>/<?= ($this->memory == 0 ? '-' : $this->memory) ?></td> +</tr> \ No newline at end of file Added: website/application/modules/acm/views/scripts/archieve/results.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/results.phtml (rev 0) +++ website/application/modules/acm/views/scripts/archieve/results.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,33 @@ +<table cellspacing="1" cellpadding="8" border="0" width="100%"><tbody><tr><td width="100%" valign="top" class="name"> + +<table cellspacing="0" cellpadding="0" border="0" width="100%"> +<tbody> +<tr> +<td nowrap="" bgcolor="#122a5b" width="*" class="name"> +<font color="#d4d0e2"><b><small>Набiр задач</small></b><small/></font> +</td> +<td nowrap="" bgcolor="#122a5b" align="right" class="name"> +<font color="#d4d0e2"><b><small> 05:26 23 березня 2007 року </small></b><small/></font> +</td> +</tr> +</tbody> +</table> + +<table cellspacing="0" cellpadding="0" border="0" summary="" align="center" width="80%"> +<tbody> +<tr><td bgcolor="#f4f3f8" align="middle" colspan="14"><b>Архів задач</b></td></tr> +<tr bgcolor="#e1e1e1" align="middle"> +<th>ID</th> +<th>Дата</th> +<th>Логін</th> +<th>Задача</th> +<th>Мова</th> +<th>Стан</th> +<th>Тест</th> +<th>Час/Пам'ять</th> +</tr> + +<?= $this->partialLoop('archieve/result.phtml', $this->submits) ?> +</table> + +</td></tr></table> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/emails ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/emails/register.phtml =================================================================== --- website/application/modules/acm/views/scripts/emails/register.phtml (rev 0) +++ website/application/modules/acm/views/scripts/emails/register.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,8 @@ +Dear <?= $this->fullname ?>, +<br /><br /> +Thank you for registering on <?= Zend_Registry::get('config')->general->title ?>. To activate your account please +<a href="<?= $_SERVER["SERVER_NAME"] ?><?= $this->url(array('action' => 'activate', 'username' => $this->username, 'code' => $this->code), null) ?>">click here</a>. +<br /><br /> +------------ +<?= Zend_Registry::get('config')->general->title ?> Staff<br /> +<?= $_SERVER["SERVER_NAME"] ?> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/tester ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/tester/entry.phtml =================================================================== --- website/application/modules/acm/views/scripts/tester/entry.phtml (rev 0) +++ website/application/modules/acm/views/scripts/tester/entry.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,3 @@ +<entry id="<?= $this->id ?>" problemid="<?= $this->challengeid ?>" language="<?= $this->codelang ?>"> +<?= htmlentities(file_get_contents(Application::getDocRoot().'/other/submits/'.$this->id)) ?> +</entry> \ No newline at end of file Added: website/application/modules/acm/views/scripts/tester/submits.phtml =================================================================== --- website/application/modules/acm/views/scripts/tester/submits.phtml (rev 0) +++ website/application/modules/acm/views/scripts/tester/submits.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,4 @@ +<?= '<?xml version="1.0" encoding="UTF-8"?>' ?> +<entries> +<?= $this->partialLoop('tester/entry.phtml', $this->submits) ?> +</entries> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/user ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/user/activated.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/activated.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/activated.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1 @@ +You have successfully activated your account. You can login now. \ No newline at end of file Added: website/application/modules/acm/views/scripts/user/notactivated.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/notactivated.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/notactivated.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,3 @@ +There's was an error activating your account. You could try following resolution:<br /> +1) Click here to resend your activation key, if you haven't recieved it.<br /> +2) Click here to manualy enter the activation key, if url in your email is deformed. \ No newline at end of file Added: website/application/modules/acm/views/scripts/user/registered.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/registered.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/registered.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1 @@ +You have successfully registered account. Please check your mail. \ No newline at end of file Modified: website/config/config.ini =================================================================== --- website/config/config.ini 2008-12-06 23:14:20 UTC (rev 436) +++ website/config/config.ini 2008-12-07 21:57:19 UTC (rev 437) @@ -57,7 +57,7 @@ log.columnMap.when = "timestamp"; log.columnMap.ip = "ip"; -email.admin = "admin" +email.from = "admin" listtable.class = "crudtable" @@ -68,6 +68,7 @@ general.title = "ACM Contester" general.titlesep = " - " general.extention = "html" +general.roleid = "2" [development: general] Modified: website/library/Application.php =================================================================== --- website/library/Application.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Application.php 2008-12-07 21:57:19 UTC (rev 437) @@ -106,7 +106,8 @@ $this->_setupView(); // Setup Email - $mail = new Zend_Mail_Transport_Sendmail('-f'.$_config->email->admin.'@'.$_SERVER["SERVER_NAME"]); + //$mail = new Zend_Mail_Transport_Sendmail('-f'.$_config->email->from.'@'.$_SERVER["SERVER_NAME"]); + $mail = new Zend_Mail_Transport_Smtp('mail.ostacium.com', array('auth' => 'login', 'username' => 'ad...@os...', 'password' => 'g3n1u535')); Zend_Mail::setDefaultTransport($mail); // Setup Plugins @@ -236,7 +237,9 @@ $language = $_config->lang->default; $translate->setLocale($language); + Zend_Registry::set('Zend_Translate', $translate); + Zend_Registry::set('Zend_Locale', new Zend_Locale($language)); } protected function _setupRoutes(Zend_Controller_Front $frontController) Modified: website/library/Ostacium/Controller/Action.php =================================================================== --- website/library/Ostacium/Controller/Action.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Action.php 2008-12-07 21:57:19 UTC (rev 437) @@ -4,10 +4,12 @@ { protected $_model; protected $_translate; + protected $_config; public function init() { $this->_translate = Zend_Registry::get('Zend_Translate'); + $this->_config = Zend_Registry::get('config'); $name = ucfirst($this->getRequest()->getControllerName()); Modified: website/library/Ostacium/Controller/Plugin/ErrorHandler.php =================================================================== --- website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-07 21:57:19 UTC (rev 437) @@ -25,6 +25,8 @@ $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $error->exception = current($response->getException()); + $auth = Zend_Auth::getInstance(); + if (!$dispatcher->isDispatchable($request)) { $error->type = self::EXCEPTION_NO_CONTROLLER; if (!$error->exception) Modified: website/library/Ostacium/Controller/Router/Route/Language.php =================================================================== --- website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-07 21:57:19 UTC (rev 437) @@ -16,6 +16,7 @@ parent::__construct($defaults, $dispatcher, $request); $this->translate = Zend_Registry::get('Zend_Translate'); + $this->locale = Zend_Registry::get('Zend_Locale'); $this->config = Zend_Registry::get('config'); $this->extention = $extention; } @@ -53,6 +54,7 @@ if ($this->translate->isAvailable($path[0])) { $values[$this->_languageKey] = array_shift($path); $this->translate->setLocale($values[$this->_languageKey]); + $this->locale->setLocale($values[$this->_languageKey]); } if (count($path) && !empty($path[0]) && $this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) { Added: website/library/Ostacium/Mail.php =================================================================== --- website/library/Ostacium/Mail.php (rev 0) +++ website/library/Ostacium/Mail.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,19 @@ +<?php + +class Ostacium_Mail extends Zend_Mail +{ + public function setBodyTemplate($options) + { + $template = $options['template']; + $arguments = $options['arguments']; + + $view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view; + $view->assign($arguments); + + $body = $view->render('emails/'.$template); + + $this->setBodyHtml($body); + + return $this; + } +} \ No newline at end of file Added: website/library/Ostacium/View/Helper/Date.php =================================================================== --- website/library/Ostacium/View/Helper/Date.php (rev 0) +++ website/library/Ostacium/View/Helper/Date.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,17 @@ +<?php + +class Ostacium_View_Helper_Date extends Zend_View_Helper_Abstract +{ + public function date($date = null, $format = null, $part = null, $locale = null) + { + try + { + $d = new Zend_Date($date, $part, $locale); + return $d->toString($format); + } + catch (Exception $e) + { + return false; + } + } +} \ No newline at end of file Deleted: website/other/db.sql =================================================================== --- website/other/db.sql 2008-12-06 23:14:20 UTC (rev 436) +++ website/other/db.sql 2008-12-07 21:57:19 UTC (rev 437) @@ -1,759 +0,0 @@ --- phpMyAdmin SQL Dump --- version 2.11.7 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Oct 05, 2008 at 05:59 PM --- Server version: 5.0.51 --- PHP Version: 5.2.6 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - --- --- Database: `acm` --- - --- -------------------------------------------------------- - --- --- Table structure for table `archieve_submits` --- - -CREATE TABLE IF NOT EXISTS `archieve_submits` ( - `id` int(11) NOT NULL, - `username` varchar(50) NOT NULL, - `challengeid` int(11) NOT NULL, - `languageid` int(11) NOT NULL, - `state` int(11) NOT NULL, - `tests` int(11) NOT NULL, - `firsttest` tinyint(1) NOT NULL default '0', - `runtime` double NOT NULL, - `memory` int(11) NOT NULL, - `when` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `archieve_submits` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `challenges` --- - -CREATE TABLE IF NOT EXISTS `challenges` ( - `id` int(11) NOT NULL auto_increment, - `timelimit` double NOT NULL default '0', - `memorylimit` int(11) NOT NULL default '0', - `outputlimit` int(11) NOT NULL default '0', - `tries` int(11) NOT NULL default '0', - `accepted` int(11) NOT NULL default '0', - `author` varchar(50) character set latin1 NOT NULL, - `enabled` tinyint(1) NOT NULL default '1', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1195 ; - --- --- Dumping data for table `challenges` --- - -INSERT INTO `challenges` (`id`, `timelimit`, `memorylimit`, `outputlimit`, `tries`, `accepted`, `author`, `enabled`) VALUES -(1000, 1000, 5120000, 204800, 0, 0, '', 1), -(1001, 1000, 5120000, 204800, 0, 0, '', 1), -(1002, 1000, 5120000, 204800, 0, 0, '', 1), -(1003, 1000, 5120000, 204800, 0, 0, '', 1), -(1004, 1000, 3072000, 204800, 0, 0, '', 1), -(1005, 1000, 3072000, 2048, 0, 0, '', 1), -(1006, 1000, 3072000, 2048, 0, 0, '', 1), -(1007, 1000, 3072000, 2048, 0, 0, '', 1), -(1008, 1000, 5120000, 2048, 0, 0, '', 1), -(1009, 1000, 3072000, 2048, 0, 0, '', 1), -(1010, 1000, 3072000, 2048, 0, 0, '', 1), -(1011, 1500, 3072000, 204800, 0, 0, '', 1), -(1012, 500, 3072000, 2048, 0, 0, '', 1), -(1013, 500, 3072000, 204800, 0, 0, '', 1), -(1014, 500, 3072000, 2048, 0, 0, '', 1), -(1015, 500, 3072000, 204800, 0, 0, '', 1), -(1016, 1000, 3072000, 204800, 0, 0, '', 1), -(1017, 500, 3072000, 204800, 0, 0, '', 1), -(1018, 20000, 3072000, 2048, 0, 0, '', 1), -(1019, 1000, 3072000, 2048, 0, 0, '', 1), -(1020, 500, 3072000, 2048, 0, 0, '', 1), -(1021, 500, 3072000, 2048, 0, 0, '', 1), -(1022, 1000, 5120000, 2048, 0, 0, '', 1), -(1023, 1000, 3072000, 2048, 0, 0, '', 1), -(1024, 1000, 3072000, 2048, 0, 0, '', 1), -(1025, 1000, 2048000, 2048, 0, 0, '', 1), -(1026, 1000, 3072000, 2048, 0, 0, '', 1), -(1027, 1000, 3072000, 2048, 0, 0, '', 1), -(1028, 500, 3072000, 2048, 0, 0, '', 1), -(1029, 1000, 3072000, 2048, 0, 0, '', 1), -(1030, 500, 5120000, 204800, 0, 0, '', 1), -(1031, 1000, 2048000, 2048, 0, 0, '', 0), -(1032, 1000, 10240000, 2048, 0, 0, '', 1), -(1033, 500, 2048000, 2048, 0, 0, '', 1), -(1034, 2000, 2048000, 2048, 0, 0, '', 1), -(1035, 500, 2048000, 2048, 0, 0, '', 1), -(1036, 500, 2048000, 204800, 0, 0, '', 1), -(1037, 500, 20480000, 2048, 0, 0, '', 1), -(1038, 500, 20480000, 2048, 0, 0, '', 1), -(1039, 500, 20480000, 2048, 0, 0, '', 1), -(1040, 1000, 20480000, 2048, 0, 0, '', 1), -(1041, 1000, 20480000, 2048, 0, 0, '', 1), -(1042, 500, 20480000, 2048, 0, 0, '', 1), -(1043, 500, 20480000, 2048, 0, 0, '', 1), -(1044, 1000, 20480000, 2048, 0, 0, '', 1), -(1045, 1000, 20480000, 204800, 0, 0, '', 1), -(1046, 1000, 20480000, 512000, 0, 0, '', 1), -(1047, 1000, 20480000, 2048, 0, 0, '', 1), -(1048, 1000, 20480000, 2048, 0, 0, '', 1), -(1049, 1000, 20480000, 2048, 0, 0, '', 1), -(1050, 1000, 20480000, 2048, 0, 0, '', 1), -(1051, 500, 20480000, 1024, 0, 0, '', 1), -(1052, 500, 20480000, 1024, 0, 0, '', 0), -(1053, 500, 20480000, 1024, 0, 0, '', 1), -(1054, 500, 20480000, 1024, 0, 0, '', 1), -(1055, 500, 20480000, 1024, 0, 0, '', 1), -(1056, 500, 20480000, 1024, 0, 0, '', 1), -(1057, 500, 20480000, 1024, 0, 0, '', 1), -(1058, 1000, 5120000, 204800, 0, 0, '', 1), -(1059, 1000, 5120000, 204800, 0, 0, '', 1), -(1060, 1000, 3072000, 5120, 0, 0, '', 1), -(1061, 2000, 2048000, 2048000, 0, 0, '', 1), -(1062, 1000, 10240000, 2048, 0, 0, '', 1), -(1063, 3000, 20480000, 2048, 0, 0, '', 1), -(1064, 500, 20480000, 20480, 0, 0, '', 1), -(1065, 500, 3072000, 20480000, 0, 0, '', 1), -(1066, 1000, 102400000, 2048, 0, 0, '', 1), -(1067, 500, 20480000, 20480000, 0, 0, '', 1), -(1068, 1000, 5120000, 2048, 0, 0, '', 1), -(1069, 500, 5120000, 2048, 0, 0, '', 1), -(1070, 2000, 5120000, 2048, 0, 0, '', 1), -(1071, 1000, 5120000, 2048, 0, 0, '', 1), -(1072, 2000, 20480000, 2048, 0, 0, '', 1), -(1073, 250, 5120000, 2048, 0, 0, '', 1), -(1074, 500, 5120000, 2048, 0, 0, '', 1), -(1075, 1000, 5120000, 2048, 0, 0, '', 1), -(1076, 2000, 20480000, 2048, 0, 0, '', 1), -(1077, 1000, 5120000, 2048, 0, 0, '', 1), -(1078, 1000, 5120000, 2048, 0, 0, '', 1), -(1079, 1000, 5120000, 2048, 0, 0, '', 1), -(1080, 1000, 5120000, 2048, 0, 0, '', 1), -(1081, 1000, 2097152, 2048, 0, 0, '', 1), -(1082, 1000, 5120000, 2048, 0, 0, '', 1), -(1083, 1000, 5120000, 2048, 0, 0, '', 1), -(1084, 1000, 5120000, 2048, 0, 0, '', 1), -(1085, 500, 5120000, 2048, 0, 0, '', 1), -(1086, 1000, 2097152, 2048, 0, 0, '', 1), -(1087, 1000, 65536000, 2048, 0, 0, '', 1), -(1088, 1000, 65536000, 2048, 0, 0, '', 1), -(1089, 1000, 65536000, 2048, 0, 0, '', 1), -(1090, 1000, 65536000, 2048, 0, 0, '', 1), -(1091, 5000, 65536000, 2048, 0, 0, '', 1), -(1092, 1000, 65536000, 2048, 0, 0, '', 1), -(1093, 1000, 65536000, 2048, 0, 0, '', 1), -(1094, 1000, 5120000, 2048, 0, 0, '', 1), -(1095, 1000, 5120000, 2048, 0, 0, '', 1), -(1096, 1000, 16384000, 2048, 0, 0, '', 1), -(1097, 1000, 5120000, 2048, 0, 0, '', 1), -(1098, 1000, 5120000, 2048, 0, 0, '', 1), -(1099, 500, 5120000, 2048, 0, 0, '', 1), -(1100, 1500, 65536000, 10240000, 0, 0, '', 1), -(1101, 45000, 5120000, 2048, 0, 0, '', 1), -(1102, 5000, 20480000, 512, 0, 0, '', 1), -(1103, 5000, 20480000, 2048, 0, 0, '', 1), -(1104, 5000, 20480000, 2048, 0, 0, '', 1), -(1105, 5000, 20480000, 2048, 0, 0, '', 1), -(1106, 5000, 20480000, 2048, 0, 0, '', 1), -(1107, 1000, 5120000, 2048, 0, 0, '', 1), -(1108, 5000, 5120000, 2048, 0, 0, '', 1), -(1109, 1000, 5120000, 2048, 0, 0, '', 1), -(1110, 1000, 5120000, 2048, 0, 0, '', 1), -(1111, 1000, 5120000, 2048, 0, 0, '', 1), -(1112, 1000, 5120000, 2048, 0, 0, '', 1), -(1113, 1000, 5120000, 2048, 0, 0, '', 1), -(1114, 1000, 5120000, 51200, 0, 0, '', 1), -(1115, 1000, 5120000, 2048, 0, 0, '', 1), -(1116, 1000, 5120000, 2048, 0, 0, '', 1), -(1117, 1000, 5120000, 2048, 0, 0, '', 1), -(1118, 1000, 5120000, 2048, 0, 0, '', 1), -(1119, 1000, 5120000, 2048, 0, 0, '', 1), -(1120, 1000, 5120000, 2048, 0, 0, '', 1), -(1121, 1000, 5120000, 2048, 0, 0, '', 1), -(1122, 1000, 5120000, 2048, 0, 0, '', 1), -(1123, 1000, 5120000, 2048, 0, 0, '', 1), -(1124, 1000, 5120000, 2048, 0, 0, '', 1), -(1125, 1000, 5120000, 2048, 0, 0, '', 1), -(1126, 1000, 5120000, 2048, 0, 0, '', 1), -(1127, 1000, 5120000, 2048, 0, 0, '', 1), -(1128, 1000, 5120000, 256000, 0, 0, '', 1), -(1129, 1000, 5120000, 2048, 0, 0, '', 1), -(1130, 1000, 5120000, 2048, 0, 0, '', 1), -(1131, 1000, 5120000, 2048, 0, 0, '', 1), -(1132, 1000, 5120000, 2048, 0, 0, '', 1), -(1133, 1000, 5120000, 2048, 0, 0, '', 1), -(1134, 500, 5120000, 102400, 0, 0, '', 1), -(1135, 1000, 5120000, 2048, 0, 0, '', 1), -(1136, 1000, 5120000, 2048, 0, 0, '', 1), -(1137, 1000, 51200000, 5120000, 0, 0, '', 1), -(1138, 2000, 5120000, 2048000, 0, 0, '', 1), -(1139, 1000, 10240000, 2048, 0, 0, '', 1), -(1140, 1000, 10240000, 2048, 0, 0, '', 1), -(1141, 5000, 131072000, 2048, 0, 0, '', 1), -(1142, 5000, 131072000, 2048, 0, 0, '', 1), -(1143, 5000, 131072000, 2048, 0, 0, '', 1), -(1144, 5000, 131072000, 2048, 0, 0, '', 1), -(1145, 5000, 131072000, 2048, 0, 0, '', 1), -(1146, 1000, 16384000, 2048, 0, 0, '', 1), -(1147, 5000, 131072000, 2048, 0, 0, '', 1), -(1148, 1000, 5120000, 2048, 0, 0, '', 1), -(1149, 1000, 5120000, 2048, 0, 0, '', 1), -(1150, 1000, 5120000, 2048, 0, 0, '', 1), -(1151, 1000, 5120000, 2048, 0, 0, '', 1), -(1152, 1000, 5120000, 2048, 0, 0, '', 1), -(1153, 3000, 65536000, 5120000, 0, 0, '', 1), -(1154, 1000, 5120000, 2048, 0, 0, '', 1), -(1155, 2000, 65536000, 2048, 0, 0, '', 1), -(1156, 1000, 5120000, 2048, 0, 0, '', 1), -(1157, 500, 5120000, 204800, 0, 0, '', 1), -(1158, 1000, 5120000, 2048, 0, 0, '', 1), -(1159, 1000, 5120000, 2048, 0, 0, '', 1), -(1160, 1000, 5120000, 2048, 0, 0, '', 1), -(1161, 1000, 5120000, 2048000, 0, 0, '', 1), -(1162, 1000, 5120000, 2048, 0, 0, '', 1), -(1163, 1000, 5120000, 2048, 0, 0, '', 1), -(1164, 1000, 5120000, 2048, 0, 0, '', 1), -(1165, 1000, 5120000, 2048, 0, 0, '', 1), -(1166, 1000, 5120000, 2048, 0, 0, '', 1), -(1167, 1000, 5120000, 2048, 0, 0, '', 1), -(1168, 5000, 5120000, 2048, 0, 0, '', 1), -(1169, 1000, 5120000, 2048, 0, 0, '', 1), -(1170, 1000, 5120000, 2048, 0, 0, '', 1), -(1171, 1000, 5120000, 2048, 0, 0, '', 1), -(1172, 1000, 5120000, 2048, 0, 0, '', 1), -(1173, 250, 16384000, 16384, 0, 0, '', 1), -(1174, 1000, 5120000, 2048, 0, 0, '', 1), -(1175, 2000, 51200000, 5120, 0, 0, '', 1), -(1176, 1000, 51200000, 2048, 0, 0, '', 1), -(1177, 1000, 51200000, 2048000, 0, 0, '', 1), -(1178, 1000, 5120000, 2048, 0, 0, '', 1), -(1179, 500, 51200000, 2048, 0, 0, '', 1), -(1180, 1000, 5120000, 2048, 0, 0, '', 1), -(1181, 4000, 16384000, 2048, 0, 0, '', 1), -(1182, 250, 5120000, 2048, 0, 0, '', 1), -(1183, 1000, 20480000, 2048000, 0, 0, '', 1), -(1184, 1000, 20480000, 2048000, 0, 0, '', 1), -(1185, 1000, 5120000, 2048, 0, 0, '', 1), -(1186, 3000, 5120000, 2048, 0, 0, '', 1), -(1187, 1000, 5120000, 2048000, 0, 0, '', 1), -(1188, 2000, 5120000, 2048000, 0, 0, '', 1), -(1189, 1000, 5120000, 2048, 0, 0, '', 1), -(1190, 500, 5120000, 2048000, 0, 0, '', 1), -(1191, 1000, 5120000, 2048, 0, 0, '', 1), -(1192, 1000, 5120000, 2048, 0, 0, '', 1), -(1193, 10000, 5120000, 2048, 0, 0, '', 1), -(1194, 1000, 5120000, 2048, 0, 0, '', 1); - --- -------------------------------------------------------- - --- --- Table structure for table `challenges_lang` --- - -CREATE TABLE IF NOT EXISTS `challenges_lang` ( - `id` int(11) NOT NULL, - `langcode` varchar(2) NOT NULL, - `name` varchar(200) NOT NULL, - `description` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `challenges_lang` --- - -INSERT INTO `challenges_lang` (`id`, `langcode`, `name`, `description`) VALUES -(1000, 'uk', 'Swap', '<P align=left><B>Завдання</B></P><P>Дано два цілих числа a та b. Написати програму, яка б міняла їхні значення місцями. Тобто після виконання програми замість а значення b, а замість b - а. <P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа - а та b. (-32000 < a, b < 32000). <P><B>Вихідні дані</B></P><P>Вивести в єдиний рядок через пропуск два числа: спочатку b, а потім a. <P><B>Приклад введення 1</B></P><P><PRE>1 2</PRE><P><B>Приклад виведення 1</B></P><P><PRE>2 1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>3 2</PRE><BR>'), -(1001, 'uk', 'A in power k', '<P align=left><B>Завдання</B></P><P>Для заданого цілого а та натурального k обчислити a<SUP>k</SUP>.<P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа a та k (-32000 < a <= 32000, 0 < k < 32000).<P><B>Вихідні дані</B></P><P>Єдине число - відповідь. Гарантується, що відповідь не більша за 2*10<SUP>9</SUP>.<P><B>Приклад введення 1</B></P><P><PRE>1 1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>8</PRE><BR>'), -(1002, 'uk', 'Послідовність Фібоначчі', '<P align=left><B>Завдання</B></P><P>Послідовність фібоначчі визначається наступним чином:<BR></P><UL><LI>a<SUB>0</SUB>=0;<LI>a<SUB>1</SUB>=1;<LI>a<SUB>k</SUB>=a<SUB>k-1</SUB> + a<SUB>k-2</SUB></LI></UL><BR><BR>Для заданого n знайти значення n-го елемента послідовності Фібоначчі (a<SUB>n</SUB>).<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 40).<P><B>Вихідні дані</B></P><P>Єдине число - відповідь.<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>5</PRE><P><B>Приклад виведення 2</B></P><P><PRE>5</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>8</PRE><P><B>Приклад виведення 3</B></P><P><PRE>21</PRE><BR>'), -(1003, 'uk', 'Рукавички', '<P align=left><B>Завдання</B></P><P>Комірник видає по К рукавичок кожному робітнику. Тобто другий робітник отримає рукавички від (K+1)-шої до (2∙K)-ї включно, рукавички номер (2∙K+2) отримає третій робітник і для нього вони будуть другими.<P>Напишіть програму, яка за номером виданих рукавичок визначає номер робітника, якому їх видано та порядковий номер цих рукавичок в цього робітника<P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа - K та N. K - кількість рукавичок кожному робітнику, N - номер пари рукавичок (1 <= K <= 200, 1 <= N <= 20000) розділені пропуском.<P><B>Вихідні дані</B></P><P>Номер робітника та номер рукавичок в цього робітника, розділені пропуском.<P><B>Приклад введення 1</B></P><P><PRE>50 1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1 1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>20 25</PRE><P><B>Приклад виведення 2</B></P><P><PRE>2 5</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>15 43</PRE><P><B>Приклад виведення 3</B></P><P><PRE>3 13</PRE><BR>'), -(1004, 'uk', 'Супер проста проблема', '<P align=left><B>Завдання</B></P><P>Знайти квадрат N-го простого числа.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 100).<P><B>Вихідні дані</B></P><P>Єдине число - квадрат N-го простого числа<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>4</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2</PRE><P><B>Приклад виведення 2</B></P><P><PRE>9</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>5</PRE><P><B>Приклад виведення 3</B></P><P><PRE>121</PRE><BR>'), -(1005, 'uk', '0-1 проблема', '<P align=left><B>Завдання</B></P><P>Над рядочком 01 виконаємо наступні операції:<UL><LI>Скопіюємо в кінець рядочка самого себе (отримаємо 0101)<LI>В другій половині рядка всі 0 змінимо на 1, а всі 1 на 0 (отримаємо 0110)</LI></UL>Над рядочком 0110 виконаємо ті самі операції. Отримаємо 01101001. І т. д.Таким чином отримаємо нескінченний рядочок нулів та одиниць.Ваше завдання – знайти n-тий символ такого рядочка.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 2000000000).<P><B>Вихідні дані</B></P><P>Єдиний символ, який буде на N-й позиції.<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>0</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2</PRE><P><B>Приклад виведення 2</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>5</PRE><P><B>Приклад виведення 3</B></P><P><PRE>1</PRE><BR>'), -(1006, 'uk', 'Одинадцять', '<P align=left><B>Завдання</B></P><P>Ваше завдання – визначити чи ділиться дане число на 11.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= n). Число має не більше тисячі знаків.<P><B>Вихідні дані</B></P><P>Вам потрібно вивести “Yes” – якщо число ділиться на 11, і “No” – в протилежному випадку.<P><B>Приклад введення 1</B></P><P><PRE>323455693</PRE><P><B>Приклад виведення 1</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>5038297</PRE><P><B>Приклад виведення 2</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>112234</PRE><P><B>Приклад виведення 3</B></P><P><PRE>No</PRE><BR>'), -(1007, 'uk', 'Супер послідовність', '<P align=left><B>Завдання</B></P><P>Послідовність чисел a1, a2, … an називається супер послідовністю, якщо виконуються наступні умови:<UL><LI>0 < a1 < a2 < … < an<LI>жодне з чисел не є сумою двох або більше інших чисел</LI></UL><P><B>Вхідні дані</B></P><P>В єдиному рядку записане число N (1 <= n <= 50), далі задано N чисел, кожне з яких не менше 1 і не більше 1000.<P><B>Вихідні дані</B></P><P>Вам необхідно вивести “Yes” – якщо дано супер послідовність, “No” – в протилежному випадку.<P><B>Приклад введення 1</B></P><P><PRE>2 1 2</PRE><P><B>Приклад виведення 1</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>3 1 2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>No</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>10 1 3 16 19 25 70 100 243 245 306</PRE><P><B>Приклад виведення 3</B></... [truncated message content] |
From: <pan...@us...> - 2008-12-06 23:14:25
|
Revision: 436 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=436&view=rev Author: panzaboi Date: 2008-12-06 23:14:20 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Removed unneeded files; added firebug profiler; Added Paths: ----------- website/library/Ostacium/Db/Profiler/ website/library/Ostacium/Db/Profiler/Firebug.php website/library/Ostacium/View/Helper/Measure.php Removed Paths: ------------- website/library/Ostacium/Controller/Plugin/Router.php website/library/Ostacium/Form/Element/ Deleted: website/library/Ostacium/Controller/Plugin/Router.php =================================================================== --- website/library/Ostacium/Controller/Plugin/Router.php 2008-12-06 23:13:21 UTC (rev 435) +++ website/library/Ostacium/Controller/Plugin/Router.php 2008-12-06 23:14:20 UTC (rev 436) @@ -1,83 +0,0 @@ -<?php - -class Ostacium_Controller_Plugin_Router_Exception extends Zend_Controller_Exception {} - -class Ostacium_Controller_Plugin_Router extends Zend_Controller_Plugin_Abstract -{ - private $_acl; - private $_noauth = array( /*'module' => 'default',*/ - 'controller' => 'index', - 'action' => 'index' ); - - private $_noacl = array( 'module' => 'default', - 'controller' => 'error', - 'action' => 'error' ); - - public function __construct($acl, $noauth = null, $noacl = null) { - $this->_acl = $acl; - $this->_noauth = is_array($noauth) ? $noauth : $this->_noauth; - $this->_noacl = is_array($noacl) ? $noacl : $this->_noacl; - } - - public function preDispatch(Zend_Controller_Request_Abstract $request) { - $auth = Zend_Auth::getInstance(); - $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); - - if ($auth->hasIdentity()) { - $role = $this->_acl->getRoleById($auth->getIdentity()->roleid) ? $this->_acl->getRoleById($auth->getIdentity()->roleid) : 'guest'; - } else { - $role = 'guest'; - } - - $controller = $request->getControllerName(); - $action = $request->getActionName(); - $module = $request->getModuleName(); - $resource = ($module != 'default' ? $module . ':' . $controller : $controller); - - if (!$this->_acl->has($resource) || !$dispatcher->isDispatchable($request) || !$this->isProperAction($dispatcher, $request)) - { - $e = new Zend_Controller_Dispatcher_Exception("Resource doesn't exist", 404); - - $response = $this->getResponse(); - $response->setException($e); - } - elseif (!$this->_acl->isAllowed($role, $resource, $action)) { - if (!$auth->hasIdentity()) { - //$module = $this->_noauth['module']; - $controller = $this->_noauth['controller']; - $action = $this->_noauth['action']; - - $request->setParam('error_message', 'nologin'); - } else { - $module = $this->_noacl['module']; - $controller = $this->_noacl['controller']; - $action = $this->_noacl['action']; - - $request->setParam('error_message', 'noallowed'); - } - } - - $request->setModuleName($module); - $request->setControllerName($controller); - $request->setActionName($action); - } - - public function isProperAction($dispatcher, $request) - { - $className = $dispatcher->loadClass($dispatcher->getControllerClass($request)); - $actionName = $request->getActionName(); - - if (empty($actionName)) { - $actionName = $dispatcher->getDefaultAction(); - } - - $methodName = $dispatcher->formatActionName($actionName); - $class = new ReflectionClass($className); - - if ($class->hasMethod($methodName)) { - return true; - } - - return false; - } -} \ No newline at end of file Property changes on: website/library/Ostacium/Db/Profiler ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/library/Ostacium/Db/Profiler/Firebug.php =================================================================== --- website/library/Ostacium/Db/Profiler/Firebug.php (rev 0) +++ website/library/Ostacium/Db/Profiler/Firebug.php 2008-12-06 23:14:20 UTC (rev 436) @@ -0,0 +1,63 @@ +<?php + +class Ostacium_Db_Profiler_Firebug extends Zend_Db_Profiler_Firebug +{ + /** + * The longest query + * @var Zend_Db_Profiler_Query + */ + protected $_longestQuery = null; + + /** + * Constructor + * + * @param string $label OPTIONAL Label for the profiling info. + * @return void + */ + public function __construct($label = null) + { + $this->_label = $label; + if(!$this->_label) { + $this->_label = 'Ostacium_Db_Profiler_Firebug'; + } + } + + public function setLabel($label) + { + $this->_label = $label; + } + + /** + * Intercept the query end and find out longest query + * + * @param integer $queryId + * @throws Zend_Db_Profiler_Exception + * @return void + */ + public function queryEnd($queryId) + { + parent::queryEnd($queryId); + + $profile = $this->getQueryProfile($queryId); + + if ($this->_longestQuery == null || $profile->getElapsedSecs() > $this->_longestQuery->getElapsedSecs()) + { + $this->_longestQuery = $profile; + $this->updateMessageLabel(); + } + } + + /** + * Update the label of the message holding the profile info. + * + * @return void + */ + protected function updateMessageLabel() + { + if (!$this->_message) { + return; + } + + $this->_message->setLabel($this->_label . ' (' . round($this->_totalElapsedTime,5) . ' sec)' . ($this->_longestQuery ? '[Longest('.round($this->_longestQuery->getElapsedSecs(), 5).' sec): ' . $this->_longestQuery->getQuery() . ']' : '')); + } +} \ No newline at end of file Added: website/library/Ostacium/View/Helper/Measure.php =================================================================== --- website/library/Ostacium/View/Helper/Measure.php (rev 0) +++ website/library/Ostacium/View/Helper/Measure.php 2008-12-06 23:14:20 UTC (rev 436) @@ -0,0 +1,22 @@ +<?php + +class Ostacium_View_Helper_Measure extends Zend_View_Helper_Abstract +{ + public function measure($measure, $amount, $type = null, $convert = null, $round = 2, $locale = null) + { + try + { + $measure = 'Zend_Measure_'.$measure; + $m = new $measure($amount, $type, $locale); + + if ($convert) + $m->setType($convert, 2); + + return $m->toString($round); + } + catch (Exception $e) + { + return false; + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pan...@us...> - 2008-12-06 23:13:26
|
Revision: 435 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=435&view=rev Author: panzaboi Date: 2008-12-06 23:13:21 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Added functionality to submit problems by textarea or file upload. Modified Paths: -------------- website/application/layouts/layout.phtml website/application/modules/acm/controllers/ArchieveController.php website/application/modules/acm/controllers/IndexController.php website/application/modules/acm/models/Archieve.php website/application/modules/acm/views/scripts/archieve/entry.phtml website/application/modules/acm/views/scripts/archieve/index.phtml website/application/modules/acm/views/scripts/archieve/view.phtml website/application/modules/acm/views/scripts/index/index.phtml website/config/config.ini website/httpdocs/scripts/main.js website/library/Application.php website/library/Ostacium/Controller/Plugin/ErrorHandler.php website/library/Ostacium/Controller/Router/Route/Language.php website/library/Ostacium/Db/Table.php website/other/todo.txt Added Paths: ----------- website/application/modules/acm/models/Form/Submit.php website/application/modules/acm/views/scripts/archieve/submit.phtml website/other/submits/ website/other/uploads/ Property Changed: ---------------- website/library/ Modified: website/application/layouts/layout.phtml =================================================================== --- website/application/layouts/layout.phtml 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/layouts/layout.phtml 2008-12-06 23:13:21 UTC (rev 435) @@ -12,6 +12,7 @@ <?= $this->headLink()->appendStylesheet('styles/style.css') ?> <?= /*$this->headLink()->appendStylesheet('styles/ie6.css', 'screen', 'IE 6')*/'' ?> <?= /*$this->headLink()->appendStylesheet('styles/ie7.css', 'screen', 'IE 7')*/'' ?> + <?= $this->headScript()->appendFile('/scripts/main.js') ?> <? if ($this->dojo()->isEnabled()): $this->dojo()->setLocalPath('/scripts/dojo/dojo.js') @@ -19,7 +20,6 @@ echo $this->dojo(); endif; ?> - <?= $this->headScript()->appendFile('/scripts/main.js') ?> </head> <body class="tundra"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> @@ -39,10 +39,10 @@ <table width="100%" border="0" cellpadding="0" cellspacing="5"> <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="index/about">Що це за проект</a></td></tr> <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="index/rule">Правила</a></td></tr> - <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="archieve/index">Набір завдань</a></td></tr> - <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="archieve/submit">Протестувати Розв'язок</a></td></tr> - <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="archieve/results">Результати Тестувань</a></td></tr> - <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="archieve/ranks">Рейтинг Учасників</a></td></tr> + <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="/acm/archieve/index">Набір завдань</a></td></tr> + <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="/acm/archieve/submit">Протестувати Розв'язок</a></td></tr> + <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="/acm/archieve/results">Результати Тестувань</a></td></tr> + <tr><td><img border="0" src="images/arrow.gif" width="8" height="8" hspace="5"><a href="/acm/archieve/ranks">Рейтинг Учасників</a></td></tr> <tr><td><hr></td></tr> </table> Modified: website/application/modules/acm/controllers/ArchieveController.php =================================================================== --- website/application/modules/acm/controllers/ArchieveController.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/controllers/ArchieveController.php 2008-12-06 23:13:21 UTC (rev 435) @@ -15,11 +15,76 @@ if (!$problem) return $this->_forward('index', null, null, $this->_getAllParams() + array('message' => 'noProblem')); - $this->view->problem = $problem; + $this->view->assign($problem); } public function submitAction() { + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + $form = $this->_model->getSubmitForm(array( + 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), + 'method' => 'post', + 'name' => 'submitform', + )); + + $this->view->dojo()->addOnLoad('function(){ changeEditor('.$form->type->getValue().'); }'); + + echo $form; } + + public function uploadAction() + { + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + $form = $this->_model->getSubmitForm(array( + 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), + 'method' => 'post', + 'name' => 'submitform', + )); + + if (!$this->getRequest()->isPost()) + { + return $this->_forward('submit', null, null, $this->_getAllParams()); + } + + if ($_POST['type'] == 0) + { + $form->code->setRequired(true); + } + elseif ($_POST['type'] == 1) + { + $form->codefile->setRequired(true); + } + + $result = $form->isValid($this->getRequest()->getPost()); + $this->view->dojo()->addOnLoad('function(){ changeEditor('.$form->type->getValue().'); }'); + + if ($form->type->getValue() == 0) + { + $form->code->setRequired(false); + } + elseif ($form->type->getValue() == 1) + { + $form->codefile->setRequired(false); + } + + if (!$result) + { + echo $form; + return; + } + + $values = $form->getValues(); + $values += $this->_getAllParams(); + $id = $this->_model->addSubmit($values); + + if ($values['type'] == 0) + { + file_put_contents(Application::getDocRoot().'/other/submits/'.$id.'.cpp', $values['code']); + } + elseif ($values['type'] == 1) + { + rename($form->codefile->getFileName(), Application::getDocRoot().'/other/submits/'.$id.'.cpp'); + } + } } \ No newline at end of file Modified: website/application/modules/acm/controllers/IndexController.php =================================================================== --- website/application/modules/acm/controllers/IndexController.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/controllers/IndexController.php 2008-12-06 23:13:21 UTC (rev 435) @@ -58,7 +58,7 @@ protected function getLoginForm() { return new Form_Login(array( - 'action' => $this->getRequest()->getBaseUrl() . 'acm/index/login', + 'action' => $this->view->url(array('action' => 'login'), null), 'method' => 'post', 'name' => 'loginform', )); Modified: website/application/modules/acm/models/Archieve.php =================================================================== --- website/application/modules/acm/models/Archieve.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/models/Archieve.php 2008-12-06 23:13:21 UTC (rev 435) @@ -13,6 +13,37 @@ $challenges = new Challenges(); return $challenges->get($id); } + + public function getCodeLanguages() + { + return $this->_db->fetchPairs($this->_db->select()->from('code_languages', array('id', 'name'))); + } + + public function addSubmit($values) + { + $data = array( + 'username' => Zend_Auth::getInstance()->getStorage()->read()->username, + 'challengeid' => $values['id'], + 'languageid' => $values['languageid'], + 'firsttest' => $values['firsttest'], + 'when' => time() + ); + + $submits = new Submits(); + return $submits->insert($data); + } + + public function getSubmitForm($options = array()) + { + $form = new Form_Submit($options); + $user = Zend_Auth::getInstance()->getStorage()->read(); + + $languageid = $form->getElement('languageid'); + $languageid->addMultiOptions($this->getCodeLanguages()); + $languageid->setValue($user->codelangid); + + return $form; + } } class Challenges extends Ostacium_Db_Table @@ -20,8 +51,19 @@ protected $_name = 'challenges'; protected $_primary = 'id'; + public function get($id) + { + return $this->selectLang(array('name', 'description'))->where($this->_name.'.id = ?', $id)->query()->fetch(); + } + public function getAll() { - return $this->select()->from($this)->where('enabled = ?', 1)->query()->fetchAll(); + return $this->selectLang(array('name', 'description'))->where('enabled = ?', 1)->query()->fetchAll(); } +} + +class Submits extends Ostacium_Db_Table +{ + protected $_name = 'archieve_submits'; + protected $_primary = 'id'; } \ No newline at end of file Added: website/application/modules/acm/models/Form/Submit.php =================================================================== --- website/application/modules/acm/models/Form/Submit.php (rev 0) +++ website/application/modules/acm/models/Form/Submit.php 2008-12-06 23:13:21 UTC (rev 435) @@ -0,0 +1,82 @@ +<?php + +class Form_Submit extends Zend_Dojo_Form +{ + public $elementDecorators = array( + 'DijitElement', + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $simpleDecorators = array( + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $buttonDecorators = array( + 'DijitElement', + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + + $this->setAttrib('enctype', 'multipart/form-data'); + + $this->addElement('FilteringSelect', 'languageid', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'style' => 'height: 18px; width: 100px;', + 'title' => $translate->_('code_language'), + 'label' => $translate->_('code_language').': ', + )); + + $this->addElement('RadioButton', 'type', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('upload_type'), + 'label' => $translate->_('upload_type ').': ', + 'multiOptions' => array($translate->_('editor'), $translate->_('file_upload')), + 'onclick' => 'changeEditor(this.value);', + 'value' => 0 + )); + + $this->addElement('SimpleTextarea', 'code', array( + 'decorators' => $this->elementDecorators, + 'style' => 'height: 400px; width: 500px;', + 'title' => $translate->_('enter_code'), + 'label' => $translate->_('enter_code'), + )); + + $this->addElement('File', 'codefile', array( + 'decorators' => array_merge(array('File'), $this->simpleDecorators), + 'validators' => array(array('Count', false, 1)), + 'destination' => Application::getDocRoot().'/other/uploads/', + 'label' => $translate->_('enter_code'), + )); + + $this->addElement('Checkbox', 'firsttest', array( + 'decorators' => $this->elementDecorators, + 'title' => $translate->_('first_test'), + 'label' => $translate->_('first_test ').': ' + )); + + $this->addElement('SubmitButton', 'submitbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('submit'), + )); + } + + public function loadDefaultDecorators() + { + $this->setDecorators(array( + 'FormElements', + 'DijitForm', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + )); + } +} \ No newline at end of file Modified: website/application/modules/acm/views/scripts/archieve/entry.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/entry.phtml 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/views/scripts/archieve/entry.phtml 2008-12-06 23:13:21 UTC (rev 435) @@ -12,7 +12,7 @@ <td style="border-left: 0px none; border-right: 1px solid rgb(196, 196, 219);"><?= $this->accepted ?></td> <td style="border-left: 0px none; border-right: 0px solid rgb(196, 196, 219);"> - <img height="17" width="22" alt="Здати" src="images/b_find.gif"/> - <img height="17" width="22" alt="Показати як здають" src="images/probstatus.png"/> + <a href="<?= $this->url( array('action' => 'submit', 'id' => $this->id), null) ?>"><img height="17" width="22" alt="Здати" title="Здати" src="images/b_find.gif"/></a> + <a href="<?= $this->url( array('action' => 'status', 'id' => $this->id), null) ?>"><img height="17" width="22" alt="Показати як здають" src="images/probstatus.png"/> </td> </tr> \ No newline at end of file Modified: website/application/modules/acm/views/scripts/archieve/index.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/index.phtml 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/views/scripts/archieve/index.phtml 2008-12-06 23:13:21 UTC (rev 435) @@ -1,5 +1,10 @@ -<table cellspacing="1" cellpadding="8" border="0" width="100%"><tbody><tr><td width="100%" valign="top" class="name"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td bgcolor="#d0d4de" width="4" class="name"><img height="18" width="4" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/"/></td><td nowrap="" bgcolor="#122a5b" width="*" class="name"> <font color="#d4d0e2"><b><small>Набiр задач</small></b><small/></font></td><td nowrap="" bgcolor="#122a5b" align="right" class="name"> <font color="#d4d0e2"><b><small> 05:26 23 березня 2007 року </small></b><small/></font></td></tr></tbody></table> <table cellspacing="0" cellpadding="0" border="0" width="100%" summary=""><tbody><tr><td bgcolor="#f4f3f8" align="middle" colspan="14"><b>Архів задач</b></td></tr><tr><td bgcolor="#c4c4db" colspan="20"><img height="1" width="1" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/" alt=""/></td></tr><tr bgcolor="#e1e1e1" align="middle"> -<th width="70">Задача</th><th align="left" width="*"> Назва</th><th width="70">Спробували</th><th width="70">Здали</th><th align="middle" width="70">Дії</th></tr><tr><td height="1" bgcolor="#c4c4db" colspan="20"><img height="1" width="1" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/" alt=""/></td></tr> +<table cellspacing="1" cellpadding="8" border="0" width="100%"><tbody><tr><td width="100%" valign="top" class="name"> + +<table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td bgcolor="#d0d4de" width="4" class="name"> + +<img height="18" width="4" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/"/></td> + +<td nowrap="" bgcolor="#122a5b" width="*" class="name"> <font color="#d4d0e2"><b><small>Набiр задач</small></b><small/></font></td><td nowrap="" bgcolor="#122a5b" align="right" class="name"> <font color="#d4d0e2"><b><small> 05:26 23 березня 2007 року </small></b><small/></font></td></tr></tbody></table> <table cellspacing="0" cellpadding="0" border="0" summary="" align="center"><tbody><tr><td bgcolor="#f4f3f8" align="middle" colspan="14"><b>Архів задач</b></td></tr><tr><td bgcolor="#c4c4db" colspan="20"><img height="1" width="1" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/" alt=""/></td></tr><tr bgcolor="#e1e1e1" align="middle"> +<th width="70">Задача</th><th align="left" width="270"> Назва</th><th width="70">Спробували</th><th width="70">Здали</th><th align="middle" width="70">Дії</th></tr><tr><td height="1" bgcolor="#c4c4db" colspan="20"><img height="1" width="1" src="http://web.archive.org/web/20070323032706/http://acm.lviv.ua/" alt=""/></td></tr> <?= $this->partialLoop('archieve/entry.phtml', $this->challenges) ?> - </table><br/></td></tr></table> \ No newline at end of file Modified: website/application/modules/acm/views/scripts/archieve/view.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/view.phtml 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/views/scripts/archieve/view.phtml 2008-12-06 23:13:21 UTC (rev 435) @@ -1,5 +1,12 @@ -<?php +<h2 align="center"><?= $this->id.' - '.$this->name ?></h2> +<div align="center"> + <?= $this->translate('timelimit') ?>: <?= $this->measure("Time", $this->timelimit, Zend_Measure_Time::MILLISECOND, Zend_Measure_Time::SECOND, 0 ) ?><br /> + <?= $this->translate('memorylimit') ?>: <?= $this->measure("Binary", $this->memorylimit, Zend_Measure_Binary::BYTE, Zend_Measure_Binary::KILOBYTE ) ?><br /> + <?= $this->translate('outputlimit') ?>: <?= $this->measure("Binary", $this->outputlimit, Zend_Measure_Binary::BYTE, Zend_Measure_Binary::KILOBYTE ) ?><br /> +</div> +<br /> +<p><?= $this->description ?></p> -var_dump($this->problem); - -?> \ No newline at end of file +<div> + <a href="<?= $this->url(array('action' => 'submit', 'id' => $this->id), null) ?>"><?= $this->translate('submit') ?></a> +</div> \ No newline at end of file Modified: website/application/modules/acm/views/scripts/index/index.phtml =================================================================== --- website/application/modules/acm/views/scripts/index/index.phtml 2008-12-06 13:12:31 UTC (rev 434) +++ website/application/modules/acm/views/scripts/index/index.phtml 2008-12-06 23:13:21 UTC (rev 435) @@ -1 +1,9 @@ -<table cellspacing="1" cellpadding="8" border="0" width="100%"><tbody><tr><td width="100%" valign="top" class="name"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td bgcolor="#d0d4de" width="4" class="name"><img height="18" width="4" src="http://web.archive.org/web/20070323032459/http://acm.lviv.ua/"/></td><td nowrap="" bgcolor="#122a5b" width="*" class="name"> <font color="#d4d0e2"><b><small>Про систему</small></b><small/></font></td><td nowrap="" bgcolor="#122a5b" align="right" class="name"> <font color="#d4d0e2"><b><small> 05:24 23 березня 2007 року </small></b><small/></font></td></tr></tbody></table> <p style="font-size: 20px; font-family: arial; text-align: center;"><b>ACM Contester</b></p><p align="justify" style="font-size: 20px; font-family: arial; text-align: justify;"><font size="3">Ми, команда розробників цієї системи, дуже раді вітати Вас - учасників цієї системи. </font></p><p align="justify" style="font-size: 20px; font-family: arial; text-align: justify;"><font size="3">Тут Ви маєте можливість спробувати свої сили у розв'язанні різних типів задач. Змагайтесь!!!</font></p><p> </p></td></tr></tbody></table> \ No newline at end of file +<table cellspacing="1" cellpadding="8" border="0" width="100%"> +<tbody> + <tr> + <td width="100%" valign="top" class="name"> + <table cellspacing="0" cellpadding="0" border="0" width="100%"> + <tbody> + <tr> + <td bgcolor="#d0d4de" width="4" class="name"> + <img height="18" width="4" src="http://web.archive.org/web/20070323032459/http://acm.lviv.ua/"/></td><td nowrap="" bgcolor="#122a5b" width="*" class="name"> <font color="#d4d0e2"><b><small>Про систему</small></b><small/></font></td><td nowrap="" bgcolor="#122a5b" align="right" class="name"> <font color="#d4d0e2"><b><small> 05:24 23 березня 2007 року </small></b><small/></font></td></tr></tbody></table> <p style="font-size: 20px; font-family: arial; text-align: center;"><b>ACM Contester</b></p><p align="justify" style="font-size: 20px; font-family: arial; text-align: justify;"><font size="3">Ми, команда розробників цієї системи, дуже раді вітати Вас - учасників цієї системи. </font></p><p align="justify" style="font-size: 20px; font-family: arial; text-align: justify;"><font size="3">Тут Ви маєте можливість спробувати свої сили у розв'язанні різних типів задач. Змагайтесь!!!</font></p><p> </p></td></tr></tbody></table> \ No newline at end of file Modified: website/config/config.ini =================================================================== --- website/config/config.ini 2008-12-06 13:12:31 UTC (rev 434) +++ website/config/config.ini 2008-12-06 23:13:21 UTC (rev 435) @@ -65,8 +65,9 @@ #currency.precision = "2" currency.display = "2" -title = "ACM Contester" -titlesep = " - " +general.title = "ACM Contester" +general.titlesep = " - " +general.extention = "html" [development: general] @@ -76,7 +77,8 @@ db.params.dbname = "acm" db.params.username = "acm" db.params.password = "c0nt3st3r" +db.params.profiler.label = Db Profiler db.params.profiler.enabled = true -db.params.profiler.class = Zend_Db_Profiler_Firebug +db.params.profiler.class = Ostacium_Db_Profiler_Firebug [stable: genral] \ No newline at end of file Modified: website/httpdocs/scripts/main.js =================================================================== --- website/httpdocs/scripts/main.js 2008-12-06 13:12:31 UTC (rev 434) +++ website/httpdocs/scripts/main.js 2008-12-06 23:13:21 UTC (rev 435) @@ -1 +1,19 @@ +function changeEditor(value) +{ + if (!dojo.byId('code') || !dojo.byId('codefile')) return false; + + if (value == 0) + { + dojo.byId('code').parentNode.style.display = 'block'; + dojo.byId('codefile').parentNode.style.display = 'none'; + } + else if(value == 1) + { + dojo.byId('code').parentNode.style.display = 'none'; + dojo.byId('codefile').parentNode.style.display = 'block'; + } + + return false; +} + function checkForm(form){if(form.lgn.value.length<3){alert('Логін повинен мати як мінімум 3 символи!');return false;}} \ No newline at end of file Property changes on: website/library ___________________________________________________________________ Modified: svn:ignore - Zend + Zend ZendX Modified: website/library/Application.php =================================================================== --- website/library/Application.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/library/Application.php 2008-12-06 23:13:21 UTC (rev 435) @@ -5,12 +5,12 @@ protected $_environment; protected static $_approot; protected static $_start; - protected $_docroot; + protected static $_docroot; public function __construct($_approot) { self::$_approot = $_approot; - $this->_docroot = dirname($_SERVER["DOCUMENT_ROOT"]); + self::$_docroot = dirname($_SERVER["DOCUMENT_ROOT"]); self::$_start = microtime(true); } @@ -19,6 +19,11 @@ return self::$_approot; } + public static function getDocRoot() + { + return self::$_docroot; + } + public static function getRunTime() { return (microtime(true) - self::$_start); @@ -58,9 +63,9 @@ { // Set Include paths set_include_path( - $this->_docroot . PATH_SEPARATOR - . $this->_docroot . '/application' . PATH_SEPARATOR - . $this->_docroot . '/library' . PATH_SEPARATOR + self::$_docroot . PATH_SEPARATOR + . self::$_docroot . '/application' . PATH_SEPARATOR + . self::$_docroot . '/library' . PATH_SEPARATOR . get_include_path() ); @@ -74,15 +79,15 @@ // Setup Config $_config = $this->_setupConfig(); + // Setup DB + $this->_setupDB(); + // Setup Front Controller $frontController = $this->_setupFrontController(); // Setup Date Ostacium_Date::setOptions($_config->date->toArray()); //date_default_timezone_set($_config->date->timezone); - - // Setup DB - $this->_setupDB(); // Setup Helpers Ostacium_View_Helper_Truncate::setDefault($_config->truncate->toArray()); @@ -90,9 +95,6 @@ // Setup Log $this->_setupLog(); - - // Setup Authorication - $acl = $this->_setupAuth(); // Setup Languages $this->_setupLang(); @@ -108,8 +110,8 @@ Zend_Mail::setDefaultTransport($mail); // Setup Plugins - $routerPlugin = new Ostacium_Controller_Plugin_Router($acl, $_config->auth->noauth->toArray(), $_config->auth->noacl->toArray()); - $frontController->registerPlugin($routerPlugin, -1); + //$routerPlugin = new Ostacium_Controller_Plugin_Router($acl, $_config->auth->noauth->toArray(), $_config->auth->noacl->toArray()); + //$frontController->registerPlugin($routerPlugin, -1); return $frontController; } @@ -131,7 +133,7 @@ protected function _setupConfig() { - $_config = new Zend_Config_Ini($this->_docroot . '/config/config.ini', $this->getEnvironment()); + $_config = new Zend_Config_Ini(self::$_docroot . '/config/config.ini', $this->getEnvironment()); error_reporting((int)$_config->error->report); ini_set('display_errors', (int)$_config->error->display); @@ -162,16 +164,15 @@ $frontController->throwExceptions((bool) $_config->error->throw); $frontController->setParam('environment', $this->_environment); $frontController->setModuleControllerDirectoryName('controllers'); - $frontController->addModuleDirectory($this->_docroot . '/application/modules/'); + $frontController->addModuleDirectory(self::$_docroot . '/application/modules/'); $frontController->setRequest('Ostacium_Controller_Request_Http'); + // Setup Authorication + $acl = $this->_setupAuth(); + // Error Handler $frontController->setParam('noErrorHandler', 1); - $frontController->registerPlugin(new Ostacium_Controller_Plugin_ErrorHandler(array( - 'module' => $_config->auth->noacl->module, - 'controller' => $_config->auth->noacl->controller, - 'action' => $_config->auth->noacl->action - ))); + $frontController->registerPlugin(new Ostacium_Controller_Plugin_ErrorHandler($acl, $_config->auth->noauth->toArray())); return $frontController; } @@ -181,18 +182,20 @@ $_config = Zend_Registry::get('config'); $options = $_config->view->toArray(); - $options['helperPath'] = $this->_docroot . '/' . $options['helperPath']; + $options['helperPath'] = self::$_docroot . '/' . $options['helperPath']; $view = new Zend_View($options); // Setup DocType $view->doctype('XHTML1_TRANSITIONAL'); + // Setup Title - $view->headTitle($_config->title)->setSeparator($_config->titlesep); + $view->headTitle($_config->general->title)->setSeparator($_config->general->titlesep); + // Setup Dojo Zend_Dojo::enableView($view); $options = $_config->layout->toArray(); - $options['layoutpath'] = $this->_docroot . '/' . $options['layoutpath']; + $options['layoutpath'] = self::$_docroot . '/' . $options['layoutpath']; Zend_Layout::startMvc($options + array('view' => $view)); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); @@ -205,6 +208,7 @@ $acl = new Ostacium_Acl($_config->auth->order); $auth = new Ostacium_Auth_Adapter_DbTable(Zend_Registry::get('db'), $_config->auth->table, $_config->auth->user, $_config->auth->pass, $_config->auth->passtreat); + $auth->setReferenceMap($_config->auth->referenceMap->toArray()); Zend_Registry::set('auth', $auth); @@ -219,11 +223,11 @@ $_db = Zend_Registry::get('db'); $_auth = Zend_Auth::getInstance(); - $translate = new Zend_Translate('csv', $this->_docroot . '/' . $_config->lang->path . $_config->lang->default . '.csv', $_config->lang->default); - foreach($_config->lang->langs as $lang) + $translate = new Zend_Translate('csv', self::$_docroot . '/' . $_config->lang->path . $_config->lang->default . '.csv', $_config->lang->default); + foreach ($_config->lang->langs as $lang) { if ($lang != $_config->lang->default) - $translate->addTranslation($this->_docroot . '/' . $_config->lang->path . $lang .'.csv', 'en'); + $translate->addTranslation(self::$_docroot . '/' . $_config->lang->path . $lang .'.csv', 'en'); } if ($_auth->hasIdentity()) @@ -240,7 +244,7 @@ $_config = Zend_Registry::get('config'); $router = $frontController->getRouter(); - $router->addRoute('default', new Ostacium_Controller_Router_Route_Language(array(), $frontController->getDispatcher(), $frontController->getRequest())); + $router->addRoute('default', new Ostacium_Controller_Router_Route_Language(array(), $frontController->getDispatcher(), $frontController->getRequest(), $_config->general->extention)); if ($_config->routes) $router->addConfig($_config->routes); Modified: website/library/Ostacium/Controller/Plugin/ErrorHandler.php =================================================================== --- website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-06 23:13:21 UTC (rev 435) @@ -3,33 +3,50 @@ class Ostacium_Controller_Plugin_ErrorHandler extends Zend_Controller_Plugin_ErrorHandler { protected $_isPreDispatch = false; + protected $_acl; + protected $_noauth = array( + 'controller' => 'index', + 'action' => 'login' + ); + + public function __construct($acl, $noauth = null) { + $this->_acl = $acl; + $this->_noauth = is_array($noauth) ? $noauth : $this->_noauth; + } const EXCEPTION_NOTALLOWED = 'EXCEPTION_NOTALLOWED'; public function preDispatch(Zend_Controller_Request_Abstract $request) - { + { $frontController = Zend_Controller_Front::getInstance(); $dispatcher = $frontController->getDispatcher(); $response = $this->getResponse(); $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $error->exception = current($response->getException()); - + if (!$dispatcher->isDispatchable($request)) { $error->type = self::EXCEPTION_NO_CONTROLLER; if (!$error->exception) $error->exception = new Zend_Controller_Dispatcher_Exception("Resource doesn't exist", 404); - } elseif (!$this->isProperAction($dispatcher, $request)) { + } elseif (!$this->isProperAction($dispatcher, $request) || !$this->existsResource($dispatcher, $request)) { $error->type = self::EXCEPTION_NO_ACTION; if (!$error->exception) $error->exception = new Zend_Controller_Dispatcher_Exception("Resource doesn't exist", 404); + } elseif (!$this->isAllowed($request)) { + if (!$auth->hasIdentity()) { + $request->setControllerName($this->_noauth['controller']); + $request->setActionName($this->_noauth['action']); + $request->setParam('message', 'nologin'); + + return $request; + } + + $error->type = self::EXCEPTION_NOTALLOWED; + if (!$error->exception) + $error->exception = new Zend_Controller_Dispatcher_Exception("No rights to access the resouce", 403); } elseif ($error->exception) { $error->type = self::EXCEPTION_OTHER; - } elseif ($request->getParam('error_message') != "") - { - $error->type = self::EXCEPTION_NOTALLOWED; - if (!$error->exception) - $error->exception = new Ostacium_Controller_Plugin_Router_Exception("No rights to access the resouce", 403); } if (isset($error->type)) { @@ -103,7 +120,7 @@ } } - public function isProperAction($dispatcher, $request) + public function isProperAction($dispatcher, Zend_Controller_Request_Abstract $request) { $className = $dispatcher->loadClass($dispatcher->getControllerClass($request)); $actionName = $request->getActionName(); @@ -121,4 +138,42 @@ return false; } + + public function existsResource($dispatcher, Zend_Controller_Request_Abstract $request) + { + $controller = $request->getControllerName(); + $action = $request->getActionName(); + $module = $request->getModuleName(); + $resource = ($module != 'default' ? $module . ':' . $controller : $controller); + + if (!$this->_acl->has($resource) || !$dispatcher->isDispatchable($request) || !$this->isProperAction($dispatcher, $request)) + { + return false; + } + + return true; + } + + public function isAllowed(Zend_Controller_Request_Abstract $request) + { + $auth = Zend_Auth::getInstance(); + $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); + + if ($auth->hasIdentity()) { + $role = $this->_acl->getRoleById($auth->getIdentity()->roleid) ? $this->_acl->getRoleById($auth->getIdentity()->roleid) : 'guest'; + } else { + $role = 'guest'; + } + + $controller = $request->getControllerName(); + $action = $request->getActionName(); + $module = $request->getModuleName(); + $resource = ($module != 'default' ? $module . ':' . $controller : $controller); + + + if (!$this->_acl->isAllowed($role, $resource, $action)) + return false; + + return true; + } } \ No newline at end of file Modified: website/library/Ostacium/Controller/Router/Route/Language.php =================================================================== --- website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-06 23:13:21 UTC (rev 435) @@ -4,17 +4,20 @@ { protected $translate; protected $config; + protected $extention; protected $_languageKey = 'language'; public function __construct(array $defaults = array(), Zend_Controller_Dispatcher_Interface $dispatcher = null, - Zend_Controller_Request_Abstract $request = null) + Zend_Controller_Request_Abstract $request = null, + $extention = null) { parent::__construct($defaults, $dispatcher, $request); $this->translate = Zend_Registry::get('Zend_Translate'); $this->config = Zend_Registry::get('config'); + $this->extention = $extention; } protected function _setRequestKeys() @@ -36,6 +39,13 @@ $values = array(); $params = array(); $path = trim($path, self::URI_DELIMITER); + + if ($this->extention) + { + $ext = strrchr($path, '.' . $this->extention); + if ($ext) $path = substr($path, 0, -strlen($ext)); + //else $path = ''; + } if ($path != '') { $path = explode(self::URI_DELIMITER, $path); @@ -133,6 +143,11 @@ if ($encode) $language = urlencode($language); $url = '/' . $language . $url; } + + if (!empty($url) && substr($url, 0, -1) != '/' && $this->extention) + { + $url .= '.' . $this->extention; + } return ltrim($url, self::URI_DELIMITER); } Modified: website/library/Ostacium/Db/Table.php =================================================================== --- website/library/Ostacium/Db/Table.php 2008-12-06 13:12:31 UTC (rev 434) +++ website/library/Ostacium/Db/Table.php 2008-12-06 23:13:21 UTC (rev 435) @@ -49,10 +49,26 @@ return $query->fetchColumn(); } + public function selectLang(array $cols = array()) + { + $translate = Zend_Registry::get('Zend_Translate'); + $_config = Zend_Registry::get('config'); + $columns = array(); + + foreach ($cols as $col) + { + $columns[] = 'IF (l.id, l.'.$col.', d.'.$col.') AS '.$col; + } + + return $this->select()->setIntegrityCheck(false)->from($this->_name, array('*', implode(', ', $columns))) + ->joinLeft(array('d' => $this->_name.'_lang'), 'd.id = '.$this->_name.'.id AND d.langcode = \''.$_config->lang->default.'\'', array()) + ->joinLeft(array('l' => $this->_name.'_lang'), 'l.id = '.$this->_name.'.id AND l.langcode = \''.$translate->getLocale().'\'', array()); + } + protected function _dataFilter(&$data) { if(empty($this->_cols)) { - $this->_setupMetadata(); + $this->_getCols(); } $data = array_intersect_key($data, array_flip($this->_cols)); Property changes on: website/other/submits ___________________________________________________________________ Added: tsvn:logminsize + 5 Modified: website/other/todo.txt =================================================================== --- website/other/todo.txt 2008-12-06 13:12:31 UTC (rev 434) +++ website/other/todo.txt 2008-12-06 23:13:21 UTC (rev 435) @@ -1,10 +1,10 @@ -1. Add Zend_Log, write - undecided, FILE? DB? ++/-1. Add Zend_Log, write - undecided, FILE? DB? 2. Design Change 3. Ostacium_CrudAction redesign 4. Ostacium_View_Helper_listTable redesign 5. Front_Controller => catch Exception => go to Error Controller 6. Caching for DB, VIEW, etc. -7. Table Prefix - відложено +-7. Table Prefix - відложено 8. Custom Admin Email 9. Add mb_ support to everything 10!. _authenticateCreateSelect - quote the reference! how? Property changes on: website/other/uploads ___________________________________________________________________ Added: tsvn:logminsize + 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-12-06 13:12:38
|
Revision: 434 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=434&view=rev Author: Oracle_ Date: 2008-12-06 13:12:31 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Added C++ compiler. Added support of LangIDs. Made some small changes to code - now it is a bit more readable. Fixed bug with case sensitivity in SysCallSecure. Modified Paths: -------------- ACMServer/trunk/sharp tester/SourceTest 2.0/Load/LoaderClass.cs ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/Program.cs ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/AllowedFunc.txt ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/InData.txt ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.cpp ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.h ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.cpp ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.h ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp Added Paths: ----------- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/CompIDs.txt ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/D7.bat ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/DCC32.exe here.txt ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/dcc32.cfg ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/rlink32.dll here.txt ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/VS.bat ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/includeVS/ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/includeVS/includes here.txt Removed Paths: ------------- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7.bat ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/DCC32.exe here.txt ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/dcc32.cfg ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/includeD7/ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/rlink32.dll here.txt Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Load/LoaderClass.cs =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Load/LoaderClass.cs 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Load/LoaderClass.cs 2008-12-06 13:12:31 UTC (rev 434) @@ -9,19 +9,19 @@ public class DataLoader { public string path; - public int CodeLimit=65536; - public int CompilationTimeLimit=10000; - public int MemoryLimit=67108864; - public int OutputLimit=20000000; - public int RealTimeLimit=20000; - public int TimeLimit=1000; - public int MaxThreads=2; - public int PerTestCount=2; - public string InputName="in.txt"; - public string OutputName="out.txt"; - public string PointFileName="points.txt"; - public string TestFolderName="test*"; - public string Checker=""; + public int CodeLimit = 65536; + public int CompilationTimeLimit = 10000; + public int MemoryLimit = 67108864; + public int OutputLimit = 20000000; + public int RealTimeLimit = 20000; + public int TimeLimit = 1000; + public int MaxThreads = 2; + public int PerTestCount = 2; + public string InputName = "in.txt"; + public string OutputName = "out.txt"; + public string PointFileName = "points.txt"; + public string TestFolderName = "test*"; + public string Checker = ""; public string CheckPlugin = ""; public DataLoader(string Path) @@ -36,7 +36,7 @@ StreamReader f = File.OpenText(path); while (!f.EndOfStream) { - string[] param=f.ReadLine().Split(' '); + string[] param = f.ReadLine().Split(' '); if (param.Length < 2) continue; try { @@ -88,14 +88,22 @@ OutPath = outname; PointPath = pointname; if (File.Exists(inname)) - input = File.OpenText(inname).ReadToEnd(); + { + input = File.OpenText(inname).ReadToEnd(); + } else + { input = ""; + } if (File.Exists(outname)) + { output = File.OpenText(outname).ReadToEnd(); + } else + { output = ""; + } if (File.Exists(pointname)) { @@ -109,7 +117,9 @@ } } else + { points = 1; + } } } @@ -118,8 +128,10 @@ private string MaskToString(string mask, int numb) { int star; - if ((star=mask.IndexOf('*')) == -1) + if ((star = mask.IndexOf('*')) == -1) + { return mask; + } int cnt=0; while (star < mask.Length && mask[star] == '*') { @@ -127,8 +139,11 @@ cnt++; } string NS = numb.ToString(); - while (NS.Length < cnt) NS = '0' + NS; - return mask.Replace(mask.Substring(star - cnt, cnt), NS); ; + while (NS.Length < cnt) + { + NS = '0' + NS; + } + return mask.Replace(mask.Substring(star - cnt, cnt), NS); } public string InName; @@ -155,8 +170,10 @@ string curInPath = ProblemPath + MaskToString(FolderName,cnt+1)+"\\"+MaskToString(InName,cnt+1); string curOutPath = ProblemPath + MaskToString(FolderName, cnt+1) + "\\" + MaskToString(OutName, cnt+1); string curPointPath = ProblemPath + MaskToString(FolderName, cnt+1) + "\\" + MaskToString(PointName, cnt+1); - if (File.Exists(curInPath)||File.Exists(curOutPath)||File.Exists(curPointPath)) - cnt++; + if (File.Exists(curInPath) || File.Exists(curOutPath) || File.Exists(curPointPath)) + { + cnt++; + } else break; } Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs 2008-12-06 13:12:31 UTC (rev 434) @@ -1,4 +1,9 @@ -using System; +/* + This file includes definition of class TestEnv, that encapsulates all features of Tester. + Only this file should be used by user. +*/ + +using System; using System.IO; using Test; using Load; @@ -16,25 +21,27 @@ { public string ProblemPath; public string TempPath; - public string CompPath; + public int LangID; //language ID, that stores in CompIDs.txt public string Source; public Compiler comp; public Runner run; - public TestEnv(string Source,string CompPath,string TempPath,string ProblemPath) + public TestEnv(string Source,int LangID,string TempPath,string ProblemPath) { try { this.Source = Source; this.TempPath = Path.GetFullPath(TempPath); if (!Directory.Exists(this.TempPath)) + { Directory.CreateDirectory(this.TempPath); - this.CompPath = Path.GetFullPath(CompPath); - if (!File.Exists(this.CompPath)) - throw new FileNotFoundException("Compiler file do not exists!"); + } + this.LangID = LangID; this.ProblemPath = Path.GetFullPath(ProblemPath); if (!Directory.Exists(this.ProblemPath)) + { throw new DirectoryNotFoundException("Problem path do not exists!"); + } } catch (Exception e) { @@ -49,16 +56,24 @@ if (comp == null) { if (!File.Exists(ProblemPath + "ProblemData.txt")) + { throw new FileNotFoundException("ProblemData.txt do not exists"); + } DataLoader dat = new DataLoader(ProblemPath + "ProblemData.txt"); if (!dat.Load()) + { throw new FileLoadException("Can not load data from ProblemData.txt"); + } if (!File.Exists("TesterInData.txt")) + { throw new FileNotFoundException("TesterInData.txt do not exists"); + } string[] InData = System.IO.File.ReadAllLines("TesterInData.txt"); if (InData.Length < 1) + { throw new FileLoadException("Can not load data from ProblemData.txt"); + } int buf; try { @@ -69,7 +84,7 @@ throw new FileLoadException("Can not load sleep time from TesterInData.txt " + e.Message); } - comp = new Compiler(CompPath, Source, TempPath, dat.CompilationTimeLimit, buf); + comp = new Compiler(LangID, Source, TempPath, dat.CompilationTimeLimit, buf); } comp.Compile(); } @@ -83,6 +98,7 @@ { RunAllTests(SecureType.Double,true); } + public void RunAllTests(SecureType SecType) { RunAllTests(SecType,true); @@ -95,7 +111,9 @@ if (run == null) { if (comp == null) + { throw new TesterException("You should first compile source before running tests!"); + } run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP); } run.TestAll = TestAll; @@ -119,7 +137,9 @@ if (run == null) { if (comp == null) + { throw new TesterException("You should first compile source before running tests!"); + } run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP); } run.ExecuteTest(index); Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/Program.cs =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/Program.cs 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/Program.cs 2008-12-06 13:12:31 UTC (rev 434) @@ -1,4 +1,8 @@ -using System; +/* + This file is just a small program, used to test all features of tester. +*/ + +using System; using System.Collections.Generic; using System.Text; using System.IO; @@ -13,10 +17,10 @@ { Console.SetOut(File.CreateText("D:\\logout.txt")); string[] data=File.ReadAllLines("InData.txt"); - for (int ind = 1; ind <= 5; ind++) + for (int ind = 1; ind <= 1; ind++) { string src = File.ReadAllText("src\\source" + ind.ToString() + ".txt"); - TestEnv test = new TestEnv(src, data[0], data[1], data[2]); + TestEnv test = new TestEnv(src, Convert.ToInt32(data[0]), data[1], data[2]); test.Compile(); Console.WriteLine("------------------BEGIN SOURCE #"+ind.ToString()+"--------------------------"); Console.WriteLine(src); Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/AllowedFunc.txt =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/AllowedFunc.txt 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/AllowedFunc.txt 2008-12-06 13:12:31 UTC (rev 434) @@ -54,4 +54,52 @@ kernel32.dll GetFileSize kernel32.dll GetFileType kernel32.dll CreateFileA -kernel32.dll CloseHandle \ No newline at end of file +kernel32.dll CloseHandle + +kernel32.dll HeapFree +kernel32.dll HeapAlloc +kernel32.dll GetProcessHeap +kernel32.dll FreeEnvironmentStringsA +kernel32.dll GetEnvironmentStrings +kernel32.dll FreeEnvironmentStringsW +kernel32.dll GetEnvironmentStringsW +kernel32.dll SetHandleCount +kernel32.dll TlsAlloc +kernel32.dll TlsFree +kernel32.dll InterlockedIncrement +kernel32.dll SetLastError +kernel32.dll InterlockedDecrement +kernel32.dll HeapDestroy +kernel32.dll HeapCreate +kernel32.dll QueryPerformanceCounter +kernel32.dll GetTickCount +kernel32.dll GetCurrentProcessId +kernel32.dll GetSystemTimeAsFileTime +kernel32.dll TerminateProcess +kernel32.dll GetCurrentProcess +kernel32.dll SetUnhandledExceptionFilter +kernel32.dll IsDebuggerPresent +kernel32.dll LoadLibraryA +kernel32.dll Sleep +kernel32.dll GetOEMCP +kernel32.dll HeapReAlloc +kernel32.dll HeapSize +kernel32.dll MultiByteToWideChar +kernel32.dll LCMapStringA +kernel32.dll LCMapStringW +kernel32.dll GetStringTypeA +kernel32.dll GetStringTypeW + +kernel32.dll InterlockedExchange +kernel32.dll GetUserDefaultLCID +kernel32.dll EnumSystemLocalesA +kernel32.dll IsValidLocale +kernel32.dll IsValidCodePage +kernel32.dll GetConsoleCP +kernel32.dll GetConsoleMode +kernel32.dll FlushFileBuffers +kernel32.dll GetLocaleInfoW +kernel32.dll WriteConsoleA +kernel32.dll GetConsoleOutputCP +kernel32.dll WriteConsoleW +kernel32.dll SetStdHandle \ No newline at end of file Added: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/CompIDs.txt =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/CompIDs.txt (rev 0) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/CompIDs.txt 2008-12-06 13:12:31 UTC (rev 434) @@ -0,0 +1,2 @@ +1 Compiler\VC6\VS.bat +2 Compiler\D7\D7.bat \ No newline at end of file Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/InData.txt =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/InData.txt 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/InData.txt 2008-12-06 13:12:31 UTC (rev 434) @@ -1,3 +1,3 @@ -Compiler\D7.bat +1 Temp\ Problem\ \ No newline at end of file Property changes on: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7 ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/D7.bat =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/D7.bat (rev 0) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/D7.bat 2008-12-06 13:12:31 UTC (rev 434) @@ -0,0 +1 @@ +DCC32.EXE -CC %1 -E%2 \ No newline at end of file Added: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/dcc32.cfg =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/dcc32.cfg (rev 0) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7/dcc32.cfg 2008-12-06 13:12:31 UTC (rev 434) @@ -0,0 +1 @@ +-u"includeD7" Deleted: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7.bat =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7.bat 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/D7.bat 2008-12-06 13:12:31 UTC (rev 434) @@ -1 +0,0 @@ -DCC32.EXE -CC %1 -E%2 \ No newline at end of file Property changes on: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6 ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/VS.bat =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/VS.bat (rev 0) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/VS.bat 2008-12-06 13:12:31 UTC (rev 434) @@ -0,0 +1 @@ +cl /EHsc /TP /Za /O1 /IincludeVS /D ONLINE_JUDGE /Fe%2source.exe" %1 /link /LIBPATH:includeVS \ No newline at end of file Property changes on: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/VC6/includeVS ___________________________________________________________________ Added: tsvn:logminsize + 5 Deleted: ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/dcc32.cfg =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/dcc32.cfg 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/SourceTest 2.0/bin/Debug/compiler/dcc32.cfg 2008-12-06 13:12:31 UTC (rev 434) @@ -1 +0,0 @@ --u"includeD7" Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.cpp 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.cpp 2008-12-06 13:12:31 UTC (rev 434) @@ -3,9 +3,50 @@ using namespace System::IO; using namespace System::Diagnostics; -Compiler::Compiler(String^ CompPath, String^ Source, String^ TempPath, int CompilationTimeLimit, int WaitForFile) +String^ Compiler::GetCompFromID(int LangID) //resolves ID to compiler's path { - comppath=CompPath; + if (!File::Exists("CompIDs.txt")) + { + throw gcnew FileNotFoundException("Can not find file CompIDs.txt"); + } + StreamReader^ f = File::OpenText("CompIDs.txt"); + String^ res = ""; + while (!f->EndOfStream) + { + array<String^>^ param = f->ReadLine()->Split(' '); + if (param->Length < 2) continue; + try + { + int curID = Convert::ToInt32(param[0]); + if (curID == LangID) + { + res=""; + for (int i=1;i<param->Length;i++) + { + res += param[i]+" "; + } + } + } + catch (System::Exception^) + { + throw gcnew FileLoadException("Can not load data from CompIDs.txt"); + } + } + if (res=="") + { + throw gcnew FileLoadException("Can not load data from CompIDs.txt"); + } + return res; +} + +Compiler::Compiler(int LangID, String^ Source, String^ TempPath, int CompilationTimeLimit, int WaitForFile) +{ + comppath=GetCompFromID(LangID); + comppath=Path::GetFullPath(comppath); + if (!File::Exists(comppath)) + { + throw gcnew FileNotFoundException("Can not find compiler!"); + } source=Source; temp=TempPath; ExeFile=TempPath+"source.exe"; @@ -42,9 +83,15 @@ System::Threading::Thread::Sleep(CONST_SLEEP); for (int i=0;i<CONST_SLEEP;i++) + { if (!File::Exists(srcpath)) - System::Threading::Thread::Sleep(5); else + { + System::Threading::Thread::Sleep(5); + } else + { break; + } + } si->FileName=comppath; si->Arguments="\""+srcpath+"\" \""+temp; @@ -63,9 +110,15 @@ UsedTime=comp->TotalProcessorTime; for (int i=0;i<CONST_SLEEP;i++) + { if (!File::Exists(ExeFile)) - System::Threading::Thread::Sleep(5); else + { + System::Threading::Thread::Sleep(5); + } else + { break; + } + } if (!File::Exists(ExeFile)) //compilation error { Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.h =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.h 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/CompileClass.h 2008-12-06 13:12:31 UTC (rev 434) @@ -22,6 +22,7 @@ String^ comppath; String^ source; String^ temp; + String^ GetCompFromID(int LangID); public: String^ Details; CompRes Result; @@ -31,7 +32,7 @@ int TL; int CONST_SLEEP; - Compiler(String^ CompPath, String^ Source, String^ TempPath, int CompilationTimeLimit, int WaitForFile); + Compiler(int LangID, String^ Source, String^ TempPath, int CompilationTimeLimit, int WaitForFile); void Compile(); }; } \ No newline at end of file Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.cpp 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.cpp 2008-12-06 13:12:31 UTC (rev 434) @@ -8,9 +8,9 @@ UserSecure::UserSecure() { - process=NULL; - thread=NULL; - err=0; + process=NULL; + thread=NULL; + err=0; } BOOL UserSecure::SetUserObjectFullAccess(HANDLE hUserObject) @@ -39,86 +39,92 @@ bool UserSecure::Init(LPWSTR lpApplicationName) { - FILE* f=_wfopen(L"TesterInData.txt",L"r"); - if (f==NULL) - { - Details="Cannot open TesterInData.txt"; - return false; - } - int buf=0; - fwscanf(f,L"%d %s %s",&buf,&USER_NAME,&USER_PASSW); - fclose(f); + FILE* f=_wfopen(L"TesterInData.txt",L"r"); + if (f==NULL) + { + Details="Cannot open TesterInData.txt"; + return false; + } + int buf=0; + fwscanf(f,L"%d %s %s",&buf,&USER_NAME,&USER_PASSW); + fclose(f); - if (!SetUserObjectFullAccess(GetThreadDesktop(GetCurrentThreadId()))) - { - Details="Cannot SetUserObjectFullAccess(GetThreadDesktop(GetCurrentThreadId())). Error#"+ToStr(GetLastError()); - return false; //needed for accessing from CreateProcessAsUser - } - if (!SetUserObjectFullAccess( GetProcessWindowStation())) - { - Details="Cannot SetUserObjectFullAccess( GetProcessWindowStation()). Error#"+ToStr(GetLastError()); - return false; //needed for accessing from CreateProcessAsUser - } + if (!SetUserObjectFullAccess(GetThreadDesktop(GetCurrentThreadId()))) + { + Details="Cannot SetUserObjectFullAccess(GetThreadDesktop(GetCurrentThreadId())). Error#"+ToStr(GetLastError()); + return false; //needed for accessing from CreateProcessAsUser + } + if (!SetUserObjectFullAccess( GetProcessWindowStation())) + { + Details="Cannot SetUserObjectFullAccess(GetProcessWindowStation()). Error#"+ToStr(GetLastError()); + return false; //needed for accessing from CreateProcessAsUser + } - USER_INFO_1 ui; - NET_API_STATUS st; - ui.usri1_comment=NULL; - ui.usri1_flags=UF_SCRIPT|UF_PASSWD_CANT_CHANGE|UF_DONT_EXPIRE_PASSWD; - ui.usri1_home_dir=NULL; - ui.usri1_name=USER_NAME; - ui.usri1_password=USER_PASSW; - ui.usri1_priv=USER_PRIV_USER; - ui.usri1_script_path=NULL; - st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); //trying to create new user - bool userex=false; - if (st!=NERR_Success) - { - if (st==NERR_UserExists) - userex=true; else - { - Details="Cannot create user. Error#"+ToStr(GetLastError()); - return false; - } - } - if (!userex) - { - array<DriveInfo^>^ drv=DriveInfo::GetDrives(); - for (int i=0;i<drv->Length;i++) //for all fixed drives set limitation - if (drv[i]->DriveType==DriveType::Fixed) - DenyAccessFolder(drv[i]->Name); - wchar_t buf[MAX_PATH+1]; - GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetWindowsDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetSystemDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - DWORD size=MAX_PATH; - GetProfilesDirectory(buf,&size); - DenyAccessFolder(gcnew String(buf)); - Details="User created. "; - } else - Details="User exists. "; - return true; + USER_INFO_1 ui; + NET_API_STATUS st; + ui.usri1_comment=NULL; + ui.usri1_flags=UF_SCRIPT|UF_PASSWD_CANT_CHANGE|UF_DONT_EXPIRE_PASSWD; + ui.usri1_home_dir=NULL; + ui.usri1_name=USER_NAME; + ui.usri1_password=USER_PASSW; + ui.usri1_priv=USER_PRIV_USER; + ui.usri1_script_path=NULL; + st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); //trying to create new user + bool userex=false; + if (st!=NERR_Success) + { + if (st==NERR_UserExists) + { + userex=true; + } else + { + Details="Cannot create user. Error#"+ToStr(GetLastError()); + return false; + } + } + if (!userex) + { + array<DriveInfo^>^ drv=DriveInfo::GetDrives(); + for (int i=0;i<drv->Length;i++) //for all fixed drives set limitation + { + if (drv[i]->DriveType==DriveType::Fixed) + { + DenyAccessFolder(drv[i]->Name); + } + } + wchar_t buf[MAX_PATH+1]; + GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetWindowsDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetSystemDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + DWORD size=MAX_PATH; + GetProfilesDirectory(buf,&size); + DenyAccessFolder(gcnew String(buf)); + Details="User created. "; + } else + Details="User exists. "; + return true; } BOOL UserSecure::AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) { -TOKEN_PRIVILEGES tp; -LUID luid; -if (!LookupPrivilegeValue( NULL,lpszPrivilege,&luid)) - return FALSE; -tp.PrivilegeCount = 1; -tp.Privileges[0].Luid = luid; -tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + TOKEN_PRIVILEGES tp; + LUID luid; + if (!LookupPrivilegeValue( NULL,lpszPrivilege,&luid)) + return FALSE; + tp.PrivilegeCount = 1; + tp.Privileges[0].Luid = luid; + tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; -if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) - return FALSE; -if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) - return FALSE; -return TRUE; + if (!AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES)NULL,(PDWORD)NULL)) + return FALSE; + if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) + return FALSE; + return TRUE; } bool UserSecure::CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo) @@ -186,151 +192,153 @@ bool UserSecure::CheckSecure() { - return false; //NoDF + return false; //NoDF } void UserSecure::Finalize() { - if (process!=NULL) - CloseHandle(process); - if (thread!=NULL) - CloseHandle(thread); + if (process!=NULL) + CloseHandle(process); + if (thread!=NULL) + CloseHandle(thread); } SysCallSecure::SysCallSecure() { -process=NULL; -thread=NULL; -err=0; + process=NULL; + thread=NULL; + err=0; } bool SysCallSecure::Init(LPWSTR lpApplicationName) { -HasDF=false; -FILE* f=fopen("AllowedFunc.txt","r"); -if (f==NULL) -{ - Details="Cannot open AllowedFunc.txt"; - return false; -} -vector<TFunc> allowed; -char mod_name[256],func_name[256]; -while (fscanf(f,"%s %s",mod_name,func_name)==2) -{ - TFunc func; - func.Name=func_name; - func.Module=mod_name; - allowed.push_back(func); -} -fclose(f); + HasDF=false; + FILE* f=fopen("AllowedFunc.txt","r"); + if (f==NULL) + { + Details="Cannot open AllowedFunc.txt"; + return false; + } + vector<TFunc> allowed; + char mod_name[256],func_name[256]; + while (fscanf(f,"%s %s",mod_name,func_name)==2) + { + TFunc func; + strcpy_s(func.Name,256,func_name); + strcpy_s(func.Module,256,mod_name); + allowed.push_back(func); + } + fclose(f); -HMODULE hmodCaller=LoadLibrary(lpApplicationName); -if (hmodCaller==NULL) -{ - Details="Can not load module. Error#"+ToStr(err=GetLastError()); - return false; -} -ULONG ulSize; -PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hmodCaller,TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&ulSize); -if (pImportDesc!=NULL) -{ -for (;pImportDesc->Name; pImportDesc++) -{ - PSTR pszModName = (PSTR)((PBYTE) hmodCaller + pImportDesc->Name); - PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)((PBYTE) hmodCaller + pImportDesc->FirstThunk); - for (; pThunk->u1.Function; pThunk++) - { - if ((pThunk->u1.Function&(1<<31))!=0) - continue; - PSTR NAME=(PSTR)((PIMAGE_IMPORT_BY_NAME)((PBYTE)hmodCaller+pThunk->u1.AddressOfData))->Name; - - bool allow=false; - for (unsigned i=0;i<allowed.size();i++) - if ((allowed[i].Name==string(NAME))&&(allowed[i].Module==string(pszModName))) + HMODULE hmodCaller=LoadLibrary(lpApplicationName); + if (hmodCaller==NULL) { - allow=true; - break; + Details="Can not load module. Error#"+ToStr(err=GetLastError()); + return false; } - if (!allow) - { - HasDF=true; - Details="Import DF. \""+string(NAME)+"\" from module \""+string(pszModName)+"\" "; - FreeLibrary(hmodCaller); - return true; - } - } + ULONG ulSize; + PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hmodCaller,TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&ulSize); + if (pImportDesc!=NULL) + { + for (;pImportDesc->Name; pImportDesc++) + { + PSTR pszModName = (PSTR)((PBYTE) hmodCaller + pImportDesc->Name); + PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)((PBYTE) hmodCaller + pImportDesc->FirstThunk); + for (; pThunk->u1.Function; pThunk++) + { + if ((pThunk->u1.Function&(1<<31))!=0) + continue; + PSTR NAME=(PSTR)((PIMAGE_IMPORT_BY_NAME)((PBYTE)hmodCaller+pThunk->u1.AddressOfData))->Name; + + bool allow=false; + for (unsigned i=0;i<allowed.size();i++) + { + if ((strcmp(allowed[i].Name,NAME)==0)&&(stricmp(allowed[i].Module,pszModName)==0)) + { + allow=true; + break; + } + } + if (!allow) + { + HasDF=true; + Details="Import DF. \""+string(NAME)+"\" from module \""+string(pszModName)+"\" "; + FreeLibrary(hmodCaller); + return true; + } + } + } + } + FreeLibrary(hmodCaller); + return true; } -} -FreeLibrary(hmodCaller); -return true; -} bool SysCallSecure::CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo) { -PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); -if (!CreateProcess(lpApplicationName,NULL,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,&pi)) -{ - Details+="Cannot create process. Error#"+ToStr(err=GetLastError()); - return false; -} -process=pi.hProcess; -thread=pi.hThread; + PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); + if (!CreateProcess(lpApplicationName,NULL,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,&pi)) + { + Details+="Cannot create process. Error#"+ToStr(err=GetLastError()); + return false; + } + process=pi.hProcess; + thread=pi.hThread; -Details+="Process created."; -return true; + Details+="Process created."; + return true; } bool SysCallSecure::CheckSecure() { -return HasDF; + return HasDF; } void SysCallSecure::Finalize() { -if (process!=NULL) - CloseHandle(process); -if (thread!=NULL) - CloseHandle(thread); + if (process!=NULL) + CloseHandle(process); + if (thread!=NULL) + CloseHandle(thread); } NoneSecure::NoneSecure() { -process=NULL; -thread=NULL; -err=0; + process=NULL; + thread=NULL; + err=0; } bool NoneSecure::Init(LPWSTR lpApplicationName) { -return true; + return true; } bool NoneSecure::CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo) { -PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); -if (CreateProcess(lpApplicationName,NULL,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,&pi)) -{ - process=pi.hProcess; - thread=pi.hThread; - Details="Process created."; - return true; + PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); + if (CreateProcess(lpApplicationName,NULL,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,&pi)) + { + process=pi.hProcess; + thread=pi.hThread; + Details="Process created."; + return true; + } + err=GetLastError(); + Details="Cannot create process. Error#"+ToStr(err); + return false; } -err=GetLastError(); -Details="Cannot create process. Error#"+ToStr(err); -return false; -} bool NoneSecure::CheckSecure() { -return false; //No DF + return false; //No DF } void NoneSecure::Finalize() { -if (process!=NULL) - CloseHandle(process); -if (thread!=NULL) - CloseHandle(thread); + if (process!=NULL) + CloseHandle(process); + if (thread!=NULL) + CloseHandle(thread); } DoubleSecure::DoubleSecure() Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.h =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.h 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/SecureClass.h 2008-12-06 13:12:31 UTC (rev 434) @@ -13,16 +13,39 @@ { protected: int err; - string ToStr(int x) {char c[15]; _itoa_s(x,c,10); return string(c);}; + string ToStr(int x) + { + char c[15]; + _itoa_s(x,c,10); + return string(c); + }; + public: string Details; HANDLE process; HANDLE thread; - virtual bool Init(LPWSTR lpApplicationName) {return true;}; - virtual bool CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo) {return true;}; - virtual bool CheckSecure() {return true;}; + + virtual bool Init(LPWSTR lpApplicationName) + { + return true; + }; + + virtual bool CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo) + { + return true; + }; + + virtual bool CheckSecure() + { + return true; + }; + virtual void Finalize() {}; - virtual int LastError() {return err;}; + + virtual int LastError() + { + return err; + } }; public class UserSecure: public BasicSecure @@ -43,8 +66,8 @@ private struct TFunc { - string Name; - string Module; + char Name[256]; + char Module[256]; }; public class SysCallSecure:public BasicSecure @@ -69,7 +92,10 @@ bool CreateProc(LPWSTR lpApplicationName,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo); bool CheckSecure(); void Finalize(); - int LastError() {return syssec->LastError(); } + int LastError() + { + return syssec->LastError(); + } }; public class NoneSecure:public BasicSecure Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp 2008-11-07 10:17:40 UTC (rev 433) +++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp 2008-12-06 13:12:31 UTC (rev 434) @@ -11,16 +11,22 @@ SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); //for better testing initlock(); if (!File::Exists(ProblemPath + "ProblemData.txt")) + { throw gcnew FileNotFoundException("ProblemData not found!"); + } data = gcnew DataLoader(ProblemPath + "ProblemData.txt"); if (!data->Load()) + { throw gcnew FileLoadException("Can not load problem data!"); + } testfield=gcnew TestLoader(data->InputName,data->OutputName,data->PointFileName,data->TestFolderName,ProblemPath); testfield->Load(); results=gcnew array<TestRes^>(testfield->tests->Length); plug=gcnew PluginLoader(System::IO::Path::GetFullPath(data->CheckPlugin)); if (!plug->Load()) + { throw gcnew FileLoadException("Can not load Plugin!"); + } exe=ExeFile; prob=ProblemPath; temp=TempPath; @@ -31,288 +37,295 @@ bool Runner::ExecuteTest(int index) //returns false if not AC verdict { -STARTUPINFO si;ZeroMemory(&si,sizeof(si)); -SECURITY_ATTRIBUTES secdesc; -secdesc.bInheritHandle=TRUE; -secdesc.nLength=sizeof(secdesc); -secdesc.lpSecurityDescriptor=NULL; -JOBOBJECT_BASIC_ACCOUNTING_INFORMATION acc; -JOBOBJECT_EXTENDED_LIMIT_INFORMATION mem; -HANDLE job=NULL; -JOBOBJECT_ASSOCIATE_COMPLETION_PORT port; ZeroMemory(&port,sizeof(port)); -JOBOBJECT_BASIC_UI_RESTRICTIONS uilim; -DWORD len=0; -wchar_t* bufW; -TestRes^ result=gcnew TestRes(); -BasicSecure* sec=NULL; -try -{ - if (SecType==SecureType::None) - sec=new NoneSecure(); else - if (SecType==SecureType::User) - sec=new UserSecure(); else - if (SecType==SecureType::SysCall) - sec=new SysCallSecure(); else - if (SecType==SecureType::Double) - sec=new DoubleSecure(); - lock(); - String^ oupath=temp+"out"+index.ToString()+".txt"; - String^ erpath=temp+"err"+index.ToString()+".txt"; - unlock(); - String^ inpath=test->tests[index-1]->InPath; - - si.cb=sizeof(si); - si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - si.wShowWindow=FALSE; - si.hStdInput= CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(inpath).ToPointer(),GENERIC_READ,FILE_SHARE_READ,&secdesc,OPEN_EXISTING,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); - si.hStdOutput=CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(oupath).ToPointer(),GENERIC_WRITE,0,&secdesc,CREATE_ALWAYS,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); - si.hStdError=CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(erpath).ToPointer(),GENERIC_WRITE,FILE_SHARE_WRITE,&secdesc,CREATE_ALWAYS,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); + STARTUPINFO si;ZeroMemory(&si,sizeof(si)); + SECURITY_ATTRIBUTES secdesc; + secdesc.bInheritHandle=TRUE; + secdesc.nLength=sizeof(secdesc); + secdesc.lpSecurityDescriptor=NULL; + JOBOBJECT_BASIC_ACCOUNTING_INFORMATION acc; + JOBOBJECT_EXTENDED_LIMIT_INFORMATION mem; + HANDLE job=NULL; + JOBOBJECT_ASSOCIATE_COMPLETION_PORT port; ZeroMemory(&port,sizeof(port)); + JOBOBJECT_BASIC_UI_RESTRICTIONS uilim; + DWORD len=0; + wchar_t* bufW; + TestRes^ result=gcnew TestRes(); + BasicSecure* sec=NULL; + try + { + lock(); + if (SecType==SecureType::None) + sec=new NoneSecure(); else + if (SecType==SecureType::User) + sec=new UserSecure(); else + if (SecType==SecureType::SysCall) + sec=new SysCallSecure(); else + if (SecType==SecureType::Double) + sec=new DoubleSecure(); + String^ oupath=temp+"out"+index.ToString()+".txt"; + String^ erpath=temp+"err"+index.ToString()+".txt"; + unlock(); + String^ inpath=test->tests[index-1]->InPath; + + si.cb=sizeof(si); + si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + si.wShowWindow=FALSE; + si.hStdInput= CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(inpath).ToPointer(),GENERIC_READ,FILE_SHARE_READ,&secdesc,OPEN_EXISTING,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); + si.hStdOutput=CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(oupath).ToPointer(),GENERIC_WRITE,0,&secdesc,CREATE_ALWAYS,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); + si.hStdError=CreateFile(bufW=(wchar_t*)Marshal::StringToHGlobalUni(erpath).ToPointer(),GENERIC_WRITE,FILE_SHARE_WRITE,&secdesc,CREATE_ALWAYS,0,NULL); Marshal::FreeHGlobal(IntPtr(bufW)); - SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); - lock(); - bufW=(wchar_t*)Marshal::StringToHGlobalUni(exe).ToPointer(); - unlock(); + SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); + lock(); + bufW=(wchar_t*)Marshal::StringToHGlobalUni(exe).ToPointer(); + bool Succed=sec->Init(bufW); + unlock(); - if (!sec->Init(bufW)) - { - int err=sec->LastError(); - if ((err==193)||(err==1455)) + if (!Succed) { - result->res=TestResult::RuntimeError; - result->Details=gcnew String(sec->Details.c_str())+" Too large array"; - } else + int err=sec->LastError(); + if ((err==193)||(err==1455)) + { + result->res=TestResult::RuntimeError; + result->Details=gcnew String(sec->Details.c_str())+" Too large array"; + } else + { + result->res=TestResult::InternalError; + result->Details=gcnew String(sec->Details.c_str())+" Can not init secure"; + } + Marshal::FreeHGlobal(IntPtr(bufW)); + return false; + } + + if (sec->CheckSecure()) { - result->res=TestResult::InternalError; - result->Details=gcnew String(sec->Details.c_str())+" Can not init secure"; + result->res=TestResult::DestrictedFunction; + result->Details=gcnew String(sec->Details.c_str())+"Destricted function."; + Marshal::FreeHGlobal(IntPtr(bufW)); + return false; } - Marshal::FreeHGlobal(IntPtr(bufW)); - return false; - } - if (sec->CheckSecure()) - { - result->res=TestResult::DestrictedFunction; - result->Details=gcnew String(sec->Details.c_str())+"Destricted function."; - Marshal::FreeHGlobal(IntPtr(bufW)); - return false; - } - - if (!sec->CreateProc(bufW,TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|ABOVE_NORMAL_PRIORITY_CLASS,&si)) - { - Marshal::FreeHGlobal(IntPtr(bufW)); - int err=sec->LastError(); - if ((err==193)||(err==1455)) + if (!sec->CreateProc(bufW,TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|ABOVE_NORMAL_PRIORITY_CLASS,&si)) { - result->res=TestResult::RuntimeError; - result->Details=gcnew String(sec->Details.c_str())+" Too large array"; - } else - { - if (!sec->CheckSecure()) + Marshal::FreeHGlobal(IntPtr(bufW)); + int err=sec->LastError(); + if ((err==193)||(err==1455)) { - result->res=TestResult::InternalError; - result->Details=gcnew String(sec->Details.c_str())+" Can not start process"; + result->res=TestResult::RuntimeError; + result->Details=gcnew String(sec->Details.c_str())+" Too large array"; } else { - result->res=TestResult::DestrictedFunction; - result->Details=gcnew String(sec->Details.c_str())+" Destricted function"; + if (!sec->CheckSecure()) + { + result->res=TestResult::InternalError; + result->Details=gcnew String(sec->Details.c_str())+" Can not start process"; + } else + { + result->res=TestResult::DestrictedFunction; + result->Details=gcnew String(sec->Details.c_str())+" Destricted function"; + } } + return false; } - return false; - } - Marshal::FreeHGlobal(IntPtr(bufW)); + Marshal::FreeHGlobal(IntPtr(bufW)); - job=CreateJobObject(NULL,NULL); - mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_JOB_MEMORY; - mem.JobMemoryLimit=data->MemoryLimit; - SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); - port.CompletionKey=(void*)index; - port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); - SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); - - uilim.UIRestrictionsClass=JOB_OBJECT_UILIMIT_ALL; - SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); + job=CreateJobObject(NULL,NULL); + mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_JOB_MEMORY; + mem.JobMemoryLimit=data->MemoryLimit; + SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); + port.CompletionKey=(void*)index; + port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); + SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); + + uilim.UIRestrictionsClass=JOB_OBJECT_UILIMIT_ALL; + SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); - AssignProcessToJobObject(job,sec->process); + AssignProcessToJobObject(job,sec->process); - ResumeThread(sec->thread); + ResumeThread(sec->thread); - DWORD start=GetTickCount(); - while (true) - { + DWORD start=GetTickCount(); + while (true) + { + if (plug->p->OutputLimit((int)GetFileSize(si.hStdOutput,NULL),data->OutputLimit,result->Details)) + { + TerminateJobObject(job,0); + result->res=TestResult::OutputLimit; + break; + } + QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); + if (plug->p->RealTimeLimit((int)(GetTickCount()-start),data->RealTimeLimit,result->Details)) + { + TerminateJobObject(job,0); + result->res=TestResult::RealTimeLimit; + break; + } + if (plug->p->TimeLimit((int)((acc.TotalUserTime.QuadPart)/10000),data->TimeLimit,result->Details)) + { + TerminateJobObject(job,0); + result->res=TestResult::TimeLimit; + break; + } + + unsigned long len,key; + HANDLE proc; + if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&(key==index)) + { + DWORD code=0; + bool needbreak=false; + switch(len) + { + case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: + GetExitCodeProcess(sec->process,&code); + if (code==5) + { + result->res=TestResult::DestrictedFunction; + result->Details="Access denied."; + } else + if (code!=0) + { + result->res=TestResult::RuntimeError; + result->Details="Runtime error #"+code.ToString(); + } + needbreak=true; + break; + case JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: + result->res=TestResult::MemoryLimit; + result->Details="Memory Limit"; + needbreak=true; + break; + case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: + GetExitCodeProcess(sec->process,&code); + if (code==5) + { + result->res=TestResult::DestrictedFunction; + result->Details="Access denied."; + } else + if (code!=0) + { + result->res=TestResult::RuntimeError; + result->Details="Runtime error #"+code.ToString(); + } + needbreak=true; + break; + } + if (needbreak) + { + TerminateJobObject(job,0); + break; + } + } + Sleep(1); + } + + result->UsedRealTime=GetTickCount()-start; + QueryInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem),NULL); + QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); + result->UsedMemory=mem.PeakJobMemoryUsed; + result->UsedTime=(int)((acc.TotalUserTime.QuadPart)/10000); + + if (result->res!=TestResult::NotTested) + { + result->Details=gcnew String(sec->Details.c_str())+result->Details; + return false; + } + if (plug->p->OutputLimit((int)GetFileSize(si.hStdOutput,NULL),data->OutputLimit,result->Details)) { - TerminateJobObject(job,0); + result->Details=gcnew String(sec->Details.c_str())+result->Details; result->res=TestResult::OutputLimit; - break; + return false; } - QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); - if (plug->p->RealTimeLimit((int)(GetTickCount()-start),data->RealTimeLimit,result->Details)) + + if (plug->p->TimeLimit(result->UsedTime,data->TimeLimit,result->Details)) { - TerminateJobObject(job,0); + result->Details=gcnew String(sec->Details.c_str())+result->Details; + result->res=TestResult::TimeLimit; + return false; + } + + if (plug->p->RealTimeLimit(result->UsedRealTime,data->RealTimeLimit,result->Details)) + { + result->Details=gcnew String(sec->Details.c_str())+result->Details; result->res=TestResult::RealTimeLimit; - break; + return false; } - if (plug->p->TimeLimit((int)((acc.TotalUserTime.QuadPart)/10000),data->TimeLimit,result->Details)) + + if (plug->p->MemoryLimit(result->UsedMemory,data->MemoryLimit,result->Details)) { - TerminateJobObject(job,0); - result->res=TestResult::TimeLimit; - break; + result->Details=gcnew String(sec->Details.c_str())+result->Details; + result->res=TestResult::MemoryLimit; + return false; } - unsigned long len,key; - HANDLE proc; - if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&(key==index)) + CloseHandle(si.hStdOutput);si.hStdOutput=NULL; + CloseHandle(si.hStdInput);si.hStdInput=NULL; + + for (int i=0;i<CONST_SLEEP;i++) { - DWORD code=0; - bool needbreak=false; - switch(len) + if (!File::Exists(oupath)) { - case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: - GetExitCodeProcess(sec->process,&code); - if (code==5) - { - result->res=TestResult::DestrictedFunction; - result->Details="Access denied."; - } else - if (code!=0) - { - result->res=TestResult::RuntimeError; - result->Details="Runtime error #"+code.ToString(); - } - needbreak=true; - break; - case JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: - result->res=TestResult::MemoryLimit; - result->Details="Memory Limit"; - needbreak=true; - break; - case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: - GetExitCodeProcess(sec->process,&code); - if (code==5) - { - result->res=TestResult::DestrictedFunction; - result->Details="Access denied."; - } else - if (code!=0) - { - result->res=TestResult::RuntimeError; - result->Details="Runtime error #"+code.ToString(); - } - needbreak=true; - break; - } - if (needbreak) + Sleep(5); + } else { - TerminateJobObject(job,0); break; } } - Sleep(1); - } - result->UsedRealTime=GetTickCount()-start; - QueryInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem),NULL); - QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); - result->UsedMemory=mem.PeakJobMemoryUsed; - result->UsedTime=(int)((acc.TotalUserTime.QuadPart)/10000); + if (!File::Exists(oupath)) + { + result->res=TestResult::WrongAnswer; + result->Details=gcnew String(sec->Details.c_str())+" No output file"; + return false; + } - if (result->res!=TestResult::NotTested) - { - result->Details=gcnew String(sec->Details.c_str())+result->Details; - return false; - } + Checker^ check=gcnew Tester::Checker(Path::GetFullPath(data->Checker),test->tests[index-1]->input,ReadAllFile(oupath),test->tests[index-1]->output); - if (plug->p->OutputLimit((int)GetFileSize(si.hStdOutput,NULL),data->OutputLimit,result->Details)) - { + switch (check->Check()) + { + case CheckResult::OE: + result->res=TestResult::OutputError; + result->Details="Output Error"; + break; + case CheckResult::PE: + result->res=TestResult::PresentationError; + result->Details="Presentation Error"; + break; + case CheckResult::WA: + result->res=TestResult::WrongAnswer; + result->Details="Wrong Answer"; + break; + case CheckResult::AC: + result->res=TestResult::Accepted; + result->Details="Accepted"; + break; + }; result->Details=gcnew String(sec->Details.c_str())+result->Details; - result->res=TestResult::OutputLimit; - return false; - } - - if (plug->p->TimeLimit(result->UsedTime,data->TimeLimit,result->Details)) + if (result->res!=TestResult::Accepted) + return false; + return true; + }finally { - result->Details=gcnew String(sec->Details.c_str())+result->Details; - result->res=TestResult::TimeLimit; - return false; + lock(); + results[index-1]=result; + unlock(); + if (sec!=NULL) + { + sec->Finalize(); + delete sec; + } + if (si.hStdInput!=NULL) + CloseHandle(si.hStdInput); + if (si.hStdOutput!=NULL) + CloseHandle(si.hStdOutput); + if (si.hStdError!=NULL) + CloseHandle(si.hStdError); + if (port.CompletionPort!=NULL) + CloseHandle(port.CompletionPort); + if (job!=NULL) + CloseHandle(job); } - - if (plug->p->RealTimeLimit(result->UsedRealTime,data->RealTimeLimit,result->Details)) - { - result->Details=gcnew String(sec->Details.c_str())+result->Details; - result->res=TestResult::RealTimeLimit; - return false; - } - - if (plug->p->MemoryLimit(result->UsedMemory,data->MemoryLimit,result->Details)) - { - result->Details=gcnew String(sec->Details.c_str())+result->Details; - result->res=TestResult::MemoryLimit; - return false; - } - - CloseHandle(si.hStdOutput);si.hStdOutput=NULL; - CloseHandle(si.hStdInput);si.hStdInput=NULL; - - for (int i=0;i<CONST_SLEEP;i++) - if (!File::Exists(oupath)) - Sleep(5); else - break; - - if (!File::Exists(oupath)) - { - result->res=TestResult::WrongAnswer; - result->Details=gcnew String(sec->Details.c_str())+" No output file"; - return false; - } - - Checker^ check=gcnew Tester::Checker(Path::GetFullPath(data->Checker),test->tests[index-1]->input,ReadAllFile(oupath),test->tests[index-1]->output); - - switch (check->Check()) - { - case CheckResult::OE: - result->res=TestResult::OutputError; - result->Details="Output Error"; - break; - case CheckResult::PE: - result->res=TestResult::PresentationError; - result->Details="Presentation Error"; - break; - case CheckResult::WA: - result->res=TestResult::WrongAnswer; - result->Details="Wrong Answer"; - break; - case CheckResult::AC: - result->res=TestResult::Accepted; - result->Details="Accepted"; - break; - }; - result->Details=gcnew String(sec->Details.c_str())+result->Details; - if (result->res!=TestResult::Accepted) - return false; - return true; -}finally -{ - lock(); - results[index-1]=result; - unlock(); - if (sec!=NULL) - { - sec->Finalize(); - delete sec; - } - if (si.hStdInput!=NULL) - CloseHandle(si.hStdInput); - if (si.hStdOutput!=NULL) - CloseHandle(si.hStdOutput); - if (si.hStdError!=NULL) - CloseHandle(si.hStdError); - if (port.CompletionPort!=NULL) - CloseHandle(port.CompletionPort); - if (job!=NULL) - CloseHandle(job); } -} void Runner::ThreadProc() { @@ -325,7 +338,9 @@ if (n<=test->tests->Length) { if (!ExecuteTest(n)) + { StopTest=true; + } } else break; } @@ -351,7 +366,9 @@ void Runner::TerminateThreads() { for (int i=0;i<threads->Length;i++) + { threads[i]->Abort(); + } } Runner::~Runner() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-07 10:17:43
|
Revision: 433 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=433&view=rev Author: brus07 Date: 2008-11-07 10:17:40 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Fixed bug. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs 2008-11-07 00:21:23 UTC (rev 432) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs 2008-11-07 10:17:40 UTC (rev 433) @@ -68,6 +68,9 @@ OnAddLogText("Send", "ID " + res.Submit.id + " result - " + res.res); } + if (client == null) + return true; + return client.Send(message); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-07 00:21:30
|
Revision: 432 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=432&view=rev Author: brus07 Date: 2008-11-07 00:21:23 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Added new Plugin. In this plugin can submit source code from application, without web interface (this need for easy testing). Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties/AssemblyInfo.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.csproj ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.resx Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2008-11-06 11:48:11 UTC (rev 431) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2008-11-07 00:21:23 UTC (rev 432) @@ -31,6 +31,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocketClientGatePlugin", "Plugins\TesterPlugins\SocketClientGatePlugin\SocketClientGatePlugin.csproj", "{79EB24DD-AF0D-40D0-974E-198F4D8C92BC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubmitterGUIPlugin", "Plugins\TesterPlugins\SubmitterGUIPlugin\SubmitterGUIPlugin.csproj", "{E255910C-499D-48E2-9846-7EB24DE32C4A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,6 +83,10 @@ {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Debug|Any CPU.Build.0 = Debug|Any CPU {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Release|Any CPU.ActiveCfg = Release|Any CPU {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Release|Any CPU.Build.0 = Release|Any CPU + {E255910C-499D-48E2-9846-7EB24DE32C4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E255910C-499D-48E2-9846-7EB24DE32C4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E255910C-499D-48E2-9846-7EB24DE32C4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E255910C-499D-48E2-9846-7EB24DE32C4A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,5 +103,6 @@ {9462E3BD-67AD-4887-BF4C-8B6A25048941} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {8F305004-8FB7-4F85-8063-3A7041DB840F} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} {79EB24DD-AF0D-40D0-974E-198F4D8C92BC} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} + {E255910C-499D-48E2-9846-7EB24DE32C4A} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} EndGlobalSection EndGlobal Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin ___________________________________________________________________ Added: svn:ignore + bin obj Added: tsvn:logminsize + 5 Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/Properties/AssemblyInfo.cs 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SubmitterGUIPlugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("SubmitterGUIPlugin")] +[assembly: AssemblyCopyright("Copyright © Home 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("60412f5e-1284-4eb5-b14c-b659440dd84a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.cs 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,52 @@ +using System; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.LibraryExtention; +using AcmContester.Library.LibraryExtention.Data; + +namespace AcmContester.Plugins.TesterPlugins.SubmitterGUIPlugin +{ + public class SubmitterGUIPlugin : BaseMediatorPlugin + { + private int submitID = 0; + + public SubmitterGUIPlugin() + { + base.Control = new SubmitterGUIUserControl(); + ((SubmitterGUIUserControl)base.Control).SetPlugin(this); + } + + public bool SendSubmit(string sourceCode, int language) + { + Submit submit = new Submit(); + submitID++; + submit.id = submitID; + submit.sourceCode = sourceCode; + submit.language = language; + + SystemMessage message = new SystemMessage(submit.ToString(), "TestingSubmit"); + base.DataArrived(message); + + + string text = submit.id.ToString() + + Environment.NewLine + + submit.sourceCode; + ((SubmitterGUIUserControl)base.Control).AddText("Send", text); + + return true; + } + + public override void Send(SystemMessage message) + { + if (message.IsType("TestingResult") == true) + { + // ce pryjshow rezult testuvannja + Result result = Result.CreateFromXml(message.Message); + string text = result.Submit.id.ToString() + ": " + result.res + + Environment.NewLine + + "usedMemory:" + result.usedMemory.ToString() + " " + + "usedTime:" + result.usedTime.ToString(); + ((SubmitterGUIUserControl)base.Control).AddText("Receive", text); + } + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.csproj (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIPlugin.csproj 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,79 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{E255910C-499D-48E2-9846-7EB24DE32C4A}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SubmitterGUIPlugin</RootNamespace> + <AssemblyName>SubmitterGUIPlugin</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="LogDataGridView, Version=1.1.3198.29045, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\Resource\LogDataGridView.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SubmitterGUIPlugin.cs" /> + <Compile Include="SubmitterGUIUserControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="SubmitterGUIUserControl.Designer.cs"> + <DependentUpon>SubmitterGUIUserControl.cs</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Library\Data\Data.csproj"> + <Project>{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}</Project> + <Name>Data</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Library\LibraryExtention\LibraryExtention.csproj"> + <Project>{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}</Project> + <Name>LibraryExtention</Name> + </ProjectReference> + <ProjectReference Include="..\..\PluginsFramework\PluginsFramework.csproj"> + <Project>{69FB4176-F298-4AF7-B714-B6758AA9A58E}</Project> + <Name>PluginsFramework</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="SubmitterGUIUserControl.resx"> + <SubType>Designer</SubType> + <DependentUpon>SubmitterGUIUserControl.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.Designer.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.Designer.cs 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,113 @@ +namespace AcmContester.Plugins.TesterPlugins.SubmitterGUIPlugin +{ + partial class SubmitterGUIUserControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.sourceTextBox = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.languageTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Location = new System.Drawing.Point(3, 168); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(387, 164); + this.panel1.TabIndex = 0; + // + // sourceTextBox + // + this.sourceTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.sourceTextBox.Location = new System.Drawing.Point(3, 29); + this.sourceTextBox.Multiline = true; + this.sourceTextBox.Name = "sourceTextBox"; + this.sourceTextBox.Size = new System.Drawing.Size(387, 100); + this.sourceTextBox.TabIndex = 1; + this.sourceTextBox.Text = "begin\r\nend."; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(3, 135); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(387, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Submit"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // languageTextBox + // + this.languageTextBox.Enabled = false; + this.languageTextBox.Location = new System.Drawing.Point(64, 3); + this.languageTextBox.Name = "languageTextBox"; + this.languageTextBox.Size = new System.Drawing.Size(100, 20); + this.languageTextBox.TabIndex = 3; + this.languageTextBox.Text = "2"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 6); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Language"; + // + // SubmitterGUIUserControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Controls.Add(this.languageTextBox); + this.Controls.Add(this.button1); + this.Controls.Add(this.sourceTextBox); + this.Controls.Add(this.panel1); + this.Name = "SubmitterGUIUserControl"; + this.Size = new System.Drawing.Size(393, 335); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TextBox sourceTextBox; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox languageTextBox; + private System.Windows.Forms.Label label1; + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.cs 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; + +namespace AcmContester.Plugins.TesterPlugins.SubmitterGUIPlugin +{ + public partial class SubmitterGUIUserControl : UserControl + { + SubmitterGUIPlugin plugin; + + public SubmitterGUIUserControl() + { + InitializeComponent(); + initGridSe(); + } + + LogDataGridView.LogDataGridView view = new LogDataGridView.LogDataGridView(); + private void initGridSe() + { + view.Dock = DockStyle.Fill; + panel1.Controls.Add(view); + } + + public void SetPlugin(SubmitterGUIPlugin pl) + { + plugin = pl; + } + + + public void AddText(string type, string text) + { + view.AddRow(new LogDataGridView.SystemMessage(text, type)); + } + + private void button1_Click(object sender, EventArgs e) + { + int lang = Int32.Parse(languageTextBox.Text); + plugin.SendSubmit(sourceTextBox.Text, lang); + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.resx (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SubmitterGUIPlugin/SubmitterGUIUserControl.resx 2008-11-07 00:21:23 UTC (rev 432) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-06 12:01:41
|
Revision: 431 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=431&view=rev Author: brus07 Date: 2008-11-06 11:48:11 +0000 (Thu, 06 Nov 2008) Log Message: ----------- Added GUI to TestRunnerPlugin. LogDataGridView, counters of submits result. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.resx Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-11-06 09:53:57 UTC (rev 430) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-11-06 11:48:11 UTC (rev 431) @@ -17,9 +17,41 @@ private bool runner_onDataArrived(SystemMessage message) { - base.DataArrived(message); - return true; + if (message.IsType("TestingResult") == true) + { + SendResultToControl(message.Message, "Send"); + base.DataArrived(message); + return true; + } + throw new Exception(); } + private void SendResultType(string text) + { + ((TestRunnerUserControl)base.Control).AddResult(text); + } + private void SendMessageToControl(string text, string type) + { + ((TestRunnerUserControl)base.Control).AddText(type, text); + } + private void SendSubmitToControl(string text, string type) + { + Submit submit = Submit.CreateFromXml(text); + text = submit.id.ToString() + + Environment.NewLine + + submit.sourceCode; + ((TestRunnerUserControl)base.Control).AddText(type, text); + SendResultType("All"); + } + private void SendResultToControl(string text, string type) + { + Result result = Result.CreateFromXml(text); + text = result.Submit.id + ": " + result.res + + Environment.NewLine + + "usedMemory:" + result.usedMemory.ToString() + " " + + "usedTime:" + result.usedTime.ToString(); + ((TestRunnerUserControl)base.Control).AddText(type, text); + SendResultType(result.res); + } public override void Send(SystemMessage message) { @@ -27,6 +59,7 @@ { if (message.Message == "stop") { + SendMessageToControl("Stop", "SystemReceive"); runner.Stop(); return; } @@ -36,6 +69,7 @@ { if (message.Message == "isbusy") { + SendMessageToControl("isbusy", "SystemReceive"); SystemMessage mes; if (runner.IsBusy() == true) { @@ -45,21 +79,28 @@ { mes = new SystemMessage("free", "CheckStateResult"); } + SendMessageToControl(mes.Message, "SystemSend"); Send(mes); return; } } if (message.IsType("TestingSubmit") == true) + { + SendSubmitToControl(message.Message, "Receive"); runner.AddWork(message.Message); + } if (message.IsType("TestingSubmitList") == true) { + SendMessageToControl("TestingSubmitList", "Receive"); + SubmitList list = SubmitList.CreateFromXml(message.Message); for (int i = 0; i < list.Items.Length; i++) { while (runner.IsBusy() == true) System.Threading.Thread.Sleep(50); + SendSubmitToControl(list.Items[i].ToString(), "Receive"); runner.AddWork(list.Items[i].ToString()); } Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj 2008-11-06 09:53:57 UTC (rev 430) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj 2008-11-06 11:48:11 UTC (rev 431) @@ -28,6 +28,10 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="LogDataGridView, Version=1.1.3198.29045, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\Resource\LogDataGridView.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> @@ -63,6 +67,12 @@ <Name>PluginsFramework</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="TestRunnerUserControl.resx"> + <SubType>Designer</SubType> + <DependentUpon>TestRunnerUserControl.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs 2008-11-06 09:53:57 UTC (rev 430) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs 2008-11-06 11:48:11 UTC (rev 431) @@ -28,10 +28,279 @@ /// </summary> private void InitializeComponent() { - components = new System.ComponentModel.Container(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.labelAll = new System.Windows.Forms.Label(); + this.labelAC = new System.Windows.Forms.Label(); + this.labelWA = new System.Windows.Forms.Label(); + this.labelTL = new System.Windows.Forms.Label(); + this.labelML = new System.Windows.Forms.Label(); + this.labelOL = new System.Windows.Forms.Label(); + this.labelCE = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.labelDF = new System.Windows.Forms.Label(); + this.labelRE = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Location = new System.Drawing.Point(3, 57); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(302, 236); + this.panel1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(18, 13); + this.label1.TabIndex = 1; + this.label1.Text = "All"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label2.Location = new System.Drawing.Point(3, 13); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(23, 13); + this.label2.TabIndex = 2; + this.label2.Text = "AC"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.labelAll, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.labelAC, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label3, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.labelWA, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.label4, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.labelTL, 3, 0); + this.tableLayoutPanel1.Controls.Add(this.label7, 4, 0); + this.tableLayoutPanel1.Controls.Add(this.labelCE, 5, 0); + this.tableLayoutPanel1.Controls.Add(this.label5, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.labelML, 3, 1); + this.tableLayoutPanel1.Controls.Add(this.label6, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.labelOL, 3, 3); + this.tableLayoutPanel1.Controls.Add(this.label8, 4, 3); + this.tableLayoutPanel1.Controls.Add(this.labelDF, 5, 3); + this.tableLayoutPanel1.Controls.Add(this.labelRE, 5, 1); + this.tableLayoutPanel1.Controls.Add(this.label9, 4, 1); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 5; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 48); + this.tableLayoutPanel1.TabIndex = 3; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 26); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(25, 13); + this.label3.TabIndex = 3; + this.label3.Text = "WA"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(54, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(20, 13); + this.label4.TabIndex = 4; + this.label4.Text = "TL"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(54, 13); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(22, 13); + this.label5.TabIndex = 5; + this.label5.Text = "ML"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(54, 26); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(21, 13); + this.label6.TabIndex = 6; + this.label6.Text = "OL"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(101, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(21, 13); + this.label7.TabIndex = 7; + this.label7.Text = "CE"; + // + // labelAll + // + this.labelAll.AutoSize = true; + this.labelAll.Location = new System.Drawing.Point(34, 0); + this.labelAll.Name = "labelAll"; + this.labelAll.Size = new System.Drawing.Size(13, 13); + this.labelAll.TabIndex = 8; + this.labelAll.Text = "0"; + // + // labelAC + // + this.labelAC.AutoSize = true; + this.labelAC.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.labelAC.Location = new System.Drawing.Point(34, 13); + this.labelAC.Name = "labelAC"; + this.labelAC.Size = new System.Drawing.Size(14, 13); + this.labelAC.TabIndex = 9; + this.labelAC.Text = "0"; + // + // labelWA + // + this.labelWA.AutoSize = true; + this.labelWA.Location = new System.Drawing.Point(34, 26); + this.labelWA.Name = "labelWA"; + this.labelWA.Size = new System.Drawing.Size(13, 13); + this.labelWA.TabIndex = 10; + this.labelWA.Text = "0"; + // + // labelTL + // + this.labelTL.AutoSize = true; + this.labelTL.Location = new System.Drawing.Point(82, 0); + this.labelTL.Name = "labelTL"; + this.labelTL.Size = new System.Drawing.Size(13, 13); + this.labelTL.TabIndex = 11; + this.labelTL.Text = "0"; + // + // labelML + // + this.labelML.AutoSize = true; + this.labelML.Location = new System.Drawing.Point(82, 13); + this.labelML.Name = "labelML"; + this.labelML.Size = new System.Drawing.Size(13, 13); + this.labelML.TabIndex = 12; + this.labelML.Text = "0"; + // + // labelOL + // + this.labelOL.AutoSize = true; + this.labelOL.Location = new System.Drawing.Point(82, 26); + this.labelOL.Name = "labelOL"; + this.labelOL.Size = new System.Drawing.Size(13, 13); + this.labelOL.TabIndex = 13; + this.labelOL.Text = "0"; + // + // labelCE + // + this.labelCE.AutoSize = true; + this.labelCE.Location = new System.Drawing.Point(129, 0); + this.labelCE.Name = "labelCE"; + this.labelCE.Size = new System.Drawing.Size(13, 13); + this.labelCE.TabIndex = 14; + this.labelCE.Text = "0"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(101, 26); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(21, 13); + this.label8.TabIndex = 15; + this.label8.Text = "DF"; + // + // labelDF + // + this.labelDF.AutoSize = true; + this.labelDF.Location = new System.Drawing.Point(129, 26); + this.labelDF.Name = "labelDF"; + this.labelDF.Size = new System.Drawing.Size(13, 13); + this.labelDF.TabIndex = 16; + this.labelDF.Text = "0"; + // + // labelRE + // + this.labelRE.AutoSize = true; + this.labelRE.Location = new System.Drawing.Point(129, 13); + this.labelRE.Name = "labelRE"; + this.labelRE.Size = new System.Drawing.Size(13, 13); + this.labelRE.TabIndex = 17; + this.labelRE.Text = "0"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(101, 13); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(22, 13); + this.label9.TabIndex = 18; + this.label9.Text = "RE"; + // + // TestRunnerUserControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.panel1); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "TestRunnerUserControl"; + this.Size = new System.Drawing.Size(308, 296); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label labelAll; + private System.Windows.Forms.Label labelAC; + private System.Windows.Forms.Label labelTL; + private System.Windows.Forms.Label labelWA; + private System.Windows.Forms.Label labelML; + private System.Windows.Forms.Label labelOL; + private System.Windows.Forms.Label labelCE; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label labelDF; + private System.Windows.Forms.Label labelRE; + private System.Windows.Forms.Label label9; } } Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs 2008-11-06 09:53:57 UTC (rev 430) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs 2008-11-06 11:48:11 UTC (rev 431) @@ -10,9 +10,111 @@ { public partial class TestRunnerUserControl : UserControl { + int All = 0; + int AC = 0; + int WA = 0; + int TL = 0; + int ML = 0; + int OL = 0; + int CE = 0; + int RE = 0; + int DF = 0; public TestRunnerUserControl() { InitializeComponent(); + initGridSe(); } + + LogDataGridView.LogDataGridView view = new LogDataGridView.LogDataGridView(); + private void initGridSe() + { + view.Dock = DockStyle.Fill; + panel1.Controls.Add(view); + } + + + delegate void UpdateCountersCallback(); + public void UpdateCounters() + { + if (this.InvokeRequired) + { + UpdateCountersCallback d = new UpdateCountersCallback(UpdateCounters); + this.Invoke(d); + } + else + { + labelAll.Text = All.ToString(); + labelAC.Text = AC.ToString(); + labelWA.Text = WA.ToString(); + labelDF.Text = DF.ToString(); + labelML.Text = ML.ToString(); + labelOL.Text = OL.ToString(); + labelTL.Text = TL.ToString(); + labelCE.Text = CE.ToString(); + labelRE.Text = RE.ToString(); + } + } + + public void AddText(string type, string text) + { + view.AddRow(new LogDataGridView.SystemMessage(text, type)); + } + public void AddResult(string text) + { + bool knowType = false; + if (text == "All") + { + knowType = true; + All++; + } + if (text == "Accepted") + { + knowType = true; + AC++; + } + if (text == "WrongAnswer") + { + knowType = true; + WA++; + } + if (text == "TimeLimit") + { + knowType = true; + TL++; + } + if (text == "MemoryLimit") + { + knowType = true; + ML++; + } + if (text == "OutputLimit") + { + knowType = true; + OL++; + } + if (text == "CompilationError") + { + knowType = true; + CE++; + } + if (text == "RuntimeError") + { + knowType = true; + RE++; + } + if (text == "DestrictedFunction") + { + knowType = true; + DF++; + } + if (knowType == false) + { + MessageBox.Show("Unknow result type when update form counters" + + Environment.NewLine + + "retult type: " + text); + } + UpdateCounters(); + + } } } Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.resx (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.resx 2008-11-06 11:48:11 UTC (rev 431) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-06 09:54:03
|
Revision: 430 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=430&view=rev Author: brus07 Date: 2008-11-06 09:53:57 +0000 (Thu, 06 Nov 2008) Log Message: ----------- Added name of main form to Config. Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs ACMServer/trunk/ACMServer/Mediator/Config.ini ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs 2008-11-04 18:20:49 UTC (rev 429) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs 2008-11-06 09:53:57 UTC (rev 430) @@ -32,6 +32,21 @@ public static string PluginLeftDirectory; public static string PluginRightDirectory; + private static string mainFormName; + public static string MainFormName + { + get + { + if (String.IsNullOrEmpty(mainFormName) == true) + return "MainForm"; + return mainFormName; + } + private set + { + mainFormName = value; + } + } + private static string LoadStringFromDifferentFile(string sectionName, string keyName) { string defaultString = "#$%^$343@#$"; @@ -53,6 +68,7 @@ { PluginLeftDirectory = LoadStringFromDifferentFile("Plugin", "LeftDirectory"); PluginRightDirectory = LoadStringFromDifferentFile("Plugin", "RightDirectory"); + MainFormName = LoadStringFromDifferentFile("MainForm", "MainFormName"); } } } Modified: ACMServer/trunk/ACMServer/Mediator/Config.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Config.ini 2008-11-04 18:20:49 UTC (rev 429) +++ ACMServer/trunk/ACMServer/Mediator/Config.ini 2008-11-06 09:53:57 UTC (rev 430) @@ -1,3 +1,6 @@ +[MainForm] +MainFormName=Mediator + [Plugin] LeftDirectory=Dll_Web RightDirectory=Dll_Tester \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-11-04 18:20:49 UTC (rev 429) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-11-06 09:53:57 UTC (rev 430) @@ -24,6 +24,7 @@ InitializeComponent(); string s = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); textBox2.Text = s; + this.Text = Configuration.MainFormName; } Modified: ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini 2008-11-04 18:20:49 UTC (rev 429) +++ ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini 2008-11-06 09:53:57 UTC (rev 430) @@ -1,3 +1,6 @@ +[MainForm] +MainFormName=Tester + [Plugin] LeftDirectory=Dll_Web1 RightDirectory=Dll_Tester1 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-04 18:20:54
|
Revision: 429 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=429&view=rev Author: brus07 Date: 2008-11-04 18:20:49 +0000 (Tue, 04 Nov 2008) Log Message: ----------- Added LogDataGridView to SocketClientGatePlugin and fix bug with logging (was all message logging twice). Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs 2008-11-04 17:14:31 UTC (rev 428) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs 2008-11-04 18:20:49 UTC (rev 429) @@ -12,15 +12,8 @@ { socketClientGate.onDataArrived += DataArrived; base.Control = new SocketClientGatePluginUserControl(); - - socketClientGate.onAddLogText += new SocketClientGate.AddLogTextDelegate(socketClientGate_onAddLogText); } - void socketClientGate_onAddLogText(string type, string text) - { - ((SocketClientGatePluginUserControl)base.Control).AddText(type, text); - } - public override void Send(SystemMessage message) { if (message.IsType("ApplicationSystem") && message.Message == "stop") Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj 2008-11-04 17:14:31 UTC (rev 428) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj 2008-11-04 18:20:49 UTC (rev 429) @@ -28,6 +28,10 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="LogDataGridView, Version=1.1.3198.29045, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\Resource\LogDataGridView.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs 2008-11-04 17:14:31 UTC (rev 428) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs 2008-11-04 18:20:49 UTC (rev 429) @@ -38,6 +38,7 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.statusStrip1.SuspendLayout(); @@ -48,6 +49,7 @@ this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Location = new System.Drawing.Point(3, 61); this.tabControl1.Name = "tabControl1"; @@ -123,6 +125,16 @@ this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(230, 135); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "tabPage2"; + this.tabPage2.UseVisualStyleBackColor = true; + // // SocketClientGatePluginUserControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -155,5 +167,6 @@ private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.TabPage tabPage2; } } Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs 2008-11-04 17:14:31 UTC (rev 428) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs 2008-11-04 18:20:49 UTC (rev 429) @@ -13,6 +13,7 @@ public SocketClientGatePluginUserControl() { InitializeComponent(); + initGridSe(); string ip = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); textBox2.Text = ip; @@ -21,6 +22,13 @@ gate.onAddLogText += AddText; } + LogDataGridView.LogDataGridView view = new LogDataGridView.LogDataGridView(); + private void initGridSe() + { + view.Dock = DockStyle.Fill; + tabPage2.Controls.Add(view); + } + delegate void AddTextCallback(string text); private void AddTextToTextLog(string text) { @@ -44,7 +52,7 @@ public void AddText(string type, string text) { AddTextToTextLog(type + ": " + text); - //view.AddRow(new LogDataGridView.SystemMessage(text, type)); + view.AddRow(new LogDataGridView.SystemMessage(text, type)); } private void button1_Click(object sender, EventArgs e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-04 17:14:37
|
Revision: 428 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=428&view=rev Author: brus07 Date: 2008-11-04 17:14:31 +0000 (Tue, 04 Nov 2008) Log Message: ----------- Added user control to TestRunnerPlugin. (now is empty usercontrol) Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-11-04 10:15:26 UTC (rev 427) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-11-04 17:14:31 UTC (rev 428) @@ -11,6 +11,8 @@ public TestRunnerPlugin() { runner.onDataArrived += new WorkRunner.DataArrivedDelegate(runner_onDataArrived); + + base.Control = new TestRunnerUserControl(); } private bool runner_onDataArrived(SystemMessage message) Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj 2008-11-04 10:15:26 UTC (rev 427) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj 2008-11-04 17:14:31 UTC (rev 428) @@ -30,11 +30,19 @@ <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="TestRunnerPlugin.cs" /> + <Compile Include="TestRunnerUserControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="TestRunnerUserControl.Designer.cs"> + <DependentUpon>TestRunnerUserControl.cs</DependentUpon> + </Compile> <Compile Include="WorkRunner.cs" /> </ItemGroup> <ItemGroup> Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.Designer.cs 2008-11-04 17:14:31 UTC (rev 428) @@ -0,0 +1,37 @@ +namespace AcmContester.Plugins.TesterPlugins.TestRunnerPlugin +{ + partial class TestRunnerUserControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerUserControl.cs 2008-11-04 17:14:31 UTC (rev 428) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; + +namespace AcmContester.Plugins.TesterPlugins.TestRunnerPlugin +{ + public partial class TestRunnerUserControl : UserControl + { + public TestRunnerUserControl() + { + InitializeComponent(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-11-04 10:15:30
|
Revision: 427 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=427&view=rev Author: brus07 Date: 2008-11-04 10:15:26 +0000 (Tue, 04 Nov 2008) Log Message: ----------- Write to log all works information in Tester. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs 2008-10-31 21:51:12 UTC (rev 426) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs 2008-11-04 10:15:26 UTC (rev 427) @@ -1,6 +1,7 @@ using System; using System.Threading; using AcmContester.Library.LibraryExtention; +using System.IO; namespace AcmContester.Plugins.TesterPlugins.TestRunnerPlugin { @@ -14,6 +15,19 @@ object working = 0; Thread thread = new Thread(new ParameterizedThreadStart(Go)); + public WorkRunner() + { + try + { + StreamWriter sw = File.AppendText("testerlog.txt"); + Log log = Log.GetLog(sw, Log.Priority.EMPTY); + } + catch (Exception) + { + //UpdateTextLog("\r\n\tLogFile can't open. Working without logging to LogFile."); + } + } + internal bool IsBusy() { lock (working) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-31 21:51:14
|
Revision: 426 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=426&view=rev Author: brus07 Date: 2008-10-31 21:51:12 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Added *.user to ignore list. Property Changed: ---------------- ACMServer/trunk/ACMServer/Mediator/ Property changes on: ACMServer/trunk/ACMServer/Mediator ___________________________________________________________________ Modified: svn:ignore - bin obj + bin obj *.user This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-31 21:47:45
|
Revision: 425 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=425&view=rev Author: brus07 Date: 2008-10-31 21:47:35 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Added Configuration class. Get address to plugins from initialization files (INI). Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Mediator/Mediator.csproj ACMServer/trunk/ACMServer/Mediator/Program.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs ACMServer/trunk/ACMServer/Mediator/Config.ini ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini Added: ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,58 @@ +using System; + +namespace AcmContester.Library.LibraryExtention +{ + public static class Configuration + { + public static string ExecutablePath; + + static readonly string defaultConfigFileName = "config.ini"; + static public string DefaultConfigFileName + { + get + { + return defaultConfigFileName; + } + } + + static string concreteConfigFileName; + + public static string ConcreteConfigFileName + { + get + { + return concreteConfigFileName; + } + set + { + concreteConfigFileName = value; + } + } + + public static string PluginLeftDirectory; + public static string PluginRightDirectory; + + private static string LoadStringFromDifferentFile(string sectionName, string keyName) + { + string defaultString = "#$%^$343@#$"; + string result = defaultString; + if (concreteConfigFileName != null) + { + IniFile ini = new IniFile(ConcreteConfigFileName); + result = ini.GetString(sectionName, keyName, defaultString); + } + if (result == defaultString) + { + IniFile ini = new IniFile(DefaultConfigFileName); + result = ini.GetString(sectionName, keyName, ""); + } + return result; + } + + public static void Load() + { + PluginLeftDirectory = LoadStringFromDifferentFile("Plugin", "LeftDirectory"); + PluginRightDirectory = LoadStringFromDifferentFile("Plugin", "RightDirectory"); + } + } +} Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-31 21:47:35 UTC (rev 425) @@ -33,6 +33,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Configuration.cs" /> <Compile Include="IniFile.cs" /> <Compile Include="Log.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> @@ -50,4 +51,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project> \ No newline at end of file +</Project> Added: ACMServer/trunk/ACMServer/Mediator/Config.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Config.ini (rev 0) +++ ACMServer/trunk/ACMServer/Mediator/Config.ini 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,3 @@ +[Plugin] +LeftDirectory=Dll_Web +RightDirectory=Dll_Tester \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -11,6 +11,8 @@ using AcmContester.Library.LibraryExtention; using AcmContester.Plugins.PluginsFramework; + + namespace Mediator { public partial class Form1 : Form @@ -27,7 +29,10 @@ private void button2_Click(object sender, EventArgs e) { - kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + kernel = new MediatorKernelGUI(Configuration.PluginRightDirectory, + Configuration.PluginLeftDirectory); + //kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + //kernel = new MediatorKernelGUI("Dll_Runner", "Dll_Client"); kernel.Dock = DockStyle.Fill; this.panel1.Controls.Add(kernel); } Modified: ACMServer/trunk/ACMServer/Mediator/Mediator.csproj =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-31 21:47:35 UTC (rev 425) @@ -58,6 +58,12 @@ <DependentUpon>Resources.resx</DependentUpon> <DesignTime>True</DesignTime> </Compile> + <None Include="Config.ini"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TesterConfig.ini"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> @@ -93,4 +99,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project> \ No newline at end of file +</Project> Modified: ACMServer/trunk/ACMServer/Mediator/Program.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Program.cs 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Program.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using System.IO; namespace Mediator { @@ -10,8 +11,16 @@ /// The main entry point for the application. /// </summary> [STAThread] - static void Main() + static void Main(string[] args) { + string path = Application.ExecutablePath; + path = System.IO.Path.GetDirectoryName(path); + AcmContester.Library.LibraryExtention.Configuration.ExecutablePath = path; + if (args.Length == 1) + { + AcmContester.Library.LibraryExtention.Configuration.ConcreteConfigFileName = args[0]; + } + AcmContester.Library.LibraryExtention.Configuration.Load(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); Added: ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini (rev 0) +++ ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,3 @@ +[Plugin] +LeftDirectory=Dll_Web1 +RightDirectory=Dll_Tester1 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-31 21:44:29
|
Revision: 424 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=424&view=rev Author: brus07 Date: 2008-10-31 21:44:07 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Change IniFile class Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs 2008-10-23 21:06:35 UTC (rev 423) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs 2008-10-31 21:44:07 UTC (rev 424) @@ -2,95 +2,682 @@ using System.IO; using System.Text; using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Globalization; namespace AcmContester.Library.LibraryExtention { /// <summary> - /// Class to read from INI files. Based loosely on the Delphi class of the same name. + /// Provides methods for reading and writing to an INI file. /// </summary> + /// <!--http://www.codeproject.com/KB/files/win32fileutilityclass.aspx--> public class IniFile { - private string fileName; + /// <summary> + /// The maximum size of a section in an ini file. + /// </summary> + /// <remarks> + /// This property defines the maximum size of the buffers + /// used to retreive data from an ini file. This value is + /// the maximum allowed by the win32 functions + /// GetPrivateProfileSectionNames() or + /// GetPrivateProfileString(). + /// </remarks> + public const int MaxSectionSize = 32767; // 32 KB + //The path of the file we are operating on. + private string m_path; + + #region P/Invoke declares + /// <summary> - /// Creates a new <see cref="IniFile"/> instance. + /// A static class that provides the win32 P/Invoke signatures + /// used by this class. /// </summary> - /// <param name="fileName">Name of the INI file.</param> - public IniFile(string fileName) + /// <remarks> + /// Note: In each of the declarations below, we explicitly set CharSet to + /// Auto. By default in C#, CharSet is set to Ansi, which reduces + /// performance on windows 2000 and above due to needing to convert strings + /// from Unicode (the native format for all .Net strings) to Ansi before + /// marshalling. Using Auto lets the marshaller select the Unicode version of + /// these functions when available. + /// </remarks> + [System.Security.SuppressUnmanagedCodeSecurity] + private static class NativeMethods { - if (!File.Exists(fileName)) - throw new FileNotFoundException(fileName + " does not exist", fileName); - this.fileName = fileName; + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern int GetPrivateProfileSectionNames(IntPtr lpszReturnBuffer, + uint nSize, + string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern uint GetPrivateProfileString(string lpAppName, + string lpKeyName, + string lpDefault, + StringBuilder lpReturnedString, + int nSize, + string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern uint GetPrivateProfileString(string lpAppName, + string lpKeyName, + string lpDefault, + [In, Out] char[] lpReturnedString, + int nSize, + string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern int GetPrivateProfileString(string lpAppName, + string lpKeyName, + string lpDefault, + IntPtr lpReturnedString, + uint nSize, + string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern int GetPrivateProfileInt(string lpAppName, + string lpKeyName, + int lpDefault, + string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern int GetPrivateProfileSection(string lpAppName, + IntPtr lpReturnedString, + uint nSize, + string lpFileName); + + //We explicitly enable the SetLastError attribute here because + // WritePrivateProfileString returns errors via SetLastError. + // Failure to set this can result in errors being lost during + // the marshal back to managed code. + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern bool WritePrivateProfileString(string lpAppName, + string lpKeyName, + string lpString, + string lpFileName); + + } + #endregion - // native methods - [DllImport("kernel32")] - private static extern int GetPrivateProfileString(string section, - string key, string def, StringBuilder retVal, int size, string filePath); + /// <summary> + /// Initializes a new instance of the <see cref="IniFile"/> class. + /// </summary> + /// <param name="path">The ini file to read and write from.</param> + public IniFile(string path) + { + if (!File.Exists(path)) + throw new FileNotFoundException(path + " does not exist", path); - [DllImport("kernel32")] - private static extern int GetPrivateProfileSection(string section, IntPtr lpReturnedString, - int nSize, string lpFileName); + //Convert to the full path. Because of backward compatibility, + // the win32 functions tend to assume the path should be the + // root Windows directory if it is not specified. By calling + // GetFullPath, we make sure we are always passing the full path + // the win32 functions. + m_path = System.IO.Path.GetFullPath(path); + } - [DllImport("kernel32")] - private static extern long WritePrivateProfileString(string section, - string key, string val, string filePath); + /// <summary> + /// Gets the full path of ini file this object instance is operating on. + /// </summary> + /// <value>A file path.</value> + public string Path + { + get + { + return m_path; + } + } + private string[] GetArreyKeys(string sectionName, + string keyName) + { + string[] allKeys = this.GetKeyNames(sectionName); + List<string> list = new List<string>(); + for (int i = 0; i < allKeys.Length; i++) + { + if (allKeys[i].IndexOf(keyName + ".") == 0) + { + list.Add(allKeys[i]); + } + } + return list.ToArray(); + } + #region Get Value Methods + /// <summary> - /// Reads a string value from the INI file. + /// Gets the value of a setting in an ini file as a <see cref="T:System.String"/>. /// </summary> - /// <param name="section">Section to read.</param> - /// <param name="key">Key to read.</param> - public string ReadString(string section, string key) + /// <param name="sectionName">The name of the section to read from.</param> + /// <param name="keyName">The name of the key in section to read.</param> + /// <param name="defaultValue">The default value to return if the key + /// cannot be found.</param> + /// <returns>The value of the key, if found. Otherwise, returns + /// <paramref name="defaultValue"/></returns> + /// <remarks> + /// The retreived value must be less than 32KB in length. + /// </remarks> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public string GetString(string sectionName, + string keyName, + string defaultValue) { - const int bufferSize = 255; - //TODO: jaksho bilshe za bufferSize todi Exception - StringBuilder temp = new StringBuilder(bufferSize); - GetPrivateProfileString(section, key, "", temp, bufferSize, fileName); - return temp.ToString(); + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + if (keyName == null) + throw new ArgumentNullException("keyName"); + + StringBuilder retval = new StringBuilder(IniFile.MaxSectionSize); + + NativeMethods.GetPrivateProfileString(sectionName, + keyName, + defaultValue, + retval, + IniFile.MaxSectionSize, + m_path); + + return retval.ToString(); } /// <summary> - /// Reads a whole section of the INI file. + /// Gets the value of a setting in an ini file as a <see cref="T:System.Int16"/>. /// </summary> - /// <param name="section">Section to read.</param> - public string[] ReadSection(string section) + /// <param name="sectionName">The name of the section to read from.</param> + /// <param name="keyName">The name of the key in section to read.</param> + /// <param name="defaultValue">The default value to return if the key + /// cannot be found.</param> + /// <returns>The value of the key, if found. Otherwise, returns + /// <paramref name="defaultValue"/>.</returns> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public int GetInt16(string sectionName, + string keyName, + short defaultValue) { - const int bufferSize = 2048; - //TODO: jaksho bilshe za bufferSize todi Exception + int retval = GetInt32(sectionName, keyName, defaultValue); - StringBuilder returnedString = new StringBuilder(); + return Convert.ToInt16(retval); + } - IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize); + /// <summary> + /// Gets the value of a setting in an ini file as a <see cref="T:System.Int32"/>. + /// </summary> + /// <param name="sectionName">The name of the section to read from.</param> + /// <param name="keyName">The name of the key in section to read.</param> + /// <param name="defaultValue">The default value to return if the key + /// cannot be found.</param> + /// <returns>The value of the key, if found. Otherwise, returns + /// <paramref name="defaultValue"/></returns> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public int GetInt32(string sectionName, + string keyName, + int defaultValue) + { + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + if (keyName == null) + throw new ArgumentNullException("keyName"); + + + return NativeMethods.GetPrivateProfileInt(sectionName, keyName, defaultValue, m_path); + } + + /// <summary> + /// Gets the value of a setting in an ini file as a <see cref="T:System.Double"/>. + /// </summary> + /// <param name="sectionName">The name of the section to read from.</param> + /// <param name="keyName">The name of the key in section to read.</param> + /// <param name="defaultValue">The default value to return if the key + /// cannot be found.</param> + /// <returns>The value of the key, if found. Otherwise, returns + /// <paramref name="defaultValue"/></returns> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public double GetDouble(string sectionName, + string keyName, + double defaultValue) + { + string retval = GetString(sectionName, keyName, ""); + + if (retval == null || retval.Length == 0) + { + return defaultValue; + } + + return Convert.ToDouble(retval, CultureInfo.InvariantCulture); + } + + public string[] GetStringArray(string sectionName, + string keyName) + { + string[] keys = GetArreyKeys(sectionName, keyName); + string[] result = new string[keys.Length]; + for (int i = 0; i < keys.Length; i++) + { + result[i] = GetString(sectionName, keys[i], ""); + + } + return result; + } + + #endregion + + #region GetSectionValues Methods + + /// <summary> + /// Gets all of the values in a section as a list. + /// </summary> + /// <param name="sectionName"> + /// Name of the section to retrieve values from. + /// </param> + /// <returns> + /// A <see cref="List{T}"/> containing <see cref="KeyValuePair{T1, T2}"/> objects + /// that describe this section. Use this verison if a section may contain + /// multiple items with the same key value. If you know that a section + /// cannot contain multiple values with the same key name or you don't + /// care about the duplicates, use the more convenient + /// <see cref="GetSectionValues"/> function. + /// </returns> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> is a null reference (Nothing in VB) + /// </exception> + public List<KeyValuePair<string, string>> GetSectionValuesAsList(string sectionName) + { + List<KeyValuePair<string, string>> retval; + string[] keyValuePairs; + string key, value; + int equalSignPos; + + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + //Allocate a buffer for the returned section names. + IntPtr ptr = Marshal.AllocCoTaskMem(IniFile.MaxSectionSize); + try { - int bytesReturned = GetPrivateProfileSection(section, pReturnedString, bufferSize, fileName); + //Get the section key/value pairs into the buffer. + int len = NativeMethods.GetPrivateProfileSection(sectionName, + ptr, + IniFile.MaxSectionSize, + m_path); - //bytesReturned -1 to remove trailing \0 - for (int i = 0; i < bytesReturned - 1; i++) - returnedString.Append((char)Marshal.ReadByte(new IntPtr((uint)pReturnedString + (uint)i))); + keyValuePairs = ConvertNullSeperatedStringToStringArray(ptr, len); } finally { - Marshal.FreeCoTaskMem(pReturnedString); + //Free the buffer + Marshal.FreeCoTaskMem(ptr); } - string sectionData = returnedString.ToString(); - return sectionData.Split('\0'); + //Parse keyValue pairs and add them to the list. + retval = new List<KeyValuePair<string, string>>(keyValuePairs.Length); + + for (int i = 0; i < keyValuePairs.Length; ++i) + { + //Parse the "key=value" string into its constituent parts + equalSignPos = keyValuePairs[i].IndexOf('='); + + key = keyValuePairs[i].Substring(0, equalSignPos); + + value = keyValuePairs[i].Substring(equalSignPos + 1, + keyValuePairs[i].Length - equalSignPos - 1); + + retval.Add(new KeyValuePair<string, string>(key, value)); + } + + return retval; } /// <summary> - /// Write Data to the INI File + /// Gets all of the values in a section as a dictionary. /// </summary> - /// <PARAM name="Section"><Section name/PARAM> - /// <PARAM name="Key">Key Name</PARAM> - /// <PARAM name="Value">Value Name</PARAM> - public void WriteString(string section, string key, string value) + /// <param name="sectionName"> + /// Name of the section to retrieve values from. + /// </param> + /// <returns> + /// A <see cref="Dictionary{T, T}"/> containing the key/value + /// pairs found in this section. + /// </returns> + /// <remarks> + /// If a section contains more than one key with the same name, + /// this function only returns the first instance. If you need to + /// get all key/value pairs within a section even when keys have the + /// same name, use <see cref="GetSectionValuesAsList"/>. + /// </remarks> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> is a null reference (Nothing in VB) + /// </exception> + public Dictionary<string, string> GetSectionValues(string sectionName) { - WritePrivateProfileString(section, key, value, fileName); + List<KeyValuePair<string, string>> keyValuePairs; + Dictionary<string, string> retval; + + keyValuePairs = GetSectionValuesAsList(sectionName); + + //Convert list into a dictionary. + retval = new Dictionary<string, string>(keyValuePairs.Count); + + foreach (KeyValuePair<string, string> keyValuePair in keyValuePairs) + { + //Skip any key we have already seen. + if (!retval.ContainsKey(keyValuePair.Key)) + { + retval.Add(keyValuePair.Key, keyValuePair.Value); + } + } + + return retval; } + #endregion + + #region Get Key/Section Names + + /// <summary> + /// Gets the names of all keys under a specific section in the ini file. + /// </summary> + /// <param name="sectionName"> + /// The name of the section to read key names from. + /// </param> + /// <returns>An array of key names.</returns> + /// <remarks> + /// The total length of all key names in the section must be + /// less than 32KB in length. + /// </remarks> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> is a null reference (Nothing in VB) + /// </exception> + public string[] GetKeyNames(string sectionName) + { + int len; + string[] retval; + + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + //Allocate a buffer for the returned section names. + IntPtr ptr = Marshal.AllocCoTaskMem(IniFile.MaxSectionSize); + + try + { + //Get the section names into the buffer. + len = NativeMethods.GetPrivateProfileString(sectionName, + null, + null, + ptr, + IniFile.MaxSectionSize, + m_path); + + retval = ConvertNullSeperatedStringToStringArray(ptr, len); + } + finally + { + //Free the buffer + Marshal.FreeCoTaskMem(ptr); + } + + return retval; + } + + /// <summary> + /// Gets the names of all sections in the ini file. + /// </summary> + /// <returns>An array of section names.</returns> + /// <remarks> + /// The total length of all section names in the section must be + /// less than 32KB in length. + /// </remarks> + public string[] GetSectionNames() + { + string[] retval; + int len; + + //Allocate a buffer for the returned section names. + IntPtr ptr = Marshal.AllocCoTaskMem(IniFile.MaxSectionSize); + + try + { + //Get the section names into the buffer. + len = NativeMethods.GetPrivateProfileSectionNames(ptr, + IniFile.MaxSectionSize, m_path); + + retval = ConvertNullSeperatedStringToStringArray(ptr, len); + } + finally + { + //Free the buffer + Marshal.FreeCoTaskMem(ptr); + } + + return retval; + } + + /// <summary> + /// Converts the null seperated pointer to a string into a string array. + /// </summary> + /// <param name="ptr">A pointer to string data.</param> + /// <param name="valLength"> + /// Length of the data pointed to by <paramref name="ptr"/>. + /// </param> + /// <returns> + /// An array of strings; one for each null found in the array of characters pointed + /// at by <paramref name="ptr"/>. + /// </returns> + private static string[] ConvertNullSeperatedStringToStringArray(IntPtr ptr, int valLength) + { + string[] retval; + + if (valLength == 0) + { + //Return an empty array. + retval = new string[0]; + } + else + { + //Convert the buffer into a string. Decrease the length + //by 1 so that we remove the second null off the end. + string buff = Marshal.PtrToStringAuto(ptr, valLength - 1); + + //Parse the buffer into an array of strings by searching for nulls. + retval = buff.Split('\0'); + } + + return retval; + } + + #endregion + + #region Write Methods + + /// <summary> + /// Writes a <see cref="T:System.String"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The string value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + private void WriteValueInternal(string sectionName, string keyName, string value) + { + if (!NativeMethods.WritePrivateProfileString(sectionName, keyName, value, m_path)) + { + throw new System.ComponentModel.Win32Exception(); + } + } + + /// <summary> + /// Writes a <see cref="T:System.String"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The string value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> or + /// <paramref name="value"/> are a null reference (Nothing in VB) + /// </exception> + public void WriteValue(string sectionName, string keyName, string value) + { + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + if (keyName == null) + throw new ArgumentNullException("keyName"); + + if (value == null) + throw new ArgumentNullException("value"); + + WriteValueInternal(sectionName, keyName, value); + } + + /// <summary> + /// Writes an <see cref="T:System.Int16"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + public void WriteValue(string sectionName, string keyName, short value) + { + WriteValue(sectionName, keyName, (int)value); + } + + /// <summary> + /// Writes an <see cref="T:System.Int32"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public void WriteValue(string sectionName, string keyName, int value) + { + WriteValue(sectionName, keyName, value.ToString(CultureInfo.InvariantCulture)); + } + + /// <summary> + /// Writes an <see cref="T:System.Single"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public void WriteValue(string sectionName, string keyName, float value) + { + WriteValue(sectionName, keyName, value.ToString(CultureInfo.InvariantCulture)); + } + + /// <summary> + /// Writes an <see cref="T:System.Double"/> value to the ini file. + /// </summary> + /// <param name="sectionName">The name of the section to write to .</param> + /// <param name="keyName">The name of the key to write to.</param> + /// <param name="value">The value to write</param> + /// <exception cref="T:System.ComponentModel.Win32Exception"> + /// The write failed. + /// </exception> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public void WriteValue(string sectionName, string keyName, double value) + { + WriteValue(sectionName, keyName, value.ToString(CultureInfo.InvariantCulture)); + } + + public void WriteStringArray(string sectionName, + string keyName, + string[] values) + { + //Delete contain keys in INI file + string[] containKeys = GetArreyKeys(sectionName, keyName); + for (int i = 0; i < containKeys.Length; i++) + DeleteKey(sectionName, containKeys[i]); + + //Write new element into INI file + for (int i = 0; i < values.Length; i++) + { + string newKey = keyName + "." + i.ToString(); + WriteValue(sectionName, newKey, values[i]); + } + + } + + #endregion + + #region Delete Methods + + /// <summary> + /// Deletes the specified key from the specified section. + /// </summary> + /// <param name="sectionName"> + /// Name of the section to remove the key from. + /// </param> + /// <param name="keyName"> + /// Name of the key to remove. + /// </param> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> or <paramref name="keyName"/> are + /// a null reference (Nothing in VB) + /// </exception> + public void DeleteKey(string sectionName, string keyName) + { + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + if (keyName == null) + throw new ArgumentNullException("keyName"); + + WriteValueInternal(sectionName, keyName, null); + } + + /// <summary> + /// Deletes a section from the ini file. + /// </summary> + /// <param name="sectionName"> + /// Name of the section to delete. + /// </param> + /// <exception cref="ArgumentNullException"> + /// <paramref name="sectionName"/> is a null reference (Nothing in VB) + /// </exception> + public void DeleteSection(string sectionName) + { + if (sectionName == null) + throw new ArgumentNullException("sectionName"); + + WriteValueInternal(sectionName, null, null); + } + + #endregion } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-23 21:06:39
|
Revision: 423 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=423&view=rev Author: brus07 Date: 2008-10-23 21:06:35 +0000 (Thu, 23 Oct 2008) Log Message: ----------- Added project (SocketClientGatePlugin) to solution. Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-23 20:58:55 UTC (rev 422) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-23 21:06:35 UTC (rev 423) @@ -29,6 +29,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner", "Runner\Runner.csproj", "{052D9F77-17AF-42F3-BFBF-975A19383496}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocketClientGatePlugin", "Plugins\TesterPlugins\SocketClientGatePlugin\SocketClientGatePlugin.csproj", "{79EB24DD-AF0D-40D0-974E-198F4D8C92BC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -75,6 +77,10 @@ {052D9F77-17AF-42F3-BFBF-975A19383496}.Debug|Any CPU.Build.0 = Debug|Any CPU {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.ActiveCfg = Release|Any CPU {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.Build.0 = Release|Any CPU + {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79EB24DD-AF0D-40D0-974E-198F4D8C92BC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -90,5 +96,6 @@ {20B192BC-FD4D-4ED5-90F5-B5994F995238} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {9462E3BD-67AD-4887-BF4C-8B6A25048941} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {8F305004-8FB7-4F85-8063-3A7041DB840F} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} + {79EB24DD-AF0D-40D0-974E-198F4D8C92BC} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} EndGlobalSection EndGlobal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-23 20:59:00
|
Revision: 422 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=422&view=rev Author: brus07 Date: 2008-10-23 20:58:55 +0000 (Thu, 23 Oct 2008) Log Message: ----------- Rename namespace. Work with new message type. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-10-23 20:37:56 UTC (rev 421) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-10-23 20:58:55 UTC (rev 422) @@ -3,7 +3,7 @@ using AcmContester.Library.LibraryExtention; using AcmContester.Library.LibraryExtention.Data; -namespace AcmContester.Plugins.MediatorPlugins.TestRunnerPlugin +namespace AcmContester.Plugins.TesterPlugins.TestRunnerPlugin { public class TestRunnerPlugin: BaseMediatorPlugin { @@ -21,14 +21,36 @@ public override void Send(SystemMessage message) { - if (message.IsType("ApplicationSystem") && message.Message == "stop") + if (message.IsType("ApplicationSystem") == true) { - runner.Stop(); - return; + if (message.Message == "stop") + { + runner.Stop(); + return; + } } + if (message.IsType("CheckState") == true) + { + if (message.Message == "isbusy") + { + SystemMessage mes; + if (runner.IsBusy() == true) + { + mes = new SystemMessage("busy", "CheckStateResult"); + } + else + { + mes = new SystemMessage("free", "CheckStateResult"); + } + Send(mes); + return; + } + } + if (message.IsType("TestingSubmit") == true) runner.AddWork(message.Message); + if (message.IsType("TestingSubmitList") == true) { SubmitList list = SubmitList.CreateFromXml(message.Message); Modified: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs 2008-10-23 20:37:56 UTC (rev 421) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs 2008-10-23 20:58:55 UTC (rev 422) @@ -2,7 +2,7 @@ using System.Threading; using AcmContester.Library.LibraryExtention; -namespace AcmContester.Plugins.MediatorPlugins.TestRunnerPlugin +namespace AcmContester.Plugins.TesterPlugins.TestRunnerPlugin { class WorkRunner { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-23 20:38:02
|
Revision: 421 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=421&view=rev Author: brus07 Date: 2008-10-23 20:37:56 +0000 (Thu, 23 Oct 2008) Log Message: ----------- Added new Plugin. For work with SocketClient. Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties/AssemblyInfo.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.resx Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin ___________________________________________________________________ Added: svn:ignore + bin obj Added: tsvn:logminsize + 5 Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/Properties/AssemblyInfo.cs 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SocketClientGatePlugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("SocketClientGatePlugin")] +[assembly: AssemblyCopyright("Copyright © Home 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("83e8447b-02bf-400f-9a0d-e51b8bdb4abb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] Copied: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs (from rev 418, ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs) =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,97 @@ +using System; +using AcmContester.Library.LibraryExtention; +using AcmContester.Library.Connector; +using AcmContester.Library.LibraryExtention.Data; + +namespace AcmContester.Plugins.TesterPlugins.SocketClientGatePlugin +{ + class SocketClientGate: AbstractConnector + { + static SocketClientGate instance = new SocketClientGate(); + + SocketClientTask client; + + private SocketClientGate() + { + } + + public static SocketClientGate GetInstance() + { + return instance; + } + + public void CreateClient(string IP) + { + client = new SocketClientTask(IP); + client.onDataArrived += new SocketClient.DataArrivedDelegate(SocketClientGate_onDataArrived); + client.onAddLogText += OnAddLogText; + client.isBusy += IsBusy; + } + + System.Threading.Mutex mutex = new System.Threading.Mutex(); + bool busyState = false; + bool IsBusy() + { + OnDataArrived(new SystemMessage("isbusy", "CheckState")); + if (mutex.WaitOne(200, false) == true) + { + return busyState; + } + //TODO: ne znaju tochno sho krashe povertaty u takomu vypadku + return false; + } + + void SocketClientGate_onDataArrived(SystemMessage message) + { + OnAddLogText("Receive", message.Message); + + if (message.IsType("TestingSubmit") == true) + { + OnDataArrived(message); + } + } + + public override bool Send(SystemMessage message) + { + message = new SystemMessage(message); + + if (message.IsType("CheckStateResult") == true) + { + busyState = (message.Message == "busy"); + mutex.ReleaseMutex(); + return true; + } + + if (message.IsType("TestingResult") == true) + { + Result res = Result.CreateFromXml(message.Message); + OnAddLogText("Send", "ID " + res.Submit.id + " result - " + res.res); + } + + return client.Send(message); + } + + public delegate void AddLogTextDelegate(string type, string text); + public event AddLogTextDelegate onAddLogText; + private void OnAddLogText(string type, string text) + { + if (onAddLogText != null) + onAddLogText(type,text); + } + + public void Connect() + { + if (client != null) + client.Connect(); + } + public void Disconnect() + { + if (client != null) + client.Disconnect(); + } + public bool IsConnected() + { + return client.IsConnected(); + } + } +} Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGate.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.cs 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,34 @@ +using System; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Plugins.TesterPlugins.SocketClientGatePlugin +{ + public class SocketClientGatePlugin: BaseMediatorPlugin + { + SocketClientGate socketClientGate = SocketClientGate.GetInstance(); + + public SocketClientGatePlugin() + { + socketClientGate.onDataArrived += DataArrived; + base.Control = new SocketClientGatePluginUserControl(); + + socketClientGate.onAddLogText += new SocketClientGate.AddLogTextDelegate(socketClientGate_onAddLogText); + } + + void socketClientGate_onAddLogText(string type, string text) + { + ((SocketClientGatePluginUserControl)base.Control).AddText(type, text); + } + + public override void Send(SystemMessage message) + { + if (message.IsType("ApplicationSystem") && message.Message == "stop") + { + socketClientGate.Disconnect(); + return; + } + socketClientGate.Send(message); + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePlugin.csproj 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,80 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{79EB24DD-AF0D-40D0-974E-198F4D8C92BC}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SocketClientGatePlugin</RootNamespace> + <AssemblyName>SocketClientGatePlugin</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SocketClientGate.cs" /> + <Compile Include="SocketClientGatePlugin.cs" /> + <Compile Include="SocketClientGatePluginUserControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="SocketClientGatePluginUserControl.Designer.cs"> + <DependentUpon>SocketClientGatePluginUserControl.cs</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Library\Connector\Connector.csproj"> + <Project>{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}</Project> + <Name>Connector</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Library\Data\Data.csproj"> + <Project>{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}</Project> + <Name>Data</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Library\LibraryExtention\LibraryExtention.csproj"> + <Project>{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}</Project> + <Name>LibraryExtention</Name> + </ProjectReference> + <ProjectReference Include="..\..\PluginsFramework\PluginsFramework.csproj"> + <Project>{69FB4176-F298-4AF7-B714-B6758AA9A58E}</Project> + <Name>PluginsFramework</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="SocketClientGatePluginUserControl.resx"> + <SubType>Designer</SubType> + <DependentUpon>SocketClientGatePluginUserControl.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.Designer.cs 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,159 @@ +namespace AcmContester.Plugins.TesterPlugins.SocketClientGatePlugin +{ + partial class SocketClientGatePluginUserControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Location = new System.Drawing.Point(3, 61); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(238, 161); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.textBox1); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(230, 135); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "tabPage1"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // textBox1 + // + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Location = new System.Drawing.Point(3, 3); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(224, 129); + this.textBox1.TabIndex = 0; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(141, 3); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(100, 20); + this.textBox2.TabIndex = 1; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(3, 3); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Connect"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(3, 32); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 3; + this.button2.Text = "Disconnect"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel1}); + this.statusStrip1.Location = new System.Drawing.Point(0, 225); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(244, 22); + this.statusStrip1.TabIndex = 4; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(37, 17); + this.toolStripStatusLabel1.Text = "xx0xx"; + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // SocketClientGatePluginUserControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.tabControl1); + this.Name = "SocketClientGatePluginUserControl"; + this.Size = new System.Drawing.Size(244, 247); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.Timer timer1; + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.cs 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; + +namespace AcmContester.Plugins.TesterPlugins.SocketClientGatePlugin +{ + public partial class SocketClientGatePluginUserControl : UserControl + { + public SocketClientGatePluginUserControl() + { + InitializeComponent(); + + string ip = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); + textBox2.Text = ip; + + SocketClientGate gate = SocketClientGate.GetInstance(); + gate.onAddLogText += AddText; + } + + delegate void AddTextCallback(string text); + private void AddTextToTextLog(string text) + { + if (this.textBox1.InvokeRequired) + { + AddTextCallback d = new AddTextCallback(AddTextToTextLog); + this.Invoke(d, new object[] { text }); + } + else + { + string timeStr = DateTime.Now.ToLongTimeString() + "." + DateTime.Now.Millisecond.ToString(); + textBox1.Text += timeStr + " " + text + Environment.NewLine; + if (true) + { + textBox1.Select(textBox1.Text.Length, 0); + textBox1.ScrollToCaret(); + } + } + } + + public void AddText(string type, string text) + { + AddTextToTextLog(type + ": " + text); + //view.AddRow(new LogDataGridView.SystemMessage(text, type)); + } + + private void button1_Click(object sender, EventArgs e) + { + SocketClientGate gate = SocketClientGate.GetInstance(); + gate.CreateClient(textBox2.Text); + gate.Connect(); + } + + private void button2_Click(object sender, EventArgs e) + { + SocketClientGate.GetInstance().Disconnect(); + } + + private void timer1_Tick(object sender, EventArgs e) + { + MessageBox.Show("!"); + if (SocketClientGate.GetInstance().IsConnected() == true) + toolStripStatusLabel1.Text = "CONNECTED"; + else + toolStripStatusLabel1.Text = "not connected"; + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.resx (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/SocketClientGatePlugin/SocketClientGatePluginUserControl.resx 2008-10-23 20:37:56 UTC (rev 421) @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> + <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>127, 17</value> + </metadata> +</root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-22 11:58:37
|
Revision: 420 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=420&view=rev Author: brus07 Date: 2008-10-22 11:58:24 +0000 (Wed, 22 Oct 2008) Log Message: ----------- Added TestRunnerPlugin. In this plugin using Tester for test source. But now using old version of testing module. Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties/ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties/AssemblyInfo.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-21 07:44:02 UTC (rev 419) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-22 11:58:24 UTC (rev 420) @@ -23,6 +23,12 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testData", "Library\testData\testData.csproj", "{4EB54D66-105B-4CFD-8883-CBE7CA70AFA5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TesterPlugins", "TesterPlugins", "{D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestRunnerPlugin", "Plugins\TesterPlugins\TestRunnerPlugin\TestRunnerPlugin.csproj", "{8F305004-8FB7-4F85-8063-3A7041DB840F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner", "Runner\Runner.csproj", "{052D9F77-17AF-42F3-BFBF-975A19383496}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,6 +67,14 @@ {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5}.Release|Any CPU.Build.0 = Release|Any CPU + {8F305004-8FB7-4F85-8063-3A7041DB840F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F305004-8FB7-4F85-8063-3A7041DB840F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F305004-8FB7-4F85-8063-3A7041DB840F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F305004-8FB7-4F85-8063-3A7041DB840F}.Release|Any CPU.Build.0 = Release|Any CPU + {052D9F77-17AF-42F3-BFBF-975A19383496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {052D9F77-17AF-42F3-BFBF-975A19383496}.Debug|Any CPU.Build.0 = Debug|Any CPU + {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.ActiveCfg = Release|Any CPU + {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -72,7 +86,9 @@ {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {69FB4176-F298-4AF7-B714-B6758AA9A58E} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} + {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {20B192BC-FD4D-4ED5-90F5-B5994F995238} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {9462E3BD-67AD-4887-BF4C-8B6A25048941} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} + {8F305004-8FB7-4F85-8063-3A7041DB840F} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} EndGlobalSection EndGlobal Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin ___________________________________________________________________ Added: svn:ignore + bin obj Added: tsvn:logminsize + 5 Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/Properties/AssemblyInfo.cs 2008-10-22 11:58:24 UTC (rev 420) @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestRunnerPlugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("TestRunnerPlugin")] +[assembly: AssemblyCopyright("Copyright © Home 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7defcb4b-5ef7-4f12-97e0-03dcdaccbb09")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.cs 2008-10-22 11:58:24 UTC (rev 420) @@ -0,0 +1,46 @@ +using System; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.LibraryExtention; +using AcmContester.Library.LibraryExtention.Data; + +namespace AcmContester.Plugins.MediatorPlugins.TestRunnerPlugin +{ + public class TestRunnerPlugin: BaseMediatorPlugin + { + WorkRunner runner = new WorkRunner(); + public TestRunnerPlugin() + { + runner.onDataArrived += new WorkRunner.DataArrivedDelegate(runner_onDataArrived); + } + + private bool runner_onDataArrived(SystemMessage message) + { + base.DataArrived(message); + return true; + } + + public override void Send(SystemMessage message) + { + if (message.IsType("ApplicationSystem") && message.Message == "stop") + { + runner.Stop(); + return; + } + + if (message.IsType("TestingSubmit") == true) + runner.AddWork(message.Message); + if (message.IsType("TestingSubmitList") == true) + { + SubmitList list = SubmitList.CreateFromXml(message.Message); + for (int i = 0; i < list.Items.Length; i++) + { + while (runner.IsBusy() == true) + System.Threading.Thread.Sleep(50); + runner.AddWork(list.Items[i].ToString()); + } + + } + } + + } +} Added: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/TestRunnerPlugin.csproj 2008-10-22 11:58:24 UTC (rev 420) @@ -0,0 +1,66 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{8F305004-8FB7-4F85-8063-3A7041DB840F}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>TestRunnerPlugin</RootNamespace> + <AssemblyName>TestRunnerPlugin</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="TestRunnerPlugin.cs" /> + <Compile Include="WorkRunner.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Library\Data\Data.csproj"> + <Project>{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}</Project> + <Name>Data</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Library\LibraryExtention\LibraryExtention.csproj"> + <Project>{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}</Project> + <Name>LibraryExtention</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Runner\Runner.csproj"> + <Project>{052D9F77-17AF-42F3-BFBF-975A19383496}</Project> + <Name>Runner</Name> + </ProjectReference> + <ProjectReference Include="..\..\PluginsFramework\PluginsFramework.csproj"> + <Project>{69FB4176-F298-4AF7-B714-B6758AA9A58E}</Project> + <Name>PluginsFramework</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Copied: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs (from rev 418, ACMServer/trunk/ACMServer/Tester/Library/WorkRunner.cs) =================================================================== --- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs 2008-10-22 11:58:24 UTC (rev 420) @@ -0,0 +1,105 @@ +using System; +using System.Threading; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Plugins.MediatorPlugins.TestRunnerPlugin +{ + class WorkRunner + { + + public delegate bool DataArrivedDelegate(SystemMessage message); + public event DataArrivedDelegate onDataArrived; + + string source = ""; + object working = 0; + Thread thread = new Thread(new ParameterizedThreadStart(Go)); + + internal bool IsBusy() + { + lock (working) + { + if ((int)working == 1 || (thread.ThreadState == ThreadState.Running)) + { + return true; + } + } + return false; + } + + internal bool AddWork(string message) + { + if (IsBusy() == true) + { + return false; + } + + //TODO: tut potribno stavyty lock + // a znimaty vze u samomu Thread'i + // (dyv. na inshe TODO:) + lock (source) + source = message; + + //TODO: potribno jakos obnulyty status thread, + // tak shob ne potribno bulo stvorjuvaty novyj + thread = new Thread(new ParameterizedThreadStart(Go)); + thread.Start(this); + return true; + } + + static void Go(object data) + { + if (data is WorkRunner == false) + throw new ArgumentException(); + + WorkRunner gate = (WorkRunner)data; + + lock (gate.working) + gate.working = 1; + + string copySource; + //TODO: tut potribno znimaty postavlenyj lock + // toj lock postavlenyj u potoci sho vyklykav cej + lock (gate.source) + copySource = gate.source; + gate.Run(copySource); + + lock (gate.working) + gate.working = 0; + } + + void Run(string message) + { + string result; + try + { + result = Checker.Checker.GetResult(message); + } + catch (Exception ex) + { + Log log = Log.GetLog(); + log.Loging("Form1::DataArrived: Error: " + ex.Message, Log.Priority.ERR); + log.Loging("Form1::DataArrived: Error: " + ex.StackTrace, Log.Priority.ERR); + return; + } + + //TODO: ne znaju chy tut potriben lock + lock (this) + { + this.Send(new SystemMessage(result, "TestingResult")); + } + } + + private bool Send(SystemMessage systemMessage) + { + if (onDataArrived != null) + return this.onDataArrived(systemMessage); + return true; + } + + internal void Stop() + { + if (thread != null) + thread.Abort(); + } + } +} Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins/TestRunnerPlugin/WorkRunner.cs ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-21 07:44:11
|
Revision: 419 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=419&view=rev Author: brus07 Date: 2008-10-21 07:44:02 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Added to PluginsFramework UserControl for work with plugins in all application equally (one app, one MediatorKernelGUI, one MediatorKernel, one Config, many Plugins). Modified Paths: -------------- ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx Modified: ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -33,11 +33,7 @@ this.button3 = new System.Windows.Forms.Button(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.textBox2 = new System.Windows.Forms.TextBox(); - this.textBox3 = new System.Windows.Forms.TextBox(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); + this.panel1 = new System.Windows.Forms.Panel(); this.SuspendLayout(); // // button2 @@ -87,57 +83,31 @@ this.textBox2.Size = new System.Drawing.Size(110, 20); this.textBox2.TabIndex = 11; // - // textBox3 + // panel1 // - this.textBox3.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox3.Location = new System.Drawing.Point(3, 3); - this.textBox3.Multiline = true; - this.textBox3.Name = "textBox3"; - this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox3.Size = new System.Drawing.Size(343, 190); - this.textBox3.TabIndex = 12; - // - // tabControl1 - // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.tabControl1.Controls.Add(this.tabPage1); - this.tabControl1.Location = new System.Drawing.Point(12, 70); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(357, 222); - this.tabControl1.TabIndex = 13; + this.panel1.Location = new System.Drawing.Point(12, 70); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(357, 222); + this.panel1.TabIndex = 12; // - // tabPage1 - // - this.tabPage1.Controls.Add(this.textBox3); - this.tabPage1.Location = new System.Drawing.Point(4, 22); - this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(349, 196); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "Main"; - this.tabPage1.UseVisualStyleBackColor = true; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(369, 317); - this.Controls.Add(this.tabControl1); this.Controls.Add(this.textBox2); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.button3); this.Controls.Add(this.label1); this.Controls.Add(this.button2); + this.Controls.Add(this.panel1); this.Name = "Form1"; this.Text = "Gate"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); - this.tabControl1.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.tabPage1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -150,9 +120,7 @@ private System.Windows.Forms.Button button3; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.TextBox textBox3; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.Panel panel1; } } Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -15,6 +15,7 @@ { public partial class Form1 : Form { + MediatorKernelGUI kernel; public Form1() { @@ -23,56 +24,14 @@ textBox2.Text = s; } - MediatorKernel kernel; private void button2_Click(object sender, EventArgs e) { - kernel = new MediatorKernel(); - System.Threading.ThreadPool.QueueUserWorkItem(RunLoadDll); + kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + kernel.Dock = DockStyle.Fill; + this.panel1.Controls.Add(kernel); } - void RunLoadDll(Object ob) - { - kernel.AddControl += new EventHandler<AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs>(kernel_AddControl); - kernel.LoadLists("Dll_Tester", "Dll_Web"); - } - - delegate void AddControlCallback(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e); - void kernel_AddControl(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e) - { - if (this.tabControl1.InvokeRequired) - { - AddControlCallback d = new AddControlCallback(kernel_AddControl); - this.Invoke(d, new object[] { sender, e }); - } - else - { - Control control = e.Control; - control.Dock = DockStyle.Fill; - string name = e.Name; - TabPage page = new TabPage(name); - page.Controls.Add(control); - tabControl1.TabPages.Add(page); - } - } - - delegate void UpdateTextLogCallback(string message, TextBox textBox); - private void UpdateTextLog(string message, TextBox textBox) - { - if (textBox.InvokeRequired) - { - UpdateTextLogCallback d = new UpdateTextLogCallback(UpdateTextLog); - this.Invoke(d, new object[] { message }); - } - else - { - textBox.Text += message; - textBox.Select(textBox3.Text.Length, 0); - textBox.ScrollToCaret(); - } - - } - private void button3_Click(object sender, EventArgs e) { Disconnnect(); Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,58 @@ +namespace AcmContester.Plugins.PluginsFramework +{ + partial class MediatorKernelGUI + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(359, 282); + this.tabControl1.TabIndex = 0; + // + // MediatorKernelGUI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tabControl1); + this.Name = "MediatorKernelGUI"; + this.Size = new System.Drawing.Size(359, 282); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + } +} Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Plugins.PluginsFramework +{ + public partial class MediatorKernelGUI : UserControl + { + MediatorKernel mediator = new MediatorKernel(); + + private MediatorKernelGUI() + { + InitializeComponent(); + } + + public MediatorKernelGUI(string testerFolderPath, string clientFolderPath) + { + InitializeComponent(); + LoadLists(testerFolderPath, clientFolderPath); + } + + private void LoadLists(string testerFolderPath, string clientFolderPath) + { + List<string> list = new List<string>(); + list.Add(testerFolderPath); + list.Add(clientFolderPath); + System.Threading.ThreadPool.QueueUserWorkItem(RunLoadDll,list); + } + + private void RunLoadDll(Object ob) + { + if (ob is List<string> == false) + throw new ArgumentException(); + List<string> list = (List<string>)ob; + if (list.Count != 2) + throw new ArgumentException(); + string testerFolderPath = list[0]; + string clientFolderPath = list[1]; + + mediator.AddControl += new EventHandler<MediatorKernel.ControlEventArgs>(mediator_AddControl); + mediator.LoadLists(testerFolderPath, clientFolderPath); + } + + private delegate void AddControlCallback(object sender, MediatorKernel.ControlEventArgs e); + private void mediator_AddControl(object sender, MediatorKernel.ControlEventArgs e) + { + if (this.tabControl1.InvokeRequired) + { + AddControlCallback d = new AddControlCallback(mediator_AddControl); + this.Invoke(d, new object[] { sender, e }); + } + else + { + Control control = e.Control; + control.Dock = DockStyle.Fill; + string name = e.Name; + TabPage page = new TabPage(name); + page.Controls.Add(control); + tabControl1.TabPages.Add(page); + } + } + + public void SendToAll(SystemMessage message) + { + mediator.SendToAll(message); + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-21 07:44:02 UTC (rev 419) @@ -29,11 +29,20 @@ </PropertyGroup> <ItemGroup> <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="BaseMediatorPlugin.cs" /> <Compile Include="MediatorKernel.cs" /> + <Compile Include="MediatorKernelGUI.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="MediatorKernelGUI.Designer.cs"> + <DependentUpon>MediatorKernelGUI.cs</DependentUpon> + </Compile> <Compile Include="PluginsLoader.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> @@ -43,6 +52,12 @@ <Name>LibraryExtention</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="MediatorKernelGUI.resx"> + <SubType>Designer</SubType> + <DependentUpon>MediatorKernelGUI.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-14 22:35:26
|
Revision: 418 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=418&view=rev Author: brus07 Date: 2008-10-14 22:35:16 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Added folder structure for TesterPlugins. Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMTester.sln Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/TesterPlugins/ Modified: ACMServer/trunk/ACMServer/ACMTester.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMTester.sln 2008-10-14 21:52:59 UTC (rev 417) +++ ACMServer/trunk/ACMServer/ACMTester.sln 2008-10-14 22:35:16 UTC (rev 418) @@ -13,6 +13,12 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data", "Library\Data\Data.csproj", "{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{99406CE6-D303-4383-A33D-948E1BBE2537}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsFramework", "Plugins\PluginsFramework\PluginsFramework.csproj", "{69FB4176-F298-4AF7-B714-B6758AA9A58E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TesterPlugins", "TesterPlugins", "{9A3BBF7F-8FCA-4AA1-8531-6DE6EFEB2F4D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +45,10 @@ {30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}.Debug|Any CPU.Build.0 = Debug|Any CPU {30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}.Release|Any CPU.ActiveCfg = Release|Any CPU {30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}.Release|Any CPU.Build.0 = Release|Any CPU + {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -47,5 +57,7 @@ {211DD6A5-2D73-439E-8722-ED2C89ED1DDB} = {72651BCE-2999-49F0-8B33-4F6E4EE824D0} {A8135069-F8BA-4E5D-835F-3FF3F350AA5D} = {72651BCE-2999-49F0-8B33-4F6E4EE824D0} {30C0EFA3-36A8-4C6F-8FEC-28F771D4933F} = {72651BCE-2999-49F0-8B33-4F6E4EE824D0} + {69FB4176-F298-4AF7-B714-B6758AA9A58E} = {99406CE6-D303-4383-A33D-948E1BBE2537} + {9A3BBF7F-8FCA-4AA1-8531-6DE6EFEB2F4D} = {99406CE6-D303-4383-A33D-948E1BBE2537} EndGlobalSection EndGlobal Property changes on: ACMServer/trunk/ACMServer/Plugins/TesterPlugins ___________________________________________________________________ Added: tsvn:logminsize + 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-14 21:53:07
|
Revision: 417 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=417&view=rev Author: brus07 Date: 2008-10-14 21:52:59 +0000 (Tue, 14 Oct 2008) Log Message: ----------- MediatorKernel moved to PluginsFramework Modified Paths: -------------- ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Mediator/Mediator.csproj ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernel.cs Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-14 20:29:04 UTC (rev 416) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-14 21:52:59 UTC (rev 417) @@ -9,6 +9,7 @@ using System.Net.Sockets; using System.IO; using AcmContester.Library.LibraryExtention; +using AcmContester.Plugins.PluginsFramework; namespace Mediator { @@ -22,22 +23,22 @@ textBox2.Text = s; } - AcmContester.Mediator.Library.MediatorKernel kernel; + MediatorKernel kernel; private void button2_Click(object sender, EventArgs e) { - kernel = new AcmContester.Mediator.Library.MediatorKernel(); + kernel = new MediatorKernel(); System.Threading.ThreadPool.QueueUserWorkItem(RunLoadDll); } void RunLoadDll(Object ob) { - kernel.AddControl += new EventHandler<AcmContester.Mediator.Library.MediatorKernel.ControlEventArgs>(kernel_AddControl); - kernel.LoadLists(); + kernel.AddControl += new EventHandler<AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs>(kernel_AddControl); + kernel.LoadLists("Dll_Tester", "Dll_Web"); } - delegate void AddControlCallback(object sender, AcmContester.Mediator.Library.MediatorKernel.ControlEventArgs e); - void kernel_AddControl(object sender, AcmContester.Mediator.Library.MediatorKernel.ControlEventArgs e) + delegate void AddControlCallback(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e); + void kernel_AddControl(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e) { if (this.tabControl1.InvokeRequired) { Modified: ACMServer/trunk/ACMServer/Mediator/Mediator.csproj =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-14 20:29:04 UTC (rev 416) +++ ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-14 21:52:59 UTC (rev 417) @@ -42,7 +42,6 @@ <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> - <Compile Include="Library\MediatorKernel.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="Form1.resx"> @@ -83,6 +82,9 @@ <Name>PluginsFramework</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <Folder Include="Library\" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Copied: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernel.cs (from rev 414, ACMServer/trunk/ACMServer/Mediator/Library/MediatorKernel.cs) =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernel.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernel.cs 2008-10-14 21:52:59 UTC (rev 417) @@ -0,0 +1,108 @@ +using System; +using System.Collections; +using AcmContester.Plugins.PluginsFramework; +using System.Collections.Generic; +using System.Windows.Forms; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Plugins.PluginsFramework +{ + public class MediatorKernel + { + List<BaseMediatorPlugin> clientSideList; + List<BaseMediatorPlugin> testerSideList; + + public sealed class ControlEventArgs : EventArgs + { + Control control; + string name; + public ControlEventArgs(Control in_Control, string in_Name) + { + control = in_Control; + name = in_Name; + } + public Control Control + { + get + { + return control; + } + } + public string Name + { + get + { + return name; + } + } + + } + + public event EventHandler<ControlEventArgs> AddControl; + + public void LoadLists(string testerFolderPath, string clientFolderPath) + { + LoadAllTesterList(testerFolderPath); + LoadAllClientList(clientFolderPath); + } + + public void LoadAllTesterList(string folderPath) + { + testerSideList = PluginsLoader<BaseMediatorPlugin>.Load(folderPath); + foreach (BaseMediatorPlugin plugin in testerSideList) + { + plugin.onDataArrived += DataArrivedFromTesterList; + if (plugin.Control != null) + { + this.OnAddControl(new ControlEventArgs(plugin.Control, plugin.GetType().Name)); + } + } + } + public void LoadAllClientList(string folderPath) + { + clientSideList = PluginsLoader<BaseMediatorPlugin>.Load(folderPath); + foreach (BaseMediatorPlugin plugin in clientSideList) + { + plugin.onDataArrived += DataArrivedFromClientList; + if (plugin.Control != null) + { + this.OnAddControl(new ControlEventArgs(plugin.Control, plugin.GetType().Name)); + } + } + } + + private void OnAddControl(ControlEventArgs e) + { + EventHandler<ControlEventArgs> temp = AddControl; + if (temp != null) + temp(this, e); + } + + private void DataArrivedFromClientList(SystemMessage message) + { + if (testerSideList != null) + { + for (int index = 0; index < testerSideList.Count; index++) + { + ((BaseMediatorPlugin)testerSideList[index]).Send(message); + } + } + } + private void DataArrivedFromTesterList(SystemMessage message) + { + if (clientSideList != null) + { + for (int index = 0; index < clientSideList.Count; index++) + { + ((BaseMediatorPlugin)clientSideList[index]).Send(message); + } + } + } + + public void SendToAll(SystemMessage message) + { + DataArrivedFromClientList(message); + DataArrivedFromTesterList(message); + } + } +} Property changes on: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernel.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-14 20:29:04 UTC (rev 416) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-14 21:52:59 UTC (rev 417) @@ -33,6 +33,7 @@ </ItemGroup> <ItemGroup> <Compile Include="BaseMediatorPlugin.cs" /> + <Compile Include="MediatorKernel.cs" /> <Compile Include="PluginsLoader.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs 2008-10-14 20:29:04 UTC (rev 416) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs 2008-10-14 21:52:59 UTC (rev 417) @@ -43,7 +43,11 @@ ///\xE3\xE5\xED\xE5\xF0\xF3\xBA\xF2\xFC\xF1\xFF \xEF\xEE\xF2\xF0\xB3\xE1\xED\xE8\xE9 \xF8\xEB\xFF\xF5 \xE4\xEE dll \xF3 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xBF directory string fileName = directory.Substring(directory.LastIndexOf('\\')+1) + ".dll"; string fileFullName = directory + "\\" + fileName; - ScanAndLoad(fileFullName, ref plugins); + List<T> lst = ScanAndLoad(fileFullName); + foreach(T t in lst) + { + plugins.Add(t); + } } return plugins; } @@ -54,11 +58,12 @@ /// </summary> /// <param name="filename">Which file to scan.</param> /// <param name="lst">Where to add found objects.</param> - private static void ScanAndLoad(string filename, ref List<T> lst) + public static List<T> ScanAndLoad(string filename) { + List<T> lst = new List<T>(); if (File.Exists(filename) == false) { - return; + return lst; } Assembly assembly; @@ -68,7 +73,7 @@ } catch { - return; + return lst; } if (assembly != null) { @@ -99,6 +104,7 @@ } } } + return lst; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-14 20:29:16
|
Revision: 416 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=416&view=rev Author: brus07 Date: 2008-10-14 20:29:04 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Added class for work with IniFiles. (not tested) Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs Added: ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/IniFile.cs 2008-10-14 20:29:04 UTC (rev 416) @@ -0,0 +1,96 @@ +using System; +using System.IO; +using System.Text; +using System.Runtime.InteropServices; + +namespace AcmContester.Library.LibraryExtention +{ + /// <summary> + /// Class to read from INI files. Based loosely on the Delphi class of the same name. + /// </summary> + public class IniFile + { + private string fileName; + + /// <summary> + /// Creates a new <see cref="IniFile"/> instance. + /// </summary> + /// <param name="fileName">Name of the INI file.</param> + public IniFile(string fileName) + { + if (!File.Exists(fileName)) + throw new FileNotFoundException(fileName + " does not exist", fileName); + this.fileName = fileName; + } + + // native methods + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, + string key, string def, StringBuilder retVal, int size, string filePath); + + [DllImport("kernel32")] + private static extern int GetPrivateProfileSection(string section, IntPtr lpReturnedString, + int nSize, string lpFileName); + + [DllImport("kernel32")] + private static extern long WritePrivateProfileString(string section, + string key, string val, string filePath); + + + /// <summary> + /// Reads a string value from the INI file. + /// </summary> + /// <param name="section">Section to read.</param> + /// <param name="key">Key to read.</param> + public string ReadString(string section, string key) + { + const int bufferSize = 255; + //TODO: jaksho bilshe za bufferSize todi Exception + StringBuilder temp = new StringBuilder(bufferSize); + GetPrivateProfileString(section, key, "", temp, bufferSize, fileName); + return temp.ToString(); + } + + /// <summary> + /// Reads a whole section of the INI file. + /// </summary> + /// <param name="section">Section to read.</param> + public string[] ReadSection(string section) + { + const int bufferSize = 2048; + //TODO: jaksho bilshe za bufferSize todi Exception + + StringBuilder returnedString = new StringBuilder(); + + IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize); + try + { + int bytesReturned = GetPrivateProfileSection(section, pReturnedString, bufferSize, fileName); + + //bytesReturned -1 to remove trailing \0 + for (int i = 0; i < bytesReturned - 1; i++) + returnedString.Append((char)Marshal.ReadByte(new IntPtr((uint)pReturnedString + (uint)i))); + } + finally + { + Marshal.FreeCoTaskMem(pReturnedString); + } + + string sectionData = returnedString.ToString(); + return sectionData.Split('\0'); + } + + /// <summary> + /// Write Data to the INI File + /// </summary> + /// <PARAM name="Section"><Section name/PARAM> + /// <PARAM name="Key">Key Name</PARAM> + /// <PARAM name="Value">Value Name</PARAM> + public void WriteString(string section, string key, string value) + { + WritePrivateProfileString(section, key, value, fileName); + } + + } + +} Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-13 18:19:46 UTC (rev 415) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-14 20:29:04 UTC (rev 416) @@ -33,6 +33,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="IniFile.cs" /> <Compile Include="Log.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Reader.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-13 18:19:57
|
Revision: 415 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=415&view=rev Author: brus07 Date: 2008-10-13 18:19:46 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Delete old example plugin. Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln Removed Paths: ------------- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/Plugin1/ Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-10 21:36:40 UTC (rev 414) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2008-10-13 18:19:46 UTC (rev 415) @@ -13,8 +13,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MediatorPlugins", "MediatorPlugins", "{E4F4B91E-CC25-410B-B53A-E2507EFA4FCB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin1", "Plugins\MediatorPlugins\Plugin1\Plugin1.csproj", "{B75187D7-2032-44F3-AC12-20804C7229AC}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsFramework", "Plugins\PluginsFramework\PluginsFramework.csproj", "{69FB4176-F298-4AF7-B714-B6758AA9A58E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebGatePlugin", "Plugins\MediatorPlugins\WebGatePlugin\WebGatePlugin.csproj", "{20B192BC-FD4D-4ED5-90F5-B5994F995238}" @@ -43,10 +41,6 @@ {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Release|Any CPU.Build.0 = Release|Any CPU - {B75187D7-2032-44F3-AC12-20804C7229AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B75187D7-2032-44F3-AC12-20804C7229AC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B75187D7-2032-44F3-AC12-20804C7229AC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B75187D7-2032-44F3-AC12-20804C7229AC}.Release|Any CPU.Build.0 = Release|Any CPU {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Debug|Any CPU.Build.0 = Debug|Any CPU {69FB4176-F298-4AF7-B714-B6758AA9A58E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -78,7 +72,6 @@ {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {69FB4176-F298-4AF7-B714-B6758AA9A58E} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} - {B75187D7-2032-44F3-AC12-20804C7229AC} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {20B192BC-FD4D-4ED5-90F5-B5994F995238} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} {9462E3BD-67AD-4887-BF4C-8B6A25048941} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} EndGlobalSection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-10-10 21:36:46
|
Revision: 414 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=414&view=rev Author: brus07 Date: 2008-10-10 21:36:40 +0000 (Fri, 10 Oct 2008) Log Message: ----------- Separate Socket and Work (Testing) into two different module and added Mediator module. Modified Paths: -------------- ACMServer/trunk/ACMServer/Tester/Form1.cs ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs ACMServer/trunk/ACMServer/Tester/Library/WorkRunner.cs ACMServer/trunk/ACMServer/Tester/Tester.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Tester/Library/ISocketMediator.cs ACMServer/trunk/ACMServer/Tester/Library/IWorkerMediator.cs ACMServer/trunk/ACMServer/Tester/Library/WorkMediator.cs Modified: ACMServer/trunk/ACMServer/Tester/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-10-10 19:05:39 UTC (rev 413) +++ ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -14,6 +14,8 @@ public partial class Form1 : Form { static SocketClientGate socket; + static WorkRunner worker; + static WorkMediator mediator; public Form1() { @@ -51,6 +53,12 @@ socket.onAddLogText += AddText; } socket.Connect(); + + if (worker == null) + { + worker = new WorkRunner(); + } + mediator = WorkMediator.GetInstance(worker, socket); } private void button2_Click(object sender, EventArgs e) @@ -65,6 +73,11 @@ socket.Disconnect(); socket = null; } + if (worker != null) + { + worker.Stop(); + worker = null; + } } delegate void AddTextCallback(string text); Added: ACMServer/trunk/ACMServer/Tester/Library/ISocketMediator.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/ISocketMediator.cs (rev 0) +++ ACMServer/trunk/ACMServer/Tester/Library/ISocketMediator.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -0,0 +1,12 @@ +using System; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Tester.Library +{ + interface ISocketMediator + { + bool Send(SystemMessage message); + bool Arrived(SystemMessage message); + bool IsBusy(); + } +} Added: ACMServer/trunk/ACMServer/Tester/Library/IWorkerMediator.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/IWorkerMediator.cs (rev 0) +++ ACMServer/trunk/ACMServer/Tester/Library/IWorkerMediator.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -0,0 +1,11 @@ +using System; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Tester.Library +{ + interface IWorkerMediator + { + bool Send(SystemMessage message); + bool Arrived(SystemMessage message); + } +} Modified: ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs 2008-10-10 19:05:39 UTC (rev 413) +++ ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -7,23 +7,29 @@ { class SocketClientGate: AbstractConnector { + ISocketMediator mediator; + SocketClientTask client; - //TODO: tut vin tymchasovo, potribno bude perenesty jogo kudys dali - private WorkRunner workRunner = new WorkRunner(); - public SocketClientGate(string IP) { client = new SocketClientTask(IP); client.onDataArrived +=new SocketClient.DataArrivedDelegate(SocketClientGate_onDataArrived); client.onAddLogText += OnAddLogText; client.isBusy += IsBusy; - workRunner.onDataArrived += Send; } + public ISocketMediator Mediator + { + set + { + mediator = value; + } + } + bool IsBusy() { - return workRunner.IsBusy(); + return mediator.IsBusy(); } void SocketClientGate_onDataArrived(SystemMessage message) @@ -32,7 +38,7 @@ if (message.IsType("TestingSubmit") == true) { - workRunner.AddWork(message.Message); + OnDataArrived(message); } } @@ -64,7 +70,6 @@ public void Disconnect() { client.Disconnect(); - workRunner.Stop(); } public bool IsConnected() { Added: ACMServer/trunk/ACMServer/Tester/Library/WorkMediator.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/WorkMediator.cs (rev 0) +++ ACMServer/trunk/ACMServer/Tester/Library/WorkMediator.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -0,0 +1,93 @@ +using System; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Tester.Library +{ + sealed class WorkMediator: ISocketMediator, IWorkerMediator + { + private static WorkMediator instance = new WorkMediator(); + + WorkRunner runner; + SocketClientGate socketClient; + + private WorkMediator() + { + } + void init(WorkRunner runner, SocketClientGate client) + { + if (this.runner == null) + { + this.runner = runner; + + this.runner.onDataArrived += ((IWorkerMediator)this).Arrived; + } + if (this.socketClient == null) + { + this.socketClient = client; + this.socketClient.Mediator = (ISocketMediator)this; + this.socketClient.onDataArrived += SocketArrived; + } + } + public static WorkMediator GetInstance(WorkRunner runner, SocketClientGate client) + { + instance.init(runner, client); + return instance; + } + public static WorkMediator GetInstance() + { + return instance; + } + + + public bool Send(SystemMessage message) + { + throw new Exception("The method or operation is not implemented."); + } + + public bool Arrived(SystemMessage message) + { + throw new Exception("The method or operation is not implemented."); + } + + void SocketArrived(SystemMessage messsage) + { + ((ISocketMediator)this).Arrived(messsage); + } + + #region ISocket Members + + bool ISocketMediator.Send(SystemMessage message) + { + return socketClient.Send(message); + } + + bool ISocketMediator.Arrived(SystemMessage message) + { + return ((IWorkerMediator)this).Send(message); + } + + public bool IsBusy() + { + return runner.IsBusy(); + } + + + #endregion + + #region IWorker Members + + bool IWorkerMediator.Send(SystemMessage message) + { + if (message.IsType("TestingSubmit") == true) + return runner.AddWork(message.Message); + return true; + } + + bool IWorkerMediator.Arrived(SystemMessage message) + { + return ((ISocketMediator)this).Send(message); + } + + #endregion + } +} Modified: ACMServer/trunk/ACMServer/Tester/Library/WorkRunner.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/WorkRunner.cs 2008-10-10 19:05:39 UTC (rev 413) +++ ACMServer/trunk/ACMServer/Tester/Library/WorkRunner.cs 2008-10-10 21:36:40 UTC (rev 414) @@ -27,11 +27,11 @@ return false; } - internal void AddWork(string message) + internal bool AddWork(string message) { if (IsBusy() == true) { - return; + return false; } //TODO: tut potribno stavyty lock @@ -44,6 +44,7 @@ // tak shob ne potribno bulo stvorjuvaty novyj thread = new Thread(new ParameterizedThreadStart(Go)); thread.Start(this); + return true; } static void Go(object data) Modified: ACMServer/trunk/ACMServer/Tester/Tester.csproj =================================================================== --- ACMServer/trunk/ACMServer/Tester/Tester.csproj 2008-10-10 19:05:39 UTC (rev 413) +++ ACMServer/trunk/ACMServer/Tester/Tester.csproj 2008-10-10 21:36:40 UTC (rev 414) @@ -46,7 +46,10 @@ <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> + <Compile Include="Library\ISocketMediator.cs" /> + <Compile Include="Library\IWorkerMediator.cs" /> <Compile Include="Library\WorkRunner.cs" /> + <Compile Include="Library\WorkMediator.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="Form1.resx"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |