SycnJavaUsersService.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.PxcModels;
  5. using Library;
  6. using LitJson;
  7. using System.Threading;
  8. namespace MySystem
  9. {
  10. public class SycnJavaUsersService
  11. {
  12. public readonly static SycnJavaUsersService Instance = new SycnJavaUsersService();
  13. private SycnJavaUsersService()
  14. { }
  15. public bool Add(string content)
  16. {
  17. try
  18. {
  19. JsonData jsonObj = JsonMapper.ToObject(content);
  20. WebCMSEntities db = new WebCMSEntities();
  21. db.Users.Add(new Users()
  22. {
  23. Id = int.Parse(jsonObj["id"].ToString()),
  24. ParentUserId = int.Parse(jsonObj["pid"].ToString()),
  25. ParentNav = jsonObj["pidPath"].ToString(),
  26. CreateDate = DateTime.Parse(jsonObj["create_time"].ToString()),
  27. MakerCode = jsonObj["userCode"].ToString(),
  28. Mobile = jsonObj["phone"].ToString(),
  29. UserLevel = int.Parse(jsonObj["userLevel"].ToString()),
  30. });
  31. db.SaveChanges();
  32. db.Dispose();
  33. return true;
  34. }
  35. catch (Exception ex)
  36. {
  37. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "同步创客信息异常");
  38. return false;
  39. }
  40. }
  41. }
  42. }