示例#1
0
        /// <summary>
        /// Adds the navigation item.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="currentGroup">The current group.</param>
        private static void AddNavigationItem(SafeDataReader reader, NavigationGroupDTO currentGroup)
        {
            var navItemDto = new NavigationItemDTO
                                 {
                                     Id = reader.GetInt32(5),
                                     Name = reader.GetString(6),
                                     SystemName = reader.GetString(7),
                                     IconId = reader.GetNullableInt(8),
                                     IconUrl = reader.GetString(9),
                                     AssemblyName = reader.GetString(10),
                                     ProcessId = reader.GetNullableInt(11),
                                     ProcessSystemName = reader.GetString(13),
                                     Description = reader.GetString(17)
                                 };
            navItemDto.Description = navItemDto.ProcessId == null ? reader.GetString("HelpText") : reader.GetString(reader.GetOrdinal("Description"));
            navItemDto.BackgroundColor = reader.GetInt64(reader.GetOrdinal("BackgroundColor"));
            navItemDto.ProcessViewGuid = reader.GetNullableGuid(reader.GetOrdinal("ProcessViewGuid"));
            navItemDto.IsSystem = reader.GetNullableBool(reader.GetOrdinal("IsSystem"));
            navItemDto.IsBeta = reader.GetBoolean(reader.GetOrdinal("IsBeta"));
            var processName = reader.GetString(12);

            if (!string.IsNullOrEmpty(processName))
                navItemDto.Name = processName;

            currentGroup.NavigationItems.Add(navItemDto);
        }
示例#2
0
        /// <summary>
        /// Saves the navigation item.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException">The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.</exception>
        public void SaveNavigationItem(NavigationItemDTO dto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
                @"
DECLARE @p_navigationItemId AS INT

SELECT @p_navigationItemId = ni.Id
FROM   NavigationItems ni
WHERE  ni.PublishedProcessId = @p_publishedProcessId 
	
IF (NOT @p_navigationItemId IS NULL)
BEGIN
    UPDATE NavigationItems
    SET   
           LastModifiedOn      = @p_LastModifiedOn
          ,Name                = @p_Name
          ,IconURL             = @p_IconUrl
          ,Sequence            = @p_Sequence
          ,NavigationGroupId   = @p_GroupId
          ,IconId              = @p_IconId
          ,PublishedProcessId  = @p_publishedProcessId
    WHERE  PublishedProcessId  = @p_publishedProcessId
END
ELSE
BEGIN
    INSERT INTO [dbo].[NavigationItems]
      (
        [LastModifiedOn]
       ,[Name]
       ,[IconURL]
       ,[Sequence]
       ,[NavigationGroupId]
       ,[IconId]
       ,[PublishedProcessId]
      )
    VALUES
      (
        @p_LastModifiedOn
       ,@p_Name
       ,@p_IconUrl
       ,@p_Sequence
       ,@p_GroupId
       ,@p_IconId
       ,@p_publishedProcessId
      )
END

SET @p_id = SCOPE_IDENTITY()
";

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var cn = ctx.Connection;
                if (cn.State != ConnectionState.Open)
                {
                    cn.Open();
                }

                using (var command = new SqlCommand(CommandText, cn))
                {
                    command.Parameters.AddWithValue("@p_LastModifiedOn", dto.LastModifiedOn);
                    command.Parameters.AddWithValue("@p_Name", dto.Name);
                    command.Parameters.AddWithValue("@p_IconUrl", dto.IconUrl);
                    command.Parameters.AddWithValue("@p_Sequence", dto.Sequence);
                    if (dto.IconId == null)
                        command.Parameters.AddWithValue("@p_IconId", DBNull.Value);
                    else
                        command.Parameters.AddWithValue("@p_IconId", dto.IconId);

                    command.Parameters.AddWithValue("@p_GroupId", dto.GroupId);
                    command.Parameters.AddWithValue("@p_publishedProcessId", dto.PublishedProcessId);
                    var idParam = new SqlParameter("@p_id", SqlDbType.Int, 0, "Id")
                                      {
                                          Direction =
                                              ParameterDirection.Output
                                      };
                    command.Parameters.Add(idParam);

                    var rowsAffetcted = command.ExecuteNonQuery();
                    if (rowsAffetcted == 0)
                        throw new DBConcurrencyException(
                            "The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.");

                    if (idParam.Value != DBNull.Value)
                        dto.Id = (int)idParam.Value;
                }
            }
        }
 public void SaveNavigationItem(NavigationItemDTO navigationItemDto)
 {
     throw new NotImplementedException();
 }