Ejemplo n.º 1
0
        /// <summary>
        /// 登录成功后,查询用户信息
        /// </summary>
        /// <returns></returns>
        public bool GetUserInfo(string userId, out string errMsg)
        {
            errMsg = string.Empty;
            queryOption queryOption = new queryOption {
                batchNo = 1, batchSize = 10
            };
            queryResult queryResult = query("tUser", null, string.Format("UserID='{0}'", userId), queryOption);

            //queryResult queryResult = Soap.Instance.query("tUser", null, string.Format("UserID='{0}'", userId), queryOption, out errMsg);
            if (queryResult == null)
            {
                return(false);
            }
            if (queryResult.result > 0)
            {
                //int i = queryResult.count;
                userInfo.id        = Convert.ToInt32(queryResult.records[0].values[0]);
                userInfo.name      = queryResult.records[0].values[3].ToString();
                userInfo.grade     = Convert.ToInt32(queryResult.records[0].values[4]);
                userInfo.lastLogin = queryResult.records[0].values[5].ToString();
                userInfo.status    = Convert.ToInt32(queryResult.records[0].values[9]);
                //userInfo.orgId = Convert.ToInt64(queryResult.records[0].values[14]);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="objectName">查询的对象名</param>
        /// <param name="parms"> 传入的参数集合(当要查询的对象为 查询对象,带参数的视图 等要传入参数, 实体对象则传入空值) </param>
        /// <param name="condition">查询的附加条件(查询对象无效),如:“ID=1000” 等 </param>
        /// <param name="queryOption">查询选项</param>
        /// <returns></returns>
        public queryResult query(string objectName, lbParameter[] parms, string condition, queryOption queryOption, out string errMsg)
        {
            errMsg = string.Empty;
            queryResult result = null;

            //根据URL创建请求对象
            HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(serviceURL);

            webRequest.Method      = "POST";
            webRequest.ContentType = "text/xml;charset=\"utf-8\"";

            //查询报文格式
            ///*
            //<q0:query>
            //    <sessionId>$sessionId</sessionId>
            //    <objectName>$objectName</objectName>
            //    <params>$params</params>
            //    <condition>$condition</condition>
            //    <queryOption>
            //        <batchNo>$batchNo</batchNo>
            //        <batchSize>$batchSize</batchSize>
            //        <queryCount>$queryCount</queryCount>
            //        <valueOption>$valueOption</valueOption>
            //        <orderBy>$orderBy</orderBy>
            //        <queryId>$queryId</queryId>>
            //    </queryOption>
            //</q0:query>
            // *
            // * *

            StringBuilder soap = new StringBuilder();

            soap.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            soap.Append("<soapenv:Envelope xmlns:q0=\"http://ws.livebos.apex.com/\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
            soap.Append("<soapenv:Header>");
            soap.Append("</soapenv:Header>");
            soap.Append("<soapenv:Body>");
            soap.Append("<q0:query>");
            soap.Append("<sessionId>{0}</sessionId>");
            soap.Append("<objectName>{1}</objectName>");
            soap.Append("{2}");
            soap.Append("<condition>{3}</condition>");
            soap.Append("<queryOption>");
            soap.Append("<batchNo>{4}</batchNo>");
            soap.Append("<batchSize>{5}</batchSize>");
            soap.Append("<queryCount>{6}</queryCount>");
            soap.Append("<valueOption>{7}</valueOption>");
            soap.Append("<orderBy></orderBy>");
            soap.Append("<queryId></queryId>>");
            soap.Append("</queryOption>");
            soap.Append("</q0:query>");
            soap.Append("</soapenv:Body>  ");
            soap.Append("</soapenv:Envelope>");

            string strparams = GetSoapArrayString(Serialize(parms), "lbParameter", "params");

            //转换成字节数组
            byte[] bytes = Encoding.UTF8.GetBytes(string.Format(soap.ToString(), Common.Instance.SessionId, objectName, strparams, condition, queryOption.batchNo, queryOption.batchSize, queryOption.queryCount.ToString().ToLower(), queryOption.valueOption));
            webRequest.ContentLength = bytes.Length;
            Stream stream = webRequest.GetRequestStream();

            stream.Write(bytes, 0, bytes.Length);
            stream.Flush();
            stream.Close();

            try
            {
                HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;
                if (webResponse.StatusCode == HttpStatusCode.OK)
                {
                    //获取返回结果流
                    Stream       tempStraem = webResponse.GetResponseStream();
                    StreamReader sr         = new StreamReader(tempStraem, Encoding.UTF8);
                    //获取结果
                    string res = sr.ReadToEnd();
                    sr.Close();         //关闭读取器
                    tempStraem.Close(); //关闭流

                    //把结果先转换为xml文件 查询<LoginResult>节点,然后把它该节点再转换为类对象
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(res);
                    XmlNode node = xmlDoc.SelectSingleNode("//QueryResult");
                    res = node.OuterXml.Replace("QueryResult", "queryResult");


                    //把xml转换成lbeResult对象
                    result = Deserialize(res, typeof(queryResult)) as queryResult;
                }
            }
            catch (WebException ex)
            {
                HttpWebResponse response = ex.Response as HttpWebResponse;
                StreamReader    sr       = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                //获取结果
                errMsg = sr.ReadToEnd();
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据提货单号查询物资明细
        /// </summary>
        /// <param name="cNO1"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public DataTable GetOrderDetail(string cNO1, out string errMsg)
        {
            errMsg = string.Empty;
            queryOption queryOption = new queryOption {
                batchNo = 1, batchSize = 1000
            };
            //第一步:根据编号查询主表ID
            //queryResult queryResult = Common.Instance.query("ERP_MM_Order0", null, string.Format("cNO1='{0}'", cNO1), queryOption); //string.Format("cNO1='{0}'", cNO1)
            queryResult queryResult = Soap.Instance.query("ERP_MM_Order0", null, string.Format("cNO1='{0}'", cNO1), queryOption, out errMsg);
            int         ID          = 0;

            if (queryResult.result > 0)
            {
                if (queryResult.records == null)
                {
                    errMsg = "没有查询到数据!";
                    return(null);
                }
                //ID = Convert.ToInt32(queryResult.records[0].values[0]);
                //把返回的数据,放在表中,为了使用字段名称来获取数据
                DataTable dt = new DataTable();
                //遍历列名
                DataColumn dc;
                foreach (colInfo col in queryResult.metaData.colInfo)
                {
                    dc = new DataColumn(col.name);
                    //dc.Caption = col.label;
                    dt.Columns.Add(dc);
                }
                DataRow row = dt.NewRow();
                for (int i = 0; i < queryResult.records[0].size; i++)
                {
                    row[i] = queryResult.records[0].values[i];
                }
                dt.Rows.Add(row);
                ID = Convert.ToInt32(dt.Rows[0]["ID"]);
            }
            else
            {
                errMsg = "查询主表出错:" + queryResult.message;
                return(null);
            }
            //第二步:根据主表ID查询子表明细
            queryResult = Common.Instance.query("ERP_MM_Order0_tDetail", null, string.Format("fID={0}", ID), queryOption);
            //queryResult = Soap.Instance.query("ERP_MM_Order0_tDetail", null, string.Format("fID={0}", ID), queryOption,out errMsg);
            if (queryResult.result > 0)
            {
                //第三步:封装数据结果
                DataTable dt = new DataTable();
                //遍历列名
                DataColumn dc;
                foreach (colInfo col in queryResult.metaData.colInfo)
                {
                    dc         = new DataColumn(col.name);
                    dc.Caption = col.label;
                    dt.Columns.Add(dc);
                }
                //类型标识0:装车,1:出门
                dc = new DataColumn("type");
                dt.Columns.Add(dc);

                //判断是否有数据
                if (queryResult.records == null)
                {
                    errMsg = "子表没有数据!";
                    return(null);
                }

                DataRow row;
                //遍历数据
                foreach (lbRecord lbR in queryResult.records)
                {
                    row = dt.NewRow();
                    for (int i = 0; i < lbR.size; i++)
                    {
                        row[i] = lbR.values[i];
                    }
                    row["ikey0"] = row["ikey0"].Equals("0") ? "已上车" : "未上车";
                    row["type"]  = 0;
                    dt.Rows.Add(row);
                }

                //返回数据
                return(dt);
            }
            errMsg = "查询子表出错:" + queryResult.message;
            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据出门证查询物资明细
        /// </summary>
        /// <param name="cNO1"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public DataTable GetOrderDetail(string cNO, out Dictionary <string, object> dic, out string errMsg)
        {
            errMsg = string.Empty;
            int mainID, iState = 0;//单据状态(1|提货单;2|出门证;5|已确认;3|已出厂;4|已返厂)

            dic = new Dictionary <string, object>();

            //修改,添加    提货人:cUser/经办人:cUser2/审核领导:iUser2/开票人:iUser/过磅人:iUser3/监磅人:iUser4
            string      cUser, cUser2, iUser, iUser2, iUser3, iUser4;
            queryOption queryOption = new queryOption {
                batchNo = 1, batchSize = 1000
            };
            //第一步:根据编号查询主表ID
            queryResult queryResult = Common.Instance.query("ERP_MM_Order0", null, string.Format("cNO='{0}'", cNO), queryOption);

            //queryResult queryResult = Soap.Instance.query("ERP_MM_Order0", null, string.Format("cNO='{0}'", cNO), queryOption, out errMsg);

            if (queryResult.result > 0)
            {
                if (queryResult.records == null)
                {
                    errMsg = "没有查询到数据!";
                    return(null);
                }
                //把返回的数据,放在表中,为了使用字段名称来获取数据(如何按字段位置获取,如果字段位置改变会出现问题)
                DataTable dt = new DataTable();
                //遍历列名
                DataColumn dc;
                foreach (colInfo col in queryResult.metaData.colInfo)
                {
                    dc = new DataColumn(col.name);
                    //dc.Caption = col.label;
                    dt.Columns.Add(dc);
                }
                DataRow row = dt.NewRow();
                for (int i = 0; i < queryResult.records[0].size; i++)
                {
                    row[i] = queryResult.records[0].values[i];
                }
                dt.Rows.Add(row);
                mainID = Convert.ToInt32(dt.Rows[0]["ID"]);
                iState = Convert.ToInt32(dt.Rows[0]["iState"]);
                //提货人/经办人/审核领导....
                cUser  = dt.Rows[0]["cUser"].ToString();
                cUser2 = dt.Rows[0]["cUser2"].ToString();
                iUser  = dt.Rows[0]["iUser"].ToString();
                iUser2 = dt.Rows[0]["iUser2"].ToString();
                iUser3 = dt.Rows[0]["iUser3"].ToString();
                iUser4 = dt.Rows[0]["iUser4"].ToString();

                dic.Add("mainID", mainID);
                dic.Add("iState", iState);
                dic.Add("cUser", cUser);
                dic.Add("cUser2", cUser2);
                dic.Add("iUser", iUser);
                dic.Add("iUser2", iUser2);
                dic.Add("iUser3", iUser3);
                dic.Add("iUser4", iUser4);

                if (iState == 3)//已出厂
                {
                    errMsg = "单据已出厂!";
                    return(null);
                }
            }
            else
            {
                errMsg = "查询主表出错:" + queryResult.message;
                return(null);
            }
            //第二步:根据主表ID查询子表明细
            queryResult = Common.Instance.query("ERP_MM_Order0_tDetail", null, string.Format("fID={0}", mainID), queryOption);
            //queryResult = Soap.Instance.query("ERP_MM_Order0_tDetail", null, string.Format("fID={0}", mainID), queryOption, out errMsg);
            if (queryResult.result > 0)
            {
                //第三步:封装数据结果
                DataTable dt = new DataTable();
                //遍历列名
                DataColumn dc;
                foreach (colInfo col in queryResult.metaData.colInfo)
                {
                    dc         = new DataColumn(col.name);
                    dc.Caption = col.label;
                    dt.Columns.Add(dc);
                }
                //类型标识0:装车,1:出门
                dc = new DataColumn("type");
                dt.Columns.Add(dc);

                //判断是否有数据
                if (queryResult.records == null)
                {
                    errMsg = "子表没有数据!";
                    return(null);
                }

                DataRow row;
                //遍历数据
                foreach (lbRecord lbR in queryResult.records)
                {
                    row = dt.NewRow();
                    for (int i = 0; i < lbR.size; i++)
                    {
                        row[i] = lbR.values[i];
                    }
                    row["ikey1"] = row["ikey1"].Equals("0") ? "已出门" : "未出门";
                    row["type"]  = 1;

                    dt.Rows.Add(row);
                }

                //返回数据
                return(dt);
            }
            errMsg = "查询子表出错:" + queryResult.message;
            return(null);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 查询数据
 /// </summary>
 /// <param name="objectName">查询的对象名</param>
 /// <param name="parms"> 传入的参数集合(当要查询的对象为 查询对象,带参数的视图 等要传入参数, 实体对象则传入空值) </param>
 /// <param name="condition">查询的附加条件(查询对象无效),如:“ID=1000” 等 </param>
 /// <param name="queryOption">查询选项</param>
 /// <returns></returns>
 public queryResult query(string objectName, lbParameter[] parms, string condition, queryOption queryOption)
 {
     return(service.query(sessionId, objectName, parms, condition, queryOption));
 }