//+--------------------------------------------------------------------------- // // function: DisplayFaxAccount // // Synopsis: prints the display name of a Fax Account // // Arguments: [objFaxAcc] - FaxAccount object whose display name is to be printed // // Returns: bool: true if passed successfully // //---------------------------------------------------------------------------- static bool DisplayFaxAccount(FAXCOMEXLib.IFaxAccount objFaxAcc) { if (objFaxAcc != null) { //print the accountname System.Console.WriteLine("Fax Account Name: " + objFaxAcc.AccountName); return(true); } System.Console.WriteLine("DisplayFaxAccount: Parameter is NULL"); return(false); }
//+--------------------------------------------------------------------------- // // function: FaxEnumAccounts // // Synopsis: Enumerates the list of accounts // // Arguments: [objFaxAccSet] - FaxAccountSet object having the list of all Fax Accounts // [bCheck] - if set to true then is verifies if the account with name strAccName is present. // [strAccName] - name of the account that is to be verified. // [pbFound] - used to return the result of whether the account is present or not // // Returns: bool: true if passed successfully // // Modifies: pbFound : if the account with the name strAccName is found then pbFound is set to true. // //---------------------------------------------------------------------------- static bool FaxEnumAccounts(FAXCOMEXLib.IFaxAccountSet objFaxAccSet, bool bCheck, string strAccName, ref bool pbFound) { if (objFaxAccSet != null) { //Get the FaxAccounts object FAXCOMEXLib.IFaxAccounts objFaxAccounts = objFaxAccSet.GetAccounts(); //Print the number of FaxAccounts System.Console.WriteLine("Number of accounts: " + objFaxAccounts.Count); //start enumerating each account. System.Collections.IEnumerator objFaxEnum = objFaxAccounts.GetEnumerator(); while (true) { bool bLast = objFaxEnum.MoveNext(); if (bLast == false) { //enumeration is done System.Console.WriteLine("Enumeration of accounts done."); break; } FAXCOMEXLib.IFaxAccount objFaxAccount = (IFaxAccount)objFaxEnum.Current; //if check that a account is present. if (bCheck) { if (String.IsNullOrEmpty(strAccName) == false) { if (String.Compare(objFaxAccount.AccountName.ToLower(CultureInfo.CurrentCulture), strAccName.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0) { pbFound = true; } } else { System.Console.WriteLine("FaxEnumAccounts: strAccName Parameter is NULL"); return(false); } } //Display the current account info. DisplayFaxAccount(objFaxAccount); } return(true); } System.Console.WriteLine("FaxEnumAccounts: Parameter is NULL"); return(false); }
//+--------------------------------------------------------------------------- // // function: AddAccount // // Synopsis: Adds a Fax Account // // Arguments: [objFaxAccSet] - FaxAccountSet object having the list of all Fax Accounts // [strAccName] - name of the account to be added. Must be a valid NT/Domain user. // // Returns: bool: true if passed successfully // //---------------------------------------------------------------------------- static bool AddAccount(FAXCOMEXLib.IFaxAccountSet objFaxAccSet, string strAccName) { if ((objFaxAccSet != null) && (String.IsNullOrEmpty(strAccName) == false)) { bool bFound = true; //first enum the existing accounts if (!FaxEnumAccounts(objFaxAccSet, false, null, ref bFound)) { //enum failed System.Console.WriteLine("FaxEnumAccounts failed"); } //now add the account FAXCOMEXLib.IFaxAccount objFaxAccount = objFaxAccSet.AddAccount(strAccName); //Display Info on added account. DisplayFaxAccount(objFaxAccount); return(true); } System.Console.WriteLine("AddAccount: Parameter is NULL"); return(false); }