Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MyPhonePlugins;
- using System;
- using System.IO;
- [MyPhonePlugins.CRMPluginLoader]
- public class MyCRMPlugin
- {
- private static MyCRMPlugin instance = null;
- private MyPhonePlugins.IMyPhoneCallHandler callHandler = null;
- [MyPhonePlugins.CRMPluginInitializer]
- public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
- {
- try
- {
- System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "Loader");
- instance = new MyCRMPlugin(callHandler);
- }
- catch (Exception ex)
- {
- string filePath = @"C:/Temp/Error.txt";
- using (StreamWriter writer = new StreamWriter(filePath, true))
- {
- writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
- }
- }
- }
- private MyCRMPlugin(MyPhonePlugins.IMyPhoneCallHandler callHandler)
- {
- try
- {
- this.callHandler = callHandler;
- callHandler.OnCallStatusChanged += new MyPhonePlugins.CallInfoHandler(callHandler_OnCallStatusChanged);
- callHandler.OnMyPhoneStatusChanged += new MyPhonePlugins.MyPhoneStatusHandler(callHandler_OnMyPhoneStatusChanged);
- }
- catch (Exception ex)
- {
- string filePath = @"C:/Temp/Error.txt";
- using (StreamWriter writer = new StreamWriter(filePath, true))
- {
- writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
- }
- }
- }
- private void callHandler_OnCallStatusChanged(object sender, MyPhonePlugins.CallStatus callInfo)
- {
- try
- {
- if (callInfo.State == CallState.Ended)
- {
- string filePath = @"C:/Temp/Status.txt";
- using (StreamWriter writer = new StreamWriter(filePath, true))
- {
- writer.WriteLine(callInfo.State);
- }
- }
- }
- catch (Exception ex)
- {
- string filePath = @"C:/Temp/Error.txt";
- using (StreamWriter writer = new StreamWriter(filePath, true))
- {
- writer.WriteLine(DateTime.Now + Environment.NewLine + "Message: " + ex.ToString() + Environment.NewLine + "Stack Trace: " + ex.StackTrace);
- }
- }
- }
- private void callHandler_OnMyPhoneStatusChanged(object sender, MyPhonePlugins.MyPhoneStatus status)
- {
- System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "callHandler_OnMyPhoneStatusChanged");
- }
- public MyPhonePlugins.CallStatus MakeCall(string destination)
- {
- System.IO.File.WriteAllText("C:/Temp/phonestatus.txt", "MakeCall");
- return callHandler.MakeCall(destination);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement