本文整理汇总了C++中user::Ptr::GetVars方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::GetVars方法的具体用法?C++ Ptr::GetVars怎么用?C++ Ptr::GetVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user::Ptr
的用法示例。
在下文中一共展示了Ptr::GetVars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnConfigUpdate
void UserDbObject::OnConfigUpdate(void)
{
Dictionary::Ptr fields = make_shared<Dictionary>();
User::Ptr user = static_pointer_cast<User>(GetObject());
/* contact addresses */
Log(LogDebug, "UserDbObject", "contact addresses for '" + user->GetName() + "'");
Dictionary::Ptr vars = user->GetVars();
if (vars) { /* This is sparta. */
for (int i = 1; i <= 6; i++) {
String key = "address" + Convert::ToString(i);
String val = vars->Get(key);
if (val.IsEmpty())
continue;
fields->Set("contact_id", DbValue::FromObjectInsertID(user));
fields->Set("address_number", i);
fields->Set("address", val);
fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbQuery query;
query.Type = DbQueryInsert;
query.Table = "contact_addresses";
query.Fields = fields;
OnQuery(query);
}
}
}
示例2: OnConfigUpdateHeavy
void UserDbObject::OnConfigUpdateHeavy(void)
{
User::Ptr user = static_pointer_cast<User>(GetObject());
/* groups */
Array::Ptr groups = user->GetGroups();
std::vector<DbQuery> queries;
DbQuery query1;
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query1.Type = DbQueryDelete;
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("contact_object_id", user);
queries.push_back(query1);
if (groups) {
ObjectLock olock(groups);
for (const String& groupName : groups) {
UserGroup::Ptr group = UserGroup::GetByName(groupName);
DbQuery query2;
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query2.Type = DbQueryInsert | DbQueryUpdate;
query2.Category = DbCatConfig;
query2.Fields = new Dictionary();
query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.Fields->Set("contact_object_id", user);
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.WhereCriteria->Set("contact_object_id", user);
queries.push_back(query2);
}
}
DbObject::OnMultipleQueries(queries);
queries.clear();
DbQuery query2;
query2.Table = "contact_addresses";
query2.Type = DbQueryDelete;
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("contact_id", DbValue::FromObjectInsertID(user));
queries.push_back(query2);
Dictionary::Ptr vars = user->GetVars();
if (vars) { /* This is sparta. */
for (int i = 1; i <= 6; i++) {
Dictionary::Ptr fields = new Dictionary();
String key = "address" + Convert::ToString(i);
if (!vars->Contains(key))
continue;
String val = vars->Get(key);
fields->Set("contact_id", DbValue::FromObjectInsertID(user));
fields->Set("address_number", i);
fields->Set("address", val);
fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbQuery query;
query.Type = DbQueryInsert;
query.Table = "contact_addresses";
query.Category = DbCatConfig;
query.Fields = fields;
queries.push_back(query);
}
}
DbObject::OnMultipleQueries(queries);
}