private void C_BtnRevertStyle_Click(object sender, System.EventArgs e) { TreeNode node = this.C_GroupInfoTree.SelectedNode; if (node == null) { return; } if (node.Tag is GroupInfo) { GroupInfo groupInfo = node.Tag as GroupInfo; groupInfo.Style.Revert(); } if (node.Tag is GroupSummary) { GroupSummary summary = node.Tag as GroupSummary; summary.Style.Revert(); } this.C_PropertyGrid.Refresh(); }
private void AddSummary(TreeNode i_ParentNode) { FieldGroupInfo gi = i_ParentNode.Tag as FieldGroupInfo; GroupSummary m_Summary = new GroupSummary(); m_Summary.Field = gi.GroupByField; m_Summary.SummaryType = SummaryTypes.Frequence; TreeNode m_node = this.CreateSummaryNode(m_Summary); bool bFindSubGroup = false; int index = 0; for (; index < i_ParentNode.Nodes.Count; index++) { if (i_ParentNode.Nodes[index].Tag is GroupInfo) { bFindSubGroup = true; break; } } if (bFindSubGroup || index == i_ParentNode.Nodes.Count) { i_ParentNode.Nodes.Insert(index, m_node); } }
public static GroupSummary LookupGroup(Int32 groupKey, out String ErrorMsg) { ErrorMsg = null; try { SqlConnection connection = new SqlConnection($"Data Source=(LocalDB)\\.;AttachDBFileName={DB_FILE};Initial Catalog={DB_NAME};Integrated Security=True;"); connection.Open(); SqlCommand cmd; cmd = new SqlCommand(@"SELECT GroupName FROM dbo.Groups WHERE GroupKey = @groupKey", connection); cmd.Parameters.Add(new SqlParameter("groupKey", groupKey)); SqlDataReader rdr = cmd.ExecuteReader(); GroupSummary result = null; if (rdr.Read()) { result = new GroupSummary(groupKey, rdr.GetString(0)); } rdr.Close(); connection.Close(); return(result); } catch (Exception e) { ErrorMsg = $"Lookup Group Failed. Reason: {e.Message}"; return(null); } }
public void DataValidation() { string fileContent = "Le TP 2/3 consiste à mettre en place un système de partage de fichier inspiré de systèmes comme\r\n" + "Dropbox, GoogleDrive, etc. Le système permettra à différents clients de partager et de\r\n" + "synchroniser des fichiers au sein de groupes définis. Le système est constitué de deux\r\n" + "composantes : un serveur central et un client. Le serveur est accessible à une adresse fixe,\r\n" + "connue de tous les clients. Le serveur a pour rôle de synchroniser, recevoir et transmettre les\r\n" + "fichiers des clients, et gérer les groupes auxquels les clients peuvent se rattacher. Les clients\r\n" + "doivent se synchroniser avec le serveur. Le système à implémenter est donc un système de clientserveur\r\n" + "basé sur le protocole TCP."; string fileAdded = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); GroupSummary oldSummary = new GroupSummary(GROUP1, TESTING_PATH); File.WriteAllText(fileAdded, fileContent); GroupSummary newSummary = new GroupSummary(GROUP1, TESTING_PATH); byte[] extractData = newSummary.GenerateRevisions(oldSummary)[0].Data; //WriteAllText write in UTF8 by default. Assert.AreEqual(Encoding.UTF8.GetBytes(fileContent), extractData); File.Delete(fileAdded); }
private void SetTotalValue() { int lastRow = this.PrintingTable.GetRows() - 1; int lastCol = this.PrintingTable.GetColumns() - 1; this.TotalRows.Add(lastRow); // this.PrintingTable.MergeCells(lastRow,lastRow,0,lastCol); // // WebbTableCell cell = this.PrintingTable.GetCell(lastRow,0) as WebbTableCell; // // if(cell != null) // { // cell.Text = string.Format("{0}: {1}",this._TotalTitle,this.FilteredRows.Count); // } //05-09-2008@Scott int index = 0; bool bFindFirstCol = false; for (int col = 0; col <= lastCol; col++) { if (index > this.TotalSummaries.Count - 1) { break; } if (this.ColumnStyleRows.GroupColumns.Contains(col) || col == 0) { continue; } if (!this.TotalColumns.Contains(col)) { index++; continue; } if (!bFindFirstCol) { int startCol = col > 1 ? col - 2 : col - 1; this.PrintingTable.MergeCells(lastRow, lastRow, startCol, col - 1); this.PrintingTable.GetCell(lastRow, startCol).Text = this.TotalTitle; bFindFirstCol = true; } WebbTableCell cell = this.PrintingTable.GetCell(lastRow, col) as WebbTableCell; GroupSummary summary = this.TotalSummaries[index++]; WebbTableCellHelper.SetCellValue(this.PrintingTable, lastRow, col, summary); } }
private static async Task <List <Asset> > GetAssets(GroupSummary group, string apiBaseUrl, IdServerResourceOwnerClientSettings idServerResourceOwnerClientSettings) { Console.WriteLine("Retrieving Asset list..."); var assetsClient = new AssetsClient(apiBaseUrl, idServerResourceOwnerClientSettings); var assets = await assetsClient.GetAllAsync(group.GroupId); return(assets); }
private static async Task <List <Location> > GetLocationsAsync(GroupSummary group, string apiBaseUrl, IdServerResourceOwnerClientSettings idServerResourceOwnerClientSettings) { Console.WriteLine($"Retrieving Locations for {group.Name}..."); var locationsClient = new LocationsClient(apiBaseUrl, idServerResourceOwnerClientSettings); var locations = await locationsClient.GetAllAsync(group.GroupId); return(locations); }
public override string ToString() { var json = new StringBuilder(); json.Append("groupingView : {"); if (GroupField.IsEmpty()) { throw new ArgumentException("必须为分组设置至少一个列名!"); } json.AppendFormat("groupField:{0},", GroupField.ToJson()); if (!GroupOrder.IsEmpty()) { json.AppendFormat("groupOrder:{0},", GroupOrder.ToJson()); } if (!GroupText.IsEmpty()) { json.AppendFormat("groupText:{0},", GroupText.ToJson()); } if (!GroupColumnShow.IsEmpty()) { json.AppendFormat("groupColumnShow:{0},", GroupColumnShow.ToJson()); } if (!GroupSummary.IsEmpty()) { json.AppendFormat("groupSummary:{0},", GroupSummary.ToJson()); } if (HideFirstGroupCol) { json.Append("groupSummary:true,"); } if (ShowSummaryOnHide) { json.Append("showSummaryOnHide:true,"); } if (!Plusicon.IsEmpty()) { json.AppendFormat("plusicon:'{0}',", Plusicon); } if (!Minusicon.IsEmpty()) { json.AppendFormat("minusicon:'{0}',", Minusicon); } if (!IsInTheSameGroup.IsEmpty()) { json.AppendFormat("isInTheSameGroup:{0},", Regex.Replace(IsInTheSameGroup.ToJson(), "'\"", "")); } if (!FormatDisplayField.IsEmpty()) { json.AppendFormat("formatDisplayField:{0},", Regex.Replace(FormatDisplayField.ToJson(), "'\"", "")); } json.Append("}"); return(json.ToString()); }
public void GenerateRevision() { string fileAdded = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); string fileDeleted = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); string fileModifed = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); string fileModifedPast = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); File.Create(fileDeleted).Close(); File.Create(fileModifed).Close(); File.Create(fileModifedPast).Close(); GroupSummary oldSummary = new GroupSummary(GROUP1, TESTING_PATH); //When we create a file, a stream is created, so we need to close the stream because we are done with it. File.Create(fileAdded).Close(); File.Delete(fileDeleted); File.SetLastWriteTime(fileModifed, DateTime.Now); File.SetLastWriteTime(fileModifedPast, DateTime.Now - new TimeSpan(12, 0, 0, 0)); GroupSummary newSummary = new GroupSummary(GROUP1, TESTING_PATH); List <Revision> result = newSummary.GenerateRevisions(oldSummary); Assert.AreEqual(4, result.Count); //We are suppose to have only one new file. Assert.AreEqual(1, result.Count(revision => revision.Action == Action.Create)); Revision createRevision = result.Find(revision => revision.Action == Action.Create); Assert.AreEqual(Path.GetFileName(fileAdded), createRevision.File.Name); Assert.AreEqual(GROUP1, createRevision.GroupName); //Delete Test Assert.AreEqual(1, result.Count(revision => revision.Action == Action.Delete)); Revision deleteRevision = result.Find(revision => revision.Action == Action.Delete); Assert.AreEqual(Path.GetFileName(fileDeleted), deleteRevision.File.Name); Assert.AreEqual(GROUP1, deleteRevision.GroupName); //Modify test Assert.AreEqual(2, result.Count(revision => revision.Action == Action.Modify)); Revision modifyRevision = result.Find(revision => revision.File.Name == Path.GetFileName(fileModifed)); Assert.AreEqual(Path.GetFileName(fileModifed), modifyRevision.File.Name); Assert.AreEqual(GROUP1, modifyRevision.GroupName); //Modify test past Revision modifyRevisionpast = result.Find(revision => revision.File.Name == Path.GetFileName(fileModifedPast)); Assert.AreEqual(Path.GetFileName(fileModifedPast), modifyRevisionpast.File.Name); Assert.AreEqual(GROUP1, modifyRevisionpast.GroupName); File.Delete(fileAdded); File.Delete(fileModifed); File.Delete(fileModifedPast); }
private TreeNode CreateSummaryNode(GroupSummary summary) { TreeNode node = new TreeNode(summary.ToString()); node.Tag = summary.Copy(); node.ImageIndex = 2; node.SelectedImageIndex = 3; return(node); }
private static GroupSummary GetDefaultSite(GroupSummary organisationGroup) { foreach (var subGroup in organisationGroup.SubGroups) { if (subGroup.Type == GroupType.DefaultSite) { return(subGroup); } } return(null); }
private void checkGroupSummary() { innerChange = true; for (int i = GroupSummary.Count - 1; i >= 0; i--) { if (GroupSummary[i].FieldName == ChooseColumnName) { GroupSummary.RemoveAt(i); } } GroupSummary.Add(this.GroupChooseNeedSummary); innerChange = false; }
public GroupSummary CreateSummary(SummaryTypes type) { GroupSummary summary = new GroupSummary(); summary.Field = this._Field; summary.Filter = this._Filter.Copy(); summary.SummaryType = type; summary.ColumnHeading = this.SeriesName; return(summary); }
public GroupOfTypeResult GetInGroupOfType(int personId, Guid groupTypeGuid) { GroupOfTypeResult result = new GroupOfTypeResult(); result.PersonId = personId; result.PersonInGroup = false; result.GroupList = new List <GroupSummary>(); // get person info Person person = new PersonService((Rock.Data.RockContext)Service.Context).Get(personId); if (person != null) { result.NickName = person.NickName; result.LastName = person.LastName; } // get group type info GroupType groupType = new GroupTypeService((Rock.Data.RockContext)Service.Context).Get(groupTypeGuid); if (groupType != null) { result.GroupTypeName = groupType.Name; result.GroupTypeIconCss = groupType.IconCssClass; result.GroupTypeId = groupType.Id; } // determine if person is in this type of group GroupMemberService groupMemberService = new GroupMemberService((Rock.Data.RockContext)Service.Context); IQueryable <GroupMember> groupMembershipsQuery = groupMemberService.Queryable("Person,GroupRole,Group") .Where(t => t.Group.GroupType.Guid == groupTypeGuid && t.PersonId == personId && t.GroupMemberStatus == GroupMemberStatus.Active && t.Group.IsActive) .OrderBy(g => g.GroupRole.Order); foreach (GroupMember member in groupMembershipsQuery) { result.PersonInGroup = true; GroupSummary group = new GroupSummary(); group.GroupName = member.Group.Name; group.GroupId = member.Group.Id; group.RoleName = member.GroupRole.Name; result.GroupList.Add(group); } return(result); }
public void UpdateValidation() { //tester que les fichiers sont bien ajouter GroupSummary groupSummary = new GroupSummary(GROUP1, TESTING_PATH); Assert.AreEqual(NUMBER_OF_TEST_FILE, groupSummary.Files.Count); string fileAdded = Path.Combine(TESTING_PATH, GROUP1, Path.GetRandomFileName()); File.Create(fileAdded).Close(); groupSummary.Update(); Assert.AreEqual(NUMBER_OF_TEST_FILE + 1, groupSummary.Files.Count); Assert.IsTrue(groupSummary.Files.Exists(info => info.Name == Path.GetFileName(fileAdded))); File.Delete(fileAdded); }
private static void PrintLocationDetails(GroupSummary group, List <Location> locations) { Console.WriteLine($"{locations.Count} locations found for {group.Name}"); Console.WriteLine(string.Empty); Console.WriteLine("Locations"); Console.WriteLine("========="); Console.WriteLine("ID".PadRight(25) + "Name".PadRight(80) + "Type".PadRight(10) + "Shape Type".PadRight(10)); foreach (Location location in locations) { Console.WriteLine(location.LocationId.ToString().PadRight(25) + location.Name.PadRight(80) + location.LocationType.ToString().PadRight(10) + location.ShapeType.ToString().PadRight(10)); } Console.WriteLine(string.Empty); Console.WriteLine(string.Empty); }
protected virtual void InitializeGroupItemCountSummary() { if (SettingsText.GroupItemCountFormat.IsEmpty()) { return; } GroupSummary.Add( new ASPxSummaryItem { FieldName = KeyFieldName, SummaryType = SummaryItemType.Count, DisplayFormat = SettingsText.GroupItemCountFormat, } ); }
/// <summary> /// Generate and push revisions list /// </summary> /// <returns>Revision list of the server.</returns> public List <Revision> UpdateServerHistory() { List <Revision> localRevisions = new List <Revision>(); List <GroupSummary> newGroupSummaries = new List <GroupSummary>(); //Creating the revision list foreach (GroupSummary group in lastGroupsSummaries) { GroupSummary updateSummary = new GroupSummary(group.GroupName, rootFolderPath); localRevisions.AddRange(updateSummary.GenerateRevisions(group)); newGroupSummaries.Add(updateSummary); } lastGroupsSummaries = newGroupSummaries; List <Revision> serverRevisions = access.UpdateServerHistory(userName, localRevisions, lastGroupsSummaries); return(serverRevisions); }
public GroupOfTypeResult GetInGroupOfType(int personId, Guid groupTypeId) { GroupOfTypeResult result = new GroupOfTypeResult(); result.PersonId = personId; result.PersonInGroup = false; result.GroupList = new List<GroupSummary>(); // get person info Person person = new PersonService( (Rock.Data.RockContext)Service.Context ).Get( personId ); if (person != null) { result.NickName = person.NickName; result.LastName = person.LastName; } // get group type info GroupType groupType = new GroupTypeService( (Rock.Data.RockContext)Service.Context ).Get( groupTypeId ); if (groupType != null) { result.GroupTypeName = groupType.Name; result.GroupTypeIconCss = groupType.IconCssClass; result.GroupTypeId = groupType.Id; } // determine if person is in this type of group GroupMemberService groupMemberService = new GroupMemberService( (Rock.Data.RockContext)Service.Context ); IQueryable<GroupMember> groupMembershipsQuery = groupMemberService.Queryable("Person,GroupRole,Group") .Where(t => t.Group.GroupType.Guid == groupTypeId && t.PersonId == personId ) .OrderBy(g => g.GroupRole.Order); foreach (GroupMember member in groupMembershipsQuery) { result.PersonInGroup = true; GroupSummary group = new GroupSummary(); group.GroupName = member.Group.Name; group.GroupId = member.Group.Id; group.RoleName = member.GroupRole.Name; result.GroupList.Add(group); } return result; }
private void AddSummary(TreeNode i_ParentNode, SectionFilter secFilter) { GroupInfo gi = i_ParentNode.Tag as GroupInfo; GroupSummary m_Summary = new GroupSummary(); if (i_ParentNode.Tag is FieldGroupInfo) { m_Summary.Field = (i_ParentNode.Tag as FieldGroupInfo).GroupByField; } else { m_Summary.Field = string.Empty; } m_Summary.SummaryType = SummaryTypes.Frequence; if (secFilter != null) { m_Summary.Filter = secFilter.Filter.Copy(); m_Summary.ColumnHeading = secFilter.FilterName; } TreeNode m_node = this.CreateSummaryNode(m_Summary); bool bFindSubGroup = false; int index = 0; for (; index < i_ParentNode.Nodes.Count; index++) { if (i_ParentNode.Nodes[index].Tag is GroupInfo) { bFindSubGroup = true; break; } } if (bFindSubGroup || index == i_ParentNode.Nodes.Count) { i_ParentNode.Nodes.Insert(index, m_node); } }
private async static Task PrintResults(List <Task <TaskResult> > tasks) { var groups = new Dictionary <string, GroupSummary>(); Console.WriteLine("\rSummary:"); var info = await db.StreamInfoAsync(STREAM_NAME); Console.WriteLine("- {0} consumer groups associated", info.ConsumerGroupCount); Console.WriteLine("- last message: {0} (entryID = {1})", info.LastEntry.Id, (from entry in info.LastEntry.Values where entry.Name.Equals("eventID") select entry.Value).FirstOrDefault() ); var grpsinfo = await db.StreamGroupInfoAsync(STREAM_NAME); foreach (var ginf in grpsinfo) { Console.WriteLine("- Group has {0} consumers and {1} pending messages", ginf.ConsumerCount, ginf.PendingMessageCount); } foreach (var entry in tasks) { var result = entry.Result; Console.WriteLine( "- Process {0} {1} {2} events", result.consumer, result.sender ? "created" : "received", result.events ); // group summary if (!groups.TryGetValue(result.group, out GroupSummary data)) { data = new GroupSummary() { sender = result.sender, consumers = 0, events = 0 }; } data.events += result.events; data.consumers++; groups[result.group] = data; } }
private void Menu_CopySummary_Click(object sender, System.EventArgs e) { TreeNode node = this.C_GroupInfoTree.SelectedNode; if (node == null || !(node.Tag is GroupSummary)) { return; } TreeNode rootNode = this.C_GroupInfoTree.SelectedNode; while (!(rootNode.Tag is GroupInfo)) { rootNode = rootNode.Parent; } GroupSummary newSummary = (node.Tag as GroupSummary).Copy(); newSummary.ColumnHeading = (node.Tag as GroupSummary).ColumnHeading; TreeNode newNode = this.CreateSummaryNode(newSummary); bool bFindSubGroup = false; int index = 0; for (; index < rootNode.Nodes.Count; index++) { if (rootNode.Nodes[index].Tag is GroupInfo) { bFindSubGroup = true; break; } } if (bFindSubGroup || index == rootNode.Nodes.Count) { rootNode.Nodes.Insert(index, newNode); } this.C_GroupInfoTree.SelectedNode = node; this.C_GroupInfoTree.Focus(); }
public GroupWithPurposeResult GetGroupWithPurpose(int personId, Guid definedValueGuid) { GroupWithPurposeResult result = new GroupWithPurposeResult(); result.PersonId = personId; result.PersonInGroup = false; result.GroupList = new List <GroupSummary>(); // get person info Person person = new PersonService((Rock.Data.RockContext)Service.Context).Get(personId); if (person != null) { result.NickName = person.NickName; result.LastName = person.LastName; } var purposeValue = DefinedValueCache.Get(definedValueGuid); result.Purpose = purposeValue.Value; // determine if person is in a group with this purpose GroupMemberService groupMemberService = new GroupMemberService((Rock.Data.RockContext)Service.Context); IQueryable <GroupMember> groupMembershipsQuery = groupMemberService.Queryable("Person,GroupRole,Group") .Where(t => t.Group.GroupType.GroupTypePurposeValueId == purposeValue.Id && t.PersonId == personId && t.GroupMemberStatus == GroupMemberStatus.Active && t.Group.IsActive) .OrderBy(g => g.GroupRole.Order); foreach (GroupMember member in groupMembershipsQuery) { result.PersonInGroup = true; GroupSummary group = new GroupSummary(); group.GroupName = member.Group.Name; group.GroupId = member.Group.Id; group.RoleName = member.GroupRole.Name; result.GroupList.Add(group); } return(result); }
public static List <GroupSummary> LookupUserGroups(Int32 userKey, out String ErrorMsg) { ErrorMsg = null; try { SqlConnection connection = new SqlConnection($"Data Source=(LocalDB)\\.;AttachDBFileName={DB_FILE};Initial Catalog={DB_NAME};Integrated Security=True;"); connection.Open(); SqlCommand cmd; cmd = new SqlCommand(@"SELECT GroupKey FROM dbo.GroupMembership WHERE UserKey = @userKey", connection); cmd.Parameters.Add(new SqlParameter("userKey", userKey)); SqlDataReader rdr = cmd.ExecuteReader(); List <GroupSummary> result = new List <GroupSummary>(); while (rdr.Read()) { GroupSummary gs = LookupGroup(rdr.GetInt32(0), out ErrorMsg); if (ErrorMsg != null) { rdr.Close(); connection.Close(); return(null); } result.Add(gs); } rdr.Close(); connection.Close(); return(result); } catch (Exception e) { ErrorMsg = $"Lookup User Groups Failed. Reason: {e.Message}"; return(null); } }
private void C_GroupInfoTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { // Retrieve the client coordinates of the drop location. Point targetPoint = this.C_GroupInfoTree.PointToClient(new Point(e.X, e.Y)); // Retrieve the node at the drop location. TreeNode targetNode = this.C_GroupInfoTree.GetNodeAt(targetPoint); // Retrieve the node that was dragged. TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); // Confirm that the node at the drop location is not // the dragged node or a descendant of the dragged node. if (!draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode) && CheckNode(draggedNode, targetNode)) { // If it is a move operation, remove the node from its current // location and add it to the node at the drop location. if (e.Effect == DragDropEffects.Move) { draggedNode.Remove(); this.AddNode(draggedNode, targetNode); } // If it is a copy operation, clone the dragged node // and add it to the node at the drop location. else if (e.Effect == DragDropEffects.Copy && draggedNode.Tag is GroupSummary) { GroupSummary summary = (draggedNode.Tag as GroupSummary).Copy(); TreeNode node = this.CreateSummaryNode(summary); this.AddNode(node, targetNode); } // Expand the node at the location // to show the dropped node. targetNode.Expand(); } }
public void ConstructorTest() { List <string> files = new List <string> { Path.Combine(TESTING_PATH, GROUP2, "file1.jp"), Path.Combine(TESTING_PATH, GROUP2, "file2.jp"), Path.Combine(TESTING_PATH, GROUP2, "file3.jp") }; foreach (string file in files) { File.Create(file).Close(); } List <DateTime> filesCreations = new List <DateTime> { new DateTime(2021, 9, 12, 17, 12, 4), new DateTime(2000, 1, 1, 0, 0, 0), new DateTime(2017, 7, 12, 12, 15, 4) }; List <DateTime> filesModifications = new List <DateTime> { new DateTime(2021, 9, 12, 17, 12, 4), new DateTime(2001, 1, 1, 0, 0, 0), new DateTime(2017, 7, 12, 12, 15, 5) }; for (int i = 0; i < files.Count; i++) { File.SetCreationTime(files[i], filesCreations[i]); File.SetLastWriteTime(files[i], filesModifications[i]); } GroupSummary group2Summary = new GroupSummary(GROUP2, TESTING_PATH); Assert.AreEqual(GROUP2, group2Summary.GroupName); Assert.AreEqual(3, group2Summary.Files.Count); for (int i = 0; i < group2Summary.Files.Count; i++) { Assert.AreEqual($"file{i + 1}.jp", group2Summary.Files[i].Name); Assert.AreEqual(filesCreations[i], group2Summary.Files[i].CreationDate); Assert.AreEqual(filesModifications[i], group2Summary.Files[i].LastModificationDate); } files.ForEach(File.Delete); }
public HorizonGroupView(SerializationInfo info, StreamingContext context) : base(info, context) { try { _RootGroupInfo = (Webb.Reports.ExControls.Data.GroupInfo)info.GetValue("_RootGroupInfo", typeof(Webb.Reports.ExControls.Data.GroupInfo)); } catch { } try { _Fitler = (Webb.Data.DBFilter)info.GetValue("_Fitler", typeof(Webb.Data.DBFilter)); } catch { } try { _ShowRowIndicators = info.GetBoolean("_ShowRowIndicators"); } catch { _ShowRowIndicators = false; } try { _HaveHeader = info.GetBoolean("_HaveHeader"); } catch { _HaveHeader = true; } try { _ColumnsWidth = (Webb.Collections.Int32Collection)info.GetValue("_ColumnsWidth", typeof(Webb.Collections.Int32Collection)); } catch { } try { _RowsHight = (Webb.Collections.Int32Collection)info.GetValue("_RowsHight", typeof(Webb.Collections.Int32Collection)); } catch { } try { _Total = info.GetBoolean("_Total"); } catch { _Total = true; } try { _HorizonTopCount = info.GetInt32("_HorizonTopCount"); } catch { _HorizonTopCount = 0; } try { _TotalOthers = info.GetBoolean("_TotalOthers"); } catch { _TotalOthers = false; } try { _TotalOthersName = info.GetString("_TotalOthersName"); } catch { _TotalOthersName = "Others"; } try { _TotalStyle = (Webb.Reports.ExControls.BasicStyle)info.GetValue("_TotalStyle", typeof(Webb.Reports.ExControls.BasicStyle)); } catch { _TotalStyle = new BasicStyle(); } try { _HeaderRows = (Webb.Collections.Int32Collection)info.GetValue("_HeaderRows", typeof(Webb.Collections.Int32Collection)); } catch { _HeaderRows = new Int32Collection(); } try { TableHeaders = (Webb.Reports.ExControls.Data.HeadersData)info.GetValue("TableHeaders", typeof(Webb.Reports.ExControls.Data.HeadersData)); } catch { TableHeaders = null; } try { _TotalPosition = (Webb.Data.TotalType)info.GetValue("_TotalPosition", typeof(Webb.Data.TotalType)); } catch { if (_RootGroupInfo != null && _RootGroupInfo.AddTotal) { _TotalPosition = TotalType.AllBefore; _RootGroupInfo.AddTotal = false; } else { _TotalPosition = TotalType.None; } if (RootGroupInfo != null) { if (RootGroupInfo.SubGroupInfos.Count > 0 && RootGroupInfo.Summaries != null) { RootGroupInfo.SubGroupInfos[0].Summaries = RootGroupInfo.Summaries.CopyStructure(); } RootGroupInfo.Summaries = new GroupSummaryCollection(); if (this.Total) { GroupSummary groupSummary = new GroupSummary(); groupSummary.ColorNeedChange = true; groupSummary.Style.SetStyle(this.TotalStyle); groupSummary.ShowZeros = true; RootGroupInfo.Summaries.Add(groupSummary); } } } try { _TotalOthersPosition = (Webb.Data.TotalType)info.GetValue("_TotalOthersPosition", typeof(Webb.Data.TotalType)); } catch { if (this._TotalOthers) { _TotalOthersPosition = TotalType.AllAfter; } else { _TotalOthersPosition = TotalType.None; } } try { _SummaryForTotalGroup = (Webb.Reports.ExControls.Data.GroupSummary)info.GetValue("_SummaryForTotalGroup", typeof(Webb.Reports.ExControls.Data.GroupSummary)); } catch { _SummaryForTotalGroup = new GroupSummary(); } try { _SummaryForOthers = (Webb.Reports.ExControls.Data.GroupSummary)info.GetValue("_SummaryForOthers", typeof(Webb.Reports.ExControls.Data.GroupSummary)); } catch { _SummaryForOthers = new GroupSummary(); } }
public void AddTotalAndOthers(System.Data.DataTable i_Table, Int32Collection outerRows, Int32Collection innerRows) { if (this.RootGroupInfo == null) { return; } GroupResultCollection m_newResults = new GroupResultCollection(); GroupResult m_TotalGroupResult = new GroupResult(); m_TotalGroupResult.Summaries = new GroupSummaryCollection(); GroupResult m_OtherGroupResult = new GroupResult(); m_OtherGroupResult.Summaries = new GroupSummaryCollection(); if (this.TotalPosition != TotalType.None) { #region Caclculate Result for Total m_TotalGroupResult.GroupValue = this.RootGroupInfo.TotalTitle; m_TotalGroupResult.RowIndicators = new Int32Collection(); m_TotalGroupResult.ParentGroupInfo = this.RootGroupInfo; //Add at 2009-2-19 14:23:47@Simon innerRows.CopyTo(m_TotalGroupResult.RowIndicators); if (this.RootGroupInfo.Summaries.Count > 0) { GroupSummary summaryTotal = this.SummaryForTotalGroup.Copy(); m_TotalGroupResult.Summaries.Add(summaryTotal); m_TotalGroupResult.CalculateSummaryResult(i_Table, innerRows, innerRows); } m_TotalGroupResult.SubGroupInfos = RootGroupInfo.SubGroupInfos.Copy(); foreach (GroupInfo subGroupInfo in m_TotalGroupResult.SubGroupInfos) { subGroupInfo.CalculateGroupResult(i_Table, outerRows, outerRows, innerRows, subGroupInfo); } #endregion } if (this.TotalPosition == TotalType.AllBefore) { m_newResults.Add(m_TotalGroupResult); } if (this.TotalOthersPosition == TotalType.AllBefore) { m_newResults.Add(m_OtherGroupResult); } Int32Collection m_OtherRowsTotal = new Int32Collection(); for (int i = 0; i < this.RootGroupInfo.GroupResults.Count; i++) { if (i >= this.HorizonTopCount && HorizonTopCount > 0) { m_OtherRowsTotal = m_OtherRowsTotal.Combine(this.RootGroupInfo.GroupResults[i].RowIndicators, m_OtherRowsTotal); } else { m_newResults.Add(this.RootGroupInfo.GroupResults[i]); } } if (this.TotalOthersPosition != TotalType.None) { #region calculate Other results m_OtherGroupResult.GroupValue = this.TotalOthersName; m_OtherGroupResult.RowIndicators = new Int32Collection(); m_OtherGroupResult.ParentGroupInfo = this.RootGroupInfo; //Add at 2009-2-19 14:23:47@Simon m_OtherRowsTotal.CopyTo(m_OtherGroupResult.RowIndicators); if (this.RootGroupInfo.Summaries.Count > 0) { GroupSummary summaryTotal = this.SummaryForOthers.Copy(); m_OtherGroupResult.Summaries.Add(summaryTotal); m_OtherGroupResult.CalculateSummaryResult(i_Table, outerRows, m_OtherRowsTotal); } m_OtherGroupResult.SubGroupInfos = this.RootGroupInfo.SubGroupInfos.Copy(); foreach (GroupInfo subGroupInfo in m_OtherGroupResult.SubGroupInfos) { subGroupInfo.CalculateGroupResult(i_Table, m_OtherRowsTotal, outerRows, m_OtherRowsTotal, subGroupInfo); } #endregion } if (this.TotalOthersPosition == TotalType.AllAfter) { m_newResults.Add(m_OtherGroupResult); } if (this.TotalPosition == TotalType.AllAfter) { m_newResults.Add(m_TotalGroupResult); } this.RootGroupInfo.ResetGroupResults(m_newResults); }
private void SetTableValue() { int m_Rows = 0, m_Col = 0; if (this.ShowRowIndicators) { m_Col = 1; //add row indicator columns } int nHeaderStart = m_Rows, nHeaderCount = 0; this.SetHeaderValue(ref m_Rows); //set header value nHeaderCount = m_Rows - nHeaderStart; this.SetHeaderRows(nHeaderStart, nHeaderCount); #region Set style int setRow = m_Rows; if (this.RootGroupInfo.Summaries.Count > 0) { this.PrintingTable.SetRowStyle(setRow, this.RootGroupInfo.Summaries[0].Style, this.ShowRowIndicators); setRow++; } if (RootGroupInfo.SubGroupInfos.Count > 0) { GroupInfo subGroupInfo = RootGroupInfo.SubGroupInfos[0]; foreach (GroupSummary m_Summary in subGroupInfo.Summaries) { this.PrintingTable.SetRowStyle(setRow, m_Summary.Style, this.ShowRowIndicators); setRow++; } } #endregion #region Set Rows Value int mergedspan = this.GetMergedSpan(); for (int i = 0; i < this.RootGroupInfo.GroupResults.Count; i++) { int tempRow = m_Rows; GroupResult m_Result = RootGroupInfo.GroupResults[i]; IWebbTableCell cell = null; if (m_Result.Summaries.Count > 0) { GroupSummary m_Summary = m_Result.Summaries[0]; if (RootGroupInfo.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, tempRow, m_Col, m_Summary); } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, tempRow, m_Col, m_Summary); } this.PrintingTable.MergeCells(tempRow, tempRow, m_Col, m_Col + mergedspan - 1); cell = this.PrintingTable.GetCell(tempRow, m_Col); if (cell == null) { continue; } if (tempRow < this.PrintingTable.GetRows() - 1 && cell != null) { cell.CellStyle.Sides &= ~DevExpress.XtraPrinting.BorderSide.Bottom; } tempRow++; } #region Sub GroupInfo if (this.RootGroupInfo.SubGroupInfos.Count > 0) { GroupInfo subGroupInfo = RootGroupInfo.GroupResults[i].SubGroupInfos[0]; for (int j = 0; j < subGroupInfo.GroupResults.Count; j++, m_Col++) { GroupResult m_subResult = subGroupInfo.GroupResults[j]; int nextRow = tempRow; for (int k = 0; k < m_subResult.Summaries.Count; k++) { GroupSummary m_Summary = m_subResult.Summaries[k]; WebbTableCellHelper.SetCellValue(this.PrintingTable, nextRow, m_Col, m_Summary); cell = this.PrintingTable.GetCell(nextRow, m_Col); if (cell == null) { continue; } cell.CellStyle.Sides = DevExpress.XtraPrinting.BorderSide.None; if (cell != null) { if (nextRow == 0) { cell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Top; } if (k == m_subResult.Summaries.Count - 1) { cell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Bottom; } if (j == 0) { cell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Left; } if (j == subGroupInfo.GroupResults.Count - 1) { cell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Right; } } nextRow++; } } } else { m_Col++; } #endregion } #endregion if (this.ShowRowIndicators) { this.SetRowIndicators(this.PrintingTable.GetRows()); } }
public void Execute() { // Blocking call foreach (Job job in syncJobs.GetConsumingEnumerable()) { Console.WriteLine(@"Execute Job {0}", ++executionCount); List <Revision> returnRevisions = new List <Revision>(); // For each client group revision foreach (GroupSummary clientGroupSummary in job.GroupSummaries) { // Check user authorizations if (dataStore.CheckUserInGroup(job.Username, clientGroupSummary.GroupName)) { // Get the server GroupSummary equal to client GroupSummary GroupSummary serverGroupSummary = serverGroupSummaries.Find(s => s.GroupName == clientGroupSummary.GroupName); if (serverGroupSummary != null) { // Build revision list with client List <Revision> revisions = serverGroupSummary.GenerateRevisions(clientGroupSummary); foreach (Revision rev in revisions) { ShareLibrary.Models.FileInfo currentServerFile = serverGroupSummary.Files.Find(f => f.Name == rev.File.Name); ShareLibrary.Models.FileInfo currentClientFile = clientGroupSummary.Files.Find(f => f.Name == rev.File.Name); Revision currentRelatedjobRevision = job.Revisions.Find(r => r.File?.Name == currentClientFile?.Name); switch (rev.Action) { case Action.Create: // Rebind the currentRelatedjobRevision from the server instead of the client currentRelatedjobRevision = job.Revisions.Find(r => r.File?.Name == currentServerFile?.Name); // Case 1 : The file was deleted by the current client // Update server history (delete the current file) if (currentRelatedjobRevision?.File.Name == rev.File.Name && currentRelatedjobRevision?.Action == Action.Delete) { currentRelatedjobRevision.Apply(rootPath); serverGroupSummary.Update(); } // Case 2 : There is a new file on the server and the current client doesn't have it. // Add revision to response with data (Create) else { returnRevisions.Add(rev); } break; case Action.Modify: rev.Data = currentRelatedjobRevision?.Data ?? rev.Data; // Case 1 : Server modification date > client modification date // Add revision to response with data (Modify) if (currentServerFile.LastModificationDate > currentClientFile.LastModificationDate) { returnRevisions.Add(rev); } // Case 2 : Server modification date < client modification date // Update server history (replace the current file) else { rev.Apply(rootPath); serverGroupSummary.Update(); } break; case Action.Delete: // Case 1 : The file was created by the current client. // Update server history (add the current file) if (currentRelatedjobRevision?.Action == Action.Create) { currentRelatedjobRevision.Apply(rootPath); serverGroupSummary.Update(); } // Case 2 : The file is deleted for real (deleted from an other client) // Add revision to response (Delete) else { rev.Data = new byte[0]; returnRevisions.Add(rev); } break; } } } else { // Initial case when the server does not have the client group synced // Add the client files (revisions) to the server files List <Revision> clientRevisions = job.Revisions.FindAll(r => r.GroupName == clientGroupSummary.GroupName); // Create the group directory Directory.CreateDirectory(Path.Combine(rootPath, clientGroupSummary.GroupName)); // Add every client file to the server foreach (Revision clientRev in clientRevisions) { clientRev.Apply(rootPath); } // Create the server group summary because he didn't exist serverGroupSummaries.Add(new GroupSummary(clientGroupSummary.GroupName, rootPath)); } } } // Return the truth job.CallBack(returnRevisions); } }
public GroupWithPurposeResult GetGroupWithPurpose( int personId, Guid definedValueGuid ) { GroupWithPurposeResult result = new GroupWithPurposeResult(); result.PersonId = personId; result.PersonInGroup = false; result.GroupList = new List<GroupSummary>(); // get person info Person person = new PersonService( ( Rock.Data.RockContext ) Service.Context ).Get( personId ); if ( person != null ) { result.NickName = person.NickName; result.LastName = person.LastName; } var purposeValue = DefinedValueCache.Read( definedValueGuid ); result.Purpose = purposeValue.Value; // determine if person is in a group with this purpose GroupMemberService groupMemberService = new GroupMemberService( ( Rock.Data.RockContext ) Service.Context ); IQueryable<GroupMember> groupMembershipsQuery = groupMemberService.Queryable( "Person,GroupRole,Group" ) .Where( t => t.Group.GroupType.GroupTypePurposeValueId == purposeValue.Id && t.PersonId == personId && t.GroupMemberStatus == GroupMemberStatus.Active && t.Group.IsActive ) .OrderBy( g => g.GroupRole.Order ); foreach ( GroupMember member in groupMembershipsQuery ) { result.PersonInGroup = true; GroupSummary group = new GroupSummary(); group.GroupName = member.Group.Name; group.GroupId = member.Group.Id; group.RoleName = member.GroupRole.Name; result.GroupList.Add( group ); } return result; }
private void SetRowsValue(ref int i_Row, ref int i_Col, GroupInfo i_GroupInfo) { int m_OriginalStartCol = i_Col; int m_OriginalStartRow = i_Row; int m_Rows = i_GroupInfo.GetGroupedRows(); if (i_GroupInfo.GroupResults != null) {//if not section group , sort group result if (!(i_GroupInfo is SectionGroupInfo)) { i_GroupInfo.GroupResults.Sort(i_GroupInfo.Sorting, i_GroupInfo.SortingBy, i_GroupInfo.UserDefinedOrders); } } bool visible = GroupInfo.IsVisible(i_GroupInfo); for (int m_row = 0; m_row < m_Rows; m_row++) { GroupResult m_GroupResult = i_GroupInfo.GroupResults[m_row]; if (i_GroupInfo == this.RootGroupInfo && i_GroupInfo.IsSectionOutSide) { //Set grouped value #region set grouped value StringBuilder sbGroup = new StringBuilder(); sbGroup.Append(m_GroupResult.GroupValue); foreach (GroupSummary summary in m_GroupResult.Summaries) { string summaryValue = WebbTableCellHelper.FormatValue(null, summary); sbGroup.Append(summaryValue); } if (m_GroupResult.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, sbGroup.ToString(), FormatTypes.String, m_GroupResult.RowIndicators); } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, sbGroup.ToString(), FormatTypes.String); } #endregion #region Merge cell for section row this.PrintingTable.MergeCells(i_Row, i_Row, i_Col, this.PrintingTable.GetColumns() - 1); this.SectionRows.Add(i_Row); i_Row++; #endregion #region Set sub rows if (m_GroupResult.SubGroupInfos.Count > 0) { int m_StartRow = i_Row; int maxRow = 0; foreach (GroupInfo groupInfo in m_GroupResult.SubGroupInfos) { this.SetRowsValue(ref i_Row, ref i_Col, groupInfo); maxRow = Math.Max(maxRow, i_Row); i_Row = m_StartRow; } i_Row = maxRow - 1; } i_Row++; if (m_row < m_Rows - 1) { i_Col = m_OriginalStartCol; } #endregion } else { #region set summaryies ----Summaries before group if (i_GroupInfo.FollowSummaries && m_GroupResult.Summaries != null) { foreach (GroupSummary m_Summary in m_GroupResult.Summaries) { //if group have click event , summaries also need. if (m_GroupResult.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, m_Summary); //03-10-2008@Scott } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, m_Summary); } i_Col++; } } #endregion //Set grouped value #region set grouped value if (visible) { #region New string groupValue = string.Empty; if (m_GroupResult.GroupValue != null) { groupValue = m_GroupResult.GroupValue.ToString(); if (i_GroupInfo is FieldGroupInfo) { string followWith = (i_GroupInfo as FieldGroupInfo).FollowsWith; if (followWith != string.Empty && followWith.IndexOf("[VALUE]") >= 0) { groupValue = followWith.Replace("[VALUE]", groupValue); } } } if (m_GroupResult.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, groupValue, FormatTypes.String, m_GroupResult.RowIndicators); } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, groupValue, FormatTypes.String); } #endregion i_Col++; } #endregion #region set summaryies ----Summaries after group if (!i_GroupInfo.FollowSummaries) { if (m_GroupResult.Summaries != null) { foreach (GroupSummary m_Summary in m_GroupResult.Summaries) { //if group have click event , summaries also need. if (m_GroupResult.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, m_Summary); //03-10-2008@Scott } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, m_Summary); } i_Col++; } } } #endregion #region Set sub rows if (m_GroupResult.SubGroupInfos.Count > 0) { int m_StartRow = i_Row; int maxRow = 0; foreach (GroupInfo groupInfo in m_GroupResult.SubGroupInfos) { this.SetRowsValue(ref i_Row, ref i_Col, groupInfo); maxRow = Math.Max(maxRow, i_Row); i_Row = m_StartRow; } i_Row = maxRow - 1; } i_Row++; if (m_row < m_Rows - 1) { i_Col = m_OriginalStartCol; } #endregion } } #region Set total row if (i_GroupInfo.AddTotal && i_GroupInfo.TotalSummaries != null) { i_Col = m_OriginalStartCol; if (i_GroupInfo.IsSectionOutSide) { #region RootGroup Info & In IsSectionRow StringBuilder sbSummaryValue = new StringBuilder(); sbSummaryValue.Append(i_GroupInfo.TotalTitle); for (int i = 0; i < i_GroupInfo.Summaries.Count; i++) { if (i >= i_GroupInfo.TotalSummaries.Count) { continue; } GroupSummary summary = i_GroupInfo.TotalSummaries[i]; string summaryValue = WebbTableCellHelper.FormatValue(null, summary); sbSummaryValue.Append(summaryValue); } if (i_GroupInfo.ClickEvent == ClickEvents.PlayVideo) { Int32Collection totalIndicators = (i_GroupInfo as FieldGroupInfo).GetTotalIndicators(i_GroupInfo); WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, sbSummaryValue.ToString(), FormatTypes.String, totalIndicators); } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, sbSummaryValue.ToString(), FormatTypes.String); } #endregion this.PrintingTable.MergeCells(i_Row, i_Row, i_Col, this.PrintingTable.GetColumns() - 1); } else { #region Not IsSectionOutSide if (i_GroupInfo.FollowSummaries) { i_Col--; } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, i_GroupInfo.TotalTitle, FormatTypes.String); } foreach (GroupSummary m_TotalSummary in i_GroupInfo.TotalSummaries) { i_Col++; while (this._GroupColumns.Contains(i_Col)) { i_Col++; } //05-08-2008@Scott switch (m_TotalSummary.SummaryType) { case SummaryTypes.RelatedPercent: case SummaryTypes.GroupPercent: if (m_TotalSummary.Filter.Count == 0) { continue; } break; case SummaryTypes.FreqAndPercent: case SummaryTypes.FreqAndRelatedPercent: continue; default: break; } if (i_GroupInfo.ClickEvent == ClickEvents.PlayVideo) { WebbTableCellHelper.SetCellValueWithClickEvent(this.PrintingTable, i_Row, i_Col, m_TotalSummary); } else { WebbTableCellHelper.SetCellValue(this.PrintingTable, i_Row, i_Col, m_TotalSummary); } } #endregion } this.TotalRows.Add(i_Row); i_Row++; } #endregion }