Esempio n. 1
0
void CConfigGeneral::store(CConfigManager &ConfMan)const
{
	storeOutput(ConfMan.GetSection(_T("Output")));
	storeLogView(ConfMan.GetSection(_T("LogView")));
	storeFiler(ConfMan.GetSection(_T("Filer")));
	storeGeneral(ConfMan.GetSection(_T("General")));
}
Esempio n. 2
0
void GeneralResult::prepareCalculations(oTeam &team) const {
  int nr = team.getNumRunners();
  for (int j = 0; j < nr; j++) {
    pRunner r = team.getRunner(j);
    if (r) {
      prepareCalculations(*r);
      r->tmpResult.runningTime = deduceTime(*r, r->getStartTime()); //XXX
      r->tmpResult.status = deduceStatus(*r);
      r->tmpResult.place = 0;//XXX?
      r->tmpResult.timeAfter = 0;//XXX?
      r->tmpResult.points = deducePoints(*r);
      storeOutput(r->tmpResult.outputTimes,
                  r->tmpResult.outputNumbers);
    }
  }
}
Esempio n. 3
0
pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aexitcode)
{
  BOOL success;
  STARTUPINFO startupinfo;
  SECURITY_ATTRIBUTES securityattributes;
  SECURITY_DESCRIPTOR securitydescriptor;
  PROCESS_INFORMATION processinformation;
  HANDLE  newstdin, newstdout, readstdout, writestdin;
  char *inputpos;
  DWORD transfered;
  int size;

  LogMessage("commandline:\n", acommandline, "\n");

  ZeroMemory(&securityattributes, sizeof(securityattributes));
  securityattributes.nLength=sizeof(SECURITY_ATTRIBUTES);
  securityattributes.bInheritHandle=TRUE;

  if(isWindowsNT())
  {
    InitializeSecurityDescriptor(&securitydescriptor, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&securitydescriptor, TRUE, NULL, FALSE);
    securityattributes.lpSecurityDescriptor=&securitydescriptor;
  }
  else securityattributes.lpSecurityDescriptor=NULL;

  success=CreatePipe(&newstdin, &writestdin ,&securityattributes ,0);
  if(! success)
  {
    LogMessage("--- ", "create pipe failed", "\n");
    return pxCreatePipeFailed;
  }

  success=CreatePipe(&readstdout, &newstdout, &securityattributes, 0);
  if(! success)
  {
    LogMessage("--- ", "create pipe failed", "\n");
    CloseHandle(newstdin);
    CloseHandle(writestdin);
    return pxCreatePipeFailed;
  }

  GetStartupInfo(&startupinfo);
  startupinfo.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
  startupinfo.wShowWindow=SW_HIDE;
  startupinfo.hStdOutput=newstdout;
  startupinfo.hStdError=newstdout;
  startupinfo.hStdInput=newstdin;

  success=CreateProcess(NULL, acommandline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupinfo, &processinformation);

  if(! success)
  {
    LogMessage("--- ", "create process failed", "\n");
    CloseHandle(newstdin);
    CloseHandle(writestdin);
    CloseHandle(newstdout);
    CloseHandle(readstdout);
    return pxCreateProcessFailed;
  }

  inputpos=ainput;

  while(TRUE)
  {
    success=GetExitCodeProcess(processinformation.hProcess, aexitcode);
    if((success)&&(*aexitcode!=STILL_ACTIVE)) break;

    storeOutput(readstdout, aoutput);

    if(*inputpos!='\0') size=1;
    else size=0;

    success=WriteFile(writestdin, inputpos, size, &transfered, NULL);

    inputpos+=transfered;
  }

  storeOutput(readstdout, aoutput);
  WaitForSingleObject(processinformation.hProcess, INFINITE);

  LogMessage("output:\n", *aoutput, "");

  CloseHandle(processinformation.hThread);
  CloseHandle(processinformation.hProcess);
  CloseHandle(newstdin);
  CloseHandle(newstdout);
  CloseHandle(readstdout);
  CloseHandle(writestdin);

  return pxSuccess;
}
Esempio n. 4
0
void GeneralResult::calculateIndividualResults(vector<oRunner *> &runners, oListInfo::ResultType resType, bool sortRunners, int inputNumber) const {

  if (runners.empty())
    return;
  prepareCalculations(*runners[0]->oe, false, inputNumber);
  bool classSort = resType == oListInfo::Global ? false : true;
  vector<GRSortInfo> runnerScore(runners.size());
  for (size_t k = 0; k < runners.size(); k++) {
    if (classSort) {
      runnerScore[k].principalSort = runners[k]->Class ? runners[k]->Class->getSortIndex() * 50000
                                                       + runners[k]->Class->getId() : 0;
    }
    else
      runnerScore[k].principalSort = 0;

    int from = getListParamTimeFromControl();
    if (from == 0) {
      runners[k]->tmpResult.startTime =  runners[k]->getStartTime();
    }
    else {
      int rt;
      RunnerStatus stat;
      runners[k]->getSplitTime(from, stat, rt);
      if (stat == StatusOK)
        runners[k]->tmpResult.startTime = runners[k]->getStartTime() + rt;
    }
    prepareCalculations(*runners[k]);
    runners[k]->tmpResult.runningTime = deduceTime(*runners[k], runners[k]->tmpResult.startTime);
    runners[k]->tmpResult.status = deduceStatus(*runners[k]);
    runners[k]->tmpResult.points = deducePoints(*runners[k]);

    runnerScore[k].score = score(*runners[k], runners[k]->tmpResult.status,
                                              runners[k]->tmpResult.runningTime,
                                              runners[k]->tmpResult.points);

    storeOutput(runners[k]->tmpResult.outputTimes,
                runners[k]->tmpResult.outputNumbers);

    runnerScore[k].tr = runners[k];

  }

  ::sort(runnerScore.begin(), runnerScore.end());
  int place = 1;
  int leadtime = 0;
  for (size_t k = 0; k < runnerScore.size(); k++) {
    if (k>0 &&  runnerScore[k-1].principalSort != runnerScore[k].principalSort) {
      place = 1;
    }
    else if (k>0 && runnerScore[k-1].score != runnerScore[k].score) {
      if (runnerScore[k-1].tr->tmpResult.status == StatusOK)
        place++;
    }

    if (runnerScore[k].tr->tmpResult.status == StatusOK) {
      runnerScore[k].tr->tmpResult.place = place;
      if (place == 1) {
        leadtime = runnerScore[k].tr->tmpResult.runningTime;
        runnerScore[k].tr->tmpResult.timeAfter = 0;
      }
      else {
        runnerScore[k].tr->tmpResult.timeAfter = runnerScore[k].tr->tmpResult.runningTime - leadtime;
      }
    }
    else {
      runnerScore[k].tr->tmpResult.place = 0;
      runnerScore[k].tr->tmpResult.timeAfter = 0;
    }
  }

  if (sortRunners) {
    for (size_t k = 0; k < runnerScore.size(); k++) {
      runners[k] = (oRunner *)runnerScore[k].tr;
    }
  }
}
Esempio n. 5
0
void GeneralResult::calculateTeamResults(vector<oTeam *> &teams, oListInfo::ResultType resType, bool sortTeams, int inputNumber) const {
  if (teams.empty())
    return;
  prepareCalculations(*teams[0]->oe, true, inputNumber);

  bool classSort = resType == oListInfo::Global ? false : true;
  vector<GRSortInfo> teamScore(teams.size());
  for (size_t k = 0; k < teams.size(); k++) {
    if (classSort) {
      teamScore[k].principalSort = teams[k]->Class ? teams[k]->Class->getSortIndex() * 50000
                                                     + teams[k]->Class->getId() : 0;
    }
    else
      teamScore[k].principalSort = 0;

    prepareCalculations(*teams[k]);
    teams[k]->tmpResult.runningTime = teams[k]->getStartTime(); //XXX
    teams[k]->tmpResult.runningTime = deduceTime(*teams[k]);
    teams[k]->tmpResult.status = deduceStatus(*teams[k]);
    teams[k]->tmpResult.points = deducePoints(*teams[k]);

    teamScore[k].score = score(*teams[k], teams[k]->tmpResult.status,
                                          teams[k]->tmpResult.runningTime,
                                          teams[k]->tmpResult.points);

    storeOutput(teams[k]->tmpResult.outputTimes,
                teams[k]->tmpResult.outputNumbers);

    teamScore[k].tr = teams[k];

  }

  ::sort(teamScore.begin(), teamScore.end());
  int place = 1;
  int leadtime = 0;
  for (size_t k = 0; k < teamScore.size(); k++) {
    if (k>0 &&  teamScore[k-1].principalSort != teamScore[k].principalSort) {
      place = 1;
    }
    else if (k>0 && teamScore[k-1].score != teamScore[k].score) {
      if (teamScore[k-1].tr->tmpResult.status == StatusOK) 
        place++;
    }

    if (teamScore[k].tr->tmpResult.status == StatusOK) {
      teamScore[k].tr->tmpResult.place = place;
      if (place == 1) {
        leadtime = teamScore[k].tr->tmpResult.runningTime;
        teamScore[k].tr->tmpResult.timeAfter = 0;
      }
      else {
        teamScore[k].tr->tmpResult.timeAfter = teamScore[k].tr->tmpResult.runningTime - leadtime;
      }
    }
    else {
      teamScore[k].tr->tmpResult.place = 0;
      teamScore[k].tr->tmpResult.timeAfter = 0;
    }
  }

  if (sortTeams) {
    for (size_t k = 0; k < teamScore.size(); k++) {
      teams[k] = (oTeam *)teamScore[k].tr;
    }
  }
}