/// <summary> /// Reads required rule config fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> /// ProcessCommandSecurityConfigurations private static void ReadRequiredRuleConfigFields(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); int? requiredConfigId = null; RequiredRuleConfigEditDto config = null; while (sr.Read()) { var configFieldDto = new RequiredRuleConfigFieldEditDto { Id = sr.GetInt32(0), RequiredConfigId = sr.GetInt32(1), Guid = sr.GetGuid(2), FieldGuid = sr.GetGuid(3), IsRequired = sr.GetBoolean(4) }; if (configFieldDto.RequiredConfigId != requiredConfigId) { config = process.RequiredRuleConfigs.First(rrc => rrc.Id == configFieldDto.RequiredConfigId); requiredConfigId = configFieldDto.RequiredConfigId; } config.FieldList.Add(configFieldDto); } }
public IHttpActionResult Update(ProcessEditDto dto) { //Recupero l'entity var oResult = _processService.UpdateProcess(dto); //Se ci sono stati errori, li notifico if (oResult.HasErrors()) { Log4NetConfig.ApplicationLog.Warn(string.Format("Errore durante la modifica di un processo. Nome: {0}", dto.Name, oResult.GetValidationErrorsInline(" - "))); NHibernateHelper.SessionFactory.GetCurrentSession().Transaction.Rollback(); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, oResult))); } //Ritorno i risultati return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK))); }
/// <summary> /// Reads search display fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadSearchDisplayFields(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { process.Search.Add( new ProcessSearchEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), GuidId = sr.GetGuid(2), FieldSystemName = sr.GetString(3), Position = sr.GetInt32(4), Width = sr.GetInt32(5), ShowInList = sr.GetBoolean(6) }); } }
/// <summary> /// Reads commands. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadCommands(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { var commandDto = new ProcessCommandEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), GuidId = sr.GetGuid(2).ToString(), LastModifiedOn = sr.GetDateTime(3), CommandName = sr.GetString(4), CommandType = sr.GetString(5), Documentation = sr.GetString(6), IntegrationServiceGuid = sr.GetNullableGuid(7), DataTriggerGuid = sr.GetNullableGuid("DataTriggerGuid") }; process.Commands.Add(commandDto); } ReadCommandSecurityConfiguration(process, sr); }
/// <summary> /// Reads filters. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadFilters(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { process.Filters.Add( new ProcessFilterEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), LastModifiedOn = sr.GetDateTime(2), GuidId = sr.GetString(3), Name = sr.GetString(4), Documentation = sr.GetString(5), FilterDefinition = sr.GetString(6), RoleIds = sr.GetString(7) }); } }
/// <summary> /// Updates the process. /// </summary> /// <param name="dto">The process DTO.</param> /// <exception cref="System.ArgumentException">The input DTO is null.</exception> /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception> public void UpdateProcess(ProcessEditDto dto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" UPDATE [dbo].[Processes] SET [LastUpdated] = @p_LastModifiedOn ,[Name] = @p_Name ,[Description] = @p_Description ,[Documentation] = @p_Documentation ,[SystemName] = @p_SystemName ,[BaseProcessId] = @p_BaseProcessId ,[IconId] = @p_IconId ,[ProcessOption] = @p_ProcessOption ,[IsStateEnabled] = @p_IsStateEnabled ,[DefaultStateId] = @p_DefaultStateId ,[AllowPaperclips] = @p_AllowPaperclips ,[ColorId] = @p_ColorId ,[InheritanceContext] = @p_inheritanceContext ,[ShowDerivedProcess] = @p_showDerivedProcess ,[SimpleProcess] = @p_simpleProcess ,[IsInactive] = @p_isInactive ,[IsTabbedUI] = @p_isTabbedUI ,[IsTrackable] = @p_isTrackable ,[ShowSummaryPage] = @p_showSummaryPage ,[AllowBatchProcessing] = @p_allowBatchProcessing ,[IdentifierField] = @p_identifierField WHERE [Id] = @p_Id "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Id", dto.Id); command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now); command.Parameters.AddWithValue("@p_Name", dto.Name.Trim()); command.Parameters.AddWithValue("@p_Description", dto.Description ?? string.Empty); command.Parameters.Add(new SqlParameter("@p_Documentation", SqlDbType.NVarChar, -1) { Value = dto.Documentation ?? string.Empty }); command.Parameters.AddWithValue("@p_SystemName", dto.SystemName); if (dto.BaseProcessId.HasValue) command.Parameters.AddWithValue("@p_BaseProcessId", dto.BaseProcessId); else command.Parameters.AddWithValue("@p_BaseProcessId", DBNull.Value); command.Parameters.AddWithValue("@p_IconId", AdoHelper.NullCheck(dto.IconId)); command.Parameters.AddWithValue("@p_ColorId", AdoHelper.NullCheck(dto.ColorId)); command.Parameters.AddWithValue("@p_ProcessOption", dto.ProcessOption); command.Parameters.AddWithValue("@p_IsStateEnabled", dto.IsStateEnabled); command.Parameters.AddWithValue("@p_DefaultStateId", dto.DefaultStateId); command.Parameters.AddWithValue("@p_AllowPaperclips", dto.AllowPaperclips); command.Parameters.AddWithValue("@p_inheritanceContext", AdoHelper.NullCheck(dto.InheritanceContext)); command.Parameters.AddWithValue("@p_showDerivedProcess", dto.ShowDerivedProcess); command.Parameters.AddWithValue("@p_simpleProcess", dto.SimpleProcess); command.Parameters.AddWithValue("@p_isInactive", dto.IsInactive); command.Parameters.AddWithValue("@p_isTabbedUI", dto.IsTabbedUI); command.Parameters.AddWithValue("@p_isTrackable", dto.IsTrackable); command.Parameters.AddWithValue("@p_showSummaryPage", dto.ShowSummaryPage); command.Parameters.AddWithValue("@p_allowBatchProcessing", dto.AllowBatchProcessing); command.Parameters.AddWithValue("@p_identifierField", AdoHelper.NullCheck(dto.IdentifierField)); using (var reader = new SafeDataReader(command.ExecuteReader())) if (reader.RecordsAffected == 0) throw new DBConcurrencyException(Resources.StaleDataException); } } }
/// <summary> /// Restores process. /// </summary> /// <param name="processDto">The process DTO.</param> /// <returns>Returns true if operation succeeded<see cref="bool" />.</returns> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public bool RestoreProcess(ProcessEditDto processDto) { if (processDto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "processDto")); const string CommandText = @" UPDATE [dbo].[Processes] SET [IsRemoved] = 0 WHERE [SystemName] = @p_SystemName AND [id] IN ( SELECT TOP 2 p.[Id] FROM [dbo].[Processes] p WHERE isRemoved = 1 AND p.[SystemName] = @p_SystemName ORDER BY p.[Id] DESC ) "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_SystemName", processDto.SystemName); using (var reader = new SafeDataReader(command.ExecuteReader())) { if (reader.RecordsAffected != 0) { return true; } } } } return false; }
/// <summary> /// Reads process security configurations. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadProcessSecurityConfigurations(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { var securityConfigurationDto = new ProcessSecurityConfigurationDto { Id = sr.GetInt32(0), CanCreate = sr.GetBoolean(1), CanDelete = sr.GetBoolean(2), ProcessId = sr.GetInt32(3), RoleId = sr.GetInt32(4), BusinessUnitId = sr.GetInt32(5), }; process.SecurityConfigurations.Add(securityConfigurationDto); } }
/// <summary> /// Retrieves process published copy. /// </summary> /// <param name="processGuid">The process GUID.</param> /// <param name="fetchHistory">The fetch history.</param> /// <returns>The <see cref="ProcessEditDto" />.</returns> public ProcessEditDto FetchProcessPublishedCopy(Guid processGuid, IProcessFetchHistory fetchHistory) { var process = new ProcessEditDto(); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; const string CommandText = @" SELECT [p].[Id] ,[p].[Name] ,[p].[Description] ,[p].[Documentation] ,[p].[SystemName] ,[p].[IconId] FROM [dbo].[Processes] p WHERE p.Guid = @guid AND IsPublishedCopy = 1 AND IsRemoved = 0"; using (var cmd = new SqlCommand(CommandText, cn)) { cmd.Parameters.AddWithValue("@guid", processGuid); return ReadPublishedProcess(process, cmd, processGuid) ? null : this.FetchProcess(process.Id, fetchHistory); } } }
/// <summary> /// Read reports. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadReports(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { var reportDto = new ProcessReportEditDto { Id = sr.GetInt32(0), Guid = sr.GetGuid(1), Title = sr.GetString(2), Description = sr.GetString(3), FileName = sr.GetString(4), DisplayToUsers = sr.GetBoolean(5), Visibility = (ReportVisibility)Enum.Parse(typeof(ReportVisibility), sr.GetString(6), true), IsSecured = sr.GetBoolean(7) }; process.ReportList.Add(reportDto); } ReadReportSecurityConfigurations(process, sr); }
/// <summary> /// Reads ordered list of field editors. /// </summary> /// <param name="process">Process DTO.</param> /// <param name="sr">Data Reader.</param> private void ReadFieldEditors(ProcessEditDto process, SafeDataReader sr) { var stepFetchers = this.StepFetchers.ToDictionary(k => k.Metadata.TargetType, v => v.Value); sr.NextResult(); var stepList = new List<StepDto>(); // ReSharper disable ImplicitlyCapturedClosure Profiler.Profile(() => GetStepList(sr, stepList)); // ReSharper restore ImplicitlyCapturedClosure Profiler.Profile(() => ReadSteps(process, sr, stepList, null, null, stepFetchers)); }
/// <summary> /// Reads connectors security configurations. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadConnectorsSecurityConfigurations(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); var connectorInId = Guid.Empty; var connectorOutId = Guid.Empty; ConnectorDTO connector = null; while (sr.Read()) { var securityDto = new StateConnectorSecurityConfigurationEditDto { Id = sr.GetInt(0), CanMove = sr.GetBoolean(1), RoleId = sr.GetInt(2), BusinessUnitId = sr.GetInt(3), PersonFieldName = sr.GetString(4), StateInGuid = sr.GetGuid(5), StateOutGuid = sr.GetGuid(6) }; if (connectorInId != securityDto.StateInGuid || connectorOutId != securityDto.StateOutGuid) { connectorInId = securityDto.StateInGuid; connectorOutId = securityDto.StateOutGuid; connector = process.States.SelectMany(s => s.Connectors).FirstOrDefault(c => c.ConnectsToStateGuid == connectorInId && c.ConnectsFromStateGuid == connectorOutId); if (connector == null) { continue; } } if (connector != null) { connector.SecurityConfigurations.Add(securityDto); } } }
/// <summary> /// Reads View steps. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> /// <param name="stepList">The step list.</param> /// <param name="sectionId">The Section id.</param> /// <param name="fieldDto">The field DTO.</param> /// <param name="stepFetchers">The step fetchers.</param> private static void ReadViewSteps( ProcessEditDto process, SafeDataReader sr, IEnumerable<ViewStepDto> stepList, int? sectionId, ProcessViewSectionEditDto fieldDto, Dictionary<string, IFetcher> stepFetchers) { foreach (var fieldEditorDto in stepList) { try { var dto = fieldEditorDto; ReadViewStep(process, sr, sectionId, ref fieldDto, stepFetchers, dto); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } } }
/// <summary> /// Reads the layouts. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadLayouts(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { process.Layouts.Add( new ProcessLayoutDto { Id = sr.GetInt32(0), Name = sr.GetString(1), GuidId = sr.GetGuid(2), LayoutDefinition = sr.GetString(3), ProcessId = process.Id, IsDefault = sr.GetBoolean(4) }); } }
/// <summary> /// Reads field backcolor rules. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadFieldBackcolorRules(ProcessEditDto process, SafeDataReader sr) { int? ruleId = null; ProcessActionRuleEditDto rule = null; sr.NextResult(); while (sr.Read()) { var dto = new FieldBackcolorRuleEditDto { RuleId = sr.GetInt32(0), RuleGuid = sr.GetGuid(1), FieldGuid = sr.GetGuid(2), BackColor = sr.GetInt64(3), FieldSystemName = sr.GetString(4), FieldName = sr.GetString(5) }; if (dto.RuleId != ruleId) { rule = process.ActionRules.First(r => r.Id == dto.RuleId); ruleId = rule.Id; } rule.FieldBackcolorRules.Add(dto); } }
/// <summary> /// Reads field visibility rules. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadFieldVisibilityRules(ProcessEditDto process, SafeDataReader sr) { int? ruleId = null; ProcessActionRuleEditDto rule = null; sr.NextResult(); while (sr.Read()) { var visibilityRule = new FieldVisibilityRuleEditDto { RuleId = sr.GetInt32(0), FieldGuid = sr.GetGuid(1) }; if (visibilityRule.RuleId != ruleId) { rule = process.ActionRules.First(r => r.Id == visibilityRule.RuleId); ruleId = rule.Id; } rule.FieldVisibilityRules.Add(visibilityRule); } }
/// <summary> /// The read security config system fields. /// </summary> /// <param name="sr">The reader.</param> /// <param name="process">The process.</param> private static void ReadSecurityConfigSystemFields(SafeDataReader sr, ProcessEditDto process) { sr.NextResult(); while (sr.Read()) { var systemFieldSecurityConfig = new ProcessSystemFieldSecurityConfigEditDto { Id = sr.GetInt(0), SecurityConfigId = sr.GetInt(1), Guid = sr.GetGuid(2), FieldSystemName = sr.GetString(3), CanView = sr.GetBoolean(4), CanEdit = sr.GetBoolean(5) }; var config = process.SecurityConfigs.FirstOrDefault(sc => sc.Id == systemFieldSecurityConfig.SecurityConfigId); if (config != null) { config.SecurityConfigSystemFields.Add(systemFieldSecurityConfig); } } }
/// <summary> /// The read security config fields. /// </summary> /// <param name="sr">The reader.</param> /// <param name="process">The process.</param> private static void ReadSecurityConfigFields(SafeDataReader sr, ProcessEditDto process) { sr.NextResult(); while (sr.Read()) { var securityConfigFieldDto = new ProcessSecurityConfigFieldDto { Id = sr.GetInt32(0), SecurityConfigId = sr.GetInt32(1), CanView = sr.GetBool(2), CanEdit = sr.GetBool(3), Guid = sr.GetGuid(4), FieldGuid = sr.GetGuid(5) }; var config = process.SecurityConfigs.FirstOrDefault(sc => sc.Id == securityConfigFieldDto.SecurityConfigId); if (config != null) { config.SecurityConfigFields.Add(securityConfigFieldDto); } } }
/// <summary> /// Read View Step. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> /// <param name="SectionId">The Section id.</param> /// <param name="fieldDto">The field DTO.</param> /// <param name="stepFetchers">The step fetchers.</param> /// <param name="fieldEditorDto">The field editor DTO.</param> /// <returns>The Field Id.</returns> private static int? ReadViewStep( ProcessEditDto process, SafeDataReader sr, int? SectionId, ref ProcessViewSectionEditDto fieldDto, Dictionary<string, IFetcher> stepFetchers, ViewStepDto fieldEditorDto) { sr.NextResult(); if (SectionId != fieldEditorDto.SectionId) { SectionId = fieldEditorDto.SectionId; fieldDto = process.ViewList.SelectMany(v => v.SectionList).First(s => s.Id == SectionId); } fieldDto.StepList.Add((BaseViewStepDto)(stepFetchers.ContainsKey("Cebos.Veyron.Library.Process.ProcessViews.SectionSteps." + fieldEditorDto.Class) ? stepFetchers["Cebos.Veyron.Library.Process.ProcessViews.SectionSteps." + fieldEditorDto.Class].Fetch(fieldEditorDto, sr) : fieldEditorDto)); return SectionId; }
/// <summary> /// Reads metrics. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadMetrics(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { process.Metrics.Add(new ProcessMetricEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), LastModifiedOn = sr.GetDateTime(2), GuidId = sr.GetString(3), Name = sr.GetString(4), Documentation = sr.GetString(5), SummaryType = sr.GetString(6), LockFilter = sr.GetBool(7), SnapshotFrequency = sr.GetString(8), MetricFieldSystemName = sr.GetString(9), GroupFieldOneSystemName = sr.GetString(10), GroupFieldTwoSystemName = sr.GetString(11), GroupFieldThreeSystemName = sr.GetString(12), GroupFieldFourSystemName = sr.GetString(13), FilterGuid = sr.GetGuid(14), OrderByMetricField = sr.GetString(15), OrderByAscending = (bool?)sr.GetValue(16), FilterDefinition = sr.GetString(17) }); } }
/// <summary> /// Reads command security configuration. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadCommandSecurityConfiguration(ProcessEditDto process, SafeDataReader sr) { int? commandId = null; ProcessCommandEditDto commandDto = null; sr.NextResult(); while (sr.Read()) { var securityConfiguration = new ProcessCommandSecurityConfigurationDto { Id = sr.GetInt32(0), ProcessCommandId = sr.GetInt32(1), CommandId = sr.GetInt32(1), RoleId = sr.GetInt32(2), BusinessUnitId = sr.GetInt32(3), StateGuid = sr.GetString(4), PersonFieldName = sr.GetString(5) }; if (commandId != securityConfiguration.CommandId) { commandId = securityConfiguration.CommandId; commandDto = process.Commands.First(c => c.Id == commandId); } commandDto.SecurityConfigurationList.Add(securityConfiguration); } }
/// <summary> /// The read KPIs. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadKpis(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { process.Kpis.Add(new ProcessKpiEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), MetricGuid = sr.GetString(2), LastModifiedOn = sr.GetDateTime(3), GuidId = sr.GetString(4), Name = sr.GetString(5), TargetValue = sr.GetDouble(6), FavorableDirection = sr.GetString(7), GreenIconUrl = sr.GetString(8), GreenIconId = sr.GetInt32(9, null), GreenValue = sr.GetDouble(10), YellowIconUrl = sr.GetString(11), YellowIconId = sr.GetInt32(12, null), YellowValue = sr.GetDouble(13), RedIconUrl = sr.GetString(14), RedIconId = sr.GetInt32(15, null), FilterGuid = sr.GetString(16, null), FilterDefinition = sr.GetString(17, null), Documentation = sr.GetString(18), }); } }
/// <summary> /// Reads required rule configurations. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadRequiredRuleConfigs(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); while (sr.Read()) { var configDto = new RequiredRuleConfigEditDto { Id = sr.GetInt32(0), ProcessId = sr.GetInt32(1), Guid = sr.GetGuid(2), StateGuid = sr.GetGuid(3) }; process.RequiredRuleConfigs.Add(configDto); } ReadRequiredRuleConfigFields(process, sr); }
/// <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> /// 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> /// Reads report security configurations. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private static void ReadReportSecurityConfigurations(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); int? reportId = null; ProcessReportEditDto report = null; while (sr.Read()) { var config = new ProcessReportSecurityConfigurationDto { Id = sr.GetInt(0), Guid = sr.GetGuid(1), ReportId = sr.GetInt(2), RoleId = sr.GetInt(3), BusinessUnitId = sr.GetInt(4), Name = sr.GetString(5) }; if (config.ReportId != reportId) { report = process.ReportList.First(r => r.Id == config.ReportId); reportId = config.ReportId; } report.SecurityConfigurations.Add(config); } }
/// <summary> /// Retrieves process published copy. /// </summary> /// <param name="assemblyName">The assembly name.</param> /// <param name="fetchHistory">The fetch history.</param> /// <returns>The <see cref="ProcessEditDto" />.</returns> public ProcessEditDto FetchProcessPublishedCopy(string assemblyName, IProcessFetchHistory fetchHistory) { var process = new ProcessEditDto(); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; const string CommandText = @" SELECT [p].[Id], [p].[Name], [p].[Description], [p].[Documentation], [p].[SystemName], [p].[IconId], [pp].ProcessGuid as Guid FROM [dbo].[Processes] p LEFT OUTER JOIN PublishedProcesses pp ON pp.ProcessId = p.Id WHERE pp.AssemblyName = @assemblyName AND IsPublishedCopy = 1 AND isRemoved = 0"; using (var cmd = new SqlCommand(CommandText, cn)) { cmd.Parameters.AddWithValue("@assemblyName", assemblyName); return ReadPublishedProcess(process, cmd) ? null : this.FetchProcess(process.Id, fetchHistory); } } }
/// <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> /// Updates the process. /// </summary> /// <param name="dto">The process DTO.</param> /// <param name="locDto">The process localization DTO.</param> /// <exception cref="System.ArgumentException">The input DTO is null.</exception> /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception> public void UpdateProcessWithLocalization(ProcessEditDto dto, ProcessLocalizationDto locDto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" UPDATE [dbo].[Processes] SET [LastUpdated] = @p_LastModifiedOn ,[SystemName] = @p_SystemName ,[BaseProcessId] = @p_BaseProcessId ,[IconId] = @p_IconId ,[ProcessOption] = @p_ProcessOption ,[IsStateEnabled] = @p_IsStateEnabled ,[DefaultStateId] = @p_DefaultStateId ,[AllowPaperclips] = @p_AllowPaperclips ,[ColorId] = @p_ColorId ,[InheritanceContext] = @p_inheritanceContext ,[ShowDerivedProcess] = @p_showDerivedProcess ,[SimpleProcess] = @p_simpleProcess ,[IsInactive] = @p_isInactive WHERE [Id] = @p_Id "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Id", dto.Id); command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now); ; command.Parameters.AddWithValue("@p_SystemName", dto.SystemName); if (dto.BaseProcessId.HasValue) command.Parameters.AddWithValue("@p_BaseProcessId", dto.BaseProcessId); else command.Parameters.AddWithValue("@p_BaseProcessId", DBNull.Value); command.Parameters.AddWithValue("@p_IconId", AdoHelper.NullCheck(dto.IconId)); command.Parameters.AddWithValue("@p_ColorId", AdoHelper.NullCheck(dto.ColorId)); command.Parameters.AddWithValue("@p_ProcessOption", dto.ProcessOption); command.Parameters.AddWithValue("@p_IsStateEnabled", dto.IsStateEnabled); command.Parameters.AddWithValue("@p_DefaultStateId", dto.DefaultStateId); command.Parameters.AddWithValue("@p_AllowPaperclips", dto.AllowPaperclips); command.Parameters.AddWithValue("@p_inheritanceContext", AdoHelper.NullCheck(dto.InheritanceContext)); command.Parameters.AddWithValue("@p_showDerivedProcess", dto.ShowDerivedProcess); command.Parameters.AddWithValue("@p_simpleProcess", dto.SimpleProcess); command.Parameters.AddWithValue("@p_isInactive", dto.IsInactive); using (var reader = new SafeDataReader(command.ExecuteReader())) if (reader.RecordsAffected == 0) throw new DBConcurrencyException(Resources.StaleDataException); } } UpdateProcessLocalization(locDto); }
/// <summary> /// Reads process view fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The sr.</param> private void ReadProcessViewSteps(ProcessEditDto process, SafeDataReader sr) { var stepFetchers = this.StepFetchers.ToDictionary(k => k.Metadata.TargetType, v => v.Value); sr.NextResult(); var stepList = new List<ViewStepDto>(); GetViewStepList(sr, stepList); ReadViewSteps(process, sr, stepList, null, null, stepFetchers); /* sr.NextResult(); int? sectionId = null; ProcessViewSectionEditDto section = null; var fieldDto = null; if (fieldDto.SectionId != sectionId) { section = process.ViewList.SelectMany(v => v.SectionList).First(s => s.Id == fieldDto.SectionId); sectionId = fieldDto.SectionId; } section.StepList.Add(fieldDto); 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> /// Inserts new process. /// </summary> /// <param name="dto">The Process DTO.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public void InsertProcess(ProcessEditDto dto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" INSERT INTO [dbo].[Processes] ( [Name] ,[Description] ,[Documentation] ,[LastUpdated] ,[SystemName] ,[Guid] ,[IsPublishedCopy] ,[BaseProcessId] ,[IconId] ,[ProcessOption] ,[IsStateEnabled] ,[DefaultStateId] ,[AllowPaperclips] ,[ColorId] ,[InheritanceContext] ,[SimpleProcess] ,[IsInactive] ,[IsTabbedUI] ,[IsTrackable] ,[ShowSummaryPage] ,[AllowBatchProcessing] ,[IdentifierField] ) VALUES ( @p_Name ,@p_Description ,@p_Documentation ,@p_LastUpdated ,@p_SystemName ,@p_Guid ,@p_IsPublishedCopy ,@p_BaseProcessId ,@p_IconId ,@p_ProcessOption ,@p_IsStateEnabled ,@p_DefaultStateId ,@p_AllowPaperclips ,@p_ColorId ,@p_inheritanceContext ,@p_simpleProcess ,@p_isInactive ,@p_isTabbedUI ,@p_isTrackable ,@p_showSummaryPage ,@p_allowBatchProcessing ,@p_identifierField ); SELECT [Id] FROM [dbo].[Processes] WHERE Id = SCOPE_IDENTITY()"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Name", dto.Name.Trim()); command.Parameters.AddWithValue("@p_Description", AdoHelper.NullCheck(dto.Description)); command.Parameters.AddWithValue("@p_Documentation", AdoHelper.NullCheck(dto.Documentation)); command.Parameters.AddWithValue("@p_LastUpdated", dto.LastUpdated); command.Parameters.AddWithValue("@p_SystemName", dto.SystemName); command.Parameters.AddWithValue("@p_Guid", dto.Guid); command.Parameters.AddWithValue("@p_IsPublishedCopy", dto.IsPublishedCopy); command.Parameters.AddWithValue("@p_BaseProcessId", dto.BaseProcessId.HasValue ? (object)dto.BaseProcessId.Value : DBNull.Value); command.Parameters.AddWithValue("@p_IconId", dto.IconId.HasValue ? (object)dto.IconId.Value : DBNull.Value); command.Parameters.AddWithValue("@p_ProcessOption", dto.ProcessOption); command.Parameters.AddWithValue("@p_IsStateEnabled", dto.IsStateEnabled); command.Parameters.AddWithValue("@p_DefaultStateId", DBNull.Value); // State does not exists command.Parameters.AddWithValue("@p_AllowPaperclips", dto.AllowPaperclips); command.Parameters.AddWithValue("@p_ColorId", AdoHelper.NullCheck(dto.ColorId)); command.Parameters.AddWithValue("@p_inheritanceContext", AdoHelper.NullCheck(dto.InheritanceContext)); command.Parameters.AddWithValue("@p_simpleProcess", dto.SimpleProcess); command.Parameters.AddWithValue("@p_isInactive", dto.IsInactive); command.Parameters.AddWithValue("@p_isTabbedUI", dto.IsTabbedUI); command.Parameters.AddWithValue("@p_isTrackable", dto.IsTrackable); command.Parameters.AddWithValue("@p_showSummaryPage", dto.ShowSummaryPage); command.Parameters.AddWithValue("@p_allowBatchProcessing", dto.AllowBatchProcessing); command.Parameters.AddWithValue("@p_identifierField", AdoHelper.NullCheck(dto.IdentifierField)); dto.Id = (int)command.ExecuteScalar(); } } }
public OperationResult <Guid?> CreateProcess(ProcessEditDto dto) { //Validazione argomenti if (dto == null) { throw new ArgumentNullException(nameof(dto)); } //Dichiaro la lista di risultati di ritorno IList <ValidationResult> vResults = new List <ValidationResult>(); //Definisco l'entità Process entity = new Process(); entity.Name = dto.Name; entity.ProcessType = dto.ProcessType; entity.IsEnabled = !dto.IsEnabled.HasValue ? false : dto.IsEnabled; //Eseguo la validazione logica vResults = ValidateEntity(entity); if (!vResults.Any()) { //Salvataggio su db _processRepository.Save(entity); } if (dto.Parameters != null && dto.Parameters.Count > 0) { entity.Parameters.Clear(); foreach (var item in dto.Parameters) { item.Process = entity.Id; var oResult = _parameterService.CreateParameter(item); if (oResult.HasErrors()) { return(new OperationResult <Guid?> { ValidationResults = oResult.ValidationResults }); } var parameter = _parameterService.Load <Parameter, Guid?>(oResult.ReturnedValue); entity.Parameters.Add(parameter); } } if (dto.ProcessMacros != null && dto.ProcessMacros.Count > 0) { entity.ProcessMacros.Clear(); foreach (var item in dto.ProcessMacros) { item.Process = entity.Id; var oResult = _processMacroService.CreateProcessMacro(item); if (oResult.HasErrors()) { return(new OperationResult <Guid?> { ValidationResults = oResult.ValidationResults }); } var processMacro = _processMacroService.Load <ProcessMacro, Guid?>(oResult.ReturnedValue); entity.ProcessMacros.Add(processMacro); } } //Eseguo la validazione logica vResults = ValidateEntity(entity); if (!vResults.Any()) { //Salvataggio su db _processRepository.Save(entity); } //Ritorno i risultati return(new OperationResult <Guid?> { ReturnedValue = entity.Id, ValidationResults = vResults }); }