bazy pro: Plik źródłowy C:/Users/DANTE/Documents/Visual Studio 2012/Projects/script connector/script connector/connector.cs
$(document).ready(initResizable);
$(window).load(resizeHeight);
$(document).ready(function() { searchBox.OnSelectItem(0); });
bazy pro
var searchBox = new SearchBox("searchBox", "search",false,'Szukaj');
Strona główna
Pakiety
Klasy
Pliki
Lista plików
$(document).ready(function(){initNavTree('connector_8cs_source.html','');});
All Klasy Przestrzenie nazw Funkcje Zmienne
connector.cs
1 ïżusing System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10 using System.Net;
11 using System.IO;
12 using global::apka;
13 using Microsoft.Win32;
14 using System.Xml;
15 namespace script_connector
16 {
20 public partial class connector : Form
21 {
22
26 HttpWebRequest req;
30 public bool net_error = false;
34 int srv_ok = 0;
38 bool valid = false;
42 StreamReader sr;
46 apk apka;
50 string user;
54 string pass;
58 string check_sum;
62 string baza64;
66 ASCIIEncoding encode = new ASCIIEncoding();
70 string post;
74 byte[] pdata;
78 Stream str;
82 public connector()
83 {
84 InitializeComponent();
85 nowy_req("http://srv.joinlicense.eu/");
86 valid = false;
87
88
89
90
91 }
99 public connector(string user,string key,string sum,string base64)
100 {
101 InitializeComponent();
102 this.baza64 = base64;
103 textBox1.Text = user;
104 this.user = user;
105 textBox2.Text = key;
106 this.pass = key;
107 textBox6.Text = sum;
108 this.check_sum = sum;
109 nowy_req("http://srv.joinlicense.com/");
110 valid = true;
111 }
117 private void nowy_req(string s)
118 {
119
120 req = (HttpWebRequest)HttpWebRequest.Create(s);
121 req.ContentType = "application/x-www-form-urlencoded";
122 req.Method = "POST";
123 // req.Timeout = 100;
124 req.UserAgent = "#sdyas872432";
125 try
126 {
127 HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
128
129
130 if (resp.StatusCode == HttpStatusCode.OK)
131
132 {
133 srv_ok= 0;
134
135 req = (HttpWebRequest)HttpWebRequest.Create(s);
136 req.ContentType = "application/x-www-form-urlencoded";
137 req.Method = "POST";
138 // req.Timeout = 100;
139 req.UserAgent = "#sdyas872432";
140 return;
141
142 }
143 else
144 {
145
146 srv_ok++;
147 throw new WebException();
148
149 }
150 }
151 catch (WebException ex)
152 {
153 // MessageBox.Show(ex.Status+"<>"+ex.Message);
154 if (srv_ok == 2)
155 {
156 return;
157 }
158 else
159 {
160 srv_ok++;
161 nowy_req("http://srv.licencjonuj.eu/");
162 }
163 }
164 }
172 private void button1_Click(object sender, EventArgs e)
173 {
174
175
176 if (textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && textBox6.Text.Length != 0
177 )
178 {
179 bool licence_status = false;
180 user = textBox1.Text;
181 pass = textBox2.Text;
182 check_sum = textBox6.Text;
183 post = "login=" + user + "&key=" + pass + "&checksum=" + check_sum;
184
185 pdata = encode.GetBytes(post);
186
187
188
189
190 //--------------------------
191 try
192 {
193
194 if (srv_ok==0)
195 {
196 MessageBox.Show("YOU ARE USING " + req.RequestUri.ToString());
197 req.ContentLength = pdata.Length;
198 // req.Timeout = 100;
199 str = req.GetRequestStream();
200
201 str.Write(pdata, 0, pdata.Length);//wyslanie danych z formularza
202 //------------------------
203 HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
204 str = resp.GetResponseStream();
205
206 sr = new StreamReader(str);
207 string pom;
208 // textBox5.Text
209 pom = sr.ReadToEnd();
210
211 if (pom.IndexOf("xml") > -1)
212 {
213 if (xaml(pom, "licence_status") == "SUCCESS")
214 {
215 licence_status = true; textBox3.Text = "SUCCESS"; textBox5.Text = pom;
216 reg_add();
217
218 }
219 else
220 if (xaml(pom, "licence_status") != "SUCCESS")
221 { textBox3.Text = "FAILED"; licence_status = false; }
222 }
223 else
224 throw new WebException();
225
226 if (!valid)
227 {
228 if (licence_status)
229 {
230 reg_add();
231
232
233 apk apka = new apk(true);
234 button3.Visible = true;
235 }
236 else
237 { MessageBox.Show("VALIDATION ERROR-WRONG DATA"); }
238 }
239 else
240 if (licence_status)
241 {
242
243
244 apka = new apk(true);
245
246 button3.Visible = true;
247
248 }
249
250 }
251 else
252 {
253
254 throw new WebException();
255
256 }
257 }
258 catch (Exception Ex)
259 {
260
261 if(Ex is WebException)
262 {
263
264 err();
265
266 }
267
268
269 }
270
271 }
272 else
273 {
274 MessageBox.Show("THIS FIELDS CANT BE EMPTY !!");
275 valid = false;
276
277 }
278
279 }
280
284 private void err()
285 {
286 MessageBox.Show("COULDN'T CONNECT-INTERNET CONNECTION PROBLEM\n");
287
288 connector x = this;
289 net_problem nt = new net_problem(ref x);
290 nt.Show();
291 this.Enabled = false;
292
293 }
294
295
296
297
298
302 private void reg_add()
303 {
304 RegistryKey reg;
305 string licence = base64_encrypt(xaml(textBox5.Text, "type"));
306 string date = base64_encrypt(xaml(textBox5.Text, "dateex"));
307 string regi = licence + "#ah1n1#" + date;
308 reg = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\licencjonuj_eu");
309 reg.SetValue(label1.Text, textBox1.Text, RegistryValueKind.String);
310 reg.SetValue(label2.Text, textBox2.Text, RegistryValueKind.String);
311 reg.SetValue(label3.Text, textBox6.Text, RegistryValueKind.String);
312 reg.SetValue("info", regi, RegistryValueKind.String);
313 reg.Close();
314
315
316
317 }
324 private string xaml(string tek,string tag)
325 {
326
327 XmlDocument doc = new XmlDocument();
328 doc.LoadXml(tek);
329 XmlNodeList stat;
330
331 stat=doc.GetElementsByTagName(tag);
332
333
334 if (stat == null)
335 return null;
336 else
337
338 return stat[0].InnerXml.ToString();
339 }
340
341
345 private void clear_form()
346 {
347 foreach (Control ct in this.Controls)
348 if (ct is TextBox)
349 ct.Text = "";
350 }
351
357 private void button2_Click(object sender, EventArgs e)
358 {
359 clear_form();
360 button3.Visible = false;
361
362 }
363
369 private void textBox5_KeyDown(object sender, KeyEventArgs e)
370 {
371 if(e.Control && e.KeyCode == Keys.A)
372 textBox5.SelectAll();
373 if (e.Control && e.KeyCode == Keys.C && textBox5.SelectionLength > 0)
374 textBox5.Copy();
375 }
376
382 private void button3_Click(object sender, EventArgs e)
383 {
384 if(!net_error)
385 {
386 try
387 {
388 apka.Show();
389 }
390 catch(Exception ex)
391 { MessageBox.Show(ex.ToString()); }
392 this.Close();
393 }
394 else
395 {
396
397 apk apk = new apk(true);
398 apk.Show();
399 this.Close();
400 }
401 }
402
408 private void button4_Click(object sender, EventArgs e)
409 {
410 textBox1.Text = user;
411 textBox2.Text = pass;
412 textBox6.Text = check_sum;
413
414
415 }
421 public static string base64_encrypt(string tek)
422 {
423 ASCIIEncoding enc=new ASCIIEncoding();
424
425 byte[] data = enc.GetBytes(tek);
426 return Convert.ToBase64String(data, Base64FormattingOptions.InsertLineBreaks);
427
428 }
434 public static string base64_decrypt(string tek)
435 {
436 ASCIIEncoding enc=new ASCIIEncoding();
437 byte[] data=Convert.FromBase64String(tek);
438 return enc.GetString(data);
439 }
440
446 private void connector_FormClosing(object sender, FormClosingEventArgs e)
447 {
448
449 }
450
451
452 }
453 }
UsersDANTEDocumentsVisual Studio 2012Projectsscript connectorscript connectorconnector.cs
Wygenerowano Cz, 7 mar 2013 13:04:30 dla bazy pro programem
1.8.3.1
Wyszukiwarka
Podobne podstrony:
connector 8?signer?s sourceMODELLING GRID CONNECTED VOLTAGE SOURCE INVERTER OPERATIONsource30Matrix3?pp sourceThread?pp sourcearm biquad ?scade ?1 ?st q31? sourcearm conv ?2? sourcearm mat mult q15? sourceconnections pre intermediate minimock test 0 4 bResource 8inl sourcearm fir lattice init q31? sourcearm fir ?cimate ?st q15? sourcesource11arm correlate ?st q15? sourceRJ45 to?25M connectionswięcej podobnych podstron