Ejemplo n.º 1
0
        internal HardRockWebServiceProxy(IFieldMigratorConfiguration configuration)
        {
            _configuration  = configuration;
            _templateFields = new ConcurrentDictionary <Guid, List <FieldModel> >();
            _workFlows      = new ConcurrentDictionary <Guid, WorkflowModel>();

            var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
            {
                MaxReceivedMessageSize = 524288000, // 500 Megabytes
                ReceiveTimeout         = TimeSpan.FromMinutes(10),
                SendTimeout            = TimeSpan.FromMinutes(10)
            };
            var remoteAddress = new EndpointAddress(_configuration.SourceEndpointAddress);

            _service = new SitecoreWebService2SoapClient(binding, remoteAddress);
        }
Ejemplo n.º 2
0
        public override bool TestConnection(string physicalPath)
        {
            Assert.ArgumentNotNull(physicalPath, nameof(physicalPath));

            bool retry;

            do
            {
                retry = false;
                SitecoreWebService2SoapClient service = null;

                try
                {
                    service = GetDataService();

                    var result = service.Login(GetCredentials());

                    if (result == @"Invalid user or password.")
                    {
                        AppHost.MessageBox(Resources.HardRockWebService_TestConnection_Invalid_user_name_or_password_, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    if (service == null)
                    {
                        AppHost.MessageBox(ex.Message, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }

                    var pipeline = TroubleshooterPipeline.Run().WithParameters(this, true, ex, service.Endpoint);
                    if (pipeline.Cancelled)
                    {
                        return(false);
                    }

                    retry = pipeline.Retry;
                }
            }while (retry);

            return(true);
        }
Ejemplo n.º 3
0
 public override void ResetDataService()
 {
     dataService = null;
 }
Ejemplo n.º 4
0
        private void InitializeDataService()
        {
            if (Connection.AutomaticallyUpdate && !string.IsNullOrEmpty(Connection.WebRootPath))
            {
                UpdateServerComponentsManager.AutomaticUpdate(Connection, Connection.WebRootPath);
            }

            dataService = CreateDataService();
            var busy = true;

            var aspxAuthCookieBehavior = new AspxAuthCookieBehavior(GetHostName());

            dataService.Endpoint.Behaviors.Add(aspxAuthCookieBehavior);

            AppHost.Statusbar.SetText(string.Format(Resources.LoginWindow_ControlLoaded_Connecting_to___0______, Connection.HostName));

            EventHandler <LoginCompletedEventArgs> completed = delegate(object sender, LoginCompletedEventArgs e)
            {
                if (e.Error != null)
                {
                    if (DisableLoginErrorMessage)
                    {
                        busy        = false;
                        dataService = null;
                        return;
                    }

                    Dispatcher.CurrentDispatcher.Invoke(new Action(delegate
                    {
                        var endPoint = dataService != null ? dataService.Endpoint : null;
                        var pipeline = TroubleshooterPipeline.Run().WithParameters(this, true, e.Error, endPoint);

                        if (pipeline.Retry)
                        {
                            if (dataService == null)
                            {
                                dataService = CreateDataService();
                            }

                            dataService.LoginAsync(GetCredentials());
                            return;
                        }

                        dataService = null;
                        busy        = false;
                    }));

                    return;
                }

                var root = e.Result.ToXElement();
                if (root.Name == "error")
                {
                    Dispatcher.CurrentDispatcher.Invoke(new Action <string>(x =>
                    {
                        AppHost.MessageBox(x, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    }), root.Value);
                    dataService = null;
                    busy        = false;
                    return;
                }

                WebServiceVersion     = @"0.0.0.0";
                SitecoreVersionString = string.Empty;
                SitecoreVersion       = RuntimeVersion.Empty;

                if (root != null)
                {
                    LoggedInPipeline.Run().WithParameters(this, root);
                }

                busy = false;
            };

            AppHost.DoEvents();

            if (dataService != null)
            {
                dataService.LoginCompleted += completed;

                var dispatcherOperation = Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => dataService.LoginAsync(GetCredentials())));

                if (!AppHost.DoEvents(ref busy))
                {
                    dispatcherOperation.Abort();

                    ServiceEndpoint endPoint = null;
                    if (dataService != null)
                    {
                        endPoint = dataService.Endpoint;
                    }

                    var pipeline = TroubleshooterPipeline.Run().WithParameters(this, true, new TimeoutException("The operation timed out after 2 minutes."), endPoint);
                    if (pipeline.Retry && dataService != null)
                    {
                        dataService.LoginAsync(GetCredentials());
                        return;
                    }

                    dataService = null;
                }
            }

            if (dataService != null)
            {
                dataService.LoginCompleted -= completed;
            }

            if (dataService != null && dataService.InnerChannel.State == CommunicationState.Opened)
            {
                Status = DataServiceStatus.Connected;
            }
            else
            {
                Status = DataServiceStatus.Failed;
            }
        }