示例#1
0
void Information::addDeleteComp()
{
    Service serv;
    char number;
    string nameToDelete = "";
    string table = "Computers";
    cin >> number;
    cout << endl;

    switch (number) {
        case'1':{
            addComputer();
            cout << endl << "--Computer added to database!--" << endl;
            compSciOrLink();
            break;}
        case'2':{
            deleteStuff('2');
            compSciOrLink();
            break;}
        case'3':{
            compSciOrLink();
            break;}
        default:{
            cout << "This is invalid choice! Please try again!" << endl;
            addDeleteSci();
            break;}
    }
}
示例#2
0
void SWProcess::addInstances(IPropertyTree *parent, IPropertyTree *params)
{
  IPropertyTree* pAttrs = params->queryPropTree("Attributes");
  if (!pAttrs)
     throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance attributes input");

  const char * instanceXMLTagName = getInstanceXMLTagName(params->queryProp("@selector"));

  Owned<IPropertyTreeIterator> iter = pAttrs->getElements("Attribute");

  ForEach (*iter)
  {
     IPropertyTree *attr = &iter->query();
     const char* propName = attr->queryProp("@name");
     if (!stricmp(propName, "ip") || !stricmp(propName, "ipfile"))
     {
        bool isFile = false;
        if (!stricmp(propName, "ipfile")) isFile = true;

        StringArray ips;
        m_envHelper->processNodeAddress(attr->queryProp("@value"), ips, isFile);
        for ( unsigned i = 0; i < ips.ordinality() ; i++)
        {
           IPropertyTree * computerNode = addComputer(ips.item(i));
           addInstance(computerNode, parent, pAttrs, instanceXMLTagName);
        }
     }
  }
}
//========PRIVATE FUNCTIONS==========
//--menus--
void Interface::addCompOrPerson()
{
    newMenu("ADD VIEW");

    char ch = ' ';

    cout << "(1) to add a computer scientist\n"
            "(2) to add a computer\n"
            "enter anything else to go to main menu \n";
    printLines();

    cout << "Choice: ";
    cin.ignore(1, '\n');
    ch = cin.get();

    switch(ch)
    {
    case '1':
        addPerson();
        break;
    case '2':
        addComputer();
        break;
    default:
        break;
    }
}
示例#4
0
void SWProcess::modifyInstance(IPropertyTree *parent, IPropertyTree *params)
{
   IPropertyTree* pAttrs = params->queryPropTree("Attributes");
   if (!pAttrs)
      throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance attributes input");

   const char * instanceXMLTagName = getInstanceXMLTagName(pAttrs->queryProp("@selector"));
   Owned<IPropertyTreeIterator> iter = pAttrs->getElements("Attribute");
   ForEach (*iter)
   {
      IPropertyTree *attr = &iter->query();
      const char* propName = attr->queryProp("@name");
      if (stricmp(propName, "ip"))
         continue;

      StringBuffer xpath;
      IPropertyTree *instanceToModify;
      const char* oldIp = attr->queryProp("@oldValue");
      if ((!oldIp || !(*oldIp)) && m_singleInstanceList.find(m_name.str()) == NotFound)
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance  current ip to change");
      else if (oldIp && *oldIp)
      {
         xpath.clear().appendf("%s[%s=\"%s\"]", instanceXMLTagName, m_ipAttribute.str(), oldIp);
         instanceToModify = parent->queryPropTree(xpath.str());
      }
      else
      {
         xpath.clear().appendf("%s[1]", instanceXMLTagName);
         instanceToModify = parent->queryPropTree(xpath.str());
      }

      if (!instanceToModify)
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Cannot find instance node to modify");

      IPropertyTree * computerNode = addComputer(attr->queryProp("@value"));
      instanceToModify->setProp("@computer", computerNode->queryProp(XML_ATTR_NAME));

      instanceToModify->setProp(m_ipAttribute.str(), computerNode->queryProp(XML_ATTR_NETADDRESS));
  }

}
示例#5
0
void ADOU::performEntry(ADEntry* entry)
{
	if (entry->dnKeys.size() == 0)
	{
		return;
	}
	else if (entry->dnKeys[entry->dnKeys.size() - 1] == _T("OU"))
	{
		CString strLastValue = entry->popKeyValue();
		findOU(strLastValue, entry->getOUDN())->performEntry(entry);
	}
	else if (entry->type == _T("computer"))
	{
		ADComputer *computer = addComputer(entry->cn, entry->dn, domain);
		computer->infos = entry->infos;
	}
	else if (entry->type == _T("user"))
	{
		ADUser *user = addUser(entry->cn, entry->dn);
		user->infos = entry->infos;
	}
	else if (entry->type == _T("localgroup"))
	{
		ADGroup *group = addGroup(entry->cn, entry->dn, domain, _T("local"));
		group->infos = entry->infos;
	}
	else if (entry->type == _T("globalgroup"))
	{
		ADGroup *group = addGroup(entry->cn, entry->dn, domain, _T("global"));
		group->infos = entry->infos;
	}
	else
	{
		MyMessageBox_Error(_T("performEntry Error"), _T("Error"));
	}
}
示例#6
0
Computer modify( vector<Computer>& comp ) {      // User menu that changes a persons template for the modify person operation
    QTextStream in(stdin);
    Computer temp;
    QString text, name, numId;
    QDate year;
    char modify;
    int id = 0;

    cout << "Select a computer to modify(input the number displayed before the name): ";
    while( !(id > 0 && id <= int( comp.size() ) )) {
        numId = in.readLine();
        id = numId.toInt();
    }

    temp = comp[id-1];

    cout << "  1. Name\n" <<
            "  2. Designed/Created\n" <<
            "  3. Type\n" <<
            "  4. Constructed\n" <<
            "  5. All" << endl;
    cout << "What would you like to modify: ";
    cin >> modify;

    switch( modify ) {
    case '1':                                   //To modify name only
        cout << "Name: ";
        cin.ignore();
        name = "";
        while( name == "" )
                name = in.readLine();
        temp.setName( name );
        break;

    case '2':                                   //To modify date created only
        cout << "Designed/Created(yyyy): ";
        year = QDate();
        while( !year.isValid() )
            year = QDate::fromString( in.readLine(), "yyyy" );
        temp.setType( year.toString("yyyy") );

    case '3':                                   //To modify type only
        cout << "Type: ";
        temp.getType() = "";
        while( temp.getType() == "" )
            temp.setType( in.readLine() );
        break;

    case '4':                                   //To modify if construced only
        cout << "Constructed(true/false): ";
        while( text != "true" && text != "True" && text != "1" && text != "false" && text != "False" && text != "0" )
            text = in.readLine();
        if( text == "true" || text == "True" || text == "1" )
            temp.setWasBuilt( true );
        else
            temp.setWasBuilt( false );
        break;

    case '5':                                   //To modify all
        temp = addComputer();

        break;

    default:
        cout << "Not a valid option" << endl;
        break;
    }

    temp.setId( comp[id-1].getId() );

    cout << endl;
    return temp;
}