Пример #1
0
        public override void Generate()
        {
            //if (_model.Database.AllowZeroTouch) return;
            try
            {
                if (this.UseSingleFile)
                {
                    //Process all views
                    var sb = new StringBuilder();
                    sb.AppendLine("--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION.");
                    sb.AppendLine();

                    if (_model.EmitSafetyScripts)
                    {
                        sb.AppendLine("--##SECTION BEGIN [INTERNAL STORED PROCS]");
                        sb.AppendLine();

                        foreach (var table in _model.Database.Tables.Where(x => x.Generated && (x.TypedTable != TypedTableConstants.EnumOnly)).OrderBy(x => x.Name))
                        {
                            var template = new SQLStoredProcedureTableAllTemplate(_model, table, true);
                            sb.Append(template.FileContent);
                        }

                        sb.AppendLine("--##SECTION END [INTERNAL STORED PROCS]");
                        sb.AppendLine();
                    }

                    var eventArgs = new ProjectItemGeneratedEventArgs("StoredProcedures.sql", sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
                    eventArgs.Properties.Add("BuildAction", 3);
                    OnProjectItemGenerated(this, eventArgs);
                }
                else
                {
                    if (_model.EmitSafetyScripts)
                    {
                        //Process all tables
                        foreach (var table in _model.Database.Tables.Where(x => x.Generated && (x.TypedTable != TypedTableConstants.EnumOnly)).OrderBy(x => x.Name))
                        {
                            var template     = new SQLStoredProcedureTableAllTemplate(_model, table, false);
                            var fullFileName = template.FileName;
                            var eventArgs    = new ProjectItemGeneratedEventArgs(fullFileName, template.FileContent, ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
                            eventArgs.Properties.Add("BuildAction", 3);
                            OnProjectItemGenerated(this, eventArgs);
                        }
                    }
                }

                var gcEventArgs = new ProjectItemGenerationCompleteEventArgs(this);
                OnGenerationComplete(this, gcEventArgs);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void Generate()
        {
            //if (_model.Database.AllowZeroTouch) return;
            try
            {
                if (this.UseSingleFile)
                {
                    //Process all views
                    var sb = new StringBuilder();
                    sb.AppendLine("--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION.");
                    sb.AppendLine();

                    if (_model.EmitSafetyScripts)
                    {
                        sb.AppendLine("--##SECTION BEGIN [INTERNAL STORED PROCS]");
                        sb.AppendLine();

                        foreach (var table in _model.Database.Tables.Where(x => x.Generated && (x.TypedTable != TypedTableConstants.EnumOnly)).OrderBy(x => x.Name))
                        {
                            var template = new SQLStoredProcedureTableAllTemplate(_model, table, true);
                            sb.Append(template.FileContent);
                        }

                        sb.AppendLine("--##SECTION END [INTERNAL STORED PROCS]");
                        sb.AppendLine();
                    }

                    var eventArgs = new ProjectItemGeneratedEventArgs("StoredProcedures.sql", sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
                    eventArgs.Properties.Add("BuildAction", 3);
                    OnProjectItemGenerated(this, eventArgs);
                }
                else
                {
                    if (_model.EmitSafetyScripts)
                    {
                        //Process all tables
                        foreach (var table in _model.Database.Tables.Where(x => x.Generated && (x.TypedTable != TypedTableConstants.EnumOnly)).OrderBy(x => x.Name))
                        {
                            var template = new SQLStoredProcedureTableAllTemplate(_model, table, false);
                            var fullFileName = template.FileName;
                            var eventArgs = new ProjectItemGeneratedEventArgs(fullFileName, template.FileContent, ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
                            eventArgs.Properties.Add("BuildAction", 3);
                            OnProjectItemGenerated(this, eventArgs);
                        }
                    }
                }

                var gcEventArgs = new ProjectItemGenerationCompleteEventArgs(this);
                OnGenerationComplete(this, gcEventArgs);
            }
            catch (Exception ex)
            {
                throw;
            }
        }