public async Task Upload() { try { this.CancelTokenSource = new CancellationTokenSource(); this.SelectedApp.PrepareUpload(); AppInfo appInfo = this.SelectedApp.AppInfo; UploadStrategy uploadStrategy = UploadStrategy.GetStrategy(appInfo); await uploadStrategy.Upload(this.SelectedApp.FileToUpload, this._activeUserConfiguration, ReportProgress, _cancelTokenSource.Token); string publicWebSite = this._activeUserConfiguration.ApiBase; publicWebSite = publicWebSite.Substring(0, publicWebSite.Length - 6); System.Diagnostics.Process.Start(publicWebSite + "apps/" + appInfo.PublicID); this.Close(); } catch (TaskCanceledException) { //do nothing } catch (Exception ex) { IWindowManager wm = IoC.Get <IWindowManager>(); wm.ShowMetroMessageBox("Error while creating a new version:\n" + ex.Message); } finally { this.CancelTokenSource = null; } }
static void Main(string[] args) { new CrashHandler(); string exeFile = System.Reflection.Assembly.GetEntryAssembly().Location; string exePath = Path.GetDirectoryName(exeFile); var tmp = System.Configuration.ConfigurationManager.OpenExeConfiguration(exePath + @"\HockeyUpload.exe"); System.Configuration.KeyValueConfigurationCollection col = tmp.AppSettings.Settings; HockeyApp.AppLoader.Model.Configuration c = HockeyApp.AppLoader.Model.Configuration.Instance; if (Environment.CommandLine.ToUpper().Contains("/HELP")) { HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH"); } else if (Environment.GetCommandLineArgs().Count() > 1) { try { _args = Args.Configuration.Configure <HockeyApp.AppLoader.Model.CommandLineArgs>().CreateAndBind(Environment.GetCommandLineArgs()); } catch { HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH"); return; } string errMsg = ""; if (!_args.IsValid(out errMsg)) { LogToConsole("Wrong parameter: " + errMsg); return; } try { AppInfoMatcher matcher = new AppInfoMatcher(); Task <List <AppInfo> > t = matcher.GetMatchingApps(_args); t.Wait(); List <AppInfo> list = t.Result; if (list.Count == 0) { LogToConsole("No matching application found. Please check the configuration information!"); return; } else if (list.Count > 1) { LogToConsole("More than one apps are matching. Please change parameter!"); LogToConsole("Matching apps: " + list.Select(p => p.Title).Aggregate((a, b) => a + "," + b)); return; } UploadStrategy uploader = UploadStrategy.GetStrategy(list.First()); LogToConsole(""); DateTime start = DateTime.Now; Task task = uploader.Upload(_args.Package, matcher.ActiveUserConfiguration, ProgressHandler, CancellationToken.None); task.Wait(); DateTime end = DateTime.Now; TimeSpan sp = end.Subtract(start); FileInfo fi = new FileInfo(_args.Package); long length = fi.Length; length = length / 8; LogToConsole(""); LogToConsole(string.Format("Uploaded {0}KB in {1}sec", length.ToString("###,###,###"), sp.Seconds.ToString("d"))); } catch (Exception ex) { LogToConsole("Error: " + ex.Message); } } else { HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH"); } }