public LocationResponse GetLocationResponse(string SN)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}(CustSN:{1})", methodName, SN);
            try
            {
                //1.检查传进来的参数
                Execute.ValidateParameter(SN);

                //2.获取DB中的数据
                LocationResponse locationResponse = Execute.GetLocationandCoordinateInfo(SN);
                logger.DebugFormat("Reponse data:{0}", locationResponse.ToString());
                return locationResponse;
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                LocationResponse locationResponse = new LocationResponse();

                locationResponse.SN = SN;
                locationResponse.Location = "";
                locationResponse.Coordinate = "";
                locationResponse.Status = -2;
                locationResponse.ErrorMsg = e.Message;
                logger.DebugFormat("Reponse data:{0}", locationResponse.ToString());
                return locationResponse;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
        public LocationResponse GetLocationResponse(string SN)
        {
            try
            {
                //1.检查传进来的参数
                Execute.ValidateParameter(SN);

                //2.获取DB中的数据
                LocationResponse locationResponse = Execute.GetLocationandCoordinateInfo(SN);
                return locationResponse;
            }
            catch (Exception e)
            {
                LocationResponse locationResponse = new LocationResponse();
                locationResponse.SN = SN;
                locationResponse.Location = "";
                locationResponse.Coordinate = "";
                locationResponse.Status = -2;
                locationResponse.ErrorMsg = e.Message;

                return locationResponse;
            }

        }
Exemplo n.º 3
0
        private static LocationResponse ToLocationResponse(DataRow row)
        {
            LocationResponse locationResponse = new LocationResponse();
            locationResponse.SN = (string)row["SN"];
            locationResponse.Location = (string)row["Location"];
            locationResponse.Coordinate = (string)row["Coordinate"];
            locationResponse.ErrorMsg = "";
            locationResponse.Status = 1;

            return locationResponse;
        }
Exemplo n.º 4
0
        public static LocationResponse GetLocationandCoordinateBySN(string sn)
        {
            string sqlStr = @"select CUSTSN as SN,@Location as Location,@Coordinate as Coordinate
                              from   Product where CUSTSN=@SN";

            DataTable dt = SqlHelper.ExecuteDataTable(HistoryDBName,System.Data.CommandType.Text, sqlStr,
                new SqlParameter("@SN", sn),
                new SqlParameter("@Location", "Location"),
                new SqlParameter("@Coordinate", "Coordinate"));

            if (dt == null || dt.Rows.Count == 0)
            {
                LocationResponse locationResponse = new LocationResponse();
                locationResponse.SN = sn;
                locationResponse.Location = "";
                locationResponse.Coordinate = "";
                locationResponse.Status = -1;
                locationResponse.ErrorMsg = "The SN: " + sn + " is not exist in DB!";

                return locationResponse;
            }
            else
            {
                return ToLocationResponse(dt.Rows[0]);
            }
        }
Exemplo n.º 5
0
        public static LocationResponse GetLocationandCoordinateBySN(string sn)
        {
            string sqlStr = @"select c.PartNo,ltrim(rtrim(c.LightNo)) as Location,ltrim(rtrim(d.Descr)) as Coordinate
                              from   Product a(nolock), ModelBOM b(nolock), WipBuffer c(nolock), 
                                     FamilyInfo d(nolock) ,Model e(nolock) 
                              where  c.Code='Automatic' and a.CUSTSN=@SN
                                     and a.Model=b.Material and b.Component=c.PartNo 
                                     and a.Model=e.Model and d.Family=e.Family 
                                     and c.Code=d.Name and c.PartNo=d.Value
                              order by c.PartNo";

            DataTable dt = SqlHelper.ExecuteDataTable(HistoryDBName,System.Data.CommandType.Text, sqlStr,
                new SqlParameter("@SN", sn));

            if (dt == null || dt.Rows.Count == 0)
            {
                LocationResponse locationResponse = new LocationResponse();
                locationResponse.SN = sn;
                locationResponse.Location = "";
                locationResponse.Coordinate = "";
                locationResponse.Status = -1;
                locationResponse.ErrorMsg = "Cant't find the information for SN: '" + sn + "' in DB!";

                return locationResponse;
            }
            else
            {
                DataRowCollection rows = dt.Rows;
                LocationResponse locationResponse = new LocationResponse();
                string locations = "";
                string coordinates = "";

                //将多个Location整理到一个栏位,多个Coordinate整理到一个栏位
                for (int i = 0; i < rows.Count; i++)
                {
                    DataRow row = rows[i];
                    string location = (string)row["Location"];
                    string coordinate = (string)row["Coordinate"];

                    if (i == rows.Count - 1)
                    {
                        locations = locations + location;
                        coordinates = coordinates + "(" + coordinate + ")";
                    }
                    else
                    {
                        locations = locations + location + ",";
                        coordinates = coordinates + "(" + coordinate + "),";
                    }
                }

                locationResponse.SN = sn;
                locationResponse.Location = locations;
                locationResponse.Coordinate = coordinates;
                locationResponse.ErrorMsg = "";
                locationResponse.Status = 1;

                return locationResponse;
            }
        }