public void Run(params string[] args) { var emaillookup = PhoneSystem.Root.CreateLookup(() => PhoneSystem.Root.GetExtensions(), y => y.EmailAddress, "DN"); PhoneSystem ps = PhoneSystem.Root; while (!Program.Stop) { Console.WriteLine("s <string> - search for email"); Console.WriteLine("keys - print all keys with counter of the objects"); Console.Write("Enter cammand:"); var command = Console.ReadLine(); if (command.StartsWith("s ")) { foreach (var k in emaillookup.Lookup(string.Join(" ", command.Split(' ').Skip(1)))) { Console.WriteLine($"{k}"); } } else if (command == "keys") { foreach (var k in emaillookup.Keys) { Console.WriteLine($"'{k}'={emaillookup.Lookup(k).Count()}"); } } } }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; String filter = null; if (args.Length > 1) { filter = args[1]; } MyListener a = new MyListener(filter); ps.Updated += new NotificationEventHandler(a.ps_Updated); ps.Inserted += new NotificationEventHandler(a.ps_Inserted); ps.Deleted += new NotificationEventHandler(a.ps_Deleted); Statistics[] myStat; myStat = ps.InitializeStatistics(args[1]); foreach (Statistics s in myStat) { Console.WriteLine(s.ToString()); } while (true) { Thread.Sleep(5000); } }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; Parameter p = ps.GetParameterByName("DIALCODEBTHELPER"); if (p == null) { ps.GetTenants()[0].CreateParkExtension(args[1]).Save(); p = ps.CreateParameter(); p.Name = "DIALCODEBTHELPER"; p.Value = args[1]; p.Type = ParameterType.String; p.Description = "Dial code for Blind transfer helper"; p.Save(); } else { ParkExtension pe = ps.GetDNByNumber(p.Value) as ParkExtension; if (pe == null) { ps.GetTenants()[0].CreateParkExtension(args[1]).Save(); p.Value = args[1]; p.Save(); } else { pe.Number = args[1]; pe.Save(); p.Value = args[1]; p.Save(); } } }
public void GetPhoneSystemAssociations_NullConnectionServer_Failure() { List <PhoneSystemAssociation> oList; var res = PhoneSystem.GetPhoneSystemAssociations(null, "objectid", out oList); Assert.IsFalse(res.Success, "Static call to GetPhoneSystemAssociations with null ConnectionServerRest did not fail"); }
public void PropertyGetFetch_CallLoopExtensionDetect() { PhoneSystem oPhoneSystem = new PhoneSystem(); const bool expectedValue = true; oPhoneSystem.CallLoopExtensionDetect = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("CallLoopExtensionDetect", expectedValue), "CallLoopExtensionDetect value get fetch failed"); }
public static string show(string args1) { PhoneSystem ps = PhoneSystem.Root; var extension = ps.GetDNByNumber(args1) as Extension; Logger.WriteLine($" CURRENT_STATUS={extension.CurrentProfile?.Name}"); return($" CURRENT_STATUS={extension.CurrentProfile?.Name}"); }
public void PropertyGetFetch_CallLoopGuardTimeMs() { PhoneSystem oPhoneSystem = new PhoneSystem(); const int expectedValue = 321; oPhoneSystem.CallLoopGuardTimeMs = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("CallLoopGuardTimeMs", expectedValue), "CallLoopGuardTimeMs value get fetch failed"); }
public void PropertyGetFetch_DefaultTrapSwitch() { PhoneSystem oPhoneSystem = new PhoneSystem(); const bool expectedValue = false; oPhoneSystem.DefaultTrapSwitch = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("DefaultTrapSwitch", expectedValue), "DefaultTrapSwitch value get fetch failed"); }
public void PropertyGetFetch_MwiForceOff() { PhoneSystem oPhoneSystem = new PhoneSystem(); const bool expectedValue = false; oPhoneSystem.MwiForceOff = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("MwiForceOff", expectedValue), "MwiForceOff value get fetch failed"); }
public void GetPhoneSystem_InvalidObjectId_Failure() { PhoneSystem oPhoneSystem; var res = PhoneSystem.GetPhoneSystem(out oPhoneSystem, _connectionServer, "bogus"); Assert.IsFalse(res.Success, "Static call to GetPhoneSystem with invalid ObjectId did not fail"); }
public void GetPhoneSystemAssociations_InvalidObjectId_Success() { List <PhoneSystemAssociation> oList; var res = PhoneSystem.GetPhoneSystemAssociations(_connectionServer, "objectid", out oList); Assert.IsTrue(res.Success, "Fetching phone system associations with invalid objectid should not fail:" + res); Assert.IsTrue(oList.Count == 0, "Static call to GetPhoneSystemAssociations with invalid ObjectId did not return empty list"); }
public void PropertyGetFetch_RestrictDialEndTimef() { PhoneSystem oPhoneSystem = new PhoneSystem(); const int expectedValue = 345; oPhoneSystem.RestrictDialEndTime = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("RestrictDialEndTime", expectedValue), "RestrictDialEndTime value get fetch failed"); }
public void PropertyGetFetch_CallLoopDTMF() { PhoneSystem oPhoneSystem = new PhoneSystem(); const string expectedValue = "Test string"; oPhoneSystem.CallLoopDTMF = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("CallLoopDTMF", expectedValue), "CallLoopDTMF value get fetch failed"); }
public void PropertyGetFetch_DisplayName() { PhoneSystem oPhoneSystem = new PhoneSystem(); const string expectedValue = "Test string"; oPhoneSystem.DisplayName = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("DisplayName", expectedValue), "DisplayName value get fetch failed"); }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; Extension ex = ps.GetDNByNumber("100") as Extension; FwdProfile[] fps = ex.FwdProfiles; if (fps.Length > 0) { ex.CurrentProfile = fps[0]; ex.Save(); } ExtensionRule er = ex.CreateForwardingRule(); er.Conditions.Condition = ps.GetRuleConditions()[0]; er.Conditions.Hours = ps.GetRuleHourTypes()[0]; er.Conditions.CallType = ps.GetRuleCallTypes()[0]; er.Data = "1234567"; er.Forward.To = DestinationType.External; er.Forward.External = "987654321"; HoursRange hr = er.CreateHoursRange(); System.Collections.Generic.List <HoursRange> arr = new System.Collections.Generic.List <HoursRange>(); HoursRange r = er.CreateHoursRange(); r.DayOfWeek = System.DayOfWeek.Wednesday; r.StartTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0); r.EndTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0); arr.Add(r); r = er.CreateHoursRange(); r.DayOfWeek = System.DayOfWeek.Thursday; r.StartTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0); r.EndTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0); arr.Add(r); er.HoursRanges = arr.ToArray(); System.Collections.Generic.List <ExtensionRule> arrR = new System.Collections.Generic.List <ExtensionRule>(); arrR.Add(er); ExtensionRule er2 = ex.CreateForwardingRule(); er2.Conditions.Condition = ps.GetRuleConditions()[1]; er2.Conditions.Hours = ps.GetRuleHourTypes()[1]; er2.Conditions.CallType = ps.GetRuleCallTypes()[1]; er2.Data = "1234567"; er2.Forward.To = DestinationType.External; er2.Forward.External = "1234567890"; arrR.Add(er2); FwdProfile fp = ex.CreateFwdProfile("test_forward_profile1"); fp.ForwardingRules = arrR.ToArray(); fp.Save(); FwdProfile fp1 = ex.CreateFwdProfile("test_forward_profile2"); arrR.Clear(); arrR.Add(fp.ForwardingRules[0]); fp1.ForwardingRules = arrR.ToArray(); fp1.Save(); ex.Save(); }
public override int GetHashCode() { int hash = 1; if (PhoneName.Length != 0) { hash ^= PhoneName.GetHashCode(); } if (PhoneSystem.Length != 0) { hash ^= PhoneSystem.GetHashCode(); } if (PhoneModel.Length != 0) { hash ^= PhoneModel.GetHashCode(); } if (PhoneProducter.Length != 0) { hash ^= PhoneProducter.GetHashCode(); } if (AppVersion.Length != 0) { hash ^= AppVersion.GetHashCode(); } if (PhoneMac.Length != 0) { hash ^= PhoneMac.GetHashCode(); } if (PhoneImei.Length != 0) { hash ^= PhoneImei.GetHashCode(); } if (PhoneIp.Length != 0) { hash ^= PhoneIp.GetHashCode(); } if (UserId.Length != 0) { hash ^= UserId.GetHashCode(); } if (PlaceCode.Length != 0) { hash ^= PlaceCode.GetHashCode(); } if (AppCode.Length != 0) { hash ^= AppCode.GetHashCode(); } if (UserType.Length != 0) { hash ^= UserType.GetHashCode(); } if (Timestamps != 0L) { hash ^= Timestamps.GetHashCode(); } return(hash); }
public void PhoneSystem_Test() { _errorString = ""; List <PhoneSystem> oPhoneSystems; var res = PhoneSystem.GetPhoneSystems(_connectionServer, out oPhoneSystems, 1, 2); Assert.IsTrue(res.Success & oPhoneSystems.Count > 0, "Failed to fetch phone systems:" + res); Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString); }
public void Update_EmptyClass_Failure() { PhoneSystem oPhoneSystem = new PhoneSystem(_mockServer); oPhoneSystem.DisplayName = "Updated display name"; var res = oPhoneSystem.Update(); Assert.IsFalse(res.Success, "Calling Update on empty class should fail"); }
public void GetPhoneSystemAssociations_EmptyClass_Failure() { List <PhoneSystemAssociation> oPhoneSystemAssociations; PhoneSystem oPhoneSystem = new PhoneSystem(_mockServer); var res = oPhoneSystem.GetPhoneSystemAssociations(out oPhoneSystemAssociations); Assert.IsFalse(res.Success, "Calling GetPhoneSystemAssociations on empty class should fail"); }
public void PropertyGetFetch_RestrictDialScheduled() { PhoneSystem oPhoneSystem = new PhoneSystem(); const bool expectedValue = false; oPhoneSystem.RestrictDialScheduled = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("RestrictDialScheduled", expectedValue), "RestrictDialScheduled value get fetch failed"); }
public void PropertyGetFetch_EnablePhoneApplications() { PhoneSystem oPhoneSystem = new PhoneSystem(); const bool expectedValue = false; oPhoneSystem.EnablePhoneApplications = expectedValue; Assert.IsTrue(oPhoneSystem.ChangeList.ValueExists("EnablePhoneApplications", expectedValue), "EnablePhoneApplications value get fetch failed"); }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; switch (args[1]) { case "create": case "update": { using (var pbe = args[1] == "update" ? ps.GetByID <PhoneBookEntry>(int.Parse(args[2])) : args[2] == "company" ? ps.GetTenant().CreatePhoneBookEntry() : ps.GetDNByNumber(args[2]).CreatePhoneBookEntry()) { foreach (var param in args.Skip(3).Select(x => x.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries)).Select(x => new KeyValuePair <string, string>(x[0], string.Join("", x.Skip(1))))) { typeof(PhoneBookEntry).GetProperty(param.Key).SetValue(pbe, param.Value); } pbe.Save(); Display(new[] { pbe }); } } break; case "delete": { using (var pbe = ps.GetByID <PhoneBookEntry>(int.Parse(args[2]))) { pbe.Delete(); Console.WriteLine("REMOVED:"); Display(new[] { pbe }); } } break; case "lookup": { var minmatch = uint.Parse(args.Skip(4).FirstOrDefault() ?? uint.MaxValue.ToString()); using (var result = (args[2] == "company" ? ps.GetTenant().FindContacts(args[3], minmatch) : ps.GetDNByNumber(args[2]).FindContacts(args[3], minmatch)).GetDisposer()) { Display(result); } } break; case "show": { string a = args.Skip(2).FirstOrDefault(); using (var pb = ((a == "all" || a == null) ? ps.GetAll <PhoneBookEntry>().ToArray() : a == "company" ? ps.GetTenant().PhoneBookEntries : ps.GetDNByNumber(a).PhoneBookEntries).GetDisposer()) { Display(pb); } } break; default: throw new ArgumentException("Invalid action name"); } }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; String filter = null; if (args.Length > 1) { filter = args[1]; } BlackList a = new BlackList(); DateTime startAt = DateTime.Now; FillBlacklist(a); Console.WriteLine("Added entries. time elabpsed {0}", DateTime.Now - startAt); startAt = DateTime.Now; for (int i = 0; i < 10000; i++) { if (a.Checker.IsBlackListed("10.172.0.103") == 0) { Console.Write('X'); } else { Console.Write('.'); } if (a.Checker.IsBlackListed("192.168.4.254") == 0) { Console.Write('X'); } else { Console.Write('.'); } } Console.WriteLine("Checked 20000 times. time elabpsed {0}", DateTime.Now - startAt); while (true) { if (a.Checker.IsBlackListed("10.172.0.103") == 0) { Console.Write('X'); } else { Console.Write('.'); } if (a.Checker.IsBlackListed("192.168.1.83") == 0) { Console.Write('X'); } else { Console.Write('.'); } Thread.Sleep(1000); } }
public new static void MyClassInitialize(TestContext testContext) { BaseIntegrationTests.MyClassInitialize(testContext); WebCallResult res = PhoneSystem.AddPhoneSystem(_connectionServer, "UnitTest_" + Guid.NewGuid(), out _phoneSystem); Assert.IsTrue(res.Success, "Creating new temporary phone system failed:" + res); res = PortGroup.AddPortGroup(_connectionServer, "UnitTest_" + Guid.NewGuid(), _phoneSystem.ObjectId, _connectionServer.ServerName, TelephonyIntegrationMethodEnum.SIP, "", out _portGroup); Assert.IsTrue(res.Success, "Creating new temporary port group failed:" + res); }
public void Run(params string[] args) { PhoneSystem ps = PhoneSystem.Root; using (var listener = new MyListener(new HashSet <string>(args.Skip(1)))) { while (!Program.Stop) { Thread.Sleep(5000); } } }
public void Constructor_DisplayName_ErrorResponse_Failure() { _mockTransport.Setup(m => m.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), It.IsAny <bool>())).Returns(new WebCallResult { ResponseText = "Error response text", Success = false, }); PhoneSystem oTest = new PhoneSystem(_mockServer, "", "Display Name"); Console.WriteLine(oTest); }
public void GetPhoneSystemAssociations_EmptyResult_Failure() { _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "" }); List <PhoneSystemAssociation> oPhoneSystemAssociations; var res = PhoneSystem.GetPhoneSystemAssociations(_mockServer, "ObjectId", out oPhoneSystemAssociations, 1, 5); Assert.IsFalse(res.Success, "Calling GetPhoneSystemAssociations with EmptyResultText did not fail"); }
public void DeletePhoneSystem_ErrorResponse_Failure() { _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = false, ResponseText = "error text", StatusCode = 404 }); var res = PhoneSystem.DeletePhoneSystem(_mockServer, "ObjectId"); Assert.IsFalse(res.Success, "Calling DeletePhoneSystem with ErrorResponse did not fail"); }
public void GetPhoneSystemAssociations_ZeroCount_Success() { _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = true, ResponseText = "junk text", TotalObjectCount = 0 }); List <PhoneSystemAssociation> oPhoneSystemAssociations; var res = PhoneSystem.GetPhoneSystemAssociations(_mockServer, "ObjectId", out oPhoneSystemAssociations, 1, 5); Assert.IsTrue(res.Success, "Calling GetPhoneSystemAssociations with ZeroCount failed:" + res); }
public void GetPhoneSystemAssociations_ErrorResponse_Failure() { _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(), It.IsAny <string>(), true)).Returns(new WebCallResult { Success = false, ResponseText = "error text", StatusCode = 404 }); List <PhoneSystemAssociation> oPhoneSystemAssociations; var res = PhoneSystem.GetPhoneSystemAssociations(_mockServer, "ObjectId", out oPhoneSystemAssociations, 1, 5); Assert.IsFalse(res.Success, "Calling GetPhoneSystemAssociations with ErrorResponse did not fail"); }
public PhoneSystemHub(PhoneSystem phoneSystem) { _phoneSystem = phoneSystem; }