Exemple #1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            YCTSetting yct = (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).GetOrCreateSetting <YCTSetting>();

            yct.FTPServer   = txtFTPServer.Text;
            yct.FTPPort     = txtFTPPort.IntergerValue;
            yct.FTPUser     = txtFTPUser.Text;
            yct.FTPPassword = txtFTPPwd.Text;
            (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).SaveSetting <YCTSetting>(yct);

            try
            {
                using (FtpClient ftp = new FtpClient())
                {
                    ftp.Host        = yct.FTPServer;
                    ftp.Port        = yct.FTPPort;
                    ftp.Credentials = new System.Net.NetworkCredential(string.IsNullOrEmpty(yct.FTPUser) ? "anonymous" : yct.FTPUser, string.IsNullOrEmpty(yct.FTPPassword) ? "huihai.com" : yct.FTPPassword);
                    ftp.Connect();
                    InsertMsg("连接FTP服务器" + (ftp.IsConnected ? "成功" : "失败"));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                InsertMsg("连接FTP服务器失败:" + ex.Message);
            }
        }
Exemple #2
0
 private void DoSync()
 {
     try
     {
         _Dosyncing = true;
         InsertMsg("开始进行同步...");
         YCTSetting yct = (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).GetSetting <YCTSetting>();
         if (yct != null && !string.IsNullOrEmpty(yct.FTPServer) && yct.FTPPort > 0)
         {
             using (FtpClient ftp = new FtpClient())
             {
                 ftp.Host = yct.FTPServer;
                 ftp.Port = yct.FTPPort;
                 ftp.DataConnectionType = FtpDataConnectionType.PORT; //数据传输设置成主动
                 ftp.Credentials        = new System.Net.NetworkCredential(string.IsNullOrEmpty(yct.FTPUser) ? "anonymous" : yct.FTPUser, string.IsNullOrEmpty(yct.FTPPassword) ? "huihai.com" : yct.FTPPassword);
                 var temp = ftp.SystemType;                           //获取系统类型
                 SyncUploadFiles(ftp, yct);                           //同频上传目录
                 SyncDownloadFiles(ftp);                              //同步下载目录,
             }
         }
     }
     catch (Exception ex)
     {
         InsertMsg(ex.Message);
     }
     finally
     {
         _Dosyncing = false;
         InsertMsg(" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
     }
 }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }
            YCTSetting yct = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetOrCreateSetting <YCTSetting>();

            yct.Items.Clear();
            yct.ServiceCode     = txtServiceCode.IntergerValue;
            yct.ReaderCode      = txtReaderCode.IntergerValue;
            yct.MaxOfflineMonth = txtMaxofflineMonth.IntergerValue;
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                yct.Items.Add(row.Tag as YCTItem);
            }
            CommandResult ret = (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).SaveSetting <YCTSetting>(yct);

            if (CustomCardTypeSetting.Current.GetCardType(YCTSetting.CardTyte) == null) //增加自定义卡片类型
            {
                CustomCardTypeSetting.Current.AddCardType(YCTSetting.CardTyte, (byte)Ralid.Park.BusinessModel.Enum.CardType.MonthRentCard);
                new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect).SaveSetting <CustomCardTypeSetting>(CustomCardTypeSetting.Current);
            }
            if (ret.Result == ResultCode.Successful)
            {
                AppSettings.CurrentSetting.SaveConfig("EnableYCT", chkEnable.Checked.ToString());
                OpenCardMessageHandler handler = GlobalSettings.Current.Get <OpenCardMessageHandler>();
                if (chkEnable.Checked)
                {
                    handler.InitService(yct);
                }
                else
                {
                    handler.CloseService <YCTSetting>();
                }
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(ret.Message);
            }
        }
Exemple #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text += string.Format(" [{0}]", Application.ProductVersion);
            if (string.IsNullOrEmpty(AppSettings.CurrentSetting.MasterParkConnect) || !CheckConnect(AppSettings.CurrentSetting.MasterParkConnect))
            {
                FrmConnect frm = new FrmConnect();
                frm.StartPosition = FormStartPosition.CenterParent;
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    Environment.Exit(0);
                }
            }
            UpGradeDataBase(); //生成需要的一些表

            string temp = AppSettings.CurrentSetting.GetConfigContent("WriteFolder");

            if (!string.IsNullOrEmpty(temp))
            {
                _WriteFolder = temp;
            }
            temp = AppSettings.CurrentSetting.GetConfigContent("ReadFolder");
            if (!string.IsNullOrEmpty(temp))
            {
                _ReadFolder = temp;
            }

            YCTSetting yct = (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).GetSetting <YCTSetting>();

            if (yct != null)
            {
                txtFTPServer.Text        = yct.FTPServer;
                txtFTPPort.IntergerValue = yct.FTPPort;
                txtFTPUser.Text          = yct.FTPUser;
                txtFTPPwd.Text           = yct.FTPPassword;
            }

            Thread t = new Thread(new ThreadStart(SyncFile_Thread));

            t.IsBackground = true;
            t.Start();
        }
Exemple #5
0
        private void FrmZSTSetting_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            YCTSetting yct = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <YCTSetting>();

            if (yct != null)
            {
                txtServiceCode.IntergerValue     = yct.ServiceCode;
                txtReaderCode.IntergerValue      = yct.ReaderCode;
                txtMaxofflineMonth.IntergerValue = yct.MaxOfflineMonth;
                dataGridView1.Rows.Clear();
                if (yct.Items != null && yct.Items.Count > 0)
                {
                    foreach (YCTItem item in yct.Items)
                    {
                        int row = dataGridView1.Rows.Add();
                        ShowItemOnRow(dataGridView1.Rows[row], item);
                    }
                }
            }
            chkEnable.Checked = GlobalSettings.Current.Get <OpenCardMessageHandler>().ContainService <YCTSetting>();
        }
Exemple #6
0
        private void InitOpenCardServices(object obj)
        {
            OpenCardMessageHandler handler = new OpenCardMessageHandler();

            GlobalSettings.Current.Set <OpenCardMessageHandler>(handler);
            GlobalSettings.Current.Set <Dictionary <int, CardEventReport> >(new Dictionary <int, CardEventReport>());
            handler.Debug       = this.chkDebug.Checked;
            handler.OnReadCard += new EventHandler <OpenCardEventArgs>(handler_OnReadCard);
            handler.OnPaying   += new EventHandler <OpenCardEventArgs>(handler_OnPaying);
            handler.OnPaidOk   += new EventHandler <OpenCardEventArgs>(handler_OnPaidOk);
            handler.OnPaidFail += new EventHandler <OpenCardEventArgs>(handler_OnPaidFail);
            handler.OnError    += new EventHandler <OpenCardEventArgs>(handler_OnError);

            SysParaSettingsBll ssb  = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);
            string             temp = AppSettings.CurrentSetting.GetConfigContent("EnableZST");
            bool enabled            = false;

            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ZSTSettings zst = ssb.GetSetting <ZSTSettings>();
                if (zst != null)
                {
                    handler.InitService(zst);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYiTingShanFu");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YiTingShanFuSetting yt = ssb.GetSetting <YiTingShanFuSetting>();
                if (yt != null)
                {
                    AppSettings.CurrentSetting.GetYiTingConfig(yt);
                    handler.InitService(yt);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYCT");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YCTSetting yct = ssb.GetSetting <YCTSetting>();
                if (yct != null)
                {
                    handler.InitService(yct);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableETC");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ETCSetting etc = ETCSetting.GetSetting();
                if (etc != null)
                {
                    handler.InitService(etc);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableLR280");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                Ralid.OpenCard.OpenCardService.LR280.LR280Setting lr280 = ssb.GetSetting <OpenCardService.LR280.LR280Setting>();
                if (lr280 != null)
                {
                    handler.InitService(lr280);
                }
            }
            this.Invoke((Action)(() => { ShowServiceState(); }));
        }
Exemple #7
0
        private void SyncUploadFiles(FtpClient ftp, YCTSetting yct)
        {
            //DateTime dt = DateTime.Now;
            DateTime dt     = DateTime.Today.AddMilliseconds(-1);
            string   m1Zip  = string.Format("XF{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMdd"));
            string   cpuZip = string.Format("CX{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMddHH"));

            InsertMsg("定位到: " + _WriteFolder);
            ftp.SetWorkingDirectory(_WriteFolder);
            var items = ftp.GetListing(_WriteFolder, FtpListOption.NoPath);

            if (items == null && items.Length == 0 || items.Count(it => it.Name == m1Zip) == 0)
            {
                YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为M1钱包且未上传的记录
                {
                    WalletType           = 1,
                    State                = (int)YCTPaymentRecordState.PaidOk,
                    UnUploaded           = true,
                    PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt)
                };
                List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects;
                if (records != null && records.Count > 0)
                {
                    YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition();
                    ycon.WalletType     = 1; //M
                    ycon.OnlyCatched    = true;
                    ycon.OnlyUnUploaded = true;
                    List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects;
                    string zip = YCTUploadFileFactory.CreateM1UploadFile(dt, m1Zip, records, blacks);
                    if (!string.IsNullOrEmpty(zip))
                    {
                        InsertMsg("上传文件" + m1Zip);
                        using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read))
                        {
                            ftp.Upload(m1Zip, fs);
                            new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, m1Zip);
                            if (blacks != null && blacks.Count > 0)
                            {
                                new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, m1Zip);
                            }
                        }
                    }
                }
            }

            if (items == null && items.Length == 0 || items.Count(it => it.Name == cpuZip) == 0)
            {
                YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为CPU钱包且未上传的记录
                {
                    WalletType           = 2,
                    State                = (int)YCTPaymentRecordState.PaidOk,
                    UnUploaded           = true,
                    PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt)
                };
                List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects;
                if (records != null && records.Count > 0)
                {
                    YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition();
                    ycon.WalletType     = 2; //cpu
                    ycon.OnlyCatched    = true;
                    ycon.OnlyUnUploaded = true;
                    List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects;
                    string zip = YCTUploadFileFactory.CreateCPUUploadFile(dt, cpuZip, records, blacks);
                    if (!string.IsNullOrEmpty(zip))
                    {
                        InsertMsg("上传文件" + cpuZip);
                        using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read))
                        {
                            ftp.Upload(cpuZip, fs);
                            new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, cpuZip);
                            if (blacks != null && blacks.Count > 0)
                            {
                                new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, cpuZip);
                            }
                        }
                    }
                }
            }
        }