//группы рабочих void __fastcall TWorkersSettings::N1Click(TObject *Sender) { //добавить TWorkerGroup *wnd = new TWorkerGroup(this); if (wnd->ShowModal() == mrOk) { std::string group_name = AnsiString(wnd->group_name->Text).c_str(); long r_kol = wnd->r_kol->Text.ToIntDef(0); TADOQuery *rez = DB->SendSQL(std::string("select count(*) as cnt from `manufacture`.`worker_groups` where name = '"+ group_name +"'").c_str()); if (rez) { int cnt = (int)rez->FieldByName("cnt")->Value; if (!cnt) { std::stringstream sql; sql << "insert into `manufacture`.`worker_groups` (name,p_kol) values ('"<<group_name<<"','"<<r_kol<<"')"; DB->SendCommand(sql.str().c_str()); } delete rez; } LoadGroups(); } delete wnd; }
bool CThesaurus::LoadModels (string FileName) { m_Models.clear(); FILE* fp = fopen (FileName.c_str(), "r"); if (!fp) return false; char buff[2000]; if ( !fgets (buff, 2000, fp) ) return false; string Header = buff; Trim(Header); if (Header != "FreqCollocTypeId;Length;AtomGroups;Relations;Examples;Enabled;LoadTextForm;LanguageId;Groups;") return false; while (fgets(buff, 2000, fp)) { CInnerModel M; StringTokenizer Line (buff,FieldDelimiter); int i = 0; while (true) { const char* s = Line(); if (s==0) break; string Field = s; if (Field[0] == '"') { if (Field[Field.length() - 1] != '"') return false; Field.erase(0,1); Field.erase(Field.length() - 1,1); }; if (i==0) M.m_ModelId = atoi(Field.c_str()); else if (i==2) { if (!LoadAtomicGroups (Field, M)) return false; } else if (i==3) { if (!LoadModelRelations (Field, M)) return false; } else if (i==8) { if (!LoadGroups (Field, M)) return false; }; i++; }; m_Models.push_back(M); }; fclose(fp); return true; }
bool SipccSdpAttributeList::Load(sdp_t* sdp, uint16_t level, SdpErrorHolder& errorHolder) { LoadSimpleStrings(sdp, level, errorHolder); LoadSimpleNumbers(sdp, level, errorHolder); LoadFlags(sdp, level); LoadDirection(sdp, level, errorHolder); if (AtSessionLevel()) { if (!LoadGroups(sdp, level, errorHolder)) { return false; } if (!LoadMsidSemantics(sdp, level, errorHolder)) { return false; } LoadIdentity(sdp, level); } else { sdp_media_e mtype = sdp_get_media_type(sdp, level); if (mtype == SDP_MEDIA_APPLICATION) { if (!LoadSctpmap(sdp, level, errorHolder)) { return false; } } else { if (!LoadRtpmap(sdp, level, errorHolder)) { return false; } } LoadCandidate(sdp, level); LoadFmtp(sdp, level); LoadMsids(sdp, level, errorHolder); LoadRtcpFb(sdp, level, errorHolder); LoadRtcp(sdp, level, errorHolder); LoadSsrc(sdp, level); if (!LoadImageattr(sdp, level, errorHolder)) { return false; } if (!LoadSimulcast(sdp, level, errorHolder)) { return false; } if (!LoadRid(sdp, level, errorHolder)) { return false; } } LoadIceAttributes(sdp, level); if (!LoadFingerprint(sdp, level, errorHolder)) { return false; } LoadSetup(sdp, level); LoadExtmap(sdp, level, errorHolder); return true; }
BOOL CIconImgList::LoadExtIconData( void) { // 通常アイコンの読み込み m_hBmpDefault = ::LoadBitmap( AfxGetResourceHandle(), MAKEINTRESOURCE( IDB_ICONIMG)); TCHAR szFilePath[ MAX_PATH]; int nLength = GetModuleFileName( NULL, szFilePath, MAX_PATH); for( int nIndex = nLength; nIndex >= 0; nIndex--) { if( TEXT( '\\') == szFilePath[ nIndex]) { lstrcpy( &szFilePath[ nIndex + 1], TEXT( "GetIcon.xml")); break; } } BOOL blResult = FALSE; MSXML2::IXMLDOMDocumentPtr piDocument; if( SUCCEEDED( piDocument.CreateInstance( _T( "Microsoft.XMLDOM")))) { piDocument->PutvalidateOnParse( VARIANT_TRUE); if( VARIANT_FALSE != piDocument->load( _variant_t( _bstr_t( szFilePath)))) { if( LoadIcons( piDocument)) { blResult = LoadGroups( piDocument); } } else { MSXML2::IXMLDOMParseErrorPtr piError; piError = piDocument->GetparseError(); long lCode = piError->GeterrorCode(); TRACE( _T( "0x%08X\n"), lCode); // 0x800C0005 if( NULL != piError && 0 != lCode && 0x800C0005/*INET_E_RESOURCE_NOT_FOUND*/ != lCode) { long lRaw = piError->Getline(); long lCol = piError->Getlinepos(); _bstr_t cBstr = piError->Getreason(); _bstr_t cBstrSrc = piError->GetsrcText(); CString cStr; cStr.Format( _T( "拡張アイコンデータファイルを解析できませんでした。\n%s\n\nソース:%s\n位置:%d行 %d文字"), ( ( char*)cBstr), ( ( char*)cBstrSrc), lRaw, lCol); MessageBox( NULL, cStr, NULL, MB_OK | MB_ICONEXCLAMATION); } } } return blResult; }
void __fastcall TWorkersSettings::N5Click(TObject *Sender) { //удалить if ( MessageBoxA(this->Handle, "Удалить рабочего?", "Удалить рабочего?",MB_YESNO|MB_ICONQUESTION) == mrYes ) { DB->SendCommand(AnsiString("update `manufacture`.`workers` set date_to = now() " "where tab_no = '"+sgWorkers->Cells[0][sgWorkers->Row]+"' and date_to is null")); LoadGroups(); LoadWorkers(AnsiString(sgGroups->Cells[3][sgGroups->Row]).c_str()); } }
TError TClient::IdentifyClient(TContainerHolder &holder, bool initial) { std::shared_ptr<TContainer> ct; struct ucred cr; socklen_t len = sizeof(cr); TError error; if (getsockopt(Fd, SOL_SOCKET, SO_PEERCRED, &cr, &len)) return TError(EError::Unknown, errno, "Cannot identify client: getsockopt() failed"); /* check that request from the same pid and container is still here */ if (!initial && Pid == cr.pid && TaskCred.Uid == cr.uid && TaskCred.Gid == cr.gid && !ClientContainer.expired()) return TError::Success(); TaskCred.Uid = cr.uid; TaskCred.Gid = cr.gid; Pid = cr.pid; error = holder.FindTaskContainer(Pid, ct); if (error && error.GetErrno() != ENOENT) L_WRN() << "Cannot identify container of pid " << Pid << " : " << error << std::endl; if (error) return error; if (!ct->IsPortoEnabled()) return TError(EError::Permission, "Porto disabled in container " + ct->GetName()); ClientContainer = ct; error = TPath("/proc/" + std::to_string(Pid) + "/comm").ReadAll(Comm, 64); if (error) Comm = "<unknown process>"; else Comm.resize(Comm.length() - 1); /* cut \n at the end */ if (ct->IsRoot()) { Cred.Uid = cr.uid; Cred.Gid = cr.gid; error = LoadGroups(); if (error && error.GetErrno() != ENOENT) L_WRN() << "Cannot load supplementary group list" << Pid << " : " << error << std::endl; } else { /* requests from containers are executed in behalf of their owners */ Cred = ct->OwnerCred; } ReadOnlyAccess = !Cred.IsPortoUser(); return TError::Success(); }
void __fastcall TWorkersSettings::N4Click(TObject *Sender) { //редактировать TWorkerData *wnd = new TWorkerData(this, DB); wnd->tab_no->Text = sgWorkers->Cells[0][sgWorkers->Row]; wnd->tab_no->Enabled = false; wnd->worker_family->Text = sgWorkers->Cells[1][sgWorkers->Row]; wnd->worker_name->Text = sgWorkers->Cells[2][sgWorkers->Row]; wnd->worker_otch->Text = sgWorkers->Cells[3][sgWorkers->Row]; wnd->razr->Text = sgWorkers->Cells[5][sgWorkers->Row]; wnd->proff->Text = sgWorkers->Cells[4][sgWorkers->Row]; wnd->group_id = sgGroups->Cells[3][sgGroups->Row].ToIntDef(0); for (size_t i = 0; i < wnd->ComboBox1->Items->Count; ++i) { if (wnd->group_id == ((GroupData *)wnd->ComboBox1->Items->Objects[i])->group_id) { wnd->ComboBox1->ItemIndex = i; break; } } if (wnd->ShowModal() == mrOk) { std::string tab_no = AnsiString(wnd->tab_no->Text).c_str(); std::string worker_family = AnsiString(wnd->worker_family->Text).c_str(); std::string worker_name = AnsiString(wnd->worker_name->Text).c_str(); std::string worker_otch = AnsiString(wnd->worker_otch->Text).c_str(); std::string razr = AnsiString(wnd->razr->Text).c_str(); std::string proff = AnsiString(wnd->proff->Text).c_str(); long group_id = wnd->group_id; std::stringstream sql; sql << "update `manufacture`.`workers` " "set date_from = now(), " "razr = '"<<razr<<"'," "family = '"<<worker_family<<"'," "name = '"<<worker_name<<"'," "otch = '"<<worker_otch<<"'," "proff = '"<<proff<<"' "; if (group_id) sql << ", group_id = '"<<group_id<<"'"; sql << "where tab_no = '"<<tab_no<<"' and date_to is null"; DB->SendCommand(sql.str().c_str()); LoadGroups(); LoadWorkers(AnsiString(sgGroups->Cells[3][sgGroups->Row]).c_str()); } delete wnd; }
static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int _hLang) { char setting[512]; mir_snprintf(setting, "Position_%s", name); extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000)); mir_snprintf(setting, "Slot_%s", name); int slot = db_get_w(NULL, MODULE_NAME, setting, 1); if (slot == (WORD)-1) slot = -1; extra->setSlot(slot); extra->m_hLangpack = _hLang; registeredExtraIcons.insert(extra); extraIconsByHandle.insert(extra); LIST<ExtraIconGroup> groups(1); LoadGroups(groups); ExtraIconGroup *group = IsInGroup(groups, extra); if (group != NULL) RebuildListsBasedOnGroups(groups); else { for (int i = 0; i < groups.getCount(); i++) delete groups[i]; extraIconsBySlot.insert(extra); } if (slot >= 0 || group != NULL) { if (clistRebuildAlreadyCalled) extra->rebuildIcons(); slot = 0; for (int i = 0; i < extraIconsBySlot.getCount(); i++) { ExtraIcon *ex = extraIconsBySlot[i]; if (ex->getSlot() < 0) continue; int oldSlot = ex->getSlot(); ex->setSlot(slot++); if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot)) extra->applyIcons(); } } }
cGroupManager::cGroupManager() : m_pState( new sGroupManagerState ) { LOGD("-- Loading Groups --"); if (!LoadGroups()) { LOGWARNING("ERROR: Groups could not load!"); } if (!CheckUsers()) { LOGWARNING("ERROR: User file could not be found!"); } LOGD("-- Groups Successfully Loaded --"); }
void __fastcall TWorkersSettings::N2Click(TObject *Sender) { //удалить std::string group_id = AnsiString(sgGroups->Cells[3][sgGroups->Row]).c_str(); if (group_id == "") return; if ( MessageBoxA(this->Handle, "Удалить группу рабочих?", "Удалить группу рабочих?",MB_YESNO|MB_ICONQUESTION) == mrYes ) { std::stringstream sql; sql << "delete from `manufacture`.`worker_groups` where group_id = '"<<group_id<<"'"; DB->SendCommand(sql.str().c_str()); LoadGroups(); } }
TError TClient::IdentifyClient(TContainerHolder &holder, bool initial) { struct ucred cr; socklen_t len = sizeof(cr); TError error; if (getsockopt(Fd, SOL_SOCKET, SO_PEERCRED, &cr, &len)) return TError(EError::Unknown, errno, "Cannot identify client: getsockopt() failed"); if (!initial && Pid == cr.pid && Cred.Uid == cr.uid && Cred.Gid == cr.gid && !ClientContainer.expired()) return TError::Success(); Cred.Uid = cr.uid; Cred.Gid = cr.gid; Pid = cr.pid; error = TPath("/proc/" + std::to_string(Pid) + "/comm").ReadAll(Comm, 64); if (error) Comm = "<unknown process>"; else Comm.resize(Comm.length() - 1); /* cut \n at the end */ error = LoadGroups(); if (error && error.GetErrno() != ENOENT) L_WRN() << "Cannot load supplementary group list" << Pid << " : " << error << std::endl; ReadOnlyAccess = !Cred.IsPortoUser(); std::shared_ptr<TContainer> container; error = holder.FindTaskContainer(Pid, container); if (error && error.GetErrno() != ENOENT) L_WRN() << "Cannot identify container of pid " << Pid << " : " << error << std::endl; if (error) return error; if (!container->Prop->Get<bool>(P_ENABLE_PORTO)) return TError(EError::Permission, "Porto disabled in container " + container->GetName()); ClientContainer = container; return TError::Success(); }
TError TClient::Identify(TContainerHolder &holder, bool full) { struct ucred cr; socklen_t len = sizeof(cr); if (getsockopt(Fd, SOL_SOCKET, SO_PEERCRED, &cr, &len) == 0) { if (full) { TFile f("/proc/" + std::to_string(cr.pid) + "/comm"); std::string comm; if (f.AsString(comm)) comm = "unknown process"; comm.erase(std::remove(comm.begin(), comm.end(), '\n'), comm.end()); Pid = cr.pid; Comm = comm; TError err = LoadGroups(); if (err) { L_WRN() << "Can't load supplementary group list" << cr.pid << " : " << err << std::endl; } err = IdentifyContainer(holder); if (err) { L_WRN() << "Can't identify container of pid " << cr.pid << " : " << err << std::endl; return err; } } else { if (Container.expired()) return TError(EError::Unknown, "Can't identify client (container is dead)"); } Cred.Uid = cr.uid; Cred.Gid = cr.gid; return TError::Success(); } else { return TError(EError::Unknown, "Can't identify client (getsockopt() failed)"); } }
//рабочие void __fastcall TWorkersSettings::N3Click(TObject *Sender) { //добавить TWorkerData *wnd = new TWorkerData(this, DB); if (wnd->ShowModal() == mrOk) { std::string tab_no = AnsiString(wnd->tab_no->Text).c_str(); std::string worker_family = AnsiString(wnd->worker_family->Text).c_str(); std::string worker_name = AnsiString(wnd->worker_name->Text).c_str(); std::string worker_otch = AnsiString(wnd->worker_otch->Text).c_str(); std::string razr = AnsiString(wnd->razr->Text).c_str(); std::string proff = AnsiString(wnd->proff->Text).c_str(); long group_id = wnd->group_id; //если не задан табельный - послать DB->SendCommand(std::string("update `manufacture`.`workers` set date_to = now() " "where tab_no = '"+tab_no+"' and date_to is null").c_str()); //если табельный задан, считать последнего активного рабочего с ним, //если такового нет то просто добавить новоро работягу //если таковой есть то закрыть его историю работы на этом номере std::stringstream sql; sql << "insert into `manufacture`.`workers` " "set date_from = now(), " "tab_no = '"<<tab_no<<"'," "razr = '"<<razr<<"'," "family = '"<<worker_family<<"'," "name = '"<<worker_name<<"'," "otch = '"<<worker_otch<<"'," "proff = '"<<proff<<"' "; if (group_id) sql << ", group_id = '"<<group_id<<"'"; DB->SendCommand(sql.str().c_str()); LoadGroups(); LoadWorkers(AnsiString(sgGroups->Cells[3][sgGroups->Row]).c_str()); } delete wnd; }
MIR_APP_DLL(void) KillModuleExtraIcons(int _hLang) { LIST<ExtraIcon> arDeleted(1); for (int i=registeredExtraIcons.getCount()-1; i >= 0; i--) { BaseExtraIcon *p = registeredExtraIcons[i]; if (p->m_hLangpack == _hLang) { registeredExtraIcons.remove(i); arDeleted.insert(p); } } if (arDeleted.getCount() == 0) return; LIST<ExtraIconGroup> groups(1); LoadGroups(groups); RebuildListsBasedOnGroups(groups); for (int k=0; k < arDeleted.getCount(); k++) delete arDeleted[k]; }
void __fastcall TWorkersSettings::N6Click(TObject *Sender) { //редактировать std::string group_id = AnsiString(sgGroups->Cells[3][sgGroups->Row]).c_str(); if (group_id == "") return; TWorkerGroup *wnd = new TWorkerGroup(this); wnd->group_name->Text = sgGroups->Cells[0][sgGroups->Row]; wnd->group_name->Enabled = false; wnd->r_kol->Text = sgGroups->Cells[2][sgGroups->Row]; if (wnd->ShowModal() == mrOk) { long r_kol = wnd->r_kol->Text.ToIntDef(0); std::stringstream sql; sql << "update `manufacture`.`worker_groups` set p_kol = '"<<r_kol<<"' where group_id = '"<<group_id<<"'"; DB->SendCommand(sql.str().c_str()); LoadGroups(); } delete wnd; }
INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) { if (wParam == 0) return 0; EXTRAICON_INFO *ei = (EXTRAICON_INFO *)wParam; if (ei->cbSize < (int)sizeof(EXTRAICON_INFO)) return 0; if (ei->type != EXTRAICON_TYPE_CALLBACK && ei->type != EXTRAICON_TYPE_ICOLIB) return 0; if (IsEmpty(ei->name) || IsEmpty(ei->description)) return 0; if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL)) return 0; ptrT tszDesc(mir_a2t(ei->description)); TCHAR *desc = TranslateTH(lParam, tszDesc); BaseExtraIcon *extra = GetExtraIconByName(ei->name); if (extra != NULL) { if (ei->type != extra->getType() || ei->type != EXTRAICON_TYPE_ICOLIB) return 0; // Found one, now merge it if (_tcsicmp(extra->getDescription(), desc)) { CMString newDesc = extra->getDescription(); newDesc += _T(" / "); newDesc += desc; extra->setDescription(newDesc.c_str()); } if (!IsEmpty(ei->descIcon)) extra->setDescIcon(ei->descIcon); if (ei->OnClick != NULL) extra->setOnClick(ei->OnClick, ei->onClickParam); if (extra->getSlot() > 0) { if (clistRebuildAlreadyCalled) extra->rebuildIcons(); if (clistApplyAlreadyCalled) extraIconsByHandle[extra->getID() - 1]->applyIcons(); } return extra->getID(); } int id = registeredExtraIcons.getCount() + 1; switch (ei->type) { case EXTRAICON_TYPE_CALLBACK: extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam); break; case EXTRAICON_TYPE_ICOLIB: extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick, ei->onClickParam); break; default: return 0; } char setting[512]; mir_snprintf(setting, SIZEOF(setting), "Position_%s", ei->name); extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000)); mir_snprintf(setting, SIZEOF(setting), "Slot_%s", ei->name); int slot = db_get_w(NULL, MODULE_NAME, setting, 1); if (slot == (WORD)-1) slot = -1; extra->setSlot(slot); extra->hLangpack = (int)lParam; registeredExtraIcons.insert(extra); extraIconsByHandle.insert(extra); LIST<ExtraIconGroup> groups(1); LoadGroups(groups); ExtraIconGroup *group = IsInGroup(groups, extra); if (group != NULL) RebuildListsBasedOnGroups(groups); else { for (int i = 0; i < groups.getCount(); i++) delete groups[i]; extraIconsBySlot.insert(extra); } if (slot >= 0 || group != NULL) { if (clistRebuildAlreadyCalled) extra->rebuildIcons(); slot = 0; for (int i = 0; i < extraIconsBySlot.getCount(); i++) { ExtraIcon *ex = extraIconsBySlot[i]; if (ex->getSlot() < 0) continue; int oldSlot = ex->getSlot(); ex->setSlot(slot++); if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot)) extra->applyIcons(); } } return id; }
void TWorkersSettings::OnShow(void) { LoadGroups();//загрузить список групп LoadWorkers();//загрузить список рабочих }
TError TCred::Load(const std::string &user) { TError error = FindUser(user, Uid, Gid); if (!error) error = LoadGroups(user); return error; }
INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) { if (wParam == 0) return 0; EXTRAICON_INFO *ei = (EXTRAICON_INFO *) wParam; if (ei->cbSize < (int) sizeof(EXTRAICON_INFO)) return 0; if (ei->type != EXTRAICON_TYPE_CALLBACK && ei->type != EXTRAICON_TYPE_ICOLIB) return 0; if (IsEmpty(ei->name) || IsEmpty(ei->description)) return 0; if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL)) return 0; const char *desc = Translate(ei->description); BaseExtraIcon *extra = GetExtraIconByName(ei->name); if (extra != NULL) { if (ei->type != extra->getType() || ei->type != EXTRAICON_TYPE_ICOLIB) return 0; // Found one, now merge it if (_stricmp(extra->getDescription(), desc)) { string newDesc = extra->getDescription(); newDesc += " / "; newDesc += desc; extra->setDescription(newDesc.c_str()); } if (!IsEmpty(ei->descIcon)) extra->setDescIcon(ei->descIcon); if (ei->OnClick != NULL) extra->setOnClick(ei->OnClick, ei->onClickParam); if (extra->getSlot() > 0) { if (clistRebuildAlreadyCalled) extra->rebuildIcons(); if (clistApplyAlreadyCalled) extraIconsByHandle[extra->getID() - 1]->applyIcons(); } return extra->getID(); } size_t id = registeredExtraIcons.size() + 1; switch (ei->type) { case EXTRAICON_TYPE_CALLBACK: extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam); break; case EXTRAICON_TYPE_ICOLIB: extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick, ei->onClickParam); break; default: return 0; } char setting[512]; mir_snprintf(setting, MAX_REGS(setting), "Position_%s", ei->name); extra->setPosition(DBGetContactSettingWord(NULL, MODULE_NAME, setting, 1000)); mir_snprintf(setting, MAX_REGS(setting), "Slot_%s", ei->name); int slot = DBGetContactSettingWord(NULL, MODULE_NAME, setting, 1); if (slot == (WORD) -1) slot = -1; extra->setSlot(slot); registeredExtraIcons.push_back(extra); extraIconsByHandle.push_back(extra); vector<ExtraIconGroup *> groups; LoadGroups(groups); ExtraIconGroup *group = IsInGroup(groups, extra); if (group != NULL) { RebuildListsBasedOnGroups(groups); } else { for (unsigned int i = 0; i < groups.size(); ++i) delete groups[i]; extraIconsBySlot.push_back(extra); std::sort(extraIconsBySlot.begin(), extraIconsBySlot.end(), compareFunc()); } if (slot >= 0 || group != NULL) { if (clistRebuildAlreadyCalled) extra->rebuildIcons(); slot = 0; for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i) { ExtraIcon *ex = extraIconsBySlot[i]; if (ex->getSlot() < 0) continue; int oldSlot = ex->getSlot(); ex->setSlot(slot++); if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot)) extra->applyIcons(); } } return id; }