public static Dictionary <string, bool> GetEffectiveEntityRecordPermissions(int userUID, EntityTypeGUIDRecordUIDPair eTypeUIDPair, List <int> groupUIDList) { //Create initial dictionary Dictionary <string, bool> effPerms = new Dictionary <string, bool>(); DataAccessAdapter da = new DataAccessAdapter(true); da.CloseConnection(); //Get Datatable of entitytype permissions for user DataTable userPerms = RetrievalProcedures.SelectUserRecordPermissions(eTypeUIDPair.EntityTypeGUID, eTypeUIDPair.RecordUID, userUID); assignAllowFromDataView(effPerms, userPerms.DefaultView); foreach (int gGUID in groupUIDList) { //Get Datatable of entitytype permissions for group gm DataTable groupPerms = RetrievalProcedures.SelectGroupRecordPermissions(eTypeUIDPair.EntityTypeGUID, eTypeUIDPair.RecordUID, gGUID); //If no prmissions for the EntityType, ignore and continue if (groupPerms.DefaultView.Count == 0) { continue; } assignAllowFromDataView(effPerms, groupPerms.DefaultView); } return(effPerms); }
public IEnumerable <LicenseRequestEntity> GetLicensesRequests() { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); return(metaData.LicenseRequest.ToList()); } }
public IEnumerable <CityEntity> GetCities() { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); return(metaData.City.ToList()); } }
public IEnumerable <DocumentEntity> GetDocuments() { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); return(metaData.Document.ToList()); } }
public IEnumerable <GovernorateEntity> GetGovernorates() { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); return(metaData.Governorate.ToList()); } }
public static Dictionary <Guid, Dictionary <string, bool> > GetEffectiveCustomPermissions(int userUID, List <int> groupUIDList) { //Create initial dictionary Dictionary <Guid, Dictionary <string, bool> > effPerms = new Dictionary <Guid, Dictionary <string, bool> >(); //Get List of all entityTypes. EntityCollection <CustomPermissionTypeEntity> customPermissionTypes = new EntityCollection <CustomPermissionTypeEntity>(); DataAccessAdapter da = new DataAccessAdapter(true); da.FetchEntityCollection(customPermissionTypes, null); da.CloseConnection(); //Get Datatable of entitytype permissions for user DataTable userPerms = RetrievalProcedures.SelectUserCustomPermissions(userUID); //Iterate through list of entity Types foreach (CustomPermissionTypeEntity cpType in customPermissionTypes) { DataView cpTypeRows = new DataView(userPerms); cpTypeRows.RowFilter = "CPUID = '" + cpType.GUID + "'"; //If no prmissions for the EntityType, ignore and continue //if(eTypeRows.Count == 0) // continue; //CReate sub-keyvalue pair Dictionary <string, bool> cpPerms = new Dictionary <string, bool>(); assignAllowFromDataView(cpPerms, cpTypeRows); foreach (int gUID in groupUIDList) { //Get Datatable of entitytype permissions for group gm DataTable groupPerms = RetrievalProcedures.SelectGroupEntityTypePermissions(gUID); DataView cpTypeGRows = new DataView(groupPerms); cpTypeGRows.RowFilter = "CPUID = '" + cpType.GUID + "'"; //If no prmissions for the EntityType, ignore and continue if (cpTypeGRows.Count == 0) { continue; } assignAllowFromDataView(cpPerms, cpTypeGRows); } //No point adding perm if no perms anyways. if (cpPerms.Count > 0) { effPerms.Add(cpType.GUID, cpPerms); } } return(effPerms); }
public async Task <IEnumerable <LicenseTypeEntity> > GetLicensesTypesAsync() { IEnumerable <LicenseTypeEntity> types = null; await Task.Run(async() => { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); types = await metaData.LicenseType.ToListAsync(); } }); return(types); }
public async Task <IEnumerable <GovernorateEntity> > GetGovernoratesAsync() { IEnumerable <GovernorateEntity> governorates = null; await Task.Run(async() => { using (var adapter = new DataAccessAdapter()) { var metaData = new LinqMetaData(adapter); adapter.CloseConnection(); governorates = await metaData.Governorate.ToListAsync(); } }); return(governorates); }
public static bool IsConnectDatabase(string connectString) { bool result = true; try { using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(connectString)) { dataAccessAdapterBase.OpenConnection(); dataAccessAdapterBase.CloseConnection(); ManageBase._connectionString = connectString; } } catch { result = false; } return(result); }
/// <summary> /// Fetches a specific page of data from the database /// </summary> private void LoadData() { // Read the page size stored in a Form label. int pageSize = (int)_pageSize.Value; // Validate the _pageSize if (pageSize <= 0) { MessageBox.Show("Page size should not be less then 1."); return; } int totalPagesCount = 0; // Create an adapter object and keep the connection open. // A using statement makes sure the Adapter is Dispose. using (DataAccessAdapter adapter = new DataAccessAdapter(true)) { // Get the total count of entities in the database int recordsCount = adapter.GetDbCount(_entities, null); // Validate the total number of entities in the database if (recordsCount <= 0) { MessageBox.Show("No entities found in the database."); return; } // If the total number of entities is less than or equal the page size // Then we only have one page to display. if (recordsCount <= pageSize) { totalPagesCount = 1; _pageNumber = totalPagesCount; } else { // Compute the total number of pages. int remainder = 0; totalPagesCount = Math.DivRem(recordsCount, pageSize, out remainder); if (remainder > 0) { totalPagesCount++; } } // A _pageNumber smaller than 0 is specified to load the last page. if (_pageNumber < 0) { _pageNumber = totalPagesCount; } // Reflect the current page number on the Form. _currentPageNumber.Text = _pageNumber.ToString() + " of (" + totalPagesCount.ToString() + ")"; // Clear the bound collection before fetching entities into it. _entities.Clear(); // Fetch the specified page of records into the bound entityCollection. adapter.FetchEntityCollection(_entities, null, 0, null, _pageNumber, pageSize); // Close the connection. adapter.CloseConnection(); } // Raise/Call the appropriate event/method to update the navigation buttons. // According to the current displayed page. if (totalPagesCount == 1) { OnSinglePage(); } else if (_pageNumber == 1) { OnFirstPage(); } else if (_pageNumber == totalPagesCount) { OnLastPage(); } else if (_pageNumber > 1 && _pageNumber < totalPagesCount) { OnInBetweenPage(); } }