示例#1
0
        private static bool doPostSmsMethod(string phoneNumber, string verifyCode, int minute = 15)
        {
            SmsModel sms = new SmsModel();

            try
            {
                var    config    = new Utility.SiteConfig();
                string serverUrl = config.tencentServer;
                string random    = Utility.Tools.GetRandomString(8);
                serverUrl = string.Format(serverUrl, config.tencentAppID, random);
                string         result         = String.Empty;
                long           time           = getCurrentTime();
                string         sig            = calculateSignature(phoneNumber, time, random);
                int            tpl_id         = config.tencentTemplateID;
                string         postJsonTpl    = "\"ext\":\"\",\"extend\":\"\",\"params\":[\"" + verifyCode + "\",\"" + minute + "\"],\"sig\":\"" + sig + "\",\"sign\":\"\",\"tel\":{\"mobile\":\"" + phoneNumber + "\",\"nationcode\":\"86\"},\"time\":" + time + ",\"tpl_id\":" + tpl_id + "";
                string         jsonBody       = "{" + postJsonTpl + "}";
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(serverUrl);
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    streamWriter.Write(jsonBody);
                    streamWriter.Flush();
                    streamWriter.Close();
                    HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        result = streamReader.ReadToEnd();
                    }
                }
                if (string.IsNullOrEmpty(result))
                {
                    return(false);
                }
                var response = Utility.JsonConvert.DeserializeObject <TencentSmsResponse>(result);
                if (response.result == 0)
                {
                    return(true);
                }
                LogHelper.WriteInfo("Utility.TencentSms.doPostSmsMethod", result);
                return(false);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("Utility.TencentSms", "doPostSmsMethod", ex);
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 获取开票结果
 /// </summary>
 /// <param name="XTLSH"></param>
 /// <param name="TOCKET"></param>
 /// <returns></returns>
 public static bool doGetInvoiceResult(string XTLSH, out string msg)
 {
     msg = string.Empty;
     try
     {
         string TOCKET   = GetLoginTOCKET();
         string postname = ChequeHttpConfig.HOST_SHKJ_FPKJ_KPJG;
         Dictionary <string, string> formParams = new Dictionary <string, string>();
         formParams["QYSH"]   = ChequeHttpConfig.QYSH;
         formParams["XTLSH"]  = XTLSH;
         formParams["FPZL"]   = "2";
         formParams["TOCKET"] = TOCKET;
         string result = doPostMethod(formParams, postname);
         LogHelper.WriteInfo("ChequeHelper.doGetInvoiceResult", result);
         string ReturnCode = Utility.Tools.GetJosnValue(result, "Result");
         if (!ReturnCode.Equals("1"))
         {
             msg = Utility.Tools.GetJosnValue(result, "TEXT");
             return(false);
         }
         string PDFContent = Utility.Tools.GetJosnValue(result, "PDF");
         if (string.IsNullOrEmpty(PDFContent))
         {
             msg = "PDF流内容为空";
             return(false);
         }
         string filepath = "/upload/invoice/" + DateTime.Now.ToString("yyyyMMdd") + "/";
         string rootPath = HttpContext.Current.Server.MapPath("~" + filepath);
         string fileName = Utility.Tools.GetJosnValue(PDFContent, "XTLSH");
         fileName = string.IsNullOrEmpty(fileName) ? DateTime.Now.ToFileTime().ToString() : fileName + ".pdf";
         byte[] PDFChar = Convert.FromBase64String(PDFContent);
         using (var flieStream = new FileStream(Path.Combine(rootPath, fileName), FileMode.Create))
         {
             flieStream.Write(PDFChar, 0, PDFChar.Length);
         }
         msg = filepath + fileName;
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(LogModule, "doGetInvoiceResult", ex);
         return(false);
     }
 }
示例#3
0
 /// <summary>
 /// 单独获取PDF信息
 /// </summary>
 /// <param name="FPHM">发票号</param>
 /// <param name="JSHJ">价税合计</param>
 /// <returns></returns>
 public static string doChequeGetReceiptPDF(string FPHM, string JSHJ)
 {
     try
     {
         string postname = ChequeHttpConfig.HOST_SHKJ_DZFP_PDFINFO;
         Dictionary <string, string> formParams = new Dictionary <string, string>();
         formParams["APPID"] = ChequeHttpConfig.APPID;
         formParams["FPHM"]  = FPHM;
         formParams["JSHJ"]  = JSHJ;
         string result = doPostMethod(formParams, postname);
         LogHelper.WriteInfo("ChequeHelper.doChequeGetReceiptPDF", result);
         return(result);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(LogModule, "doChequeGetReceiptPDF", ex);
         return(ex.Message);
     }
 }