40 Star 85 Fork 38

codeman35 / weixinHttpApi2.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainForm_WeiXin.cs 2.97 KB
一键复制 编辑 原始数据 按行查看 历史
codeman35 提交于 2016-01-12 15:30 . no commit message
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace demo_win_httpsocket
{
partial class MainForm
{
/// <summary>
/// 查找对应Key的Value
/// </summary>
/// <param name="result"></param>
/// <param name="code"></param>
/// <param name="regex"></param>
/// <returns></returns>
string SearchKey(string result, string code, string regex)
{
if (result.IndexOf(code) != -1)
{
Regex reg = new Regex(regex);
Match m = reg.Match(result);
while (m.Success)
{
return m.Groups[1].Value;
}
}
//没有找到
throw new Exception("SearchKey not find \"" + code + "\"");
}
string SubString(
string objValue,
string indexStr = "",
string lastStr = "",
string iDefault = "",
bool throwE = false)
{
try
{
int index = objValue.IndexOf(indexStr);
if (lastStr != "" && index > -1)
{
objValue = objValue.Remove(0, index);
index = objValue.IndexOf(indexStr);
}
int last = objValue.IndexOf(lastStr);
last = last == 0 ? objValue.Length : last;
if (index > -1 && last > -1)
{
objValue = objValue.Substring(index + indexStr.Length, last - (index + indexStr.Length));
return objValue;
}
else
{
return iDefault;
}
}
catch (Exception error)
{
if (throwE) throw error;
return iDefault;
}
}
string GetDIName(string skey)
{
if (USER_DI.ContainsKey(skey))
return USER_DI[skey];
return skey;
}
String generateDeviceId()
{
StringBuilder sb = new StringBuilder();
sb.Append("e");
int count = 15;//15个随机数字
Random ran = new Random();
for (int i = 0; i < count; i++)
{
int num = (int)(ran.Next(10));
sb.Append(num);
}
return sb.ToString();
}
string CreateWeiXinFilesFolder(string folder = "files")
{
//存储到本地
var filesFolder = Path.Combine(Application.StartupPath, folder);
if (!Directory.Exists(filesFolder))
Directory.CreateDirectory(filesFolder);
return filesFolder;
}
}
}
1
https://gitee.com/lxwcode/weixinHttpApi2.0.git
git@gitee.com:lxwcode/weixinHttpApi2.0.git
lxwcode
weixinHttpApi2.0
weixinHttpApi2.0
master

搜索帮助