Exemplo n.º 1
0
        private void OpenResource(DictObj resource)
        {
            var showMessage = resource[SEBSettings.KeyAdditionalResourcesConfirm] is true;

            if (showMessage)
            {
                var title          = resource[SEBSettings.KeyAdditionalResourcesTitle] as string;
                var customMessage  = resource[SEBSettings.KeyAdditionalResourcesConfirmText] as string;
                var defaultMessage = SEBUIStrings.AdditionalResourceConfirmMessage;
                var message        = (String.IsNullOrWhiteSpace(customMessage) ? defaultMessage : customMessage).Replace("%%TITLE%%", title);
                var result         = SEBMessageBox.Show(SEBUIStrings.AdditionalResourceConfirmTitle, message, MessageBoxIcon.Question, MessageBoxButtons.YesNo);

                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (!string.IsNullOrEmpty((string)resource[SEBSettings.KeyAdditionalResourcesResourceData]))
            {
                OpenEmbededResource(resource);
            }
            else if (!string.IsNullOrEmpty((string)resource[SEBSettings.KeyAdditionalResourcesUrl]))
            {
                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.AdditionalResources, new { id = resource[SEBSettings.KeyAdditionalResourcesIdentifier] }));
            }
        }
Exemplo n.º 2
0
        private void OpenEmbededResource(DictObj resource)
        {
            var launcher = (int)resource[SEBSettings.KeyAdditionalResourcesResourceDataLauncher];
            var filename = (string)resource[SEBSettings.KeyAdditionalResourcesResourceDataFilename];
            var path     =
                _fileCompressor.DecompressDecodeAndSaveFile(
                    (string)resource[SEBSettings.KeyAdditionalResourcesResourceData], filename, resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString());

            //XulRunner
            if (launcher == 0)
            {
                SEBXULRunnerWebSocketServer.SendMessage(
                    new SEBXULMessage(
                        SEBXULMessage.SEBXULHandler.AdditionalResources, new
                {
                    id   = resource[SEBSettings.KeyAdditionalResourcesIdentifier],
                    path = path
                }
                        )
                    );
            }
            else
            {
                var permittedProcess = (DictObj)SEBSettings.permittedProcessList[launcher];
                var fullPath         = SEBClientInfo.SebWindowsClientForm.GetPermittedApplicationPath(permittedProcess);
                try
                {
                    Process process = SEBClientInfo.SebWindowsClientForm.CreateProcessWithExitHandler(string.Join(" ", fullPath, "\"" + path + filename + "\""));
                    if (SEBClientInfo.SebWindowsClientForm.permittedProcessesReferences[launcher] == null)
                    {
                        SEBClientInfo.SebWindowsClientForm.permittedProcessesReferences[launcher] = process;
                    }
                }
                catch (Exception ex)
                {
                    SEBMessageBox.Show(SEBUIStrings.errorOpeningResource, ex.Message, MessageBoxIcon.Error, MessageBoxButtons.OK);
                }
            }
        }