Exemplo n.º 1
0
        /// <summary>
        ///     This is called after the class is constructed and before the page is displayed.
        ///     We use it as a trigger to populate the page elements.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Write our status messages to a list on the page.
            var statusBuilder = new StringBuilder();

            if (StatusLog.Count > 0)
            {
                statusBuilder.AppendLine("<ul>");
                foreach (var status in StatusLog)
                {
                    statusBuilder.AppendFormat("<li>{0}</li>\n", status.Contains("\n") ? FormatForPage(status) : status);
                }
                statusBuilder.AppendLine("</ul>");
                statusPlaceholder.Text = statusBuilder.ToString();

                // We've written the messages out, so remove them from the list.
                StatusLog.Clear();
            }

            // Write information about the system to the page.
            WriteSystemVariables();

            // Build our list of images from DynamoDB and S3
            BuildImageList();

            // Display the image list in a table on the page.
            var imageListBuilder = new StringBuilder();

            foreach (var imageRow in ImageListRows)
            {
                imageListBuilder.AppendLine(imageRow);
            }
            imageListPlaceholder.Text = imageListBuilder.ToString();
        }
        /// <summary>
        /// Called when [uninstall wing].
        /// </summary>
        /// <param name="dynamicTarget">The dynamic target.</param>
        private async void OnUninstallWing(Target dynamicTarget)
        {
            if (dynamicTarget == null)
            {
                return;
            }



            var uninstallConfirmation = MessageBox.Show(@"Are you sure you want to uninstall '" + dynamicTarget.DisplayName + "'?"
                                                        + Environment.NewLine + "The Website(s) using this Wing will be deleted."
                                                        , @"Uninstall Confirmation", MessageBoxButton.YesNo);

            if (uninstallConfirmation == MessageBoxResult.No)
            {
                return;
            }
            UninstallInProgress = true;
            StatusLog.Clear();
            ProgressPopupVisibility = true;

            await Task.Delay(500);

            UnistallWingName = dynamicTarget.DisplayName;
            var cancellationToken = new CancellationTokenSource();
            var uninstallResult   = await DynamicTargetService.Uninstall(dynamicTarget, cancellationToken.Token, result =>
            {
                if (result.Status == OpenSourceUnInstallFlags.StatusUpdate)
                {
                    StatusLog.Add(result.Message);
                }
                if (result.Status == OpenSourceUnInstallFlags.Success)
                {
                    StatusLog.Add(string.Format("Uninstallation of wing \"{0}\" completed successfully.", dynamicTarget.Name));

                    if (WingItems.Contains(dynamicTarget))
                    {
                        WingItems.Remove(dynamicTarget);
                    }
                }
            },
                                                                         exceptionResult =>
            {
                var statusMessage = string.Format("Uninstallation of wing \"{0}\" was unsuccessful. Please try again. If for any reason the" +
                                                  "the error still remains after trying to uninstall again. Please contact Monahrq technical assistance.",
                                                  dynamicTarget.Name);
                StatusLog.Add(statusMessage);
                Logger.Write(exceptionResult.Exception);
            });


            UninstallInProgress = false;
        }
        /// <summary>
        /// Called when [install flutter].
        /// </summary>
        private async void OnInstallFlutter()
        {
            FlutterInstalled = false;

            var uiContext = SynchronizationContext.Current;

            StatusLog.Clear();
            ApplicableReports.Clear();

            if (string.IsNullOrEmpty(SelectedFlutterFile))
            {
                return;
            }


            OSFlutterInstallResult installResult = null;

            var cTokenSource = new CancellationTokenSource();
            var taskResult   = await DynamicTargetService.InstallFlutterFiles(SelectedFlutterFile, cTokenSource.Token,
                                                                              result =>
            {
                installResult = result;
                if (result.Status == OSFlutterInstallFlags.StatusUpdate || result.Status == OSFlutterInstallFlags.UploadFileComplete)
                {
                    uiContext.Send(x => StatusLog.Add(result.Message), null);
                }

                if (result.Status == OSFlutterInstallFlags.Success)
                {
                    uiContext.Send(x => StatusLog.Add(result.Message), null);
                }
            },
                                                                              exceptionResult =>
            {
                if (exceptionResult.Status == OSFlutterInstallFlags.Error)
                {
                    uiContext.Send(x => StatusLog.Add(exceptionResult.Message), null);
                    Logger.Warning(installResult.ToString());

                    installResult = exceptionResult;
                }
            });

            if (installResult.Status == OSFlutterInstallFlags.Success && installResult.Flutter != null)
            {
                if (FlutterItems.All(f => !f.Name.EqualsIgnoreCase(installResult.Flutter.Name)))
                {
                    FlutterItems.Add(installResult.Flutter);
                }
            }
            FlutterInstalled = true;
        }
        /// <summary>
        /// Called when [uninstall flutter].
        /// </summary>
        /// <param name="flutter">The flutter.</param>
        private async void OnUninstallFlutter(Flutter flutter)
        {
            var uiContext = SynchronizationContext.Current;

            var uninstallConfirmation = MessageBox.Show(@"Are you sure you want to uninstall '" + flutter.Name + "'?"
                                                        , @"Uninstall Confirmation", MessageBoxButton.YesNo);

            if (uninstallConfirmation == MessageBoxResult.No)
            {
                return;
            }
            UninstallInProgress = true;
            StatusLog.Clear();
            ProgressPopupVisibility = true;

            var cancellationToken = new CancellationTokenSource();

            var uninstallResult = await DynamicTargetService.Uninstall(flutter, cancellationToken.Token,
                                                                       result =>
            {
                if (result.Status == OpenSourceUnInstallFlags.StatusUpdate)
                {
                    StatusLog.Add(result.Message);
                }
                if (result.Status == OpenSourceUnInstallFlags.Success)
                {
                    StatusLog.Add(string.Format("Uninstallation of flutter \"{0}\" completed successfully.", flutter.Name));
                }
            },
                                                                       errorCallback =>
            {
                var statusMessage = string.Format("Uninstallation of flutter \"{0}\" was unsuccessful. Please try again. If for any reason the" +
                                                  "the error still remains after trying to uninstall again. Please contact Monahrq technical assistance.",
                                                  flutter.Name);
                uiContext.Send(x => StatusLog.Add(statusMessage), null);
                Logger.Write(errorCallback.Exception);

                //if (FlutterItems.Contains(flutter))
                //    FlutterItems.Remove(flutter);
            });

            if (FlutterItems.Contains(flutter))
            {
                FlutterItems.Remove(flutter);
            }
            UninstallInProgress = false;
        }
Exemplo n.º 5
0
        /************************** ON TEXTBOX PASTE */
        private void Folder_name_TextChanged(object sender, TextChangedEventArgs ev)
        {
            try {
                // Check for empty "paste TextBox", or whitespace input
                if (String.IsNullOrEmpty(Folder_name.Text))
                {
                    StatusLog.Text = "Invalid folder name";
                }
                else
                {
                    StatusLog.Clear(); // Remove previous message from status.


                    // Variables
                    var TargetPathRoot = @"S:\Dying Light Dev Stuff\FBX\Rise of the Tomb Raider"; // Root folder where all newly created folders exist. Used to check if folder has been created.

                    // btn_move_obj_dds.IsEnabled = true; // Re-enable MF&F button, case it was disabled when duplicated folder name was found.

                    // Check If To-Be-Created Folder Has Already Been Created
                    var dirs = Directory.EnumerateDirectories(TargetPathRoot, Folder_name.Text, SearchOption.AllDirectories);
                    if (dirs.Any()) // Folder has already been created! Halt process!
                    {
                        StatusLog.Text = "Folder already exists.";
                        // btn_move_obj_dds.IsEnabled = false; // Disable button, as a visual clue, and not to re-copy files accidentaly.
                    }
                    else
                    {
                        // Folder doesn't exist. Continue process;

                        // TO ADD HERE: Check if i've exported obj and dds files before creating folders

                        // Variables
                        var dumpFolder    = Path.Combine(DumpPath.Text, Folder_name.Text);                      // Dump folder created when dumping .drm file with DRMDumper. Folder name used to create new folder
                        var objDumpFolder = Path.Combine(dumpFolder, "RenderMesh");                             // Folder where exported .obj files are
                        var ddsDumpFolder = Path.Combine(dumpFolder, "Texture");                                // Folder where exported .dds files are

                        var newFolder = Path.Combine(TargetPath.Text, Folder_name.Text);                        // Created folder to move exported .obj and .dds files to

                        var processedFolder = Path.Combine(DumpPath.Text, "[COPIED TO FBX]", Folder_name.Text); // Where to move dumpFolder to, when .objs and .dds are moved to newFolder.


                        // Create new folders and subfolders
                        var path = Path.Combine(TargetPath.Text, Folder_name.Text);
                        Directory.CreateDirectory(path); // Create new folder.

                        var tex = Path.Combine(path, "textures");
                        Directory.CreateDirectory(tex);      // Create "textures" sub-folder.

                        StatusLog.Text = "Folders created."; // Success

                        // Move all .OBJ files to newFolder
                        string sourceOBJDirectory  = objDumpFolder;
                        string archiveOBJDirectory = newFolder;

                        var objFiles = Directory.EnumerateFiles(sourceOBJDirectory, "*.obj", SearchOption.AllDirectories);

                        foreach (string currentFile in objFiles)
                        {
                            string fileName = Path.GetFileName(currentFile);
                            Directory.Move(currentFile, Path.Combine(archiveOBJDirectory, fileName));
                        }


                        // And all .DDS files to newFolder as well.
                        string sourceDDSDirectory  = ddsDumpFolder;
                        string archiveDDSDirectory = Path.Combine(newFolder, "textures");

                        var ddsFiles = Directory.EnumerateFiles(sourceDDSDirectory, "*.dds", SearchOption.AllDirectories);

                        foreach (string currentFile in ddsFiles)
                        {
                            string fileName = Path.GetFileName(currentFile);
                            Directory.Move(currentFile, Path.Combine(archiveDDSDirectory, fileName));
                        }

                        // Console.Error.WriteLine(dumpFolder);
                        // Console.Error.WriteLine(processedFolder);

                        // When files are moved, move dumpFolder to processedFolder.
                        Directory.Move(dumpFolder, processedFolder);

                        StatusLog.Text = "Done."; // Success
                    }
                }
            }
            catch (Exception ex) {
                Console.Error.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 6
0
 /************************** ON TEXTBOX PRESS */
 private void Folder_name_MouseLeftButtonUp(object sender, MouseButtonEventArgs ev)
 {
     Folder_name.SelectAll(); // Select all, readying for next "paste".
     StatusLog.Clear();       // Remove message from status.
 }
        /// <summary>
        /// Called when [install wing].
        /// </summary>
        private async void OnInstallWing()
        {
            WingInstalled = false;

            StatusLog.Clear();

            if (string.IsNullOrEmpty(SelectedWingFile))
            {
                return;
            }

            await Task.Run(() => StatusLog.Add("Copying files to Wing directory. Please, stand by. It may take a few seconds."));

            await Task.Delay(100);

            var targetsToInstall = await Task.Run(() => DynamicTargetService.CopyTargetFilesToDirectory(SelectedWingFile).ToList());

            using (var session = Provider.SessionFactory.OpenSession())
            {
                var wing = session.Query <Wing>().FirstOrDefault(w => w.WingGUID == new Guid(DynamicTargetWingConstants.WING_MODULE_GUID));
                if (wing == null)
                {
                    throw new NotSupportedException("Dynamic wings module is not installed. XML Wings cannot be installed.");
                }

                foreach (var dynamicTarget in targetsToInstall)
                {
                    StatusLog.Add(string.Format("Starting installation of wing \"{0}\".", dynamicTarget.Name));

                    #region "Asynchronous Aproach"
                    var result = await DynamicTargetService.InstallDynamicTargetAsync(dynamicTarget, wing, session, DynamicTargetService.Context.Value,
                                                                                      InstallWingProgress);

                    if (!result)
                    {
                        StatusLog.Add($"An error occurred while trying to install wing \"{dynamicTarget.Name}\". Please try again and if the error persists, please contact technical assistance for help.");
                    }
                    #endregion

                    #region synchronous install
                    //var result = DynamicTargetService.InstallDynamicTarget(dynamicTarget, wing, session);

                    //switch (result.Status)
                    //{
                    //    case OpenSourceInstallFlags.AlreadyExists:
                    //        uiContext.Send(x => StatusLog.Add(string.Format("Wing \"{0}\" has already been installed.", dynamicTarget.Name)), null);
                    //        continue;
                    //    case OpenSourceInstallFlags.Error:
                    //        // TODO: Add message for user.
                    //        uiContext.Send(x => StatusLog.Add(string.Format("An error occurred while trying to install wing \"{0}\". Please try again and if the error persists, please contact technical assistance for help.", dynamicTarget.Name)), null);
                    //        Logger.Write(result);
                    //        break;
                    //    case OpenSourceInstallFlags.Success:
                    //        uiContext.Send(x => StatusLog.Add(
                    //            string.Format(
                    //                "Start installation of associated measures, reports, wing dataset target tables for wing \"{0}\".",
                    //                dynamicTarget.Name)), null);

                    //        target = result.Target;

                    //        if (target != null)
                    //        {
                    //            // Thread.Sleep(500);

                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(string.Format("Start importing measures for wing \"{0}\".",
                    //                        dynamicTarget.Name)), null);
                    //            DynamicTargetService.ImportMeasures(target, dynamicTarget, session);
                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(string.Format("End importing measures for wing \"{0}\".",
                    //                        dynamicTarget.Name)), null);

                    //            // Thread.Sleep(500);
                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(string.Format("Start importing reports for wing \"{0}\".",
                    //                        dynamicTarget.Name)), null);
                    //            DynamicTargetService.ImportReports(dynamicTarget, session);
                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(string.Format("End importing reports for wing \"{0}\".",
                    //                        dynamicTarget.Name)), null);

                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(string.Format("Finalizing installation for wing \"{0}\".",
                    //                        dynamicTarget.Name)), null);
                    //            // Thread.Sleep(1000);
                    //            uiContext.Send(
                    //                x =>
                    //                    StatusLog.Add(
                    //                        string.Format("Installation for wing \"{0}\" successfully completed.",
                    //                            dynamicTarget.Name)), null);

                    //            if (target != null && !WingItems.Any(item => item.Name.EqualsIgnoreCase(target.Name)))
                    //                WingItems.Add(target);

                    //        }
                    //        break;
                    //}
                    #endregion
                }
            }
            WingInstalled = true;
        }