/// <summary> /// Parses the response received from the server. /// </summary> protected override void UnpackResponse() { base.UnpackResponse(); // Create the streams we will be reading from. MemoryStream responseStream = new MemoryStream(m_responsePayload); BinaryReader responseReader = new BinaryReader(responseStream, Encoding.Unicode); // Seek past return code. responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin); ushort groupCount = 0, reportCount = 0, tempLength = 0, parameterCount = 0; int tempID = 0, tempTypeID = 0; string tempName = string.Empty; UserReportType tempType; UserReportGroup tempGroup; ReportInfo tempReport; ushort typeCount = responseReader.ReadUInt16(); for (int iType = 0; iType < typeCount; iType++) { tempID = responseReader.ReadInt32(); tempLength = responseReader.ReadUInt16(); tempName = new string(responseReader.ReadChars(tempLength)); tempType = new UserReportType(tempID, tempName); groupCount = responseReader.ReadUInt16(); for (int iGroup = 0; iGroup < groupCount; iGroup++) { tempID = responseReader.ReadInt32(); tempLength = responseReader.ReadUInt16(); tempName = new string(responseReader.ReadChars(tempLength)); tempGroup = new UserReportGroup(tempID, tempName); reportCount = responseReader.ReadUInt16(); for (int iReport = 0; iReport < reportCount; iReport++) { tempID = responseReader.ReadInt32(); tempTypeID = responseReader.ReadInt32(); tempLength = responseReader.ReadUInt16(); tempName = new string(responseReader.ReadChars(tempLength)); tempReport = new ReportInfo(tempID, tempTypeID, tempName); parameterCount = responseReader.ReadUInt16(); for (int iParameter = 0; iParameter < parameterCount; iParameter++) { tempID = responseReader.ReadInt32(); tempLength = responseReader.ReadUInt16(); tempName = new string(responseReader.ReadChars(tempLength)); tempReport.Parameters.Add(tempID, tempName); } tempGroup.ReportsArray.Add(tempReport); } tempType.UserReportGroups.Add(tempGroup.UserGroupID, tempGroup); } mReportTypes.Add(tempType.UserReportTypeID, tempType); } // Close the streams. responseReader.Close(); }
private void SaveTree() { foreach (UserReportTypeTreeNode typeNode in customReportTreeView.Nodes) { int typeId = typeNode.ReportType.UserReportTypeID; UserReportType reportType; m_userReportDictionary.TryGetValue(typeId, out reportType); if (reportType == null) { reportType = new UserReportType(m_tmpTypeId, typeNode.ReportType.UserReportTypeName); m_userReportDictionary.Add(m_tmpTypeId, reportType); m_tmpTypeId--; } foreach (UserReportGroupTreeNode groupNode in typeNode.Nodes) { int groupId = groupNode.ReportGroup.UserGroupID; UserReportGroup group; reportType.UserReportGroups.TryGetValue(groupId, out group); if (group == null) { group = new UserReportGroup(m_tmpGroupId, groupNode.ReportGroup.UserGroupName); reportType.UserReportGroups.Add(m_tmpGroupId, group); m_tmpGroupId--; } foreach (ReportSetTreeNode setNode in groupNode.Nodes) { foreach (ReportTreeNode reportNode in setNode.Nodes) { if (reportNode.IsNewNode) { group.ReportsArray.Add(reportNode.ReportInfo); } } } } } }
private static ReportGroupAccessLevelType GetAccessLevel( string userID, string reportGroupPathName, IEnumerable <ReportGroup> reportGroupsList) { ReportGroupAccessLevelType MyAccessLevel = ReportGroupAccessLevelType.None; // To obtain the UserReportGroup, we need the UserCode and ReportGroupCode ReportGroup CurrentReportGroup = reportGroupsList.First(x => x.PathName == reportGroupPathName); //MCUser ThisUser = mcUserRepository.Find(x => x.Name == userID).First(); UserReportGroup CurrentUserReportGroup = CurrentReportGroup.UserReportGroups.FirstOrDefault(); // userReportGroupRepository.Find(x => x.ReportGroupCode == CurrentReportGroup.Code && x.UserCode == ThisUser.Code).FirstOrDefault(); /* In getting the access level, we try firstly to obtain it from the * specified report group. If it has none, we must then check the parent * of this report group for its access level. If the parent has an access * level, we return that, otherwise we check this folder's parent. We * continue like this, until a level is found or the top of the tree * is reached without finding one. */ // This denotes whether the top of the tree has been reached in event of searching. bool IsTreeTop = false; // This denotes if a UserReportGroup for the ReportGroup has been found. bool IsFound = false; while (!IsTreeTop && !IsFound) { // If a UserReportGroup is found, we can stop searching. if (CurrentUserReportGroup != null) { MyAccessLevel = (ReportGroupAccessLevelType)CurrentUserReportGroup.AccessLevel; IsFound = true; } else { // We must look to its parent for an access level. if (CurrentReportGroup.ParentPath != null) { string ParentPath = CurrentReportGroup.ParentPath; CurrentReportGroup = reportGroupsList.FirstOrDefault(x => x.PathName == ParentPath); if (CurrentReportGroup == null) { IsTreeTop = true; } else { CurrentUserReportGroup = CurrentReportGroup.UserReportGroups.FirstOrDefault(); //userReportGroupRepoitory.Find(x => x.ReportGroupCode == CurrentReportGroup.Code && x.UserCode == ThisUser.Code).FirstOrDefault(); } } else // The child is a root folder, so has no parent. { // Hence, we must stop searching. IsTreeTop = true; } } } return(MyAccessLevel); }
public static UserReportGroup WithUser(this UserReportGroup userReportGroup, MCUser user) { userReportGroup.User = user; return(userReportGroup); }
public static UserReportGroup WithReportGroup(this UserReportGroup userReportGroup, ReportGroup reportGroup) { userReportGroup.ReportGroup = reportGroup; return(userReportGroup); }
public static UserReportGroup WithAccessLevel(this UserReportGroup userReportGroup, Int32 accessLevel) { userReportGroup.AccessLevel = accessLevel; return(userReportGroup); }
public static UserReportGroup WithReportGroupCode(this UserReportGroup userReportGroup, Guid reportGroupCode) { userReportGroup.ReportGroupCode = reportGroupCode; return(userReportGroup); }
public static UserReportGroup WithUserCode(this UserReportGroup userReportGroup, Guid userCode) { userReportGroup.UserCode = userCode; return(userReportGroup); }
public static UserReportGroup WithCode(this UserReportGroup userReportGroup, Guid code) { userReportGroup.Code = code; return(userReportGroup); }