Beispiel #1
0
        public override void Generate()
        {
            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();

                    var grantSB = new StringBuilder();
                    foreach (var storedProcedure in _model.Database.CustomStoredProcedures.Where(x => x.Generated).OrderBy(x => x.Name))
                    {
                        var template = new SQLSelectStoredProcedureTemplate(_model, storedProcedure, true, grantSB);
                        sb.Append(template.FileContent);
                    }

                    //Add Grants
                    sb.Append(grantSB.ToString());

                    var eventArgs = new ProjectItemGeneratedEventArgs("StoredProcedures.sql", sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
                    eventArgs.Properties.Add("BuildAction", 3);
                    OnProjectItemGenerated(this, eventArgs);
                }
                else
                {
                    foreach (var storedProcedure in _model.Database.CustomStoredProcedures.Where(x => x.Generated).OrderBy(x => x.Name))
                    {
                        var grantSB  = new StringBuilder();
                        var template = new SQLSelectStoredProcedureTemplate(_model, storedProcedure, false, grantSB);

                        //Add grants
                        var sb = new StringBuilder();
                        sb.Append(template.FileContent);
                        sb.Append(grantSB.ToString());

                        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()
		{
			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();

					var grantSB = new StringBuilder();
					foreach (var storedProcedure in _model.Database.CustomStoredProcedures.Where(x => x.Generated).OrderBy(x => x.Name))
					{
						var template = new SQLSelectStoredProcedureTemplate(_model, storedProcedure, true, grantSB);
						sb.Append(template.FileContent);
					}

					//Add Grants
					sb.Append(grantSB.ToString());

					var eventArgs = new ProjectItemGeneratedEventArgs("StoredProcedures.sql", sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true);
					eventArgs.Properties.Add("BuildAction", 3);
					OnProjectItemGenerated(this, eventArgs);
				}
				else
				{
					foreach (var storedProcedure in _model.Database.CustomStoredProcedures.Where(x => x.Generated).OrderBy(x => x.Name))
					{
						var grantSB = new StringBuilder();
						var template = new SQLSelectStoredProcedureTemplate(_model, storedProcedure, false, grantSB);

						//Add grants
						var sb = new StringBuilder();
						sb.Append(template.FileContent);
						sb.Append(grantSB.ToString());

						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;
			}
		}