コード例 #1
0
        protected new  PackingLog NewPackingLog(LatticeSetting lattice, UserInfo userInfo, int operationType, List <LatticeOrdersCache> logList, decimal boxWeight)
        {
            string PackNumber = API_Helper.GetFlytPackageLabelIDBySingleFlyt();

            var pkgLog = new PackingLog()
            {
                ID            = Guid.NewGuid().ToString(),
                PackNumber    = PackNumber,
                CabinetId     = "",
                LatticeId     = "",
                OrderIds      = string.Join(",", logList.Select(l => l.OrderId)),
                OrderQty      = logList.Count,
                Weight        = boxWeight + logList.Sum(o => o.Weight),
                OperationType = operationType,
                OperationTime = DateTime.Now,
                UserId        = userInfo.UserId,
                UserName      = userInfo.UserName
            };

            if (lattice != null)
            {
                pkgLog.CabinetId = lattice.CabinetId.ToString();
                pkgLog.LatticeId = lattice.LatticeId;
            }
            pkgLog.PostTypeIds = string.Join(",", logList.Select(l => l.PostId).Distinct());
            var postTypeNames = logList.Select(l => l.PostName).Distinct();

            pkgLog.PostTypeNames = postTypeNames.Count() > 2 ? "MIX" : string.Join(",", postTypeNames);
            pkgLog.CountryIds    = string.Join(",", logList.Select(s => s.CountryId).Distinct());
            var countryNames = logList.Select(s => s.CountryName).Distinct();

            pkgLog.CountryNames = countryNames.Count() > 2 ? "MIX" : string.Join(",", countryNames);
            return(pkgLog);
        }
コード例 #2
0
        public void Can_Retrieve_Specific_Student()
        {
            int studentPicked;
            var ids      = _studentDbContext.Students.Select(s => s.StudentId).ToArray();
            int randomID = ids.OrderBy(x => Guid.NewGuid()).FirstOrDefault();

            if (ids.Count() >= 1)
            {
                studentPicked = randomID;
            }
            else
            {
                throw new Exception("There is no data to test in DB");
            }

            endPoint = _baseUrl + "/" + studentPicked;
            headers.Add("content-type", "application/json");
            var result = API_Helper.GetRequest(endPoint, headers);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            var fromAPI = JsonConvert.DeserializeObject <Student>(result.Content);
            var fromDB  = _studentDbContext.Students.Where(s => s.StudentId == randomID).ToList().FirstOrDefault();

            Assert.IsTrue(fromAPI.stEquals(fromDB));
        }
コード例 #3
0
    protected override void DataParser(JSONObject jsonObject)
    {
        int        code    = API_Helper.GetCode(jsonObject);
        string     message = API_Helper.GetMessage(jsonObject);
        JSONObject result  = null;

        if (API_Code.CodeIsNoContentUpdated(code))
        {
            var localSaveJson = new JSONObject(localSaveJsonString);
            result = API_Helper.GetResult(localSaveJson);
        }
        else if (jsonObject.HasField("result"))
        {
            result = API_Helper.GetResult(jsonObject);

            if (API_Code.CodeIsNormalSuccess(code))
            {
                var fileStream = File.CreateText(filePath);
                fileStream.Write(jsonObject.Print());
                fileStream.Close();
            }
        }

        OnRequestDataSuccess(code, message, result);
    }
コード例 #4
0
 /// <summary>
 /// 创建装箱记录(operationType:1自动满格,2手动满格,3打印包牌号)
 /// </summary>
 /// <param name="lattice">柜格</param>
 /// <param name="userInfo">用户信息</param>
 /// <param name="boxWeight">箱子重量</param>
 /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param>
 /// <returns></returns>
 internal override PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, decimal boxWeight, out List <LatticeOrdersCache> LatticeOrdersCacheList, int operationType = 3)
 {
     Debug.WriteLine("CreatePackingLog begin 2");
     using (var db = new OrderSortingDBEntities())
     {
         var logCache = db.LatticeOrdersCache.Where(o => o.LatticesettingId == lattice.ID);
         if (logCache == null || logCache.Count() < 1)
         {
             LatticeOrdersCacheList = null;
             return(null);
         }
         var logList = logCache.ToList();
         LatticeOrdersCacheList = logList;
         PackingLog pkgLog = NewPackingLog(lattice, userInfo, operationType, logList, boxWeight);
         db.PackingLog.Add(pkgLog);
         db.LatticeOrdersCache.RemoveRange(logList);
         var response = API_Helper.BatchOutbound(userInfo, pkgLog, logList);
         if (response != null && !response.Success && !string.IsNullOrWhiteSpace(response.Message))
         {
             throw new Exception(response.Message);
         }
         db.SaveChanges();
         return(pkgLog);
     }
 }
コード例 #5
0
        /// <summary>
        /// 调用物流接口,根据订单号获取订单信息
        /// </summary>
        /// <param name="orderId">订单号</param>
        /// <param name="userInfo">用户信息</param>
        /// <returns></returns>
        private OrderInfo CreateFlytOrderInfo(string orderId, UserInfo userInfo)
        {
            //调用物流接口,根据订单号获取订单信息
            VerifyOrderResponseContract order = null;

            if (userInfo.Pcid == "1067")//杭州处理中心
            {
                order = API_Helper.VerifyOrderForHangZhou(orderId, userInfo);
            }
            else
            {
                order = API_Helper.VerifyOrder(orderId, userInfo);
            }

            if (((!order.Success ?? false) || (!order?.Sucess ?? false)) && !string.IsNullOrWhiteSpace(order.Message))
            {
                throw new Exception(order.Message);
            }
            return(new OrderInfo
            {
                OrderId = order.OrderId,
                TraceId = string.IsNullOrWhiteSpace(order.TraceId) ? "" : order.TraceId,
                CountryId = order.CountryId,
                CountryName = order.CountryCnName,
                PostId = order.PostId,
                PostName = order.PostCnName,
                Zip = string.IsNullOrWhiteSpace(order.Zip) ? "" : order.Zip,
                Weight = order.Weight,
                CreateTime = DateTime.Now
            });
        }
コード例 #6
0
        public void Can_Create_A_New_Student()
        {
            endPoint = _baseUrl;
            Student postData = new Student()
            {
                FirstName = "testFirstName",
                LastName  = "testLastName",
                Email     = "*****@*****.**",
                Phone     = "3939992222",
                isActive  = true
            };

            var jsonData = JsonConvert.SerializeObject(postData);

            headers.Add("content-type", "application/json");
            var result = API_Helper.PostRequest(endPoint, headers, jsonData);

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var fromDB = _studentDbContext.Students.OrderByDescending(s => s.StudentId).FirstOrDefault();

            postData.StudentId = fromDB.StudentId;
            Assert.IsTrue(postData.stEquals(fromDB));

            //clean up the test data
            // _studentDbContext.Students.ToList().RemoveAll(s => s.Email == "*****@*****.**");
        }
コード例 #7
0
        public void Can_Delete_A_Student()
        {
            Student postData = new Student()
            {
                FirstName = "testFirstName",
                LastName  = "testLastName",
                Email     = "*****@*****.**",
                Phone     = "3939992222",
                isActive  = true
            };

            // Add a test data to DB
            _studentDbContext.Students.Add(postData);
            _studentDbContext.SaveChanges();


            endPoint = _baseUrl + "/" + postData.StudentId;


            // Delete the test data
            var result = API_Helper.DeleteRequest(endPoint, headers);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var fromDB = _studentDbContext.Students.Where(s => s.StudentId == postData.StudentId).FirstOrDefault();

            Assert.IsNull(fromDB); //Doesn't exist in DB
        }
コード例 #8
0
    protected void CheckCode(JSONObject data)
    {
        int code = API_Helper.GetCode(data);

        if (!API_Code.CodeIsNormalSuccess(code))
        {
            string errorMessage = API_Helper.GetMessage(data);
            error = new ErrorServerRequest(code, errorMessage);
        }
    }
コード例 #9
0
 /// <summary>
 /// 更新邮寄方式
 /// </summary>
 internal static void UpdatePostTypes()
 {
     try
     {
         var systemSetting = GetSystemSetting();
         using (var db = new OrderSortingDBEntities())
         {
             var now        = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
             var loginCount = db.LoginLog.Count(ll => ll.LoginTime > now);
             if (loginCount > 0)
             {
                 return;
             }
             //获取OA的全部邮寄方式
             DataTable dt = null;
             if (systemSetting.InterfaceType == InterfaceType.SigleFlyt)
             {
                 var content = API_Helper.GetPostListBySingleFlyt();
                 if (content != null && content.Count > 1)
                 {
                     foreach (var row in content)
                     {
                         Posttypes post = new Posttypes();
                         post.PostID     = row.Id;
                         post.CnPostName = row.Type;
                         post.EnPostCode = row.Id;
                         db.Posttypes.AddOrUpdate(post);
                     }
                     db.SaveChangesAsync();
                 }
             }
             else
             {
                 dt = API_Helper.GetPostList();
                 if (dt != null && dt.Rows.Count > 1)
                 {
                     foreach (DataRow row in dt.Rows)
                     {
                         Posttypes post = new Posttypes();
                         post.PostID     = row["id"].ToString();
                         post.CnPostName = row["type"].ToString();
                         post.EnPostCode = row["entype"].ToString();
                         db.Posttypes.AddOrUpdate(post);
                     }
                     db.SaveChangesAsync();
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #10
0
        public void Can_Retrieve_All_Students()
        {
            endPoint = _baseUrl;
            headers.Add("content-type", "application/json");
            var result = API_Helper.GetRequest(endPoint, headers);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            var fromAPI = JsonConvert.DeserializeObject <List <Student> >(result.Content).ToList();
            var fromDB  = _studentDbContext.Students.ToList();

            Assert.IsTrue(API_Helper.Check3Spots(fromAPI, fromDB));
        }
コード例 #11
0
        public pgAudioRecording()
        {
            InitializeComponent();

            audioBuffer  = new AudioBuffer();
            resultBuffer = new ResultBuffer();

            audioRecording = new AudioRecording(audioBuffer);
            apiHelper      = new API_Helper(audioBuffer, resultBuffer, ConfigFileHelper.ConfigApiAddress);
            dataAnalyzer   = new DataAnalyzer(resultBuffer);

            cts = new CancellationTokenSource();

            RecordingStateChanged += OnRecordingStateChanged;
        }
コード例 #12
0
        /// <summary>
        /// 调用EDS接口,根据订单号获取订单信息
        /// </summary>
        /// <param name="orderId">订单号</param>
        private OrderInfo CreateOrderInfo(string orderId)
        {
            var order = API_Helper.GetPostForSortOrder(orderId);

            return(new OrderInfo
            {
                OrderId = order.OrderId,
                TraceId = order.TraceId,
                CountryId = order.CountryId,
                CountryName = order.CountryCnName,
                PostId = order.PostId,
                PostName = order.PostCnName,
                Zip = order.Zip,
                Weight = order.Weight,
                CreateTime = DateTime.Now
            });
        }
コード例 #13
0
        public void Can_Update_Existing_Student_Info()
        {
            Student postData = new Student()
            {
                FirstName = "testFirstName",
                LastName  = "testLastName",
                Email     = "*****@*****.**",
                Phone     = "3939992222",
                isActive  = true
            };

            // Add a test data to DB
            _studentDbContext.Students.Add(postData);
            _studentDbContext.SaveChanges();

            Student updatedData = new Student()
            {
                FirstName = "xxxFirstName",
                LastName  = "xxxLastName",
                Email     = "*****@*****.**",
                Phone     = "0000000000",
                isActive  = false
            };

            updatedData.StudentId = postData.StudentId;
            endPoint = _baseUrl + "/" + updatedData.StudentId;

            var jsonData = JsonConvert.SerializeObject(updatedData);

            headers.Add("content-type", "application/json");

            // Update the test data
            var result = API_Helper.PutRequest(endPoint, headers, jsonData);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            // Get the updated data from DB
            var fromDB = _studentDbContext.Students.Where(s => s.StudentId == updatedData.StudentId).FirstOrDefault();

            // Refresh DbContext so that it has the most updated data.
            (((IObjectContextAdapter)_studentDbContext).ObjectContext).Refresh(RefreshMode.StoreWins, fromDB);

            Assert.IsTrue(updatedData.stEquals(fromDB));
        }
コード例 #14
0
ファイル: LoginService.cs プロジェクト: liusile/OrderSorting
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userAccount">帐号</param>
        /// <param name="userPassword">密码</param>
        /// <param name="lst_temp">获取登录对象</param>
        /// <param name="ErrorMsg">获取错误信息</param>
        /// <returns></returns>
        public static UserInfo CheckLogin(string userAccount, string userPassword, ref string ErrorMsg)
        {
            var systemSetting = BaseDataService.GetSystemSetting();

            if (systemSetting.InterfaceType == InterfaceType.Flyt)
            {
                return(API_Helper.Login(userAccount, userPassword, ref ErrorMsg));
            }
            else if (systemSetting.InterfaceType == InterfaceType.General)
            {
                userPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassword, "MD5").ToLower();
                return(API_Helper.CheckLogin(userAccount, userPassword, ref ErrorMsg));
            }
            else if (systemSetting.InterfaceType == InterfaceType.SigleFlyt)
            {
                userPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassword, "MD5").ToUpper();
                return(API_Helper.LoginBySingleFlyt(userAccount, userPassword, ref ErrorMsg));
            }
            else
            {
                throw new System.Exception("配置出错,未知的对接方!");
            }
        }
コード例 #15
0
#pragma warning restore

    protected virtual void DataParser(JSONObject jsonObject)
    {
        int        code    = API_Helper.GetCode(jsonObject);
        string     message = API_Helper.GetMessage(jsonObject);
        JSONObject result  = null;

        bool through = true;

        if (HasErrorCodeInActionHandleErrorCodeDict(code))
        {
            through = false;
            actionHandleErrorCodeDict[code](code, message);
        }

        if (through)
        {
            if (jsonObject.HasField("result"))
            {
                result = API_Helper.GetResult(jsonObject);
            }

            OnRequestDataSuccess(code, message, result);
        }
    }
コード例 #16
0
 /// <summary>
 /// 创建装箱记录(多格口打印一个PKG标签)
 /// </summary>
 /// <param name="latticeIdArray">格口号</param>
 /// <param name="userInfo">用户信息</param>
 /// <param name="criticalWeight">临界重量</param>
 /// <param name="boxWeight">箱子重量</param>
 /// <returns></returns>
 internal override PackingLog CreatePackingLog(string[] latticeIdArray, UserInfo userInfo, decimal criticalWeight, decimal boxWeight, out List <LatticeOrdersCache> latticeInfo, int operationType = 3)
 {
     using (var db = new OrderSortingDBEntities())
     {
         //根据格口号获取格口信息
         var LatticesettingIds = db.LatticeSetting.Where(ls => latticeIdArray.Contains(ls.LatticeId)).Select(ls => ls.ID);
         if (LatticesettingIds.Count() != latticeIdArray.Where(o => !string.IsNullOrWhiteSpace(o)).Count())
         {
             throw new Exception("输入的格口号有误,注意:多个格口间需使用回车键分隔!");
         }
         //根据格口信息获取相关的快件信息
         var logCache = db.LatticeOrdersCache.Where(o => LatticesettingIds.Contains(o.LatticesettingId));
         if (logCache == null || logCache.Count() < 1)
         {
             throw new Exception("没有分拣记录,装箱记录生成失败!");
         }
         var logList = logCache.ToList();
         latticeInfo = logList;
         //装箱记录
         PackingLog pkgLog = NewPackingLog(null, userInfo, operationType, logList, boxWeight);
         if (pkgLog.Weight > criticalWeight)
         {
             throw new Exception(string.Format("总重量{0}Kg,临界重量{1}Kg,装箱记录生成失败!", pkgLog.Weight, criticalWeight));
         }
         db.PackingLog.Add(pkgLog);
         db.LatticeOrdersCache.RemoveRange(logList);
         //把装箱信息上传到物流系统
         var response = API_Helper.BatchOutboundBySingleFlyt(userInfo, pkgLog, logList);
         if (response != null && !response.Success && !string.IsNullOrWhiteSpace(response.Message))
         {
             throw new Exception(response.Message);
         }
         db.SaveChanges();
         return(pkgLog);
     }
 }
コード例 #17
0
    public override void OnRequestDataSuccess(int code, string message, JSONObject result)
    {
        if (API_Helper.CodeIsSuccess(code))
        {
            Dictionary <string, string> constantsData = null;

            try
            {
                ValidateHasConstantsArray(result);
                constantsData = GetConstantsData(result);
            }
            catch (Exception e)
            {
                code    = API_Code.ERROR_CODE;
                message = e.Message;
            }

            callback(code, message, constantsData);
        }
        else
        {
            callback(code, message);
        }
    }
コード例 #18
0
ファイル: LoginService.cs プロジェクト: liusile/OrderSorting
 public static void SetProcessCenterID(string processCenterId, string deliverAddress = "9")
 {
     API_Helper.SetProcessCenterID(processCenterId, deliverAddress);
 }