public async Task <string> GetTopClubToMemberJoinIdAsync(ContentURI uriToEdit, string connect, string baseNodeName, string baseId, int accountId) { //top joins mean the base record can be edited (they were both //inserted by the same owner at the same time) string sTopJoinTableId = string.Empty; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uriToEdit); SqlParameter[] colPrams = { sqlIO.MakeInParam("@MemberId", SqlDbType.Int, 4, baseId), sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, accountId), sqlIO.MakeInParam("@NodeName", SqlDbType.NVarChar, 25, baseNodeName), sqlIO.MakeOutParam("@TopJoinTableId", SqlDbType.Int, 4) }; string sQryName = "0GetMemberTopJoinTableId"; int iNotUsed = await sqlIO.RunProcIntAsync(sQryName, colPrams); if (colPrams[3].Value != System.DBNull.Value) { sTopJoinTableId = colPrams[3].Value.ToString(); } sqlIO.Dispose(); return(sTopJoinTableId); }
public async Task <int> GetDevTreksGroupIdsFromRegionIdAsync(ContentURI uri, int accountGeoRegionId, int memberGeoRegionId) { int iAccountGroupId = 0; //can't use datacontext because this is used prior to club and member insertion Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] prams = { sqlIO.MakeInParam("@AccountGroupGeoRegionId", SqlDbType.Int, 4, accountGeoRegionId), sqlIO.MakeInParam("@MemberGroupGeoRegionId", SqlDbType.Int, 4, memberGeoRegionId), sqlIO.MakeOutParam("@AccountGroupId", SqlDbType.Int, 4), sqlIO.MakeOutParam("@MemberGroupId", SqlDbType.Int, 4) }; // run the stored procedure (and close the sqlIO connection) int iNotUsed = await sqlIO.RunProcIntAsync( "0GetDevTreksGroupIdsFromGeoRegionId", prams); if (prams[2].Value != System.DBNull.Value) { iAccountGroupId = (int)prams[2].Value; } if (prams[3].Value != System.DBNull.Value) { int memberGroupId = (int)prams[3].Value; } sqlIO.Dispose(); return(iAccountGroupId); }
public async Task <bool> DeleteJoinAndCheckBaseAsync( ContentURI uri, ContentURI deletionURI, bool isDbEdit) { //this should be moved to where the sqlio can be disposed normally bool bIsDeleted = false; if (isDbEdit) { string sQry = GetDeleteBaseandJoinQry(uri); Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); if (!string.IsNullOrEmpty(sQry)) { SqlParameter[] colPrams = { sqlIO.MakeInParam("@Id", SqlDbType.Int, 4, deletionURI.URIId), sqlIO.MakeInParam("@NodeName", SqlDbType.NVarChar, 25, deletionURI.URINodeName), sqlIO.MakeInParam("@NetworkPartName", SqlDbType.NVarChar, 20, deletionURI.URINetworkPartName) }; int iIsCompleted = await sqlIO.RunProcIntAsync( sQry, colPrams); sqlIO.Dispose(); if (iIsCompleted == 1) { bIsDeleted = true; } } } return(bIsDeleted); }
public async Task <string> GetAncestorsAndAuthorizationsAsync( ContentURI uri, int clubOrMemberId) { Dictionary <string, int> ancestors = new Dictionary <string, int>(); string ancestorArray = string.Empty; int iAuthorizationLevel = 0; string sAdminNetworkPartName = Data.Helpers.GeneralHelpers.GetDefaultNetworkPartName(); Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] oPrams = { sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, clubOrMemberId), sqlIO.MakeInParam("@ServiceId", SqlDbType.Int, 4, uri.URIService.ServiceId), sqlIO.MakeInParam("@NetworkPartName", SqlDbType.NVarChar, 20, uri.URINetworkPartName), sqlIO.MakeInParam("@AdminNetworkPartName", SqlDbType.NVarChar, 20, sAdminNetworkPartName), sqlIO.MakeInParam("@ParamDelimiter", SqlDbType.NVarChar, 2, Helpers.GeneralHelpers.PARAMETER_DELIMITER), sqlIO.MakeOutParam("@AncestorNameArray", SqlDbType.NVarChar, 1000), sqlIO.MakeOutParam("@AuthorizationLevel", SqlDbType.SmallInt, 2) }; string sQryName = "0GetAncestorNamesAgreementByServiceId"; int iNotUsed = await sqlIO.RunProcIntAsync(sQryName, oPrams); if (oPrams[5].Value != System.DBNull.Value) { ancestorArray = oPrams[5].Value.ToString(); } if (oPrams[6].Value != System.DBNull.Value) { AccountHelper.AUTHORIZATION_LEVELS publicOrPrivateAL = AccountHelper.AUTHORIZATION_LEVELS.viewonly; iAuthorizationLevel = Helpers.GeneralHelpers.ConvertStringToInt(oPrams[6].Value.ToString()); publicOrPrivateAL = AccountHelper.GetAuthorizationLevel(iAuthorizationLevel); //new in 1.5.2 if (uri.URIMember == null) { uri.URIMember = new AccountToMember(true); } if (uri.URIMember.ClubInUse == null) { uri.URIMember.ClubInUse = new Account(true); } //set what the db says is their authorization level uri.URIMember.ClubInUse.PrivateAuthorizationLevel = publicOrPrivateAL; } sqlIO.Dispose(); return(ancestorArray); }
public async Task <bool> UpdateDefaultNetworkForLoggedinMemberAsync( ContentURI uri, int accountId, int newIsDefaultAccountToNetworkId) { bool bHasUpdated = false; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] colPrams = { sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, accountId), sqlIO.MakeInParam("@NewIsDefaultAccountToNetworkId", SqlDbType.Int, 4, newIsDefaultAccountToNetworkId) }; int iResult = await sqlIO.RunProcIntAsync("0UpdateNetworkDefaultId", colPrams); if (iResult == 1) { bHasUpdated = true; } sqlIO.Dispose(); return(bHasUpdated); }
public static async Task <string> GetDevPackBaseIdFromJoinIdAsync( ContentURI uri, string connect, string currentNodeName, string currentId) { string sBaseTableId = string.Empty; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] colPrams = { sqlIO.MakeInParam("@Id", SqlDbType.Int, 4, currentId), sqlIO.MakeInParam("@NodeName", SqlDbType.NVarChar, 25, currentNodeName), sqlIO.MakeOutParam("@BaseTableId", SqlDbType.Int, 4) }; string sQryName = "0GetDevPackBaseTableId"; int iNotUsed = await sqlIO.RunProcIntAsync(sQryName, colPrams); if (colPrams[2].Value != System.DBNull.Value) { sBaseTableId = colPrams[2].Value.ToString(); } sqlIO.Dispose(); return(sBaseTableId); }
public async Task <bool> SetClubOwnerByServiceAsync(ContentURI uri) { bool bHasSet = true; Account newClub = new Account(); Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] oPrams = { sqlIO.MakeInParam("@Id", SqlDbType.Int, 4, uri.URIService.ServiceId), sqlIO.MakeOutParam("@AccountId", SqlDbType.Int, 4), sqlIO.MakeOutParam("@AccountName", SqlDbType.NVarChar, 75), sqlIO.MakeOutParam("@AccountGroupId", SqlDbType.Int, 4), sqlIO.MakeOutParam("@AccountEmail", SqlDbType.NVarChar, 255) }; int iNotUsed = await sqlIO.RunProcIntAsync("0GetAccountByService", oPrams); if (oPrams[1].Value != System.DBNull.Value) { newClub.PKId = (int)oPrams[1].Value; } if (oPrams[2].Value != System.DBNull.Value) { newClub.AccountName = oPrams[2].Value.ToString(); } if (oPrams[3].Value != System.DBNull.Value) { int iAccountGroupId = (int)oPrams[3].Value; newClub.AccountClassId = iAccountGroupId; } if (oPrams[4].Value != System.DBNull.Value) { newClub.AccountEmail = oPrams[4].Value.ToString(); } uri.URIClub = newClub; bHasSet = true; sqlIO.Dispose(); return(bHasSet); }
public async Task <int> InsertNewAuditItemAsync( ContentURI uri, AccountToAudit audit) { int iId = 0; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] oPrams = { sqlIO.MakeInParam("@MemberId", SqlDbType.Int, 4, audit.MemberId), sqlIO.MakeInParam("@MemberRole", SqlDbType.NVarChar, 25, audit.MemberRole), sqlIO.MakeInParam("@ClubInUseId", SqlDbType.Int, 4, audit.ClubInUseId), sqlIO.MakeInParam("@ClubInUseAuthorizationLevel", SqlDbType.NVarChar, 25, audit.ClubInUseAuthorizationLevel), sqlIO.MakeInParam("@EditedDocURI", SqlDbType.NVarChar, 300, audit.EditedDocURI), sqlIO.MakeInParam("@EditedDocFullPath", SqlDbType.NVarChar, 400, audit.EditedDocFullPath), sqlIO.MakeInParam("@ServerSubAction", SqlDbType.NVarChar, 25, audit.ServerSubAction), sqlIO.MakeInParam("@EditDate", SqlDbType.Date, 4, audit.EditDate), sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, audit.AccountId) }; iId = await sqlIO.RunProcIntAsync("0InsertAudit", oPrams); sqlIO.Dispose(); return(iId); }
public async Task <bool> AddNetworkCategoriesAsync(ContentURI uri, int serviceGroupId, int networkId, int numberToAdd) { bool bIsOkToSave = false; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] colPrams = { sqlIO.MakeInParam("@NetworkId", SqlDbType.Int, 4, networkId), sqlIO.MakeInParam("@ServiceGroupId", SqlDbType.Int, 4, serviceGroupId), sqlIO.MakeInParam("@NumberToAdd", SqlDbType.Int, 4, numberToAdd) }; string sQryName = "0InsertCategories"; int iRowCount = await sqlIO.RunProcIntAsync(sQryName, colPrams); //no error means sp ran successfully if (iRowCount > 0) { bIsOkToSave = true; } sqlIO.Dispose(); return(bIsOkToSave); }
public async Task <string> GetAncestorsAndSetServiceAsync(ContentURI uri) { string ancestorArray = string.Empty; int iId = uri.URIId; string sNodeName = uri.URINodeName; if (uri.URINodeName == AGREEMENT_TYPES.service.ToString()) { //same rule enforced with contenthelper.geturichildren //only show the ancestors and children of owned services, not subscribed if (uri.URIService != null) { if (uri.URIService.ServiceId != 0) { iId = uri.URIService.ServiceId; sNodeName = AGREEMENT_BASE_TYPES.servicebase.ToString(); } } } //commontreks string sAdminNetworkPartName = Data.Helpers.GeneralHelpers.GetDefaultNetworkPartName(); //service object can be filled in from the same stored procedure Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] oPrams = { sqlIO.MakeInParam("@Id", SqlDbType.Int, 4, iId), sqlIO.MakeInParam("@NodeName", SqlDbType.NVarChar, 50, sNodeName), sqlIO.MakeInParam("@NetworkPartName", SqlDbType.NVarChar, 20, uri.URINetworkPartName), sqlIO.MakeInParam("@AdminNetworkPartName", SqlDbType.NVarChar, 20, sAdminNetworkPartName), sqlIO.MakeInParam("@ParamDelimiter", SqlDbType.NVarChar, 2, Helpers.GeneralHelpers.PARAMETER_DELIMITER), sqlIO.MakeOutParam("@AncestorNameArray", SqlDbType.NVarChar, 1000), sqlIO.MakeOutParam("@CurrentName", SqlDbType.NVarChar, 150), sqlIO.MakeOutParam("@ServiceId", SqlDbType.Int, 8), }; int iNotUsed = await sqlIO.RunProcIntAsync( "0GetAncestorNamesAgreement", oPrams); if (oPrams[5].Value != System.DBNull.Value) { ancestorArray = oPrams[5].Value.ToString(); } if (oPrams[6].Value != System.DBNull.Value) { //always use the name stored in db, not the name passed in the search url //if needed, fix the uri's name string sCurrentNameFromClient = uri.URIName; string sNewName = oPrams[6].Value.ToString(); RuleHelpers.ResourceRules.ValidateScriptArgument(ref sNewName); uri.URIName = sNewName; //make sure this is the same name sent by the client (i.e. no edit*) if (sCurrentNameFromClient.Equals(uri.URIName) == false) { uri.URIPattern = uri.URIPattern.Replace(sCurrentNameFromClient, uri.URIName); } } if (oPrams[7].Value != System.DBNull.Value) { //only applicable for service nodes //(supports switching between agreements and app groups) int iServiceId = (int)oPrams[7].Value; if (uri.URIService.ServiceId != iServiceId) { uri.URIService.ServiceId = iServiceId; bool bIsBaseService = true; //data readers always close sqlio connections, use a new connection Helpers.SqlIOAsync sqlIO2 = new Helpers.SqlIOAsync(uri); SqlDataReader services = await GetServiceAsync(sqlIO2, uri, bIsBaseService); uri.URIService = FillServiceObject(services); sqlIO2.Dispose(); } } sqlIO.Dispose(); return(ancestorArray); }
public async Task <Network> GetNetworkConnectionsAsync( ContentURI uri, string networkIdOrPartName) { //default is 'all networks' network int networkId = 0; string networkName = string.Empty; string networkPartName = string.Empty; string networkDescription = string.Empty; string adminConnection = Helpers.AppSettings.GetConnection(uri); string webFileSystemPath = string.Empty; //most connections are made using this property string webConnection = string.Empty; string webDbPath = string.Empty; int networkGroupId = 0; string networkGroupName = string.Empty; int iNetworkId = 0; bool bIsNetworkId = int.TryParse(networkIdOrPartName, out iNetworkId); if (networkIdOrPartName == string.Empty || networkIdOrPartName == Helpers.GeneralHelpers.NONE) { //use default network settings Helpers.GeneralHelpers.GetDefaultNetworkSettings(out networkId, out networkName, out networkPartName, out networkGroupId, out networkGroupName); networkDescription = "allnetworks network"; webFileSystemPath = Helpers.GeneralHelpers.GetDefaultNetworkGroupName(uri); webConnection = adminConnection; } else { int iIsNetwork = 0; if (bIsNetworkId) { iIsNetwork = 1; } Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); // params to stored proc SqlParameter[] oParams = { sqlIO.MakeInParam("@NetworkParam", SqlDbType.NVarChar, 20, networkIdOrPartName), sqlIO.MakeInParam("@IsId", SqlDbType.Bit, 1, iIsNetwork), sqlIO.MakeOutParam("@NetworkId", SqlDbType.Int, 4), sqlIO.MakeOutParam("@NetworkName", SqlDbType.NVarChar, 150), sqlIO.MakeOutParam("@NetworkURIPartName", SqlDbType.NVarChar, 20), sqlIO.MakeOutParam("@NetworkDescription", SqlDbType.NVarChar, 255), sqlIO.MakeOutParam("@AdminConnection", SqlDbType.NVarChar, 255), sqlIO.MakeOutParam("@WebFileSystemPath", SqlDbType.NVarChar, 255), sqlIO.MakeOutParam("@WebConnection", SqlDbType.NVarChar, 255), sqlIO.MakeOutParam("@WebDbPath", SqlDbType.NVarChar, 255), sqlIO.MakeOutParam("@NetworkClassId", SqlDbType.Int, 4), sqlIO.MakeOutParam("@NetworkControllerName", SqlDbType.NVarChar, 25) }; // run the stored procedure int iId = await sqlIO.RunProcIntAsync("0GetNetworkConnections", oParams); //[1] is join field PKId and not used if (oParams[2].Value != System.DBNull.Value) { networkId = (int)oParams[2].Value; } if (oParams[3].Value != System.DBNull.Value) { networkName = oParams[3].Value.ToString(); } if (oParams[4].Value != System.DBNull.Value) { networkPartName = oParams[4].Value.ToString(); } if (oParams[5].Value != System.DBNull.Value) { networkDescription = oParams[5].Value.ToString(); } if (oParams[6].Value != System.DBNull.Value) { adminConnection = oParams[6].Value.ToString(); } if (oParams[7].Value != System.DBNull.Value) { webFileSystemPath = oParams[7].Value.ToString(); } if (oParams[8].Value != System.DBNull.Value) { webConnection = oParams[8].Value.ToString(); } if (oParams[9].Value != System.DBNull.Value) { webDbPath = oParams[9].Value.ToString(); } if (oParams[10].Value != System.DBNull.Value) { networkGroupId = (int)oParams[10].Value; } if (oParams[11].Value != System.DBNull.Value) { networkGroupName = oParams[11].Value.ToString(); } sqlIO.Dispose(); } //version 2.0.0 standardized on this approach adminConnection = Helpers.AppSettings.GetConnection(uri); webConnection = Helpers.AppSettings.GetConnection(uri); Network network = new Network(); network.PKId = iNetworkId; network.NetworkName = networkName; network.NetworkURIPartName = networkPartName; network.NetworkDesc = networkDescription; network.AdminConnection = adminConnection; network.WebFileSystemPath = webFileSystemPath; network.WebConnection = webConnection; network.WebDbPath = webDbPath; network.NetworkClassId = networkGroupId; network.NetworkClass = new NetworkClass(); network.NetworkClass.PKId = networkGroupId; network.NetworkClass.NetworkClassName = networkGroupName; network.GeoRegionId = 0; network.IsDefault = false; network.URIFull = string.Empty; return(network); }