/// <summary> /// Connect to database and delete user from roles. /// </summary> /// <param name="user">Object of UserInfo class.</param> /// <returns>True for deleted successfully.</returns> public static bool DeleteUserInRoles(UserInfo obj) { string sp = "[dbo].[usp_sf_UserInRolesDelete]"; SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserID", obj.UserID)); ParamCollInput.Add(new KeyValuePair <string, object>("@RoleNames", obj.RoleNames)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", obj.PortalID)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@ErrorCode", 0)); List <KeyValuePair <int, string> > OutPutColl = new List <KeyValuePair <int, string> >(); OutPutColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); return(true); } catch (Exception) { throw; } }
/// <summary> /// Connect tod database and activate registered user. /// </summary> /// <param name="ActivationCode">Activation code.</param> /// <param name="PortalID">PortalID</param> /// <param name="StoreID">StoreID</param> /// <returns>User name.</returns> public static string ActivateUser(string ActivationCode, int PortalID, int StoreID) { string sp = "[usp_ActivateUserByUserId]"; SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ActivationCode", ActivationCode)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@StoreID", StoreID)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@UserName", "nouser")); try { List <KeyValuePair <int, string> > Output = new List <KeyValuePair <int, string> >(); Output = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); return(Output[0].Value.ToString()); } catch (Exception ex) { throw (ex); } }
/// <summary> /// Connects to database and adds modules details. /// </summary> /// <param name="objList">Object of ModuleInfo.</param> /// <param name="isAdmin">Set true if the module is admin.</param> /// <param name="PackageID">Package ID.</param> /// <param name="IsActive">Set true if the module is active.</param> /// <param name="AddedOn">Module added date.</param> /// <param name="PortalID">Portal ID.</param> /// <param name="AddedBy">Module added user's name.</param> /// <returns>Returns array of int containing 1: ModuleID and 2: ModuleDefID.</returns> public int[] AddModules(ModuleInfo objList, bool isAdmin, int PackageID, bool IsActive, DateTime AddedOn, int PortalID, string AddedBy) { string sp = "[dbo].[sp_ModulesAdd]"; //SQLHandler sagesql = new SQLHandler(); try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ModuleName", objList.ModuleName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Name", objList.Name)); ParamCollInput.Add(new KeyValuePair <string, object>("@FriendlyName", objList.FriendlyName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Description", objList.Description)); ParamCollInput.Add(new KeyValuePair <string, object>("@FolderName", objList.FolderName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Version", objList.Version)); ParamCollInput.Add(new KeyValuePair <string, object>("@isPremium", objList.isPremium)); ParamCollInput.Add(new KeyValuePair <string, object>("@isAdmin", isAdmin)); ParamCollInput.Add(new KeyValuePair <string, object>("@Owner", objList.Owner)); ParamCollInput.Add(new KeyValuePair <string, object>("@Organization", objList.Organization)); ParamCollInput.Add(new KeyValuePair <string, object>("@URL", objList.URL)); ParamCollInput.Add(new KeyValuePair <string, object>("@Email", objList.Email)); ParamCollInput.Add(new KeyValuePair <string, object>("@ReleaseNotes", objList.ReleaseNotes)); ParamCollInput.Add(new KeyValuePair <string, object>("@License", objList.License)); ParamCollInput.Add(new KeyValuePair <string, object>("@PackageType", objList.PackageType)); ParamCollInput.Add(new KeyValuePair <string, object>("@supportedFeatures", objList.supportedFeatures)); ParamCollInput.Add(new KeyValuePair <string, object>("@BusinessControllerClass", objList.BusinessControllerClass)); ParamCollInput.Add(new KeyValuePair <string, object>("@CompatibleVersions", objList.CompatibleVersions)); ParamCollInput.Add(new KeyValuePair <string, object>("@dependencies", objList.dependencies)); ParamCollInput.Add(new KeyValuePair <string, object>("@permissions", objList.permissions)); ParamCollInput.Add(new KeyValuePair <string, object>("@PackageID", PackageID)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsActive", IsActive)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", AddedOn)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", AddedBy)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@ModuleID", objList.ModuleID)); ParamCollOutput.Add(new KeyValuePair <string, object>("@ModuleDefID", objList.ModuleDefID)); SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int[] arrOutPutValue = new int[2]; arrOutPutValue[0] = int.Parse(OutputValColl[0].Value); arrOutPutValue[1] = int.Parse(OutputValColl[1].Value); return(arrOutPutValue); } catch (Exception) { throw; } }
/// <summary> /// Connect to database and update user. /// </summary> /// <param name="user">Object of UserInfo class.</param> /// <param name="status">User creation status. <see cref="T:SageFrame.Security.Helpers.UserCreationStatus"/></param> /// <returns>True for update sucessfully. </returns> public static bool UpdateUser(UserInfo obj, out UserUpdateStatus status) { string sp = "[dbo].[usp_sf_UsersUpdate]"; try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", obj.UserName)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserID", obj.UserID)); ParamCollInput.Add(new KeyValuePair <string, object>("@FirstName", obj.FirstName)); ParamCollInput.Add(new KeyValuePair <string, object>("@LastName", obj.LastName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Email", obj.Email)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", obj.PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsApproved", obj.IsApproved)); ParamCollInput.Add(new KeyValuePair <string, object>("@UpdatedBy", obj.UpdatedBy)); ParamCollInput.Add(new KeyValuePair <string, object>("@StoreID", obj.StoreID)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@ErrorCode", 0)); SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int ErrorCode = int.Parse(OutputValColl[0].Value); switch (ErrorCode) { case 1: status = UserUpdateStatus.DUPLICATE_EMAIL_NOT_ALLOWED; break; default: status = UserUpdateStatus.USER_UPDATE_SUCCESSFUL; break; } return(true); } catch (Exception) { throw; } }
/// <summary> /// Connects to database and adds module permission /// </summary> /// <param name="ModuleDefID">Module's definition ID.</param> /// <param name="PermissionID">Permission ID.</param> /// <param name="PortalID">Portal ID.</param> /// <param name="PortalModuleID">Portal module ID.</param> /// <param name="AllowAccess">Set true if the user is allowed access to this module.</param> /// <param name="Username">User's name.</param> /// <param name="IsActive">Set true if the permission is active.</param> /// <param name="AddedOn">Permission added date</param> /// <param name="AddedBy">Permission added user's name.</param> /// <returns>Returns array of int containing 1:ModuleDefPermissionID and 2:PortalModulePermissionID.</returns> public int[] AddModulePermission(int?ModuleDefID, int?PermissionID, int?PortalID, int?PortalModuleID, bool AllowAccess, string Username, bool IsActive, DateTime AddedOn, string AddedBy) { string sp = "[dbo].[sp_ModulesPermissionAdd]"; SQLHandler sagesql = new SQLHandler(); try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ModuleDefID", ModuleDefID)); ParamCollInput.Add(new KeyValuePair <string, object>("@PermissionID", PermissionID)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalModuleID", PortalModuleID)); ParamCollInput.Add(new KeyValuePair <string, object>("@AllowAccess", AllowAccess)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", Username)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsActive", IsActive)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", AddedOn)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", AddedBy)); //int ListID = sagesql.ExecuteNonQueryAsGivenType<int>(sp, ParamCollInput, "@ModuleDefPermissionID"); //return ListID; ModuleInfo objInfo = new ModuleInfo(); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@ModuleDefPermissionID", objInfo.ModuleDefPermissionID)); ParamCollOutput.Add(new KeyValuePair <string, object>("@PortalModulePermissionID", objInfo.PortalModulePermissionID)); SageFrameSQLHelper objHelper = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = objHelper.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int[] arrOutPutValue = new int[2]; arrOutPutValue[0] = int.Parse(OutputValColl[0].Value); arrOutPutValue[1] = int.Parse(OutputValColl[1].Value); return(arrOutPutValue); } catch (Exception) { throw; } }
/// <summary> /// Connect to database and create role. /// </summary> /// <param name="obj">Object of RoleInfo class.</param> /// <param name="status">Role creation status.<see cref="T: SageFrame.Security.Helpers.RoleCreationStatus"/></param> public static void CreateRole(RoleInfo obj, out RoleCreationStatus status) { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair <string, object>("@RoleName", obj.RoleName)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", obj.PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsActive", obj.IsActive)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", obj.AddedOn)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", obj.AddedBy)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@ErrorCode", 0)); try { SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput("[dbo].[usp_sf_CreateRole]", ParamCollInput, ParamCollOutput); int ErrorCode = int.Parse(OutputValColl[0].Value); switch (ErrorCode) { case 1: status = RoleCreationStatus.DUPLICATE_ROLE; break; default: status = RoleCreationStatus.SUCCESS; break; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Connect to database and add user module. /// </summary> /// <param name="module">Object of UserModuleInfo class.</param> /// <returns>Newly added user module ID.</returns> public string AddUserModule(UserModuleInfo module) { SageFrameSQLHelper sqlH = new SageFrameSQLHelper(); SqlTransaction tran = (SqlTransaction)sqlH.GetTransaction(); try { List <KeyValuePair <string, object> > ParaMeterCollection = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>( "@ModuleDefID", module.ModuleDefID), new KeyValuePair <string, object>( "@UserModuleTitle", module.UserModuleTitle), new KeyValuePair <string, object>( "@AllPages", module.AllPages), new KeyValuePair <string, object>( "@ShowInPages", module.ShowInPages), new KeyValuePair <string, object>( "@InheritViewPermissions", module.InheritViewPermissions), new KeyValuePair <string, object>( "@IsActive", module.IsActive), new KeyValuePair <string, object>( "@AddedOn", DateTimeHelper.GetUtcTime(DateTime.Now)), new KeyValuePair <string, object>( "@PortalID", module.PortalID), new KeyValuePair <string, object>( "@AddedBy", module.PortalID), new KeyValuePair <string, object>( "@SEOName", module.SEOName), new KeyValuePair <string, object>( "@IsHandheld", module.IsHandheld), new KeyValuePair <string, object>( "@SuffixClass", module.SuffixClass), new KeyValuePair <string, object>( "@HeaderText", module.HeaderText), new KeyValuePair <string, object>( "@ShowHeaderText", module.ShowHeaderText), new KeyValuePair <string, object>( "@IsInAdmin", module.IsInAdmin) }; List <KeyValuePair <string, object> > ParaMeterInputCollection = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>( "@UserModuleID", 0), new KeyValuePair <string, object>( "@ControlCount", 0) }; List <KeyValuePair <int, string> > resultColl = new List <KeyValuePair <int, string> >(); try { resultColl = sqlH.ExecuteNonQueryWithMultipleOutput(tran, CommandType.StoredProcedure, "[dbo].[usp_UserModulesAdd]", ParaMeterCollection, ParaMeterInputCollection); } catch (Exception ex) { } if (int.Parse(resultColl[0].Value) > 0) { if (module.InheritViewPermissions) { //if (module.IsInAdmin) //{ // module.PortalID = -1; //} SetUserModuleInheritedPermission(module.PageID, tran, int.Parse(resultColl[0].Value), module.PortalID, module.AddedBy, module.ModuleDefID); } else { SetUserModulePermission(module.LSTUserModulePermission, tran, int.Parse(resultColl[0].Value), module.PortalID, module.AddedBy, module.ModuleDefID); } if (module.IsInAdmin) { module.PortalID = -1; } SetPageModules(module, tran, int.Parse(resultColl[0].Value), module.PortalID, module.AddedBy); } tran.Commit(); return(string.Format("{0}_{1}", resultColl[0].Value.ToString(), resultColl[1].Value.ToString())); } catch (SqlException sqlEx) { tran.Rollback(); throw sqlEx; } catch (Exception ex) { throw ex; } }
/// <summary> /// Connect to the database and create user. /// </summary> /// <param name="user">Object of UserInfo class.</param> /// <param name="status">User creation status.<see cref="T:SageFrame.Security.Helpers.UserCreationStatus"/></param> /// <param name="mode">User creation mode.</param> /// <returns>True for create successfully.</returns> public static bool CreatePortalUser(UserInfo obj, out UserCreationStatus status, UserCreationMode mode) { string sp = "[dbo].[usp_sf_CreateUser]"; try { List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@ApplicationName", obj.ApplicationName)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", obj.UserName)); ParamCollInput.Add(new KeyValuePair <string, object>("@FirstName", obj.FirstName)); ParamCollInput.Add(new KeyValuePair <string, object>("@LastName", obj.LastName)); ParamCollInput.Add(new KeyValuePair <string, object>("@Password", obj.Password)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordSalt", obj.PasswordSalt)); ParamCollInput.Add(new KeyValuePair <string, object>("@Email", obj.Email)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordQuestion", obj.SecurityQuestion)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordAnswer", obj.SecurityAnswer)); ParamCollInput.Add(new KeyValuePair <string, object>("@IsApproved", obj.IsApproved)); ParamCollInput.Add(new KeyValuePair <string, object>("@CurrentTimeUtc", obj.CurrentTimeUtc)); ParamCollInput.Add(new KeyValuePair <string, object>("@CreateDate", obj.CreatedDate)); ParamCollInput.Add(new KeyValuePair <string, object>("@UniqueEmail", obj.UniqueEmail)); ParamCollInput.Add(new KeyValuePair <string, object>("@PasswordFormat", obj.PasswordFormat)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", obj.PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", obj.AddedOn)); ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", obj.AddedBy)); ParamCollInput.Add(new KeyValuePair <string, object>("@RoleNames", obj.RoleNames)); ParamCollInput.Add(new KeyValuePair <string, object>("@StoreID", obj.StoreID)); List <KeyValuePair <string, object> > ParamCollOutput = new List <KeyValuePair <string, object> >(); ParamCollOutput.Add(new KeyValuePair <string, object>("@UserId", obj.UserID)); ParamCollOutput.Add(new KeyValuePair <string, object>("@ErrorCode", 0)); ParamCollOutput.Add(new KeyValuePair <string, object>("@CustomerID", obj.CustomerID)); SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); List <KeyValuePair <int, string> > OutputValColl = new List <KeyValuePair <int, string> >(); OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput); int CustomerID = int.Parse(OutputValColl[2].Value); int ErrorCode = int.Parse(OutputValColl[1].Value); Guid UserID = new Guid(OutputValColl[0].Value.ToString()); switch (ErrorCode) { case 3: status = UserCreationStatus.DUPLICATE_EMAIL; break; case 6: status = UserCreationStatus.DUPLICATE_USER; break; default: status = UserCreationStatus.SUCCESS; break; } return(true); } catch (Exception) { throw; } }