///// <summary>
        ///// 同步故障信息到集中管控
        ///// </summary>
        ///// <param name="output"></param>
        ///// <returns></returns>
        //public void SyncQCJXCYJError(Action<string, eOutputType> output)
        //{
        //	int res = 0;

        //	foreach (EquHCQSCYJError entity in this.EquDber.Entities<EquHCQSCYJError>("where DataFlag=0"))
        //	{
        //		if (commonDAO.SaveEquInfHitch(this.MachineCode, entity.ErrorTime, "故障代码 " + entity.ErrorCode + "," + entity.ErrorDescribe))
        //		{
        //			entity.DataFlag = 1;
        //			this.EquDber.Update(entity);

        //			res++;
        //		}
        //	}

        //	output(string.Format("同步故障信息记录 {0} 条", res), eOutputType.Normal);
        //}

        /// <summary>
        /// 同步采样计划
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSamplePlan(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSamplePlan entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlan(this.MachineCode))
            {
                bool isSuccess = false;
                // 需调整:命令中的水分等信息视接口而定
                KY_CYJ_P_OUTRUN samplecmdEqu = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_OUTRUN>("where CY_Code=@CY_Code and CYJ_Machine=@CYJ_Machine", new { CYJ_Machine = MachineCodeToKY(this.MachineCode), CY_Code = entity.SampleCode });
                if (samplecmdEqu == null)
                {
                    //	isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(new KY_CYJ_P_OUTRUN
                    //	{
                    //		CYJ_Machine = MachineCodeToKY(this.MachineCode),
                    //		CY_Code = entity.SampleCode,
                    //		Send_Time = DateTime.Now,
                    //		CY_Flag = 0,
                    //		Stop_Flag = 0,
                    //		TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2",
                    //		Car_Count= commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode)

                    //}) > 0;


                    KY_CYJ_P_OUTRUN outrun = new KY_CYJ_P_OUTRUN();
                    outrun.CYJ_Machine = MachineCodeToKY(this.MachineCode);
                    outrun.CY_Code     = entity.SampleCode;
                    outrun.Send_Time   = DateTime.Now;
                    outrun.CY_Flag     = 0;
                    outrun.Stop_Flag   = 0;
                    outrun.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                    outrun.Car_Count   = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
                    isSuccess          = DcDbers.GetInstance().BeltSampler_Dber.Insert(outrun) > 0;
                    commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", outrun.Car_Count.ToString());

                    KY_CYJ_P_TurnOver turn = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_TurnOver>("where CY_Code=@CY_Code", new { CY_Code = entity.SampleCode });
                    if (turn == null)
                    {
                        turn             = new KY_CYJ_P_TurnOver();
                        turn.Send_Time   = DateTime.Now;
                        turn.CY_Code     = entity.SampleCode;
                        turn.DataFlag    = 0;
                        turn.Car_Count   = commonDAO.GetCarCountBySampleCode(entity.SampleCode);
                        turn.Ready_Count = commonDAO.GetRealyCarCountBySampleCode(entity.SampleCode);
                        turn.IsDone      = 0;
                        turn.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                        DcDbers.GetInstance().BeltSampler_Dber.Insert(turn);
                        commonDAO.SetSignalDataValue(this.MachineCode, turn.TurnCode == "#1" ? "#1翻车机车数" : "#2翻车机车数", turn.Car_Count.ToString());
                    }
                }
                else
                {
                    samplecmdEqu.CYJ_Machine = MachineCodeToKY(this.MachineCode);
                    samplecmdEqu.CY_Code     = entity.SampleCode;
                    samplecmdEqu.Send_Time   = DateTime.Now;
                    samplecmdEqu.CY_Flag     = 0;
                    samplecmdEqu.Stop_Flag   = 0;
                    samplecmdEqu.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                    samplecmdEqu.Car_Count   = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
                    isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Update(samplecmdEqu) > 0;
                    commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", samplecmdEqu.Car_Count.ToString());
                }

                if (isSuccess)
                {
                    entity.SyncFlag = 1;
                    Dbers.GetInstance().SelfDber.Update(entity);

                    res++;
                }
            }
            output(string.Format("同步采样计划 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);

            //// 集中管控 > 第三方
            //foreach (InfBeltSamplePlan entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlan(this.MachineCode))
            //{
            //	bool isSuccess = false;
            //	// 需调整:命令中的水分等信息视接口而定
            //	KY_CYJ_P_OUTRUN samplecmdEqu = DcDbers.GetInstance().BeltSampler_Dber.Entity<KY_CYJ_P_OUTRUN>("where CY_Code=@CY_Code and CYJ_Machine=@CYJ_Machine", new { CYJ_Machine = MachineCodeToKY(this.MachineCode), CY_Code = entity.SampleCode });
            //	if (samplecmdEqu == null)
            //	{
            //	//	isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(new KY_CYJ_P_OUTRUN
            //	//	{
            //	//		CYJ_Machine = MachineCodeToKY(this.MachineCode),
            //	//		CY_Code = entity.SampleCode,
            //	//		Send_Time = DateTime.Now,
            //	//		CY_Flag = 0,
            //	//		Stop_Flag = 0,
            //	//		TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2",
            //	//		Car_Count= commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode)

            //	//}) > 0;


            //		KY_CYJ_P_OUTRUN outrun = new KY_CYJ_P_OUTRUN();
            //		outrun.CYJ_Machine = MachineCodeToKY(this.MachineCode);
            //		outrun.CY_Code = entity.SampleCode;
            //		outrun.Send_Time = DateTime.Now;
            //		outrun.CY_Flag = 0;
            //		outrun.Stop_Flag = 0;
            //		outrun.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //		outrun.Car_Count = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
            //		isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(outrun)>0;
            //		commonDAO.SetSignalDataValue(this.MachineCode,"轨道车数", outrun.Car_Count.ToString());

            //		KY_CYJ_P_TurnOver turn = DcDbers.GetInstance().BeltSampler_Dber.Entity<KY_CYJ_P_TurnOver>("where CY_Code=@CY_Code", new { CY_Code = entity.SampleCode });
            //		if (turn == null)
            //		{
            //			turn = new KY_CYJ_P_TurnOver();
            //			turn.Send_Time = DateTime.Now;
            //			turn.CY_Code = entity.SampleCode;
            //			turn.DataFlag = 0;
            //			turn.Car_Count = commonDAO.GetCarCountBySampleCode(entity.SampleCode);
            //			turn.Ready_Count = commonDAO.GetRealyCarCountBySampleCode(entity.SampleCode);
            //			turn.IsDone = 0;
            //			turn.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //			DcDbers.GetInstance().BeltSampler_Dber.Insert(turn);
            //			commonDAO.SetSignalDataValue(this.MachineCode, turn.TurnCode == "#1" ? "#1翻车机车数" : "#2翻车机车数", turn.Car_Count.ToString());
            //		}
            //	}
            //	else
            //	{
            //		samplecmdEqu.CYJ_Machine = MachineCodeToKY(this.MachineCode);
            //		samplecmdEqu.CY_Code = entity.SampleCode;
            //		samplecmdEqu.Send_Time = DateTime.Now;
            //		samplecmdEqu.CY_Flag = 0;
            //		samplecmdEqu.Stop_Flag = 0;
            //		samplecmdEqu.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //		samplecmdEqu.Car_Count = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
            //		isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Update(samplecmdEqu) > 0;
            //		commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", samplecmdEqu.Car_Count.ToString());
            //	}

            //	if (isSuccess)
            //	{
            //		entity.SyncFlag = 1;
            //		Dbers.GetInstance().SelfDber.Update(entity);

            //		res++;
            //	}
            //}
            //output(string.Format("同步采样计划 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);
        }