/// <summary> /// 修改注册码 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public bool ModifyZcm(string taxNo, string pwd, string newZcm, out string errorMsg) { string strResult = string.Empty; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new ModifyZcmRequest { taxNo = taxNo, pwd = CommonHelper.MD5Encrypt(pwd), newAppKey = newZcm }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.ModifyZcm, ref result, out errorMsg); return(result); } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.ModifyZcmError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.ModifyZcmError; } return(false); }
/// <summary> /// 获取逾期提醒月数 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public int GetYqWarnMonth(out string errorMsg) { int month = 0; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new JxyqWarnMonthRequest { taxno = GlobalInfo.NSRSBH, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXYQWarnMonth, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JxyqWarnMonthResponse>(new JsonTextReader(new StringReader(response))); Int32.TryParse(obj.warnMonth, out month); } } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetJXWarnMonthError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetJXWarnMonthError; } return(month); }
/// <summary> /// 注册用户 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public bool Register(string appId, string nsrsbh, string nsrmc, string pwd, string areaId, out string errorMsg) { string strResult = string.Empty; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new RegisterRequest { taxNo = nsrsbh, appKey = appId, orgName = nsrmc, pwd = CommonHelper.MD5Encrypt(pwd), areaId = areaId }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.Register, ref result, out errorMsg); return(result); } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.RegisterError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.RegisterError; } return(false); }
/// <summary> /// 登录用户 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public LoginResponse Login(string nsrsbh, string pwd, string ftoken, out string errorMsg) { string strResult = string.Empty; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new LoginRequest { taxNo = nsrsbh, pwd = CommonHelper.MD5Encrypt(pwd), token = ftoken, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.Login, ref result, out errorMsg); if (result) { var ret = JsonConvert.DeserializeObject <LoginResponse>(response); return(ret); } } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.LoginError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.LoginError; } return(null); }
/// <summary> /// 批量获取发票状态 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public List <JXInvoiceStatusContent> GetInvoiceStatus(string fplist) { string errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new JXInvoiceStatusRequest { fplb = fplist, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXInvoiceStatus, ref result, out errorMsg); if (result) { var list = new JsonSerializer().Deserialize <List <JXInvoiceStatusContent> >(new JsonTextReader(new StringReader(response))); return(list); } return(null); } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetJXWarnMonthError, ex); } return(null); }
/// <summary> /// 获取开票起止日期 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public string[] GetJXKpStartEndDate(out string errorMsg, int reTimes = 1) { string[] strArray = new string[2]; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new JXSkssqRequest { taxno = GlobalInfo.NSRSBH, area = GlobalInfo.Dqdm, token = GlobalInfo.token, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXKpStartEndDate, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXStartEndDateResponse>(new JsonTextReader(new StringReader(response))); GlobalInfo.selectStartDate = GetFormatStr(obj.selectStartDate, "yyyyMMdd", "yyyy-MM-dd"); GlobalInfo.selectEndDate = GetFormatStr(obj.selectEndDate, "yyyyMMdd", "yyyy-MM-dd"); strArray[0] = GetFormatStr(obj.selectStartDate, "yyyyMMdd", "yyyy年MM月dd日"); strArray[1] = GetFormatStr(obj.selectEndDate, "yyyyMMdd", "yyyy年MM月dd日"); } } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetJXSkssqError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetJXSkssqError; } return(strArray); }
/// <summary> /// 获取税款所属期 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public string GetJXSsq(out string errorMsg, int reTimes = 1) { string strResult = string.Empty; errorMsg = string.Empty; try { string strRequest = new JavaScriptSerializer().Serialize( new JXSkssqRequest { taxno = GlobalInfo.NSRSBH, area = GlobalInfo.Dqdm, token = GlobalInfo.token, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXSkssq, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXSkssqResponse>(new JsonTextReader(new StringReader(response))); strResult = GetFormatStr(obj.skssq); } } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetJXSkssqError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetJXSkssqError; } return(strResult); }
public List <TQa> GetQaList(ref bool result) { List <TQa> QaList = new List <TQa>(); string requestJson = new JavaScriptSerializer().Serialize(new { NSRSBH = GlobalInfo.NSRSBH, FJH = GlobalInfo.FJH }); string errorMsg = string.Empty; string content = WSInterface.GetResponse(requestJson, InterfaceType.Lypl, ref result, out errorMsg); if (result) { QAInfo qaInfo = new JavaScriptSerializer().Deserialize <QAInfo>(content); foreach (var item in qaInfo.OWNISSUES) { QaList.Add(new TQa { Question = item.Question, Answer = item.RESPONSES.Any() ? item.RESPONSES.FirstOrDefault().RESPONSE : string.Empty }); } foreach (var item in qaInfo.HOTISSUES) { QaList.Add(new TQa { Question = item.Question, Answer = item.RESPONSES.Any() ? item.RESPONSES.FirstOrDefault().RESPONSE : string.Empty }); } } return(QaList); }
/// <summary> /// 发票查验,成功保存数据库 /// </summary> /// <returns></returns> public FpcyResult DoFPZY(string request, ref string errorMsg) { var ret = FpcyResult.FailNotSave; bool result = false; var response = WSInterface.GetResponse(request, InterfaceType.FPCY, ref result, out errorMsg); if (!result) { return(ret); } var responseObj = new JavaScriptSerializer().Deserialize <FpcyResponse>(response); if (responseObj.invoiceList != null && responseObj.invoiceList.Any()) { var invoiceInfo = responseObj.invoiceList[0].invoiceInfo; if (invoiceInfo != null) { var resultCode = (FpcyResultCode)Convert.ToInt32(invoiceInfo.resultCode); if (resultCode == FpcyResultCode.CheckSuccess || resultCode == FpcyResultCode.CheckInvoiceNotSame || resultCode == FpcyResultCode.CheckInvoiceNotExist) { FpcyDataObject fpcyObject = new FpcyDataObject(); fpcyObject.InvoiceCode = invoiceInfo.invoiceCode; fpcyObject.InvoiceNo = invoiceInfo.invoiceNo; fpcyObject.InvoiceDate = invoiceInfo.invoiceDate; fpcyObject.TotalAmount = invoiceInfo.totalAmount; fpcyObject.CheckCode = invoiceInfo.checkCode; fpcyObject.InvoiceType = invoiceInfo.invoiceType; fpcyObject.InvoiceData = response; fpcyObject.OperateDate = DateTime.Now; fpcyObject.ResultCode = invoiceInfo.resultCode; var entity = fpcyObject.ToEntity <TFpcy>(); FpcyService.AddEntities(entity); if (resultCode == FpcyResultCode.CheckSuccess) { ret = FpcyResult.SuccessAndSave; } else { errorMsg = string.Format("{0}({1})", invoiceInfo.resultTip, invoiceInfo.resultCode); ret = FpcyResult.FailAndSave; } } else { errorMsg = string.Format("{0}({1})", invoiceInfo.resultTip, invoiceInfo.resultCode); ret = FpcyResult.FailNotSave; } } } return(ret); }
/// <summary> /// 获取认证清单发票数据 /// </summary> /// <param name="query"></param> /// <param name="totalCount"></param> /// <param name="errorMsg"></param> /// <param name="reTimes"></param> /// <returns></returns> public List <JXInvoiceInfo> GetRzqdData(RzqdQueryViewModel query, out int totalCount, out string errorMsg, int reTimes = 1) { totalCount = 0; errorMsg = string.Empty; var invoiceList = new List <JXInvoiceInfo>(); try { string strRequest = new JavaScriptSerializer().Serialize( new JXCertificateRequest { taxno = GlobalInfo.NSRSBH, area = GlobalInfo.Dqdm, token = GlobalInfo.token, skssq = query.Skssq.Value.ToString("yyyyMM") }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXRZQD, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXCertificateResponse>(new JsonTextReader(new StringReader(response))); if (obj.result == "0") { errorMsg = obj.message; return(invoiceList); } else { var content = obj.data; if (content != null && content.Any()) { content = content.OrderBy(x => x.kprq).ToList(); invoiceList = ToView(content); } } } totalCount = invoiceList.Count; } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetRzqdError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetRzqdError; } totalCount = invoiceList.Count; return(invoiceList); }
/// <summary> /// 获取最新资讯 /// </summary> /// <returns></returns> public AdertiseResponse GetAdertiseInfo() { AdertiseResponse advertiseResponse = new AdertiseResponse(); string strRequest = new JavaScriptSerializer().Serialize(new { CXLX = AdvertiseCxlx.All.GetHashCode().ToString() }); bool result = false; string errorMsg = string.Empty; var response = WSInterface.GetResponse(strRequest, InterfaceType.AdvertiseQuery, ref result, out errorMsg); if (result) { advertiseResponse = JsonConvert.DeserializeObject <AdertiseResponse>(response); } return(advertiseResponse); }
/// <summary> /// 校验当前纳税人是否注册 /// </summary> /// <returns></returns> public bool IsRegister(out string errorMsg) { var ret = false; string strRequest = new JavaScriptSerializer().Serialize(new JXIsRegisterRequest { taxno = GlobalInfo.NSRSBH }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXIsRegister, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXIsRegisterResponse>(new JsonTextReader(new StringReader(response))); ret = obj.result == "1"; } return(ret); }
/// <summary> /// 获取常用应用 /// </summary> /// <returns></returns> public AppResponse GetAppInfoResponse(out bool isSuccess) { AppResponse appResponse = new AppResponse(); string strRequest = new JavaScriptSerializer().Serialize(new { YYRJLX = DownloadType.App.GetHashCode().ToString() }); bool result = false; string errorMsg = string.Empty; var response = WSInterface.GetResponse(strRequest, InterfaceType.AppDownload, ref result, out errorMsg); isSuccess = result; if (result) { appResponse = new JsonSerializer().Deserialize <AppResponse>(new JsonTextReader(new StringReader(response))); } return(appResponse); }
/// <summary> /// 设置逾期提醒月数 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public void SetYqWarnMonth(string month) { try { string strRequest = new JavaScriptSerializer().Serialize( new JxyqSetWarnMonthRequest { overWarnMonth = month, taxno = GlobalInfo.NSRSBH, }); bool result = false; string errorMsg = string.Empty; WSInterface.GetResponse(strRequest, InterfaceType.JXYQSetWarnMonth, ref result, out errorMsg); } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.SetJXWarnMonthError, ex); } }
/// <summary> /// 获取应用是否开放 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public AppSate GetAppIsOpen(AppCode appCode, out string errorMsg) { errorMsg = string.Empty; AppSate retState = AppSate.NotOpen; string strRequest = new JavaScriptSerializer().Serialize( new AppOpenRequest { taxno = GlobalInfo.NSRSBH, appId = appCode.GetHashCode().ToString(), }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.AppOpen, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <AppOpenResponse>(new JsonTextReader(new StringReader(response))); if (obj.appType == AppType.Pay) { if (obj.appFlag == 1) { if (obj.expireFlag == 0) { retState = AppSate.OverTime; } else { retState = AppSate.Open; } } else { retState = AppSate.NotOpen; } } else { retState = AppSate.Open; } } return(retState); }
/// <summary> /// 检查客户端、开票软件升级 /// </summary> /// <returns>true:相同,false:不同</returns> public bool CheckClientUpdate(int LBBM, out string serverClientVersion, out bool isForce) { serverClientVersion = string.Empty; string localVersion = string.Empty; isForce = false; try { var entity = SoftwareVersionService.LoadEntities(x => x.LBBM == LBBM && x.IsDownComplete == true).OrderByDescending(x => x.ID).FirstOrDefault(); if (LBBM == (int)LbblmType.Client) { localVersion = entity != null ? entity.Version : System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); } string strRequest = new JavaScriptSerializer().Serialize(new { LBBM = LBBM.ToString() }); bool result = false; string errorMsg = string.Empty; serverClientVersion = WSInterface.GetResponse(strRequest, InterfaceType.CX, ref result, out errorMsg); if (result) { dynamic serverVersionResponse = new JsonSerializer().Deserialize <dynamic>(new JsonTextReader(new StringReader(serverClientVersion))); if (LBBM == (int)LbblmType.Client && GetClientVersionToDouble(localVersion) < GetClientVersionToDouble(serverVersionResponse.VERSION.ToString())) { serverClientVersion = serverVersionResponse.VERSION.ToString(); if (serverVersionResponse.QZSJBZ.ToString() == ForceUpdate.Force.GetHashCode().ToString()) { isForce = true; } return(false); } } return(true); } catch (Exception e) { Logging.Log4NetHelper.Error(typeof(MainWindowService), Message.CheckVersion + e.ToString()); } return(true); }
/// <summary> /// 获取逾期提醒发票数据 /// </summary> /// <param name="query"></param> /// <param name="totalCount"></param> /// <param name="errorMsg"></param> /// <param name="reTimes"></param> /// <returns></returns> public List <JXInvoiceInfo> GetJXYQData(YqyjQueryViewModel query, out int totalCount, out string errorMsg) { totalCount = 0; errorMsg = string.Empty; var invoiceList = new List <JXInvoiceInfo>(); try { string strRequest = new JavaScriptSerializer().Serialize( new JXWarnRequest { taxno = GlobalInfo.NSRSBH, overWarnMonth = query.Month, }); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXYQYJ, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXWarnResponse>(new JsonTextReader(new StringReader(response))); var content = obj.data; if (content != null && content.Any()) { invoiceList = ToView(content); } } totalCount = invoiceList.Count; } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetYqyjError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetYqyjError; } totalCount = invoiceList.Count; return(invoiceList); }
public List <JXInvoiceInfo> GetJXData(GxrzQueryModel queryModel, out int totalCount, out string errorMsg, int reTimes = 1) { totalCount = 0; errorMsg = string.Empty; var invoiceList = new List <JXInvoiceInfo>(); try { string strRequest = new JavaScriptSerializer().Serialize( new JXGxrzRequest { taxno = GlobalInfo.NSRSBH, area = GlobalInfo.Dqdm, token = GlobalInfo.token, skssq = GlobalInfo.skssq.Replace("-", ""), invoiceCode = queryModel.InvoiceCode, invoiceNo = queryModel.InvoiceNo, fpzt = queryModel.FPZT, sellerTaxNo = queryModel.XSFSH, taxAmount = queryModel.SE, kprqBegin = queryModel.InvoiceDateStart.HasValue ? queryModel.InvoiceDateStart.Value.ToString("yyyy-MM-dd") : null, kprqEnd = queryModel.InvoiceDateEnd.HasValue ? queryModel.InvoiceDateEnd.Value.ToString("yyyy-MM-dd") : null, gxrqBegin = GlobalInfo.selectStartDate, gxrqEnd = GlobalInfo.selectEndDate }); //Logging.Log4NetHelper.Error(this, "获取进项数据request:" + strRequest); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXGXRZSearch, ref result, out errorMsg); if (result) { var obj = new JsonSerializer().Deserialize <JXGxrzResponse>(new JsonTextReader(new StringReader(response))); if (obj.result == "0") { errorMsg = obj.message; return(invoiceList); } else { var content = obj.data; if (content != null && content.Any()) { invoiceList = ToView(content); } } } totalCount = invoiceList.Count; } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GetJXDataError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GetJXDataError; } totalCount = invoiceList.Count; return(invoiceList); }
public void DownloadManual() { ManualResponse manualResponse; string strRequest = new JavaScriptSerializer().Serialize(new { SCVERSION = "" }); bool result = false; string errorMsg = string.Empty; var fileName = AppDomain.CurrentDomain.BaseDirectory + @"\Init.ini"; var myIni = new MyIniFile(fileName); var manualVersion = myIni.IniReadValue("InitializeInfo", "ManualVersion"); if (string.IsNullOrEmpty(manualVersion)) { manualVersion = "1.0.1"; myIni.IniWriteValue("InitializeInfo", "ManualVersion", manualVersion); } var response = WSInterface.GetResponse(strRequest, InterfaceType.ManualDownload, ref result, out errorMsg); if (result) { try { manualResponse = new JsonSerializer().Deserialize <ManualResponse>(new JsonTextReader(new StringReader(response))); if (manualResponse == null) { return; } if (!string.IsNullOrEmpty(manualResponse.SCWJURL)) { if (GetClientVersionToDouble(manualVersion) >= GetClientVersionToDouble(manualResponse.SCVERSION)) { return; } bool isFinish = false; DownloadHelper downLoadHelper = new DownloadHelper(manualResponse.SCWJURL, AppDomain.CurrentDomain.BaseDirectory); downLoadHelper.GetTotalSize(); string localFileName = AppDomain.CurrentDomain.BaseDirectory + downLoadHelper.FileName; if (!File.Exists(localFileName) || (File.Exists(localFileName) && new FileInfo(localFileName).Length < downLoadHelper.TotalSize)) { string downLoadStep = ConfigHelper.GetAppSettingValue("DownloadStep"); downLoadHelper.Step = !string.IsNullOrEmpty(downLoadStep) ? Convert.ToInt32(downLoadStep) : 102400; while (!downLoadHelper.IsFinished) { downLoadHelper.Download(); } isFinish = downLoadHelper.IsFinished; if (isFinish) { Logging.Log4NetHelper.Info(typeof(MainWindowService), string.Format(Resources.Message.ManualDownloadSuccess, manualResponse.SCVERSION)); } } else { downLoadHelper.OperateFile.Close(); downLoadHelper.OperateFile.Dispose(); } string localMd5 = CommonHelper.GetMD5HashFromFile(localFileName); if (localMd5 != manualResponse.MD5) { File.Delete(localFileName); } else { string oldChmPath = AppDomain.CurrentDomain.BaseDirectory + PRO_ReceiptsInvMgr.Resources.Common.ManualFilename; string newChmPath = AppDomain.CurrentDomain.BaseDirectory + downLoadHelper.FileName; if (File.Exists(newChmPath)) { if (File.Exists(oldChmPath)) { File.Delete(oldChmPath); } FileInfo fileInfo = new FileInfo(newChmPath); fileInfo.MoveTo(oldChmPath); } myIni.IniWriteValue("InitializeInfo", "ManualVersion", manualResponse.SCVERSION); } } } catch (Exception ex) { Logging.Log4NetHelper.Error(typeof(MainWindowService), string.Format(Message.ManualDownloadFail, ex.Message + System.Environment.NewLine + ex.StackTrace)); } } }
/// <summary> /// 升级服务器下载最新版本软件 /// </summary> /// <param name="LBBM">类别编码, 1:开票软件2:客户端软件</param> /// <param name="filePath">客户端更新包路径</param> /// <returns></returns> public bool DownloadSoftware(int LBBM, ref string filePath) { bool isNewVersion = false; string serverClientVersion; bool isForce = false; try { if (!CheckClientUpdate(LBBM, out serverClientVersion, out isForce)) { string updateDirectory = string.Empty; string RelativeFilePath = string.Empty; if (!string.IsNullOrEmpty(serverClientVersion)) { RelativeFilePath = "UpdatePackage" + @"\" + LbblmType.Client.ToString() + @"\" + serverClientVersion; //存放更新包路径 updateDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RelativeFilePath); } if (!Directory.Exists(updateDirectory)) { Directory.CreateDirectory(updateDirectory); } string strRequest = "{\"LBBM\":\"" + LBBM + "\",\"VERSION\":\"" + serverClientVersion + "\"}"; bool result = true; string errorMsg = string.Empty; string ret = WSInterface.GetResponse(strRequest, InterfaceType.DownLoad, ref result, out errorMsg); if (!result) { return(false); } string localFileName = string.Empty; string serverFileUrl = string.Empty; string serverMd5 = string.Empty; if (!string.IsNullOrEmpty(ret)) { dynamic downLoadResponse = new JsonSerializer().Deserialize <dynamic>(new JsonTextReader(new StringReader(ret))); serverFileUrl = downLoadResponse.FILEURL.ToString(); serverMd5 = downLoadResponse.MD5; localFileName = updateDirectory + "\\" + System.IO.Path.GetFileName(serverFileUrl); RelativeFilePath += "\\" + System.IO.Path.GetFileName(serverFileUrl); } bool isFinish = false; DownloadHelper downLoadHelper = new DownloadHelper(serverFileUrl, updateDirectory); downLoadHelper.GetTotalSize(); if (!File.Exists(localFileName) || (File.Exists(localFileName) && new FileInfo(localFileName).Length < downLoadHelper.TotalSize)) { Logging.Log4NetHelper.Info(typeof(MainWindowService), string.Format(((LbblmType)LBBM).GetDescription() + Message.DownStart, serverClientVersion)); string downLoadStep = ConfigHelper.GetAppSettingValue("DownloadStep"); downLoadHelper.Step = !string.IsNullOrEmpty(downLoadStep) ? Convert.ToInt32(downLoadStep) : 102400; while (!downLoadHelper.IsFinished) { downLoadHelper.Download(); } isFinish = downLoadHelper.IsFinished; if (isFinish) { Logging.Log4NetHelper.Info(typeof(MainWindowService), string.Format(((LbblmType)LBBM).GetDescription() + Message.UpdateSoftSuccessed, serverClientVersion, downLoadHelper.FilePath)); } } else { if (File.Exists(localFileName) && new FileInfo(localFileName).Length == downLoadHelper.TotalSize) { isFinish = true; } downLoadHelper.OperateFile.Close(); downLoadHelper.OperateFile.Dispose(); } if (isFinish) { string localMd5 = CommonHelper.GetMD5HashFromFile(localFileName); if (localMd5 == serverMd5) { var entity = SoftwareVersionService.GetFirstEntity(x => x.LBBM == LBBM && x.Version == serverClientVersion); if (entity != null) { entity.Version = serverClientVersion; entity.OPERATEDATE = DateTime.Now; entity.DowloadPath = RelativeFilePath; entity.IsDownComplete = true; entity.IsForceUpdate = isForce; SoftwareVersionService.UpdateEntities(entity); } else { entity = new SoftwareVersion(); entity.LBBM = LBBM; entity.Name = ((LbblmType)LBBM).ToString(); entity.Version = serverClientVersion; entity.OPERATEDATE = DateTime.Now; entity.DowloadPath = RelativeFilePath; entity.IsDownComplete = true; entity.IsForceUpdate = isForce; SoftwareVersionService.AddEntities(entity); } filePath = localFileName; isNewVersion = true; } else { Logging.Log4NetHelper.Info(typeof(MainWindowService), PRO_ReceiptsInvMgr.Resources.Message.DownloadMd5Fail); File.Delete(localFileName); isNewVersion = false; } } } } catch (Exception ex) { Logging.Log4NetHelper.Error(typeof(MainWindowService), (LBBM == LbblmType.Client.GetHashCode() ? Message.ClientUpdateError : Message.FwkpUpdateFailed) + ex.Message + System.Environment.NewLine + ex.StackTrace); isNewVersion = false; } return(isNewVersion); }
/// <summary> /// 勾选认证 /// </summary> /// <param name="fplb"></param> /// <param name="errorMsg"></param> /// <param name="reTimes"></param> /// <returns></returns> public bool GXRZ(List <JXInvoiceInfo> checkedList, out string errorMsg, int reTimes = 1) { bool ret = false; errorMsg = string.Empty; try { JXGxrzSubmitRequest request = new JXGxrzSubmitRequest(); request.taxno = GlobalInfo.NSRSBH; request.area = GlobalInfo.Dqdm; request.skssq = GlobalInfo.skssq.Replace("-", ""); request.token = GlobalInfo.token; List <string> strList = new List <string>(); for (var j = 0; j < checkedList.Count; j++) { if (j < checkedList.Count) { var item = checkedList[j]; strList.Add(string.Format("{0},{1},{2}", item.InvoiceCode, item.InvoiceNo, item.InvoiceDate.ToString("yyyy-MM-dd"))); } } if (strList.Any()) { request.fplb = string.Join(";", strList); } string strRequest = new JavaScriptSerializer().Serialize(request); bool result = false; var response = WSInterface.GetResponse(strRequest, InterfaceType.JXColCert, ref result, out errorMsg, 120000); if (result) { var obj = new JsonSerializer().Deserialize <JXGxrzSubmitResponse>(new JsonTextReader(new StringReader(response))); var data = obj.data; int successCount = data.Count(x => x.result == "1"); int failCount = data.Count(x => x.result == "0"); int unExecCount = data.Count(x => x.result == "-1"); StringBuilder sb = new StringBuilder(); if (successCount > 0) { sb.Append(string.Format("{0}张发票勾选认证执行成功。\r\n", successCount)); } if (failCount > 0) { sb.Append(string.Format("--------{0}张发票勾选认证执行失败--------\r\n", failCount)); foreach (var item in data.Where(x => x.result == "0")) { sb.Append(string.Format("发票代码:{0},发票号码:{1}\r\n", item.invoiceCode, item.invoiceNo)); } } if (unExecCount > 0) { sb.Append(string.Format("--------{0}张发票未执行--------\r\n", unExecCount)); foreach (var item in data.Where(x => x.result == "-1")) { sb.Append(string.Format("发票代码:{0},发票号码:{1}\r\n", item.invoiceCode, item.invoiceNo)); } } errorMsg = sb.ToString(); } } catch (Exception ex) { Logging.Log4NetHelper.Error(this, PRO_ReceiptsInvMgr.Resources.Message.GxrzSubmitError, ex); errorMsg = PRO_ReceiptsInvMgr.Resources.Message.GxrzSubmitError; } return(ret); }