Varian-Code-Samples icon indicating copy to clipboard operation
Varian-Code-Samples copied to clipboard

Error when run the structure frequency project

Open Luliny opened this issue 5 years ago • 5 comments

I am running the structure frequency project by Rex. I compiled it in my VS and tried to run it. Then I got the error message says: Cannot locate required assembly VMS.TPS.Common.Model.dll. I checked it is there on the same directory as the executable file. Any idea? Thanks!

Luliny avatar Mar 26 '20 19:03 Luliny

@Luliny hello!

Are you trying to run it from citrix, local or TBOX?

joecastelo avatar Mar 27 '20 00:03 joecastelo

I am running from citrix, by the way, Eclipse version 13.7. Thanks!

Luliny avatar Mar 27 '20 00:03 Luliny

Ok, then you must be not on local citrix files, but rather a shared folder I assume.

I've faced this challenge and I overcame this issue by copying all files to a temp folder in citrix local.

So its the same as doing a single file plugin to open an executable.

namespace VMS.TPS // Do not Change
{
    public class Script    // Do not Change
    {
        public void Execute(ScriptContext context) // Do not Change
        {

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = @"Client\Shared$\folder";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var filePath = openFileDialog1;
                try
                {
                    var tmpPath = Path.GetTempPath();
                    var randomfolder = Path.GetRandomFileName().Split('.')[0];
                    var extension = Path.GetExtension(filePath.FileName);
                    var dest = Path.Combine(tmpPath,randomfolder);
                    //MessageBox.Show(dest);
                    var fileonTmp = Path.Combine(dest, filePath.SafeFileName, filePath.DefaultExt) ;
                    //MessageBox.Show(fileonTmp);

                    try
                    {
                        Copy(Path.GetDirectoryName(filePath.FileName), dest);
                        System.Diagnostics.Process.Start(fileonTmp);
                    }
                    catch (Exception) 
                    {

                        throw new Exception("Did not work") ;
                    }


                }

                catch (SecurityException ex)
                {
                    MessageBox.Show($"Security error.\n\nError message: {ex.Message}\n\n" +
                    $"Details:\n\n{ex.StackTrace}");
                }
        }

        }

        public static void Copy(string sourceDirectory, string targetDirectory)
        {
            var diSource = new DirectoryInfo(sourceDirectory);
            var diTarget = new DirectoryInfo(targetDirectory);

            CopyAll(diSource, diTarget);
        }

        public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
        {
            Directory.CreateDirectory(target.FullName);

            // Copy each file into the new directory.
            foreach (FileInfo fi in source.GetFiles())
            {
                Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
                fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
            }

            // Copy each subdirectory using recursion.
            foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
            {
                DirectoryInfo nextTargetSubDir =
                    target.CreateSubdirectory(diSourceSubDir.Name);
                CopyAll(diSourceSubDir, nextTargetSubDir);
            }
        }

    }
}

joecastelo avatar Mar 27 '20 11:03 joecastelo

Thank you very much! Joe. Do I have to attach the code to my script or I can manually copy the files?

Luliny avatar Mar 27 '20 15:03 Luliny

Yeah, it is possible, this is just the automation, but you can click in ExternalPlanning Scripts, Open Folder, and click on some folder with right button and then open in new window. This give you access to the remote where eclipse is installed. So you can do almost anything.

joecastelo avatar Mar 27 '20 16:03 joecastelo