Exemple #1
0
        protected void InstallModelShell(string modelFile, ConflictModelResolverType resolverType)
        {
            string parameters = String.Format("import /s:{0} /db:{1} \"/file:{2}\" /conflict:{3} /noPrompt", dbServer, dbName, modelFile, resolverType.ToString());

            ProcessStartInfo processStartInfo = new ProcessStartInfo(axutilBinaryFolder + @"\axutil.exe", parameters);

            processStartInfo.WindowStyle            = ProcessWindowStyle.Minimized;
            processStartInfo.WorkingDirectory       = axutilBinaryFolder;
            processStartInfo.RedirectStandardError  = true;
            processStartInfo.RedirectStandardOutput = true;
            processStartInfo.UseShellExecute        = false;

            Process process = Process.Start(processStartInfo);
            string  error   = process.StandardError.ReadToEnd();
            string  info    = process.StandardOutput.ReadToEnd();

            try
            {
                process.WaitForExit();
                if (process.ExitCode != 0)
                {
                    throw new Exception();
                }
            }
            catch
            {
                throw new Exception(string.Format("Error installing model: {0}", string.IsNullOrEmpty(error) ? info : error));
            }
        }
Exemple #2
0
        protected void InstallModel(string modelFile, ConflictModelResolverType resolverType)
        {
            // Due to issues with appdomain assembly loading getting messed up by calling the import method,
            // currently we've disabled the use of the DLL and are using shell command instead.

            //AxUtilContext utilContext = new AxUtilContext();
            //AxUtilConfiguration config = new AxUtilConfiguration() { Server = dbServer, Database = dbName };
            //config.ImportFiles.Add(modelFile);

            //config.ConflictResolver = resolverType;

            //AxUtil util = new AxUtil();
            //IList<ModelContents> importedModels = util.Import(utilContext, config);

            //if (utilContext.ExecutionStatus == ExecutionStatus.Error)
            //{
            //    throw new Exception(string.Format("Model install failed: {0}", GetUtilContextErrorStr(utilContext)));
            //}

            //if (importedModels == null || importedModels.Count != 1)
            //{
            //    throw new Exception("Model install failed.");
            //}

            this.InstallModelShell(modelFile, resolverType);
        }