Ejemplo n.º 1
0
        /// <summary>
        /// Main logic for the command line
        /// </summary>
        /// <param name="args">Command Line Args</param>
        public static void Main(string[] args)
        {
            InitParameters(args);
            Core.Xrm.ToolingConnector toolingConnector = null;
            try
            {
                toolingConnector = new Core.Xrm.ToolingConnector();
                using (CrmServiceClient client = toolingConnector.GetCrmServiceClient(GetParameter("connection-string")))
                {
                    if (HasParameter("timeout"))
                    {
                        client.OrganizationServiceProxy.Timeout = TimeSpan.FromMinutes(
                            Convert.ToDouble(GetParameter("timeout"))
                            );
                    }

                    if (client.IsReady)
                    {
                        string solutionName = GetParameter("solution-name");
                        string localPath    = GetParameter("local-path");

                        toolingConnector.DownloadSolution(client, solutionName, localPath);
                        Console.WriteLine("Download completed: " + Path.Combine(localPath, solutionName + ".zip").ToString());

                        if (Convert.ToBoolean(GetParameter("action")))
                        {
                            // Extract Solution
                            Core.Xrm.CrmSolutionPackager packager = new Core.Xrm.CrmSolutionPackager();
                            string log = packager.ExtractCustomizing(Path.Combine(localPath, solutionName + ".zip").ToString(), localPath);

                            Console.Write(log);
                        }
                    }
                }

                toolingConnector.Dispose();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.Write(ex.StackTrace);
                Console.ResetColor();
                Console.ReadLine();
            }
            finally
            {
                if (toolingConnector != null)
                {
                    ((IDisposable)toolingConnector).Dispose();
                }
            }
        }
        /// <summary>
        /// Main logic for the command line
        /// </summary>
        /// <param name="args">Command Line Args</param>
        public static void Main(string[] args)
        {
            GetParameter(args);
            Core.Xrm.ToolingConnector toolingConnector = null;
            try
            {
                toolingConnector = new Core.Xrm.ToolingConnector();
                using (CrmServiceClient client = toolingConnector.GetCrmServiceClient(parameters.SingleOrDefault(x => x.Name == "connection-string").Value))
                {
                    if (client.IsReady)
                    {
                        string solutionName = parameters.SingleOrDefault(x => x.Name == "solution-name").Value;
                        string localPath    = parameters.SingleOrDefault(x => x.Name == "local-path").Value;

                        toolingConnector.DownloadSolution(client, solutionName, localPath);
                        Console.WriteLine("Download completed: " + Path.Combine(localPath, solutionName + ".zip").ToString());

                        if (Convert.ToBoolean(parameters.SingleOrDefault(x => x.Name == "action").Value))
                        {
                            // Extract Solution
                            Core.Xrm.CrmSolutionPackager packager = new Core.Xrm.CrmSolutionPackager();
                            string log = packager.ExtractCustomizing(Path.Combine(localPath, solutionName + ".zip").ToString(), localPath);

                            Console.Write(log);
                        }
                    }
                }

                toolingConnector.Dispose();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.Write(ex.StackTrace);
                Console.ResetColor();
                Console.ReadLine();
            }
            finally
            {
                if (toolingConnector != null)
                {
                    ((IDisposable)toolingConnector).Dispose();
                }
            }
        }