Exemplo n.º 1
0
void XaUserAddressPhone::Create() {

    
		vector<string> FieldName;	
		vector<string> FieldValue;
		CreatePrepare({"XaUserAddressPhone"},"/XaUserAddressPhone/fieldset/field",FieldName,FieldValue);
        
        string XaTable="XaUser";
        string XaUserId=HTTP.GetHttpParam("XaUser_ID");
        string XaUserAddressPhoneTypeId=HTTP.GetHttpParam("XaUserAddressPhoneType_ID");
        string XaUserAddressPhoneCodeId=HTTP.GetHttpParam("XaUserAddressPhoneCode_ID");
        
        unique_ptr<XaLibSql> LibSql (new XaLibSql());
        
        if (LibSql->CheckRow(DB_READ,XaTable,XaUserId,"1","")==0) {
            LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"Requested Record ID -> "+XaUserId+" does not exist into Table -> "+XaTable);
            throw 302;
        }
        
        if (LibSql->CheckRow(DB_READ,"XaUserAddressPhoneType",XaUserAddressPhoneTypeId,"1","")==0) {
            LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"Requested Record ID -> "+XaUserAddressPhoneTypeId+" does not exist into Table -> XaUserAddressPhoneType");
            throw 302;
        }
        
        if (LibSql->CheckRow(DB_READ,"XaUserAddressPhoneCode",XaUserAddressPhoneCodeId,"1","")==0) {
            LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"Requested Record ID -> "+XaUserAddressPhoneCodeId+" does not exist into Table -> XaUserAddressPhoneCode");
            throw 302;
        }
        
	RESPONSE.Content=CreateResponse(CreateExecute("XaUserAddressPhone",FieldName,FieldValue));
};
Exemplo n.º 2
0
void XaUserAddressGeoType::Create() {

        vector<string> FieldName;	
	vector<string> FieldValue;
	CreatePrepare({"XaUserAddressGeoType"},"/XaUserAddressGeoType/fieldset/field",FieldName,FieldValue);
	RESPONSE.Content=CreateResponse(CreateExecute("XaUserAddressGeoType",FieldName,FieldValue));
};
Exemplo n.º 3
0
void XaMedia::Create(){

    vector<string> FieldName;	
    vector<string> FieldValue;

    //FieldName.push_back("RpRe_ID");
    //FieldValue.push_back(HTTP.GetHttpParam("XaMedia-RpRe_ID"));

    CreatePrepare({"XaMedia"},"/XaMedia/fieldset/field",FieldName,FieldValue);
    CreateExecute("XaMedia",FieldName,FieldValue);
}
Exemplo n.º 4
0
/*
void XaUser::GetXmlModel() {

	ifstream MyFile;
	string Content;

	vector<string> XmlFiles=AddXmlFile({"XaUser"});

	for (auto i=0;i<XmlFiles.size();i++) {

		MyFile.open(XmlFiles[i].c_str());

		if (MyFile.is_open()) {

			string TmpString;

			while(getline(MyFile,TmpString)) {
				XaLibChar::ClearReturn(TmpString);
				Content.append(TmpString);
			}
		}
	}

	RESPONSE.Content="<model>"+Content+"</model>";

};
*/
void XaUser::Create() {

	vector<string> FieldName;	
	vector<string> FieldValue;

	CreatePrepare({"XaUser"},"/XaUser/fieldset/field",FieldName,FieldValue);

	int NextId=CreateExecute("XaUser",FieldName,FieldValue);

	RESPONSE.Content=CreateResponse(NextId);
};
Exemplo n.º 5
0
void XaLanguage::Create() {

	vector<string> FieldName;	
	vector<string> FieldValue;

	CreatePrepare({"XaLanguage"},"/XaLanguage/fieldset/field",FieldName,FieldValue);
	
        int NextId=CreateExecute("XaLanguage",FieldName,FieldValue);
        
        if (NextId!=0) {
	
            unique_ptr<XaLibSql> LibSql (new XaLibSql());

            string qry="SELECT XaLabel_ID FROM XaLabelTranslation, XaLabel WHERE XaLanguage_ID NOT IN ("+FromIntToString(NextId)+") AND XaLabel_id=XaLabel.id GROUP BY XaLabel_ID";

            DbResMap DbRes=LibSql->FreeQuerySelect(DB_READ,qry);

            for(unsigned n=0; n<DbRes.size(); ++n){

                    vector<string> VectorFields;
                    VectorFields.push_back("XaLabel_ID");
                    VectorFields.push_back("XaLanguage_ID");

                    vector<string> VectorValues;
                    VectorValues.push_back(DbRes[n]["XaLabel_ID"]);
                    VectorValues.push_back(FromIntToString(NextId));

                    LibSql->Insert(DB_WRITE,"XaLabelTranslation",VectorFields,VectorValues);
                    
                    VectorFields.clear();
                    VectorValues.clear();

            }

            XaLanguageGen();
            
        }
        
        RESPONSE.Content=CreateResponse(NextId);
};
Exemplo n.º 6
0
void XaMediaData::Create(){

    vector<string> FieldName;	
    vector<string> FieldValue;
    unique_ptr<XaLibChar> LibChar (new XaLibChar());

    string XaMediaId=HTTP.GetHttpParam("XaMedia_ID");
    string File=LibChar->B64Decode(HTTP.GetHttpParam("data"));
    
    int FileSize=File.size();
    double KFileSize = round(FileSize/1024);
    string KSize = FromDoubleToString(KFileSize);
    
    string FileName = ComposeFileName(XaMediaId);
    
    FieldName.push_back("file_name");
    FieldValue.push_back(FileName);
    
    FieldName.push_back("ksize");
    FieldValue.push_back(KSize);

    CreatePrepare({"XaMediaData"},"/XaMediaData/fieldset/field",FieldName,FieldValue);
    CreateExecute("XaMediaData",FieldName,FieldValue);
};
Exemplo n.º 7
0
void XaMedia::CreateComplete(){

    string Type=HTTP.GetHttpParam("type");
    string Name=HTTP.GetHttpParam("name");
    string XaDomainMediaCategoryId="";
    
    if (Type.substr(0,5)=="image") {
        XaDomainMediaCategoryId="854";
    } else {
        XaDomainMediaCategoryId="857";
    }
    
    vector<string> FieldName;	
    vector<string> FieldValue;

    vector<string> FieldNameMedia;
    vector<string> FieldValueMedia;
    vector<string> FieldNameData;
    vector<string> FieldValueData;
    
    // standard method CreatePrepare is run only to check field format and requirement
    CreatePrepare({"XaMediaComplete"},"/XaMediaComplete/fieldset/field",FieldName,FieldValue);
    //CreateExecute("XaMedia",FieldName,FieldValue);
    
    FieldNameMedia.push_back("XaTable");
    FieldValueMedia.push_back(HTTP.GetHttpParam("XaTable"));
    FieldNameMedia.push_back("XaField_ID");
    FieldValueMedia.push_back(HTTP.GetHttpParam("XaField_ID"));
    FieldNameMedia.push_back("XaDomainMediaCategory_ID");
    //FieldValueMedia.push_back(HTTP.GetHttpParam("XaDomainMediaCategory_ID"));
    FieldValueMedia.push_back(XaDomainMediaCategoryId);
    FieldNameMedia.push_back("preferred");
    FieldValueMedia.push_back("2");
    FieldNameMedia.push_back("marked");
    FieldValueMedia.push_back("2");
    
    int MediaId=CreateExecute("XaMedia",FieldNameMedia,FieldValueMedia);
    
    //unique_ptr<XaLibChar> LibChar (new XaLibChar());
    
    string XaMediaId=FromIntToString(MediaId);
    //string File=LibChar->B64Decode(HTTP.GetHttpParam("data","B64"));
    
    string File=HTTP.GetHttpParam("data","B64");
    File=AddPlus(File);
    
    string Thumbnail=HTTP.GetHttpParam("thumbnail","B64");
    
    if (Thumbnail=="NoHttpParam") {
        Thumbnail="";
    } else {
        Thumbnail=AddPlus(Thumbnail);
    }
    
    int FileSize=File.size();
    double KFileSize = round(FileSize/1024);
    string KSize = FromDoubleToString(KFileSize);
    
    string FileName = ComposeFileName(XaMediaId);
    
    FieldNameData.push_back("XaMedia_ID");
    FieldValueData.push_back(XaMediaId);
    
    FieldNameData.push_back("file_name");
    FieldValueData.push_back(FileName);
    
    FieldNameData.push_back("data");
    FieldValueData.push_back(File);
    
    FieldNameData.push_back("thumbnail");
    FieldValueData.push_back(Thumbnail);
    
    FieldNameData.push_back("ksize");
    FieldValueData.push_back(KSize);
    
    FieldNameData.push_back("type");
    FieldValueData.push_back(Type);
    
    FieldNameData.push_back("name");
    FieldValueData.push_back(Name);

    int DataId=CreateExecute("XaMediaData",FieldNameData,FieldValueData);
    
    RESPONSE.Content="<create_media><id>"+FromIntToString(MediaId)+"</id></create_media><create_data><id>"+FromIntToString(DataId)+"</id></create_data>";
}