Ejemplo n.º 1
0
        public static void ShowFileChooser(IEnvironmentModel environment, FileChooserMessage fileChooserMessage)
        {
            VerifyArgument.IsNotNull("environment", environment);

            const string PageName              = "dialogs/filechooser";
            const double Width                 = 704;
            const double Height                = 517;
            const string LeftTitle             = "Choose File(s)";
            var          environmentConnection = environment.Connection;

            if (environmentConnection != null)
            {
                string rightTitle = environment.Name + " (" + environmentConnection.AppServerUri + ")";

                var pageHandler = new FileChooserCallbackHandler(fileChooserMessage);

                var envirDisplayName  = FullyEncodeServerDetails(environmentConnection);
                var relativeUriString = string.Format("{0}?envir={1}", PageName, envirDisplayName);
                if (!IsTestMode)
                {
                    environment.ShowWebPageDialog(SiteName, relativeUriString, pageHandler, Width, Height, LeftTitle, rightTitle);
                }
                else
                {
                    CallBackHandler     = pageHandler;
                    TestModeRelativeUri = relativeUriString;
                }
            }
        }
        public void WebsiteCallbackHandler_GetJsonIntellisenseResults_SearchTermIsOpeningTagsAndCaretPositionIsZero_EmptyJsonArray()
        {
            var results = WebsiteCallbackHandler.GetJsonIntellisenseResults("", 0);

            Assert.IsNotNull(results);
            Assert.AreEqual("[]", results);
        }
        public void WebsiteCallbackHandler_GetJsonIntellisenseResults_SearchTermIsNull_EmptyJsonArray()
        {
            var results = WebsiteCallbackHandler.GetJsonIntellisenseResults(null, 0);

            Assert.IsNotNull(results);
            Assert.AreEqual("[]", results);
        }
        public void WebsiteCallbackHandler_GetJsonIntellisenseResults_SearchTermIsOpeningTagsAndCaretPositionIsTwo_JsonArrayWithAllVariables()
        {
            var results = WebsiteCallbackHandler.GetJsonIntellisenseResults("[[", 2);

            Assert.IsNotNull(results);
            Assert.AreEqual("[\"[[Scalar]]\",\"[[Country]]\",\"[[State]]\",\"[[City(\",\"[[City().Name]]\",\"[[City(*).Name]]\",\"[[City().GeoLocation]]\",\"[[City(*).GeoLocation]]\"]", results);
        }
Ejemplo n.º 5
0
        static void ShowSaveDialog(IContextualResourceModel resourceModel, WebsiteCallbackHandler callbackHandler, string type, string title, string resourceId = null)
        {
            if (resourceModel == null)
            {
                throw new ArgumentNullException("resourceModel");
            }
            IEnvironmentModel environment = resourceModel.Environment;

            if (environment == null)
            {
                // ReSharper disable NotResolvedInText
                throw new ArgumentNullException("environment");
            }

            EnvironmentRepository.Instance.ActiveEnvironment = environment;

            const string PageName         = "dialogs/savedialog";
            const double Width            = 604;
            const double Height           = 450;
            var          workspaceId      = GlobalConstants.ServerWorkspaceID;
            const string LeftTitle        = "Save";
            string       rightTitle       = environment.Name + " (" + environment.Connection.AppServerUri + ")";
            var          envirDisplayName = FullyEncodeServerDetails(environment.Connection);

            if (resourceModel.Category == null)
            {
                resourceModel.Category = "";
            }
            var selectedPath = resourceModel.Category.Contains("Unassigned") || string.IsNullOrEmpty(resourceModel.Category) ? "" : resourceModel.Category;
            var lastIndexOf  = selectedPath.LastIndexOf("\\", StringComparison.Ordinal);

            if (lastIndexOf != -1)
            {
                selectedPath = selectedPath.Substring(0, lastIndexOf);
            }
            selectedPath = selectedPath.Replace("\\", "\\\\");
            var relativeUriString = string.Format("{0}?wid={1}&rid={2}&type={3}&title={4}&envir={5}&category={6}", PageName, workspaceId, resourceId, type, title, envirDisplayName, selectedPath);

            if (!IsTestMode)
            {
                // this must be a property ;)
                environment.ShowWebPageDialog(SiteName, relativeUriString, callbackHandler, Width, Height, LeftTitle, rightTitle);
            }
            else
            {
                // TODO : return the relativeUriString generated ;)
                CallBackHandler     = callbackHandler;
                TestModeRelativeUri = relativeUriString;
            }
        }
Ejemplo n.º 6
0
        static async void ShowSaveDialog(IContextualResourceModel resourceModel, WebsiteCallbackHandler callbackHandler, Action loaded = null, bool loadingFromServer = true, string originalPath = "")
        {
            try
            {
                if (resourceModel == null)
                {
                    throw new ArgumentNullException(nameof(resourceModel));
                }
                var server = resourceModel.Environment;
                ServerRepository.Instance.ActiveServer = server ?? throw new ArgumentNullException("environment");

                if (server.Permissions == null)
                {
                    server.Permissions = new List <IWindowsGroupPermission>();
                    server.Permissions.AddRange(server.AuthorizationService.SecurityService.Permissions);
                }
                if (resourceModel.Category == null)
                {
                    resourceModel.Category = "";
                }

                var selectedPath = resourceModel.Category.Contains("Unassigned") || string.IsNullOrEmpty(resourceModel.Category) ? "" : resourceModel.Category;
                var lastIndexOf  = selectedPath.LastIndexOf("\\", StringComparison.Ordinal);
                if (lastIndexOf != -1)
                {
                    selectedPath = selectedPath.Substring(0, lastIndexOf);
                }
                selectedPath = selectedPath.Replace("\\", "\\\\");

                var mainViewModel        = CustomContainer.Get <IShellViewModel>();
                var environmentViewModel = mainViewModel?.ExplorerViewModel?.Environments?.FirstOrDefault(model => model.Server.EnvironmentID == resourceModel.Environment.EnvironmentID);
                if (environmentViewModel == null)
                {
                    return;
                }

                var header            = string.IsNullOrEmpty(resourceModel.Category) ? "Unsaved Item" : resourceModel.Category;
                var lastHeaderIndexOf = header.LastIndexOf("\\", StringComparison.Ordinal);
                if (lastHeaderIndexOf != -1)
                {
                    header = header.Substring(lastHeaderIndexOf, header.Length - lastHeaderIndexOf);
                    header = header.Replace("\\", "");
                }

                var requestViewModel = await RequestServiceNameViewModel.CreateAsync(environmentViewModel, selectedPath, header);

                var messageBoxResult = requestViewModel.ShowSaveDialog();
                if (messageBoxResult == MessageBoxResult.OK)
                {
                    var value           = new { resourceName = requestViewModel.ResourceName.Name, resourcePath = requestViewModel.ResourceName.Path, resourceLoadingFromServer = loadingFromServer, OriginalPath = originalPath };
                    var serializeObject = JsonConvert.SerializeObject(value);
                    callbackHandler.Save(serializeObject, server);
                }
                else
                {
                    if (!loadingFromServer)
                    {
                        mainViewModel.CloseResource(resourceModel, server.EnvironmentID);
                    }
                }
                loaded?.Invoke();
            }
            catch (Exception)
            {
                loaded?.Invoke();
                throw;
            }
        }