Ejemplo n.º 1
0
        private void CheckDependencies()
        {
            SetDialog("Checking dependencies...");
            ThreadManager.Instance.ScheduleTask(() =>
            {
                var isError      = false;
                var errorMessage = string.Empty;
                //var clonedSolutionId = Guid.Empty;
                try
                {
                    SetDialog("Connecting to destination environment...");
                    var stringConnection       = DestinationCrmConnection.GetStringConnetion(); var solution = CurrentSolutionManager.GetSolution(WorkSolution.SolutionId);
                    DestinationService         = CrmDataProvider.GetService(stringConnection);
                    DestinationSolutionManager = new SolutionManager(DestinationService); var path = Path.GetTempPath();

                    SetDialog("Downloading solution...");

                    var filePath = $@"{path}{solution.UniqueName}.zip";
                    CurrentSolutionManager.ExportSolution(solution.UniqueName, filePath, true);
                    SetDialog("Importing solution in destionation environment...");
                    DestinationSolutionManager.ImportSolution(filePath, false, false, false);
                    SetDialog("Removing solution from destination environment...");
                    DestinationSolutionManager.RemoveSolution(solution.UniqueName);
                    CurrentSolutionManager.SetDependenciesOKForWorkSolution(WorkSolution.Id);
                }
                catch (Exception ex)
                {
                    isError      = true;
                    errorMessage = ex.Message;
                }
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    if (isError)
                    {
                        CurrentSolutionManager.SetDependenciesKOForWorkSolution(WorkSolution.Id, errorMessage);
                        MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        //this.ClonedSolutionId = clonedSolutionId;
                        _window.Close();
                    }
                    UnsetDialog();
                });
            }, "Cloning solution...", _checkDependenciesTaskId);
        }
Ejemplo n.º 2
0
        private ConversationResponse ConnectPath(LuisResponse response)
        {
            if (response.topScoringIntent?.intent == ConnectToEnvironment)
            {
                var environment = response.entities.FirstOrDefault(k => k.type == "Environment");
                if (environment == null)
                {
                    return(new ConversationResponse($"{CouldntUnderstand}. {OnlyConnectToEnvironment}"));
                }
                var stringConnection = ConfigManager.GetAppConfig(environment.entity);
                if (string.IsNullOrEmpty(stringConnection))
                {
                    return(new ConversationResponse(string.Format(CouldntFindEnvironmentInAppConfig, environment.entity)));
                }

                RaiseMiddleConversationResponse($"Intentando conectarse a {environment.entity}");
                string stringConnectionComplete = string.Format(stringConnection, this.CrmPassword);

                IOrganizationService service = CrmDataProvider.GetService(stringConnectionComplete);
                if (service == null)
                {
                    return(new ConversationResponse(string.Format(CouldntConnectToEnviroment, environment.entity)));
                }
                IsConnected  = true;
                this.Service = service;
                RaiseMiddleConversationResponse("Connectado correctamente. Descargando datos de la organización");
                RetrieveAllEntitiesRequest req = new RetrieveAllEntitiesRequest()
                {
                    EntityFilters         = Microsoft.Xrm.Sdk.Metadata.EntityFilters.All,
                    RetrieveAsIfPublished = true
                };
                var responseMetadata = (RetrieveAllEntitiesResponse)service.Execute(req);
                EntitiesMetadata = responseMetadata.EntityMetadata.ToList();

                return(new ConversationResponse($"Proceso completado. ¿Qué desea hacer?"));
            }
            else
            {
                return(new ConversationResponse($"{CouldntUnderstand}. {OnlyConnectToEnvironment}"));
            }
        }