Ejemplo n.º 1
0
        public DataAcquisitionResult DeleteTaskList([FromBody] TaskListAPIParameterB param)
        {
            //记时
            LogHelper.Info("DeleteTaskList--开始");
            Stopwatch timeWatcher = new Stopwatch();
            long      checkTime   = 0;

            timeWatcher.Restart(); //开始计时
            DataAcquisitionResult result = new DataAcquisitionResult();

            result.code = "1000";
            result.msg  = "success";
            if (param == null)
            {
                param = new TaskListAPIParameterB();
                this.Request.GetQueryNameValuePairs();

                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
                HttpRequestBase request = context.Request;                                       //定义传统request对象
                param.operator_name = request.Form["operator_name"];
                param.operator_time = request.Form["operator_time"];
                param.sign          = request.Form["sign"];
                param.strdata       = request.Form["strdata"];

                LogHelper.Info("WebApi-DeleteTaskList param from forms");
            }
            if (!VerifyMiddleSign(param.operator_name, param.operator_time, param.sign))
            {
                LogHelper.Info(string.Format("operator_name{0},operation_time{1},sign{2}", param.operator_name, param.operator_time, param.sign));
                result.msg  = "签名错误";
                result.code = "1040";
                return(result);
            }
            List <TaskListBDTO> dto = new List <TaskListBDTO>();

            try
            {
                dto = Deserialize <List <TaskListBDTO> >(param.strdata);
                foreach (var item in dto)
                {
                    bool fla = DeleteTaskList(item);
                    if (!fla)
                    {
                        LogHelper.Error(string.Format("删除失败-DeleteTaskList:{0}", Serialize(item)));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                result.msg  = ex.Message;
                result.code = "1060";
                return(result);
            }
            timeWatcher.Stop();//结束计时
            checkTime = timeWatcher.ElapsedMilliseconds;
            LogHelper.Info(string.Format("DeleteTaskList--结束,执行时间:{0} ", checkTime));
            return(result);
        }
Ejemplo n.º 2
0
        private void button10_Click(object sender, EventArgs e)
        {
            DataAcquisitionResult result = new DataAcquisitionResult();
            List <TaskListBDTO>   dtos   = new List <TaskListBDTO>();
            TaskListBDTO          dto    = new TaskListBDTO();

            dto.processid = 50291;
            dtos.Add(dto);
            dto           = new TaskListBDTO();
            dto.processid = 50381;
            dtos.Add(dto);
            string server = "http://localhost:15988/api/TeamTask/DeleteTaskList";
            TaskListAPIParameterB param = new TaskListAPIParameterB();

            param.operator_name = "WebApi";
            param.operator_time = GenerateTimeStamp(DateTime.Now);
            param.sign          = GenSign(param.operator_name, param.operator_time);
            param.data          = dtos;
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("operator_name", param.operator_name);
            dic.Add("operator_time", param.operator_time);
            dic.Add("sign", param.sign);
            dic.Add("strdata", Serialize(param.data));

            try
            {
                HttpWebResponse        response = CreatePostHttpResponse(server, dic, null, null, Encoding.UTF8, null);
                System.IO.StreamReader sr       = new System.IO.StreamReader(response.GetResponseStream());
                string responseContent          = sr.ReadToEnd();
                sr.Close();

                DataAcquisitionResult rtn = Deserialize <DataAcquisitionResult>(responseContent);
                if (rtn.code != "1000")
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }