Beispiel #1
0
        private void LibraryListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                // Rename the asset
                ListViewItem renamedAsset = LibraryListView.Items[e.Item];
                string       fullName     = GetItemFullName(renamedAsset);
                string       label        = renamedAsset.SubItems[FindColumn("Name")].Text;
                string       extension    = DosUtils.PathGetExtension(fullName);

                string rename = fullName.Replace(label, e.Label);

                if (DosUtils.FileExistFast(rename))
                {
                    MOG_Prompt.PromptMessage("Rename Error", "Cannot rename (" + label + ") to (" + e.Label + ") because this asset already exists!");
                    e.CancelEdit = true;
                }
                else
                {
                    if (!DosUtils.RenameFast(fullName, rename, false))
                    {
                        MOG_Prompt.PromptMessage("Rename Error", DosUtils.GetLastError());
                        e.CancelEdit = true;
                    }
                    else
                    {
                        // Update the full filename
                        renamedAsset.SubItems[FindColumn("Fullname")].Text  = rename;
                        renamedAsset.SubItems[FindColumn("Extension")].Text = extension;
                    }
                }
            }
        }
 static public void LoadHelpText(MOG_ServerManagerMainForm mainForm, string doc)
 {
     if (DosUtils.FileExistFast(doc))
     {
         mainForm.StartPageInfoRichTextBox.LoadFile(doc, RichTextBoxStreamType.RichText);
         mHelpDoc = doc;
         mainForm.StartPageInfoRichTextBox.SelectAll();
         mainForm.StartPageInfoRichTextBox.SelectionColor = System.Drawing.Color.SteelBlue;
     }
 }
Beispiel #3
0
        private void Purge(string projName, string iniFilename)
        {
            // make sure iniFilename points to valid file
            if (DosUtils.FileExistFast(iniFilename))
            {
                List <string> args = new List <string>();
                args.Add(projName);
                args.Add(iniFilename);

                string message = "Please wait while MOG purges old deleted project.\n" +
                                 "   PROJECT: " + projName;
                ProgressDialog progress = new ProgressDialog("Purging deleted project", message, Purge_Worker, args, false);
                progress.ShowDialog();
            }
        }
Beispiel #4
0
        public bool Load()
        {
            try
            {
                if (DosUtils.FileExistFast(mFilename))
                {
                    string contents = DosUtils.FileRead(mFilename);
                    if (contents.Length > 0)
                    {
                        contents = MOG_Encryption.Decrypt(contents);

                        string[] parts = contents.Split("$".ToCharArray());

                        if (parts.Length >= 5)
                        {
                            Int64 savedChecksum = Int64.Parse(parts[0]);
                            mMacAddress         = parts[1];
                            mInstallDate        = DateTime.Parse(parts[2]);
                            mExpireDate         = DateTime.Parse(parts[3]);
                            mClientLicenseCount = Int32.Parse(parts[4]);
                            if (parts.Length >= 6)
                            {
                                mDisabledFeatureList = parts[5];
                            }

                            //generate a new checksum and compare it with the one we saved out
                            contents = contents.Substring(parts[0].Length + 1);
                            Int64 checksum = 0;
                            for (int i = 0; i < contents.Length; i++)
                            {
                                checksum += Convert.ToInt64(Char.GetNumericValue(contents[i]));
                            }

                            if (savedChecksum == checksum)
                            {
                                mIsLoaded = true;
                            }
                        }
                    }
                }
            }
            catch
            {
                mIsLoaded = false;
            }

            return(mIsLoaded);
        }
Beispiel #5
0
        private void Clean_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker             = sender as BackgroundWorker;
            ArrayList        selectedItems      = e.Argument as ArrayList;
            string           workspaceDirectory = MOG_ControllerProject.GetWorkspaceDirectory() + "\\";

            for (int i = 0; i < selectedItems.Count && !worker.CancellationPending; i++)
            {
                string file         = selectedItems[i] as string;
                string relativeFile = file;
                if (file.StartsWith(workspaceDirectory, StringComparison.CurrentCultureIgnoreCase))
                {
                    relativeFile = file.Substring(workspaceDirectory.Length);
                }

                string message = "Deleting:\n" +
                                 "     " + Path.GetDirectoryName(relativeFile) + "\n" +
                                 "     " + Path.GetFileName(relativeFile);
                worker.ReportProgress(i * 100 / selectedItems.Count, message);

                // Check if this file really exists?
                if (DosUtils.FileExistFast(file))
                {
                    if (!DosUtils.Recycle(file))
                    {
                        // Error
                        MOG_Prompt.PromptMessage("Delete File", "Could not delete:\n" + file);
                    }
                    else
                    {
                        if (!DosUtils.DirectoryDeleteEmptyParentsFast(Path.GetDirectoryName(file), true))
                        {
                            if (DosUtils.GetLastError() != null && DosUtils.GetLastError().Length > 0)
                            {
                                // Error
                                MOG_Prompt.PromptMessage("Delete directory", "Could not delete directory:\n" + Path.GetDirectoryName(file));
                            }
                        }
                    }
                }
            }
        }
        public void SaveMOGConfiguration()
        {
            string  configFilename = MOG_Main.FindInstalledConfigFile();
            MOG_Ini ini            = new MOG_Ini();

            if (ini.Load(configFilename))
            {
                // Save repository
                ini.PutString("MOG", "SystemRepositoryPath", mRepositoryPath);
                ini.PutString("MOG", "SystemConfiguration", mConfigFile);

                ini.Close();

                // If we are the installed MOG, update the loaders ini too
                if (DosUtils.FileExistFast(MOG_Main.GetExecutablePath() + "\\..\\Loader.ini"))
                {
                    MOG_Ini LoaderIni = new MOG_Ini(MOG_Main.GetExecutablePath() + "\\..\\Loader.ini");

                    LoaderIni.PutString("LOADER", "SystemRepositoryPath", mRepositoryPath);

                    LoaderIni.Save();
                }
            }
        }
Beispiel #7
0
        public void MogControl_LibraryTreeView_DragDrop(object sender, DragEventArgs args)
        {
            if (this.dragOverNode != null)
            {
                // Restore node's original colors
                this.dragOverNode.BackColor = SystemColors.Window;
                this.dragOverNode.ForeColor = SystemColors.ControlText;
            }

            // Get node we want to drop at
            TreeNode targetNode = this.GetNodeAt(this.PointToClient(new Point(args.X, args.Y)));

            // and select it so it'll show up in the ListView
            this.SelectedNode = targetNode;

            if (args.Data.GetDataPresent("FileDrop"))
            {
                // Extract the filenames and import
                string[] filenames = (string[])args.Data.GetData("FileDrop", false);
                if (filenames != null && filenames.Length > 0)
                {
                    bool bCopyFiles    = true;
                    bool bAutoAddFiles = false;
                    bool bPromptUser   = false;
                    bool bCancel       = false;

                    // Check if thes files are coming from the same spot?
                    string classification     = targetNode.FullPath;
                    string classificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(classification);
                    // Get the common directory scope of the items
                    ArrayList items    = new ArrayList(filenames);
                    string    rootPath = MOG_ControllerAsset.GetCommonDirectoryPath("", items);
                    if (rootPath.StartsWith(classificationPath))
                    {
                        bCopyFiles = false;
                    }

                    // Check if auto import is checked?
                    if (this.LibraryExplorer.IsAutoImportChecked())
                    {
                        // Automatically add the file on the server
                        bAutoAddFiles = true;
                        bPromptUser   = true;

                        // Check if these files are already within the library?
                        if (MOG_ControllerLibrary.IsPathWithinLibrary(rootPath))
                        {
                            // Ignore what the user specified and rely on the classification generated from the filenames
                            classification = "";
                            bPromptUser    = false;
                            bCopyFiles     = false;
                        }
                    }

                    // Promt the user for confirmation before we import these files
                    if (bPromptUser)
                    {
                        // Prompt the user and allow them to cancel
                        if (LibraryFileImporter.PromptUserForConfirmation(filenames, classification) == false)
                        {
                            bCancel = true;
                        }
                    }

                    // Make sure we haven't canceled
                    if (!bCancel)
                    {
                        if (bCopyFiles)
                        {
                            // Import the files
                            List <object> arguments = new List <object>();
                            arguments.Add(filenames);
                            arguments.Add(classification);
                            ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.CopyFiles, arguments, true);
                            progress.ShowDialog();
                        }
                    }

                    // Make sure we haven't canceled
                    if (!bCancel)
                    {
                        if (bAutoAddFiles)
                        {
                            // Import the files
                            List <object> arguments = new List <object>();
                            arguments.Add(filenames);
                            arguments.Add(classification);
                            ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.ImportFiles, arguments, true);
                            progress.ShowDialog();
                        }
                    }

                    // Refresh view
                    DeInitialize();
                    Initialize();
                }
            }
            else if (args.Data.GetDataPresent("LibraryListItems"))
            {
                ArrayList items = args.Data.GetData("LibraryListItems") as ArrayList;

                foreach (string item in items)
                {
                    // Move library asset here
                    MOG_Filename assetName = new MOG_Filename(item);
                    // Check if this was an asset?
                    if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        bool success = MOG_ControllerProject.GetProject().AssetRename(assetName.GetAssetFullName(), SelectedNode.FullPath + assetName.GetAssetName());
                        // Make sure we unsync this asset just in case it had already been synced
                        MOG_ControllerLibrary.Unsync(assetName);
                    }
                    // Check if this was a file?
                    else if (DosUtils.FileExistFast(item))
                    {
                        string dstPath   = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(SelectedNode.FullPath);
                        string dstTarget = Path.Combine(dstPath, Path.GetFileName(item));
                        DosUtils.FileMoveFast(item, dstTarget, true);
                    }
                }
            }
            else if (args.Data.GetDataPresent("LibraryTreeNode"))
            {
                string classification = args.Data.GetData("LibraryTreeNode") as string;

                if (classification != null && classification.Length > 0)
                {
                    //Move classification here
                    string[] parts = classification.Split("~".ToCharArray());
                    if (parts.Length > 0)
                    {
                        string lastPart = parts[parts.Length - 1];

                        bool success = MOG_ControllerProject.GetProject().ClassificationRename(classification, SelectedNode.FullPath + "~" + lastPart);
                    }
                    else
                    {
                        MOG_Prompt.PromptResponse("Cannot move classification", "MOG was unable to move the classification", Environment.StackTrace, MOGPromptButtons.OK);
                    }
                }
            }
        }