Пример #1
0
        private static void ZipFile_Compression(out List <string> mess)
        {
            mess = new List <string>();
            var    startZip     = true;
            string sourceZipKey = ConfigurationManager.AppSettings["SourceZip"];

            if (string.IsNullOrEmpty(sourceZipKey))
            {
                startZip = false;
                Console.WriteLine("SourceZip not found in App.config");
                mess.Add("SourceZip not found in App.config");
            }
            string sourcePathFileZip = ConfigurationManager.AppSettings["TargetZip"];

            if (string.IsNullOrEmpty(sourcePathFileZip))
            {
                startZip = false;
                Console.WriteLine("TargetZip not found in App.config");
                mess.Add("TargetZip not found in App.config");
            }


            if (startZip)
            {
                //read file version
                var pathVersion = Path.Combine(sourceZipKey, "PcstVersion.txt");
                if (!File.Exists(pathVersion))
                {
                    File.Create(pathVersion).Close();
                }

                _versionPcstOld = File.ReadAllText(pathVersion);
                _versionPcstNew = UpgradeVersion.UpgradeVersionText(_versionPcstOld);

                FileHelper.WriteFile(pathVersion, _versionPcstNew);


                string filePathOfNewFolder = sourceZipKey;
                string zipFilePath         = sourcePathFileZip;

                var start = DateTime.Now;
                Console.WriteLine(start.ToString("MM-dd-yyyy HH:mm:ss") + ": Start Zip");
                mess.Add(start.ToString("MM-dd-yyyy HH:mm:ss") + ": Start Zip");

                if (File.Exists(zipFilePath))
                {
                    File.Delete(zipFilePath);
                }

                ZipFile.CreateFromDirectory(filePathOfNewFolder, zipFilePath);

                var end = DateTime.Now;
                Console.WriteLine(end.ToString("MM-dd-yyyy HH:mm:ss") + ": End Zip");
                Console.WriteLine("Total Zip: " + (end - start).TotalSeconds + " s");
                mess.Add(end.ToString("MM-dd-yyyy HH:mm:ss") + ": End Zip");
                mess.Add("Total Zip: " + (end - start).TotalSeconds + " s\n");
            }
        }
Пример #2
0
        public UpgradeVersion Select_Active_Version()
        {
            MySqlConnection connection = null;

            try
            {
                var version = new UpgradeVersion();

                string query = @"
                    select *
                    from upgrade_version
                    where active = 1
                    order by id desc
                ";

                //Create a list to store the result
                //Open connection
                connection = this.OpenConnection();
                {
                    //Create Command
                    MySqlCommand cmd = new MySqlCommand(query, connection);
                    //Create a data reader and Execute the command
                    MySqlDataReader dataReader = cmd.ExecuteReader();

                    //Read the data and store them in the list
                    while (dataReader.Read())
                    {
                        // ServiceLog.WriteErrorLog("connection_status=" + ((dataReader["connection_status"] + "")));
                        // ServiceLog.WriteErrorLog("allow_send_sms=" + ((dataReader["allow_send_sms"] + "")));
                        version = new UpgradeVersion()
                        {
                            id         = dataReader["id"] + "",
                            version    = dataReader["version"] + "",
                            uri_file   = dataReader["uri_file"] + "",
                            active     = bool.Parse(dataReader["active"] + ""),
                            createdate = dataReader["createdate"] + ""
                        };

                        break;
                    }

                    //close Data Reader
                    dataReader.Close();

                    //close Connection
                    this.CloseConnection(connection);

                    //return list to be displayed
                    return(version);
                }

                return(null);
            }
            catch (Exception ex)
            {
                ServiceLog.WriteErrorLog(ex);
                //close Connection
                this.CloseConnection(connection);
                return(null);
            }
        }
Пример #3
0
 public virtual void VisitUpgradeVersion(UpgradeVersion node)
 {
 }