/// <summary> /// Adds an context object to the collection /// </summary> /// <param name="emp"></param> public void Add(CTIContext cti) { if (this.List.Contains(cti)) { return; } this.List.Add(cti); }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is CTIContext) { // Cast the value to an context type CTIContext cti = (CTIContext)value; return(cti.Context); } return(base.ConvertTo(context, culture, value, destType)); }
public object Clone() { //First we create an instance of this specific type. CTIContext newObject = new CTIContext(); newObject.Context = this.context; newObject.DisplayName = this.displayname; newObject.Application = this.application; newObject.Parameters = this.parameters; newObject.InternalBrowser = this.use_internal_browser; newObject.Enabled = this.enabled; newObject.CatchAll = this.catch_all; return(newObject); }
void ExecCTIApplication(CTIContext ctx, AsteriskCall call) { if ((!ctx.InternalBrowser) & (!File.Exists(ctx.Application))) { GenericStringAction scf = new GenericStringAction(this.MessageBoxShow); scf.Invoke(string.Format("{0} {1}", this.localizator["0015"], ctx.DisplayName)); return; } string parameters = ctx.Parameters; if (parameters != null) { parameters = parameters.Replace("{CALLERID}", call.CallerIDNum); parameters = parameters.Replace("{CALLERNAME}", call.CallerIDName); parameters = parameters.Replace("{CONTEXT}", call.Context); parameters = parameters.Replace("{CALLDATA}", call.AppData); parameters = parameters.Replace("{CHANNEL}", call.Channel); parameters = parameters.Replace("{UNIQUEID}", call.Uniqueid); } if (ctx.InternalBrowser) { Thread t = new Thread(this.OpenBrowserForm); t.SetApartmentState(ApartmentState.STA); t.Start(parameters); //GenericStringAction scf = new GenericStringAction(this.OpenBrowserForm); //scf.Invoke(parameters); } else { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.Arguments = parameters; proc.StartInfo.FileName = ctx.Application; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; proc.Start(); } }
/// <summary> /// Removes an context object from the collection /// </summary> /// <param name="emp"></param> public void Remove(CTIContext cti) { this.List.Remove(cti); }
public object Clone() { //First we create an instance of this specific type. CTIContext newObject = new CTIContext(); newObject.Context = this.context; newObject.DisplayName = this.displayname; newObject.Application = this.application; newObject.Parameters= this.parameters; newObject.InternalBrowser = this.use_internal_browser; newObject.Enabled = this.enabled; newObject.CatchAll = this.catch_all; return newObject; }
void parser_Parsed(int message, string data) { if (message == 0) { #region Asterisk Events string eventId = ""; string state = ""; AsteriskCall call = AsteriskCall.CallFromXml(data, out eventId); if (call != null) { switch (eventId) { case "Newstate": state = call.State; if (state != null) { switch (state) { case "Up": state = this.localizator["0101"]; // "Off Hook"; break; case "Ringing": state = this.localizator["0102"]; // "Ringing"; break; case "Down": state = this.localizator["0103"]; //"On Hook"; break; } } else { state = ""; } Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)lblLineState, "Text", state }); break; case "Newcallerid": if (this.optset.TriggerCallerId) { // Check matching contextes before popup GenericStringAction scf = new GenericStringAction(this.OpenCallerIdForm); scf.Invoke(call.CallerIDNum); return; } break; case "Link": EnableCallActions(false); CTIContext tostart = null; foreach (CTIContext ctx in this.optset.CTIContextes) { if (ctx.Context.Equals(call.Context)) { if (ctx.Enabled) { tostart = ctx; break; } } } // Check for a CatchAll if (tostart == null) { foreach (CTIContext ctx in this.optset.CTIContextes) { if ((ctx.CatchAll) & (ctx.Enabled)) { tostart = ctx; break; } } } state = this.localizator["0104"]; // "Connected" Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)lblLineState, "Text", state }); if (tostart != null) { ExecCTIApplication(tostart, call); } break; case "Hangup": state = this.localizator["0105"]; // "Hangup" Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)lblLineState, "Text", state }); EnableCallActions(true); break; } } #endregion } else { #region Main Switch switch (message) { case 100: switch (this.protocolStatus) { case PROTOCOL_STATES.STATUS_UNKNOWN: this.protocolStatus = PROTOCOL_STATES.SENDED_USERNAME; this.socketmanager.SendData("USER " + this.txtUsername.Text); break; case PROTOCOL_STATES.SENDED_USERNAME: this.protocolStatus = PROTOCOL_STATES.SENDED_PASSWORD; this.socketmanager.SendData("PASS " + ProtocolParser.MD5(this.txtPassword.Text)); break; default: break; } break; case 101: if (this.socketmanager.IsConnected) { this.socketmanager.SendData("QUIT"); this.socketmanager.Disconnect(); MessageBox.Show(this.localizator["0014"]); // "Invalid credentials" } break; case 102: switch (this.protocolStatus) { case PROTOCOL_STATES.SENDED_PASSWORD: string stopString = this.localizator["0009"]; this.protocolStatus = PROTOCOL_STATES.LOGGED_IN; if (this.InvokeRequired) { Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)btnStartStop, "Text", stopString }); Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)btnStartStop, "Enabled", true }); Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)btnConfig, "Enabled", false }); Invoke(new SetPropertyDelegate(SetProperty), new object[] { (object)lblLineState, "Text", "" }); if (this.optset.MinimizeOnStart) { Invoke(new SetMethodDelegate(SetMethod), new object[] { (object)this, "DoFormHide", null }); } } else { this.btnStartStop.Text = stopString; this.btnStartStop.Enabled = true; this.btnConfig.Enabled = false; this.DoFormHide(); } break; } break; } #endregion } }
void ExecCTIApplication(CTIContext ctx, AsteriskCall call) { if ( (!ctx.InternalBrowser) & (!File.Exists(ctx.Application)) ) { GenericStringAction scf = new GenericStringAction(this.MessageBoxShow); scf.Invoke(string.Format("{0} {1}", this.localizator["0015"], ctx.DisplayName)); return; } string parameters = ctx.Parameters; if (parameters != null) { parameters = parameters.Replace("{CALLERID}", call.CallerIDNum); parameters = parameters.Replace("{CALLERNAME}", call.CallerIDName); parameters = parameters.Replace("{CONTEXT}", call.Context); parameters = parameters.Replace("{CALLDATA}", call.AppData); parameters = parameters.Replace("{CHANNEL}", call.Channel); parameters = parameters.Replace("{UNIQUEID}", call.Uniqueid); } if (ctx.InternalBrowser) { Thread t = new Thread(this.OpenBrowserForm); t.SetApartmentState(ApartmentState.STA); t.Start(parameters); //GenericStringAction scf = new GenericStringAction(this.OpenBrowserForm); //scf.Invoke(parameters); } else { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.Arguments = parameters; proc.StartInfo.FileName = ctx.Application; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; proc.Start(); } }