private void MenuItem系统配置_Click(object sender, RoutedEventArgs e) { using (FormConfiguration fc = new FormConfiguration()) { fc.ShowDialog(); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; try { if (UserManager.GetUserCount() == 0) { Application.Run(new FormRegister()); } else { Application.Run(new FormLogin()); } } catch (Exception ex) { if (MessageBox.Show($"Could not connect to SQL server due to:\n{ex.Message}\n\nDo you want to open server configuration?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { using (FormConfiguration frm = new FormConfiguration()) { frm.ShowDialog(); } } } }
private void Print_Click(object sender, EventArgs e) { using (FormConfiguration frm = new FormConfiguration()) { frm.ShowDialog(); } }
private void 系统配置ToolStripMenuItem_Click(object sender, EventArgs e) { //using (FormInputAndAction fiaa = new FormInputAndAction( // str => UserClient.Net_simplify_client.ReadFromServer( // CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess, // JArray.FromObject(UserClient.SystemFactories).ToString(), // "请按照JSON格式更新分厂信息,然后提交:")) //{ // fiaa.ShowDialog(); //} using (FormConfiguration fc = new FormConfiguration()) { fc.ShowDialog(); } }
/// <summary> /// New method to show the configuration form /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void apptCalendar_ConfigurationButtonClicked(object sender, EventArgs e) { using (FormConfiguration cfg = new FormConfiguration()) { if (cfg.ShowDialog() == DialogResult.OK) { this.NumDays = cfg.NumDays; this.MailAlertsEnabled = cfg.MailAlertsEnabled; this.ShowPastAppointments = cfg.ShowPastAppointments; this.Accounts = cfg.Accounts; this.ShowFriendlyGroupHeaders = cfg.ShowFriendlyGroupHeaders; this.ShowDayNames = cfg.ShowDayNames; this.ShowWeekNumbers = cfg.ShowWeekNumbers; this.ShowTasks = cfg.ShowTasks; this.ShowCompletedTasks = cfg.ShowCompletedTasks; this.FirstDayOfWeek = cfg.FirstDayOfWeek; this.RetrieveData(); } } }
/// <summary> /// Show options dialog. /// </summary> /// <remarks> /// Currently the <paramref name="strCurrentOptions"/> parameter will be ignored. /// </remarks> /// <param name="strCurrentOptions">Seems to be the Keepass profile name</param> /// <returns></returns> public override string GetOptions(string strCurrentOptions) { try { InitWuerfelwareFileReaderIfNecessary(); var persistence = new ConfigurationPersistence(); var config = persistence.LoadFromUserFile(); if (null == config) { config = new ConfigurationModel(); } var form = new FormConfiguration(config); form.setData(WuerfelwareFileReader.FilePath, WuerfelwareFileReader.EntryCount); form.ShowDialog(); persistence.SaveToUserFile(form.Configuration); } catch (Exception e) { MessageBox.Show("Error while loading or saving properties.\n\nError message: '" + e.Message + "'\n\nError details: " + e.ToString()); } return(base.GetOptions(strCurrentOptions)); }
private static void ArgumnentsAhead(string[] args) { LogAttrbute.log.Info("There are top level argument has been caught to read it"); switch (args[0]) { case "-h": LogAttrbute.log.Info("top level argument for help, showing help"); Console.WriteLine( @"Top level Arguments:- -h Show help -s Settings -c Check for updates -v Version -l License Settings:- --r Release directory setting ---add[directory name] Add release directory location ---remove [directory name] Remove exist directory form release directory list ---show Show All release directories from the list ---clear Clear all release directories list --e Exclude list settings:- ---add[filename] Add file to be excluded from packaging ---remove [filename] Remove exist exclude from the database to be included to the list ---show Show All exclude files list ---clear Clear all exclude file list --g Show GUI setting --log [true|false] Enable Logging --clear Clear all settings License arguments --g Show graphical user interface window" ); break; case "-v": LogAttrbute.log.Info("Top level argument for getting version, getting version"); Console.WriteLine("Packager v" + typeof(Program).Assembly.GetName().Version.ToString()); break; case "-l": LogAttrbute.log.Info("Top level argument for getting license of the project"); if (args.Length < 2) { LogAttrbute.log.Info("License getting from LICENSE file"); FileInfo lic = new FileInfo("LICENSE"); LogAttrbute.log.Info("Checking if the license file is available or not"); if (!lic.Exists) { LogAttrbute.log.Info("License file not found, showing warning message"); Console.WriteLine("Warning :License not found, you can view it at http://www.gnu.org/licenses/gpl-3.0.en.html"); LogAttrbute.log.Info("Exit application with file not found existing for LICENSE file"); return; } LogAttrbute.log.Info("File founded and now using read only stream file"); StreamReader strmreader = new StreamReader(lic.OpenRead()); LogAttrbute.log.Info("Writing a little bit big output for LICENSE file"); Console.WriteLine(strmreader.ReadToEnd()); LogAttrbute.log.Info("Writing output completed"); LogAttrbute.log.Info("Exit application"); return; } LogAttrbute.log.Info("Second level argument for checking argument"); switch (args[1]) { case "--g": LogAttrbute.log.Info("Argument is getting gui window for showing license"); var s = new Packager.License(); LogAttrbute.log.Info("Showing license window.."); s.ShowDialog(); LogAttrbute.log.Info("The user closed the window"); break; default: LogAttrbute.log.Info("The input arg is invalid , showing Error message"); Console.Error.WriteLine("Argument unknown, please type -h for argument list"); break; } break; case "-c": LogAttrbute.log.Info("Top level arg for checking for update on the GitHub repo"); LogAttrbute.log.Info("Calling managed code..."); if (!CheckNet()) { LogAttrbute.log.Info("No connection to the Internet, or Internet is unavailable, because CheckNet() call InternetGetConnectedState(out desc, 0); for if there is Internet and returned that there are no Internet access"); Console.Error.WriteLine("Please check your Internet connection in order to check the update. Or Go to https://github.com/AlkindiX/packager/releases"); return; } LogAttrbute.log.Info("There are an Internet connection, processing to the update checker..."); LogAttrbute.log.Info("Preparing GitHubClient from OctaKit using GitHub API"); GitHubClient clinet = new GitHubClient(new ProductHeaderValue("packager")); LogAttrbute.log.Info("Preparing to invoke for all releases from GitHub release from project packager repo by the creator of the progrma AlkindiX "); var release = clinet.Release.GetAll("AlkindiX", "packager"); Release re = null; LogAttrbute.log.Info("The release checking is invoked, now waiting for result form GitHub..."); Console.WriteLine("Checking for update..."); release.Wait(); LogAttrbute.log.Info("Result getting successfully"); foreach (var item in release.Result) { LogAttrbute.log.Info("Getting the latest release at the top of the list and break the loop"); re = item; break; } Console.WriteLine("The current release of packager is {0} released at {1}, you can download it at \n{2}", re.TagName, re.PublishedAt.ToString(), re.HtmlUrl); Console.WriteLine("Change log:- \n{0}", re.Body); LogAttrbute.log.Info("Invoking GetAllRelease for getting files inside the release"); var ass = clinet.Release.GetAllAssets("AlkindiX", "packager", re.Id); Console.WriteLine("Reading files on the current update..."); ass.Wait(); LogAttrbute.log.Info("Checking if dir updates is exist"); DirectoryInfo updatedir = new DirectoryInfo("updates"); if (!updatedir.Exists) { LogAttrbute.log.Info("Creating update dir"); updatedir.Create(); } LogAttrbute.log.Info("Create version file"); DirectoryInfo tagdir = new DirectoryInfo(Path.Combine(updatedir.FullName, re.TagName)); if (!tagdir.Exists) { tagdir.Create(); } LogAttrbute.log.Info("Begin perform download operation"); int x = 0; foreach (var item in ass.Result) { x++; Console.WriteLine("{0} {1}", x.ToString(), item.Name); Console.WriteLine("Downloading {0}", item.Name); WebClient clin = new WebClient(); var file_full_path = Path.Combine(tagdir.FullName, item.Name); if (File.Exists(file_full_path)) { Console.WriteLine("Warning: The release is already exist {0}", file_full_path); File.Delete(file_full_path); } clin.DownloadFile(item.BrowserDownloadUrl, file_full_path); Console.WriteLine("Downloading complete at {0}", file_full_path); } LogAttrbute.log.Info("End download operation"); break; case "-s": if (args.Length < 2) { Console.Error.WriteLine("Arguments are missing, type -h for argument list"); return; } switch (args[1]) { case "--log": LogAttrbute.log.Info("Second level for setting the logging value"); if (args.Length < 3) { LogAttrbute.log.LogFast(Common.Logging.Logging.LogFastInfo.Error, "Missing argument for logging value"); Console.Error.WriteLine("Missing argument for enable logging"); return; } try { switch (bool.Parse(args[2])) { case true: LogAttrbute.log.Info("Logging is enabled"); Settings.Default.EnableLog = true; Console.WriteLine("Logging is enabled"); break; case false: LogAttrbute.log.Info("Logging is disabled"); Settings.Default.EnableLog = false; Console.WriteLine("Logging is disabled"); break; } } catch (FormatException fx) { LogAttrbute.log.LogFast(Common.Logging.Logging.LogFastInfo.Exception, fx.ToString()); Console.Error.WriteLine("The format given is invalid"); } break; case "--clear": Console.WriteLine("Reseting data..."); Settings.Default.Reset(); Console.WriteLine("All data cleared"); break; case "--g": System.Windows.Forms.Application.EnableVisualStyles(); FormConfiguration config = new FormConfiguration(); config.ShowDialog(); break; case "--r": if (args.Length < 3) { Console.WriteLine("Missing arguments, please type -h for more information"); return; } switch (args[2]) { case "---add": if (args.Length < 4) { Console.Error.WriteLine("Missing argument, please enter the directory name to be added"); } try { DirectoryInfo info = new DirectoryInfo(args[3]); if (!info.Exists) { Console.Error.WriteLine("The directory is not founded"); return; } if (Settings.Default.ReleaseLocation.Contains(info.FullName)) { Console.Error.WriteLine("The directory is already added to the release location list"); return; } Settings.Default.ReleaseLocation.Add(info.FullName); Console.WriteLine("The directory name \"" + info.FullName + "has been added to the release location list"); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } break; case "---rm": if (args.Length < 4) { Console.Error.WriteLine("Missing argument, please enter the directory name to be removed"); return; } try { DirectoryInfo info = new DirectoryInfo(args[3]); if (!Settings.Default.ReleaseLocation.Contains(info.FullName)) { Console.Error.WriteLine("The directory you have entered is not on the release directory database"); return; } Settings.Default.ReleaseLocation.Remove(info.FullName); Console.WriteLine("The directory name \"" + info.FullName + "has been removed from the release location list"); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } break; case "---show": foreach (var item in Settings.Default.ReleaseLocation) { Console.WriteLine(item); } break; case "---clear": Settings.Default.ReleaseLocation.Clear(); break; default: Console.WriteLine("Missing arguments, please enter -h for argument list"); break; } break; case "--e": if (args.Length < 3) { Console.WriteLine("Missing arguments, type -h for argument list"); return; } switch (args[2]) { case "---add": if (args.Length < 4) { Console.WriteLine("You didn't write the file to be exclude"); } else { if (!Settings.Default.ExcludeFileList.Contains(args[3])) { Settings.Default.ExcludeFileList.Add(args[3]); Console.WriteLine("The filename: \"" + args[3] + "\" Added to the exclude list"); } else { Console.WriteLine("The filename: \"" + args[3] + "\" is already included in the exclude list"); } } break; case "---rm": if (args.Length < 4) { Console.WriteLine("You didn't write the file to be include"); } else { if (!Settings.Default.ExcludeFileList.Contains(args[3])) { Console.Error.WriteLine("File is not found in the list"); } else { Settings.Default.ExcludeFileList.Remove(args[3]); Console.WriteLine("The filename: \"" + args[3] + "\" removed from the exclude list"); } } break; case "---show": if (Settings.Default.ExcludeFileList.Count == 0) { Console.WriteLine("The list is empty"); } foreach (var item in Settings.Default.ExcludeFileList) { Console.WriteLine(item); } break; case "---clear": if (Settings.Default.ExcludeFileList.Count == 0) { Console.WriteLine("The list is empty and nothing to be cleared"); } Settings.Default.ExcludeFileList.Clear(); break; default: Console.Error.WriteLine("Unknown arguments, -h for argument list"); break; } break; default: Console.WriteLine("Unknown argument, type -h for argument list"); break; } break; default: Console.Error.WriteLine("Argument is invalid, type -h for more informations"); break; } }