Operators reptiles

With the rise of loans, such as consumer credit, and now more and more companies require operators to report customers
and the amount of data is very large operators report, even if it is difficult to complete the customer's own access to, this time, we need customers licensed to us , a data carrier crawling

Note that the three network operators crawling way data is different today, the first to move an example:

General process: Customer authorizes -> Distribution -> Start crawling

If you have a problem friend, or if you want to call directly has developed a good interface can feel free to contact: phone / micro letter: 15625101713

 

using Gecko;
using Gecko.Net;
using Gecko.Observers;
using Gecko.WebIDL;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FireFox
{
public partial class Form1 : Form
{
string phone = "";//
string app = "";
string tel = "";
string serviceP = ""; // 客户提供的服务密码
string company = "";
string region = "";
string action = "";


List<long> fileList = new List<long>();
HashSet<string> hs = new HashSet<string>();//存储最后数据
int globalCountDown = 0;//全局倒计时
GeckoWebBrowser geckoBrowser;
Dictionary<string, string> HttpDataDic = new Dictionary<string, string>();
remoteS.loanSoapClient a = new remoteS.loanSoapClient();

string [] monthList = new string [ 7]; // month China Mobile parameter
string [] typeList = new string [ 7]; // China Mobile pull data classification parameters

Local //
// string FilePath = @ "";

// server
string FilePath = @ "";

 

public Form1(string phonePass, string appPass, string pwd)
{
phone = phonePass;
app = appPass;
serviceP = pwd;

InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
if (phone != "" && app != "" && serviceP != "")
{
InitTypeAndMonth();
InitWebBrowser();
timer1 = new System.Windows.Forms.Timer();
timer1.Tick += SetFristLoginAccountAndServierCode;
timer1.Interval = 5000;
timer1.Enabled = true;

 

}
else
{
this.Close();
}
}

/// <Summary>
/// month and initialization data classification parameters List
/// </ Summary>
void InitTypeAndMonth ()
{
for (int I = 0; I <monthList.Length; I ++)
{
monthList [I] = DateTime.Now.AddMonths (-i) .ToString ( "YYYYMM");
. typelist [I] = (I +. 1) .ToString () the PadLeft (2, '0');
}

}

/// <Summary>
/// Browser initialization
/// </ Summary>
Private void InitWebBrowser ()
{

 

 

string YYSWEB = "https://login.10086.cn/html/window/loginMini.html";

HttpWebRequest webReq2 = (System.Net.HttpWebRequest)WebRequest.Create("http://apis.juhe.cn/mobile/get?phone=" + tel + "&dtype=&key=您自己的key(可加微信:15625101713 获取 或直接调用接口)");
HttpWebResponse response2 = (HttpWebResponse)webReq2.GetResponse();
StreamReader sr2 = new StreamReader(response2.GetResponseStream(), Encoding.UTF8);
string ret2 = sr2.ReadToEnd();
JToken jo2 = (JToken)JsonConvert.DeserializeObject(ret2);
try
{
company = jo2["result"]["company"].ToString();
region = jo2["result"]["province"].ToString();
}
catch { }

Switch (Region)
{
Case "Guangxi": region = "Guangxi"; BREAK;
Case "Inner Mongolia": region = "Inner"; BREAK;
Case "Ningxia": region = "Ningxia"; BREAK;
Case "Chongqing": region = "Chongqing municipality"; BREAK;
Case "Beijing": region = "Beijing municipality"; BREAK;
Case "Shanghai": region = "Shanghai municipality"; BREAK;
default: Region = Region + "province" ; BREAK;
}

HttpWebRequest webReq = (System.Net.HttpWebRequest) WebRequest.Create ( VPN agents (micro-channel can be added: 15625101713 Gets or direct call interface));
the HttpWebResponse Response = (the HttpWebResponse) webReq.GetResponse ();
the StreamReader the StreamReader new new SR = (Response .GetResponseStream (), Encoding.UTF8);
String sr.ReadToEnd RET = ();
JToken Jo = (JToken) JsonConvert.DeserializeObject (RET);

the try
{
#region separate cookie code
var app_dir = Environment.CurrentDirectory; // program directory
String cookiesName = DateTime.Now.ToString ( "yyyyMMddHHmmss") + + Phone App;
String = Path.Combine Directory (APP_DIR, "Cookies", cookiesName); // cookie directory
iF) (System.IO.Directory.Exists (directory!)
System.IO.Directory.CreateDirectory (directory); // detect directory exists
Gecko.Xpcom.ProfileDirectory = directory; // bind cookie directory

FileStream fs1 = new FileStream(FilePath + "running" + phone + app + ".txt", System.IO.FileMode.Append, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(fs1);
sw1.WriteLine("deletePath:" + cookiesName);
sw1.WriteLine("------");
sw1.Close();
fs1.Close();

#endregion

Xpcom.Initialize (Path.Combine (app_dir, "FireFox ")); // initialize XPCOM
geckoBrowser new new GeckoWebBrowser = () {} the Dock = DockStyle.Fill; // create a browser instance
this.geckoBrowser.Name = "browser";
geckoBrowser.CreateControl ();
Panel1.Controls.Add (geckoBrowser); // added to the browser controls within the selected folder


GeckoPreferences.User [ "gfx.font_rendering.graphite.enabled"] = true ; // set preferences: font
GeckoPreferences.User [ "privacy.donottrackheader.enabled"] = true ; // set your browser to not be tracked
GeckoPreferences.User [ "general.useragent.override"] = "the User-- Agent: the Mozilla / 5.0 (the Windows NT 10.0; the WOW64; RV: 59.0) the Gecko / Firefox 20,100,101 / 59.0";
GeckoPreferences.User [ "intl.accept_languages"] = "en-US CN, zh; q = 0.9, en; q = 0.8 "; // not set, then the default English region

 

 

#region 设置ip代理
var ip = jo["data"][0]["IP"].ToString();
var port = jo["data"][0]["Port"].ToString();

GeckoPreferences.User["network.proxy.http"] = ip;
GeckoPreferences.User["network.proxy.http_port"] = int.Parse(port);
GeckoPreferences.User["network.proxy.type"] = 1;
#endregion

 

 

geckoBrowser.Navigate(YYSWEB);
geckoBrowser.UseHttpActivityObserver = true;
geckoBrowser.ObserveHttpModifyRequest += Browser_ObserveHttpModifyRequest;


= New new MyObserver MyObs MyObserver ();
MyObs.TicketLoadedEvent + = MyObs_TicketLoadedEvent; // how to process the captured Response
MyObs.targetUrls = new new List <String> () { "detailbillinfojsonp /" Tel +,}; // add to intercept url keyword
ObserverService.AddObserver (MyObs); // add observer
}
the catch {}


}


#region method

/// <summary>
/// 拦截HTTP请求的类
/// </summary>
public class MyObserver : BaseHttpModifyRequestObserver
{
public delegate void TicketLoadedEventHandler(HttpChannel p_HttpChannel, object sender, System.EventArgs e);

/// <the Summary>
/// handle event delegation
/// </ the Summary>
public Event TicketLoadedEventHandler TicketLoadedEvent;


/// <Summary>
/// URLs need to intercept, as long as either unique keyword
/// </ Summary>
public List <String> = targetUrls new new List <String> () {};


protected override void ObserveRequest(HttpChannel p_HttpChannel)
{
if (p_HttpChannel != null)
{
if (targetUrls.Any(s => p_HttpChannel.Uri.AbsoluteUri.Contains(s)))
{
TraceableChannel oTC = p_HttpChannel.CastToTraceableChannel();
StreamListenerTee oStream = new StreamListenerTee();
oStream.Completed += (sender, e) => TicketLoadedEvent(p_HttpChannel, sender, e);
oTC.SetNewListener(oStream);
}
}
}
}


public class NoPromptService : PromptService
{
public override void Alert(string dialogTitle, string text)
{
}
}

/// <summary>
/// 拦截请求
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Browser_ObserveHttpModifyRequest(object sender, GeckoObserveHttpModifyRequestEventArgs e)
{

}

/// <Summary>
/// interception request now use this
/// </ Summary>
/// <param name = "p_HttpChannel"> </ param>
/// <param name = "SENDER"> </ param >
/// <param name = "E"> </ param>
Private void MyObs_TicketLoadedEvent (Gecko.Net.HttpChannel p_HttpChannel, SENDER Object, EventArgs E)
{
IF (SENDER IS StreamListenerTee)
{
until after if (getHttpRequestData) // login can climb
{
GetHttpRequestData (p_HttpChannel);
getHttpRequestData = to false;
}
}
}

/// <Summary>
/// correctly detecting the first landing
/// </ Summary>
/// <Returns> </ Returns>
String LoginError ()
{
String STR = "";
the try
{
IF (geckoBrowser. Document.GetHtmlElementById ( "phone_error") Style.CssText.Contains ( "Block")).
STR + = "[phone number]";

if (geckoBrowser.Document.GetHtmlElementById("phonepwd_error").Style.CssText.Contains("block"))
str += "[服务密码]";

if (geckoBrowser.Document.GetHtmlElementById("smsCode_error").Style.CssText.Contains("block"))
str += "[短信验证码]";

IF (! STR = "")
{
return STR + "error, turn off the page and try again";
}
the else
{
return "unknown error, turn off the page and try again";
}
}
the catch
{
return "200 is";
}
}

/// <Summary>
/// set value is input
/// </ Summary>
/// <param name = "ID"> </ param>
/// <param name = "value"> </ param>
/// <Returns> </ Returns>
BOOL the SetValue (ID String, String value)
{
the try
{
GeckoHtmlElement GHE = geckoBrowser.Document.GetHtmlElementById (ID);
ghe.Focus ();
DomEventArgs geckoBrowser.Document.CreateEvent EV = ( " KeyEvents "); // create an event container?
Event webEvent = new Event (geckoBrowser.Window.DomWindow, ev.DomEvent as nsISupports); // create an event?
nsIDOMKeyEvent nsIEventVar = ((nsIDOMKeyEvent) ev.DomEvent ); // create a keyboard event?
for (int I = 0; I <value.length; I ++)
{
Keys K1 = (Keys) value [I];
nsIEventVar.InitKeyEvent (new nsAString ( "keypress" ), true, false, geckoBrowser.Window.DomWindow, false, false, false, false, (uint) k1, (uint) k1); // initialize keyboard events
ghe.GetEventTarget ( ) .DispatchEvent (ev); // trigger
nsIEventVar.InitKeyEvent (new nsAString ( "keyup" ), true, false, geckoBrowser.Window.DomWindow, false, false, false, false, (uint) k1, (uint) k1) ; // initialize keyboard events
ghe.GetEventTarget () dispatchEvent (ev); . // trigger
}
geckoBrowser.Document.Body.Click ();
ghe.Blur ();
return to true;
}
the catch
{
return false;
}
}

/// <summary>
/// 点击事件
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
bool ClickClick(string id)
{
try
{
geckoBrowser.Document.GetHtmlElementById(id).Click();
return true;
}
catch
{
return false;
}
}

/// <summary>
/// 设置httpData 的 Dictionary
/// </summary>
/// <param name="dic"></param>
/// <param name="key"></param>
/// <param name="value"></param>
void AddDataToDictionary(Dictionary<string, string> dic, string key, string value)
{
if (dic.ContainsKey(key))
{
dic[key] = value;
}
else
{
dic.Add(key, value);
}
}

#endregion

 


string verifyCode1 = "";
string verifyCode2 = "";
string verifyPicture = "";

/// <Summary>
/// Global Timer countdown
/// </ Summary>
/// <param name = "SENDER"> </ param>
/// <param name = "E"> </ param>
void timer_global_Tick Private (SENDER Object, EventArgs E)
{
globalCountDown ++;
IF (globalCountDown> 360)
{
// MessageBox.Show ( "been six minutes");
this.Close ();
}
}

 

void SetFristLoginAccountAndServierCode(object sender, EventArgs e)
{
if (SetValue("p_name", phone))
{
if (SetValue("p_pwd", serviceP))
{
if (ClickClick("getSMSpwd2"))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 1000;
timer1.Tick += SetFristLoginVerifyCode;
timer1.Enabled = true;

= to true timer_global.Enabled;
}
}
}
IF (globalCountDown> 60)
{
MessageBox.Show ( "one minute after");
}

}

void SetFristLoginVerifyCode(object sender, EventArgs e)
{

StreamReader sr = new StreamReader(FilePath + "running" + phone + app + ".txt", Encoding.Default);
String line;
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("smsCode"))
{
string[] cut = line.ToString().Split(':');
verifyCode1 = cut[1];
}

}
sr.Close();

 


if (verifyCode1 != "")//在数据库拿
{
if (SetValue("smsCode", verifyCode1))
{
if (ClickClick("submit_bt"))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 2000;
timer1.Tick += CheckFirstLoginError;
timer1.Enabled = true;
}
}
}
}

void CheckFirstLoginError(object sender, EventArgs e)
{
string errorMessage = LoginError();
if (errorMessage == "200")
{
geckoBrowser.Navigate("https://shop.10086.cn/i/?f=billdetailqry");
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 2000;
timer1.Tick += GoToBill;
timer1.Enabled = true;
}
else
{
FileStream fs1 = new FileStream(FilePath + "running" + phone + app + ".txt", System.IO.FileMode.Append, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(fs1);
sw1.WriteLine("s1:" + errorMessage);
sw1.WriteLine("------");
sw1.Close();
fs1.Close();

this.Close();
}
}

int testIsLogin = 0;
void GoToBill(object sender, EventArgs e)
{
GeckoHtmlElement he_logout = null;
if (testIsLogin < 10)
{
try
{
he_logout = geckoBrowser.Document.GetHtmlElementById("logout");
}
catch { }

if (he_logout == null)
{
testIsLogin++;
}
}
else
{
this.Close();
}

GeckoHtmlElement he_loginStr = null;
try
{
he_loginStr = geckoBrowser.Document.GetHtmlElementById("loginStr");
if (he_loginStr != null)
{
GeckoElement temp = null;
try
{
temp = geckoBrowser.Document.GetElementsByClassName("ui-dialog")[0] as GeckoHtmlElement;
}
catch
{
}
if (temp == null && globalCountDown > 65)
{
ClickClick("month1");
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 2000;
timer1.Tick += GetSecondVerifyCode;
timer1.Enabled = true;
}
}
}
catch
{ }
}

 

GeckoElement verifyCode = null;

void GetSecondVerifyCode(object sender, EventArgs e)
{
ImageCreator imageCreator = new ImageCreator(geckoBrowser);
try
{
if (verifyCode == null)
{
verifyCode = geckoBrowser.DomDocument.GetElementById("imageVec");
verifyCode.SetAttribute("style", "position:fixed;top:0;left:0;");
}
else
{
pictureBox1.Width = verifyCode.ClientWidth;
pictureBox1.Height = verifyCode.ClientHeight;
byte[] b = imageCreator.CanvasGetPngImage((uint)0 + 16, (uint)0, (uint)verifyCode.ClientWidth, (uint)verifyCode.ClientHeight);
MemoryStream ms = new MemoryStream(b);
pictureBox1.Image = Image.FromStream(ms);

Image vicoImg = Image.FromStream(ms);
vicoImg.Save(FilePath + phone + ".jpg");

FileStream fs1 = new FileStream(FilePath + "running" + phone + app + ".txt", System.IO.FileMode.Append, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(fs1);
sw1.WriteLine("imageAdd:" + "yes");
sw1.WriteLine("------");
sw1.Close();
fs1.Close();

//databaseConnection dc = new databaseConnection();
//dc.uploadPic(pictureBox1, "update towerYYS set verifyCode = @imgname where phone = '" + phone + "' and app = '" + app + "' ");

PromptFactory.PromptServiceCreator = () => new NoPromptService();

timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 2000;
timer1.Tick += ClickSecondSMSVerify;
timer1.Enabled = true;
}
}
catch
{ }
}

void ClickSecondSMSVerify(object sender, EventArgs e)
{
ClickClick("stc-send-sms");
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 1000;
timer1.Tick += SetSecondVerifyCode1;
timer1.Enabled = true;

}

void SetSecondVerifyCode1(object sender, EventArgs e)
{
StreamReader sr = new StreamReader(FilePath + "running" + phone + app + ".txt", Encoding.Default);
String line;
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("smsSecondCode"))
{
string[] cut = line.ToString().Split(':');
verifyCode2 = cut[1];
}

if (line.Contains("imageCode"))
{
string[] cut = line.ToString().Split(':');
verifyPicture = cut[1];
}

}
sr.Close();

 


if (verifyCode2 != "" && verifyPicture != "")
{
if (SetValue("vec_imgcode", verifyPicture))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 500;
timer1.Tick += SetSecondVerifyCode2;
timer1.Enabled = true;

}
}
}

void SetSecondVerifyCode2(object sender, EventArgs e)
{

if (verifyCode2 != "" && verifyPicture != "")
{
if (SetValue("vec_smspasswd", verifyCode2))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 500;
timer1.Tick += SetSecondVerifyCode3;
timer1.Enabled = true;
}
}
}

void SetSecondVerifyCode3(object sender, EventArgs e)
{
if (SetValue("vec_servpasswd", serviceP))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 500;
timer1.Tick += SetSecondVerifyCode4;
timer1.Enabled = true;
}
}

void SetSecondVerifyCode4(object sender, EventArgs e)
{
if (ClickClick("vecbtn"))
{
timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 1000;
timer1.Tick += SecondLoadingError;
timer1.Enabled = true;

getHttpRequestData = true;
}
}

SecondLoadingError void (SENDER Object, EventArgs E)
{
String errorMessage = "";
the try
{
errorMessage = geckoBrowser.Document.GetHtmlElementById. "GetAttribute (" detailerrmsg) ( "style");
IF (errorMessage.Contains ( "Block"))
{
The second error log ///
///
the FileStream new new FS1 = the FileStream (FilePath + "running" App + + + Phone ".txt", System.IO.FileMode.Append, FileAccess.Write);
the StreamWriter new new SW1 = the StreamWriter (FS1);
sw1.WriteLine ( "s1:" + "message authentication code or image verification code error, turn off the page to try again");
sw1.WriteLine ( "------");
sw1.Close () ;
fs1.Close ();

}
}
catch
{ }
timer1.Enabled = false;
}

bool getHttpRequestData = false;

 

void GetHttpRequestData(Gecko.Net.HttpChannel p_HttpChannel)
{

string path = Path.Combine(Environment.CurrentDirectory, "TempText", DateTime.Now.ToString("yyyyMMddHHmmss") + phone + app + ".txt");

string oldurl = p_HttpChannel.OriginalUri.ToString();
string[] forcut = oldurl.Split('?');
string url = forcut[0];
string[] query = forcut[1].Split('&');
string tempUrl = "?callback=" + query[0].Split('=')[1] + "&curCuror=" + query[1].Split('=')[1] + "&step=" + query[2].Split('=')[1] + "&";

AddDataToDictionary(HttpDataDic, "Path", path);
AddDataToDictionary(HttpDataDic, "Url", url + tempUrl);
AddDataToDictionary(HttpDataDic, "Host", p_HttpChannel.GetRequestHeader("Host"));
AddDataToDictionary(HttpDataDic, "Accept", p_HttpChannel.GetRequestHeader("Accept"));
AddDataToDictionary(HttpDataDic, "Accept-Language", p_HttpChannel.GetRequestHeader("Accept-Language"));
AddDataToDictionary(HttpDataDic, "Accept-Encoding", p_HttpChannel.GetRequestHeader("Accept-Encoding"));
AddDataToDictionary(HttpDataDic, "Content-Type", p_HttpChannel.GetRequestHeader("Content-Type"));
AddDataToDictionary(HttpDataDic, "X-Requested-With", p_HttpChannel.GetRequestHeader("X-Requested-With"));
AddDataToDictionary(HttpDataDic, "Connection", p_HttpChannel.GetRequestHeader("Connection"));
AddDataToDictionary(HttpDataDic, "Referer", p_HttpChannel.GetRequestHeader("Referer"));
AddDataToDictionary(HttpDataDic, "Cookie", p_HttpChannel.GetRequestHeader("Cookie"));


timer1.Enabled = false;
timer1 = new System.Windows.Forms.Timer();
timer1.Interval = 500;
timer1.Tick += papaTimer;
timer1.Enabled = true;


}

int m_index = 0;
int t_index = 0;

StringBuilder stringBuilder = new StringBuilder();
void papaTimer(object sender, EventArgs e)
{
try
{
long ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
string tempurl = "qryMonth=" + monthList[m_index] + "&billType=" + typeList[t_index] + "&" + "_=" + ts;
string url = HttpDataDic["Url"] + tempurl;

//创建请求
HttpWebRequest request = WebRequest.CreateHttp(url);
//request.Host = HttpDataDic["Host"];
request.Accept = HttpDataDic["Accept"];
request.Headers.Add("Accept-Language", HttpDataDic["Accept-Language"]);
request.Headers.Add("Accept-Encoding", HttpDataDic["Accept-Encoding"]);
request.ContentType = HttpDataDic["Content-Type"];
request.Headers.Add("X-Requested-With", HttpDataDic["X-Requested-With"]);
request.KeepAlive = true; //Connection属性
request.Referer = HttpDataDic["Referer"];
request.Headers.Add("Cookie", HttpDataDic["Cookie"]);

Task<WebResponse> res_async = request.GetResponseAsync();
while (!res_async.IsCompleted)
{
Thread.Sleep(500);
timer1.Enabled = false;
}

System.Net.HttpWebResponse response = res_async.Result as HttpWebResponse;
Stream stream = response.GetResponseStream();
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
stream = new GZipStream(stream, CompressionMode.Decompress);
}
string responseData = "";
using (StreamReader sr = new StreamReader(stream))
{
responseData = sr.ReadToEnd();
}
string newData = responseData.Substring(responseData.IndexOf('(') + 1, responseData.LastIndexOf(')') - (responseData.IndexOf('(') + 1));
timer1.Enabled = true;
WriteDataToText(newData);

}
catch
{
if (timer1.Enabled == false)
{
timer1.Enabled = true;
}
}

 

 

 

 

 

 

 

 

 

 


}

void WriteDataToText(string newData)
{
if (!newData.Contains("\"retCode\":\"000000\""))
{
newData = "{}";
}
if (t_index < 4)//类型未拉到最后
{
if (m_index < 6)//月份未拉到最后
{
if (m_index == 0)
{
string temp = "";
switch (t_index)
{
case 0: temp += "\"package\":["; break;
case 1: temp += "\"call\":["; break;
case 2: temp += "\"sms \":["; break;
case 3: temp += "\"net\":["; break;
case 4: temp += "\"increment\":["; break;
//case 5: temp += "\"collection\":["; break;
//case 6: temp += "\"other\":["; break;
}

string insertStr = temp + newData + ",";
stringBuilder.Append(temp);
m_index++;
}
else
{
stringBuilder.Append(newData + ",");
m_index++;
}

}
The else // last month
{
StringBuilder.Append (newData + "],");

m_index++;
m_index = 0;
t_index++;
}
}
else
{

string path = HttpDataDic["Path"];
{
stringBuilder.Insert(0, "{");
stringBuilder.Replace(",", "}", stringBuilder.Length - 1, 1);

byte[] BA = System.Text.Encoding.Default.GetBytes(stringBuilder.ToString());
string connectionString = a.setConnectionString("");
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand com = new SqlCommand("insert into 。。。", conn);
com.Parameters.Add("json", SqlDbType.Image);
com.Parameters["json"].Value = BA;
com.ExecuteNonQuery();
conn.Close();
}

timer1.Enabled = false;


FileStream fs1 = new FileStream(FilePath + "running" + phone + app + ".txt", System.IO.FileMode.Append, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(fs1);
sw1.WriteLine("state:" + "succeed");
sw1.WriteLine("------");
sw1.Close();
fs1.Close();

a.notReadDB("update ... ", "");

}

 

 

 

this.Close();
}

}

private void modifyName(string oldName, string newName)
{
if (FilePath != "")
{
if (System.IO.File.Exists(FilePath + oldName))
{
FileInfo fi = new FileInfo(FilePath + oldName);
fi.MoveTo(FilePath + newName);
}
}
}


private void button1_Click(object sender, EventArgs e)
{
verifyCode1 = textBox1.Text;
}

private void button2_Click(object sender, EventArgs e)
{
verifyCode2 = textBox2.Text;
}

private void button3_Click(object sender, EventArgs e)
{
verifyPicture = textBox3.Text;
}

private void timer1_Tick(object sender, EventArgs e)
{

}

 

Queue<string> qu = new Queue<string>();

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
modifyName("running" + phone + app + ".txt", "end" + phone + app + ".txt");

DirectoryInfo root = new DirectoryInfo(FilePath);
foreach (FileInfo f in root.GetFiles())
{
if (f.Name.Contains(phone) && f.Extension == ".jpg")
{
qu.Enqueue(f.Name);
}
}


for (int i = 0; i < qu.Count; i++)
{
System.IO.File.Delete(FilePath + qu.Dequeue());
}
}



}
}

search result

 

Reference: https: //blog.csdn.net/JamesData/article/details/103178888

Guess you like

Origin www.cnblogs.com/jamesData/p/11915420.html