public byte[] DealClientRequestByte(string condition)
        {
            string result = DealRequest(condition);

            byte[] bytResult    = ConvertUtility.CodingToByte(result, 2);
            byte[] returnResult = null;

            // 长度大于2048,要进行压缩。
            if (bytResult != null || bytResult.Length > WebServiceConst.Need_Compress_MinLength)
            {
                byte[] temp
                    = CompressHelper.Compress(EnumCompressType.MemCompress, bytResult);

                returnResult    = new byte[temp.Length + 1];
                returnResult[0] = 1;
                Array.Copy(temp, 0, returnResult, 1, temp.Length);
                temp = null;
            }
            else
            {
                returnResult    = new byte[bytResult.Length + 1];
                returnResult[0] = 0;
                Array.Copy(bytResult, 0, returnResult, 1, bytResult.Length);
            }

            bytResult = null;
            // 处理客户端请求
            return(returnResult);
        }
        /// <summary>
        /// 处理结收到结果信息
        /// </summary>
        private void DealResult()
        {
            while (true)
            {
                if (!m_IsLoadService)
                {
                    continue;
                }

                try
                {
                    string         resultId       = "";
                    ResponseEntity responseEntity = Singleton <ResultCacheManager <ResponseEntity> > .Instance
                                                    .GetOneResult(out resultId);

                    if (!string.IsNullOrEmpty(resultId) && responseEntity != null)
                    {
                        ServiceCommand resultCommand = new ServiceCommand();
                        ServiceCommand command       = m_ReceiveCommandCaches.GetResult(resultId);
                        if (command == null)
                        {
                            continue;
                        }

                        m_Logger.Debug("处理结果返回。");

                        // 初始化结果
                        resultCommand.CreateTime  = DateTime.Now.ToString("yyyyMMdd HH:mm:ss:fff");
                        resultCommand.Entity      = responseEntity;
                        resultCommand.Guid        = command.Guid;
                        resultCommand.Priority    = command.Priority;
                        resultCommand.ReceiveId   = command.SendId;
                        resultCommand.SendId      = m_ServerId;
                        resultCommand.ServiceName = command.ServiceName;

                        //m_CommunicationControl.Send(resultCommand);

                        ResultService.ResultService resultService = new ResultService.ResultService();
                        //this.BeginInvoke(new ExportLogHandler(ExportLog), "WebService URL:" + resultService.Url);
                        m_Logger.Debug(resultService.Url);
                        byte[] bytResult   = ConvertUtility.CodingToByte(resultCommand.ClassToCommandString(), 2);
                        byte[] bytCompress = CompressHelper.Compress(EnumCompressType.MemCompress, bytResult);
                        resultService.SendByteResult(bytCompress);
                    }
                }
                catch (Exception ex)
                {
                    LogExport(ex.Message);
                    LogExport(ex.StackTrace);
                }

                Thread.Sleep(100);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Author:shwang
        /// Date:20140617
        /// Desc:拼接导出的文本内容格式
        /// </summary>
        /// <param name="dtb">DataTable</param>
        /// <returns>文本内容</returns>
        public static byte[] GetExportBytes(DataTable dtb)
        {
            StringBuilder sbl = new StringBuilder();

            foreach (DataColumn dcl in dtb.Columns)
            {
                sbl.AppendFormat("{0}\t", dcl.ColumnName);
            }
            sbl.Append(System.Environment.NewLine);

            foreach (DataRow dtr in dtb.Rows)
            {
                for (int i = 0; i < dtb.Columns.Count; i++)
                {
                    sbl.AppendFormat("{0}\t", dtr[i]);
                }
                sbl.Append(System.Environment.NewLine);
            }
            sbl.AppendFormat("END|{0}", dtb.Rows.Count);
            return(ConvertUtility.CodingToByte(sbl.ToString(), 2));
        }
Beispiel #4
0
        /// <summary>
        /// 命令字符串转换实体类
        /// </summary>
        /// <param name="command"></param>
        public override void CommandStringToClass(string command)
        {
            // 获取返回的头部信息
            ResponseHead = ResponseHead.CommandStringToEntity(command);

            // 明细数据
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(command);

            XmlNodeList lstNodes = xmlDocument.SelectNodes("ResponseEntity");
            XmlNode     xmlNode  = null;

            foreach (XmlNode node in lstNodes)
            {
                xmlNode = node.SelectSingleNode("Result");
                if (xmlNode == null || !xmlNode.HasChildNodes)
                {
                    return;
                }

                Result = ConvertUtility.CodingToByte(xmlNode.InnerText, 1);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 检索数据
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="responseEntity"></param>
        public void SearchData(SearchBusinessListFilter filter, ResponseEntity responseEntity)
        {
            if (filter == null)
            {
                ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.RequestCommandError);
                return;
            }

            if (filter.IsFilterServiceSideKey)
            {
                List <string> companys = Singleton <RedisEnumOperatorBLL> .Instance.GetUserOwnCompanyKeys(responseEntity.UserId);

                filter.BranchKey = string.Join("','", companys.ToArray());
            }

            if (filter.IsFilterBranchKeys)
            {
                List <string> stores = Singleton <RedisEnumOperatorBLL> .Instance.GetUserOwnStoreKeys(responseEntity.UserId);

                filter.BranchKeys = string.Join("','", stores.ToArray());
            }

            var businessDetail
                = Singleton <BusinessDetailDAL <BusinessDetailViewData> > .Instance.SearchData(filter);

            if (businessDetail == null || businessDetail.Count == 0)
            {
                ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.NoResult);
                m_Logger.Info("未查询到数据!。");
            }
            else
            {
                foreach (var business in businessDetail)
                {
                    business.LoanKindName = Singleton <RedisEnumOperatorBLL> .Instance.GetRedisData(
                        RedisEnumOperatorBLL.HashId_LoanKind_6, business.LoanKind).Name;

                    business.RegionName = Singleton <RedisEnumOperatorBLL> .Instance.GetRedisData(
                        RedisEnumOperatorBLL.HashId_Region_9, business.Region).Name;

                    business.BranchKeyName = Singleton <RedisEnumOperatorBLL> .Instance.GetRedisData(
                        RedisEnumOperatorBLL.HashId_Store_12, business.BranchKey).Name;
                }
                filter.BusinessID = businessDetail[0].BusinessID;

                var lstBills = Singleton <BillDetailDAL <BillDetailViewData> > .Instance.SearchData(filter);

                var lstBillItems = Singleton <BillItemDetailDAL <BillItemDetailViewData> > .Instance.SearchData(filter);

                var lstReceives = Singleton <ReceiveDetailDAL <ReceiveDetailViewData> > .Instance.SearchData(filter);

                var lstReceiveCut = Singleton <ReceiveCutDetailDAL <ReceivedCutViewData> > .Instance.SearchData(filter);

                var lastCloseDay = Singleton <GetLatestCloseTimeBLL> .Instance.GetLatestCloseTimeViewData(businessDetail[0].ServiceSideID);

                businessDetail[0].LatestTime = lastCloseDay.LatestTime;

                List <PenaltyIntViewData> lstPenaltyInt = null;
                // 罚息
                if (filter.IsSearchPenaltyInt)
                {
                    lstPenaltyInt = Singleton <PenaltyIntDetailDAL <PenaltyIntViewData> > .Instance.SearchData(filter);
                }

                // 代偿卡
                List <AdaptationCardDetailData> lstACard = null;
                if (filter.IsSearchAdaptationCard)
                {
                    lstACard = Singleton <AdaptationCardDAL <AdaptationCardDetailData> > .Instance.SearchData(filter);

                    lstACard.ForEach(p =>
                    {
                        p.AdaBankName = Singleton <RedisEnumOperatorBLL> .Instance.GetRedisData(
                            RedisEnumOperatorBLL.HashId_BankList_8, p.AdaBankName).Name;
                    });
                }

                StringBuilder sbHead           = new StringBuilder();
                int           billLength       = 0;
                int           billItemLength   = 0;
                int           receiveLength    = 0;
                int           receiveCutLength = 0;
                int           penaltyIntLength = 0;
                int           aCardLength      = 0;

                if (lstBills != null && lstBills.Count != 0)
                {
                    billLength = lstBills.Count;
                }
                if (lstBillItems != null && lstBillItems.Count != 0)
                {
                    billItemLength = lstBillItems.Count;
                }
                if (lstReceives != null && lstReceives.Count != 0)
                {
                    receiveLength = lstReceives.Count;
                }
                if (lstReceiveCut != null && lstReceiveCut.Count != 0)
                {
                    receiveCutLength = lstReceiveCut.Count;
                }
                if (lstPenaltyInt != null && lstPenaltyInt.Count != 0)
                {
                    penaltyIntLength = lstPenaltyInt.Count;
                }
                if (lstACard != null && lstACard.Count != 0)
                {
                    aCardLength = lstACard.Count;
                }

                sbHead.AppendFormat("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}"
                                    , 1, WebServiceConst.Separater_Semicolon, billLength, billItemLength
                                    , receiveLength, receiveCutLength, penaltyIntLength, aCardLength);

                StringBuilder sbContent = new StringBuilder();
                sbContent.AppendLine(sbHead.ToString());
                sbContent.AppendLine(businessDetail[0].ToString());
                if (lstBills != null && lstBills.Count != 0)
                {
                    foreach (var bill in lstBills)
                    {
                        sbContent.AppendLine(bill.ToString());
                    }
                }

                if (lstBillItems != null && lstBillItems.Count != 0)
                {
                    foreach (var billItem in lstBillItems)
                    {
                        sbContent.AppendLine(billItem.ToString());
                    }
                }

                if (lstReceives != null && lstReceives.Count != 0)
                {
                    foreach (var receive in lstReceives)
                    {
                        sbContent.AppendLine(receive.ToString());
                    }
                }

                if (lstReceiveCut != null && lstReceiveCut.Count != 0)
                {
                    foreach (var receiveCut in lstReceiveCut)
                    {
                        sbContent.AppendLine(receiveCut.ToString());
                    }
                }
                if (lstPenaltyInt != null && lstPenaltyInt.Count != 0)
                {
                    foreach (var penaltyInt in lstPenaltyInt)
                    {
                        sbContent.AppendLine(penaltyInt.ToString());
                    }
                }
                if (lstACard != null && lstACard.Count != 0)
                {
                    foreach (var aCard in lstACard)
                    {
                        sbContent.AppendLine(aCard.ToString());
                    }
                }

                var responseResult = new ResponseFileResult();
                responseResult.Result = ConvertUtility.CodingToByte(sbContent.ToString(), 2);

                ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.Success);
                responseEntity.Results = responseResult;
            }
        }