コード例 #1
0
        public static void Main(string[] rgArgs)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ErrorReport.AddProperty("EmailAddress", "*****@*****.**");
            ErrorReport.AddStandardProperties();
            ExceptionHandler.Init();

            s_loadingWnd = new SmallFadingWnd(Properties.Resources.kstidLoadingProgramMsg);

            PortableSettingsProvider.SettingsFileFolder = App.ProjectFolder;
            PortableSettingsProvider.SettingsFileName   = "PCIEditor.settings";

            string inventoryFilePath =
                FileLocator.GetDirectoryDistributedWithApplication(App.ConfigFolderName);

            // This is the poor man's way of determining whether or not the user has
            // write access to the folder in which the phonetic inventory
            // is stored. I'm sure there is a great class in .Net to use for such a
            // thing, but I couldn't find it in the little bit of digging I did. Sigh!
            string tmpFile = Path.Combine(inventoryFilePath, "!~tmpaccesstest~!");

            try
            {
                File.WriteAllText(tmpFile, string.Empty);
            }
            catch
            {
                string msg = string.Format(Properties.Resources.kstidWriteAccessErrorMsg, inventoryFilePath);
                Utils.MsgBox(msg);
                return;
            }

            File.Delete(tmpFile);

            string inventoryPath = null;

            try
            {
                // Make sure the phonetic inventory file exists.
                inventoryPath = FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName,
                                                                              App.kDefaultInventoryFileName);
            }
            catch
            {
                string filePath = Utils.PrepFilePathForMsgBox(inventoryPath);
                string msg      = string.Format(Properties.Resources.kstidInventoryFileMissing, filePath);
                Utils.MsgBox(msg);
                return;
            }

            var editor = new PCIEditor();

            editor.OpenFile(inventoryPath);
            Application.Run(editor);
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            if (s_loadingWnd != null)
            {
                s_loadingWnd.CloseFade();
                s_loadingWnd.Dispose();
                s_loadingWnd = null;
            }

            SortList(m_symbols[0]);
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Starts SQL Server (MSDE) or makes sure it's started.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static bool StartSQLServer(bool showErrMessages)
        {
            if (!IsSQLServerInstalled(showErrMessages))
            {
                return(false);
            }

            Exception error = null;

            while (true)
            {
                try
                {
                    using (var svcController = new ServiceController(FwDBAccessInfo.Service))
                    {
                        // If the server instance is already running, we're good.
                        if (svcController.Status == ServiceControllerStatus.Running)
                        {
                            return(true);
                        }

                        var startingSQLMsg = LocalizationManager.GetString(
                            "Miscellaneous.Messages.DataSourceReading.StartingSQLServerMsg", "Starting SQL Server...");

                        using (var msgWnd = new SmallFadingWnd(startingSQLMsg))
                        {
                            msgWnd.Show();
                            Application.DoEvents();

                            // Start the server instance and wait 15 seconds for it to finish starting.
                            if (svcController.Status == ServiceControllerStatus.Paused)
                            {
                                svcController.Continue();
                            }
                            else
                            {
                                svcController.Start();
                            }

                            svcController.WaitForStatus(ServiceControllerStatus.Running,
                                                        new TimeSpan(FwDBAccessInfo.SecsToWaitForDBEngineStartup * (long)10000000));

                            msgWnd.CloseFade();
                        }

                        if (svcController.Status == ServiceControllerStatus.Running)
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (!showErrMessages)
                    {
                        continue;
                    }

                    error = e;
                }

                if (!showErrMessages || error == null)
                {
                    continue;
                }

                // Check if we've timed out.
                if (error.Message.ToLower().IndexOf("time out") < 0)
                {
                    ErrorReport.NotifyUserOfProblem(error, LocalizationManager.GetString(
                                                        "Miscellaneous.Messages.DataSourceReading.ErrorStartingSQLServer1",
                                                        "SQL Server cannot be started. It may not be installed. Make sure " +
                                                        "FieldWorks Language Explorer has been installed or restart Phonology " +
                                                        "Assistant to try again."));

                    return(false);
                }

                var msg = LocalizationManager.GetString("Miscellaneous.Messages.DataSourceReading.ErrorStartingSQLServer2",
                                                        "Phonology Assistant waited {0} seconds for SQL Server to fully start up." +
                                                        "\nEither that is not enough time for your computer or it may not be installed." +
                                                        "\nMake sure FieldWorks Language Explorer has been installed. Would you\nlike to try again?");

                msg = String.Format(msg, FwDBAccessInfo.SecsToWaitForDBEngineStartup);

                if (Utils.MsgBox(msg, MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return(false);
                }
            }
        }
コード例 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the list of FW databases on the specified machine.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static IEnumerable <FwDataSourceInfo> GetFwDataSourceInfoList(string server,
                                                                             bool showErrorOnFailure)
        {
            // Make sure SQL server is running.
            if (!IsSQLServerStarted)
            {
                return(null);
            }

            s_showErrorOnConnectionFailure = showErrorOnFailure;
            var fwDBInfoList = new List <FwDataSourceInfo>();

            SmallFadingWnd msgWnd = null;

            if (ShowMsgWhenGatheringFWInfo)
            {
                msgWnd = new SmallFadingWnd(LocalizationManager.GetString(
                                                "Miscellaneous.Messages.DataSourceReading.GatheringFw6ProjectInfoMsg",
                                                "Gathering FieldWorks Project Information..."));
            }
            try
            {
                // Read all the SQL databases from the server's master table.
                using (var connection = FwConnection(FwDBAccessInfo.MasterDB, server))
                {
                    if (connection != null && FwDBAccessInfo.FwDatabasesSQL != null)
                    {
                        var command = new SqlCommand(FwDBAccessInfo.FwDatabasesSQL, connection);

                        // Get all the database names.
                        using (var reader = command.ExecuteReader(CommandBehavior.SingleResult))
                        {
                            while (reader.Read() && !String.IsNullOrEmpty(reader[0] as string))
                            {
                                fwDBInfoList.Add(new FwDataSourceInfo(reader[0] as string, server, DataSourceType.FW));
                            }

                            reader.Close();
                        }

                        connection.Close();
                    }
                }
            }
            catch (Exception e)
            {
                if (s_showErrorOnConnectionFailure)
                {
                    ErrorReport.NotifyUserOfProblem(e, LocalizationManager.GetString(
                                                        "Miscellaneous.Messages.DataSourceReading.ErrorGettingFwProjectMsg",
                                                        "An error occurred while trying to get a list of FieldWorks projects."));
                }

                fwDBInfoList = null;
            }

            if (msgWnd != null)
            {
                msgWnd.CloseFade();
                msgWnd.Dispose();
            }

            s_showErrorOnConnectionFailure = true;
            return(fwDBInfoList);
        }