Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. using cn.bmob.api;
  2. using cn.bmob.io;
  3. using cn.bmob.json;
  4. using cn.bmob.tools;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12.  
  13. namespace BmobTest.answers
  14. {
  15. class Answers : BmobTable
  16. {
  17. public BmobInt index { get; set; }
  18. public string answer { get; set; }
  19.  
  20. public override void readFields(BmobInput input)
  21. {
  22. base.readFields(input);
  23.  
  24. this.index = input.getInt("index");
  25. this.answer = input.getString("answer");
  26.  
  27. }
  28.  
  29. public override void write(BmobOutput output, Boolean all)
  30. {
  31. base.write(output, all);
  32.  
  33. output.Put("index", this.index);
  34. output.Put("answer", this.answer);
  35. }
  36.  
  37. public static BmobWindows server()
  38. {
  39. var Bmob = new BmobWindows();
  40. Bmob.initialize("5c4db3dcd0d2c259a82e3cd90b9a1921", "1bc16364ee4620d8b25c701dd16a3958");
  41. BmobDebug.Register(msg => { Debug.WriteLine(msg); });
  42. BmobDebug.level = BmobDebug.Level.TRACE;
  43.  
  44. return Bmob;
  45. }
  46.  
  47. public static void load(String path)
  48. {
  49. var Bmob = server();
  50. StreamReader reader = null;
  51. try
  52. {
  53. reader = new StreamReader(path);
  54.  
  55. int count = 0;
  56. string line = null;
  57. while ((line = reader.ReadLine()) != null)
  58. {
  59. line = line.Trim();
  60. if (line.Length == 0) {
  61. continue;
  62. }
  63.  
  64. count++;
  65.  
  66. var data = new Answers();
  67. data.index = count;
  68. data.answer = line;
  69.  
  70. var future = Bmob.CreateTaskAsync("answers", data);
  71. var resp = future.Result;
  72.  
  73. Console.WriteLine();
  74. Console.WriteLine("\n返回结果: " + JsonAdapter.JSON.ToDebugJsonString(resp));
  75. }
  76.  
  77. }
  78. finally
  79. {
  80. if (reader != null)
  81. {
  82. reader.Close();
  83. }
  84. }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement