protected void Page_Load(object sender, EventArgs e) { if (Utilities.userToken == "token") { Utilities.pageName = "Default"; Response.Redirect("/Default.aspx"); return; } if (Utilities.statusId != 1 && HttpContext.Current.Request.Url.AbsolutePath != "/Users/UserProfileSecurity.aspx") { Utilities.pageName = "User Profile Security"; Response.Redirect("/Users/UserProfileSecurity.aspx"); return; } controls = new List <string>(); operations = dataProvider.GetAuthorizedOperations(Utilities.userToken, Utilities.userGroupId); int roleId; foreach (var operation in operations.Operation) { roleId = operation.OperationId; controls.AddRange(dataProvider.GetControlListByOperation(Utilities.userToken, roleId)); } controls.Add("checker"); foreach (var control in controls) { var a = MenuS.FindControl(control); if (a != null) { a.Visible = true; var parent = (HtmlControl)a.Parent; parent.Visible = true; } } var logout = (HtmlControl)Master.FindControl("divLogin"); logout.Visible = true; var showSidebar = (HtmlControl)Master.FindControl("btnShowSidebar"); showSidebar.Visible = true; var username = (Label)Master.FindControl("lblUserFullName"); username.Text = Utilities.userFullName; if (Utilities.pageName != string.Empty) { if (!controls.Contains(Utilities.pageName)) { Utilities.pageName = string.Empty; Response.Redirect("/LandingPage.aspx"); } } }
public override global::System.Data.DataSet Clone() { OperationDataSet cln = ((OperationDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
protected void Page_Load(object sender, EventArgs e) { if (Utilities.userToken == "token") { Utilities.pageName = "Default"; Response.Redirect("/Default.aspx"); return; } if (Utilities.statusId != 1 && HttpContext.Current.Request.Url.AbsolutePath != "/Users/UserProfileSecurity.aspx") { Utilities.pageName = "User Profile Security"; Response.Redirect("/Users/UserProfileSecurity.aspx"); return; } controls = new List<string>(); operations = dataProvider.GetAuthorizedOperations(Utilities.userToken, Utilities.userGroupId); int roleId; foreach (var operation in operations.Operation) { roleId = operation.OperationId; controls.AddRange(dataProvider.GetControlListByOperation(Utilities.userToken, roleId)); } controls.Add("checker"); foreach (var control in controls) { var a = MenuS.FindControl(control); if (a != null) { a.Visible = true; var parent = (HtmlControl) a.Parent; parent.Visible = true; } } var logout = (HtmlControl) Master.FindControl("divLogin"); logout.Visible = true; var showSidebar = (HtmlControl) Master.FindControl("btnShowSidebar"); showSidebar.Visible = true; var username = (Label) Master.FindControl("lblUserFullName"); username.Text = Utilities.userFullName; if (Utilities.pageName != string.Empty) { if (!controls.Contains(Utilities.pageName)) { Utilities.pageName = string.Empty; Response.Redirect("/LandingPage.aspx"); } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OperationDataSet ds = new OperationDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public OperationDataSet GetAuthorizedOperations(string userToken, int userGroupId) { try { logger.Log(Level.INFO, "Entering {0}. userToken={1}. userGroupId={2}." , "GetAuthorizedOperations" , userToken , userGroupId); OperationDataSet result = dataProvider.GetAuthorizedOperations(userToken, userGroupId); logger.Log(Level.INFO, "Exiting {0}" , "GetAuthorizedOperations"); return(result); } catch (ArgumentNullException ex) { logger.Log(Level.ERROR, "Exception thrown in GetAuthorizedOperations. Exception={0}. Message: {1}." , "ArgumentNullException" , ex); throw new ArgumentNullException(ex.ParamName, ex.InnerException); } catch (InvalidUserTokenException ex) { logger.Log(Level.ERROR, "Exception thrown in GetAuthorizedOperations. Exception={0}. Message: {1}." , "InvalidUserTokenException" , ex); throw new InvalidUserTokenException(ex.Message, userToken, ex.InnerException); } catch (ExpiredUserTokenException ex) { logger.Log(Level.ERROR, "Exception thrown in GetAuthorizedOperations. Exception={0}. Message: {1}." , "ExpiredUserTokenException" , ex); throw new ExpiredUserTokenException(ex.Message, userToken, ex.InnerException); } catch (OperationFailedException ex) { logger.Log(Level.ERROR, "Exception thrown in GetAuthorizedOperations. Exception={0}. Message: {1}." , "OperationFailedException" , ex); throw new OperationFailedException(ex.Message, userToken, ex.InnerException); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OperationDataSet ds = new OperationDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "OperationDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OperationDataSet ds = new OperationDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OperationDataSet ds = new OperationDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "OperationDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
/// <summary> /// Gets the list of authorised actions for that user /// </summary> /// <param name="userToken">The userToken of the user performing the request</param> /// <param name="userGroupId">The Id of the user group whose authorisations are being sought for</param> /// <returns>A string list collection of the specifed user's rights</returns> public OperationDataSet GetAuthorizedOperations(string userToken, int userGroupId) { var retValues = new OperationDataSet(); if (IsUserTokenValid(userToken)) { try { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spGetAuthorizedOperations"; var p2 = new SqlParameter[1]; for (int i = 0; i < 1; i++) p2[i] = new SqlParameter(); p2[0] = new SqlParameter("userGroupId", userGroupId); cmd.Parameters.AddRange(p2); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var oper = retValues.Operation.NewOperationRow(); oper.OperationId = int.Parse(reader["OperationId"].ToString()); oper.OperationName = reader["Operation"].ToString(); oper.UserGroup_Id = reader["Id"].ToString(); retValues.Operation.AddOperationRow(oper); } reader.Close(); } } catch (Exception ex) { throw new OperationFailedException(ex.Message, ex); } finally { if (conn.State != System.Data.ConnectionState.Closed) { conn.Close(); } } } return retValues; }
public OperationDataSet GetAllOperations(string userToken) { var retValues = new OperationDataSet(); if (IsUserTokenValid(userToken)) { try { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; if (Utilities.isSystemAdmin) { cmd.CommandText = "spGetAllAdminOperations"; } else { cmd.CommandText = "spGetAllNonAdminOperations"; } SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var oper = retValues.Operation.NewOperationRow(); oper.OperationId = int.Parse(reader["OperationId"].ToString()); oper.OperationName = reader["Operation"].ToString(); retValues.Operation.AddOperationRow(oper); } reader.Close(); } } catch (Exception ex) { throw new OperationFailedException(ex.Message, ex); } finally { if (conn.State != System.Data.ConnectionState.Closed) { conn.Close(); } } } return retValues; }