/// <summary> /// Fetches the navigation items. /// </summary> /// <param name="groupId">The group identifier.</param> /// <returns>IEnumerable{NavigationItemDTO}.</returns> public IEnumerable<NavigationItemDTO> FetchNavigationItems(int? groupId = null) { const string Sql = @" SELECT ni.[Id] , p.[Name] , ni.NavigationGroupId FROM NavigationItems ni INNER JOIN PublishedProcesses pp ON ni.PublishedProcessId = pp.Id INNER JOIN Processes p ON pp.[ProcessId] = p.[Id] AND p.IsInactive = 0 WHERE ni.NavigationGroupId = COALESCE(@groupId, NavigationGroupId) "; var result = new List<NavigationItemDTO>(); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; if (cn.State != ConnectionState.Open) { cn.Open(); } using (var cmd = new SqlCommand(Sql, cn)) { cmd.Parameters.AddWithValue("@groupId", groupId); using (var reader = new SafeDataReader(cmd.ExecuteReader())) { while (reader.Read()) { result.Add(new NavigationItemDTO { Id = reader.GetInt32(0), Name = reader.GetString(1), ProcessId = reader.GetNullableInt(2) }); } } } } return result; }
/// <summary> /// Retrieves reverse cross ref required step. /// </summary> /// <param name="processName">The process name.</param> /// <param name="fieldName">The field name.</param> /// <param name="isPublishedCopy">The is published copy.</param> /// <returns>The <see cref="ReverseCrossRefRequiredStepDto" />.</returns> public ReverseCrossRefRequiredStepDto FetchReverseCrossRefRequiredStep(string processName, string fieldName, bool isPublishedCopy = false) { const string CmdText = @" DECLARE @fieldId AS INT SELECT @fieldId = f.Id FROM [dbo].[Processes] p INNER JOIN [dbo].[Sections] s ON s.ProcessId = p.Id INNER JOIN [dbo].[Fields] f ON f.SectionId = s.Id WHERE p.[SystemName] = @processName AND p.IsRemoved = 0 AND p.IsPublishedCopy = @isPublishedCopy AND f.SystemName = @fieldName; EXEC [dbo].[GetReverseCrossRefRequiredStep] @FieldId = @fieldId; "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { using (var cmd = new SqlCommand(CmdText, ctx.Connection)) { cmd.Parameters.AddWithValue("@processName", processName); cmd.Parameters.AddWithValue("@fieldName", fieldName); cmd.Parameters.AddWithValue("@isPublishedCopy", isPublishedCopy); using (var reader = new SafeDataReader(cmd.ExecuteReader())) { if (reader.Read()) { var dto = new ReverseCrossRefRequiredStepDto { Id = reader.GetInt32(0), FieldId = reader.GetInt32(1), ReverseCrossRefProcessId = reader.GetNullableInt(2), CrossRefFieldName = reader.GetString(3), DisplayFieldName = reader.GetString(4), DisplayMultiple = reader.GetBoolean(5) }; if (reader.NextResult()) { while (reader.Read()) { var df = new ReverseCrossReferenceDisplayFieldDto { Id = reader.GetInt32(0), DisplayName = reader.GetString(1), FullPath = reader.GetString(2), Order = reader.GetDouble(3) }; dto.SelectedDisplayFields.Add(df); } } return dto; } } } } return null; }
/// <summary> /// Retrieves the process. /// </summary> /// <param name="id">The process id.</param> /// <param name="fetchHistory">The fetch history.</param> /// <param name="locId">The localization/language id.</param> /// <returns>The processEdit DTO object <see cref="ProcessEditDto" />.</returns> public ProcessEditDto FetchProcess(int id, IProcessFetchHistory fetchHistory = null, int locId = 0) { var process = new ProcessEditDto(); const string commandText = "GetProcessWithLoc"; if (fetchHistory != null) fetchHistory.BeginLogExecuteSP(); Database.GetDataReader( commandText, 600, r => { if (r == null || !r.Read()) { return; } var sr = new SafeDataReader(r); process.Id = sr.GetInt("Id"); process.Name = sr.GetString("Name").Trim(); process.Description = sr.GetString("Description"); process.Documentation = sr.GetString("Documentation"); process.SystemName = sr.GetString("SystemName"); process.IconId = sr.GetNullableInt("IconId"); process.Guid = sr.GetGuid("Guid"); process.IsPublishedCopy = sr.GetBool("IsPublishedCopy"); process.BaseProcessId = sr.GetNullableInt("BaseProcessId"); process.BaseProcessProcessId = sr.GetNullableInt("BaseProcessProcessId"); process.ProcessOption = sr.GetString("ProcessOption"); process.IsStateEnabled = sr.GetBool("IsStateEnabled", true); process.DefaultStateId = sr.GetInt32("DefaultStateId"); process.AllowPaperclips = sr.GetBool("AllowPaperclips", true); process.ColorId = sr.GetNullableInt("ColorId"); process.InheritanceContext = sr.GetString("InheritanceContext"); process.ShowDerivedProcess = sr.GetBool(Constants.ShowDerivedProcess); process.PublishedProcessId = sr.GetInt("PublishedProcessId"); process.PublishedId = sr.GetInt("PublishedId"); process.IsSystem = sr.GetBool("IsSystem"); process.SimpleProcess = sr.GetBool("SimpleProcess"); process.IsInactive = sr.GetBool("IsInactive"); process.IsTabbedUI = sr.GetBool("IsTabbedUI"); process.IsTrackable = sr.GetBool("IsTrackable"); process.ShowSummaryPage = sr.GetBool("ShowSummaryPage"); process.AllowBatchProcessing = sr.GetBool("AllowBatchProcessing"); process.LastUpdated = sr.GetDateTime("LastUpdated"); process.IdentifierField = sr.GetString("IdentifierField"); var processVersionId = sr.GetInt("ProcessVersionId"); if (fetchHistory != null) fetchHistory.LogExecuteSP(); if (processVersionId > 0) { process.Version = new VersionDto { ProcessId = processVersionId, VersioningStyle = sr.GetEnum("VersioningStyle", VersioningStyles.Char), StartingVersion = sr.GetString("StartingVersion"), NextVersionStateGuid = sr.GetGuid("NextVersionStateGuid"), PreviousVersionStateGuid = sr.GetGuid("PreviousVersionStateGuid"), IncludeVersionNumberInList = sr.GetBool("IncludeVersionNumberInList"), IncludeVersionDateInList = sr.GetBool("IncludeVersionDateInList"), StateFilterGuid = sr.GetGuid("StateFilterGuid") }; } if (fetchHistory != null) fetchHistory.ProcessHistoryDTO.FetchSectionsTime = Profiler.Profile(() => ReadSections(process, sr)); else ReadSections(process, sr); ReadRequiredRuleConfigs(process, sr); if (fetchHistory != null) fetchHistory.ProcessHistoryDTO.FetchSecurityConfigurationsTime = fetchHistory.Profile( () => { ReadProcessSecurityConfigurations(process, sr); ReadProcessSecurityConfigs(process, sr); }); else { ReadProcessSecurityConfigurations(process, sr); ReadProcessSecurityConfigs(process, sr); } ReadStates(process, sr); ReadEscalationActionOptions(process, sr); ReadAssignmentActionOptions(process, sr); ReadApprovalActionOptions(process, sr); ReadActionRules(process, sr); ReadFilters(process, sr); ReadMetrics(process, sr); ReadKpis(process, sr); ReadCommands(process, sr); ReadESyncProcesses(process, sr); ReadReports(process, sr); ReadProcessViews(process, sr); ReadDataTriggers(process, sr); ReadIntegrationServices(process, sr); ReadSearchDisplayFields(process, sr); ReadLayouts(process, sr); ReadProcessDataIndexes(process, sr); ReadExternalData(process, sr); }, CommandType.StoredProcedure, new SqlParameter("p_id", id), new SqlParameter("localizationId", locId)); // run after GetProcessNew this.ReadDependencies(process); return process; }
/// <summary> /// Retrieves synchronized processes. /// </summary> /// <returns>The <see cref="IList" />.</returns> public IEnumerable<PublishedProcessInfoDTO> FetchSynchronizedProcesses() { var result = new List<PublishedProcessInfoDTO>(); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; const string CommandText = @" SELECT pp.Id ,p.[Name] ,p.[SystemName] ,p.Id AS ProcessId ,p.[BaseProcessId] ,p.[IconId] FROM [dbo].[PublishedProcesses] pp INNER JOIN Processes p ON pp.ProcessId = p.Id WHERE p.IsRemoved = 0 AND p.IsInactive = 0 AND EXISTS( SELECT * FROM [dbo].[SyncProcesses] sp WHERE sp.ProcessId = p.Id) ORDER BY p.Name "; using (var cmd = new SqlCommand(CommandText, connection)) using (var reader = new SafeDataReader(cmd.ExecuteReader())) { while (reader.Read()) { var dto = new PublishedProcessInfoDTO { Id = reader.GetInt32(0), Name = reader.GetString(1), SystemName = reader.GetString(2), ProcessId = reader.GetInt32(3), IconId = reader.GetNullableInt(5) }; if (!reader.IsDBNull(4)) { dto.BaseProcess = this.FetchPublishedProcess(reader.GetInt(4)); } result.Add(dto); } } } return result; }
public IList<PublishedProcessInfoDTO> FetchPublishedProcesses(string culture) { var result = new List<PublishedProcessInfoDTO>(); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; var commandText = string.Format(CultureInfo.InvariantCulture, @" SELECT pp.Id ,ISNULL(pl.ProcessName, p.[Name]) ,p.[SystemName] ,p.Id AS ProcessId ,p.[BaseProcessId] ,p2.[IconId] ,p.[Guid] ,p.[ProcessOption] ,p.[IsStateEnabled] FROM [dbo].[PublishedProcesses] pp INNER JOIN Processes p ON pp.ProcessId = p.Id INNER JOIN Processes p2 ON pp.ProcessGuid = p2.[Guid] and p2.[IsPublishedCopy] = 0 LEFT OUTER JOIN dbo.ProcessLocalizations pl INNER JOIN dbo.Localizations l ON pl.LocalizationId = l.Id AND l.CultureName = '{0}' ON p2.Id = pl.ProcessId WHERE p.IsRemoved = 0 AND p2.IsRemoved = 0 ORDER BY p.Name", culture); using (var cmd = new SqlCommand(commandText, connection)) using (var reader = new SafeDataReader(cmd.ExecuteReader())) { while (reader.Read()) { var dto = new PublishedProcessInfoDTO { Id = reader.GetInt32(0), Name = reader.GetString(1), SystemName = reader.GetString(2), ProcessId = reader.GetInt32(3), IconId = reader.GetNullableInt(5), ProcessGuid = reader.GetGuid(6), ProcessOption = reader.GetEnum(7, ProcessOption.None), IsStateEnabled = reader.GetBoolean(8) }; if (!reader.IsDBNull(4)) { dto.BaseProcess = this.FetchPublishedProcess(reader.GetInt(4)); } result.Add(dto); } } } return result; }
/// <summary> /// Fetches the group navigation items. /// </summary> /// <param name="connection">The connection.</param> /// <param name="dto">The dto.</param> /// <param name="currentLocalizationId">The current localization identifier.</param> private static void FetchGroupNavigationItems(SqlConnection connection, NavigationGroupEditDto dto, int currentLocalizationId) { const string sql = @" SELECT nv.[Id] ,nv.[Guid] ,ISNULL(pl.ProcessName, p.[Name]) + (CASE WHEN ISNULL(pvl.Name, pv.Name) IS NULL THEN '' ELSE ' - ' + ISNULL(pvl.Name, pv.Name) END) ,p.[SystemName] ,nv.[Sequence] ,nv.[PublishedProcessId] ,nv.[IconURL] ,p.[IconId] ,nv.[ProcessViewGuid] FROM [dbo].[NavigationItems] nv INNER JOIN [dbo].[PublishedProcesses] pp ON nv.[PublishedProcessId] = pp.[Id] INNER JOIN [dbo].[Processes] p ON pp.[ProcessId] = p.[Id] INNER JOIN Processes p2 ON pp.ProcessGuid = p2.[Guid] and p2.[IsPublishedCopy] = 0 LEFT JOIN [dbo].[ProcessViews] pv ON pv.[Guid] = nv.ProcessViewGuid AND pv.ProcessId = p.Id LEFT OUTER JOIN dbo.ProcessLocalizations pl ON p2.Id = pl.ProcessId AND pl.LocalizationId = @locId LEFT OUTER JOIN dbo.ProcessViewLocalizations pvl ON p2.Id = pl.ProcessId AND pvl.LocalizationId = @locId WHERE p.[IsRemoved] = 0 AND p.IsInactive = 0 AND nv.[NavigationGroupId] = @groupId UNION SELECT nv.[Id] ,nv.[Guid] ,nv.[Name] ,NULL ,nv.[Sequence] ,NULL ,nv.[IconURL] ,NULL ,NULL FROM [dbo].[NavigationItems] nv WHERE nv.[SystemName] IS NULL AND nv.[PublishedProcessId] IS NULL AND nv.[NavigationGroupId] = @groupId; "; using (var cmd = new SqlCommand(sql, connection)) { cmd.Parameters.AddWithValue("@groupId", dto.Id); cmd.Parameters.AddWithValue("@locId", currentLocalizationId); using (var reader = new SafeDataReader(cmd.ExecuteReader())) { while (reader.Read()) { var navigationItemDto = new NavigationItemEditDto { Id = reader.GetInt(0), Guid = reader.GetGuid(1), Name = reader.GetString(2), Sequence = reader.GetDouble(4), PublishedProcessId = reader.GetNullableInt(5), IconURL = reader.GetString(6), IconId = reader.GetNullableInt(7), ProcessViewGuid = reader.GetNullableGuid(8) }; //FetchNavigationItemSecurityConfigurations(connection, navigationItemDto); dto.NavigationItems.Add(navigationItemDto); } } foreach (var navigationItemDto in dto.NavigationItems) { FetchNavigationItemSecurityConfigurations(connection, navigationItemDto); } } }
/// <summary> /// Fetches the navigation group edit list. /// </summary> /// <param name="currentLocalizationId">The current localization identifier.</param> /// <returns>IList{NavigationGroupEditDto}.</returns> public IList<NavigationGroupEditDto> FetchNavigationGroupEditList(int currentLocalizationId) { if (currentLocalizationId == 0) currentLocalizationId = GetLocIdByCultureName(Thread.CurrentThread.CurrentUICulture.Name); var result = new List<NavigationGroupEditDto>(); const string sql = @" SELECT [Id] ,[Guid] ,ISNULL(l.[Name], g.[Name]) as Name ,[SystemName] ,[Sequence] ,[IconURL] ,[IconId] FROM [dbo].[NavigationGroups] g left outer join [dbo].[NavigationGroupLocalizations] l on l.NavigationGroupId = g.Id and l.LocalizationId = @locId "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; if (cn.State != ConnectionState.Open) { cn.Open(); } using (var cmd = new SqlCommand(sql, cn)) { cmd.Parameters.AddWithValue("@locId", currentLocalizationId); using (var reader = new SafeDataReader(cmd.ExecuteReader())) { while (reader.Read()) { var navigationGroupDto = new NavigationGroupEditDto { Id = reader.GetInt(0), Guid = reader.GetGuid(1), Name = reader.GetString(2), SystemName = reader.GetString(3), Sequence = reader.GetDouble(4), IconURL = reader.GetString(5), IconId = reader.GetNullableInt(6) }; //FetchGroupNavigationItems(cn, navigationGroupDto); //FetchNavigationGroupSecurityConfigurations(cn, navigationGroupDto); result.Add(navigationGroupDto); } } foreach (var navigationGroupDto in result) { FetchGroupNavigationItems(cn, navigationGroupDto, currentLocalizationId); FetchNavigationGroupSecurityConfigurations(cn, navigationGroupDto); } } } return result; }
/// <summary> /// Adds the navigation item. /// </summary> /// <param name="reader">The reader.</param> /// <param name="currentGroup">The current group.</param> private static void AddNavigationItem(SafeDataReader reader, NavigationGroupDTO currentGroup) { var navItemDto = new NavigationItemDTO { Id = reader.GetInt32(5), Name = reader.GetString(6), SystemName = reader.GetString(7), IconId = reader.GetNullableInt(8), IconUrl = reader.GetString(9), AssemblyName = reader.GetString(10), ProcessId = reader.GetNullableInt(11), ProcessSystemName = reader.GetString(13), Description = reader.GetString(17) }; navItemDto.Description = navItemDto.ProcessId == null ? reader.GetString("HelpText") : reader.GetString(reader.GetOrdinal("Description")); navItemDto.BackgroundColor = reader.GetInt64(reader.GetOrdinal("BackgroundColor")); navItemDto.ProcessViewGuid = reader.GetNullableGuid(reader.GetOrdinal("ProcessViewGuid")); navItemDto.IsSystem = reader.GetNullableBool(reader.GetOrdinal("IsSystem")); navItemDto.IsBeta = reader.GetBoolean(reader.GetOrdinal("IsBeta")); var processName = reader.GetString(12); if (!string.IsNullOrEmpty(processName)) navItemDto.Name = processName; currentGroup.NavigationItems.Add(navItemDto); }
/// <summary> /// Fetches the navigation groups with items. /// </summary> /// <param name="isAdmin">if set to <c>true</c> [is admin].</param> /// <param name="personRoles">The person roles.</param> /// <returns>List{NavigationGroupDTO}.</returns> private static List<NavigationGroupDTO> FetchNavigationGroupsWithItems(bool isAdmin, IEnumerable<int> personRoles) { var result = new List<NavigationGroupDTO>(); var licenseInfo = LicenseInfo.GetLicenseInfo(); var roles = new List<int> { Constants.AllRolesId }; var whereString = GetNavigationGroupsFilter(isAdmin, personRoles, roles); int locId = GetLocIdByCultureName(Thread.CurrentThread.CurrentUICulture.Name); const string SqlTemplate = @" --Admin menu SELECT ng.[Id] AS GroupId ,ng.[Name] AS GroupName ,ng.[SystemName] AS GroupSystemName ,ng.[IconId] AS GroupIconId ,ng.[IconURL] AS GroupIconURL ,ni.[Id] AS ItemId ,ni.[Name] AS ItemName ,ni.[SystemName] AS ItemSystemName ,NULL AS ItemIconId ,ni.[IconURL] AS ItemIconURL ,NULL AS AssemblyName ,NULL AS ProcessId ,NULL ,NULL AS SystemName ,NULL AS Icon ,NULL AS Description ,NULL AS BackgroundColor ,Description AS HelpText ,NULL AS ProcessViewGuid ,ng.[Sequence] ,ni.[Sequence] ,NULL AS IsSystem ,ni.[IsBeta] FROM [dbo].[NavigationGroups] ng INNER JOIN [dbo].[NavigationItems] ni ON ng.[Id] = ni.[NavigationGroupId] WHERE ng.[SystemName] = '{3}' UNION ALL --Navigation SELECT TOP {2} ng.[Id] AS GroupId ,ISNULL(ngl.[Name], ng.[Name]) AS GroupName ,ng.[SystemName] AS GroupSystemName ,ng.[IconId] AS GroupIconId ,ng.[IconURL] AS GroupIconURL ,ni.[Id] AS ItemId ,ni.[Name] AS ItemName ,ni.[SystemName] AS ItemSystemName ,p.[IconId] AS ItemIconId ,ni.[IconURL] AS ItemIconURL ,pp.[AssemblyName] ,pp.[ProcessId] ,CASE WHEN (pl.LocalizationId = l.Id AND LEN(pl.ProcessName) > 0) THEN pl.ProcessName ELSE p.[Name] END + CASE WHEN pv.Name IS NULL THEN '' ELSE ' - ' + CASE WHEN (pvl.LocalizationId = l.Id AND LEN(pvl.Name) > 0) THEN pvl.Name ELSE pv.Name END END ,p.[SystemName] ,i.[Icon] ,p.[Description] ,c.[Color] AS BackgroundColor ,ni.Description AS HelpText ,ni.[ProcessViewGuid] ,ng.[Sequence] ,ni.[Sequence] ,p.[IsSystem] ,ni.[IsBeta] FROM [dbo].[NavigationGroups] ng INNER JOIN [dbo].[NavigationItems] ni ON ng.[Id] = ni.[NavigationGroupId] LEFT OUTER JOIN [dbo].[PublishedProcesses] pp ON pp.[Id] = ni.[PublishedProcessId] LEFT OUTER JOIN [dbo].[Processes] p ON p.[Id] = pp.[ProcessId] LEFT OUTER JOIN [dbo].[Processes] p1 ON p.SystemName = p1.[SystemName] AND p1.IsPublishedCopy = 0 AND p1.IsRemoved = 0 LEFT OUTER JOIN dbo.Localizations l ON l.CultureName = '{4}' LEFT OUTER JOIN dbo.ProcessLocalizations pl ON pl.LocalizationId = l.Id AND p1.Id = pl.ProcessId LEFT OUTER JOIN Icons i ON i.Id = ng.IconId LEFT OUTER JOIN Colors c ON c.Id = p.ColorId LEFT JOIN [dbo].[ProcessViews] pv ON pv.[Guid] = ni.ProcessViewGuid AND pv.ProcessId = p.Id LEFT JOIN [dbo].[ProcessViews] pv1 ON pv1.[Guid] = pv.Guid AND pv1.ProcessId = p1.Id LEFT OUTER JOIN dbo.ProcessViewLocalizations pvl ON pv1.Id = pvl.ProcessViewId LEFT JOIN [dbo].[NavigationGroupSecurityConfigurations] ngsc ON (ngsc.NavigationGroupId = ng.Id AND ngsc.RoleId = {0}) LEFT JOIN [dbo].[NavigationItemSecurityConfigurations] nisc ON (nisc.NavigationItemId = ni.Id AND nisc.RoleId = {0}) LEFT OUTER JOIN dbo.NavigationGroupLocalizations ngl ON ngl.NavigationGroupId = ng.Id AND ngl.LocalizationId = {5} {1} ORDER BY ng.[Sequence] ,ni.[Sequence]"; var sql = string.Format( CultureInfo.InvariantCulture, SqlTemplate, roles.Count > 1 ? roles[1] : roles[0], whereString, licenseInfo == null ? 0 : licenseInfo.Processes, Constants.AdminMenu, Thread.CurrentThread.CurrentUICulture.Name, locId); Database.GetDataReader( sql, reader => { if (reader == null) return; var groupId = -1; NavigationGroupDTO currentGroup = null; using (var safeReader = new SafeDataReader(reader)) { while (safeReader.Read()) { var newGroupId = safeReader.GetInt32(0); if (newGroupId == groupId && currentGroup != null) { AddNavigationItem(safeReader, currentGroup); } else // Make New group { var group = result.FirstOrDefault(g => g.Id == newGroupId); if (group == null) { group = new NavigationGroupDTO { Id = newGroupId, Name = safeReader.GetString(1), SystemName = safeReader.GetString(2), IconId = safeReader.GetNullableInt(3), IconURL = safeReader.GetString(4), Icon = AdoHelper.ReadImage(reader, 14) }; result.Add(group); } currentGroup = group; AddNavigationItem(safeReader, currentGroup); groupId = newGroupId; } } } }); return result; }
/// <summary> /// Initializes a new <see cref="PersonInfo"/> with values from a data reader. /// </summary> /// <param name="reader"> /// The data reader. /// </param> /// <returns> /// The <see cref="PersonInfo"/>. /// </returns> protected virtual PersonInfo ReadPerson(SafeDataReader reader) { if (reader == null) throw new ArgumentNullException("reader"); return new PersonInfo { Id = reader.GetInt32(0), FirstName = reader.GetString(1), LastName = reader.GetString(2), Email = reader.GetString(3), OutOfOffice = reader.GetNullableBool(4), DelegateApproverId = reader.GetNullableInt(5), AccountId = reader.GetNullableInt(6), UserName = reader.GetString(7), Locale = reader.GetString(8), AuthenticationType = reader.GetEnum(9, AuthenticationTypes.MQ1) }; }
public Collection<PersonInfo> GetPersons(IEditableRoot item) { if (item == null) throw new ArgumentNullException("item"); using (var ctx = ConnectionManager<SqlConnection>.GetManager(ServerSettings.ConnectionString, false)) { using (var cmd = new SqlCommand(QueryDefinition.CommandText, ctx.Connection)) { foreach (var parameterBuilder in QueryDefinition.ParameterBuilders) { cmd.Parameters.Add(parameterBuilder.CreateParameter(item)); } using (var reader = new SafeDataReader(cmd.ExecuteReader())) { var result = new Collection<PersonInfo>(); while (reader.Read()) { result.Add( new PersonInfo { Id = reader.GetInt32(0), FirstName = reader.GetString(1), LastName = reader.GetString(2), Email = reader.GetString(3), OutOfOffice = reader.GetNullableBool(4), DelegateApproverId = reader.GetNullableInt(5), AccountId = reader.GetNullableInt(6), UserName = reader.GetString(7), Locale = reader.GetString(8), AuthenticationType = reader.GetEnum(9, AuthenticationTypes.MQ1) }); } return result; } } } }
/// <summary> /// Reads process view fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadProcessViewFields(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); int? sectionId = null; ProcessViewSectionEditDto section = null; while (sr.Read()) { var fieldDto = new ProcessViewFieldEditDto { Id = sr.GetInt32(0), SectionId = sr.GetInt32(1), Guid = sr.GetGuid(2), TemplateFieldGuid = sr.GetGuid(3), FieldSystemName = sr.GetString(4), DisplayOrder = sr.GetDouble(5), DisplayType = sr.GetString(6), IconId = sr.GetNullableInt(7), CustomConfig = sr.GetString(8) }; if (fieldDto.SectionId != sectionId) { section = process.ViewList.SelectMany(v => v.SectionList).First(s => s.Id == fieldDto.SectionId); sectionId = fieldDto.SectionId; } section.FieldList.Add(fieldDto); } }
/// <summary> /// The read eSync processes. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadESyncProcesses(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { var syncProcess = new ESyncProcessDto { Id = sr.GetInt(0), Guid = sr.GetGuid(1), Name = sr.GetString(2), Description = sr.GetString(3), Action = (ESyncAction)Enum.Parse(typeof(ESyncAction), sr.GetString(4), true), Definition = sr.GetString(5), PublishedCopyId = sr.GetNullableInt(6), GenerateIndexes = sr.GetBoolean("GenerateIndexes") }; process.ESyncProcessList.Add(syncProcess); } }
/// <summary> /// Reads fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private void ReadFields(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); int? sectionId = null; SectionDto section = null; var times = new List<double>(); while (sr.Read()) { var start = DateTime.Now; var fieldDto = new FieldDto { Id = sr.GetInt32(0), Name = sr.GetSafeString(1, string.Empty).Replace(@"""", "''"), FieldTypeId = sr.GetInt32(2), SectionId = sr.GetInt32(3), Width = sr.GetDouble(4), RowSpan = sr.GetInt(5), ShowInList = sr.GetBoolean(6), IncludeInFilter = sr.GetBoolean(7), HideFromDetails = sr.GetBoolean(8), SystemName = sr.GetString(9), Position = sr.GetInt32(10), CopyFieldValueOnCopyItem = sr.GetBool(11), DeepCopy = sr.GetBool(12), Guid = sr.GetGuid(13), SearchPosition = sr.GetInt(14), SearchWidth = sr.GetInt(15), IsBase = sr.GetBoolean(16), UseInGlobalSearch = sr.GetBoolean(19), PublishedCopyId = sr.GetNullableInt(21), AllowLocalizedData = sr.GetBoolean("AllowLocalizedData") }; if (fieldDto.SectionId != sectionId || section == null) { section = process.Sections.First(s => s.Id == fieldDto.SectionId); sectionId = fieldDto.SectionId; } fieldDto.FieldTypeInfo = new FieldTypeDto { Id = fieldDto.FieldTypeId, Name = sr.GetString(17), DataType = sr.GetString(18), CanBeRequired = sr.GetBoolean(20) }; section.FieldList.Add(fieldDto); times.Add((DateTime.Now - start).TotalMilliseconds); } Profiler.Profile(() => this.ReadFieldEditors(process, sr)); }
/// <summary> /// Reads published process. /// </summary> /// <param name="process">The process.</param> /// <param name="cmd">The command.</param> /// <param name="processGuid">The process GUID.</param> /// <returns>Returns true if successfully loaded published process.</returns> private static bool ReadPublishedProcess(ProcessEditDto process, SqlCommand cmd, Guid? processGuid = null) { using (var reader = new SafeDataReader(cmd.ExecuteReader())) { if (reader.Read()) { process.Id = reader.GetInt32(0); process.Name = reader.GetString(1); process.Description = reader.GetString(2); process.Documentation = reader.GetString(3); process.SystemName = reader.GetString(4); process.IsPublishedCopy = true; process.Guid = processGuid == null ? reader.GetGuid("Guid") : processGuid.Value; process.IconId = reader.GetNullableInt("IconId"); } else { return true; } } return false; }
/// <summary> /// Fetches the integration service web method call settings. /// </summary> /// <param name="parentSettingsId">The parent settings identifier.</param> /// <returns>IntegrationServiceWebMethodCallSettingsDto.</returns> public IntegrationServiceWebMethodCallSettingsDto FetchIntegrationServiceWebMethodCallSettings(int parentSettingsId) { const string CommandText = @" DECLARE @settingsId INT; SELECT @settingsId = [Id] FROM [dbo].[IntegrationServiceWebMethodCallSettings] WHERE [SettingsId] = @parentSettingsId; SELECT [Id] ,[Address] ,[ServiceDescriptionId] ,[ContractTypeName] ,[MethodName] ,[ParametersMapping] ,[ResultMapping] ,[Username] ,[Password] ,[EndpointConfiguration] FROM [dbo].[IntegrationServiceWebMethodCallSettings] WHERE [Id] = @settingsId; SELECT [Id] ,[ParentId] ,[Guid] ,[Name] ,[TypeCode] ,[TypeName] ,[TypeDisplayName] ,[IsNull] ,[IsArray] ,[ArrayItemCount] ,[IsEnum] ,[IsSoapHeader] FROM [dbo].[IntegrationServiceWebMethodCallParameters] WHERE [SettingsId] = @settingsId; SELECT [Id] ,[ParentId] ,[Name] ,[DeclaringTypeName] FROM [dbo].[IntegrationServiceWebMethodCallResultFields] WHERE [SettingsId] = @settingsId;"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { using (var cmd = new SqlCommand(CommandText, ctx.Connection)) { cmd.Parameters.AddWithValue("@parentSettingsId", parentSettingsId); using (var reader = new SafeDataReader(cmd.ExecuteReader())) { if (reader.Read()) { var result = new IntegrationServiceWebMethodCallSettingsDto { Id = reader.GetInt32(0), Address = reader.GetString(1), ServiceDescriptionId = reader.GetNullableInt(2), ContractTypeName = reader.GetString(3), MethodName = reader.GetString(4), ParametersMapping = reader.GetString(5), ResultMapping = reader.GetString(6), Username = reader.GetString("Username"), Password = reader.GetString("Password"), EndpointConfiguration = reader.GetString("EndpointConfiguration") }; ReadIntegrationServiceWebMethodCallParameters(result, reader); ReadIntegrationServiceWebMethodCallResultFields(result, reader); return result; } } } } return null; }