public QueryDataViewModel() { if (this.IsInDesignMode) { return; } SelectMeasureCommand = new ActionCommand(SelectMethod); QueryCommand = new ActionCommand(QueryWeightRecords); SupplementCommand = new ActionCommand(SupplementMethod); ShowPictureCommand = new ActionCommand(ShowPictureMethod); ShowVideoCommand = new ActionCommand(ShowVideoMethod); #region 获取配置文件路径 string basePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ClientConfig"); var configPath = System.IO.Path.Combine(basePath, "SystemConfig.xml"); #endregion #region 获取等待任务结果过时时间 int waitPrintResultTime = 1; string waitPrintResultTimeItem = ConfigurationManager.AppSettings["WaitPrintResultTime"].ToString(); string getWaitPrintResultTimeItem = XpathHelper.GetValue(configPath, waitPrintResultTimeItem); if (!string.IsNullOrEmpty(getWaitPrintResultTimeItem)) { waitPrintResultTime = Convert.ToInt32(getWaitPrintResultTimeItem); } #endregion #region 注册等待打印结果计时器 waitPrintReusltTimer = new Calculagraph(""); waitPrintReusltTimer.Timeout = waitPrintResultTime; waitPrintReusltTimer.TimeOver += new TimeoutCaller(waitPrintReusltTimer_TimeOver); #endregion }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { //获取称点编码 _curClientCode = XpathHelper.GetValue(_sysConfigFile, _curClientCode); this.notifyIcon = new NotifyIcon(); //this.notifyIcon.BalloonTipText = "文件同步程序"; //设置程序启动时显示的文本 //this.notifyIcon.Text = "文件同步程序";//最小化到托盘时,鼠标点击时显示的文本 this.notifyIcon.BalloonTipText = ""; //设置程序启动时显示的文本 this.notifyIcon.Text = ""; //最小化到托盘时,鼠标点击时显示的文本 this.notifyIcon.Icon = Properties.Resources.FileSync; this.notifyIcon.Visible = true; //退出菜单项 System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出"); exit.Click += new EventHandler(Quit); //关联托盘控件 System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { exit }; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen); // notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick; //this.notifyIcon.ShowBalloonTip(1000); log.Info("注册托盘图标完成"); //读取照片配置 ConfigReader rf = new ConfigReader(_sysConfigFile); _curPhotoConfig = ConfigReader.ReadPhotoConfig(); log.Info("读取配置文件完成"); _curFtpServices = new FtpManager(); _curFtpServices.FtpUpDown(_curPhotoConfig.FtpIp, _curPhotoConfig.FtpUserName, _curPhotoConfig.FtpPassWord); log.Info("初始化文件服务器完成"); //定时器相关 curUploadTimer = new DispatcherTimer(); curUploadTimer.Interval = new TimeSpan(0, 1, 0); //一分钟检测一次 curUploadTimer.Tick += curUploadJpgTimer_Tick; curUploadTimer.Start(); ShowUpLoadInfo("开始文件同步"); WindowState = System.Windows.WindowState.Minimized; wsl = WindowState; // this.Visibility = System.Windows.Visibility.Hidden; this.Hide(); }
/// <summary> /// 下载图片 /// </summary> /// <param name="list"></param> public void DownloadImags(List <PictureModel> list) { if (list != null && list.Count > 0) { try { FtpManager fm = new FtpManager(); string basePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "CarMeasureClient"); string clientConfigPath = System.IO.Path.Combine(basePath, list.First().equcode + ".xml");//正式用 #region 读取FTP配置 #region ftpIp string ftpIpItem = ConfigurationManager.AppSettings["FtpIp"].ToString(); string ftpIp = XpathHelper.GetValue(clientConfigPath, ftpIpItem); #endregion #region ftp用户名 string ftpUserNameItem = ConfigurationManager.AppSettings["FtpPicUserName"].ToString(); string ftpUserName = XpathHelper.GetValue(clientConfigPath, ftpUserNameItem); #endregion #region ftp密码 string ftpPasswordItem = ConfigurationManager.AppSettings["FtpPicPassWord"].ToString(); string ftpPassword = XpathHelper.GetValue(clientConfigPath, ftpPasswordItem); #endregion #endregion //fm.FtpUpDown(ftpIp, ftpUserName, ftpPassword); foreach (var item in list) { //byte[] imageData = fm.Download(item.photo); //item.image = GetImageByBytes(imageData); //item.image = GetImageByUrl(ftpIp, ftpUserName, ftpPassword, item.photo); item.FtpPhoto = "ftp://" + ftpUserName + ":" + ftpPassword + "@" + ftpIp + "/" + item.photo; } } catch //(Exception ex) { //this.ShowBusy = false; //this.ShowMessage("信息提示", "下载图片失败!原因:" + ex.Message, true, false); } } }
/// <summary> /// 初始化坐席信息 /// </summary> private void InitSeatInfo() { string configSet = ConfigurationManager.AppSettings["SysConfigFileName"].ToString(); string basePath = System.AppDomain.CurrentDomain.BaseDirectory; string configUrl = basePath + configSet; #region 读取坐席ID string seatIdMark = ConfigurationManager.AppSettings["SeatId"].ToString(); var seatId = XpathHelper.GetValue(configUrl, seatIdMark); #endregion #region 读取坐席名称 string seatNameMark = ConfigurationManager.AppSettings["SeatName"].ToString(); var seatName = XpathHelper.GetValue(configUrl, seatNameMark); #endregion LoginUser.Role = new Role() { Code = seatId, Name = seatName }; }
/// <summary> /// 读取app配置 /// </summary> /// <param name="pConfigName"></param> /// <returns></returns> internal static string ReadCfg(string pConfigName) { string temp = ConfigurationManager.AppSettings[pConfigName].ToString(); return(XpathHelper.GetValue(_configUrl, temp)); }