示例#1
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            double ratedPower = Convert.ToDouble(txtBoxRatedPower.Text.Length > 0 ? txtBoxRatedPower.Text : null);
            int    ratedRPM   = Convert.ToInt32(txtBoxRatedRPM.Text.Length > 0 ? txtBoxRatedRPM.Text : null);
            int    refMass    = Convert.ToInt32(txtBoxRefMass.Text.Length > 0 ? txtBoxRefMass.Text : null);
            int    maxMass    = Convert.ToInt32(txtBoxMaxMass.Text.Length > 0 ? txtBoxMaxMass.Text : null);
            bool   bCanTest   = true;

            bCanTest = bCanTest && (txtBoxGettedVIN.TextLength > 0);
            bCanTest = bCanTest && (txtBoxVehicleModel.TextLength > 0);
            bCanTest = bCanTest && (ratedPower > 0);
            bCanTest = bCanTest && (ratedRPM > 0);
            bCanTest = bCanTest && (cmbBoxEmissionStage.SelectedIndex > 0);
            bCanTest = bCanTest && (refMass > 0);
            bCanTest = bCanTest && (maxMass > 0);
            bCanTest = bCanTest && (cmbBoxTestMethod.SelectedIndex != 5);
            if (bCanTest)
            {
                // 目前欧润特软件只能使用“在用车”登录接口
                //NewVehicle newVehicle = new NewVehicle();
                //SetNewVehicle(newVehicle);
                //SaveNewVehicleInfoParams cmdParams = new SaveNewVehicleInfoParams() {
                //    ClientID = _dynoCmd.ClientID,
                //    Newvehicle = newVehicle
                //};
                //if (_dynoCmd.SaveNewVehicleInfoCmd(cmdParams, out string errMsg)) {
                //    DialogResult = DialogResult.OK;
                //    Close();
                //} else {
                //    MessageBox.Show("保存车辆登录表单至服务器时出错", "车辆登录", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}

                DateTime   fromDate   = DateTime.Now;
                UseVehicle useVehicle = new UseVehicle();
                SetUseVehicle(useVehicle);
                SaveInUseVehicleInfoParams cmdParams = new SaveInUseVehicleInfoParams()
                {
                    ClientID   = _dynoCmd.ClientID,
                    Usevehicle = useVehicle
                };
                if (_dynoCmd.SaveInUseVehicleInfoCmd(cmdParams, out string errMsg))
                {
                    // 调用“GetWaitCheckQueueInfo”接口获取 WJBGBH
                    string WJBGBH = string.Empty;
                    GetWaitCheckQueueInfoParams cmdParams2 = new GetWaitCheckQueueInfoParams {
                        ClientID = _dynoCmd.ClientID,
                        FromDate = fromDate.ToLocalTime().ToString("yyyy-M-d HH:mm:ss"),
                        ToDate   = DateTime.Now.ToLocalTime().ToString("yyyy-M-d HH:mm:ss"),
                    };
                    GetWaitCheckQueueInfoAckParams ackParams2 = new GetWaitCheckQueueInfoAckParams();
                    if (_dynoCmd.GetWaitCheckQueueInfoCmd(cmdParams2, ref ackParams2, out errMsg) && ackParams2 != null)
                    {
                        for (int i = 0; i < ackParams2.waitCheckQueueInfo.Rows.Count; i++)
                        {
                            if (ackParams2.waitCheckQueueInfo.Rows[i]["VIN"].ToString() == VI.VIN)
                            {
                                WJBGBH = ackParams2.waitCheckQueueInfo.Rows[i]["WJBGBH"].ToString();
                            }
                        }
                        // 使用上一步得到的 WJBGBH 调用“GetOneWaitVehicleInfo”接口填充服务器端 vehicleInfo 变量
                        GetOneWaitVehicleInfoParams cmdParams3 = new GetOneWaitVehicleInfoParams {
                            ClientID   = _dynoCmd.ClientID,
                            IsInUseCar = true,
                            WJBGBH     = WJBGBH,
                            DLY        = EI.Name,
                            DLSJ       = DateTime.Now.ToLocalTime().ToString("yyyy-M-d HH:mm:ss"),
                            HPHM       = string.Empty,
                            HPYS       = string.Empty,
                            VIN        = VI.VIN
                        };
                        GetOneWaitVehicleInfoAckParams ackParams3 = new GetOneWaitVehicleInfoAckParams();
                        if (_dynoCmd.GetOneWaitVehicleInfoCmd(cmdParams3, ref ackParams3, out errMsg) && ackParams3 != null)
                        {
                            DialogResult = DialogResult.OK;
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("获取待检车辆信息时出错", "车辆登录", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("获取待检队列时出错", "车辆登录", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("保存车辆登录表单至服务器时出错", "车辆登录", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (txtBoxGettedVIN.TextLength <= 0)
                {
                    txtBoxGettedVIN.BackColor = Color.Yellow;
                }
                if (txtBoxVehicleModel.TextLength <= 0)
                {
                    txtBoxVehicleModel.BackColor = Color.Yellow;
                }
                if (ratedPower <= 0)
                {
                    txtBoxRatedPower.BackColor = Color.Yellow;
                }
                if (ratedRPM <= 0)
                {
                    txtBoxRatedRPM.BackColor = Color.Yellow;
                }
                if (cmbBoxEmissionStage.SelectedIndex <= 0)
                {
                    cmbBoxEmissionStage.BackColor = Color.Yellow;
                }
                if (refMass <= 0)
                {
                    txtBoxRefMass.BackColor = Color.Yellow;
                }
                if (maxMass <= 0)
                {
                    txtBoxMaxMass.BackColor = Color.Yellow;
                }
                if (cmbBoxTestMethod.SelectedIndex == 5)
                {
                    cmbBoxTestMethod.BackColor = Color.Yellow;
                }
                MessageBox.Show("车辆登录表单有必填项未填写", "车辆登录", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void SetUseVehicle(UseVehicle useVehicle)
        {
            useVehicle.VIN     = VI.VIN;
            useVehicle.CarId   = _db.GetLastNewVehicleID() + 1;
            useVehicle.HPHM    = string.Empty;
            useVehicle.HPYS    = string.Empty;
            useVehicle.CLXH    = EI.VehicleModel;
            useVehicle.JZZL    = EI.RefMass.ToString();
            useVehicle.ZDZZL   = EI.MaxMass.ToString();
            useVehicle.FDJXH   = EI.EngineModel;
            useVehicle.FDJHM   = EI.EngineSN;
            useVehicle.FDJPL   = EI.EngineVolume.ToString("F");
            useVehicle.EDZS    = EI.RatedRPM.ToString();
            useVehicle.FDJEDGL = EI.RatedPower.ToString("F");

            string[] PostProcessorTypes = EI.PostProcessorType.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in PostProcessorTypes)
            {
                if (item.Contains("DPF"))
                {
                    useVehicle.DPF = item;
                }
                if (item.Contains("SCR"))
                {
                    useVehicle.SRC = item;
                }
            }
            string[] PostProcessorModels = EI.PostProcessorModel.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in PostProcessorModels)
            {
                if (item.Contains("DPF"))
                {
                    int index = item.IndexOf(':');
                    if (index < 0)
                    {
                        useVehicle.DPFXH = item;
                    }
                    else
                    {
                        useVehicle.DPFXH = item.Substring(index + 1);
                    }
                }
                if (item.Contains("SCR"))
                {
                    int index = item.IndexOf(':');
                    if (index < 0)
                    {
                        useVehicle.SRCXH = item;
                    }
                    else
                    {
                        useVehicle.SRCXH = item.Substring(index + 1);
                    }
                }
            }

            useVehicle.QGS      = EI.CylinderQTY.ToString();
            useVehicle.QDDJXH   = EI.MotorModel;
            useVehicle.CNZZXH   = EI.EnergyStorage;
            useVehicle.DCRL     = EI.BatteryCap;
            useVehicle.CLSCQY   = EI.VehicleMfr;
            useVehicle.CLCCRQ   = string.Empty;
            useVehicle.LJXSLC   = string.Empty;
            useVehicle.CZXMorDW = string.Empty;
            useVehicle.LXDH     = string.Empty;

            switch (EI.TestMethod)
            {
            case 4:
            case 6:
            case 7:
                useVehicle.RYLX = "柴油";
                break;

            default:
                useVehicle.RYLX = "汽油";
                break;
            }

            useVehicle.GYFS   = EI.GetFuelSupplyString();
            useVehicle.QDFS   = string.Empty;
            useVehicle.PPorXH = string.Empty;
            useVehicle.BSQXS  = EI.GetTransmissionString();
            useVehicle.SYXZ   = string.Empty;
            useVehicle.CCDJRI = string.Empty;
            useVehicle.HasOBD = EI.OBDLocation.Length <= 0 || EI.OBDLocation.Contains("无") || EI.OBDLocation.Contains("没有") ? "无" : "有";

            switch (EI.TestMethod)
            {
            case 0:
                useVehicle.CheckMethod = "免检";
                break;

            case 1:
                useVehicle.CheckMethod = "双怠速";
                break;

            case 2:
                useVehicle.CheckMethod = "稳态工况";
                break;

            case 3:
                useVehicle.CheckMethod = "简易瞬态";
                break;

            case 4:
                useVehicle.CheckMethod = "加载减速";
                break;

            case 6:
                useVehicle.CheckMethod = "自由加速";
                break;

            case 7:
                useVehicle.CheckMethod = "林格曼黑度";
                break;

            case 8:
                useVehicle.CheckMethod = "瞬态工况";
                break;

            case 9:
                useVehicle.CheckMethod = "其他";
                break;
            }

            useVehicle.CheckType   = _db.GetVINCountFromUseVehicle(VI.VIN) <= 0 ? "初检" : "复检";
            useVehicle.CLLX        = string.Empty;
            useVehicle.CXXL        = string.Empty;
            useVehicle.CSYS        = string.Empty;
            useVehicle.ZKRS        = string.Empty;
            useVehicle.DPH         = string.Empty;
            useVehicle.LTQY        = string.Empty;
            useVehicle.SYZT        = string.Empty;
            useVehicle.DWS         = string.Empty;
            useVehicle.LCBDS       = string.Empty;
            useVehicle.DCZZ        = string.Empty;
            useVehicle.JCZQ        = string.Empty;
            useVehicle.SFSYGYYB    = string.Empty;
            useVehicle.PFSP        = EI.GetEmissionStageString();
            useVehicle.CLS         = string.Empty;
            useVehicle.JQFS        = string.Empty;
            useVehicle.HPZL        = string.Empty;
            useVehicle.CCS         = string.Empty;
            useVehicle.FDJZZCJ     = EI.EngineMfr;
            useVehicle.EDNJ        = string.Empty;
            useVehicle.EDNJZS      = string.Empty;
            useVehicle.PQCLZZ      = string.Empty;
            useVehicle.PQGSL       = string.Empty;
            useVehicle.SFSYSRL     = string.Empty;
            useVehicle.CHQXH       = EI.CatConverter;
            useVehicle.ZRCL        = string.Empty;
            useVehicle.JRCZ        = string.Empty;
            useVehicle.YQBF        = string.Empty;
            useVehicle.CZLX        = string.Empty;
            useVehicle.CLLB        = string.Empty;
            useVehicle.CZDZ        = string.Empty;
            useVehicle.XQBH        = string.Empty;
            useVehicle.SFYSYCHQ    = string.Empty;
            useVehicle.ZBZL        = string.Empty;
            useVehicle.CheckStatus = "待检";
        }