Example #1
0
        /// <summary>
        /// 添加充电监控数据
        /// </summary>
        public bool AddAMCIMData(AM_CIMData mod)
        {
            bool b = false;

            OpSql.Open();
            try
            {
                DataSet  ds  = new DataSet();
                object[] obj = new object[] {
                    mod.cs_id,
                    mod.t_id,
                    mod.v_id,
                    mod.cp_id,
                    mod.cp_code,
                    mod.cb_id,
                    mod.cb_code,
                    mod.am_cimd_begintime,
                    mod.am_cimd_endtime,
                    mod.am_cimd_kwh,
                    mod.am_cimd_unitmoney,
                    mod.am_cimd_money,
                    mod.am_cimd_health,
                    mod.am_cimd_chargenum,
                    mod.u_id
                };
                b = OpSql.Selectproce("Listener_IncludeCIMTCPReceive_UP0006", obj, ref ds);
            }
            catch { }
            finally { OpSql.Close(); }
            return(b);
        }
Example #2
0
        /// <summary>
        /// 单次充电结束
        /// </summary>
        public bool UP005(AM_CIMData mod)
        {
            bool b = false;
            List <PAY_IdCard> list = new List <PAY_IdCard>();
            HttpWebRequest    hwr  = (HttpWebRequest)WebRequest.Create(Config.g_httpUrl +
                                                                       string.Format("?type=UP0005"));

            hwr.Method = "post";
            using (StreamWriter sw = new StreamWriter(hwr.GetRequestStream()))
            {
                sw.Write(Convert.ToBase64String(m_appcode.OpMemory.Serialize(mod)));
            }
            WebResponse wr = hwr.GetResponse();

            using (StreamReader sr = new StreamReader(wr.GetResponseStream()))
            {
                b = bool.Parse(sr.ReadToEnd());
            }
            wr.Close();
            return(b);
        }
        /// <summary>
        /// 结束充电命令
        /// </summary>
        /// <returns></returns>
        public string UP0009(string cp_code, string cb_code, string bodyData)
        {
            string sendData = "";
            Dictionary <string, object> tcpClientDic = Config.g_tcpClientDic[cp_code];
            Listener_ChargePile_Data_AC data         = (Listener_ChargePile_Data_AC)tcpClientDic["data"];

            MatchCollection arr  = Regex.Matches(bodyData, @"(?<=\[)[^\]]*(?=\])");
            string          UP_0 = arr[0].Value; //枪编号
            string          UP_1 = arr[1].Value; //用户名
            string          UP_2 = arr[2].Value; //已充电量
            string          UP_3 = arr[3].Value; //充电开始时间

            //计算充电数据
            List <G_User> list = m_incUser.GetUser(long.Parse(UP_1));

            if (list.Count > 0)
            {
                //开始统计单次充电数据
                AM_CIMData mod = new AM_CIMData();
                mod.cs_id             = data.cs_id;
                mod.t_id              = data.t_id;
                mod.v_id              = data.v_id;
                mod.cp_id             = data.cp_id;
                mod.cp_code           = cp_code;
                mod.cb_id             = 0;
                mod.cb_code           = cb_code;
                mod.am_cimd_begintime = DateTime.Parse(UP_3);
                mod.am_cimd_endtime   = DateTime.Now;
                mod.am_cimd_kwh       = double.Parse(UP_2);
                mod.am_cimd_unitmoney = data.unitmoney;
                mod.am_cimd_money     = Convert.ToDecimal(Math.Ceiling(double.Parse(UP_2) * Convert.ToDouble(mod.am_cimd_unitmoney) * 100) / 100);
                mod.am_cimd_health    = 0;
                mod.am_cimd_chargenum = 0;
                mod.u_id              = list[0].u_id;
                mod.cp_guncode        = int.Parse(UP_0);
                if (m_incAMCIMData.AddAMCIMData(mod))
                {
                    sendData = "[1][" + (((decimal)list[0].u_money) - (decimal)mod.am_cimd_money).ToString("0.00") + "]";

                    //重置充电桩数据
                    data.condition = 1;
                    data.unitmoney = 0;
                    data.gundata[int.Parse(UP_0)].guncondition     = false;
                    data.gundata[int.Parse(UP_0)].useruname        = 0;
                    data.gundata[int.Parse(UP_0)].kwh              = 0;
                    data.gundata[int.Parse(UP_0)].timeleft         = new TimeSpan(0);
                    data.gundata[int.Parse(UP_0)].chargemod        = 0;
                    data.gundata[int.Parse(UP_0)].chargemodcontent = 0;
                }
                else
                {
                    sendData = "[0][0]";
                }
            }
            else
            {
                sendData = "[1][0]";
            }

            string checkbody = "DW0009" + sendData;

            sendData =
                tcpClientDic["version"].ToString() +
                data.cs_id +
                cp_code +
                cb_code +
                CRC16.GetString(checkbody) +
                checkbody;
            return(sendData);
        }
    /// <summary>
    /// 获取AM_CIMData实体List
    /// </summary>
    /// <param name="dt">源数据表</param>
    /// <returns></returns>
    public List <AM_CIMData> AM_CIMData(DataTable dt)
    {
        List <AM_CIMData> modelList = new List <AM_CIMData>();
        AM_CIMData        model;

        for (int n = 0; n < dt.Rows.Count; n++)
        {
            model = new AM_CIMData();
            try
            {
                model.am_cimd_id = (long)dt.Rows[n]["am_cimd_id"];
            }
            catch { }
            try{
                model.cs_id = (long)dt.Rows[n]["cs_id"];
            }
            catch { }
            try{
                model.t_id = (int)dt.Rows[n]["t_id"];
            }
            catch { }
            try{
                model.v_id = (int)dt.Rows[n]["v_id"];
            }
            catch { }
            try{
                model.cp_id = (long)dt.Rows[n]["cp_id"];
            }
            catch { }
            model.cp_code = dt.Rows[n]["cp_code"].ToString();
            try{
                model.cp_guncode = (int)dt.Rows[n]["cp_guncode"];
            }
            catch { }
            try{
                model.cb_id = (long)dt.Rows[n]["cb_id"];
            }
            catch { }
            model.cb_code = dt.Rows[n]["cb_code"].ToString();
            try{
                model.am_cimd_begintime = (DateTime)dt.Rows[n]["am_cimd_begintime"];
            }
            catch { }
            try{
                model.am_cimd_endtime = (DateTime)dt.Rows[n]["am_cimd_endtime"];
            }
            catch { }
            try{
                model.am_cimd_kwh = (double)dt.Rows[n]["am_cimd_kwh"];
            }
            catch { }
            try{
                model.am_cimd_kwhf = (double)dt.Rows[n]["am_cimd_kwhf"];
            }
            catch { }
            try{
                model.am_cimd_kwhg = (double)dt.Rows[n]["am_cimd_kwhg"];
            }
            catch { }
            try{
                model.am_cimd_kwhp = (double)dt.Rows[n]["am_cimd_kwhp"];
            }
            catch { }
            try{
                model.am_cimd_kwhj = (double)dt.Rows[n]["am_cimd_kwhj"];
            }
            catch { }
            try{
                model.am_cimd_unitmoney = (decimal)dt.Rows[n]["am_cimd_unitmoney"];
            }
            catch { }
            try{
                model.am_cimd_money = (decimal)dt.Rows[n]["am_cimd_money"];
            }
            catch { }
            try{
                model.am_cimd_health = (int)dt.Rows[n]["am_cimd_health"];
            }
            catch { }
            try{
                model.am_cimd_chargenum = (int)dt.Rows[n]["am_cimd_chargenum"];
            }
            catch { }
            try{
                model.u_id = (long)dt.Rows[n]["u_id"];
            }
            catch { }
            try{
                model.am_cimd_addtime = (DateTime)dt.Rows[n]["am_cimd_addtime"];
            }
            catch { }
            modelList.Add(model);
        }
        return(modelList);
    }