Ejemplo n.º 1
0
    public void DealStartTime(string tokenId, string id, string time)
    {
        HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
        var jsonCallBackFunName = HttpContext.Current.Request.Params["jsoncallback"];

        Dugufeixue.Common.SystemConfig.ConnectionStringKey = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStringDes"].ToString();
        //判断TokenId是否合法
        if (Common.VerifyTokenId(tokenId))
        {
            time = Convert.ToDateTime(time).ToString("yyyy-MM-dd 12:00:00");
            //查询接班人
            MySqlCommand sqlcom = new MySqlCommand
            {
                CommandText = "UPDATE ep_maintain SET maintain_date = now(),expect_finish_date=@time,  maintain_status = 2 where maintain_id =@id"
            };
            MySqlParameter[] commandParameters = new MySqlParameter[]
            {
                new MySqlParameter("@id", id),
                new MySqlParameter("@time", time),
            };
            MySqlCommand sqlcom2 = new MySqlCommand
            {
                CommandText = "UPDATE ep_equipment_component SET status = 5 WHERE equipment_component_id IN (SELECT relation_equipment_component_id FROM ep_maintain_relation WHERE maintain_id =@id)"
            };
            MySqlParameter[] commandParameters2 = new MySqlParameter[]
            {
                new MySqlParameter("@id", id)
            };
            try
            {
                var Info  = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom.CommandText, commandParameters);
                var Info2 = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom2.CommandText, commandParameters2);
                if (Info == 1 && Info2 >= 1) //信息存在
                {
                    // var json = Common.DataTableToJson(Info.Table); //信息的Json形式
                    HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(1, "处理成功"));
                    tbl_ep_maintain tbl = BF <bll_ep_maintain> .Instance.GetModel(id);

                    sendAllCenterPerson("接收到一条设置预期完成时间消息", "设置预期完成时间提醒:现场【" + tbl.scene_name + "】的设备【" + tbl.equipment_name + "】的部件【" + tbl.maintain_component_name + "】的保养人员设置了预期完成的时间!", "管理员保养提醒", id, tbl.scene_id, tbl.scene_name, tbl.equipment_id, tbl.equipment_name, tbl.maintain_equipment_component_id, tbl.maintain_component_name);
                    return;
                }
                else //不存在或已删除
                {
                    HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "处理失败"));
                    return;
                }
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "系统异常"));
                DLog.w("系统异常:" + e.Message);
                return;
            }
        }
        else//TokenId过期
        {
            HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "TokenId过期"));
            return;
        }
    }
Ejemplo n.º 2
0
    public void DealMaintainInfo(string tokenId, string equi, string solu, string id)
    {
        HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
        var jsonCallBackFunName = HttpContext.Current.Request.Params["jsoncallback"];

        Dugufeixue.Common.SystemConfig.ConnectionStringKey = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStringDes"].ToString();

        //判断TokenId是否合法
        if (Common.VerifyTokenId(tokenId))
        {
            //查询接班人
            MySqlCommand sqlcom = new MySqlCommand
            {
                CommandText = "UPDATE ep_maintain SET solution = @solution,maintain_date = NOW(),maintain_status = 2 where maintain_id =@id"
            };
            MySqlParameter[] commandParameters = new MySqlParameter[]
            {
                new MySqlParameter("@id", id),
                new MySqlParameter("@solution", solu)
            };
            MySqlCommand sqlcom2 = new MySqlCommand
            {
                CommandText = "INSERT INTO ep_maintain_relation (maintain_relation_id,maintain_id,relation_equipment_component_id) VALUES( UUID(), @maintain_id , @relation_equipment_component_id)"
            };
            MySqlCommand sqlcom3 = new MySqlCommand
            {
                CommandText = "UPDATE ep_equipment_component SET status = 6 WHERE equipment_component_id =@equipment_component_id"
            };
            string[] sArray = equi.Split(',');
            for (var i = 0; i < sArray.Length - 1; i++)
            {
                MySqlParameter[] commandParameters2 = new MySqlParameter[]
                {
                    // 循环插入数据
                    new MySqlParameter("@maintain_id", id),
                    new MySqlParameter("@relation_equipment_component_id", sArray[i])
                };
                MySqlParameter[] commandParameters3 = new MySqlParameter[]
                {
                    // 循环插入数据
                    new MySqlParameter("@equipment_component_id", sArray[i])
                };
                try
                {
                    var Info2 = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom2.CommandText, commandParameters2);
                    var Info3 = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom3.CommandText, commandParameters3);
                    if (Info2 != 1 || Info3 != 1)
                    {
                        return;
                    }
                    tbl_ep_maintain maintain = BF <bll_ep_maintain> .Instance.GetModel(id);

                    sendAllCenterPerson("接收到一条提交保养单消息", "提交保养单提醒:现场【" + maintain.scene_name + "】的设备【" + maintain.equipment_name + "】的部件【" + maintain.maintain_component_name + "】的保养人员提交了保养单!", "管理员保养提醒", id, maintain.scene_id, maintain.scene_name, maintain.equipment_id, maintain.equipment_name, maintain.maintain_equipment_component_id, maintain.maintain_component_name);
                }
                catch (Exception e)
                {
                    HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "系统异常"));
                    DLog.w("系统异常:" + e.Message);
                    return;
                }
            }
            try
            {
                var Info = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom.CommandText, commandParameters);
                if (Info == 1) //信息存在
                {
                    // var json = Common.DataTableToJson(Info.Table); //信息的Json形式
                    HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(1, "处理成功"));
                    return;
                }
                else //不存在或已删除
                {
                    HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "处理失败"));
                    return;
                }
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "系统异常"));
                DLog.w("系统异常:" + e.Message);
                return;
            }
        }
        else//TokenId过期
        {
            HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "TokenId过期"));
            return;
        }
    }