Ejemplo n.º 1
0
        //+---------------------------------------------------------------------------
        //
        //  function:   DeleteAccount
        //
        //  Synopsis:   Deletes a Fax Account
        //
        //  Arguments:  [objFaxAccSet] - FaxAccountSet object having the list of all Fax Accounts
        //                [strAccountName] - name of the account to be deleted.
        //
        //  Returns:    bool: true if passed successfully
        //
        //----------------------------------------------------------------------------
        static bool DeleteAccount(FAXCOMEXLib.IFaxAccountSet objFaxAccSet, string strAccountName)
        {
            if ((objFaxAccSet != null) && (String.IsNullOrEmpty(strAccountName) == false))
            {
                bool bFound = false;
                //now lets enumerate the existing accounts first.
                if (!FaxEnumAccounts(objFaxAccSet, false, null, ref bFound))
                {
                    //FaxEnumAccounts failed
                    System.Console.WriteLine("FaxEnumAccounts failed before deleting");
                }

                objFaxAccSet.RemoveAccount(strAccountName);
                //now enumerate to see if account exists
                if (!FaxEnumAccounts(objFaxAccSet, true, strAccountName, ref bFound))
                {
                    //we can properly validate if this call fails, hence log an error
                    System.Console.WriteLine("FaxEnumAccounts failed during validation");
                    return(false);
                }
                if (bFound)
                {
                    //we just deleted the account but still the enumeration shows the account. hecen log error
                    System.Console.WriteLine("Account exists after deleteion");
                    return(false);
                }
                return(true);
            }
            System.Console.WriteLine("DeleteAccount: Parameter is NULL");
            return(false);
        }
Ejemplo n.º 2
0
 //+---------------------------------------------------------------------------
 //
 //  function:   GetAccountInfo
 //
 //  Synopsis:   Get the account object.
 //
 //  Arguments:  [objFaxAccSet] - FaxAccountSet object having the list of all Fax Accounts
 //                [strAccountName] - Account whose info is to be printed.
 //
 //  Returns:    bool: true if passed successfully
 //
 //----------------------------------------------------------------------------
 static bool GetAccountInfo(FAXCOMEXLib.IFaxAccountSet objFaxAccSet, string strAccountName)
 {
     if ((objFaxAccSet != null) && (String.IsNullOrEmpty(strAccountName) != false))
     {
         FAXCOMEXLib.IFaxAccount objFaxAccount;
         //Get the account with the name lptstrAccountName
         objFaxAccount = objFaxAccSet.GetAccount(strAccountName);
         DisplayFaxAccount(objFaxAccount);
         return(true);
     }
     System.Console.WriteLine("GetAccountInfo: Parameter is NULL");
     return(false);
 }
Ejemplo n.º 3
0
        //+---------------------------------------------------------------------------
        //
        //  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);
        }
Ejemplo n.º 4
0
 //+---------------------------------------------------------------------------
 //
 //  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);
 }