Beispiel #1
0
        /// <summary>
        /// Clear old folders
        /// </summary>
        void CleanOldTempFolders()
        {
            var   folders = Directory.GetDirectories(m_tempFolder);
            Int64 pv      = 0;

            Int64.TryParse(GetPOSVersion(), out pv);
            foreach (var folder in folders)
            {
                Int64  vf = 0;
                string f  = folder.Substring(m_tempFolder.Length);
                f = f.Replace("\\", "");
                Int64.TryParse(f, out vf);
                if (vf < pv)
                {
                    try
                    {
                        Directory.Delete(folder, true);
                    }
                    catch (Exception ex)
                    {
                        POSFtpClient.LogMessage(ex);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Run all sql files in a folder
        /// </summary>
        /// <param name="folder"></param>
        void RunPatchSql(string folder, string dbFile)
        {
            string[] sqlFiles = Directory.GetFiles(folder, "*.sql");
            foreach (var filePath in sqlFiles)
            {
                string sqlCommand = File.ReadAllText(filePath);

                try
                {
                    string connString = string.Format(CONN_STRING, dbFile);
                    using (SQLiteConnection conn = new SQLiteConnection(connString))
                    {
                        using (var cmd = new SQLiteCommand(sqlCommand, conn))
                        {
                            cmd.CommandType = CommandType.Text;
                            if (conn.State != ConnectionState.Open)
                            {
                                conn.Open();
                            }

                            cmd.ExecuteNonQuery();
                        }
                    }
                }
                catch (Exception ex)
                {
                    POSFtpClient.LogMessage(ex);
                }
            }
        }