/// <summary>
        /// Generates SQL post deployment script that pushes R code into a table
        /// as well as 
        /// </summary>
        private void CreatePostDeploymentScriptFile(SqlSProcPublishSettings settings, 
            EnvDTE.Project targetProject, string targetFolder, 
            EnvDTE.ProjectItem targetProjectItem, SProcMap sprocMap) {
            var postDeploymentScript = Path.Combine(targetFolder, PostDeploymentScriptName);

            var g = new SProcScriptGenerator(_fs);
            var script = g.CreatePostDeploymentScript(settings, sprocMap);

            _fs.WriteAllText(postDeploymentScript, script);

            var item = targetProjectItem.ProjectItems.AddFromFile(postDeploymentScript);
            item.Properties.Item("BuildAction").Value = "PostDeploy";
        }
示例#2
0
        /// <summary>
        /// Generates SQL post deployment script that pushes R code into a table
        /// as well as 
        /// </summary>
        public string CreatePostDeploymentScript(SqlSProcPublishSettings settings, SProcMap sprocMap) {
            var sb = new StringBuilder();
            sb.AppendLine(Invariant($"INSERT INTO {settings.TableName.ToSqlName(settings.QuoteType)}"));

            int i = 0;
            foreach (var sprocName in sprocMap) {
                var content = sprocMap[sprocName];
                sb.Append(Invariant($"VALUES ('{sprocName.ToSqlName(settings.QuoteType)}', '{content}')"));
                if (i < sprocMap.Count - 1) {
                    sb.Append(',');
                }
                sb.AppendLine(string.Empty);
                i++;
            }
            return sb.ToString();
        }
示例#3
0
 /// <summary>
 /// Creates code for stored procedures
 /// </summary>
 public SProcMap CreateStoredProcedureScripts(SqlSProcPublishSettings settings, IEnumerable<string> sprocFiles) {
     var sprocMap = new SProcMap();
     foreach (var rFilePath in sprocFiles) {
         var sprocName = _fs.GetSProcNameFromTemplate(rFilePath);
         if (!string.IsNullOrEmpty(sprocName)) {
             string template;
             if (settings.CodePlacement == RCodePlacement.Inline) {
                 template = FillSprocInlineTemplate(rFilePath, sprocName);
             } else {
                 template = FillSprocTableTemplate(rFilePath, sprocName, settings.TableName, settings.QuoteType);
             }
             if (!string.IsNullOrEmpty(template)) {
                 sprocMap[sprocName] = template;
             }
         }
     }
     return sprocMap;
 }