예제 #1
0
파일: Updater.cs 프로젝트: 65001/DBM-CSharp
        public static void CheckForUpdates(string downloadlocation, string URI = GlobalStatic.OnlineDB_Refrence_Location, bool UI = true)
        {
            int StackReference = Stack.Add($"Utilities.Updater.CheckForUpdates({UI})");

            if (string.IsNullOrWhiteSpace(UpdaterDB) == false || LDNetwork.DownloadFile(downloadlocation, URI) != -1)
            {
                int LatestVersion = LatestUpdate();
                int.TryParse(GlobalStatic.VersionID, out int CurrentVersion);

                string[] Locations         = FetchLinks();
                string   DownloadLocation  = Locations[0];
                string   DownloadLocation2 = Locations[1];

                if (CurrentVersion == LatestVersion && UI == true)
                {
                    GraphicsWindow.ShowMessage("There are no updates available", Language.Localization["NoUpdates"] ?? "No Updates"); //TODO LOCALIZE
                }
                else if (CurrentVersion > LatestVersion && UI == true)
                {
                    GraphicsWindow.ShowMessage("You have a more recent edition of the program than that offered to the public.\nYou have version " + CurrentVersion + " while the most recent public release is version " + LatestVersion,
                                               Language.Localization["NoUpdates"] ?? "No Updates");
                }
                else if (CurrentVersion < LatestVersion)
                {
                    if (LDDialogs.Confirm($"Do you wish to download Version {LatestVersion }? You have Version {CurrentVersion}.", "Download Update") == "Yes") //TODO LOCALIZE
                    {
                        if (Download(DownloadLocation) == false)
                        {
                            Download(DownloadLocation2);
                        }
                    }
                }
                Primitive Temp = GlobalStatic.Settings["Updates"];
                Temp["LastCheck"] = DateTime.Now.ToString("yyyy-MM-dd");
                GlobalStatic.Settings["Updates"] = Temp;
                Settings.Save();
                Settings.Load(GlobalStatic.RestoreSettings, GlobalStatic.SettingsPath);
            }
            else
            {
                GraphicsWindow.ShowMessage(
                    Language.Localization["Check Log"],
                    Language.Localization["Error"]);
            }
            Stack.Exit(StackReference);
        }
예제 #2
0
파일: DBM.cs 프로젝트: 65001/DBM-CSharp
        public static void CreateTableHandler()
        {
            int    StackPointer = Stack.Add("UI.CreateTableHandler()");
            string LastButton   = Controls.LastClickedButton;
            string Name         = Controls.GetTextBoxText(_TextBox["Table_Name"]);

            if (LastButton == _Buttons["Commit"])
            {
                if (!string.IsNullOrWhiteSpace(Name))
                {
                    Name = Name.Replace("[", "").Replace("]", "").Replace("\"", "");
                    int Max = LDControls.DataViewRowCount(GlobalStatic.Dataview);

                    StringBuilder Define_SQL = new StringBuilder();
                    Define_SQL.Append("CREATE TABLE \"" + Name + "\"(");
                    for (int i = 1; i <= Max; i++)
                    {
                        Primitive _Data = LDControls.DataViewGetRow(GlobalStatic.Dataview, i);
                        if (!string.IsNullOrWhiteSpace(_Data[1]))
                        {
                            if (_Data[4] == true)
                            {
                                _Data[3] = true;
                            }
                            string Field = ((string)_Data[1]).Replace("[", "").Replace("]", "").Replace("\"", "");
                            Define_SQL.AppendFormat("\"{0}\" {1}", Field, (string)_Data[2]);

                            if (_Data[6] == true)
                            {
                                Define_SQL.Append(" NOT NULL");
                            }
                            if (_Data[3] == true)
                            {
                                Define_SQL.Append(" PRIMARY KEY");
                            }
                            if (_Data[4] == true)
                            {
                                Define_SQL.Append(" AUTOINCREMENT");
                            }
                            if (_Data[5] == true)
                            {
                                Define_SQL.Append(" UNIQUE");
                            }
                            if (i != Max)
                            {
                                Define_SQL.Append(",");
                            }
                            else
                            {
                                Define_SQL.Append(");");
                            }
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(Engines.CurrentDatabase))
                    {
                        string Confirmation = LDDialogs.Confirm("Do you wish to commit the following SQL:\n" + Define_SQL.ToString() + "\n to " + Engines.DB_ShortName[Engines.DB_Name.IndexOf(Engines.CurrentDatabase)], "Commit SQL");
                        if (Confirmation == "Yes")
                        {
                            Engines.CommandSettings CS = new Engines.CommandSettings()
                            {
                                Database    = Engines.CurrentDatabase,
                                SQL         = Define_SQL.ToString(),
                                User        = GlobalStatic.UserName,
                                Explanation = "User Defining a Table" //Localize
                            };
                            Engines.Command(CS);
                        }
                    }
                }
                else
                {
                    GraphicsWindow.ShowMessage("Table Name is not empty, please fill it!", "NAME");
                }
                Stack.Exit(StackPointer);
                return;
            }

            if (LastButton == _Buttons["Exit"])
            {
                Controls.ButtonClicked -= CreateTableHandler;
                Controls.ButtonClicked += Events.BC;
                ClearWindow();
                DisplayResults();
                ShowDisplayResults();
                MainMenu();
                //Events.MC("View");
                Stack.Exit(StackPointer);
                return;
            }


            Stack.Exit(StackPointer);
        }