public new static void MyClassInitialize(TestContext testContext) { BaseIntegrationTests.MyClassInitialize(testContext); _connectionServer.ErrorEvents += ServerOnErrorEvents; //create new list with GUID in the name to ensure uniqueness String strAlias = "TempUserServerResp_" + Guid.NewGuid().ToString().Replace("-", ""); //generate a random number and tack it onto the end of some zeros so we're sure to avoid any legit numbers on the system. Random random = new Random(); int iExtPostfix = random.Next(100000, 999999); string strExtension = "000000" + iExtPostfix.ToString(); //use a bogus extension number that's legal but non dialable to avoid conflicts var res = UserBase.AddUser(_connectionServer, "voicemailusertemplate", strAlias, strExtension, null, out _tempUser); Assert.IsTrue(res.Success, "Failed creating temporary user:"******"TempContactJsn_" + Guid.NewGuid().ToString().Replace("-", ""); res = Contact.AddContact(_connectionServer, "systemcontacttemplate", strAlias, "", "", strAlias, null, out _tempContact); Assert.IsTrue(res.Success, "Failed creating temporary contact:" + res.ToString()); strAlias = "TempInterviewer_" + Guid.NewGuid().ToString().Replace("-", ""); res = InterviewHandler.AddInterviewHandler(_connectionServer, strAlias, _tempUser.ObjectId, "", null, out _tempInterviewer); Assert.IsTrue(res.Success, "Failed creating temporary interviewer:" + res.ToString()); strAlias = "TempRecording_" + Guid.NewGuid().ToString().Replace("-", ""); res = PostGreetingRecording.AddPostGreetingRecording(_connectionServer, strAlias, out _tempRecording); Assert.IsTrue(res.Success, "Failed creating temporary post greeting recording:" + res.ToString()); }
//create a new user - pop a dialog that allows the user to provide an alias, first name, last name, display name and extension - if at least //the alias and extension are provided this routine will then attempt to create that user on the Connection server. private void buttonAddItem_Click(object sender, EventArgs e) { //gather the new subscriber data from the user. using (FormNewUserInfo oForm = new FormNewUserInfo()) { if (oForm.ShowDialog() != DialogResult.OK) { //user canceled or closed the dialog without going through OK - bail out. return; } //the call can take a minute to return - disable controls on the form to indicate we're busy. DisableFormControls(); ConnectionPropertyList oProps = new ConnectionPropertyList(); //fill up the props with the other items (if any) that are not blank if (oForm.FirstName.Length > 0) { oProps.Add("FirstName", oForm.FirstName); } if (oForm.LastName.Length > 0) { oProps.Add("LastName", oForm.LastName); } if (oForm.DisplayName.Length > 0) { oProps.Add("DisplayName", oForm.DisplayName); } WebCallResult res = UserBase.AddUser(GlobalItems.CurrentConnectionServer, oForm.TemplateAlias, oForm.Alias, oForm.Extension, oProps); EnableFormControls(); if (res.Success) { //force a refresh of the grid and then select the user you just added - the ObjectId of the newly added user is returned //in the WebCallResult structure as the ReturnObjectID. _currentPage = 0; UpdateDataDisplay(res.ReturnedObjectId); Logger.Log(string.Format("New user added:{0},{1}", oForm.Alias, res.ReturnedObjectId)); } else { Logger.Log(string.Format(string.Format("New user add failed:{0}\r\n{1}", oForm.Alias, res.ToString()))); MessageBox.Show(String.Format("Error adding user: {0}\nresponse from CUPI: {1}", res.ErrorText, res.ResponseText)); } } }
public ActionResult LoginForm(LoginHelper userResponse) { if (userResponse.CreateUser) { currentBase.AddUser(userResponse.Email, userResponse.Password); currentBase.CurrentUser = currentBase.GetUserByCredentials(userResponse.Email, userResponse.Password); } else { if ((currentBase.CurrentUser = currentBase.GetUserByCredentials(userResponse.Email, userResponse.Password)) == null) { return(View(new LoginHelper())); } } return(Redirect("CarForm")); }
public new static void MyClassInitialize(TestContext testContext) { BaseIntegrationTests.MyClassInitialize(testContext); //create new list with GUID in the name to ensure uniqueness String strUserAlias = "TempUserMbx_" + Guid.NewGuid().ToString().Replace("-", ""); //generate a random number and tack it onto the end of some zeros so we're sure to avoid any legit numbers on the system. Random random = new Random(); int iExtPostfix = random.Next(100000, 999999); string strExtension = "000000" + iExtPostfix.ToString(); //use a bogus extension number that's legal but non dialable to avoid conflicts WebCallResult res = UserBase.AddUser(_connectionServer, "voicemailusertemplate", strUserAlias, strExtension, null, out _tempUser); Assert.IsTrue(res.Success, "Failed creating temporary user:" + res.ToString()); }
private void Register_Click(object sender, RoutedEventArgs e) { User user = UserBase.FindUser(usernameTextbox.Text, passwordTextbox.Text); if (user == null) { //decrypt studd using this base if (passwordTextbox.Text != confirmPasswordTextbox.Text) { MessageBox.Show("Passwords do not match"); } else { User newUser = new User(usernameTextbox.Text, passwordTextbox.Text); UserBase.AddUser(newUser); MessageBox.Show($"Account for {newUser.username} has succesfully been created"); } } else { MessageBox.Show("This user can not be created. Maybe try using a different username"); } }
private static void RunTests() { //you can attach to multiple different Connection servers an interact with them in the same program easily by just creating //new instances of ConnectionServer objects - all objects "know" which server they are associated with. This example, of course, //just attaches to one server. ConnectionServerRest connectionServer = null; Logger.Log("Starting log output"); //attach to server - insert your Connection server name/IP address and login information here. try { connectionServer = new ConnectionServerRest("connection server", "login", "password"); } catch (Exception ex) { //return an exit code of 1 to indicate failure exit. Console.WriteLine("Could not attach to Connection server: " + ex.Message); Console.Read(); Environment.Exit(1); } //turn on "chatty" output to console connectionServer.DebugMode = true; //the Connection server object spits out the server name and version number in the ToString function. Console.WriteLine("Attached to Connection server: " + connectionServer); //do a version check - most things will work on older versions as well but voice name updates and some other functions will not. if (connectionServer.Version.IsVersionAtLeast(8, 5, 0, 0) == false) { Console.WriteLine("WARNING! The ConnectionCUPIFunctions library was written and tested against Connection 8.5 and later." + " The version you are attached to is less than that."); } //the WebCallResult is the structure returned on most calls into the CUPIFunctions library. WebCallResult res; //fetch user with alias of "operator" UserFull oUserTestDude; res = UserBase.GetUser(out oUserTestDude, connectionServer, "", "operator"); if (res.Success == false) { Console.WriteLine(res); return; } List <UserMessage> oUserMessages; res = UserMessage.GetMessages(connectionServer, oUserTestDude.ObjectId, out oUserMessages); if (res.Success == false) { Console.WriteLine(res); return; } ////**** ////play voice messages using the phone as a media device - aka TRAP ////**** PhoneRecording oPhone; try { oPhone = new PhoneRecording(connectionServer, "1001"); } catch (Exception ex) { Console.WriteLine("Failed to connect to phone extension:" + ex); return; } List <UserMessage> oTestUserMessages; res = UserMessage.GetMessages(connectionServer, oUserTestDude.ObjectId, out oTestUserMessages); if (res.Success == false) { Console.WriteLine("Error fetching messages:" + res.ToString()); Console.ReadLine(); } foreach (var oMessage in oTestUserMessages) { res = oPhone.PlayMessageFile(oMessage.MsgId, 100, 100, 0, oUserTestDude.ObjectId); if (res.Success == false) { Console.WriteLine("Error playing stream:" + res.ToString()); Console.ReadLine(); } } //hang up oPhone.Dispose(); //get the schedule details off all the schedules (both holiday and regular) that the user is associated with. The schedule //assignment comes through the user's primary call handler - it references a schedule set which can contain 1 or more schedules. //Each schedule has 0 or more details associated with it. foreach (var oSchedule in oUserTestDude.PrimaryCallHandler().GetScheduleSet().Schedules()) { Console.WriteLine("Schedle name=" + oSchedule.DisplayName); Console.WriteLine(" Details:"); foreach (var oDetail in oSchedule.ScheduleDetails()) { Console.WriteLine(oDetail.DumpAllProps(" ")); } } //determine if the current schedule state is ACTIVE, INACTIVE or HOLIDAY. Console.WriteLine("Evaluating schedule state"); Console.WriteLine(" Schedule state right now=" + oUserTestDude.PrimaryCallHandler().GetScheduleSet().GetScheduleState(DateTime.Now).ToString()); TransferOption oTransferAlternateSmith; res = oUserTestDude.PrimaryCallHandler().GetTransferOption(TransferOptionTypes.Alternate, out oTransferAlternateSmith); //not a lot of reasons this would fail but just in case if (res.Success == false) { Console.WriteLine("Could not find alternate transfer rule for jsmith"); Console.ReadLine(); Environment.Exit(1); } //update the transfer number to 12345 oTransferAlternateSmith.Extension = "12345"; oTransferAlternateSmith.Update(); //enable the transfer rule with no end date oTransferAlternateSmith.UpdateTransferOptionEnabledStatus(true); //**** //Add a new user //**** //The user template name passed here is the default one created by setup and should be present on any system. There are functions included //in the library that make presenting lists of templates for user selection easy - see the CUPIFastStart project for details. UserFull oUser; res = UserBase.AddUser(connectionServer, "voicemailusertemplate", "TestUserAlias", "80001", null, out oUser); if (res.Success == false) { //the ToString for the WebCallResult structure dumps its entire contents out which is handy for logging schenarios like this. Console.WriteLine("Failed creating new user:"******"\n\rUser created, new ObjectId=" + oUser.ObjectId); //**** //Edit that user's display name //**** //We could have passed the display name, first name and any other properties we wanted into the AddUser function above if we wanted. //This just demonstrates how easy it is to update properties on a standing user object with a few lines of code. The library sends //only the items that have changed when sending the update. The full list of properties send in the body is contained in the WebCallResult //structure passed back so if there's a problem the "ToString()" call will contain the entire URL, command type, body and everything //returned by the server for easy evaluation of what went wrong. oUser.DisplayName = "Test User"; oUser.FirstName = "Test"; oUser.LastName = "User"; res = oUser.Update(); if (res.Success == false) { Console.WriteLine("Failed updating user:"******"\n\rUser Updated: " + res.ToString()); //update greeting Greeting oMyGreeting; res = oUser.PrimaryCallHandler().GetGreeting(GreetingTypes.Alternate, out oMyGreeting); if (res.Success == false) { Console.WriteLine("Error fetching alternate greeting:" + res.ToString()); Console.ReadLine(); return; } res = oMyGreeting.SetGreetingWavFile(1033, @"c:\clean.wav", true); if (res.Success == false) { Console.WriteLine("Error applying greeting stream file:" + res.ToString()); Console.ReadLine(); return; } //**** //Dump the user properties for review //**** //the user "toString" shows the alias, display name and extension for the user. The DumpAllProps does a complete list of every property //and it's value for the user. You will find all objects defined in the ConnectionCUPIFunctions library follow this design pattern. Console.WriteLine("\n\rUser properties for: {0}\r\n{1}", oUser, oUser.DumpAllProps(" ")); //**** //Add an alternate extension to that User //**** //this adds the alternate extension "800012" as the first administrator added alternate extension. res = AlternateExtension.AddAlternateExtension(connectionServer, oUser.ObjectId, 1, "800012"); if (res.Success == false) { Console.WriteLine("Failed adding alternate extension:" + res.ToString()); Console.Read(); Environment.Exit(1); } //whenever adding a new object using a method that does not return an instance of that object (as we do with the alternate extension above) the ObjectId //of the newly created object (if the call suceeds) can be pulled from the WebCallResult structure's ReturnedObjectId property. Console.WriteLine("\n\rAlternate Extension added, ObjectId returned= " + res.ReturnedObjectId); //you can always turn around and now fetch an object instance of that alternate extension like this - remember that when fetching or editing alternate //extensions you have to provide the user's objectId as well. AlternateExtension oAltExt; res = AlternateExtension.GetAlternateExtension(connectionServer, oUser.ObjectId, res.ReturnedObjectId, out oAltExt); if (res.Success == false) { Console.WriteLine("Failed fetching new alternate extension object: " + res.ToString()); Environment.Exit(1); } //now we can update the alternate extension easily - you'll find this same type of pattern on all objects in the library (when they are completed). oAltExt.DtmfAccessId = "800013"; res = oAltExt.Update(); if (res.Success == false) { Console.WriteLine("Failed to update the alternate extension: " + res.ToString()); Environment.Exit(1); } Console.WriteLine("\n\rAlternate extension updated: " + oAltExt); //**** //List the user's notification devices //**** Console.WriteLine("\n\rNotification devices for: " + oUser.Alias); foreach (NotificationDevice oDevice in oUser.NotificationDevices()) { Console.WriteLine(oDevice.ToString()); Console.WriteLine(oDevice.DumpAllProps(" ")); } //****** //List the users menu entry keys //****** Console.WriteLine("\n\rMenu entry keys for: " + oUser.Alias); foreach (MenuEntry oMenu in oUser.PrimaryCallHandler().GetMenuEntries()) { //use the GetActionDescription method on the ConnectionServer object to produce a bit more readable output for the //actions menu keys are assigned to. You can still use the oMenu.ToString() here as well to dump out the raw data instead. Console.WriteLine("{0}:{1}", oMenu.TouchtoneKey, connectionServer.GetActionDescription(oMenu.Action, oMenu.TargetConversation, oMenu.TargetHandlerObjectId)); } //**** //List the first 5 system call handlers found in the system. //**** ////Pass the query for any object's "get(object name)s" by passing in a list of strings at the end - the library makes sure these are ////put onto the URL with proper escape codes and "?" and "&" symbols. It does not check the syntax of the items, however, and remember ////that they ARE case sensitive. ////Remember "IsPrimary" is set to 1 when it's a special handler associated with a user. List <CallHandler> oCallHandlers; res = CallHandler.GetCallHandlers(connectionServer, out oCallHandlers, "query=(IsPrimary is 0)", "rowsPerPage=5", "pageNumber=1"); if (res.Success == false) { Console.WriteLine("Failed fetching system call handlers: " + res.ToString()); Console.Read(); Environment.Exit(1); } Console.WriteLine("\n\rUp to the first 5 Call Handlers in the system:"); foreach (CallHandler oHandler in oCallHandlers) { Console.WriteLine(oHandler.ToString()); } //**** //Reset the users PIN //**** //pass the optional flags for forcing change, not expiring etc... if these are not passed the current values for the credential settings //will be left alone. You can pass just these flags and a blank PIN string if you want - the PIN will NOT be set to blank (that is not //allowed in this class library). If you wish to force a blank password (assuming such a thing is allowed in your configuration which is //not advisable) then you will have to do so manually calling the credential update on your own via the RestTransportFunctions library. res = oUser.ResetPin("123454321", false, false, false, true); if (res.Success == false) { Console.WriteLine("Failure updating PIN for user: "******"True" to convert to PCM - it does more than just change the codec, it also forces it into 16 Khz, 8 bit mono which //Connection is happy with - even PCM with a different sample rate can cause it to send the dreded "invalid media format" error back. res = oUser.SetVoiceName(@"WAVFiles\TestGuyVoiceName.wav", true); if (res.Success == false) { Console.WriteLine("Failure updating voice name for user: "******"Error fetching the alternate greeting for the user: "******"WAVFiles\TestGuyGreeting.wav", true); if (res.Success == false) { Console.WriteLine("Error setting alternate greeting recording: " + res.ToString()); } //By default the greeting is set to play the system generated greeting prompts - to play the custom recorded greeting we just //uploaded you need to set the "PlayWhat" to "1" (which is wrapped in the PlayWhatTypes enum here for readability. oGreeting.PlayWhat = PlayWhatTypes.RecordedGreeting; res = oGreeting.Update(); if (res.Success == false) { Console.WriteLine("Error setting alternate greeting playwhat property: " + res.ToString()); } //use the helper function to enable the alternate greeting (it's disabled by default). This call sets it to be enabled forever. res = oGreeting.UpdateGreetingEnabledStatus(true); if (res.Success == false) { Console.WriteLine("Error alternate greeting enabled property: " + res.ToString()); } //GET the user's mailbox store stats (quotas, size etc...) MailboxInfo oMailboxInfo = new MailboxInfo(connectionServer, oUser.ObjectId); Console.WriteLine(oMailboxInfo.DumpAllProps()); //get messages for user - get the first 50 messages, sorted by urgent first and restrict the list //to only unread voice messages. List <UserMessage> oMessages; res = UserMessage.GetMessages(connectionServer, oUser.ObjectId, out oMessages, 1, 50, MessageSortOrder.URGENT_FIRST, MessageFilter.Type_Voice | MessageFilter.Read_False); //list subject, sender and time sent for each message returned if (res.Success) { foreach (UserMessage oMessage in oMessages) { Console.WriteLine(oMessage.ToString()); } } //remove test user res = oUser.Delete(); if (res.Success) { Console.WriteLine("User deleted..."); } //give you time to review the console output before exiting. Console.WriteLine("\n\rPress enter to exit..."); Console.ReadLine(); //indicate success exit code Environment.Exit(0); }
public void AddUser_InvalidTemplateAlias_Failure() { var res = UserBase.AddUser(_connectionServer, "invalid template alias", "Alias", "1234", null); Assert.IsFalse(res.Success, "AddUser should fail if the template alias is invalid"); }
public void AddUser_EmptyDisplayName_Failure() { var res = UserBase.AddUser(_mockServer, "voicemailusertemplate", "", "1234", null); Assert.IsFalse(res.Success, "AddUser should fail if the DisplayName parameter is empty"); }
public void AddUser_EmptyExtension_Failure() { var res = UserBase.AddUser(_mockServer, "voicemailusertemplate", "Alias", "", null); Assert.IsFalse(res.Success, "AddUser should fail if the extension parameter is empty"); }
public void AddUser_EmptyTemplateAlias_Failure() { var res = UserBase.AddUser(_mockServer, "", "Alias", "123", null); Assert.IsFalse(res.Success, "AddUser should fail if the template parameter is empty"); }
public void AddUser_NullConnectionServer_Failure() { WebCallResult res = UserBase.AddUser(null, "voicemailusertemplate", "alias", "1234", null); Assert.IsFalse(res.Success, "AddUser should fail if the ConnectionServerRest parameter is null"); }
public void TestAddUser() { Assert.IsTrue(testBase.AddUser("email", "pass") != -1); }