Advertisement
Guest User

Untitled

a guest
May 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Newtonsoft.Json;
  7. using System.IO;
  8. using System.Data.SqlClient;
  9.  
  10.  
  11.  
  12. namespace JsonToDb
  13. {
  14. #region RootObjects
  15. public class ClicksUserAgent
  16. {
  17. public string deviceType { get; set; }
  18. public string operatingSystem { get; set; }
  19. public string browser { get; set; }
  20. public string rawUserAgent { get; set; }
  21. }
  22.  
  23. public class ClicksUserInfo
  24. {
  25. public string userId { get; set; }
  26. public string ip { get; set; }
  27. public ClicksUserAgent userAgent { get; set; }
  28. }
  29.  
  30. public class ClicksSiteDomain
  31. {
  32. public string countryCode { get; set; }
  33. public string domainName { get; set; }
  34. }
  35.  
  36. public class ClicksRootObject
  37. {
  38. public ClicksUserInfo userInfo { get; set; }
  39. public ClicksSiteDomain siteDomain { get; set; }
  40. public string dataCenter { get; set; }
  41. public string utcDate { get; set; }
  42. public string timeKey { get; set; }
  43. public string offerTitle { get; set; }
  44. public List<string> category { get; set; }
  45. public double price { get; set; }
  46. public string merchant { get; set; }
  47. public string source { get; set; }
  48. public List<string> keywords { get; set; }
  49. public string offerViewId { get; set; }
  50. public string clickId { get; set; }
  51. public double earning { get; set; }
  52. public string searchId { get; set; }
  53. }
  54. #endregion
  55.  
  56. class Clicks
  57. {
  58.  
  59. SqlConnection con = new SqlConnection(GlobalVar.databaseConnection);
  60.  
  61. #region FieldsForClicks
  62. public string userInfo_userID { get; set; }
  63. public string userInfo_ip { get; set; }
  64. public string userInfo_userAgent_deviceType { get; set; }
  65. public string userInfo_userAgent_operatingSystem { get; set; }
  66. public string userInfo_userAgent_browser { get; set; }
  67. public string userInfo_userAgent_rawUserAgent { get; set; }
  68. public string siteDomain_countryCode { get; set; }
  69. public string siteDomain_domainName { get; set; }
  70. public string dataCenter { get; set; }
  71. public string utcDate { get; set; }
  72. public string timeKey { get; set; }
  73. public string offerTitle { get; set; }
  74. public string category { get; set; }
  75. public string price { get; set; }
  76. public string merchant { get; set; }
  77. public string source { get; set; }
  78. public string keywords { get; set; }
  79. public string offerViewId { get; set; }
  80. public string clickId { get; set; }
  81. public string earning { get; set; }
  82. public string searchId { get; set; }
  83. #endregion
  84.  
  85. List<ClicksRootObject> rootObjectList = new List<ClicksRootObject>();
  86. List<string> fileList = new List<string>();
  87.  
  88. public void start()
  89. {
  90. con.Open();
  91.  
  92. readAllFiles();
  93. foreach (string s in fileList)
  94. {
  95. fileToJson(s);
  96. }
  97. jsonToRow();
  98.  
  99. con.Close();
  100. }
  101.  
  102. private void readAllFiles()
  103. {
  104. string folderPath = @"C:\Users\venskusm\Desktop\DMP\Click";
  105. string[] filePaths = Directory.GetFiles(folderPath, "*.json", SearchOption.TopDirectoryOnly);
  106.  
  107. foreach (string s in filePaths)
  108. {
  109. fileList.Add(s);
  110. }
  111. }
  112.  
  113. private void fileToJson(string path)
  114. {
  115. string line;
  116. int index = 0;
  117. // Read the file and display it line by line.
  118. System.IO.StreamReader file = new System.IO.StreamReader(path);
  119. while ((line = file.ReadLine()) != null)
  120. {
  121. var jsonObject = JsonConvert.DeserializeObject<ClicksRootObject>(line);
  122. rootObjectList.Add(jsonObject);
  123. index++;
  124. }
  125.  
  126. file.Close();
  127. }
  128.  
  129. private void jsonToRow()
  130. {
  131.  
  132. foreach (ClicksRootObject r in rootObjectList)//0
  133. {
  134. #region defining the values of RootObjects
  135. try
  136. {
  137. if (r.userInfo == null)
  138. {
  139. //do nothing
  140. }
  141. else
  142. {
  143. ClicksUserInfo clicksUserInfo = r.userInfo;//1
  144. }
  145. }
  146. catch (NullReferenceException ex)
  147. {
  148. Console.WriteLine("Processor Usage" + ex.Message);
  149. }
  150.  
  151. try
  152. {
  153. if (r.userInfo.userId == null)
  154. {
  155. string userId = "";
  156. }
  157. else
  158. {
  159. string userId = r.userInfo.userId;//2
  160. }
  161. }
  162. catch (NullReferenceException ex)
  163. {
  164. Console.WriteLine("Processor Usage" + ex.Message);
  165. }
  166.  
  167. try
  168. {
  169. if (r.userInfo.ip == null)
  170. {
  171. string ip = "";
  172. }
  173. else
  174. {
  175. string ip = r.userInfo.ip;//2
  176. }
  177. }
  178. catch (NullReferenceException ex)
  179. {
  180. Console.WriteLine("Processor Usage" + ex.Message);
  181. }
  182.  
  183. try
  184. {
  185. if(r.userInfo.userAgent != null)
  186. {
  187. ClicksUserAgent userAgent = r.userInfo.userAgent;//2
  188. }
  189. else
  190. {
  191. Console.WriteLine("nulis");
  192. }
  193. }
  194. catch (NullReferenceException ex)
  195. {
  196. Console.WriteLine("Processor Usage" + ex.Message);
  197. }
  198.  
  199.  
  200. try
  201. {
  202. if (r.userInfo.userAgent.deviceType == null)
  203. {
  204. string deviceType = "";
  205. }
  206. else
  207. {
  208. string deviceType = r.userInfo.userAgent.deviceType;//3
  209. }
  210. }
  211. catch (NullReferenceException ex)
  212. {
  213. Console.WriteLine("Processor Usage" + ex.Message);
  214. }
  215.  
  216.  
  217. try
  218. {
  219. if (r.userInfo.userAgent.operatingSystem == null)
  220. {
  221. string operatingSystem = "";
  222. }
  223. else
  224. {
  225. string operatingSystem = r.userInfo.userAgent.operatingSystem;//3
  226. }
  227. }
  228. catch (NullReferenceException ex)
  229. {
  230. Console.WriteLine("Processor Usage" + ex.Message);
  231. }
  232.  
  233. try
  234. {
  235. if (r.userInfo.userAgent.browser == null)
  236. {
  237. string browser = "";
  238. }
  239. else
  240. {
  241. string browser = r.userInfo.userAgent.browser;//3
  242. }
  243. }
  244. catch (NullReferenceException ex)
  245. {
  246. Console.WriteLine("Processor Usage" + ex.Message);
  247. }
  248.  
  249. try
  250. {
  251. if (r.userInfo.userAgent.rawUserAgent == null)
  252. {
  253. string rawUserAgent = "";
  254. }
  255. else
  256. {
  257. string rawUserAgent = r.userInfo.userAgent.rawUserAgent;//3
  258. }
  259. }
  260. catch (NullReferenceException ex)
  261. {
  262. Console.WriteLine("Processor Usage" + ex.Message);
  263. }
  264.  
  265.  
  266. try
  267. {
  268. if (r.siteDomain == null)
  269. {
  270. //do nothing
  271. }
  272. else
  273. {
  274. ClicksSiteDomain siteDomain = r.siteDomain;//1
  275. }
  276. }
  277. catch (NullReferenceException ex)
  278. {
  279. Console.WriteLine("Processor Usage" + ex.Message);
  280. }
  281.  
  282. try
  283. {
  284. if (r.siteDomain.countryCode == null)
  285. {
  286. string countryCode = "";
  287. }
  288. else
  289. {
  290. string countryCode = r.siteDomain.countryCode;//2
  291. }
  292. }
  293. catch (NullReferenceException ex)
  294. {
  295. Console.WriteLine("Processor Usage" + ex.Message);
  296. }
  297.  
  298. try
  299. {
  300. if (r.siteDomain.domainName == null)
  301. {
  302. string domainName = "";
  303. }
  304. else
  305. {
  306. string domainName = r.siteDomain.domainName;//2
  307. }
  308. }
  309. catch (NullReferenceException ex)
  310. {
  311. Console.WriteLine("Processor Usage" + ex.Message);
  312. }
  313.  
  314. try
  315. {
  316. if (r.dataCenter == null)
  317. {
  318. string dataCenter = "";
  319. }
  320. else
  321. {
  322. string dataCenter = r.dataCenter;//1
  323. }
  324. }
  325. catch (NullReferenceException ex)
  326. {
  327. Console.WriteLine("Processor Usage" + ex.Message);
  328. }
  329.  
  330. try
  331. {
  332. if (r.utcDate == null)
  333. {
  334. string utcDate = "";
  335. }
  336. else
  337. {
  338. string utcDate = r.utcDate;//1
  339. }
  340. }
  341.  
  342. catch (NullReferenceException ex)
  343. {
  344. Console.WriteLine("Processor Usage" + ex.Message);
  345. }
  346.  
  347. string date = utcDate;
  348.  
  349.  
  350. try
  351. {
  352. if (r.offerTitle == null)
  353. {
  354. string offerTitle = "";
  355. }
  356. else
  357. {
  358. string offerTitle = r.offerTitle;//1
  359. }
  360. }
  361. catch (NullReferenceException ex)
  362. {
  363. Console.WriteLine("Processor Usage" + ex.Message);
  364. }
  365.  
  366. //category listas
  367.  
  368.  
  369. double price = r.price;//1
  370.  
  371.  
  372. try
  373. {
  374. if (r.merchant == null)
  375. {
  376. string merchant = "";
  377. }
  378. else
  379. {
  380. string merchant = r.merchant;//1
  381. }
  382. }
  383. catch (NullReferenceException ex)
  384. {
  385. Console.WriteLine("Processor Usage" + ex.Message);
  386. }
  387.  
  388. try
  389. {
  390. if (r.source == null)
  391. {
  392. string source = "";
  393. }
  394. else
  395. {
  396. string source = r.source;//1
  397. }
  398. }
  399. catch (NullReferenceException ex)
  400. {
  401. Console.WriteLine("Processor Usage" + ex.Message);
  402. }
  403.  
  404. //keywords listas
  405.  
  406. try
  407. {
  408. if (r.offerViewId == null)
  409. {
  410. string offerViewId = "";
  411. }
  412. else
  413. {
  414. string offerViewId = r.offerViewId;//1
  415. }
  416. }
  417. catch (NullReferenceException ex)
  418. {
  419. Console.WriteLine("Processor Usage" + ex.Message);
  420. }
  421.  
  422. try
  423. {
  424. if (r.clickId == null)
  425. {
  426. string clickId = "";
  427. }
  428. else
  429. {
  430. string clickId = r.clickId;//1
  431. }
  432. }
  433. catch (NullReferenceException ex)
  434. {
  435. Console.WriteLine("Processor Usage" + ex.Message);
  436. }
  437.  
  438.  
  439.  
  440. double earning = r.earning;//1
  441.  
  442. try
  443. {
  444. if (r.searchId == null)
  445. {
  446. string searchId = "";
  447. }
  448. else
  449. {
  450. string searchId = r.searchId;//1
  451. }
  452. }
  453. catch (NullReferenceException ex)
  454. {
  455. Console.WriteLine("Processor Usage" + ex.Message);
  456. }
  457.  
  458. #endregion
  459.  
  460. if (r.category.Count == 0 && r.keywords.Count == 0)
  461. {
  462. #region testavimui
  463. /*
  464. Console.WriteLine(r.userInfo);//1
  465.  
  466. Console.WriteLine(r.userInfo.userId);//2
  467.  
  468. Console.WriteLine(r.userInfo.ip);//2
  469.  
  470. Console.WriteLine(r.userInfo.userAgent);//2
  471.  
  472. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  473.  
  474. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  475.  
  476. Console.WriteLine(r.userInfo.userAgent.browser);//3
  477.  
  478. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  479.  
  480. Console.WriteLine(r.siteDomain);//1
  481.  
  482. Console.WriteLine(r.siteDomain.countryCode);//2
  483.  
  484. Console.WriteLine(r.siteDomain.domainName);//2
  485.  
  486. Console.WriteLine(r.dataCenter);//1
  487.  
  488. Console.WriteLine(r.utcDate);//1
  489.  
  490. Console.WriteLine(r.offerTitle);//1
  491.  
  492. //tuscias category listas
  493.  
  494. Console.WriteLine(r.price);//1
  495.  
  496. Console.WriteLine(r.merchant);//1
  497.  
  498. Console.WriteLine(r.source);//1
  499.  
  500. //tuscias keywords listas
  501.  
  502. Console.WriteLine(r.offerViewId);//1
  503.  
  504. Console.WriteLine(r.clickId);//1
  505.  
  506. Console.WriteLine(r.earning);//1
  507.  
  508. Console.WriteLine(r.searchId);//1*/
  509. #endregion
  510.  
  511. CallStoredProcedure
  512. (
  513. r.userInfo.userId,
  514. r.userInfo.ip,
  515. r.userInfo.userAgent.deviceType,
  516. r.userInfo.userAgent.operatingSystem,
  517. r.userInfo.userAgent.browser,
  518. r.userInfo.userAgent.rawUserAgent,
  519. r.siteDomain.countryCode,
  520. r.siteDomain.domainName,
  521. r.dataCenter,
  522. r.utcDate,
  523. r.timeKey,
  524. r.offerTitle,
  525. "",
  526. r.price,
  527. r.merchant,
  528. r.source,
  529. "",
  530. r.offerTitle,
  531. r.clickId,
  532. r.earning,
  533. r.searchId
  534. );
  535.  
  536. }
  537. else if (r.category.Count != 0 && r.keywords.Count == 0)
  538. {
  539.  
  540. foreach (string s in r.category)
  541. {
  542. #region testavimui
  543. Console.WriteLine(r.userInfo.userId);//2
  544.  
  545. Console.WriteLine(r.userInfo.ip);//2
  546.  
  547. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  548.  
  549. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  550.  
  551. Console.WriteLine(r.userInfo.userAgent.browser);//3
  552.  
  553. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  554.  
  555. Console.WriteLine(r.siteDomain.countryCode);//2
  556.  
  557. Console.WriteLine(r.siteDomain.domainName);//2
  558.  
  559. Console.WriteLine(r.dataCenter);//1
  560.  
  561. Console.WriteLine(r.utcDate);//1
  562.  
  563. Console.WriteLine(r.offerTitle);//1
  564.  
  565. Console.WriteLine(s);//category listas
  566.  
  567. Console.WriteLine(r.price);//1
  568.  
  569. Console.WriteLine(r.merchant);//1
  570.  
  571. Console.WriteLine(r.source);//1
  572.  
  573. //tuscias keywords listas
  574.  
  575. Console.WriteLine(r.offerViewId);//1
  576.  
  577. Console.WriteLine(r.clickId);//1
  578.  
  579. Console.WriteLine(r.earning);//1
  580.  
  581. Console.WriteLine(r.searchId);//1
  582. #endregion
  583. CallStoredProcedure
  584. (
  585. r.userInfo.userId,
  586. r.userInfo.ip,
  587. r.userInfo.userAgent.deviceType,
  588. r.userInfo.userAgent.operatingSystem,
  589. r.userInfo.userAgent.browser,
  590. r.userInfo.userAgent.rawUserAgent,
  591. r.siteDomain.countryCode,
  592. r.siteDomain.domainName,
  593. r.dataCenter,
  594. r.utcDate,
  595. r.timeKey,
  596. r.offerTitle,
  597. s,
  598. r.price,
  599. r.merchant,
  600. r.source,
  601. "",
  602. r.offerTitle,
  603. r.clickId,
  604. r.earning,
  605. r.searchId
  606. );
  607.  
  608. }
  609.  
  610. }
  611. else if (r.category.Count == 0 && r.keywords.Count != 0)
  612. {
  613.  
  614. foreach (string s in r.keywords)
  615. {
  616. #region testavimui
  617. /*Console.WriteLine(r.userInfo.userId);//2
  618.  
  619. Console.WriteLine(r.userInfo.ip);//2
  620.  
  621. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  622.  
  623. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  624.  
  625. Console.WriteLine(r.userInfo.userAgent.browser);//3
  626.  
  627. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  628.  
  629. Console.WriteLine(r.siteDomain.countryCode);//2
  630.  
  631. Console.WriteLine(r.siteDomain.domainName);//2
  632.  
  633. Console.WriteLine(r.dataCenter);//1
  634.  
  635. Console.WriteLine(r.utcDate);//1
  636.  
  637. Console.WriteLine(r.offerTitle);//1
  638.  
  639. //tuscias category listas
  640.  
  641. Console.WriteLine(r.price);//1
  642.  
  643. Console.WriteLine(r.merchant);//1
  644.  
  645. Console.WriteLine(r.source);//1
  646.  
  647. Console.WriteLine(s);//tuscias keywords listas
  648.  
  649. Console.WriteLine(r.offerViewId);//1
  650.  
  651. Console.WriteLine(r.clickId);//1
  652.  
  653. Console.WriteLine(r.earning);//1
  654.  
  655. Console.WriteLine(r.searchId);//1*/
  656. #endregion
  657. CallStoredProcedure
  658. (
  659. r.userInfo.userId,
  660. r.userInfo.ip,
  661. r.userInfo.userAgent.deviceType,
  662. r.userInfo.userAgent.operatingSystem,
  663. r.userInfo.userAgent.browser,
  664. r.userInfo.userAgent.rawUserAgent,
  665. r.siteDomain.countryCode,
  666. r.siteDomain.domainName,
  667. r.dataCenter,
  668. r.utcDate,
  669. r.timeKey,
  670. r.offerTitle,
  671. "",
  672. r.price,
  673. r.merchant,
  674. r.source,
  675. s,
  676. r.offerTitle,
  677. r.clickId,
  678. r.earning,
  679. r.searchId
  680. );
  681.  
  682. }
  683.  
  684. }
  685. else if (r.category.Count != 0 && r.keywords.Count != 0)//3 ir 2
  686. {
  687. int maxIndex = 0;
  688. int index = 0;
  689. if (r.category.Count > r.keywords.Count)
  690. {
  691. maxIndex = r.category.Count;
  692. }
  693. else
  694. {
  695. maxIndex = r.keywords.Count;
  696. }
  697.  
  698.  
  699. while (index < maxIndex)//0<3
  700. {
  701. if (r.category.Count > index && r.keywords.Count > index)//2>0 && 3>0, 2>1 && 3>1
  702. {
  703. #region testavimui
  704. /*Console.WriteLine(r.userInfo.userId);//2
  705.  
  706. Console.WriteLine(r.userInfo.ip);//2
  707.  
  708. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  709.  
  710. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  711.  
  712. Console.WriteLine(r.userInfo.userAgent.browser);//3
  713.  
  714. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  715.  
  716. Console.WriteLine(r.siteDomain.countryCode);//2
  717.  
  718. Console.WriteLine(r.siteDomain.domainName);//2
  719.  
  720. Console.WriteLine(r.dataCenter);//1
  721.  
  722. Console.WriteLine(r.utcDate);//1
  723.  
  724. Console.WriteLine(r.offerTitle);//1
  725.  
  726. Console.WriteLine(r.category[index]);//:)
  727.  
  728. Console.WriteLine(r.price);//1
  729.  
  730. Console.WriteLine(r.merchant);//1
  731.  
  732. Console.WriteLine(r.source);//1
  733.  
  734. Console.WriteLine(r.keywords[index]);//:)
  735.  
  736. Console.WriteLine(r.offerViewId);//1
  737.  
  738. Console.WriteLine(r.clickId);//1
  739.  
  740. Console.WriteLine(r.earning);//1
  741.  
  742. Console.WriteLine(r.searchId);//1*/
  743. #endregion
  744. CallStoredProcedure
  745. (
  746. r.userInfo.userId,
  747. r.userInfo.ip,
  748. r.userInfo.userAgent.deviceType,
  749. r.userInfo.userAgent.operatingSystem,
  750. r.userInfo.userAgent.browser,
  751. r.userInfo.userAgent.rawUserAgent,
  752. r.siteDomain.countryCode,
  753. r.siteDomain.domainName,
  754. r.dataCenter,
  755. r.utcDate,
  756. r.timeKey,
  757. r.offerTitle,
  758. r.category[index],
  759. r.price,
  760. r.merchant,
  761. r.source,
  762. Convert.ToString(r.keywords[index]),
  763. r.offerTitle,
  764. r.clickId,
  765. r.earning,
  766. r.searchId
  767. );
  768. }
  769. else if (r.category.Count > index)
  770. {
  771. #region testavimui
  772. /*Console.WriteLine(r.userInfo.userId);//2
  773.  
  774. Console.WriteLine(r.userInfo.ip);//2
  775.  
  776. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  777.  
  778. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  779.  
  780. Console.WriteLine(r.userInfo.userAgent.browser);//3
  781.  
  782. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  783.  
  784. Console.WriteLine(r.siteDomain.countryCode);//2
  785.  
  786. Console.WriteLine(r.siteDomain.domainName);//2
  787.  
  788. Console.WriteLine(r.dataCenter);//1
  789.  
  790. Console.WriteLine(r.utcDate);//1
  791.  
  792. Console.WriteLine(r.offerTitle);//1
  793.  
  794. Console.WriteLine(r.category[index]);//:)
  795.  
  796. Console.WriteLine(r.price);//1
  797.  
  798. Console.WriteLine(r.merchant);//1
  799.  
  800. Console.WriteLine(r.source);//1
  801.  
  802. //nebeliko keywordu
  803.  
  804. Console.WriteLine(r.offerViewId);//1
  805.  
  806. Console.WriteLine(r.clickId);//1
  807.  
  808. Console.WriteLine(r.earning);//1
  809.  
  810. Console.WriteLine(r.searchId);//1*/
  811. #endregion
  812. CallStoredProcedure
  813. (
  814. r.userInfo.userId,
  815. r.userInfo.ip,
  816. r.userInfo.userAgent.deviceType,
  817. r.userInfo.userAgent.operatingSystem,
  818. r.userInfo.userAgent.browser,
  819. r.userInfo.userAgent.rawUserAgent,
  820. r.siteDomain.countryCode,
  821. r.siteDomain.domainName,
  822. r.dataCenter,
  823. r.utcDate,
  824. r.timeKey,
  825. r.offerTitle,
  826. r.category[index],
  827. r.price,
  828. r.merchant,
  829. r.source,
  830. "",
  831. r.offerTitle,
  832. r.clickId,
  833. r.earning,
  834. r.searchId
  835. );
  836. }
  837. else if (r.keywords.Count > index)
  838. {
  839. #region testavimui
  840. /*Console.WriteLine(r.userInfo.userId);//2
  841.  
  842. Console.WriteLine(r.userInfo.ip);//2
  843.  
  844. Console.WriteLine(r.userInfo.userAgent.deviceType);//3
  845.  
  846. Console.WriteLine(r.userInfo.userAgent.operatingSystem);//3
  847.  
  848. Console.WriteLine(r.userInfo.userAgent.browser);//3
  849.  
  850. Console.WriteLine(r.userInfo.userAgent.rawUserAgent);//3
  851.  
  852. Console.WriteLine(r.siteDomain.countryCode);//2
  853.  
  854. Console.WriteLine(r.siteDomain.domainName);//2
  855.  
  856. Console.WriteLine(r.dataCenter);//1
  857.  
  858. Console.WriteLine(r.utcDate);//1
  859.  
  860. Console.WriteLine(r.offerTitle);//1
  861.  
  862. //nebeliko categoriju
  863.  
  864. Console.WriteLine(r.price);//1
  865.  
  866. Console.WriteLine(r.merchant);//1
  867.  
  868. Console.WriteLine(r.source);//1
  869.  
  870. Console.WriteLine(r.keywords[index]);//:)
  871.  
  872. Console.WriteLine(r.offerViewId);//1
  873.  
  874. Console.WriteLine(r.clickId);//1
  875.  
  876. Console.WriteLine(r.earning);//1
  877.  
  878. Console.WriteLine(r.searchId);//1*/
  879. #endregion
  880. CallStoredProcedure
  881. (
  882. r.userInfo.userId,
  883. r.userInfo.ip,
  884. r.userInfo.userAgent.deviceType,
  885. r.userInfo.userAgent.operatingSystem,
  886. r.userInfo.userAgent.browser,
  887. r.userInfo.userAgent.rawUserAgent,
  888. r.siteDomain.countryCode,
  889. r.siteDomain.domainName,
  890. r.dataCenter,
  891. r.utcDate,
  892. r.timeKey,
  893. r.offerTitle,
  894. "",
  895. r.price,
  896. r.merchant,
  897. r.source,
  898. Convert.ToString(r.keywords[index]),
  899. r.offerTitle,
  900. r.clickId,
  901. r.earning,
  902. r.searchId
  903. );
  904.  
  905. }
  906. index++;
  907. }
  908. }
  909. }
  910. }
  911.  
  912. private void CallStoredProcedure
  913. (
  914. string userInfo_userID,
  915. string userInfo_ip,
  916. string userInfo_userAgent_deviceType,
  917. string userInfo_userAgent_operatingSystem,
  918. string userInfo_userAgent_browser,
  919. string userInfo_userAgent_rawUserAgent,
  920. string siteDomain_countryCode,
  921. string siteDomain_domainName,
  922. string dataCenter,
  923. string utcDate,
  924. string date,
  925. string offerTitle,
  926. string category,
  927. double price,
  928. string merchant,
  929. string source,
  930. string keywords,
  931. string offerViewId,
  932. string clickId,
  933. double earning,
  934. string searchId
  935. )
  936. {
  937. SqlCommand command = new SqlCommand("StoredProcedureClicks", con);
  938. command.CommandType = System.Data.CommandType.StoredProcedure;
  939. command.Parameters.AddWithValue("@userInfo_userID", userInfo_userID ?? "");
  940. command.Parameters.AddWithValue("@userInfo_ip", @userInfo_ip ?? "");
  941. command.Parameters.AddWithValue("@userInfo_userAgent_deviceType", userInfo_userAgent_deviceType ?? "");
  942. command.Parameters.AddWithValue("@userInfo_userAgent_operatingSystem", userInfo_userAgent_operatingSystem ?? "");
  943. command.Parameters.AddWithValue("@userInfo_userAgent_browser", userInfo_userAgent_browser ?? "");
  944. command.Parameters.AddWithValue("@userInfo_userAgent_rawUserAgent", userInfo_userAgent_rawUserAgent ?? "");
  945. command.Parameters.AddWithValue("@siteDomain_countryCode", siteDomain_countryCode ?? "");
  946. command.Parameters.AddWithValue("@siteDomain_domainName", siteDomain_domainName ?? "");
  947. command.Parameters.AddWithValue("@dataCenter", dataCenter ?? "");
  948. command.Parameters.AddWithValue("@utcDate", utcDate ?? "");
  949. command.Parameters.AddWithValue("@timeKey", timeKey ?? "");
  950. command.Parameters.AddWithValue("@offerTitle", offerTitle ?? "");
  951. command.Parameters.AddWithValue("@category", category ?? "");
  952. command.Parameters.AddWithValue("@price", price);
  953. command.Parameters.AddWithValue("@merchant", merchant ?? "");
  954. command.Parameters.AddWithValue("@source", source ?? "");
  955. command.Parameters.AddWithValue("@keywords", keywords ?? "");
  956. command.Parameters.AddWithValue("@offerViewId", offerViewId ?? "");
  957. command.Parameters.AddWithValue("@clickId", clickId ?? "");
  958. command.Parameters.AddWithValue("@earning", earning);
  959. command.Parameters.AddWithValue("@searchId", searchId ?? "");
  960. command.ExecuteNonQuery();
  961. }
  962. }
  963. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement