/// <summary> /// use the permissions of the user to get all offices that this user has permissions for /// </summary> /// <returns></returns> private static List <Int64> GetRegistrationOfficeKeysOfUser(TDBTransaction ATransaction) { List <Int64> AllowedRegistrationOffices = new List <long>(); // get all offices that have registrations for this event DataTable offices = DBAccess.GDBAccessObj.SelectDT( String.Format("SELECT DISTINCT {0} FROM PUB_{1}", PmShortTermApplicationTable.GetRegistrationOfficeDBName(), PmShortTermApplicationTable.GetTableDBName()), "registrationoffice", ATransaction); // if there are no REG-... module permissions for anyone, allow all offices? this would help with a base database for testing? Int32 CountRegModules = Convert.ToInt32(DBAccess.GDBAccessObj.ExecuteScalar("SELECT COUNT(*) FROM " + SModuleTable.GetTableDBName() + " WHERE " + SModuleTable.GetModuleIdDBName() + " LIKE 'REG-%'", ATransaction)); foreach (DataRow officeRow in offices.Rows) { Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]); try { if ((CountRegModules == 0) || TModuleAccessManager.CheckUserModulePermissions(String.Format("REG-{0:10}", StringHelper.PartnerKeyToStr(RegistrationOffice)))) { AllowedRegistrationOffices.Add(RegistrationOffice); } } catch (ESecurityModuleAccessDeniedException) { // no permissions for this registration office } } // the organizer has access to all attendees if (AllowedRegistrationOffices.Count > MINIMUM_OFFICES_TO_BECOME_ORGANIZER) { AllowedRegistrationOffices = new List <long>(); foreach (DataRow officeRow in offices.Rows) { Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]); AllowedRegistrationOffices.Add(RegistrationOffice); } } return(AllowedRegistrationOffices); }
public static bool GetFieldUnits(Int64 AConferenceKey, TUnitTypeEnum AFieldTypes, out DataTable AFieldsTable, out String AConferencePrefix) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; AFieldsTable = new DataTable("Field Units"); AConferencePrefix = ""; PUnitTable UnitTable; DataTable TmpTable; PmShortTermApplicationTable ShortTermerTable = new PmShortTermApplicationTable(); AFieldsTable.Columns.Add("Selection", System.Type.GetType("System.Boolean")); AFieldsTable.Columns.Add("Unit_Key", System.Type.GetType("System.Int64")); AFieldsTable.Columns.Add("Unit_Name", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Outreach_Code", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Used_in_Conference", System.Type.GetType("System.Boolean")); AConferencePrefix = TConferenceOptions.GetConferencePrefix(AConferenceKey); switch (AFieldTypes) { case TUnitTypeEnum.utSendingFields: return(TConferenceOptions.GetSendingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utReceivingFields: return(TConferenceOptions.GetReceivingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utOutreachOptions: if (TConferenceOptions.GetOutreachOptions(AConferenceKey, out TmpTable)) { foreach (DataRow Row in TmpTable.Rows) { DataRow NewRow = AFieldsTable.NewRow(); NewRow[SELECTION] = false; NewRow[UNIT_KEY] = Row["Partner Key"]; NewRow[UNIT_NAME] = Row["Unit Name"]; NewRow[CAMPAIGN_CODE] = Row["Outreach Code"]; NewRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(NewRow); } return(true); } return(false); default: break; } TLogging.LogAtLevel(9, "TConferenceOptions.GetFieldUnits called!"); TDataBase db = DBAccess.Connect("GetFieldUnits"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PmShortTermApplicationTable.GetStFieldChargedDBName()); FieldList.Add(PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()); FieldList.Add(PmShortTermApplicationTable.GetRegistrationOfficeDBName()); ShortTermerTable = PmShortTermApplicationAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; bool IsUsedInOneConference = false; String ConfirmedOptionCode = ""; System.Type StringType = System.Type.GetType("System.String"); String SearchedColumnName = ""; switch (AFieldTypes) { case TUnitTypeEnum.utChargedFields: SearchedColumnName = PmShortTermApplicationTable.GetStFieldChargedDBName(); break; case TUnitTypeEnum.utRegisteringFields: SearchedColumnName = PmShortTermApplicationTable.GetRegistrationOfficeDBName(); break; default: break; } foreach (DataRow ShortTermerRow in ShortTermerTable.Select("", SearchedColumnName)) { if ((ShortTermerRow[SearchedColumnName] != null) && (ShortTermerRow[SearchedColumnName].ToString().Length > 0)) { NewUnitKey = (long)ShortTermerRow[SearchedColumnName]; } else { continue; } if (LastUnitKey != NewUnitKey) { if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } IsUsedInOneConference = false; } // We have to check from every shorttermer if the charged field is used // in this conference if (IsUsedInOneConference) { continue; } if (ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()].GetType() == StringType) { ConfirmedOptionCode = (string)ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()]; } else { ConfirmedOptionCode = ""; } if (ConfirmedOptionCode.StartsWith(AConferencePrefix)) { IsUsedInOneConference = true; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[CAMPAIGN_CODE] = ConfirmedOptionCode; ResultRow[USED_IN_CONFERENCE] = IsUsedInOneConference; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } // Check for the previous entry the "IsUsedInConference" field if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetFieldUnits: committed own transaction."); } } return(true); }