Exemplo n.º 1
0
bool SMOnlineRoom::GetPlayerName(const MString& data, MString& name)
{
    unsigned int pos1 = data.find('"');
    unsigned int pos2 = data.find('"', pos1+1);
    if (pos1 != pos2)
        if (pos1 != string::npos)
            if (pos2 != string::npos) {
                pos1++;
                name = data.substr(pos1, pos2 - pos1);
                return true;
            }
    return false;
}
Exemplo n.º 2
0
ChatCommandPack SMOnlineRoom::ParseCommands(MString& data, unsigned int clientNum) {
    MString command;
    m_cNum = clientNum;

    if (data.find("/") != 0) {
        return ChatCommandPack(NONE);
    }
    command = GetCommand(data);

    ChatCommandPack ccp;

    if (m_clients[clientNum]->IsAdmin())
    {
        if (Announce(command, data, ccp))
            return ccp;
        if (Drop(command, data, ccp))
            return ccp;
    }

    if (Kick(command, data, ccp))
        return ccp;
    if (Ban(command, data, ccp))
        return ccp;
    if (Msg(command, data, ccp))
        return ccp;

    return ccp;
}
Exemplo n.º 3
0
MString SMOnlineRoom::GetCommand(MString& data) {
    MString command;
    int pos = data.find(" ");
    if (pos > 0) {
        command = data.substr(1, pos);
    }
    return command;
}
Exemplo n.º 4
0
bool SMOnlineRoom::Drop(const MString& command, const MString& data, ChatCommandPack& ccp)
{
    MString name;
    if (command.find("drop") == 0)
    {
        GetPlayerName(data, name);
        ccp.cmd = DROP;
        ccp.data.push(name);
        return true;
    }
    return false;
}
Exemplo n.º 5
0
bool SMOnlineRoom::Announce(const MString& command, const MString& data, ChatCommandPack& ccp)
{
    MString message;

    if (command.find("announce") != 0)
        return false;

    message = data.substr(command.length()+1);
    ccp.cmd = ANNOUNCE;
    ccp.data.push(data.substr(command.length()+1));
    return true;
}
Exemplo n.º 6
0
int
MDBImageManager::fillSeriesVector(const MPatientStudy& study,
				     const MSeries& series, MSeriesVector& v)
{
  char* searchCriteria[] = {
    "serinsuid",
    "mod",
    "sernum"
  };

  int i;
  MCriteriaVector criteria;

  MString studyInstanceUID = study.studyInstanceUID();
  if (studyInstanceUID != "") {
    MCriteria p;
    p.attribute = "stuinsuid";
    p.oper = TBL_EQUAL;
    p.value = studyInstanceUID;
    criteria.push_back(p);
  }

  const MDomainMap& m = series.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    MString s = (*iDomain).second;

    // MString s = m[searchCriteria[i]];
    if (s != "") {
      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MSeries s;
  mDBInterface->select(s, criteria, seriesCallback, this);
  MSeriesVector::iterator seriesIterator = mSeriesVector.begin();
  for (; seriesIterator != mSeriesVector.end(); seriesIterator++)
    v.push_back(*seriesIterator);

  return 0;
}
Exemplo n.º 7
0
bool SMOnlineRoom::Kick(const MString& command, const MString& data, ChatCommandPack& ccp)
{
    MString name;
    if (m_roomType == ROOMGame)
        if (command.find("kick") == 0) {
            if (m_cNum == 0) {
                GetPlayerName(data, name);
                ccp.cmd = KICK;
                ccp.data.push(name);
                return true;
            }
        }

    return false;
}
Exemplo n.º 8
0
int
MDBImageManager::fillSOPInstanceVector(const MSeries& series,
				       const MSOPInstance& sopInstance,
				       MSOPInstanceVector& v)
{
  MCriteriaVector criteria;
  MCriteria c;
  c.attribute = "serinsuid";
  c.oper      = TBL_EQUAL;
  c.value     = series.seriesInstanceUID();
  criteria.push_back(c);

  MSOPInstance pattern(sopInstance);
  pattern.seriesInstanceUID(series.seriesInstanceUID());

  char* searchCriteria[] = {
    "insuid",
    "clauid",
    "imanum"
  };

  const MDomainMap& m = sopInstance.map();
  int i;
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    MString s = (*iDomain).second;

    if (s != "") {
      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }

  mDBInterface->select(pattern, criteria, sopInstanceCallback, &v);
  return 0;
}
Exemplo n.º 9
0
int
MDBImageManager::fillPatientVector(const MPatient& patient, MPatientVector& v)
{
  char* searchCriteria[] = {
    "patid",
    "nam",
    "datbir",
    "sex"
  };

  int i;
  MCriteriaVector criteria;

  const MDomainMap& m = patient.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    MString s = (*iDomain).second;

    //MString s = m[searchCriteria[i]];

    if (s != "") {
      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MPatient p;
  mDBInterface->select(p, criteria, patientCallback, this);
  MPatientVector::iterator patientIterator = mPatientVector.begin();
  for (; patientIterator != mPatientVector.end(); patientIterator++)
    v.push_back(*patientIterator);

  return 0;
}
Exemplo n.º 10
0
bool SMOnlineRoom::Msg(const MString& command, const MString& data, ChatCommandPack& ccp)
{
    MString tmp;
    MString user;
    MString message;
    if (command.find("msg") == 0)
    {
        tmp = data.substr(command.length()+1);
        if (tmp.length() > 0)
        {
            if (GetPlayerName(data, user))
                if (tmp.length() >= (user.length()+3))
                {
                    ccp.cmd = PM;
                    ccp.data.push(user);
                    ccp.data.push(tmp.substr(user.length()+3));
                    return true;
                }
        }
    }
    return false;
}
Exemplo n.º 11
0
int
MDBImageManager::fillPatientStudyVector(const MPatientStudy& patientStudy,
					MPatientStudyVector& v)
{

  char* searchCriteria[] = {
    "patid",
    "nam",
    "datbir",
    "sex",
    "stuinsuid",
    // "studat",	// Comment this out; treat for date range
    "stutim",
    "accnum",
    "stuid",
    "modinstu"
  };

  int i;
  MCriteriaVector criteria;

  MString studyDate = patientStudy.studyDate();
  if (studyDate != "") {
    if (studyDate.containsCharacter('-')) {
      MString lower = studyDate.getToken('-', 0);
      MString upper = studyDate.getToken('-', 1);
      if (lower != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_GREATER_EQUAL;
	p.value = lower;
	criteria.push_back(p);
      }
      if (upper != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_LESS_EQUAL;
	p.value = upper;
	criteria.push_back(p);
      }
    } else {
      MCriteria p;
      p.attribute = "studat";
      p.oper = TBL_EQUAL;
      p.value = studyDate;
      criteria.push_back(p);
    }
  }


  const MDomainMap& m = patientStudy.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    if (iDomain == m.end())   // added for testing -- does this need to be here?
      continue;
    MString s = (*iDomain).second;

    // MString s = m[searchCriteria[i]];

    if (s != "") {
      if ((*iDomain).first == "modinstu") {
	s = "*" + s + "*";
      }

      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MPatientStudy p;
  mDBInterface->select(p, criteria, patientStudyCallback, &v);
#if 0
  MPatientVector::iterator patientIterator = mPatientVector.begin();
  for (; patientIterator != mPatientVector.end(); patientIterator++)
    v.push_back(*patientIterator);
#endif

  return 0;
}
Exemplo n.º 12
0
int
MDBImageManager::fillStudyVector(const MStudy& study, MStudyVector& v)
{
  char* searchCriteria[] = {
    "stuinsuid",
    // "studat",		// Comment out as we treat this for date range
    "stutim",
    "accnum",
    "stuid"
  };

  MCriteriaVector criteria;

  MString studyDate = study.studyDate();
  if (studyDate != "") {
    if (studyDate.containsCharacter('-')) {
      MString lower = studyDate.getToken('-', 0);
      MString upper = studyDate.getToken('-', 1);
      if (lower != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_GREATER_EQUAL;
	p.value = lower;
	criteria.push_back(p);
      }
      if (upper != "") {
	MCriteria p;
	p.attribute = "studat";
	p.oper = TBL_LESS_EQUAL;
	p.value = upper;
	criteria.push_back(p);
      }
    } else {
      MCriteria p;
      p.attribute = "studat";
      p.oper = TBL_EQUAL;
      p.value = studyDate;
      criteria.push_back(p);
    }
  }


  int i;

  const MDomainMap& m = study.map();
  for(i = 0; i < (int)DIM_OF(searchCriteria); i++) {
    MDomainMap::const_iterator iDomain = m.find(searchCriteria[i]);
    if (iDomain == m.end())
      continue;

    MString s = (*iDomain).second;

    if (s != "") {
      TBL_OPERATOR oper = TBL_EQUAL;
      if (s.find("*") != string::npos) {
	s.substitute('*', '%');
	oper = TBL_LIKE;
      }
      MCriteria c;
      c.attribute = searchCriteria[i];
      c.oper = oper;
      c.value = s;
      criteria.push_back(c);
    }
  }
  MStudy s;
  mDBInterface->select(s, criteria, studyCallback, this);
  MStudyVector::iterator studyIterator = mStudyVector.begin();
  for (; studyIterator != mStudyVector.end(); studyIterator++)
    v.push_back(*studyIterator);

  return 0;
}