Advertisement
Guest User

Untitled

a guest
Aug 12th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. using MyPhonePlugins;
  2. using System;
  3. using System.IO;
  4.  
  5. [MyPhonePlugins.CRMPluginLoader]
  6. public class MyCRMPlugin
  7. {
  8. private static MyCRMPlugin instance = null;
  9. private MyPhonePlugins.IMyPhoneCallHandler callHandler = null;
  10.  
  11. [MyPhonePlugins.CRMPluginInitializer]
  12. public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
  13. {
  14. try
  15. {
  16. System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "Loader");
  17. instance = new MyCRMPlugin(callHandler);
  18. }
  19. catch (Exception ex)
  20. {
  21. string filePath = @"C:/Temp/Error.txt";
  22.  
  23. using (StreamWriter writer = new StreamWriter(filePath, true))
  24. {
  25. writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
  26. }
  27. }
  28. }
  29.  
  30. private MyCRMPlugin(MyPhonePlugins.IMyPhoneCallHandler callHandler)
  31. {
  32. try
  33. {
  34. this.callHandler = callHandler;
  35. callHandler.OnCallStatusChanged += new MyPhonePlugins.CallInfoHandler(callHandler_OnCallStatusChanged);
  36.  
  37. callHandler.OnMyPhoneStatusChanged += new MyPhonePlugins.MyPhoneStatusHandler(callHandler_OnMyPhoneStatusChanged);
  38. }
  39. catch (Exception ex)
  40. {
  41. string filePath = @"C:/Temp/Error.txt";
  42.  
  43. using (StreamWriter writer = new StreamWriter(filePath, true))
  44. {
  45. writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
  46. }
  47. }
  48. }
  49.  
  50. private void callHandler_OnCallStatusChanged(object sender, MyPhonePlugins.CallStatus callInfo)
  51. {
  52. try
  53. {
  54. if (callInfo.State == CallState.Ended)
  55. {
  56. string filePath = @"C:/Temp/Status.txt";
  57.  
  58. using (StreamWriter writer = new StreamWriter(filePath, true))
  59. {
  60. writer.WriteLine(callInfo.State);
  61. }
  62. }
  63. }
  64. catch (Exception ex)
  65. {
  66. string filePath = @"C:/Temp/Error.txt";
  67.  
  68. using (StreamWriter writer = new StreamWriter(filePath, true))
  69. {
  70. writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
  71. }
  72. }
  73. }
  74.  
  75. private void callHandler_OnMyPhoneStatusChanged(object sender, MyPhonePlugins.MyPhoneStatus status)
  76. {
  77. System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "callHandler_OnMyPhoneStatusChanged");
  78. }
  79.  
  80. public MyPhonePlugins.CallStatus MakeCall(string destination)
  81. {
  82. System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "MakeCall");
  83. return callHandler.MakeCall(destination);
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement