コード例 #1
0
        private static ArasDb GetDevelopmentDb(string slnDir)
        {
            ArasDb developmentDb = null;

            foreach (var mfFile in new[] { "arasdb-local.json", "arasdb.json" })
            {
                var mfFilePath = Path.Combine(slnDir, mfFile);
                if (!File.Exists(mfFilePath))
                {
                    continue;
                }

                try
                {
                    var json     = File.ReadAllText(mfFilePath);
                    var arasdbmf = JsonConvert.DeserializeObject <ArasConfManifest>(json);
                    developmentDb = arasdbmf.Instances.Single(db => db.Id == arasdbmf.DevelopmentInstance);
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{mfFile}: {e.Message}");
                }
            }

            if (developmentDb == null)
            {
                throw new ArasException("Aras development database not properly defined in arasdb[-local].json");
            }
            return(developmentDb);
        }
コード例 #2
0
        internal static void Export(ArasDb arasDb, LoginInfo loginInfo, string exportDir,
                                    string mfFile, int timeout = 30000)
        {
            string pkgName;

            using (var fs = new FileStream(mfFile, FileMode.Open))
            {
                var xd = XDocument.Load(fs);
                pkgName = xd.Root?.XPathSelectElement("//package")?.Attribute("name")?.Value ?? "";

                // TODO: Configure in arasdb.json?
                if (pkgName.StartsWith("com.aras") ||
                    pkgName.StartsWith("Minerva"))
                {
                    Console.WriteLine($"Not exporting package {pkgName}, as partial export is not supported");
                    return;
                }
            }

            Console.WriteLine($"Exporting package {pkgName} via {Path.GetFileName(mfFile)} ...");

            string nullStr = null;
            var    rval    = Common.RunProcess(ConsoleUpgradeExe, false, ref nullStr,
                                               $"server={arasDb.Url}",
                                               $"database={arasDb.DbName}",
                                               $"login={loginInfo.Username}",
                                               $"password={loginInfo.Password}",
                                               // "export",
                                               $"dir={exportDir}",
                                               $"mfFile={mfFile}",
                                               "verbose",
                                               $"timeout={timeout}");

            if (rval != 0)
            {
                throw new UserMessageException($"ConsoleUpgrade.exe failed with {rval}.");
            }
        }
コード例 #3
0
        internal static void Import(ArasDb arasDb, LoginInfo loginInfo, string exportDir,
                                    string mfFile, string releaseInfo, int timeout = 30000)
        {
            Console.WriteLine($"Importing {Path.GetFileName(mfFile)}...\n");

            string nullStr = null;
            var    rval    = Common.RunProcess(ConsoleUpgradeExe, false, ref nullStr,
                                               $"server={arasDb.Url}",
                                               $"database={arasDb.DbName}",
                                               $"login={loginInfo.Username}",
                                               $"password={loginInfo.Password}",
                                               "import",
                                               $"dir={exportDir}",
                                               $"mfFile={mfFile}",
                                               $"release={releaseInfo}",
                                               "merge",
                                               $"timeout={timeout}");

            if (rval != 0)
            {
                throw new UserMessageException($"ConsoleUpgrade.exe failed with {rval}.");
            }
        }
コード例 #4
0
        public override int Run(string[] remainingArguments)
        {
            if (Database == null && Dir == null || (Database != null && Dir != null))
            {
                throw new UserMessageException("You must specify one and only one of --db or --dir");
            }

            Common.RequireArasFeatureManifest();
            var featureName = Common.GetFeatureName();

            var csproj = Directory.EnumerateFiles(Environment.CurrentDirectory, "*.csproj")
                         .SingleOrDefault();

            if (csproj == null)
            {
                Console.WriteLine("No (or multiple) .csproj found. Cannot continue.");
                return(0);
            }

            if (Build)
            {
                Console.WriteLine($"Building {featureName} in {BuildConfig}...\n");


                string nullStr = null;
                if (Common.RunProcess(Common.MSBuildCmd, false, ref nullStr,
                                      csproj,
                                      $"/p:Configuration={BuildConfig}",
                                      "/verbosity:minimal",
                                      "/filelogger",
                                      "/nologo") != 0)
                {
                    throw new UserMessageException("Build failed");
                }
            }

            var    sourceFolder = Path.Combine(Environment.CurrentDirectory, "bin", BuildConfig);
            var    targetFolder = Dir;
            ArasDb arasDb       = null;

            if (Database != null)
            {
                Common.RequireLoginInfo(); // enforce logged in. Not same permissions as filecopy though, but something.
                arasDb       = Config.FindDb(Database);
                targetFolder = Path.Combine(arasDb.BinFolder, "Innovator", "server", "bin");
            }
            else if (Dir != null)
            {
                targetFolder = Path.IsPathRooted(Dir) ? Dir : Path.Combine(Environment.CurrentDirectory, Dir);
                Confirm      = false;
            }

            if (targetFolder == null)
            {
                throw new ArgumentNullException(nameof(targetFolder), "internal error");
            }

            var info = Config.GetDeployDllInfo();

            Console.WriteLine($"About to copy [{string.Join(",", info.Extensions.Distinct().Select(e => $"*{e}"))}]\n" +
                              $"  from: {sourceFolder}\n" +
                              $"  to:   {targetFolder}");

            if (Dir != null && !Directory.Exists(targetFolder))
            {
                Console.WriteLine($"\nCreating {targetFolder} ...");
                Directory.CreateDirectory(targetFolder);
            }

            if (Confirm)
            {
                // ReSharper disable once PossibleNullReferenceException
                Common.RequestUserConfirmation($"copy {BuildConfig} DLLs for '{featureName}' to Aras server '{arasDb.Id}'");
            }
            else
            {
                Console.WriteLine();
            }

            // Copy build files
            var count = 0;

            foreach (var filename in Directory.EnumerateFiles(sourceFolder)
                     .Select(Path.GetFileName)
                     .Where(file => info.Extensions.Contains(Path.GetExtension(file)?.ToLowerInvariant()))
                     .Where(file => !info.Excludes.Any(file.Contains)))
            {
                Common.CopyFileWithProgress(
                    Path.Combine(sourceFolder, filename),
                    Path.Combine(targetFolder, filename));
                count++;
            }

            Console.WriteLine($"\n{count} file(s) copied.");

            // Upload docs too

            if (!Doc)
            {
                return(0);
            }

            var uploadDoc = new UploadDocCommand
            {
                Database    = Database,
                Dir         = Dir,
                Confirm     = false,
                Build       = false, // don't build twice
                BuildConfig = BuildConfig,
            };

            Console.WriteLine();
            return(uploadDoc.Run(new string[] {}));
        }