private bool DependentResolve(Action <string> addErrorMessage, long id, string tableName, string columnName, string originalTableName, SqlException exception, SqlError error)
        {
            var args = new TableParametersArgs
            {
                ConflictedTableCode  = tableName,
                ConflictedColumnCode = columnName,
                DeleteID             = id,
                DeleteTable          = originalTableName,
                Exception            = exception,
                SqlError             = error,
            };

            SetParametersByCustomCode(args, GetProjectCode(args.ConflictedTableCode), null, null);

            var result = false;

            foreach (var dependentTable in args.DependentTables)
            {
                if (!string.IsNullOrEmpty(dependentTable.Url))
                {
                    result = true;
                }
                else if (dependentTable.ID.HasValue)
                {
                    dependentTable.Url = GetUrl(dependentTable);
                    result             = true;
                }
            }

            AddErrorMessage(args, addErrorMessage);

            return(result);
        }
 private void AddErrorMessage(TableParametersArgs args, Action <string> addErrorMessage)
 {
     foreach (var dependentTable in args.DependentTables)
     {
         var link = string.Format(
             "<a href='{0}' title=\"{1}\" target='_blank'>{2}</a>",
             HttpUtility.HtmlAttributeEncode(dependentTable.Url),
             HttpUtility.HtmlAttributeEncode(dependentTable.RowName ?? dependentTable.ID.ToString()),
             HttpUtility.HtmlEncode(dependentTable.TableHeader ?? dependentTable.TableCode));
         var text = string.Format(Resources.SErrorMessage, link);
         addErrorMessage(text);
     }
 }
        private void SimpleResolve(Action <string> addErrorMessage, long id, string tableName, string columnName, string originalTableName)
        {
            var keys = GetPrimaryKeys(tableName, columnName, id);

            foreach (var key in keys.Take(10))
            {
                var args = new TableParametersArgs
                {
                    ConflictedTableCode  = tableName,
                    ConflictedColumnCode = columnName,
                    DeleteID             = id,
                    DeleteTable          = originalTableName,
                };
                var projectCode = GetProjectCode(tableName);
                args.DependentTables.Add(
                    new DependentTable
                {
                    TableCode   = tableName,
                    ProjectCode = projectCode,
                    ID          = key,
                });
                SetParametersByCustomCode(args, projectCode, null, null);

                foreach (var dependentTable in args.DependentTables)
                {
                    if (!string.IsNullOrEmpty(dependentTable.ProjectCode))
                    {
                        if (string.IsNullOrEmpty(dependentTable.TableHeader))
                        {
                            dependentTable.TableHeader = GetTableHeader(dependentTable.ProjectCode, dependentTable.TableCode, dependentTable.Version, dependentTable.PublicKeyToken);
                        }

                        if (string.IsNullOrEmpty(dependentTable.RowName))
                        {
                            dependentTable.RowName = GetRowName(dependentTable);
                        }
                    }

                    if (string.IsNullOrEmpty(dependentTable.Url))
                    {
                        dependentTable.Url = GetUrl(dependentTable);
                    }
                }

                AddErrorMessage(args, addErrorMessage);
            }
            if (keys.Count == 11)
            {
                addErrorMessage("...");
            }
        }
        private void SetParametersByCustomCode(TableParametersArgs args, string projectCode, string version, string publicKeyToken)
        {
            var type = BuildManager.GetType(
                string.Format(
                    "{0}.ReferencesConflictResolver, {0}, Version={1}, Culture=neutral, PublicKeyToken={2}",
                    projectCode,
                    version ?? InitializerSection.GetSection().DefaultVersion,
                    publicKeyToken ?? InitializerSection.GetSection().DefaultPublicKeyToken),
                false,
                true);

            if (type == null)
            {
                return;
            }

            var source = Activator.CreateInstance(type) as IReferencesConflictResolver;

            source?.OnReferenceConflictResolving(args);
        }