示例#1
0
        /// <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);
            }
        }
 private void FetchChildren(SafeDataReader dr)
 {
     dr.NextResult();
     while (dr.Read())
     {
         _voucherList.Add(FetchVoucherEdit(dr));
     }
 }
        /// <summary>
        /// Executes the SP.
        /// </summary>
        /// <returns>spResult object</returns>
        public spResult ExecuteSP(int accountID)
        {
            var myData = new DalManager();
             var myResult = new spR_Get_Account_Info_by_AccountID_Result();
             if (myData.GetConnection(out _mySQLConn)) return null;
             try
             {
                 using (var myAccessCommand = new SqlCommand(_storedProcedureName, _mySQLConn))
                 {
                     myAccessCommand.CommandType = System.Data.CommandType.StoredProcedure;
                     myAccessCommand.Parameters.AddWithValue("@AccountID", accountID);

                     _mySQLConn.Open();
                     using (var dr = new SafeDataReader(myAccessCommand.ExecuteReader()))
                     {
                         var rdrResult = Mapper.Map<List<RenterAccountDTO>>(dr);
                         _myDTO = rdrResult.FirstOrDefault();
                         myResult.RowsReturned = rdrResult.Count;
                        // Get the next resultset (Cards) from the DataReader
                        dr.NextResult();
                        LoadRenterData(dr);
                        dr.NextResult();
                        LoadAddresses(dr);
                        dr.NextResult();
                        LoadContactInfoItems(dr);

                        myResult.ResultSet = _myDTO;
                     }
                    }
                return myResult;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: Failed to act on the data in the DataBase.\n{0}", ex.Message);
                myResult.ErrorMessage = CreateUIMessage(ex.Message);
                return myResult;
            }
            finally
            {
                _mySQLConn.Close();
            }
        }
示例#4
0
        /// <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)
                    });
            }
        }
示例#5
0
        /// <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);
            }
        }
示例#6
0
        /// <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);
                }
            }
        }
        private void BindAttackData()
        {
            using (SqlConnection cn = new SqlConnection( Database.AphelionTriggerConnection ))
            {
                cn.Open();
                using (SqlCommand cm = cn.CreateCommand())
                {
                    cm.CommandText = "GetAttackData";
                    cm.CommandType = CommandType.StoredProcedure;
                    cm.Parameters.AddWithValue( "@AttackerHouseID", _attackerHouseId );
                    cm.Parameters.AddWithValue( "@DefenderHouseID", _defenderHouseId );

                    using (SafeDataReader dr = new SafeDataReader( cm.ExecuteReader() ))
                    {
                        while (dr.Read())
                        {
                            _attackerHouse = new House(
                                dr.GetInt32( "ID" ),
                                dr.GetInt32( "UserID" ),
                                dr.GetInt32( "FactionID" ),
                                dr.GetString( "Faction" ),
                                dr.GetString( "FactionDisplay" ),
                                dr.GetString( "Name" ),
                                dr.GetInt32( "Intelligence" ),
                                dr.GetInt32( "Power" ),
                                dr.GetInt32( "Protection" ),
                                dr.GetInt32( "Affluence" ),
                                dr.GetInt32( "Speed" ),
                                dr.GetInt32( "Contingency" ),
                                dr.GetInt32( "LevelID" ),
                                (double)dr.GetDecimal( "Ambition" ),
                                dr.GetInt32( "Turns" ),
                                dr.GetInt32( "Credits" ),
                                dr.GetInt32( "MilitiaCount" ),
                                dr.GetInt32( "MilitaryCount" ),
                                dr.GetInt32( "MercenaryCount" ),
                                dr.GetInt32( "AgentCount" ),
                                dr.GetInt32( "Rank" ),
                                dr.GetInt32( "LastRank" ),
                                dr.GetInt32( "Points" ),
                                dr.GetInt32( "Experience" ),
                                dr.GetInt32( "Attack" ),
                                dr.GetInt32( "Defense" ),
                                dr.GetInt32( "Capture" ),
                                dr.GetInt32( "Plunder" ),
                                dr.GetInt32( "Stun" ),
                                dr.GetInt32( "GuildID" ),
                                dr.GetString( "Guild" ),
                                dr.GetString( "SmallFactionIconPath" ),
                                dr.GetInt32( "VotedFactionLeaderHouseID" ),
                                dr.GetInt32( "FactionLeaderHouseID" ),
                                dr.GetInt32( "FactionVotingPower" ) );
                        }

                        if (dr.NextResult())
                        {
                            while (dr.Read())
                            {
                                if (dr.GetInt32( "Count" ) > 0)
                                {
                                    _attackerForces.Add( new Unit(
                                        dr.GetInt32( "ID" ),
                                        dr.GetInt32( "FactionID" ),
                                        dr.GetInt32( "UnitClassID" ),
                                        dr.GetString( "Name" ),
                                        dr.GetString( "Description" ),
                                        dr.GetString( "Faction" ),
                                        dr.GetString( "UnitClass" ),
                                        dr.GetInt32( "Cost" ),
                                        dr.GetInt32( "Attack" ),
                                        dr.GetInt32( "Defense" ),
                                        dr.GetInt32( "Plunder" ),
                                        dr.GetInt32( "Capture" ),
                                        dr.GetInt32( "Stun" ),
                                        dr.GetInt32( "Experience" ),
                                        dr.GetDecimal( "RepopulationRate" ),
                                        dr.GetDecimal( "DepopulationRate" ),
                                        dr.GetInt32( "Count" ),
                                        dr.GetInt32( "AttackTech" ),
                                        dr.GetInt32( "DefenseTech" ),
                                        dr.GetInt32( "CaptureTech" ),
                                        dr.GetInt32( "PlunderTech" ),
                                        dr.GetInt32( "StunTech" ),
                                        dr.GetInt32( "ExperienceTech" ),
                                        dr.GetDecimal( "RepopulationRateTech" ),
                                        dr.GetDecimal( "DepopulationRateTech" ) ) );
                                }
                            }
                        }
                        else
                        {
                            throw new DataPortalException( "Attacker House has no forces to attack with.", this );
                        }

                        if (dr.NextResult())
                        {
                            while (dr.Read())
                            {
                                _attackerTechnologies.Add( new Technology(
                                    dr.GetInt32( "ID" ),
                                    dr.GetInt32( "FactionID" ),
                                    dr.GetInt32( "HouseID" ),
                                    dr.GetInt32( "GuildID" ),
                                    dr.GetInt32( "TechnologyTypeID" ),
                                    dr.GetInt32( "UnitID" ),
                                    dr.GetInt32( "UnitClassID" ),
                                    dr.GetString( "Name" ),
                                    dr.GetString( "Faction" ),
                                    dr.GetString( "House" ),
                                    dr.GetString( "Guild" ),
                                    dr.GetString( "Description" ),
                                    dr.GetString( "TechnologyType" ),
                                    dr.GetString( "Unit" ),
                                    dr.GetString( "UnitClass" ),
                                    dr.GetInt32( "Attack" ),
                                    dr.GetInt32( "Defense" ),
                                    dr.GetInt32( "Plunder" ),
                                    dr.GetInt32( "Capture" ),
                                    dr.GetInt32( "Stun" ),
                                    dr.GetInt32( "Experience" ),
                                    dr.GetDecimal( "RepopulationRate" ),
                                    dr.GetDecimal( "DepopulationRate" ),
                                    dr.GetInt32( "ResearchCost" ),
                                    dr.GetInt32( "ResearchTime" ),
                                    dr.GetInt32( "ResearchTurns" ),
                                    dr.GetInt32( "TimeSpent" ),
                                    dr.GetInt32( "TurnsSpent" ),
                                    dr.GetInt32( "CreditsSpent" ),
                                    dr.GetInt32( "ResearchStateID" ),
                                    dr.GetString( "ResearchState" ),
                                    dr.GetSmartDate( "ResearchStartedDate" ) ) );
                            }
                        }

                        if (dr.NextResult())
                        {
                            while (dr.Read())
                            {
                                _defenderHouse = new House(
                                    dr.GetInt32( "ID" ),
                                    dr.GetInt32( "UserID" ),
                                    dr.GetInt32( "FactionID" ),
                                    dr.GetString( "Faction" ),
                                    dr.GetString( "FactionDisplay" ),
                                    dr.GetString( "Name" ),
                                    dr.GetInt32( "Intelligence" ),
                                    dr.GetInt32( "Power" ),
                                    dr.GetInt32( "Protection" ),
                                    dr.GetInt32( "Affluence" ),
                                    dr.GetInt32( "Speed" ),
                                    dr.GetInt32( "Contingency" ),
                                    dr.GetInt32( "LevelID" ),
                                    (double)dr.GetDecimal( "Ambition" ),
                                    dr.GetInt32( "Turns" ),
                                    dr.GetInt32( "Credits" ),
                                    dr.GetInt32( "MilitiaCount" ),
                                    dr.GetInt32( "MilitaryCount" ),
                                    dr.GetInt32( "MercenaryCount" ),
                                    dr.GetInt32( "AgentCount" ),
                                    dr.GetInt32( "Rank" ),
                                    dr.GetInt32( "LastRank" ),
                                    dr.GetInt32( "Points" ),
                                    dr.GetInt32( "Experience" ),
                                    dr.GetInt32( "Attack" ),
                                    dr.GetInt32( "Defense" ),
                                    dr.GetInt32( "Capture" ),
                                    dr.GetInt32( "Plunder" ),
                                    dr.GetInt32( "Stun" ),
                                    dr.GetInt32( "GuildID" ),
                                    dr.GetString( "Guild" ),
                                    dr.GetString( "SmallFactionIconPath" ),
                                    dr.GetInt32( "VotedFactionLeaderHouseID" ),
                                    dr.GetInt32( "FactionLeaderHouseID" ),
                                    dr.GetInt32( "FactionVotingPower" ) );
                            }
                        }
                        else
                        {
                            throw new DataPortalException( "Defender House not found.", this );
                        }

                        if (dr.NextResult())
                        {
                            while (dr.Read())
                            {
                                if (dr.GetInt32( "Count" ) > 0)
                                {
                                    _defenderForces.Add( new Unit(
                                        dr.GetInt32( "ID" ),
                                        dr.GetInt32( "FactionID" ),
                                        dr.GetInt32( "UnitClassID" ),
                                        dr.GetString( "Name" ),
                                        dr.GetString( "Description" ),
                                        dr.GetString( "Faction" ),
                                        dr.GetString( "UnitClass" ),
                                        dr.GetInt32( "Cost" ),
                                        dr.GetInt32( "Attack" ),
                                        dr.GetInt32( "Defense" ),
                                        dr.GetInt32( "Plunder" ),
                                        dr.GetInt32( "Capture" ),
                                        dr.GetInt32( "Stun" ),
                                        dr.GetInt32( "Experience" ),
                                        dr.GetDecimal( "RepopulationRate" ),
                                        dr.GetDecimal( "DepopulationRate" ),
                                        dr.GetInt32( "Count" ),
                                        dr.GetInt32( "AttackTech" ),
                                        dr.GetInt32( "DefenseTech" ),
                                        dr.GetInt32( "CaptureTech" ),
                                        dr.GetInt32( "StunTech" ),
                                        dr.GetInt32( "PlunderTech" ),
                                        dr.GetInt32( "ExperienceTech" ),
                                        dr.GetDecimal( "RepopulationRateTech" ),
                                        dr.GetDecimal( "DepopulationRateTech" ) ) );
                                }
                            }
                        }

                        if (dr.NextResult())
                        {
                            while (dr.Read())
                            {
                                _defenderTechnologies.Add( new Technology(
                                    dr.GetInt32( "ID" ),
                                    dr.GetInt32( "FactionID" ),
                                    dr.GetInt32( "HouseID" ),
                                    dr.GetInt32( "GuildID" ),
                                    dr.GetInt32( "TechnologyTypeID" ),
                                    dr.GetInt32( "UnitID" ),
                                    dr.GetInt32( "UnitClassID" ),
                                    dr.GetString( "Name" ),
                                    dr.GetString( "Faction" ),
                                    dr.GetString( "House" ),
                                    dr.GetString( "Guild" ),
                                    dr.GetString( "Description" ),
                                    dr.GetString( "TechnologyType" ),
                                    dr.GetString( "Unit" ),
                                    dr.GetString( "UnitClass" ),
                                    dr.GetInt32( "Attack" ),
                                    dr.GetInt32( "Defense" ),
                                    dr.GetInt32( "Plunder" ),
                                    dr.GetInt32( "Capture" ),
                                    dr.GetInt32( "Stun" ),
                                    dr.GetInt32( "Experience" ),
                                    dr.GetDecimal( "RepopulationRate" ),
                                    dr.GetDecimal( "DepopulationRate" ),
                                    dr.GetInt32( "ResearchCost" ),
                                    dr.GetInt32( "ResearchTime" ),
                                    dr.GetInt32( "ResearchTurns" ),
                                    dr.GetInt32( "TimeSpent" ),
                                    dr.GetInt32( "TurnsSpent" ),
                                    dr.GetInt32( "CreditsSpent" ),
                                    dr.GetInt32( "ResearchStateID" ),
                                    dr.GetString( "ResearchState" ),
                                    dr.GetSmartDate( "ResearchStartedDate" ) ) );
                            }
                        }
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Retrieves cross ref fields.
        /// </summary>
        /// <param name="processId">The process id.</param>
        /// <param name="crossRefProcessGuid">The cross ref process GUID.</param>
        /// <param name="includeInheritedFields">The include inherited fields.</param>
        /// <returns>The <see cref="IList" />.</returns>
        public IList<CrossRefFieldDto> FetchCrossRefFields(int processId, Guid crossRefProcessGuid = new Guid(), bool includeInheritedFields = false)
        {
            var result = new List<CrossRefFieldDto>();

            string cmdText;

            if (crossRefProcessGuid == Guid.Empty)
            {
                if (includeInheritedFields)
                {
                    cmdText = @"
WITH ProcessList(
    Id,
    PublishedProcessId,
    IsBase
)
AS
(
    SELECT p.Id AS Id,
           pp.Id AS PublishedProcessId,
           0 AS IsBase
    FROM   Processes p
    LEFT OUTER JOIN PublishedProcesses pp ON  pp.Id = p.BaseProcessId
    WHERE  p.Id = @processId

    UNION ALL

    SELECT pp.ProcessId,
           pp.Id AS PublishedProcessId,
           1 AS IsBase
    FROM   Processes p
       INNER JOIN PublishedProcesses pp
            ON  p.BaseProcessId = pp.Id
       INNER JOIN processes p1
            ON  pp.ProcessId = p1.Id
       INNER JOIN ProcessList pl
            ON  p.id = pl.Id
)
SELECT f.[Name]
     , f.[SystemName]
     , f.[Id]
     , x.[AllowMultiple]
     , x.[DisplayFieldName]
     , p.[SystemName]
     , p.[Id]
FROM [dbo].[Sections] s
INNER JOIN ProcessList pl ON s.ProcessId = pl.Id
INNER JOIN [dbo].[Fields] f ON s.[Id] = f.[SectionId]
INNER JOIN [dbo].[CrossRefRequredFieldStep] x ON f.[Id] = x.[FieldId]
INNER JOIN [dbo].[PublishedProcesses] [pp] ON [pp].[Id] = x.CrossRefProcessId
INNER JOIN [dbo].[Processes] [p] ON [p].[Id] = pp.ProcessId";
                }
                else
                {
                    cmdText = @"
SELECT f.[Name]
     , f.[SystemName]
     , f.[Id]
     , x.[AllowMultiple]
     , x.[DisplayFieldName]
     , p.[SystemName]
     , p.[Id]
FROM [dbo].[Sections] s
INNER JOIN [dbo].[Fields] f ON s.[Id] = f.[SectionId]
INNER JOIN [dbo].[CrossRefRequredFieldStep] x ON f.[Id] = x.[FieldId]
INNER JOIN [dbo].[PublishedProcesses] [pp] ON [pp].[Id] = x.CrossRefProcessId
INNER JOIN [dbo].[Processes] [p] ON [p].[Id] = pp.ProcessId
WHERE s.[ProcessId] = @processId";
                }
            }
            else
            {
                cmdText = @"
DECLARE @pp_id INT
SELECT @pp_id = pp.[Id] FROM [dbo].[PublishedProcesses] pp WHERE pp.[ProcessGuid] = @crossRefProcessGuid

SELECT f.[Name]
     , f.[SystemName]
     , f.[Id]
     , x.[AllowMultiple]
     , x.[DisplayFieldName]
     , p.[SystemName]
     , p.[Id]
FROM [dbo].[Sections] s
INNER JOIN [dbo].[Fields] f ON s.[Id] = f.[SectionId]
INNER JOIN [dbo].[CrossRefRequredFieldStep] x ON f.[Id] = x.[FieldId]
INNER JOIN [dbo].[PublishedProcesses] [pp] ON [pp].[Id] = x.CrossRefProcessId
INNER JOIN [dbo].[Processes] [p] ON [p].[Id] = pp.ProcessId
WHERE s.[ProcessId] = @processId AND x.[CrossRefProcessId] = @pp_id

DECLARE @pp_systemName NVARCHAR(200)
SELECT @pp_systemName = p.[SystemName] FROM [dbo].[Processes] p WHERE p.[Guid] = @crossRefProcessGuid

SELECT f.[Name]
     , f.[SystemName]
     , f.[Id]
     , p.[SystemName]
     , p.[Id]
FROM [dbo].[Sections] s
INNER JOIN [dbo].[Fields] f ON s.[Id] = f.[SectionId]
INNER JOIN [dbo].[stepChecklist] x ON f.[Id] = x.[FieldId]
INNER JOIN [dbo].[Processes] p ON p.[IsRemoved] = 0 AND p.[IsPublishedCopy] = 1 AND p.[SystemName] = x.[AnswerProcessSystemName]
WHERE s.[ProcessId] = @processId AND x.[AnswerProcessSystemName] = @pp_SystemName";
            }

            cmdText += @"

";

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var cn = ctx.Connection;

                using (var cmd = new SqlCommand(cmdText, cn))
                {
                    cmd.Parameters.AddWithValue("@processId", processId);
                    cmd.Parameters.AddWithValue("@crossRefProcessGuid", crossRefProcessGuid);

                    using (var reader = new SafeDataReader(cmd.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            result.Add(new CrossRefFieldDto
                                           {
                                               Name = reader.GetString(0),
                                               SystemName = reader.GetString(1),
                                               FieldId = reader.GetInt(2),
                                               AllowMany = reader.GetBoolean(3),
                                               DisplayField = reader.GetString(4),
                                               ProcessSystemName = reader.GetString(5),
                                               ProcessId = reader.GetInt(6),
                                               ColumnType = reader.GetBoolean(3) ? ColumnTypes.MultiReference : ColumnTypes.Reference
                                           });
                        }

                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                result.Add(new CrossRefFieldDto
                                               {
                                                   Name = reader.GetString(0),
                                                   SystemName = reader.GetString(1),
                                                   FieldId = reader.GetInt32(2),
                                                   ProcessSystemName = reader.GetString(3),
                                                   ProcessId = reader.GetInt32(4),
                                                   ColumnType = ColumnTypes.Checklist
                                               });
                            }
                        }
                    }
                }
            }

            return result;
        }
示例#9
0
        /// <summary>
        /// Fetches reverse cross ref list.
        /// </summary>
        /// <param name="processGuid">The process GUID.</param>
        /// <returns>The <see cref="IList" />.</returns>
        public IList<PublishedProcessInfoDTO> FetchReverseCrossRefList(Guid processGuid)
        {
            var result = new List<PublishedProcessInfoDTO>();
            const string CmdText =
                @"
-- Select processes with cross reference fields
DECLARE @pp_id INT
SELECT @pp_id = pp.[Id] FROM [dbo].[PublishedProcesses] pp WHERE pp.[ProcessGuid] = @processGuid

SELECT pp.[Id]
      ,p.[Name]
      ,p.[SystemName]
      ,p.[Id]
      ,p.[IsStateEnabled]
      ,p.[ProcessOption]
FROM [dbo].[PublishedProcesses] pp
INNER JOIN [dbo].[Processes] p ON p.[Id] = pp.[ProcessId]
INNER JOIN (SELECT DISTINCT s.[ProcessId] AS [Id]
FROM [dbo].[Sections] s
INNER JOIN [dbo].[Fields] f on f.[SectionId] = s.[Id]
INNER JOIN [dbo].[CrossRefRequredFieldStep] x on x.[FieldId] = f.[Id]
WHERE x.[CrossRefProcessId] = @pp_id) pu ON p.[Id] = pu.[Id]
WHERE pp.Id <> @pp_id

-- Select processes with checklist fields
DECLARE @pp_systemName AS NVARCHAR(200)
SELECT @pp_systemName = p.[SystemName] FROM [dbo].[Processes] p WHERE p.[Guid] = @processGuid AND p.[IsPublishedCopy] = 1 AND p.[IsRemoved] = 0

SELECT pp.[Id]
    ,p.[Name]
    ,p.[SystemName]
    ,p.[Id]
    ,p.[IsStateEnabled]
    ,p.[ProcessOption]
FROM [dbo].[PublishedProcesses] pp
INNER JOIN [dbo].[Processes] p ON p.[Id] = pp.[ProcessId]
INNER JOIN (SELECT DISTINCT s.[ProcessId] AS [Id]
FROM [dbo].[Sections] s
INNER JOIN [dbo].[Fields] f on f.[SectionId] = s.[Id]
INNER JOIN [dbo].[stepChecklist] x on x.[FieldId] = f.[Id]
WHERE x.[AnswerProcessSystemName] = @pp_systemName) pu ON p.[Id] = pu.[Id]
WHERE pp.Id <> @pp_id";

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var cn = ctx.Connection;

                using (var cmd = new SqlCommand(CmdText, cn))
                {
                    cmd.Parameters.AddWithValue("@processGuid", processGuid);

                    using (var reader = new SafeDataReader(cmd.ExecuteReader()))
                    {
                        do
                        {
                            while (reader.Read())
                            {
                                var dto = new PublishedProcessInfoDTO
                                              {
                                                  Id = reader.GetInt(0),
                                                  Name = reader.GetString(1),
                                                  SystemName = reader.GetString(2),
                                                  ProcessId = reader.GetInt(3),
                                                  IsStateEnabled = reader.GetBool(4),
                                                  ProcessOption = reader.GetEnum(5, ProcessOption.None)
                                              };

                                if (result.All(x => x.Id != dto.Id))
                                {
                                    result.Add(dto);
                                }
                            }
                        }
                        while (reader.NextResult());
                    }
                }
            }

            return result;
        }
示例#10
0
        /// <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);
        }
示例#11
0
        /// <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);
            }
        }
示例#12
0
        /// <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)
                       });
            }
        }
示例#13
0
        /// <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);
                }
            }
        }
示例#14
0
        /// <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)
                    });
            }
        }
示例#15
0
        /// <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);
            }
        }
示例#16
0
        /// <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);
            }
        }
示例#17
0
        /// <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;
        }
示例#18
0
        /// <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)
                });
            }
        }
示例#19
0
        /// <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);
        }
示例#20
0
        /// <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),
                });
            }
        }
示例#21
0
        /// <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));
        }
示例#22
0
        /// <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);
            }
        }
示例#23
0
        /// <summary>
        /// Populates the result for SQL oracle.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>List{FieldInfoDto}.</returns>
        private List<FieldInfoDto> PopulateResultForSqlOracle(SafeDataReader reader)
        {
            var result = new List<FieldInfoDto>();
            while (reader.Read())
            {
                result.Add(new FieldInfoDto
                {
                    Name = reader.GetString(1),
                    SystemName = "\"" + reader.GetString(2) + "\"",
                    FieldTypeId = reader.GetInt32(3),
                    ProcessID = reader.GetInt32(4),
                    ProcessName = reader.GetString(5),
                    ProcessSystemName = "\"" + reader.GetString(6) + "\"",
                    DefinedIn = reader.GetString(8),
                    DataType = reader.GetString(9),
                    Guid = reader.GetGuid(10),
                    IsRichTextField = reader.GetBoolean(11),
                });
            }

            if (reader.NextResult() && reader.Read())
            {
                //var baseProcessId = reader.GetInt32(0);
                result.AddRange(FetchFieldList());
            }

            return result;
        }
示例#24
0
        /// <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);
            }
        }
示例#25
0
        public IList<FieldInfoDto> FetchFieldList(int processId, bool includeInheritedFields, bool includeSystemFields)
        {
            var result = new List<FieldInfoDto>();

            var cmdText = new StringBuilder(@"
SELECT DISTINCT f.[Id],
       f.[Name],
       f.[SystemName],
       f.[FieldTypeId], 
       p.[BaseProcessId],
       p.[SystemName],
       CASE
            WHEN f.[FieldTypeId] = 6 AND ISNULL(crrs.AllowMultiple, 0) = 1 THEN 
                          'MultiReference'                          
            WHEN f.[FieldTypeId] = 9 AND ISNULL(rcrrs.DisplayMultiple, 0) = 1 THEN 
                          'ReverseMultiReference'
            WHEN f.[FieldTypeId] = 1 AND ISNULL(nr.[NumberOfDigits], 0) = 0 AND ISNULL(nr.[Minimum], 0) >= @intMin AND ISNULL(nr.[Maximum], 0) <= @intMax AND ISNULL(nr.[NumericType], 0) = 0 THEN
                          'Integer'
            ELSE ft.[DataType]
       END,
       f.Guid,
       sto.[UseRichText],
       CASE
           WHEN LEN(ISNULL(CAST(es.[CalculatedExpression] AS NVARCHAR(MAX)), '')) > 0 THEN CAST(1 AS BIT)
           ELSE CAST(0 AS BIT)
       END AS 'IsCalculated',
       (SELECT CAST(
            CASE WHEN
                EXISTS (
                    SELECT * from [dbo].[RequiredRuleConfigFields] rrcf
                        INNER JOIN [dbo].[RequiredRuleConfigs] rrc on rrc.[Id] = rrcf.[RequiredConfigId]
                    WHERE rrc.[ProcessId] = p.[Id] and rrcf.[FieldGuid] = f.[Guid])
                THEN 1
                ELSE 0
            END AS BIT)) as [IsRequired],
       CAST(0 AS BIT) AS [IsBuiltIn]
      ,f.[IncludeInFilter]
      ,(SELECT p.[SystemName]
        FROM [dbo].[Processes] p
            INNER JOIN [dbo].[PublishedProcesses] pp ON pp.[ProcessId] = p.[Id]
        WHERE pp.[Id] = CASE
                            WHEN f.[FieldTypeId] = 6 THEN crrs.[CrossRefProcessId]
                            WHEN f.[FieldTypeId] = 9 THEN rcrrs.[ReverseCrossRefProcessId]
                            WHEN f.[FieldTypeId] = 24 THEN tvrs.[ReverseCrossRefProcessId]
                            ELSE NULL
                        END
        ) AS [ReferencedProcessSystemName]
      ,drs.[DateTimeFormat] AS [DateTimeFormat]
      ,CASE
            WHEN f.[FieldTypeId] = 9 THEN rcrrs.[CrossRefFieldName]
            WHEN f.[FieldTypeId] = 24 THEN tvrs.[CrossRefFieldName]
       END AS [CrossReferenceFieldName]
      ,CASE
            WHEN f.[FieldTypeId] = 6 THEN crrs.[DisplayFieldName]
            WHEN f.[FieldTypeId] = 9 THEN rcrrs.[DisplayFieldName]
            WHEN f.[FieldTypeId] = 24 THEN tvrs.[DisplayFieldName]
            ELSE NULL
       END AS [DisplayFieldName]
FROM   [dbo].[Fields] f
       INNER JOIN [dbo].[Sections] s ON  f.[SectionId] = s.[Id]
       INNER JOIN [dbo].[Processes] p ON  s.[ProcessId] = p.[Id]
       INNER JOIN [dbo].[PublishedProcesses] pp on p.Id = pp.[ProcessId]
       INNER JOIN [dbo].[FieldTypes] ft ON ft.[Id] = f.[FieldTypeId]
       LEFT JOIN [dbo].[CrossRefRequredFieldStep] crrs ON crrs.[FieldId] = f.[Id] AND f.[FieldTypeId] = 6
       LEFT JOIN [dbo].[ReverseCrossRefRequiredFieldStep] rcrrs ON rcrrs.[FieldId] = f.[Id] AND f.[FieldTypeId] = 9
       LEFT JOIN [dbo].[stepTextOptions] sto ON sto.[FieldId] = f.[Id]
       LEFT JOIN [dbo].[stepExpressions] es ON es.[FieldId] = f.[Id]
       LEFT JOIN [dbo].[NumericRequiredFieldStep] nr ON nr.[FieldId] = f.[Id]
       LEFT JOIN [dbo].[TreeViewRequiredFieldStep] tvrs ON tvrs.[FieldId] = f.[Id]
       LEFT JOIN [dbo].[stepDateRequiredSettings] drs ON drs.[FieldId] = f.[Id]
WHERE  pp.[ProcessId] = @processId
       AND f.[IsRemoved] = 0

UNION

SELECT
    0 [Id],
    'Id' Name,
    'Id' SystemName,
    (SELECT [Id] FROM FieldTypes WHERE [DataType] = 'Numeric') FieldTypeId,
    NULL BaseProcessId,
    (SELECT SystemName FROM Processes p WHERE p.[Id] = @processId) ProcessSystemName,
    'Integer' DataType,
    '00000000-0000-0000-0000-000000000000' [Guid],
    CAST(0 AS BIT) UseRichText,
    CAST(0 AS BIT) IsCalculated,
    CAST(0 AS BIT) IsRequired,
    CAST(1 AS BIT) AS [IsBuiltIn]
   ,CAST(1 AS BIT) AS [IncludeInFilter]
   ,NULL AS [ReferencedProcessSystemName]
   ,NULL AS [DateTimeFormat]
   ,NULL AS [CrossReferenceFieldName]
   ,NULL AS [DisplayFieldName]
");

            if (includeSystemFields)
            {
                cmdText.AppendLine().Append("UNION").AppendLine().Append(GetSystemFieldsSelect());
            }

            cmdText.AppendLine().Append(@"
SELECT pp.ProcessId
FROM   Processes p
       INNER JOIN PublishedProcesses pp ON  pp.Id = p.BaseProcessId
       INNER JOIN Processes p2 ON p2.Id = pp.ProcessId AND p2.IsRemoved = 0
WHERE  p.id = @processId");

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var cn = ctx.Connection;

                using (var cmd = new SqlCommand(cmdText.ToString(), cn))
                {
                    cmd.Parameters.AddWithValue("@processId", processId);
                    cmd.Parameters.AddWithValue("@intMin", int.MinValue);
                    cmd.Parameters.AddWithValue("@intMax", int.MaxValue);

                    using (var reader = new SafeDataReader(cmd.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            result.Add(ReadFieldInfo(reader));
                        }

                        if (includeInheritedFields && reader.NextResult() && reader.Read())
                        {
                            var baseProcessId = reader.GetInt32(0);
                            result.AddRange(this.FetchFieldList(baseProcessId, true, includeSystemFields));
                        }
                    }
                }
            }

            return result.Distinct(new FieldInfoDtoEqualityComparer(x => x.SystemName)).ToList();
        }
示例#26
0
        /// <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);
        }
示例#27
0
        /// <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;
        }
示例#28
0
        /// <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);
            }*/
        }
示例#29
0
        /// <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);
            }
        }
示例#30
0
        /// <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);
                }
            }
        }