BOOL CNetClient::OnLogin() { VODLOGIN login = {0}; if (FALSE == RecvData(&login,sizeof(login))) { return FALSE; } //数据库查询 // CMainFrame *pWnd=(CMainFrame*)AfxGetMainWnd(); //CUserManager userMgr(&pWnd->m_adoConnection); CUserManager userMgr(&g_pWnd->m_adoConnection); CUser user; user.strUserName=login.szUserName; user.strPwd=login.szPassword; VODLOGINRET loginret = {0}; if(userMgr.ValidateUser(user)) { loginret.dwSuccess = 1; } else { loginret.dwSuccess = 0; } BOOL nRet = SendData(VODNETCMD_LOGIN_RET, &loginret,sizeof(loginret)); return nRet; }
//---------------------------------------------------------------------------------------- // FillValues //---------------------------------------------------------------------------------------- void CZPTitleUsersPopupController::FillValues( const ZPUserIDsList & inIDList) { #if defined(InDnCS5) || defined(InDnCS5_5) const IExecutionContext* ec = GetExecutionContext(); ISession* gSession = ec->GetSession(); #endif InterfacePtr<IStringListControlData> iUsersStringListControlData( this, UseDefaultIID()); ASSERT(iUsersStringListControlData); InterfacePtr<const IZPApp> zpApp( gSession, UseDefaultIID() ); ASSERT( zpApp ); InterfacePtr<const IZPUserMgr> userMgr( zpApp->GetUserMgr(), UseDefaultIID() ); ASSERT(userMgr); int newListLen = inIDList.size(); if( newListLen <= 0 ) iUsersStringListControlData->Clear(); else iUsersStringListControlData->Clear(kFalse, kFalse); ZPUserIDsList::const_iterator endIter = inIDList.end(); int i=1; for( ZPUserIDsList::const_iterator currIter = inIDList.begin(); currIter != endIter; ++currIter,++i) { const PMString & userID = *currIter; InterfacePtr<const IStringData> userName( userMgr->GetUserForID(userID), IID_IZPDATANAME ); ASSERT( userName ); const PMString & theUserName = userName->Get(); if ( i == newListLen ) iUsersStringListControlData->AddString(theUserName); else iUsersStringListControlData->AddString(theUserName, IStringListControlData::kEnd, kFalse, kFalse ); } //this->SendMessage_ListLengthChanged(); //Commented as it is now send by its base class. }
//---------------------------------------------------------------------------------------- // GetDispName_User //---------------------------------------------------------------------------------------- PMString CZPTasksTVNodeWidgetMgr::GetDispName_User( const IZPTaskInfo * inTaskInfo, enTVColTasks inColID) const { //TODO: use inColID const PMString & theUserID = inTaskInfo->GetAssignedToUserID(); if( !theUserID.IsEmpty() ) { InterfacePtr<const IZPUserMgr> userMgr( mTaskMgr, UseDefaultIID() ); ASSERT( userMgr ); const IStringData * dbUserID = userMgr->GetUserForID( theUserID ); if( dbUserID ) { InterfacePtr<const IStringData> dispName( dbUserID, IID_IZPDATANAME ); return dispName->Get(); } } return kNullString; }
int FixUsersCommand::Execute() { LOG << "Runnning FixUsersCommand::Execute"; initStatusDat(config()->config()->datadir()); File userFile(config()->config()->datadir(), USER_LST); if (!userFile.Exists()) { LOG << userFile.full_pathname() << " does not exist."; return 1; } UserManager userMgr(config()->config()->datadir(), sizeof(userrec), config()->config()->config()->maxusers); LOG << "Checking USER.LST... found " << userMgr.GetNumberOfUserRecords() << " user records."; LOG << "TBD: Check for trashed user recs."; if (userMgr.GetNumberOfUserRecords() > config()->config()->config()->maxusers) { LOG << "Might be too many."; if (!arg("exp").as_bool()) { return 1; } } else { LOG << "Reasonable number."; } std::vector<smalrec> smallrecords; std::set<std::string> names; const int num_user_records = userMgr.GetNumberOfUserRecords(); for(int i = 1; i <= num_user_records; i++) { User user; userMgr.ReadUser(&user, i); user.FixUp(); userMgr.WriteUser(&user, i); if (!user.IsUserDeleted() && !user.IsUserInactive()) { smalrec sr = { 0 }; strcpy((char*) sr.name, user.GetName()); sr.number = static_cast<uint16_t>(i); std::string namestring((char*) sr.name); if (names.find(namestring) == names.end()) { smallrecords.push_back(sr); names.insert(namestring); if (arg("verbose").as_bool()) { LOG << "Keeping user: "******" #" << sr.number ; } } else { LOG << "[skipping duplicate user: "******" #" << sr.number << "]"; } } }; std::sort(smallrecords.begin(), smallrecords.end(), [](const smalrec& a, const smalrec& b) -> bool { int equal = strcmp((char*)a.name, (char*)b.name); // Sort by user number if names match. if (equal == 0) { return a.number < b.number; } // Otherwise sort by name comparison. return equal < 0; }); printf("size=%lu %lu\n", smallrecords.size(), sizeof(smalrec) * smallrecords.size()); LOG << "Checking NAMES.LST"; File nameFile(config()->config()->datadir(), NAMES_LST); if (!nameFile.Exists()) { LOG << nameFile.full_pathname() << " does not exist, regenerating with " << smallrecords.size() << " names"; nameFile.Open(File::modeCreateFile | File::modeBinary | File::modeWriteOnly); nameFile.Write(&smallrecords[0], sizeof(smalrec) * smallrecords.size()); nameFile.Close(); } else { if (nameFile.Open(File::modeReadOnly | File::modeBinary)) { long size = nameFile.GetLength(); uint16_t recs = static_cast<uint16_t>(size / sizeof(smalrec)); if (recs != status.users) { status.users = recs; LOG << "STATUS.DAT contained an incorrect user count."; } else { LOG << "STATUS.DAT matches expected user count of " << status.users << " users."; } } nameFile.Close(); } return 0; }