[Route("Position")]/// เรียกตำแหน่งเจ้าหน้าที่
        public HttpResponseMessage loadPosition()
        {
            try
            {
                XpoTypesInfoHelper.GetXpoTypeInfoSource();
                XafTypesInfo.Instance.RegisterEntity(typeof(nutrition.Module.Position));
                List <Position_Model> list           = new List <Position_Model>();
                XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null);
                IObjectSpace          ObjectSpace    = directProvider.CreateObjectSpace();
                IList <Position>      collection     = ObjectSpace.GetObjects <Position>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1", null));
                foreach (Position row in collection)
                {
                    Position_Model model = new Position_Model();
                    model.PositionName = row.PositionName;
                    model.IsActive     = row.IsActive;
                    list.Add(model);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, list));
            }
            catch (Exception ex)
            {                   //Error case เกิดข้อผิดพลาด
                UserError err = new UserError();
                err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ

                err.message = ex.Message;
                //  Return resual
                //return Request.CreateResponse(HttpStatusCode.BadRequest, err);
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, err));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 位置设置
        /// </summary>
        /// <param name="dic_data">excel拿出的数据</param>
        /// <param name="i">循环变量</param>
        /// <param name="cust_customer">客户</param>
        private void customer_position_setting(List <Dictionary <string, object> > dic_data, int i, cust_customer cust_customer)
        {
            try
            {
                string address = Convert.ToString(dic_data[i]["F12"]).Trim();

                if (!string.IsNullOrEmpty(address))
                {
                    String addressStr = gaode_api_get_position + address;

                    Position_Model data = GaoDeHelper.GetPosition(addressStr, "UTF-8");
                    if (data.geocodes.Count > 0)
                    {
                        string location = data.geocodes[0].location;
                        if (!string.IsNullOrEmpty(location))
                        {
                            cust_customer.cust_x = Convert.ToDecimal(location.Split(new char[] { ',' })[0]);
                            cust_customer.cust_y = Convert.ToDecimal(location.Split(new char[] { ',' })[1]);
                            if (cust_customer.cust_usersname == pub_cust_name)
                            {
                                cust_customer.cust_GaoDe   = address;
                                cust_customer.cust_address = data.geocodes[0].formatted_address;
                            }
                            else
                            {
                                cust_customer.cust_GaoDe   = data.geocodes[0].formatted_address;
                                cust_customer.cust_address = address;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }