示例#1
0
        private static string getUpdatePatrolDetailSqlString(ReqUpdatePatrol request)
        {
            List <Request.Entity.PatrolDetailInfo> source = request.patrol_detail_list;
            string sql = String.Empty;

            if (source != null && source.Count > 0)
            {
                for (int i = 0; i < source.Count; i++)
                {
                    string temp = String.Empty;
                    Request.Entity.PatrolDetailInfo item = source[i];

                    temp = "  update PatrolReportDetail set ";
                    //temp += " Remarks = '" + item.remarks + "',";
                    string isselected = (item.is_selected.Trim().ToLower() == "false") ? "0" : "1";
                    temp += " IsSelected = '" + isselected + "'";
                    temp += " ,Remarks = '" + item.remarks + "'";
                    temp += " where patrolno = '" + item.patrol_no + "'";
                    temp += " and subno = '" + item.sub_no + "'";
                    temp += " ; ";

                    sql += temp;
                }
            }
            return(sql);
        }
示例#2
0
        private static string getUpdatePatrolHeaderSqlString(ReqUpdatePatrol request)
        {
            Request.Entity.PatrolHeaderInfo item = request.patrol_header;
            string temp = String.Empty;

            if (item != null)
            {
                temp  = "  update PatrolReportHeader set ";
                temp += " Remarks = '" + item.remarks + "',";
                temp += " WorkNo = '" + item.work_no + "',";
                temp += " UpdatedAt = '" + DateTime.Now.ToString() + "',";
                temp += " Updator = '" + request.account + "' ";
                temp += " where patrolno = '" + item.patrol_no + "'";
                temp += " ; ";
            }

            return(temp);
        }
示例#3
0
        /// <summary>
        /// 更新特巡报告头表和明细表
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Stream UpdatePatrol(Stream data)
        {
            #region 查找数据
            ResUpdatePatrol response = new ResUpdatePatrol();
            bool            success  = false;
            try
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqUpdatePatrol));
                //读取器
                StreamReader sr         = new StreamReader(data);
                string       dataString = String.Empty;
                while (!sr.EndOfStream)
                {
                    dataString = sr.ReadToEnd();
                    Console.WriteLine(dataString);

                    #region 日志输出
                    CommonInfo.Log(dataString);
                    #endregion

                    //反序列化json为对象注意顺序很重要
                    ReqUpdatePatrol request = new ReqUpdatePatrol();
                    MemoryStream    temp    = new MemoryStream(Encoding.UTF8.GetBytes(dataString));
                    request = json.ReadObject(temp) as ReqUpdatePatrol;

                    //关闭临时流
                    temp.Close();

                    //调用用户更新密码接口
                    if (request != null)
                    {
                        //**********(此处加入代码) 根据查询条件 加入业务逻辑代码*************
                        if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty)
                        {
                            string header = getUpdatePatrolHeaderSqlString(request);
                            string detail = getUpdatePatrolDetailSqlString(request);
                            success = PatrolEntity.updatePatrol(header, detail);
                        }
                    }
                }
                sr.Close();
                Console.WriteLine(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                #region 日志输出
                CommonInfo.Error("更新特巡数据错误" + ex.Message);
                #endregion
            }

            //返回消息体
            if (success)
            {
                response.SetSuccess();
            }
            else
            {
                ////默认是失败
                //response.SetFailed();
            }
            //将消息序列化为Json格式数据
            DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResUpdatePatrol));
            MemoryStream ms = new MemoryStream();
            obj2Json.WriteObject(ms, response);

            //注意一定要设置流的位置到开始位置,否则没有消息输出
            ms.Position = 0;
            return(ms);

            #endregion
        }