示例#1
0
        public Form1()
        {
            this.InitializeComponent();

            Random rnd = new Random();
            var    randomName = new [] { "Jess", "Anastasia", "Bobby", "Steven", "Bonawentura" }.OrderBy(a => rnd.NextDouble()).First();

            this.userNameTextBox.Text = randomName;
            this.apiUrlTextBox.Text   = string.IsNullOrEmpty(Properties.Settings.Default.baseUri)
                ? "http://localhost:7757/"
                : Properties.Settings.Default.baseUri;
            this.apiKeyTextBox.Text = string.IsNullOrEmpty(Properties.Settings.Default.telemetryKey)
                ? ""
                : Properties.Settings.Default.telemetryKey;
            if (Guid.TryParse(this.apiKeyTextBox.Text, out Guid key))
            {
                this.Telimena =
                    TelimenaFactory.Construct(new TelimenaStartupInfo(key, new Uri(this.apiUrlTextBox.Text))
                {
                    UserInfo = new UserInfo()
                    {
                        UserIdentifier = this.userNameTextBox.Text
                    }
                }) as Telimena;
            }

            this.Text = $"Sandbox v. {TelimenaVersionReader.Read(this.GetType(), VersionTypes.FileVersion)}";
        }
示例#2
0
        private static string GetFromZip(string nameOfFileToCheck, string zipPath)
        {
            ZipFile.ExtractToDirectory(zipPath, Path.GetDirectoryName(zipPath));
            var files = Directory.GetFiles(Path.GetDirectoryName(zipPath), "*", SearchOption.AllDirectories).Where(f => !f.Equals(zipPath, StringComparison.InvariantCultureIgnoreCase)).ToList();

            foreach (string file in files)
            {
                if (Path.GetFileName(file).Equals(nameOfFileToCheck, StringComparison.InvariantCultureIgnoreCase))
                {
                    {
                        return(TelimenaVersionReader.Read(file, VersionTypes.FileVersion));
                    }
                }
            }

            foreach (string file in files)
            {
                try
                {
                    string version = TelimenaVersionReader.ReadEmbeddedAssemblyVersion(new FileInfo(file)
                                                                                       , nameOfFileToCheck, VersionTypes.FileVersion);
                    if (!string.IsNullOrEmpty(version))
                    {
                        return(version);
                    }
                }
                catch
                {
                    //oh well
                }
            }

            return(null);
        }
示例#3
0
        public VersionTuple GetVersionsFromApp(FileInfo exe)
        {
            Log($"Reading versions from [{exe.FullName}]");
            var versionTuple = new VersionTuple();

            versionTuple.AssemblyVersion = TelimenaVersionReader.Read(exe, VersionTypes.AssemblyVersion).ToString();
            versionTuple.FileVersion     = TelimenaVersionReader.Read(exe, VersionTypes.FileVersion).ToString();
            return(versionTuple);
        }
示例#4
0
        public VersionTuple GetVersionsFromFile(FileInfo exe)
        {
            string ass  = TelimenaVersionReader.Read(exe, VersionTypes.AssemblyVersion);
            string file = TelimenaVersionReader.Read(exe, VersionTypes.FileVersion);

            return(new VersionTuple()
            {
                AssemblyVersion = ass, FileVersion = file
            });
        }
示例#5
0
 private static string GetFromMsi(string nameOfFileToCheck, string zipPath)
 {
     Wixtracts.ExtractFiles(zipPath, Path.GetDirectoryName(zipPath));
     foreach (string file in Directory.GetFiles(Path.GetDirectoryName(zipPath), "*", SearchOption.AllDirectories))
     {
         if (Path.GetFileName(file).Equals(nameOfFileToCheck, StringComparison.InvariantCultureIgnoreCase))
         {
             return(TelimenaVersionReader.Read(file, VersionTypes.FileVersion));
         }
     }
     return(null);
 }
示例#6
0
        /// <summary>
        /// Creates an instance of AssemblyInfo, where assembly data is read from Assembly through reflection
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        public AssemblyInfo(Assembly assembly)
        {
            AssemblyName assName = assembly.GetName();

            this.Name      = assName.Name;
            this.Extension = Path.GetExtension(assembly.CodeBase);

            this.VersionData = new VersionData(
                assemblyVersion: TelimenaVersionReader.Read(assembly, VersionTypes.AssemblyVersion),
                fileVersion: TelimenaVersionReader.Read(assembly, VersionTypes.FileVersion)
                );

            this.Location = assembly.Location;
        }
示例#7
0
        public static void ShowArgsRequiredMessage(string[] args, Type type, string appName)
        {
            var msg = $"AssemblyVersion: {TelimenaVersionReader.Read(type, VersionTypes.AssemblyVersion)}\r\n" +
                      $"FileVersion: {TelimenaVersionReader.Read(type, VersionTypes.FileVersion)}\r\n" +
                      $"Telimena Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.AssemblyVersion)}\r\n" +
                      $"Telimena File Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.FileVersion)}";

            Console.WriteLine(msg);
            if (args.Length == 0)
            {
                MessageBox.Show(msg, $"{appName} - This app requires arguments to run");
                return;
            }
        }
        private static void Main(string[] args)
        {
            Console.WriteLine($"Starting {typeof(PackageTriggerUpdaterTestProgram).Assembly.GetName().Name}");

            string msg = $"AssemblyVersion: {TelimenaVersionReader.Read(typeof(PackageTriggerUpdaterTestProgram), VersionTypes.AssemblyVersion)}\r\n" +
                         $"FileVersion: {TelimenaVersionReader.Read(typeof(PackageTriggerUpdaterTestProgram), VersionTypes.FileVersion)}\r\n" +
                         $"Telimena Assembly Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.AssemblyVersion)}\r\n" +
                         $"Telimena File Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.FileVersion)}";

            Console.WriteLine(msg);

            if (args.Length == 0)
            {
                PerformUpdate();
                return;
            }

            Arguments arguments;

            Console.WriteLine("Loading Arguments...");
            string decoded = "";

            try
            {
                decoded   = Base64Decode(args[0]);
                arguments = JsonConvert.DeserializeObject <Arguments>(decoded);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Error while deserializing [{args[0]}], decoded: {decoded}", ex);
            }

            Console.WriteLine($"Args: {decoded}");
            Console.WriteLine("Arguments loaded OK");

            Work(arguments);

            Console.WriteLine("keep the old process running, it needs to be manually killed by the updater");
            int key = Console.Read();

            while (key != 1)
            {
                key = Console.Read();
            }
        }
示例#9
0
        public static bool PrintVersionsAndCheckArgs(string[] args, Type type)
        {
            var lines = new string[]
            {
                TelimenaVersionReader.Read(type, VersionTypes.AssemblyVersion)
                , TelimenaVersionReader.Read(type, VersionTypes.FileVersion)
                , TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.AssemblyVersion)
                , TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.FileVersion)
            };


            Console.WriteLine(string.Join("\r\n", lines));
            if (args.Length == 0)
            {
                File.WriteAllLines("Versions.txt", lines);
                Console.WriteLine("App executed with zero args. Quitting.");
                return(false);
            }

            return(true);
        }
示例#10
0
        static void Main(string[] args)
        {
            Console.WriteLine($"Starting {typeof(TestClientProgram).Assembly.GetName().Name}");

            var msg = $"AssemblyVersion: {TelimenaVersionReader.Read(typeof(TestClientProgram), VersionTypes.AssemblyVersion)}\r\n" +
                      $"FileVersion: {TelimenaVersionReader.Read(typeof(TestClientProgram), VersionTypes.FileVersion)}\r\n" +
                      $"Telimena Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.AssemblyVersion)}\r\n" +
                      $"Telimena File Version: {TelimenaVersionReader.Read(typeof(Telimena), VersionTypes.FileVersion)}";

            Console.WriteLine(msg);
            if (args.Length == 0)
            {
                MessageBox.Show(msg, "AutomaticTestsClient - This app requires arguments to run");
                return;
            }


            var arguments = SharedUtils.LoadArguments(args);

            new TestAppWorker(arguments).Work();
        }
示例#11
0
        public async Task <string> GetFileVersion(Stream stream, string expectedFileName, bool expectSingleFile)
        {
            stream.Position = 0;

            string tempFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            using (Stream file = File.Create(tempFilePath))
            {
                await stream.CopyToAsync(file).ConfigureAwait(false);
            }

            var unzippedPath = this.GetUnzippedPath(tempFilePath, expectedFileName, expectSingleFile);


            var version = TelimenaVersionReader.Read(unzippedPath, VersionTypes.FileVersion);

            if (string.IsNullOrEmpty(version))
            {
                throw new InvalidOperationException("Cannot extract version info from uploaded file");
            }

            return(version);
        }