private void ControlButton(bool enable)
 {
     btnSave.IsEnabled   = enable;
     btnCancel.IsEnabled = enable;
     ////rdbAdvertSwitch_Run.IsEnabled = rdbAdvertSwitch_Stop.IsEnabled = enable;
     sidSound.IsEnabled = enable;
     ControlSwitch(enable);
     DispatcherHelper.SleepControl();
 }
Example #2
0
        private void ControlSet(bool enable)
        {
            bool blnAdd    = btnAdd.IsEnabled;
            bool blnDelete = btnDelete.IsEnabled;

            ////if (enable)
            ////{
            ////    bdFillUpNumArea.Background = new SolidColorBrush(Colors.White);
            ////}
            ////else
            ////{
            ////    bdFillUpNumArea.Background = new SolidColorBrush(Color.FromRgb(209, 204, 204));
            ////    btnAdd.IsEnabled = btnDelete.IsEnabled = false;
            ////    btnDelete.Source = new BitmapImage(new Uri(SkinHelper.FILEPATH_REDUCE_GRAY));
            ////    btnAdd.Source = new BitmapImage(new Uri(SkinHelper.FILEPATH_ADD_GRAY));
            ////}

            btnTrayFull.IsEnabled   = btnTraySetOther.IsEnabled = btnSave.IsEnabled = btnCancel.IsEnabled = enable;
            tbBatch_Value.IsEnabled = tbMaxValidDate_Value.IsEnabled = tbProductDate_Value.IsEnabled = enable;
            DispatcherHelper.SleepControl();
        }
        private void btnYes_Click(object sender, RoutedEventArgs e)
        {
            tbInfo.Visibility     = System.Windows.Visibility.Hidden;
            tbProgress.Visibility = System.Windows.Visibility.Visible;
            btnNo.IsEnabled       = btnYes.IsEnabled = false;
            btnNo.Visibility      = btnYes.Visibility = System.Windows.Visibility.Hidden;
            DispatcherHelper.SleepControl(50);

            bool result = false;

            switch (PubHelper.p_ResetType)
            {
            case "0":    // 恢复出厂数据
                result = PubHelper.p_BusinOper.InitFactoryData();
                break;

            default:    // 恢复出厂参数
                result = PubHelper.p_BusinOper.InitFactoryCfg();
                if (result)
                {
                    if (!PubHelper.p_IsRefreshAsile)
                    {
                        PubHelper.p_IsRefreshAsile = true;
                    }
                }
                break;
            }
            if (result)
            {
                PubHelper.ShowMsgInfo(PubHelper.p_LangOper.GetStringBundle("Pub_OperSuc_Restart"), PubHelper.MsgType.Ok);
            }
            else
            {
                PubHelper.ShowMsgInfo(PubHelper.p_LangOper.GetStringBundle("Pub_OperFail"), PubHelper.MsgType.Ok);
            }
            this.Close();
        }
        /// <summary>
        /// 业务主线程
        /// </summary>
        private void MainWorkTrd()
        {
            bool result = false;
            bool blnCheckIDCardDevice = false;
            int  intErrCode           = 0;

            #region 检测条形码扫描设备

            // 初始条形码扫描数据
            PubHelper.p_BusinOper.BarCodeOper.ClearBarCodeNum();

            // 检测条形码设备状态
            intErrCode = PubHelper.p_BusinOper.BarCodeOper.CheckDeviceStatus();
            if (intErrCode == 0)
            {
                // 设备正常,开启条形码扫描
                intErrCode = PubHelper.p_BusinOper.BarCodeOper.BeginScan();
                if (intErrCode == 0)
                {
                    blnCheckIDCardDevice = true;
                    m_ErrInfo            = PubHelper.p_LangOper.GetStringBundle("TakeSell_BarCode_Pay_Progress").Replace("{N}", m_CodeNum_Name);;
                }
            }
            if (intErrCode != 0)
            {
                // 条形码扫描设备故障,退出线程
                m_ErrInfo = PubHelper.p_LangOper.GetStringBundle("TakeSell_BarCode_Err_Device");
            }

            this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
            {
                tbProgressInfo.Text  = m_ErrInfo;
                btnCancel.Visibility = System.Windows.Visibility.Visible;
            }));

            #endregion

            // 开始超时监控
            BeginMonOutTime();

            if (!blnCheckIDCardDevice)
            {
                // 设备故障,退出线程
                return;
            }

            bool blnIsFindBarCode = false;

            while (!m_CloseForm)
            {
                Thread.Sleep(200);

                #region 读取条形码

                blnIsFindBarCode = false;

                result = PostBarCode(out blnIsFindBarCode);

                #endregion

                if (result)
                {
                    #region 检测需要出货的商品是否能够出货

                    /*
                     * 1、检测所出货商品库存是否够
                     * 2、检测出货商品所在货道是否正常
                     */
                    result = CheckSaleEnvr();

                    #endregion

                    if (result)
                    {
                        #region 出货

                        result = SellGoods();

                        #endregion
                    }
                }

                if (blnIsFindBarCode)
                {
                    this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
                    {
                        tbProgressInfo.Text = m_ErrInfo;
                        DispatcherHelper.SleepControl();
                    }));
                    Thread.Sleep(2000);
                    this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
                    {
                        if (!result)
                        {
                            btnCancel.Visibility = System.Windows.Visibility.Visible;
                            tbProgressInfo.Text  = PubHelper.p_LangOper.GetStringBundle("TakeSell_BarCode_Pay_Progress").Replace("{N}", m_CodeNum_Name);;
                            DispatcherHelper.SleepControl();
                            BeginMonOutTime();// 重新开始超时监控
                        }
                        else
                        {
                            this.Close();
                        }
                    }));
                }
            }

            intErrCode = PubHelper.p_BusinOper.BarCodeOper.StopScan();
        }
Example #5
0
        /// <summary>
        /// 广告导入工作线程
        /// </summary>
        private void ImportTrd()
        {
            /* 广告导入处理流程
             * 1、搜索移动盘根目录下的广告配置文件,并读取广告配置文件
             * 2、根据广告配置文件,检查相关广告文件是否存在及格式是否正确;
             * 3、拷贝复制配置文件以及广告播放文件到指定目录
             * 3、如果成功,则清空原有广告播放文件
             * 4、拷贝新的文件到广告正式播放目录下
             *
             */

            int intErrCode = 0;

            try
            {
                this.tbTitle.Dispatcher.Invoke(new Action(() =>
                {
                    tbInfo.Text = PubHelper.p_LangOper.GetStringBundle("Pub_Import_Checking");// 正在读取导入文件
                    DispatcherHelper.SleepControl();
                    DispatcherHelper.DoEvents();
                }));

                #region 遍历各盘符,查询是否有广告信息导入文件

                string   strDiskPath      = "d;e;f;g;h;i;j;k";
                string[] hexDiskPath      = strDiskPath.Split(';');
                int      hexDiskLen       = hexDiskPath.Length;
                string   strUDiskFilePath = string.Empty;
                string   strFilaPath      = string.Empty;

                string strImportFileName = "advertlist.txt";

                bool blnFileExist = false;
                for (int i = 0; i < hexDiskLen; i++)
                {
                    strUDiskFilePath = hexDiskPath[i] + ":\\";
                    strFilaPath      = strUDiskFilePath + strImportFileName;
                    // 检测广告导入文件是否存在
                    if (File.Exists(strFilaPath))
                    {
                        // 导入文件存在
                        blnFileExist = true;
                        break;
                    }
                }

                #endregion

                // 0:成功 1:没有找到商品信息导入文件 2:读取商品信息导入文件失败 3:导入失败
                if (blnFileExist)
                {
                    #region 读取导入信息文件内容

                    string strListInfo = File.ReadAllText(strFilaPath, Encoding.Default);

                    // 0:成功 1:获取导入信息失败 2:没有要导入的信息 3:导入失败
                    string updateMcdList = string.Empty;
                    string _advListId    = string.Empty;
                    intErrCode = PubHelper.p_BusinOper.VmFileOper.ImportAdvertList(strListInfo, "0",
                                                                                   strUDiskFilePath, out _advListId, out updateMcdList);
                    if (intErrCode != 0)
                    {
                        intErrCode = intErrCode + 2;
                    }
                    else
                    {
                        #region 读取信息成功,检查相关广告文件

                        int intCount = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import.Count;
                        if (intCount == 0)
                        {
                            intErrCode = 4;// 没有广告信息
                        }
                        else
                        {
                            // 广告文件存储临时文件夹
                            string strAdvertDicPath_Temp = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Advert_Temp\\";
                            // 广告文件存储正式文件夹
                            string strAdvertDicPath_Formal = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Advert\\";

                            #region 如果广告临时文件夹不存在,则创建

                            bool result = PubHelper.CreatDire(strAdvertDicPath_Temp);

                            #endregion

                            #region 计算空间大小

                            this.tbTitle.Dispatcher.Invoke(new Action(() =>
                            {
                                tbInfo.Text = PubHelper.p_LangOper.GetStringBundle("Pub_Import_Disking");// 正在计算空间大小
                                DispatcherHelper.SleepControl();
                                DispatcherHelper.DoEvents();
                            }));

                            string   strAdvertFileName     = string.Empty;
                            string   strAdvertFileType     = string.Empty;
                            string   strAdvertFileNameType = string.Empty;
                            string   strImportFilePath     = string.Empty;
                            FileInfo fileInfo;
                            long     fileCountSize = 0;

                            for (int i = 0; i < intCount; i++)
                            {
                                strAdvertFileName     = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import[i].FileName;
                                strAdvertFileType     = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import[i].FileType;
                                strAdvertFileNameType = strAdvertFileName + "." + strAdvertFileType;
                                strImportFilePath     = strUDiskFilePath + strAdvertFileNameType;
                                // 检测该广告文件是否存在
                                if (File.Exists(strImportFilePath))
                                {
                                    // 广告文件存在
                                    fileInfo       = new FileInfo(strImportFilePath);// 获取该广告文件大小
                                    fileCountSize += fileInfo.Length;
                                }
                            }

                            #endregion

                            if (fileCountSize * 10 > PubHelper.p_BusinOper.CheckDataOper.GetCurrentDiskSpaceSize())
                            {
                                // 硬盘空间不足
                                intErrCode = 5;
                            }
                            else
                            {
                                PubHelper.p_BusinOper.SysCfgOper.UpdateSysCfg("UpdateAdvertListID", PubHelper.p_BusinOper.VmFileOper.UpdateAdvertListID);

                                #region 拷贝广告文件到临时文件夹

                                string strOperInfo = PubHelper.p_LangOper.GetStringBundle("Pub_Import_Opering");// 正在处理导入文件
                                for (int i = 0; i < intCount; i++)
                                {
                                    strAdvertFileName     = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import[i].FileName;
                                    strAdvertFileType     = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import[i].FileType;
                                    strAdvertFileNameType = strAdvertFileName + "." + strAdvertFileType;
                                    strImportFilePath     = strUDiskFilePath + strAdvertFileNameType;
                                    // 检测该广告文件是否存在
                                    if (File.Exists(strImportFilePath))
                                    {
                                        this.tbTitle.Dispatcher.Invoke(new Action(() =>
                                        {
                                            tbInfo.Text = strOperInfo.Replace("{N}", strAdvertFileNameType);// 正在处理导入文件

                                            DispatcherHelper.SleepControl();
                                            DispatcherHelper.DoEvents();
                                        }));

                                        // 广告文件存在 拷贝广告文件到临时文件夹
                                        File.Copy(strImportFilePath,
                                                  strAdvertDicPath_Temp + strAdvertFileNameType, true);
                                    }
                                }

                                File.Copy(strFilaPath, strAdvertDicPath_Temp + strImportFileName, true);

                                #endregion

                                #region 清除历史广告文件

                                this.tbTitle.Dispatcher.Invoke(new Action(() =>
                                {
                                    tbInfo.Text = PubHelper.p_LangOper.GetStringBundle("Pub_Import_Clearing");// 正在清除历史文件
                                    DispatcherHelper.SleepControl();
                                    DispatcherHelper.DoEvents();
                                }));

                                DirectoryInfo di = new DirectoryInfo(strAdvertDicPath_Formal);
                                // 判断目录是否存在
                                FileInfo[] fi = di.GetFiles();//获得目录下文件
                                foreach (FileInfo f in fi)
                                {
                                    //判断指定文件是否存在
                                    File.Delete(f.FullName);
                                }

                                #endregion

                                #region 从临时文件夹把新的广告文件移动到正式广告文件夹里

                                DirectoryInfo di_Temp = new DirectoryInfo(strAdvertDicPath_Temp);
                                // 判断目录是否存在
                                FileInfo[] fi_Temp = di_Temp.GetFiles();//获得目录下文件
                                foreach (FileInfo f in fi_Temp)
                                {
                                    //判断指定文件是否存在
                                    f.MoveTo(strAdvertDicPath_Formal + f.Name);
                                }

                                #endregion

                                PubHelper.p_BusinOper.VmFileOper.AdvertList = PubHelper.p_BusinOper.VmFileOper.AdvertList_Import;
                            }
                        }
                        #endregion
                    }

                    #endregion
                }
                else
                {
                    intErrCode = 1;// 没有找到信息导入文件
                }
            }
            catch
            {
                intErrCode = 2;// 认为读取导入文件失败
            }

            string strMsgInfo = string.Empty;
            switch (intErrCode)
            {
            case 0:    // 导入成功
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Pub_OperSuc");
                break;

            case 1:    // 没有找到信息导入文件
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_NoFile");
                break;

            case 2:    // 读取信息导入文件失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_ReadFileFail");
                break;

            case 3:    // 获取导入信息失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_GetInfoFail");
                break;

            case 4:    // 没有要导入的信息
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_NoInfo");
                break;

            case 5:    // 硬盘空间不足
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_NoSpace").Replace("{N}", PubHelper.p_BusinOper.CheckDataOper.GetAppDisk());
                break;

            default:    // 导入失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Pub_OperFail");
                break;
            }

            this.tbTitle.Dispatcher.Invoke(new Action(() =>
            {
                PubHelper.ShowMsgInfo(strMsgInfo, PubHelper.MsgType.Ok);
                this.Close();
            }));
        }
Example #6
0
 private void ControlButton(bool enable)
 {
     btnSave.IsEnabled   = enable;
     btnCancel.IsEnabled = enable;
     DispatcherHelper.SleepControl();
 }
Example #7
0
        /// <summary>
        /// 身份证业务主线程
        /// </summary>
        private void MainWorkTrd()
        {
            bool result = false;
            bool blnCheckIDCardDevice = false;

            #region 检测身份证设备

            // 打开身份证扫描环境
            int intErrCode = PubHelper.p_BusinOper.IDCardOper.OpenIDCard();
            if (intErrCode != 0)
            {
                // 身份证设备检测故障,退出线程
                m_ErrInfo = PubHelper.p_LangOper.GetStringBundle("Err_PauseServer_Reason_IDCard");
            }
            else
            {
                blnCheckIDCardDevice = true;
                m_ErrInfo            = PubHelper.p_LangOper.GetStringBundle("FreeSell_IDCard_Pay_Progress");
            }

            this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
            {
                tbProgressInfo.Text  = m_ErrInfo;
                btnCancel.Visibility = System.Windows.Visibility.Visible;
            }));

            #endregion

            // 开始超时监控
            BeginMonOutTime();

            if (!blnCheckIDCardDevice)
            {
                // 设备故障,退出线程
                return;
            }

            bool blnIsFindIDCard = false;

            while (!m_CloseForm)
            {
                Thread.Sleep(200);

                #region 读取及验证身份证

                blnIsFindIDCard = false;

                result = PostIDCard(out blnIsFindIDCard);

                #endregion

                if (result)
                {
                    #region 检测需要出货的商品是否能够出货

                    /*
                     * 1、检测所出货商品库存是否够
                     * 2、检测出货商品所在货道是否正常
                     */
                    result = CheckSaleEnvr();

                    #endregion

                    if (result)
                    {
                        #region 出货

                        result = SellGoods();

                        #endregion
                    }
                }

                if (blnIsFindIDCard)
                {
                    this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
                    {
                        tbProgressInfo.Text = m_ErrInfo;
                        DispatcherHelper.SleepControl();
                    }));
                    Thread.Sleep(2000);
                    this.tbProgressInfo.Dispatcher.Invoke(new Action(() =>
                    {
                        if (!result)
                        {
                            btnCancel.Visibility = System.Windows.Visibility.Visible;
                            tbProgressInfo.Text  = PubHelper.p_LangOper.GetStringBundle("FreeSell_IDCard_Pay_Progress");
                            DispatcherHelper.SleepControl();
                            BeginMonOutTime();// 重新开始超时监控
                        }
                        else
                        {
                            this.Close();
                        }
                    }));
                }
            }
        }