示例#1
0
    public void SendTask(string tokenId, string userlogin, string content, string sceneId, string sceneName)
    {
        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 = "SELECT * FROM sys_employee WHERE user_login = @user_login"
            };
            MySqlParameter[] commandParameters = new MySqlParameter[]
            {
                new MySqlParameter("@user_login", userlogin)
            };
            try
            {
                var Info = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sqlcom.CommandText, commandParameters).Tables[0].DefaultView;
                if (Info != null && Info.Table.Rows.Count >= 1) //信息存在
                {
                    tbl_ep_task tbl = new tbl_ep_task();
                    tbl.task_id            = Guid.NewGuid().ToString();
                    tbl.task_content       = content;
                    tbl.scene_id           = sceneId;
                    tbl.scene_name         = sceneName;
                    tbl.emp_id             = Info.Table.Rows[0]["emp_id"].ToString();
                    tbl.emp_name           = Info.Table.Rows[0]["emp_name"].ToString();
                    tbl.task_time          = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    tbl.task_status        = 0;
                    tbl.accept_task_status = 0;

                    MySqlCommand sqlmess = new MySqlCommand
                    {
                        CommandText = "INSERT INTO ep_task (task_id ,emp_id,emp_name,scene_id,scene_name,task_time,task_content,task_status,accept_task_status)" +
                                      " VALUES (@task_id ,@emp_id,@emp_name,@scene_id,@scene_name,@task_time,@task_content,@task_status,@accept_task_status)"
                    };
                    MySqlParameter[] commandParametersmess = new MySqlParameter[]
                    {
                        new MySqlParameter("@task_id", tbl.task_id),
                        new MySqlParameter("@emp_id", tbl.emp_id),
                        new MySqlParameter("@emp_name", tbl.emp_name),
                        new MySqlParameter("@scene_id", tbl.scene_id),
                        new MySqlParameter("@scene_name", tbl.scene_name),
                        new MySqlParameter("@task_time", tbl.task_time),
                        new MySqlParameter("@task_content", tbl.task_content),
                        new MySqlParameter("@task_status", tbl.task_status),
                        new MySqlParameter("@accept_task_status", tbl.accept_task_status),
                    };
                    var Info2 = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlmess.CommandText, commandParametersmess);
                    if (Info2 == 1) //信息存在
                    {
                        List <tbl_ep_scene_employee> lstEmp = BF <bll_ep_scene_employee> .Instance.GetModelList("scene_id='" + tbl.scene_id + "'", "");

                        foreach (tbl_ep_scene_employee emp in lstEmp)
                        {
                            tbl_sys_employee tblemp = BF <bll_sys_employee> .Instance.GetModel(emp.emp_id);

                            tbl_ep_message tbl_message = new tbl_ep_message();
                            tbl_message.message_id       = Guid.NewGuid().ToString();
                            tbl_message.emp_id           = tblemp.emp_id;
                            tbl_message.emp_name         = tblemp.emp_name;
                            tbl_message.message_title    = "接收到一条新任务";
                            tbl_message.message_time     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            tbl_message.message_status   = 0;
                            tbl_message.message_content  = tbl.emp_name + "发布了一条新任务,请查看!";
                            tbl_message.message_type     = "任务";
                            tbl_message.message_order_id = tbl.task_id;
                            BF <bll_ep_message> .Instance.Add(tbl_message);
                        }
                        // 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;
        }
    }
示例#2
0
    public void ApplyTask(string tokenId, string tid, string userName)
    {
        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 = "SELECT * FROM sys_employee  WHERE user_login = @user_login"
            };
            MySqlParameter[] commandParameters = new MySqlParameter[]
            {
                new MySqlParameter("@user_login", userName)
            };
            try
            {
                var Info = MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, sqlcom.CommandText, commandParameters).Tables[0].DefaultView;
                if (Info != null && Info.Table.Rows.Count >= 1) //信息存在
                {
                    tbl_ep_task tbl = BF <bll_ep_task> .Instance.GetModel(tid);

                    MySqlCommand sqlcom2 = new MySqlCommand
                    {
                        CommandText = "UPDATE ep_task SET task_status = '1',accept_emp_id = @emp_id, accept_emp_name= @emp_name,accept_time = @accept_time WHERE task_id = @id"
                    };
                    MySqlParameter[] commandParameters2 = new MySqlParameter[]
                    {
                        new MySqlParameter("@emp_id", Info.Table.Rows[0]["emp_id"].ToString()),
                        new MySqlParameter("@emp_name", Info.Table.Rows[0]["emp_name"].ToString()),
                        new MySqlParameter("@accept_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                        new MySqlParameter("@id", tid),
                    };

                    var empId   = Info.Table.Rows[0]["emp_id"].ToString();
                    var empName = Info.Table.Rows[0]["emp_name"].ToString();
                    var Info2   = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sqlcom2.CommandText, commandParameters2);
                    if (Info2 == 1) //信息存在
                    {
                        HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(1, "申请成功"));
                        sendPerson("接收到一条任务申请消息", "【" + empName + "】申请了新任务!", tbl.emp_id, tid);
                        return;
                    }
                    else //不存在或已删除
                    {
                        HttpContext.Current.Response.Write(jsonCallBackFunName + Common.GetResultJson(0, "申请失败"));
                        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;
        }
    }