Example #1
0
        public Form1()
        {
            InitializeComponent();
            //this.Font = new System.Drawing.Font("黑体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            MyConfig.of_CreateDB("config.db");

            string ls_rc;   //先设置要联结的数据库

            MyConfig.DbName = "config.db";

            string ls_tbname;

            ls_tbname = "mysysset";
            if (!MyConfig.of_ExistObj(ls_tbname, SqlHelper.ObjTypeList.Table))
            {
                string ls_sql = @"CREATE TABLE mysysset ( 
                                    itemtype  VARCHAR( 50 )   NOT NULL,
                                    itemName  VARCHAR( 50 )   NOT NULL,
                                       itemvalue VARCHAR( 200 ),
                                        memo      VARCHAR( 200 ) 
                                        );  ";

                ls_rc = MyConfig.ExecuteNonQuery(ls_sql).ToString();
            }
        }
Example #2
0
        //备份到2号服务器
        private void vf_Ftp2(object a)
        {
            Tools.WriteLog("Log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "进入FTP2");
            //检查是否有未上传的文件
            while (!ib_Ftp2Upload)
            {
                bool OK = false;
                //List<string> list = INIFile.ReadKeyValues("IfFtpUpLoad");
                List <string> list       = SysVisitor.Current.ReadKeyValues("IfFtpUpLoad");
                List <string> ls_Ftplist = ListToUploadList(list, "Ftp2");//获取待上传文件列表
                if (ls_Ftplist.Count > 0)
                {
                    OK = true;
                }             //有文件未上传

                //获取FTP2相关参数
                string IP       = SysVisitor.Current.of_GetMySysSet("FTP2", "IP");
                string UserID   = SysVisitor.Current.of_GetMySysSet("FTP2", "UserID");
                string Password = SysVisitor.Current.of_GetMySysSet("FTP2", "Password");
                string Path     = SysVisitor.Current.of_GetMySysSet("FTP2", "Path");
                string Port     = SysVisitor.Current.of_GetMySysSet("FTP2", "Port");
                FtpWeb Ftp      = new FtpWeb(IP, Path, UserID, Password);
                if (!Ftp.Connect())//FTP 不可用
                {
                    ib_Ftp2Upload = true;
                    Tools.WriteLog("error", "FTP2服务器不可用");
                    break;
                }
                if (OK)
                {
                    if (!Ftp.DirectoryExist(DateTime.Now.ToString("yyyy-MM-dd")))
                    {
                        Ftp.MakeDir(DateTime.Now.ToString("yyyy-MM-dd"));
                    }
                    Path = Path + @"\" + DateTime.Now.ToString("yyyy-MM-dd");
                    //FTP2文件上传
                    FtpWeb ftp   = new FtpWeb(IP, Path, UserID, Password);
                    int    value = 0;//计算上传成功总数
                    for (int i = 0; i < ls_Ftplist.Count; i++)
                    {
                        int j = ftp.Upload(ls_Ftplist[i].ToString());
                        if (j == 1)//上传成功
                        {
                            value++;
                        }
                        string str = SysVisitor.Current.of_GetMySysSet("IfFtpUpLoad", ls_Ftplist[i].ToString());
                        str = str.Substring(str.Length - 3, 1);
                        SysVisitor.Current.of_SetMySysSet("IfFtpUpLoad", ls_Ftplist[i].ToString(), str + ",0");//更新节点

                        string ls_sql = "delete from mysysset where itemtype='IfFtpUpLoad' and itemvalue='0,0'";
                        MyConfig.ExecuteNonQuery(ls_sql);
                    }
                    Tools.WriteLog("Ftp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "FTP2已成功上传 " + value + " 个文件,剩余待上传个数:" + (ls_Ftplist.Count - value));
                }
                Thread.Sleep(60 * 1000);//等待60秒
            }
            return;
        }  //Getreport