Exemplo n.º 1
0
        public static void StoreQueryNotify(string requestDataJson, UDPClientItemBusiness.ClientItem item, int packId, int packNum)
        {
            object outModel     = null;
            object requestModel = null;

            DataFactory.CreateResponseProtocolData(TransmiteEnum.远程门店账目应答通知指令, requestDataJson, ref requestModel, ref outModel, packId);
            StoreQueryResultNotifyRequestModel rnrModel         = (StoreQueryResultNotifyRequestModel)(requestModel);
            StoreQueryNotifyOutParamsModel     responseOutModel = (StoreQueryNotifyOutParamsModel)outModel;

            Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, ((StoreQueryNotifyOutParamsModel)outModel).ResponsePackages);
            StoreQueryResultNotifyResponseModel responseDataModel = (StoreQueryResultNotifyResponseModel)(responseOutModel.ResponseModel);

            UDPSocketStoreQueryAnswerModel answerModel = UDPSocketStoreQueryAnswerBusiness.GetAnswerModel(rnrModel.SN, 1);

            if (responseDataModel != null && responseDataModel.Result_Code == "1" && answerModel != null)
            {
                //如果应答结果正确,清除应答缓存
                //if (packId == packNum)
                //{
                answerModel.Status = 2;
                answerModel.Result = rnrModel.TDList;
                //}
            }
            SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.远程门店账目应答通知指令), "远程门店账目应答通知指令", answerModel.RadarToken, requestDataJson);
        }
Exemplo n.º 2
0
        public object GetStoreSales(Dictionary <string, object> dicParas)
        {
            string errMsg     = string.Empty;
            string storeId    = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string date       = dicParas.ContainsKey("date") ? dicParas["date"].ToString() : string.Empty;
            string icCardId   = dicParas.ContainsKey("icCardId") ? dicParas["icCardId"].ToString() : string.Empty;
            string searchType = dicParas.ContainsKey("searchType") ? dicParas["searchType"].ToString() : string.Empty;

            //验证门店信息
            StoreCacheModel storeModel = null;
            StoreBusiness   store      = new StoreBusiness();

            if (!store.IsEffectiveStore(storeId, ref storeModel, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
            }

            string sn         = UDPSocketStoreQueryAnswerBusiness.GetSN();
            string radarToken = string.Empty;

            if (!DataFactory.SendDataStoreQuery(storeId, date, sn, searchType, icCardId, storeModel.StorePassword, out radarToken, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
            }

            int whileCount = 0;
            UDPSocketStoreQueryAnswerModel answerModel = null;

            while (answerModel == null && whileCount <= 25)
            {
                whileCount++;
                System.Threading.Thread.Sleep(1000);
                answerModel = UDPSocketStoreQueryAnswerBusiness.GetAnswerModel(sn, 2);
            }

            if (answerModel == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "系统没有响应"));
            }

            List <StoreQueryResultNotifyTableData> list = (List <StoreQueryResultNotifyTableData>)(answerModel.Result);

            if (list == null || list.Count == 0)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "营业数据不存在"));
            }
            else if (list[0].Key.Equals("查询结果") && list[0].Value.Equals("无此营业日期"))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "营业数据不存在"));
            }
            else
            {
                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, list));
            }
        }
Exemplo n.º 3
0
        static void AnswerStoreQueryProcess()
        {
            if (UDPSocketStoreQueryAnswerBusiness.Answer.Count > 0)
            {
                var query = from item in UDPSocketStoreQueryAnswerBusiness.Answer.Cast <DictionaryEntry>()
                            where ((UDPSocketStoreQueryAnswerModel)item.Value).CreateTime < DateTime.Now.AddSeconds(-100)
                            select item.Key.ToString();

                if (query.Count() > 0)
                {
                    foreach (var key in query.ToList <string>())
                    {
                        UDPSocketStoreQueryAnswerBusiness.Remove(key);
                    }
                }
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 4
0
        public static void StoreQuery(string requestDataJson, UDPClientItemBusiness.ClientItem item)
        {
            object outModel     = null;
            object requestModel = null;

            DataFactory.CreateResponseProtocolData(TransmiteEnum.远程门店账目查询指令, requestDataJson, ref requestModel, ref outModel);
            StoreQueryResponseModel  requestDataModel = (StoreQueryResponseModel)requestModel;
            StoreQueryOutParamsModel responseOutModel = (StoreQueryOutParamsModel)outModel;

            //验证相应模式
            bool bSuccess = false;

            if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonErrorResponseModel"))
            {
                ComonErrorResponseModel model = (ComonErrorResponseModel)(responseOutModel.ResponseModel);
                bSuccess = model.Result_Code == "1" ? true : false;
            }
            else if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonSuccessResponseModel"))
            {
                ComonSuccessResponseModel model = (ComonSuccessResponseModel)(responseOutModel.ResponseModel);
                bSuccess = model.Result_Code == "1" ? true : false;
            }
            else
            {
                StoreQueryResponseModel responseDataModel = (StoreQueryResponseModel)(responseOutModel.ResponseModel);
                bSuccess = responseDataModel.Result_Code == "1" ? true : false;
            }

            UDPSocketStoreQueryAnswerModel answerModel = UDPSocketStoreQueryAnswerBusiness.GetAnswerModel(requestDataModel.SN);

            if (bSuccess && answerModel != null)
            {
                //如果应答结果正确,修改状态
                answerModel.Status = 1;
            }
            string message = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]";

            SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.远程门店账目查询指令), "远程门店账目查询指令响应", answerModel.RadarToken, message);
        }