private void GetListPicker() { var listClass = Database.GetList <Class>(c => c.Id > 0); foreach (var className in listClass) { ClassNames.Add(className.Name); } ClassNameSelected = ClassNames[0]; SemesterName = "Học kỳ 1"; LoadListSubjects(); }
/// <summary> /// Returns where condition. /// </summary> /// <param name="customWhere">Custom WHERE condition</param> private WhereCondition GetWhereCondition(string customWhere) { SiteInfo si; var where = new WhereCondition(); // Get required site data if (!String.IsNullOrEmpty(SiteName)) { si = SiteInfoProvider.GetSiteInfo(SiteName); } else { si = SiteContext.CurrentSite; } if (si != null) { // Build where condition var classWhere = new WhereCondition(); // Get documents of the specified class only - without coupled data !!! if (!String.IsNullOrEmpty(ClassNames)) { string[] classNames = ClassNames.Trim(';').Split(';'); foreach (string className in classNames) { classWhere.WhereEquals("ClassName", className).Or(); } } where.WhereIn("NodeSKUID", new IDQuery <OrderItemInfo>("OrderItemSKUID").Source(s => s.Join <SKUInfo>("OrderItemSKUID", "SKUID") .Join <OrderInfo>("COM_OrderItem.OrderItemOrderID", "OrderID")) .WhereTrue("SKUEnabled") .WhereNull("SKUOptionCategoryID") .WhereEquals("OrderSiteID", si.SiteID) .Where(classWhere)); // Add custom WHERE condition if (!String.IsNullOrEmpty(customWhere)) { where.Where(customWhere); } } return(where); }
/// <summary> /// Returns the next Class name for the Theme /// </summary> /// <returns></returns> public string GetNextClassName() { if (ClassNames == null || ClassNames.Count == 0) { return(NAME_UNAVAILABLE); } string nextName; do { nextName = ClassNames.Dequeue(); } while (string.IsNullOrEmpty(nextName)); //put the name at the end so we keep looping ClassNames.Enqueue(nextName); return(nextName); }
private void PopulateClassNames(int val) { ClassNames classNames = new ClassNames(_connString); List <ClassNames> classNameList = classNames.GetClass_Names(); foreach (ClassNames className in classNameList) { ComboBoxItem item = new ComboBoxItem(); item.Text = className.Description; item.Value = className.Class_Name_ID; cboClassNames.Items.Add(item); if (className.Class_Name_ID == val) { cboClassNames.Text = className.Description; } } }
protected void DogGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string Dog_ID = ((HiddenField)e.Row.FindControl("hdnID")).Value; GridView gvClasses = e.Row.FindControl("ClassGridView") as GridView; List <DogClasses> tblDog_Classes; DogClasses dogClasses = new DogClasses(_connString); if (!string.IsNullOrEmpty(Entrant_ID) && !string.IsNullOrEmpty(Dog_ID)) { Guid entrant_ID = new Guid(Entrant_ID); Guid dog_ID = new Guid(Dog_ID); tblDog_Classes = dogClasses.GetDog_ClassesByEntrant_ID_Dog_ID(entrant_ID, dog_ID); if (tblDog_Classes != null && tblDog_Classes.Count > 0) { List <DogClasses> dogClassList = new List <DogClasses>(); foreach (DogClasses row in tblDog_Classes) { if (!row.IsShow_Entry_Class_IDNull && row.Show_Entry_Class_ID != new Guid()) { DogClasses dogClass = new DogClasses(_connString, (Guid)row.Dog_Class_ID); Dogs dog = new Dogs(_connString, (Guid)row.Dog_ID); dogClass.Dog_Class_ID = row.Dog_Class_ID; dogClass.Dog_KC_Name = dog.Dog_KC_Name; ShowEntryClasses showEntryClass = new ShowEntryClasses(_connString, (Guid)row.Show_Entry_Class_ID); ClassNames className = new ClassNames(_connString, Int32.Parse(showEntryClass.Class_Name_ID.ToString())); dogClass.Class_Name_Description = string.Format("{0} : {1}", showEntryClass.Class_No, className.Description); if (!row.IsHandler_IDNull && row.Handler_ID != new Guid()) { People handler = new People(_connString, (Guid)row.Handler_ID); dogClass.Handler_Name = string.Format("{0} {1}", handler.Person_Forename, handler.Person_Surname); } dogClassList.Add(dogClass); } } if (dogClassList != null) { gvClasses.DataSource = dogClassList; gvClasses.DataBind(); } } } } }
private void Parameter_ValueChanged(object sender, EventArgs e) { var oldPositiveClass = PositiveClass; var oldClassNames = classNamesCache; var index = oldClassNames.IndexOf(oldPositiveClass); classNamesCache = null; ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name); ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name); PositiveClassParameter.ValidValues.Clear(); foreach (var className in ClassNames) { PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly()); } PositiveClassParameter.Value = PositiveClassParameter.ValidValues.ElementAt(index); OnChanged(); }
public StudentSelector() { using (DataRepository Repo = new DataRepository()) { // Get the classes Classes = Repo.Classes.ToList(); // Get the names of the classes ClassNames = Repo.Classes.Select(c => c.ClassName).ToList(); // Insert a "dummy" class which ignores the selection ClassNames.Insert(0, "All students"); // Get the students Students = Repo.Users.OfType <Student>().Select(s => new Checkable <Student>(s)).ToList(); // Initialise the filtered student list FilteredStudents = new ObservableCollection <Checkable <Student> >(Students); } InitializeComponent(); }
private void ResetTargetVariableDependentMembers() { DeregisterParameterEvents(); ((IStringConvertibleMatrix)ClassNamesParameter.Value).Columns = 1; ((IStringConvertibleMatrix)ClassNamesParameter.Value).Rows = ClassValuesCache.Count; for (int i = 0; i < Classes; i++) { ClassNamesParameter.Value[i, 0] = "Class " + ClassValuesCache[i]; } ClassNamesParameter.Value.ColumnNames = new List <string>() { "ClassNames" }; ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s); PositiveClassParameter.ValidValues.Clear(); foreach (var className in ClassNames) { PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly()); } ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Rows = Classes; ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Columns = Classes; ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name); ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name); for (int i = 0; i < Classes; i++) { for (int j = 0; j < Classes; j++) { if (i != j) { ClassificationPenaltiesParameter.Value[i, j] = 1; } else { ClassificationPenaltiesParameter.Value[i, j] = 0; } } } RegisterParameterEvents(); }
/// <summary> /// Parses the Meta Header from a byte array. /// </summary> /// <param name="data"></param> /// <param name="bytePointerPosition"></param> /// <param name="showConsole"></param> public MSV5(BinaryReader reader, bool showConsole = true) { mMetaStreamVersion += ByteFunctions.ReadFixedString(reader, 4); //Meta Stream Keyword [4 bytes] mDefaultSectionChunkSize = reader.ReadUInt32(); //Default Section Chunk Size [4 bytes] //default section chunk size mDebugSectionChunkSize = reader.ReadUInt32(); //Debug Section Chunk Size [4 bytes] //debug section chunk size (always zero) mAsyncSectionChunkSize = reader.ReadUInt32(); //Async Section Chunk Size [4 bytes] //async section chunk size (size of the bytes after the file header) mClassNamesLength = reader.ReadUInt32(); //mClassNamesLength [4 bytes] //--------------------------mClassNames-------------------------- mClassNames = new ClassNames[mClassNamesLength]; for (int i = 0; i < mClassNames.Length; i++) { mClassNames[i] = new ClassNames() { mTypeNameCRC = new Symbol() { mCrc64 = reader.ReadUInt64() }, mVersionCRC = reader.ReadUInt32() }; } MetaHeaderLength = (4 * 5) + (12 * mClassNamesLength); if (showConsole) { ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan); Console.WriteLine("||||||||||| Meta Header |||||||||||"); ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White); Console.WriteLine("Meta Stream Keyword = {0}", mMetaStreamVersion); Console.WriteLine("Meta Default Section Chunk Size = {0}", mDefaultSectionChunkSize); Console.WriteLine("Meta Debug Section Chunk Size = {0}", mDebugSectionChunkSize); Console.WriteLine("Meta Async Section Chunk Size = {0}", mAsyncSectionChunkSize); Console.WriteLine("Meta mClassNamesLength = {0}", mClassNamesLength); for (int i = 0; i < mClassNames.Length; i++) { Console.WriteLine("Meta mClassName {0} = {1}", i, mClassNames[i]); } } }
private void AfterDeserialization() { RegisterParameterEvents(); classNamesCache = new List <string>(); for (int i = 0; i < ClassNamesParameter.Value.Rows; i++) { classNamesCache.Add(ClassNamesParameter.Value[i, 0]); } // BackwardsCompatibility3.4 #region Backwards compatible code, remove with 3.5 if (!Parameters.ContainsKey(PositiveClassParameterName)) { var validValues = new ItemSet <StringValue>(ClassNames.Select(s => new StringValue(s).AsReadOnly())); Parameters.Add(new ConstrainedValueParameter <StringValue>(PositiveClassParameterName, "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)", validValues, validValues.First())); } #endregion }
public bool AddObject(ObjectModel obj) { if (NoFeatures > 0 && NoFeatures != obj.FeaturesNumber) { return(false); } Objects.Add(obj); if (ClassCounters.ContainsKey(obj.ClassName)) { ClassCounters[obj.ClassName]++; } else { ClassCounters.Add(obj.ClassName, 1); ClassNames.Add(obj.ClassName); } return(true); }
public override string ToString() { var enquote = false; var formattedClassNames = string.Join("or ", ClassNames.Select(n => $"\"{n}\"")); var s = string.IsNullOrWhiteSpace(Name) ? $"Unnamed {formattedClassNames}" : $"\"{Name}\" of class {formattedClassNames}"; if (!string.IsNullOrWhiteSpace(NameContains)) { enquote = true; s += $" with name containing \"{NameContains}\""; } foreach (var nameDoesNotContain in NameDoesNotContain) { enquote = true; s += $" with name not containing \"{nameDoesNotContain}\""; } if (NameMustNotBeEmpty) { s += " with non-empty name"; } return(enquote || NameMustNotBeEmpty ? $"\"{s}\"" : s); }
public List <ClassNames> GetClasses() { List <ClassNames> result = new List <ClassNames>(); db = new Database.ApplicationContext(); var q = db.Images.ToArray().GroupBy(img => img.ClassName); foreach (var g in q) { int count = 0; foreach (var img in g) { count++; } var tmp = new ClassNames(); tmp.ClassName = g.Key; tmp.Count = count.ToString(); result.Add(tmp); } return(result); }
private Table GetTable(TableSchema tableSchema, bool processAssociations) { Table t; string key = tableSchema.FullName; if (Database.Tables.Contains(key)) { t = Database.Tables[key]; // add sub type class names ClassNames.Add(t.Type.Name); } else { t = CreateTable(tableSchema); } if (!PropertyNames.ContainsKey(t.Type.Name)) { PropertyNames.Add(t.Type.Name, new List <string>()); } if (!t.Type.Columns.IsProcessed) { CreateColumns(t, tableSchema); } if (processAssociations && !t.Type.Associations.IsProcessed) { CreateAssociations(t, tableSchema); } t.Type.IsProcessed = true; t.IsProcessed = true; return(t); }
public IEnumerable <TypeDefinition> FindTypesToProcess() { foreach (var type in ModuleDefinition.GetTypes()) { if (!type.IsClass) { continue; } if (type.IsAbstract) { continue; } var dependencyChain = GetParentsChain(type); // dot not forget to add self type if it has no derived types dependencyChain.Add(type); var baseType = dependencyChain.FirstOrDefault(t => ClassNames.Contains(t.FullName)); if (baseType == null) { continue; } // process instance-only constructors var constructors = GetConstructorsToInject(type); // skip class with single constructor if (!constructors.Any()) { continue; } yield return(type); } }
private void EditEntryClass() { cboNewValue = new ComboBox(); cboNewValue.Width = panel1.Width; panel1.Controls.Add(cboNewValue); dog = new Dogs(_connString, new Guid(_dogID)); dogClass = new DogClasses(_connString, new Guid(_dogClassID)); ShowEntryClasses sec = new ShowEntryClasses(_connString); List <ShowEntryClasses> secList = sec.GetShow_Entry_ClassesByShow_ID(new Guid(_showID)); foreach (ShowEntryClasses showEntryClass in secList) { ClassNames cn = new ClassNames(_connString, (int)showEntryClass.Class_Name_ID); ComboBoxItem item = new ComboBoxItem(); item.Text = cn.Description; item.Value = showEntryClass.Show_Entry_Class_ID; cboNewValue.Items.Add(item); if (dogClass.Show_Entry_Class_ID == showEntryClass.Show_Entry_Class_ID) { lblCurrentValue.Text = cn.Description; lblCurrentValue.Visible = true; } } }
/// <summary> /// Parses the Meta Header from a byte array. /// </summary> /// <param name="data"></param> /// <param name="bytePointerPosition"></param> /// <param name="showConsole"></param> public MTRE(BinaryReader reader, bool showConsole = true) { mMetaStreamVersion += ByteFunctions.ReadFixedString(reader, 4); //Meta Stream Keyword [4 bytes] mClassNamesLength = reader.ReadUInt32(); //mClassNamesLength [4 bytes] //--------------------------mClassNames-------------------------- mClassNames = new ClassNames[mClassNamesLength]; for (int i = 0; i < mClassNames.Length; i++) { mClassNames[i] = new ClassNames() { mTypeNameCRC = new Symbol() { mCrc64 = reader.ReadUInt64() }, mVersionCRC = reader.ReadUInt32() }; } MetaHeaderLength = (4 * 5) + (12 * mClassNamesLength); if (showConsole) { ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.Cyan); Console.WriteLine("||||||||||| Meta Header |||||||||||"); ConsoleFunctions.SetConsoleColor(ConsoleColor.Black, ConsoleColor.White); Console.WriteLine("Meta Stream Keyword = {0}", mMetaStreamVersion); Console.WriteLine("Meta mClassNamesLength = {0}", mClassNamesLength); for (int i = 0; i < mClassNames.Length; i++) { Console.WriteLine("Meta mClassName {0} = {1}", i, mClassNames[i]); } } }
/// <summary> /// Loads all data. Should be positioned on the start /// if the second data hunk. /// </summary> /// <param name="dataReader"></param> public ExecutableData(IDataReader dataReader) { // TODO: For now we search the offset of the filelist manually // until we decode all of the data. dataReader.Position = (int)dataReader.FindString("0Map_data.amb", 0) - 184; // TODO ... FileList = new FileList(dataReader); WorldNames = new WorldNames(dataReader); Messages = new Messages(dataReader); if (dataReader.ReadDword() != 0) { throw new AmbermoonException(ExceptionScope.Data, "Invalid executable data."); } AutomapNames = new AutomapNames(dataReader); OptionNames = new OptionNames(dataReader); SongNames = new SongNames(dataReader); SpellTypeNames = new SpellTypeNames(dataReader); SpellNames = new SpellNames(dataReader); LanguageNames = new LanguageNames(dataReader); ClassNames = new ClassNames(dataReader); RaceNames = new RaceNames(dataReader); AbilityNames = new AbilityNames(dataReader); AttributeNames = new AttributeNames(dataReader); AbilityNames.AddShortNames(dataReader); AttributeNames.AddShortNames(dataReader); ItemTypeNames = new ItemTypeNames(dataReader); AilmentNames = new AilmentNames(dataReader); UITexts = new UITexts(dataReader); // TODO: There is a bunch of binary data (gfx maybe?) // TODO: Then finally the item data comes ... // TODO ... }
public static void ShadowDancer() { chosen = ClassNames.ShadowDancer; }
/// <summary> /// Saves relationship. /// </summary> public void SaveRelationship() { if (TreeNode == null) { return; } // Check modify permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } bool currentNodeIsOnLeftSide = !DefaultSide; // Selected node Id int selectedNodeId = ValidationHelper.GetInteger(hdnSelectedNodeId.Value, 0); if (BindOnPrimaryNodeOnly) { selectedNodeId = RelHelper.GetPrimaryNodeID(selectedNodeId); } var relationshipName = RelationshipName; var relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipName); int relationshipNameId; if (relationshipNameInfo != null) { relationshipNameId = relationshipNameInfo.RelationshipNameId; } else { throw new NullReferenceException("[RelatedDocuments.SaveRelationship]: Missing relationship name to use for relation."); } if ((selectedNodeId <= 0) || (relationshipNameId <= 0)) { return; } try { // Test to make sure the selected page is a Right Side macro-allowed page or left side, and also matches the Page type limiter var SelectedTreeNode = (AllowAllTypes ? new DocumentQuery() : new DocumentQuery(AllowedPageTypes)).WhereEquals("NodeID", selectedNodeId).FirstOrDefault(); // If null probably not an allowed page type, but we will need it to validate below if (SelectedTreeNode == null) { SelectedTreeNode = new DocumentQuery().WhereEquals("NodeID", selectedNodeId).FirstOrDefault(); } var CurrentPageMacroResolver = MacroResolver.GetInstance(); CurrentPageMacroResolver.SetNamedSourceData("CurrentDocument", TreeNode); var PageMacroResolver = MacroResolver.GetInstance(); PageMacroResolver.SetNamedSourceData("CurrentDocument", SelectedTreeNode); // Left side if (currentNodeIsOnLeftSide) { if (!AllowAllTypes && !ClassNames.Contains(SelectedTreeNode.ClassName.ToLower())) { AddError(ResHelper.LocalizeExpression("RelatedPages.BadPageType")); } else if (!ValidationHelper.GetBoolean(CurrentPageMacroResolver.ResolveMacros(IsLeftSideMacro), false) || !ValidationHelper.GetBoolean(PageMacroResolver.ResolveMacros(IsRightSideMacro), false)) { AddError(ResHelper.LocalizeExpression("RelatedPages.LeftSideRightSideInvalid")); } else if (TreeNode.NodeID == SelectedTreeNode.NodeID) { AddError(ResHelper.LocalizeExpression("RelatedPages.CannotSelectSelf")); } else { RelationshipInfoProvider.AddRelationship(TreeNode.NodeID, selectedNodeId, relationshipNameId); if (RelHelper.IsStagingEnabled()) { // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(TreeNode.NodeSiteName, TreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider); } ShowConfirmation(GetString("relationship.wasadded")); } } // Right side else { if (!AllowAllTypes && !ClassNames.Contains(SelectedTreeNode.ClassName.ToLower())) { AddError(ResHelper.LocalizeExpression("RelatedPages.BadPageType")); } else if (!ValidationHelper.GetBoolean(CurrentPageMacroResolver.ResolveMacros(IsLeftSideMacro), false) || !ValidationHelper.GetBoolean(PageMacroResolver.ResolveMacros(IsRightSideMacro), false)) { AddError(ResHelper.LocalizeExpression("RelatedPages.LeftSideRightSideInvalid")); } else if (TreeNode.NodeID == SelectedTreeNode.NodeID) { AddError(ResHelper.LocalizeExpression("RelatedPages.CannotSelectSelf")); } else { RelationshipInfoProvider.AddRelationship(selectedNodeId, TreeNode.NodeID, relationshipNameId); if (RelHelper.IsStagingEnabled()) { // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(TreeNode.NodeSiteName, SelectedTreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider); } ShowConfirmation(GetString("relationship.wasadded")); } } } catch (Exception ex) { ShowError(ex.Message); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { calItems.StopProcessing = true; } else { calItems.ControlContext = repEvent.ControlContext = ControlContext; // Calendar properties calItems.CacheItemName = CacheItemName; calItems.CacheDependencies = CacheDependencies; calItems.CacheMinutes = CacheMinutes; calItems.CheckPermissions = CheckPermissions; calItems.ClassNames = ClassNames; calItems.CombineWithDefaultCulture = CombineWithDefaultCulture; calItems.CultureCode = CultureCode; calItems.MaxRelativeLevel = MaxRelativeLevel; calItems.OrderBy = OrderBy; calItems.WhereCondition = WhereCondition; calItems.Columns = Columns; calItems.Path = Path; calItems.SelectOnlyPublished = SelectOnlyPublished; calItems.SiteName = SiteName; calItems.FilterName = FilterName; calItems.RelationshipName = RelationshipName; calItems.RelationshipWithNodeGuid = RelationshipWithNodeGuid; calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide; calItems.TransformationName = TransformationName; calItems.NoEventTransformationName = NoEventTransformationName; calItems.DayField = DayField; calItems.EventEndField = EventEndField; calItems.HideDefaultDayNumber = HideDefaultDayNumber; calItems.TodaysDate = TimeZoneMethods.ConvertDateTime(DateTime.Now, this); bool detail = false; // If calendar event path is defined event is loaded in accordance to the selected path string eventPath = QueryHelper.GetString("CalendarEventPath", null); if (!String.IsNullOrEmpty(eventPath)) { detail = true; repEvent.Path = eventPath; // Set selected date to specific document TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, MembershipContext.AuthenticatedUser); if (node != null) { object value = node.GetValue(DayField); if (ValidationHelper.GetDateTimeSystem(value, DateTimeHelper.ZERO_TIME) != DateTimeHelper.ZERO_TIME) { calItems.TodaysDate = TimeZoneMethods.ConvertDateTime((DateTime)value, this); } } } // By default select current event from current document value PageInfo currentPage = DocumentContext.CurrentPageInfo; if ((currentPage != null) && (ClassNames.ToLowerCSafe().Contains(currentPage.ClassName.ToLowerCSafe()))) { detail = true; repEvent.Path = currentPage.NodeAliasPath; // Set selected date to current document object value = DocumentContext.CurrentDocument.GetValue(DayField); if (ValidationHelper.GetDateTimeSystem(value, DateTimeHelper.ZERO_TIME) != DateTimeHelper.ZERO_TIME) { calItems.TodaysDate = TimeZoneMethods.ConvertDateTime((DateTime)value, this); // Get name of coupled class ID column string idColumn = DocumentContext.CurrentDocument.CoupledClassIDColumn; if (!string.IsNullOrEmpty(idColumn)) { // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar calItems.SelectedItemIDColumn = idColumn; calItems.SelectedItemID = ValidationHelper.GetInteger(DocumentContext.CurrentDocument.GetValue(idColumn), 0); } } } if (detail) { // Setup the detail repeater repEvent.Visible = true; repEvent.StopProcessing = false; repEvent.SelectedItemTransformationName = EventDetailTransformation; repEvent.ClassNames = ClassNames; repEvent.Columns = Columns; if (!String.IsNullOrEmpty(CacheItemName)) { repEvent.CacheItemName = CacheItemName + "|detail"; } repEvent.CacheDependencies = CacheDependencies; repEvent.CacheMinutes = CacheMinutes; repEvent.CheckPermissions = CheckPermissions; repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture; repEvent.CultureCode = CultureCode; repEvent.SelectOnlyPublished = SelectOnlyPublished; repEvent.SiteName = SiteName; repEvent.WhereCondition = WhereCondition; } } }
private void ReloadData() { if (StopProcessing) { // Do nothing gridDocs.StopProcessing = true; editDoc.StopProcessing = true; } else { if (((AllowUsers == UserContributionAllowUserEnum.Authenticated) || (AllowUsers == UserContributionAllowUserEnum.DocumentOwner)) && !AuthenticationHelper.IsAuthenticated()) { // Not authenticated, do not display anything pnlList.Visible = false; pnlEdit.Visible = false; StopProcessing = true; } else { SetContext(); // Hide document list gridDocs.Visible = false; // If the list of documents should be displayed ... if (DisplayList) { // Get all documents of the current user TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Generate additional where condition WhereCondition condition = new WhereCondition(WhereCondition); if (!String.IsNullOrEmpty(ClassNames)) { condition.WhereIn("ClassName", ClassNames.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); } // Add user condition if (AllowUsers == UserContributionAllowUserEnum.DocumentOwner) { condition.WhereEquals("NodeOwner", MembershipContext.AuthenticatedUser.UserID); } // Get the documents var query = DocumentHelper.GetDocuments() .OnSite(SiteName) .Path(MacroResolver.ResolveCurrentPath(Path)) .Where(condition) .OrderBy(OrderBy) .Published(SelectOnlyPublished) .NestingLevel(MaxRelativeLevel) .CheckPermissions(CheckPermissions); TreeProvider.SetQueryCultures(query, CultureCode, CombineWithDefaultCulture); // Do not apply published from / to columns to make sure the published information is correctly evaluated query.Properties.ExcludedVersionedColumns = new[] { "DocumentPublishFrom", "DocumentPublishTo" }; var ds = query.Result; if (!DataHelper.DataSourceIsEmpty(ds)) { // Display and initialize grid if datasource is not empty gridDocs.Visible = true; gridDocs.DataSource = ds; gridDocs.OrderBy = OrderBy; editDoc.AlternativeFormName = AlternativeFormName; } } bool isAuthorizedToCreateDoc = false; if (ParentNode != null) { // Check if single class name is set string className = (!string.IsNullOrEmpty(AllowedChildClasses) && !AllowedChildClasses.Contains(";")) ? AllowedChildClasses : null; // Check user's permission to create new document if allowed isAuthorizedToCreateDoc = !CheckPermissions || MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(ParentNodeID, className); // Check group's permission to create new document if allowed isAuthorizedToCreateDoc &= CheckGroupPermission("createpages"); if (!CheckDocPermissionsForInsert && CheckPermissions) { // If document permissions are not required check create permission on parent document isAuthorizedToCreateDoc = MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(ParentNode, NodePermissionsEnum.Create) == AuthorizationResultEnum.Allowed; } if (AllowUsers == UserContributionAllowUserEnum.DocumentOwner) { if (VirtualContext.ReadonlyMode) { isAuthorizedToCreateDoc = false; } else { // Check if user is document owner (or global admin) isAuthorizedToCreateDoc = isAuthorizedToCreateDoc && ((ParentNode.NodeOwner == MembershipContext.AuthenticatedUser.UserID) || MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)); } } } // Enable/disable inserting new document pnlNewDoc.Visible = (isAuthorizedToCreateDoc && AllowInsert); if (!gridDocs.Visible && !pnlNewDoc.Visible && pnlList.Visible) { // Not authenticated to create new docs and grid is hidden StopProcessing = true; } ReleaseContext(); } } }
protected void DogGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string Dog_ID = ((HiddenField)e.Row.FindControl("hdnID")).Value; GridView gvClasses = e.Row.FindControl("ClassGridView") as GridView; List<DogClasses> tblDog_Classes; DogClasses dogClasses = new DogClasses(); if (!string.IsNullOrEmpty(Dog_ID)) { Guid dog_ID = new Guid(Dog_ID); tblDog_Classes = dogClasses.GetDog_ClassesByDog_ID(dog_ID); if (tblDog_Classes != null && tblDog_Classes.Count > 0) { List<DogClasses> dogClassList = new List<DogClasses>(); foreach (DogClasses row in tblDog_Classes) { if (!row.IsShow_Entry_Class_IDNull) { DogClasses dogClass = new DogClasses((Guid)row.Dog_Class_ID); Dogs dog = new Dogs((Guid)row.Dog_ID); dogClass.Dog_Class_ID = row.Dog_Class_ID; dogClass.Dog_KC_Name = dog.Dog_KC_Name; ShowEntryClasses showEntryClass = new ShowEntryClasses((Guid)row.Show_Entry_Class_ID); ClassNames className = new ClassNames(Int32.Parse(showEntryClass.Class_Name_ID.ToString())); dogClass.Class_Name_Description = string.Format("{0} : {1}", showEntryClass.Class_No, className.Description); if (!row.IsHandler_IDNull) { People handler = new People((Guid)row.Handler_ID); dogClass.Handler_Name = string.Format("{0} {1}", handler.Person_Forename, handler.Person_Surname); } dogClassList.Add(dogClass); } } if (dogClassList != null) { gvClasses.DataSource = dogClassList; gvClasses.DataBind(); } } } } }
private void PopulateDogClassesGrid(string entrantID) { string connString = Utils.ConnectionString(); Guid entrant_ID = new Guid(entrantID); DogClasses dogClasses = new DogClasses(connString); List <DogClasses> dcList = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID); DataTable dt = new DataTable(); DataColumn dcDogClassID = new DataColumn("DogClassID"); DataColumn dcEntrantID = new DataColumn("EntrantID"); DataColumn dcDogID = new DataColumn("DogID"); DataColumn dcKCName = new DataColumn("KCName"); DataColumn dcBreed = new DataColumn("Breed"); DataColumn dcGender = new DataColumn("Gender"); DataColumn dcRegNo = new DataColumn("RegNo"); DataColumn dcDOB = new DataColumn("DOB"); DataColumn dcMeritPoints = new DataColumn("MeritPoints"); DataColumn dcBreeder = new DataColumn("Breeder"); DataColumn dcSire = new DataColumn("Sire"); DataColumn dcDam = new DataColumn("Dam"); DataColumn dcEntryClassName = new DataColumn("EntryClassName"); DataColumn dcPreferredPart = new DataColumn("PreferredPart"); DataColumn dcFinalClassName = new DataColumn("FinalClassName"); DataColumn dcHandler = new DataColumn("Handler"); DataColumn dcRingNo = new DataColumn("RingNo"); DataColumn dcRunningOrder = new DataColumn("RunningOrder"); DataColumn dcSpecialRequest = new DataColumn("SpecialRequest"); dt.Columns.Add(dcDogClassID); dt.Columns.Add(dcEntrantID); dt.Columns.Add(dcDogID); dt.Columns.Add(dcKCName); dt.Columns.Add(dcBreed); dt.Columns.Add(dcGender); dt.Columns.Add(dcRegNo); dt.Columns.Add(dcDOB); dt.Columns.Add(dcMeritPoints); dt.Columns.Add(dcBreeder); dt.Columns.Add(dcSire); dt.Columns.Add(dcDam); dt.Columns.Add(dcEntryClassName); dt.Columns.Add(dcPreferredPart); dt.Columns.Add(dcFinalClassName); dt.Columns.Add(dcHandler); dt.Columns.Add(dcRingNo); dt.Columns.Add(dcRunningOrder); dt.Columns.Add(dcSpecialRequest); object[] dogRow = new object[19]; foreach (DogClasses dc in dcList) { Dogs dog = new Dogs(connString, (Guid)dc.Dog_ID); ShowEntryClasses sec = new ShowEntryClasses(connString, (Guid)dc.Show_Entry_Class_ID); ClassNames cn = new ClassNames(connString, (int)sec.Class_Name_ID); DogBreeds db = new DogBreeds(connString, (int)dog.Dog_Breed_ID); DogGender dg = new DogGender(connString, (int)dog.Dog_Gender_ID); dogRow[0] = dc.Dog_Class_ID; dogRow[1] = entrant_ID; dogRow[2] = dog.Dog_ID; dogRow[3] = dog.Dog_KC_Name; dogRow[4] = db.Description; dogRow[5] = dg.Description; dogRow[6] = dog.Reg_No; DateTime DOB = (DateTime)dog.Date_Of_Birth; dogRow[7] = string.Format("{0}/{1}/{2}", DOB.Day, DOB.Month, DOB.Year); dogRow[8] = dog.Merit_Points; dogRow[9] = dog.Breeder; dogRow[10] = dog.Sire; dogRow[11] = dog.Dam; dogRow[12] = string.Concat(sec.Class_No, " - ", cn.Class_Name_Description); dogRow[13] = dc.Preferred_Part.ToString(); if (dc.Show_Final_Class_ID != null && dc.Show_Final_Class_ID != new Guid()) { ShowFinalClasses sfc = new ShowFinalClasses(connString, (Guid)dc.Show_Final_Class_ID); dogRow[14] = sfc.Show_Final_Class_Description; } else { dogRow[14] = "Not Yet Assigned"; } People handler = new People(connString, (Guid)dc.Handler_ID); dogRow[15] = handler.Person_FullName; dogRow[16] = string.IsNullOrWhiteSpace(dc.Ring_No.ToString()) ? "Not Yet Assigned" : dc.Ring_No.ToString(); dogRow[17] = string.IsNullOrWhiteSpace(dc.Running_Order.ToString()) ? "Not Yet Assigned" : dc.Running_Order.ToString(); dogRow[18] = dc.Special_Request; dt.Rows.Add(dogRow); } dgvDogClasses.DataSource = dt; dgvDogClasses.Columns["DogClassID"].Visible = false; dgvDogClasses.Columns["EntrantID"].Visible = false; dgvDogClasses.Columns["DogID"].Visible = false; //dgvDogClasses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; //dgvDogClasses.AutoSize = true; }
private void PopulateDogClassGridView() { List<DogClasses> tblDogClasses; DogClasses dogClasses = new DogClasses(); Guid entrant_ID = new Guid(Entrant_ID); tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID); List<DogClasses> dogClassList = new List<DogClasses>(); foreach (DogClasses row in tblDogClasses) { if (!row.IsShow_Entry_Class_IDNull) { DogClasses dogClass = new DogClasses((Guid)row.Dog_Class_ID); Dogs dog = new Dogs((Guid)row.Dog_ID); dogClass.Dog_Class_ID = row.Dog_Class_ID; dogClass.Dog_KC_Name = dog.Dog_KC_Name; ShowEntryClasses showEntryClass = new ShowEntryClasses((Guid)row.Show_Entry_Class_ID); ClassNames className = new ClassNames(Int32.Parse(showEntryClass.Class_Name_ID.ToString())); dogClass.Class_Name_Description = string.Format("{0} : {1}", showEntryClass.Class_No, className.Description); if (!row.IsHandler_IDNull) { People handler = new People((Guid)row.Handler_ID); dogClass.Handler_Name = string.Format("{0} {1}", handler.Person_Forename, handler.Person_Surname); } dogClassList.Add(dogClass); } } if (dogClassList != null) { DogClassGridView.DataSource = dogClassList; DogClassGridView.DataBind(); } }
void GenerateClassForBinding() { try { if (bindingCount == 1 && service != null && Style != ServiceDescriptionImportStyle.ServerInterface) { // If there is only one binding, then use the name of the service className = XmlConvert.DecodeName(service.Name); } else { // If multiple bindings, then use the name of the binding className = binding.Name; if (Style == ServiceDescriptionImportStyle.ServerInterface) { // append "I" if we are generating interfaces className = "I" + CodeIdentifier.MakePascal(className); } } className = XmlConvert.DecodeName(className); className = ClassNames.AddUnique(CodeIdentifier.MakeValid(className), null); this.codeClass = BeginClass(); int methodCount = 0; for (int i = 0; i < portType.Operations.Count; i++) { MoveToOperation(portType.Operations[i]); if (!IsOperationFlowSupported(operation.Messages.Flow)) { // switch (operation.Messages.Flow) { case OperationFlow.SolicitResponse: UnsupportedOperationWarning(Res.GetString(Res.SolicitResponseIsNotSupported0)); continue; case OperationFlow.RequestResponse: UnsupportedOperationWarning(Res.GetString(Res.RequestResponseIsNotSupported0)); continue; case OperationFlow.OneWay: UnsupportedOperationWarning(Res.GetString(Res.OneWayIsNotSupported0)); continue; case OperationFlow.Notification: UnsupportedOperationWarning(Res.GetString(Res.NotificationIsNotSupported0)); continue; } } CodeMemberMethod method; try { method = GenerateMethod(); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidOperationException(Res.GetString(Res.UnableToImportOperation1, operation.Name), e); } if (method != null) { AddExtensionWarningComments(codeClass.Comments, operationBinding.Extensions); if (operationBinding.Input != null) { AddExtensionWarningComments(codeClass.Comments, operationBinding.Input.Extensions); } if (operationBinding.Output != null) { AddExtensionWarningComments(codeClass.Comments, operationBinding.Output.Extensions); } methodCount++; } } bool newAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateNewAsync) != 0 && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareEvents) && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareDelegates); if (newAsync && methodCount > 0 && Style == ServiceDescriptionImportStyle.Client) { CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); string cancelAsync = "CancelAsync"; string cancelMethodName = MethodNames.AddUnique(cancelAsync, cancelAsync); CodeMemberMethod asyncCancelMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, cancelMethodName, new CodeFlags[1], new string[] { typeof(object).FullName }, new string[] { "userState" }, typeof(void).FullName, metadata, CodeFlags.IsPublic | (cancelAsync != cancelMethodName ? 0 : CodeFlags.IsNew)); asyncCancelMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(new CodeBaseReferenceExpression(), cancelAsync); invoke.Parameters.Add(new CodeArgumentReferenceExpression("userState")); asyncCancelMethod.Statements.Add(invoke); } EndClass(); if (portType.Operations.Count == 0) { NoMethodsGeneratedWarning(); } AddExtensionWarningComments(codeClass.Comments, binding.Extensions); if (port != null) { AddExtensionWarningComments(codeClass.Comments, port.Extensions); } codeNamespace.Types.Add(codeClass); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidOperationException(Res.GetString(Res.UnableToImportBindingFromNamespace2, binding.Name, binding.ServiceDescription.TargetNamespace), e); } }
protected void Page_Load(object sender, EventArgs e) { _connString = ConfigurationManager.ConnectionStrings["SSSDbConnDev"].ConnectionString; Common.ConnString = _connString; if (!string.IsNullOrEmpty(Common.Show_Entry_Class_ID)) { Show_Entry_Class_ID = Common.Show_Entry_Class_ID; } if (!string.IsNullOrEmpty(Common.Club_ID)) { Club_ID = Common.Club_ID; divGetClub.Visible = false; divClubDetails.Visible = true; } else { divGetClub.Visible = true; divClubDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Show_ID)) { Show_ID = Common.Show_ID; divGetShow.Visible = false; divShowDetails.Visible = true; } else { divGetShow.Visible = true; divShowDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Class_Name_ID)) { Class_Name_ID = Common.Class_Name_ID; lstClassNames.SelectedValue = Class_Name_ID; } if (!string.IsNullOrEmpty(Common.Class_No)) { Class_No = Common.Class_No; txtClassNo.Text = Class_No; } if (string.IsNullOrEmpty(Common.Class_Gender)) { Class_Gender = Common.Class_Gender; lstClassGender.SelectedValue = Class_Gender; } if (!string.IsNullOrEmpty(Club_ID)) { PopulateClub(Club_ID); } if (!string.IsNullOrEmpty(Show_ID)) { PopulateShow(Show_ID); PopulateClassGridview(Show_ID); } if (!Page.IsPostBack) { string returnChars = Request.QueryString["return"]; btnReturn.PostBackUrl = Common.ReturnPath(Request.QueryString, returnChars, null); // Populate the ShowType listbox ClassNames classNames = new ClassNames(_connString); List <ClassNames> lkpClassNames; lkpClassNames = classNames.GetClass_Names(); lstClassNames.DataSource = lkpClassNames; lstClassNames.DataBind(); // Populate the ClassGender ListBox ListItemCollection classGenderList = new ListItemCollection(); ListItem classGenderNS = new ListItem("Please Select...", Constants.CLASS_GENDER_NS.ToString()); classGenderList.Add(classGenderNS); ListItem classGenderDB = new ListItem("Dog & Bitch", Constants.CLASS_GENDER_DB.ToString()); classGenderList.Add(classGenderDB); ListItem classGenderD = new ListItem("Dog", Constants.CLASS_GENDER_D.ToString()); classGenderList.Add(classGenderD); ListItem classGenderB = new ListItem("Bitch", Constants.CLASS_GENDER_B.ToString()); classGenderList.Add(classGenderB); lstClassGender.DataSource = classGenderList; lstClassGender.DataBind(); } }
protected void btnAddDogClass_Click(object sender, EventArgs e) { GetFormFields(); StoreCommon(); if (ValidEntry()) { MembershipUser userInfo = Membership.GetUser(); Guid user_ID = (Guid)userInfo.ProviderUserKey; List<DogClasses> tblDogClasses; DogClasses dogClasses = new DogClasses(); Guid dog_ID = new Guid(Dog_ID); Guid show_Entry_Class_ID = new Guid(Show_Entry_Class_ID); Guid entrant_ID = new Guid(Entrant_ID); tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID); bool rowUpdated = false; bool success = false; foreach (DogClasses row in tblDogClasses) { if (dog_ID == row.Dog_ID && !rowUpdated) { if (row.IsShow_Entry_Class_IDNull || (!row.IsShow_Entry_Class_IDNull && row.Show_Entry_Class_ID == show_Entry_Class_ID)) { Dog_Class_ID = row.Dog_Class_ID.ToString(); Guid dog_Class_ID = new Guid(Dog_Class_ID); DogClasses dogClass = new DogClasses(dog_Class_ID); dogClass.Show_Entry_Class_ID = show_Entry_Class_ID; if (!string.IsNullOrEmpty(Special_Request)) dogClass.Special_Request = Special_Request; if (!string.IsNullOrEmpty(Handler_ID)) { if (GetClassName(show_Entry_Class_ID) != "NFC") { Guid handler_ID = new Guid(Handler_ID); dogClass.Handler_ID = handler_ID; } } dogClass.DeleteDogClass = false; if (dogClass.Update_Dog_Class(dog_Class_ID, user_ID)) { rowUpdated = true; success = true; } } } } if (!rowUpdated) { DogClasses dogClass = new DogClasses(); dogClass.Entrant_ID = entrant_ID; dogClass.Dog_ID = dog_ID; dogClass.Show_Entry_Class_ID = show_Entry_Class_ID; if (!string.IsNullOrEmpty(Special_Request)) dogClass.Special_Request = Special_Request; if (!string.IsNullOrEmpty(Handler_ID)) { if (GetClassName(show_Entry_Class_ID) != "NFC") { Guid handler_ID = new Guid(Handler_ID); dogClass.Handler_ID = handler_ID; } } Guid? dog_Class_ID = new Guid?(); dog_Class_ID = dogClass.Insert_Dog_Class(user_ID); if (dog_Class_ID != null) success = true; } if (success) { ShowEntryClasses showEntryClass = new ShowEntryClasses(show_Entry_Class_ID); int class_Name_ID = Int32.Parse(showEntryClass.Class_Name_ID.ToString()); ClassNames className = new ClassNames(class_Name_ID); string class_Name_Description = className.Description; Dogs dog = new Dogs(dog_ID); MessageLabel.Text = string.Format("{0} was successfully added to {1}.", dog.Dog_KC_Name, class_Name_Description); PopulateDogClassGridView(); ClearFormFields(); } } }
private string GetClassName(Guid show_Entry_Class_ID) { ShowEntryClasses sec = new ShowEntryClasses(show_Entry_Class_ID); ClassNames cn = new ClassNames((int)sec.Class_Name_ID); return cn.Description; }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Common.Show_Entry_Class_ID)) { Show_Entry_Class_ID = Common.Show_Entry_Class_ID; } if (!string.IsNullOrEmpty(Common.Club_ID)) { Club_ID = Common.Club_ID; divGetClub.Visible = false; divClubDetails.Visible = true; } else { divGetClub.Visible = true; divClubDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Show_ID)) { Show_ID = Common.Show_ID; divGetShow.Visible = false; divShowDetails.Visible = true; } else { divGetShow.Visible = true; divShowDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Class_Name_ID)) { Class_Name_ID = Common.Class_Name_ID; lstClassNames.SelectedValue = Class_Name_ID; } if (!string.IsNullOrEmpty(Common.Class_No)) { Class_No = Common.Class_No; txtClassNo.Text = Class_No; } if (string.IsNullOrEmpty(Common.Class_Gender)) { Class_Gender = Common.Class_Gender; lstClassGender.SelectedValue = Class_Gender; } if (!string.IsNullOrEmpty(Club_ID)) PopulateClub(Club_ID); if (!string.IsNullOrEmpty(Show_ID)) { PopulateShow(Show_ID); PopulateClassGridview(Show_ID); } if (!Page.IsPostBack) { string returnChars = Request.QueryString["return"]; btnReturn.PostBackUrl = Common.ReturnPath(Request.QueryString, returnChars, null); // Populate the ShowType listbox ClassNames classNames = new ClassNames(); List<ClassNames> lkpClassNames; lkpClassNames = classNames.GetClass_Names(); lstClassNames.DataSource = lkpClassNames; lstClassNames.DataBind(); // Populate the ClassGender ListBox ListItemCollection classGenderList = new ListItemCollection(); ListItem classGenderNS = new ListItem("Please Select...", Constants.CLASS_GENDER_NS.ToString()); classGenderList.Add(classGenderNS); ListItem classGenderDB = new ListItem("Dog & Bitch", Constants.CLASS_GENDER_DB.ToString()); classGenderList.Add(classGenderDB); ListItem classGenderD = new ListItem("Dog", Constants.CLASS_GENDER_D.ToString()); classGenderList.Add(classGenderD); ListItem classGenderB = new ListItem("Bitch", Constants.CLASS_GENDER_B.ToString()); classGenderList.Add(classGenderB); lstClassGender.DataSource = classGenderList; lstClassGender.DataBind(); } }
private async void LoadCssTimer_TickAsync(object sender, EventArgs e) { if (jsHandler.Click) { // User has clicked on an element in the browser, so handler class is signalling us int X = jsHandler.X; int Y = jsHandler.Y; jsHandler.Click = false; StylesList.Items.Clear(); Debug.Print($"Click at ({jsHandler.X},{jsHandler.Y})"); string S = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y}).length }})();"); string N; string ClassNames; int NumElements = Int32.Parse(S); for (int i = 0; i < NumElements; i++) { // S = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].attributes }})();"); N = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].nodeName }})();"); ClassNames = await browserForm.ExecJSAsync($"(function() {{ return document.elementsFromPoint({X}, {Y})[{i}].className }})();"); bool bFoundOne = false; foreach (string ClassName in ClassNames.Split(' ')) { foreach (StyleSheet SS in browserForm.StyleSheets) { if (!(SS.cssRules is null)) { StyleSheetRule SSR = SS.FindRuleByClass(ClassName); if (!(SSR is null)) { StylesList.Items.Add(SSR); bFoundOne = true; } } } } if (!bFoundOne) { StylesList.Items.Add($"[{i}]<{N}> {ClassNames}"); } // var x = event.clientX, y = event.clientY, // elementMouseIsOver = document.elementsFromPoint(x, y); /* * if (! (browserForm is null)) * { * if (browserForm.unPacked) * { * loadCssTimer.Enabled = false; * listBox1.Items.Clear(); * * foreach(StyleSheet S in browserForm.StyleSheets) * { * if (!(S.cssRules is null)) * { * foreach (StyleSheetRule SSR in S.cssRules) * { * if (!(SSR.selectorText is null)) * listBox1.Items.Add("" + S.index + "," + SSR.index + "," + SSR.selectorText); * } * } * } */ } } }
private void CreateFunction(CommandSchema commandSchema) { Function function; string key = commandSchema.FullName; bool isNew = !Database.Functions.Contains(key); if (isNew) { function = new Function(key); Database.Functions.Add(function); } else { function = Database.Functions[key]; } //Function/@Method is safe to update if (string.IsNullOrEmpty(function.Method)) { string methodName = ToLegalName(commandSchema.Name); if (ClassNames.Contains(methodName)) { methodName += "Procedure"; } function.Method = MakeUnique(FunctionNames, methodName); } function.IsComposable = IsFunction(commandSchema); ParameterSchema returnParameter = null; function.Parameters.Clear(); foreach (ParameterSchema p in commandSchema.Parameters) { if (p.Direction == System.Data.ParameterDirection.ReturnValue) { returnParameter = p; } else { CreateParameter(function, p); } } try { for (int i = 0; i < commandSchema.CommandResults.Count; i++) { var r = commandSchema.CommandResults[i]; string defaultName = function.Method + "Result"; if (commandSchema.CommandResults.Count > 1) { defaultName += (i + 1).ToString(); } CreateResult(function, r, defaultName, i); } } catch (Exception ex) { Debug.WriteLine("Error reading result schema: " + ex.Message); } function.HasMultipleResults = function.Types.Count > 1; function.IsProcessed = true; if (function.Types.Count != 0) { return; } if (function.Return == null) { function.Return = new Return("System.Int32"); } if (commandSchema.ReturnValueParameter != null) { function.Return.Type = GetSystemType(commandSchema.ReturnValueParameter); function.Return.DbType = GetDbType(commandSchema.ReturnValueParameter); } else if (returnParameter != null) { function.Return.Type = GetSystemType(returnParameter); function.Return.DbType = GetDbType(returnParameter); } else { function.Return.Type = "System.Int32"; function.Return.DbType = "int"; } }
private void ReloadData() { if (StopProcessing) { // Do nothing gridDocs.StopProcessing = true; editDoc.StopProcessing = true; } else { if (((AllowUsers == UserContributionAllowUserEnum.Authenticated) || (AllowUsers == UserContributionAllowUserEnum.DocumentOwner)) && !AuthenticationHelper.IsAuthenticated()) { // Not authenticated, do not display anything pnlList.Visible = false; pnlEdit.Visible = false; StopProcessing = true; } else { SetContext(); // Hide document list gridDocs.Visible = false; // If the list of documents should be displayed ... if (DisplayList) { // Get all documents of the current user TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Generate additional where condition string classWhere = null; if (!String.IsNullOrEmpty(ClassNames)) { // Remove ending semicolon classWhere = ClassNames.TrimEnd(';'); // Replace single apostrophs classWhere = SqlHelper.GetSafeQueryString(classWhere, false); // Replace ; with ',' classWhere = classWhere.Replace(";", "','"); if (!String.IsNullOrEmpty(classWhere)) { classWhere = String.Format("ClassName IN ('{0}')", classWhere); } } string where = SqlHelper.AddWhereCondition(WhereCondition, classWhere); // Add user condition if (AllowUsers == UserContributionAllowUserEnum.DocumentOwner) { where = SqlHelper.AddWhereCondition(where, "NodeOwner = " + MembershipContext.AuthenticatedUser.UserID); } // Ensure that required columns are included in "Columns" list string columns = EnsureColumns(); // Get the documents DataSet ds = DocumentHelper.GetDocuments(SiteName, MacroResolver.ResolveCurrentPath(Path), CultureCode, CombineWithDefaultCulture, null, where, OrderBy, MaxRelativeLevel, SelectOnlyPublished, 0, columns, tree); if (CheckPermissions) { ds = TreeSecurityProvider.FilterDataSetByPermissions(ds, NodePermissionsEnum.Read, MembershipContext.AuthenticatedUser); } if (!DataHelper.DataSourceIsEmpty(ds)) { // Display and initialize grid if datasource is not empty gridDocs.Visible = true; gridDocs.DataSource = ds; gridDocs.OrderBy = OrderBy; editDoc.AlternativeFormName = AlternativeFormName; } } bool isAuthorizedToCreateDoc = false; if (ParentNode != null) { // Check if single class name is set string className = (!string.IsNullOrEmpty(AllowedChildClasses) && !AllowedChildClasses.Contains(";")) ? AllowedChildClasses : null; // Check user's permission to create new document if allowed isAuthorizedToCreateDoc = !CheckPermissions || MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(ParentNodeID, className); // Check group's permission to create new document if allowed isAuthorizedToCreateDoc &= CheckGroupPermission("createpages"); if (!CheckDocPermissionsForInsert && CheckPermissions) { // If document permissions are not required check create permission on parent document isAuthorizedToCreateDoc = MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(ParentNode, NodePermissionsEnum.Create) == AuthorizationResultEnum.Allowed; } if (AllowUsers == UserContributionAllowUserEnum.DocumentOwner) { // Do not allow documents creation under virtual user if (MembershipContext.AuthenticatedUser.IsVirtual) { isAuthorizedToCreateDoc = false; } else { // Check if user is document owner (or global admin) isAuthorizedToCreateDoc = isAuthorizedToCreateDoc && ((ParentNode.NodeOwner == MembershipContext.AuthenticatedUser.UserID) || MembershipContext.AuthenticatedUser.IsGlobalAdministrator); } } } // Enable/disable inserting new document pnlNewDoc.Visible = (isAuthorizedToCreateDoc && AllowInsert); if (!gridDocs.Visible && !pnlNewDoc.Visible && pnlList.Visible) { // Not authenticated to create new docs and grid is hidden StopProcessing = true; } ReleaseContext(); } } }
CodeMemberMethod GenerateMethod(HttpMethodInfo method) { MimeParameterCollection parameters = method.MimeParameters != null ? method.MimeParameters : method.UrlParameters; string[] parameterTypeNames = new string[parameters.Count]; string[] parameterNames = new string[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { MimeParameter param = parameters[i]; parameterNames[i] = param.Name; parameterTypeNames[i] = param.TypeName; } CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); CodeExpression[] formatterTypes = new CodeExpression[2]; if (method.MimeReturn.ReaderType == null) { formatterTypes[0] = new CodeTypeOfExpression(typeof(NopReturnReader).FullName); } else { formatterTypes[0] = new CodeTypeOfExpression(method.MimeReturn.ReaderType.FullName); } if (method.MimeParameters != null) { formatterTypes[1] = new CodeTypeOfExpression(method.MimeParameters.WriterType.FullName); } else { formatterTypes[1] = new CodeTypeOfExpression(typeof(UrlParameterWriter).FullName); } WebCodeGenerator.AddCustomAttribute(metadata, typeof(HttpMethodAttribute), formatterTypes, new string[0], new CodeExpression[0]); CodeMemberMethod mainCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, method.Name, new CodeFlags[parameterTypeNames.Length], parameterTypeNames, parameterNames, method.MimeReturn.TypeName, metadata, CodeFlags.IsPublic | (Style == ServiceDescriptionImportStyle.Client ? 0 : CodeFlags.IsAbstract)); AppendMetadata(method.MimeReturn.Attributes, mainCodeMethod.ReturnTypeCustomAttributes); mainCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); for (int i = 0; i < parameters.Count; i++) { AppendMetadata(parameters[i].Attributes, mainCodeMethod.Parameters[i].CustomAttributes); } if (Style == ServiceDescriptionImportStyle.Client) { bool oldAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateOldAsync) != 0; bool newAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateNewAsync) != 0 && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareEvents) && ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareDelegates); CodeExpression[] invokeParams = new CodeExpression[3]; CreateInvokeParams(invokeParams, method, parameterNames); CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "Invoke", invokeParams); if (method.MimeReturn.ReaderType != null) { mainCodeMethod.Statements.Add(new CodeMethodReturnStatement(new CodeCastExpression(method.MimeReturn.TypeName, invoke))); } else { mainCodeMethod.Statements.Add(new CodeExpressionStatement(invoke)); } metadata = new CodeAttributeDeclarationCollection(); string[] asyncParameterTypeNames = new string[parameterTypeNames.Length + 2]; parameterTypeNames.CopyTo(asyncParameterTypeNames, 0); asyncParameterTypeNames[parameterTypeNames.Length] = typeof(AsyncCallback).FullName; asyncParameterTypeNames[parameterTypeNames.Length + 1] = typeof(object).FullName; string[] asyncParameterNames = new string[parameterNames.Length + 2]; parameterNames.CopyTo(asyncParameterNames, 0); asyncParameterNames[parameterNames.Length] = "callback"; asyncParameterNames[parameterNames.Length + 1] = "asyncState"; if (oldAsync) { CodeMemberMethod beginCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, "Begin" + method.Name, new CodeFlags[asyncParameterTypeNames.Length], asyncParameterTypeNames, asyncParameterNames, typeof(IAsyncResult).FullName, metadata, CodeFlags.IsPublic); beginCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); invokeParams = new CodeExpression[5]; CreateInvokeParams(invokeParams, method, parameterNames); invokeParams[3] = new CodeArgumentReferenceExpression("callback"); invokeParams[4] = new CodeArgumentReferenceExpression("asyncState"); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "BeginInvoke", invokeParams); beginCodeMethod.Statements.Add(new CodeMethodReturnStatement(invoke)); CodeMemberMethod endCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, "End" + method.Name, new CodeFlags[1], new string[] { typeof(IAsyncResult).FullName }, new string[] { "asyncResult" }, method.MimeReturn.TypeName, metadata, CodeFlags.IsPublic); endCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); CodeExpression expr = new CodeArgumentReferenceExpression("asyncResult"); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "EndInvoke", new CodeExpression[] { expr }); if (method.MimeReturn.ReaderType != null) { endCodeMethod.Statements.Add(new CodeMethodReturnStatement(new CodeCastExpression(method.MimeReturn.TypeName, invoke))); } else { endCodeMethod.Statements.Add(new CodeExpressionStatement(invoke)); } } if (newAsync) { metadata = new CodeAttributeDeclarationCollection(); string uniqueMethodName = method.Name; string methodKey = MethodSignature(uniqueMethodName, method.MimeReturn.TypeName, new CodeFlags[parameterTypeNames.Length], parameterTypeNames); DelegateInfo delegateInfo = (DelegateInfo)ExportContext[methodKey]; if (delegateInfo == null) { string handlerType = ClassNames.AddUnique(uniqueMethodName + "CompletedEventHandler", uniqueMethodName); string handlerArgs = ClassNames.AddUnique(uniqueMethodName + "CompletedEventArgs", uniqueMethodName); delegateInfo = new DelegateInfo(handlerType, handlerArgs); } string handlerName = MethodNames.AddUnique(uniqueMethodName + "Completed", uniqueMethodName); string asyncName = MethodNames.AddUnique(uniqueMethodName + "Async", uniqueMethodName); string callbackMember = MethodNames.AddUnique(uniqueMethodName + "OperationCompleted", uniqueMethodName); string callbackName = MethodNames.AddUnique("On" + uniqueMethodName + "OperationCompleted", uniqueMethodName); // public event xxxCompletedEventHandler xxxCompleted; WebCodeGenerator.AddEvent(this.CodeTypeDeclaration.Members, delegateInfo.handlerType, handlerName); // private SendOrPostCallback xxxOperationCompleted; WebCodeGenerator.AddCallbackDeclaration(this.CodeTypeDeclaration.Members, callbackMember); // create the pair of xxxAsync methods string userState = UniqueName("userState", parameterNames); CodeMemberMethod asyncCodeMethod = WebCodeGenerator.AddAsyncMethod(this.CodeTypeDeclaration, asyncName, parameterTypeNames, parameterNames, callbackMember, callbackName, userState); // Generate InvokeAsync call invokeParams = new CodeExpression[5]; CreateInvokeParams(invokeParams, method, parameterNames); invokeParams[3] = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), callbackMember); invokeParams[4] = new CodeArgumentReferenceExpression(userState); invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "InvokeAsync", invokeParams); asyncCodeMethod.Statements.Add(invoke); // private void On_xxx_OperationCompleted(object arg) {..} bool methodHasReturn = method.MimeReturn.ReaderType != null; WebCodeGenerator.AddCallbackImplementation(this.CodeTypeDeclaration, callbackName, handlerName, delegateInfo.handlerArgs, methodHasReturn); if (ExportContext[methodKey] == null) { // public delegate void xxxCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs args); WebCodeGenerator.AddDelegate(ExtraCodeClasses, delegateInfo.handlerType, methodHasReturn ? delegateInfo.handlerArgs : typeof(AsyncCompletedEventArgs).FullName); if (methodHasReturn) { ExtraCodeClasses.Add(WebCodeGenerator.CreateArgsClass(delegateInfo.handlerArgs, new string[] { method.MimeReturn.TypeName }, new string[] { "Result" }, ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes))); } ExportContext[methodKey] = delegateInfo; } } } return(mainCodeMethod); }
public override void VisitClassDeclaration(ClassDeclarationSyntax Node) { base.VisitClassDeclaration(Node); ClassNames.Add(Node.Identifier.ToString()); ClassModifers.Add(Node.Modifiers.Select(M => M.ToString()).ToArray()); }