Пример #1
0
 //+---------------------------------------------------------------------------
 //
 //  function:   hasReassignPermission
 //
 //  Synopsis:   Check if the current user has ReAssign Permission
 //
 //  Arguments:  [objFaxServer] - Fax Server object
 //
 //  Returns:    bool: true if it has reassign permissions
 //
 //----------------------------------------------------------------------------
 static bool hasReassignPermission(FAXCOMEXLib.FaxServerClass objFaxServer)
 {
     FAXCOMEXLib.IFaxSecurity2 objFaxSecurity2;
     if (objFaxServer != null)
     {
         //Get the Security Object
         objFaxSecurity2 = objFaxServer.Security2;
         FAXCOMEXLib.FAX_ACCESS_RIGHTS_ENUM_2 enumFaxRights;
         //Get the Access Rights of the user
         enumFaxRights = objFaxSecurity2.GrantedRights;
         if ((enumFaxRights & FAXCOMEXLib.FAX_ACCESS_RIGHTS_ENUM_2.far2MANAGE_RECEIVE_FOLDER) == FAXCOMEXLib.FAX_ACCESS_RIGHTS_ENUM_2.far2MANAGE_RECEIVE_FOLDER)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     System.Console.WriteLine("hasReassignPermission: Parameter is NULL");
     return(false);
 }
Пример #2
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass            objFaxServer       = null;
            FAXCOMEXLib.IFaxOutboundRoutingGroups objFaxOutRoutGrps  = null;
            FAXCOMEXLib.IFaxOutboundRoutingRules  objFaxOutRoutRules = null;
            string strServerName  = null;
            string strName        = null;
            string strIndex       = null;
            string strIds         = null;
            string strOption      = null;
            string strCountryCode = null;
            string strAreaCode    = null;
            string strUseDev      = null;
            bool   bConnected     = false;
            bool   bRetVal        = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }

            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'o':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case 'n':
                                if (strName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'd':
                                if (strIds != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strIds = args[argcount + 1];
                                argcount++;
                                break;

                            case 'i':
                                if (strIndex != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strIndex = args[argcount + 1];
                                argcount++;
                                break;

                            case 'a':
                                if (strAreaCode != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strAreaCode = args[argcount + 1];
                                argcount++;
                                break;

                            case 'c':
                                if (strCountryCode != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strCountryCode = args[argcount + 1];
                                argcount++;
                                break;

                            case 'b':
                                if (strUseDev != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strUseDev = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if (strOption == null)
                {
                    System.Console.WriteLine("Missing/Invalid args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                if (((strName == null) || (strIds == null)) && ((String.Compare("addgroup", strOption, true, CultureInfo.CurrentCulture) == 0)))
                {
                    System.Console.WriteLine("Missing/Invalid args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                //if addrule and strUseDev is not set
                if (((strUseDev == null) || ((String.Compare("1", strUseDev, true, CultureInfo.CurrentCulture) != 0) && (String.Compare("0", strUseDev, true, CultureInfo.CurrentCulture) != 0))) && (((String.Compare("addrule", strOption, true, CultureInfo.CurrentCulture) == 0))))
                {
                    System.Console.WriteLine("Set /b tag to 0 or 1.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }



                if ((strIndex == null) && ((String.Compare("removegroup", strOption, true, CultureInfo.CurrentCulture) == 0) && (String.Compare("removerule", strOption, true, CultureInfo.CurrentCulture) == 0)))
                {
                    System.Console.WriteLine("Missing/Invalid args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                //if UseDev = 1 then set lptstrIds
                //if UseDev = 0 then set lptstrName
                if (strUseDev != null)
                {
                    if ((((String.Compare(strUseDev, "0", true, CultureInfo.CurrentCulture) == 0) && (strName == null)) || ((String.Compare(strUseDev, "1", true, CultureInfo.CurrentCulture) == 0) && (strIds == null)) || (strCountryCode == null) || (strAreaCode == null)) && ((String.Compare("addrule", strOption, true, CultureInfo.CurrentCulture) == 0)))
                    {
                        System.Console.WriteLine("Missing/Invalid args.");
                        GiveUsage();
                        bRetVal = false;
                        goto Exit;
                    }
                }

                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                objFaxOutRoutGrps  = objFaxServer.OutboundRouting.GetGroups();
                objFaxOutRoutRules = objFaxServer.OutboundRouting.GetRules();

                //list groups
                if (String.Compare("listgroups", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!listGroups(objFaxOutRoutGrps))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //list rules
                if (String.Compare("listrules", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!listRules(objFaxOutRoutRules))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //remove group
                if (String.Compare("removegroup", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!removeGroup(objFaxOutRoutGrps, Int32.Parse(strIndex, CultureInfo.CurrentCulture.NumberFormat)))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //remove rule
                if (String.Compare("removerule", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!removeRule(objFaxOutRoutRules, Int32.Parse(strIndex, CultureInfo.CurrentCulture.NumberFormat)))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //add group
                if (String.Compare("addgroup", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!addGroup(objFaxOutRoutGrps, strName, strIds))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //add rule
                if (String.Compare("addrule", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    bool bUseDevice = false;
                    if (String.Compare("0", strUseDev, true, CultureInfo.CurrentCulture) == 0)
                    {
                        bUseDevice = false;
                    }
                    else
                    {
                        bUseDevice = true;
                    }
                    if (!addRule(objFaxOutRoutRules, strName, strIds, strCountryCode, strAreaCode, bUseDevice))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass objFaxServer = null;
            FAXCOMEXLib.IFaxAccountSet objFaxAccountSet;
            string strServerName  = null;
            string strAccountName = null;
            string strOption      = null;
            bool   bConnected     = false;
            bool   bFound         = true;
            bool   bRetVal        = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("OS Version does not support this feature");
                bRetVal = false;
                goto Exit;
            }
            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                //FaxAccount objFax = new FaxAccount();
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'o':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case 'a':
                                if (strAccountName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strAccountName = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if (strOption == null || (String.Compare("enum", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) != 0) && strAccountName == null)
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("Feature not available on this version of the Fax API");
                    goto Exit;
                }

                //lets also get the account set since that is the basis for all account relates operations
                objFaxAccountSet = objFaxServer.FaxAccountSet;

                //if Enum Account option is selected
                if (String.Compare("enum", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!FaxEnumAccounts(objFaxAccountSet, false, null, ref bFound))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }

                //if Add Account option is selected
                if (String.Compare("add", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!AddAccount(objFaxAccountSet, strAccountName))
                    {
                        bRetVal = false;
                    }
                }

                //if Delete Account option is selected
                if (String.Compare("delete", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!DeleteAccount(objFaxAccountSet, strAccountName))
                    {
                        bRetVal = false;
                    }
                }

                //if validate account option is selected
                if (String.Compare("validate", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!GetAccountInfo(objFaxAccountSet, strAccountName))
                    {
                        bRetVal = false;
                    }
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass   objFaxServer = null;
            FAXCOMEXLib.FaxDocumentClass objFaxDoc    = null;
            FAXCOMEXLib.IFaxOutgoingJob2 objFaxOutgoingJob2;

            string strServerName = null;
            string strDocList    = null;
            string strNumber     = null;
            bool   bConnected    = false;
            bool   bRetVal       = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }
            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'd':
                                if (strDocList != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strDocList = args[argcount + 1];
                                argcount++;
                                break;

                            case 'n':
                                if (strNumber != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strNumber = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if ((strDocList == null) || (strNumber == null))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }


                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                bool retVal  = false;
                int  numDocs = 0;

                objFaxDoc = new FaxDocumentClass();
                string[] strDocArray = DecodeToDocArray(strDocList, ref numDocs, ref retVal);
                objFaxDoc.Bodies = strDocArray;
                objFaxDoc.Sender.LoadDefaultSender();
                objFaxDoc.Recipients.Add(strNumber, "TestUser");
                object strJobIds = null;

                int iErrorIndex = objFaxDoc.ConnectedSubmit2(objFaxServer, out strJobIds);
                if (iErrorIndex != -1)
                {
                    System.Console.Write("ConnectedSubmit2 failed ErrorIndex = ");
                    System.Console.Write(iErrorIndex);
                    System.Console.WriteLine();
                    bRetVal = false;
                    goto Exit;
                }
                string[] strArrJobIds = (string[])strJobIds;
                System.Console.Write("Job Id= ");
                System.Console.Write(strArrJobIds[0]);
                System.Console.WriteLine();

                objFaxOutgoingJob2 = (FAXCOMEXLib.IFaxOutgoingJob2)objFaxServer.CurrentAccount.Folders.OutgoingQueue.GetJob(strArrJobIds[0]);
                if (PrintJobStatus(objFaxOutgoingJob2) == false)
                {
                    System.Console.WriteLine("PrintJobStatus failed.");
                    bRetVal = false;
                    goto Exit;
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass    objFaxServer        = null;
            FAXCOMEXLib.IFaxOutgoingQueue objFaxOutgoingQueue = null;

            string strServerName = null;
            bool   bConnected    = false;
            bool   bRetVal       = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }

            try
            {
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                objFaxOutgoingQueue = objFaxServer.Folders.OutgoingQueue;
                bool   bQuit    = false;
                string strJobId = null;
                char   cOption  = 'c';
                string strChar  = null;

                while (bQuit == false)
                {
                    System.Console.WriteLine();
                    objFaxOutgoingQueue.Blocked = true;
                    objFaxOutgoingQueue.Paused  = true;
                    objFaxOutgoingQueue.Save();
                    System.Console.WriteLine("Outgoing Queue is paused. ");
                    System.Console.WriteLine("Outgoing Queue is blocked. ");

                    //Print all outgoing jobs
                    System.Console.WriteLine("Printing list of Outgoing jobs ...");

                    if (EnumOutbox(objFaxOutgoingQueue) == false)
                    {
                        System.Console.WriteLine("Failed to enumerate");
                        bRetVal = false;
                    }
                    System.Console.WriteLine("Enter 'c' to cancel a job ");
                    System.Console.WriteLine("Enter 'q' to quit ");
                    strChar = System.Console.ReadLine();
                    strChar.Trim();
                    cOption = strChar.ToLower(CultureInfo.CurrentCulture)[0];
input:
                    switch (cOption)
                    {
                    case 'c':
                        System.Console.WriteLine("Enter 'i' to enter Job id ");
                        System.Console.WriteLine("Enter 'q' to quit ");
                        strChar = System.Console.ReadLine();
                        strChar.Trim();
                        cOption = strChar.ToLower(CultureInfo.CurrentCulture)[0];

input2:
                        switch (cOption)
                        {
                        case 'i':
                            System.Console.WriteLine("Enter Job id ");
                            strJobId = System.Console.ReadLine();
                            strJobId.Trim();
                            System.Console.Write("Job to be cancelled: ");
                            System.Console.WriteLine(strJobId);
                            CancelJob(objFaxOutgoingQueue, strJobId);
                            break;

                        case 'q':
                            goto quit;

                        default:
                            System.Console.WriteLine("Invalid Option. Enter cancel option again ");                                                  strChar = System.Console.ReadLine();
                            strChar.Trim();
                            cOption = strChar.ToLower(CultureInfo.CurrentCulture)[0];
                            goto input2;
                        }
                        break;

                    case 'q':
                        quit :                       bQuit = true;
                        break;

                    default:
                        System.Console.WriteLine("Invalid Option. Enter again ");
                        System.Console.WriteLine("Invalid Option. Enter cancel option again ");
                        strChar = System.Console.ReadLine();
                        strChar.Trim();
                        cOption = strChar.ToLower(CultureInfo.CurrentCulture)[0];
                        goto input;
                    }
                }

                //unblock queue
                objFaxOutgoingQueue.Paused  = false;
                objFaxOutgoingQueue.Blocked = false;
                objFaxOutgoingQueue.Save();
                System.Console.WriteLine("Outgoing Queue is resumed. ");
                System.Console.WriteLine("Outgoing Queue is unblocked. ");
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass objFaxServer  = null;
            FAXCOMEXLib.IFaxDevices    objFaxDevices = null;

            string strServerName = null;
            string strCSID       = null;
            string strTSID       = null;
            string strOption     = null;
            string strDeviceId   = null;
            bool   bConnected    = false;
            bool   bRetVal       = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }

            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'l':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case 'i':
                                if (strDeviceId != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strDeviceId = args[argcount + 1];
                                argcount++;
                                break;

                            case 'c':
                                if (strCSID != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strCSID = args[argcount + 1];
                                argcount++;
                                break;

                            case 't':
                                if (strTSID != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strTSID = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if ((strOption == null) || ((String.Compare("set", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0) && ((strDeviceId == null) || (strCSID == null && strTSID == null))))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                objFaxDevices = objFaxServer.GetDevices();

                //if list devices is selected
                if (String.Compare("list", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (listDevices(objFaxDevices) == false)
                    {
                        bRetVal = false;
                    }
                }
                else
                {
                    //if set device option is selected
                    if (String.Compare("set", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                    {
                        int iDeviceId = Int32.Parse(strDeviceId, CultureInfo.CurrentCulture.NumberFormat);
                        //if set TSID is selected
                        if (strTSID != null)
                        {
                            if (setTSID(objFaxDevices, iDeviceId, strTSID) == false)
                            {
                                bRetVal = false;
                            }
                        }
                        //if set CSID is selected
                        if (strCSID != null)
                        {
                            if (setCSID(objFaxDevices, iDeviceId, strCSID) == false)
                            {
                                bRetVal = false;
                            }
                        }
                    }
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass              objFaxServer = null;
            FAXCOMEXLib.IFaxAccount                 objFaxAccount;
            FAXCOMEXLib.IFaxAccountFolders          objFaxFolders;
            FAXCOMEXLib.IFaxIncomingMessageIterator objIncomingMessageIterator;

            string    strServerName = null;
            string    strMsgId      = null;
            string    strRecipient  = null;
            string    strOption     = null;
            bool      bConnected    = false;
            bool      bRetVal       = true;
            ArrayList arrFaxMsgIds  = null;
            int       count         = 0;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("OS Version does not support this feature");
                bRetVal = false;
                goto Exit;
            }
            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'o':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case 'r':
                                if (strRecipient != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strRecipient = args[argcount + 1];
                                argcount++;
                                break;

                            case 'i':
                                if (strMsgId != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strMsgId = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if ((strOption == null) || ((String.Compare("reassign", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0) && ((strRecipient == null) || (strMsgId == null))))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("The Fax Server API version does not support this feature");
                    goto Exit;
                }
                objFaxAccount = objFaxServer.CurrentAccount;
                //Now that we have got the account object lets get the folders object
                objFaxFolders = objFaxAccount.Folders;

                //if reassign message option is selected
                if (String.Compare("reassign", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (hasReassignPermission(objFaxServer))
                    {
                        objIncomingMessageIterator = FaxAccountIncomingArchive(objFaxFolders);
                        if (objIncomingMessageIterator != null)
                        {
                            if (!Reassign(objIncomingMessageIterator, strMsgId, strRecipient))
                            {
                                //we dont want to log any error here as the error will be logged in the function itself
                                bRetVal = false;
                            }
                            else
                            {
                                //we dont want to log any error here as the error will be logged in the function itself
                                bRetVal = true;
                            }
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("User doesn't have reassign permission");
                        bRetVal = false;
                    }
                }

                //if list message ids option is selected
                if (String.Compare("list", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (hasReassignPermission(objFaxServer))
                    {
                        objIncomingMessageIterator = FaxAccountIncomingArchive(objFaxFolders);
                        if (objIncomingMessageIterator != null)
                        {
                            arrFaxMsgIds = getUnassignedMsg(objIncomingMessageIterator, ref count);
                            if (arrFaxMsgIds == null)
                            {
                                System.Console.WriteLine("No reassignable faxes present");
                            }
                            else
                            {
                                System.Console.WriteLine("Printing Msg Ids of reassignable faxes");
                                for (int i = 0; i < count; i++)
                                {
                                    System.Console.WriteLine("Msg Id of Message Number " + i.ToString(CultureInfo.CurrentCulture.NumberFormat) + " is " + arrFaxMsgIds[i]);
                                }
                                bRetVal = true;
                            }
                        }
                        else
                        {
                            //we dont want to log any error here as the error will be logged in the function itself
                            bRetVal = false;
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("User doesn't have reassign permission");
                        bRetVal = false;
                    }
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass     objFaxServer = null;
            FAXCOMEXLib.IFaxAccount        objFaxAccount;
            FAXCOMEXLib.IFaxAccountFolders objFaxAccFolders;


            string strServerName = null;
            string strOption     = null;
            bool   bConnected    = false;
            bool   bRetVal       = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }

            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'o':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if (strOption == null)
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                objFaxAccount    = objFaxServer.CurrentAccount;
                objFaxAccFolders = objFaxAccount.Folders;

                if (String.Compare("enuminbox", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (EnumInbox(objFaxAccFolders) == false)
                    {
                        System.Console.WriteLine("EnumInbox Failed");
                        bRetVal = false;
                    }
                }

                if (String.Compare("enumoutbox", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (EnumOutbox(objFaxAccFolders) == false)
                    {
                        System.Console.WriteLine("EnumOutbox Failed");
                        bRetVal = false;
                    }
                }

                if (String.Compare("enumincoming", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (EnumIncoming(objFaxAccFolders) == false)
                    {
                        System.Console.WriteLine("EnumIncoming Failed");
                        bRetVal = false;
                    }
                }

                if (String.Compare("enumsentitems", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (EnumSentItems(objFaxAccFolders) == false)
                    {
                        System.Console.WriteLine("EnumSentItems Failed");
                        bRetVal = false;
                    }
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            FAXCOMEXLib.FaxServerClass    objFaxServer = null;
            FAXCOMEXLib.IFaxConfiguration objFaxConfiguration;
            string strServerName = null;
            string strValue      = null;
            string strOption     = null;
            bool   bConnected    = false;
            bool   bState        = false;
            bool   bRetVal       = true;

            int  iVista   = 6;
            bool bVersion = IsOSVersionCompatible(iVista);

            if (bVersion == false)
            {
                System.Console.WriteLine("This sample is compatible with Windows Vista");
                bRetVal = false;
                goto Exit;
            }

            try
            {
                if ((args.Length == 0))
                {
                    System.Console.WriteLine("Missing args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }

                // check for commandline switches
                for (int argcount = 0; argcount < args.Length; argcount++)
                {
                    if (argcount + 1 < args.Length)
                    {
                        if ((args[argcount][0] == '/') || (args[argcount][0] == '-'))
                        {
                            switch (((args[argcount].ToLower(CultureInfo.CurrentCulture))[1]))
                            {
                            case 's':
                                if (strServerName != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strServerName = args[argcount + 1];
                                argcount++;
                                break;

                            case 'o':
                                if (strOption != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strOption = args[argcount + 1];
                                argcount++;
                                break;

                            case 'v':
                                if (strValue != null)
                                {
                                    GiveUsage();
                                    bRetVal = false;
                                    goto Exit;
                                }
                                strValue = args[argcount + 1];
                                argcount++;
                                break;

                            case '?':
                                GiveUsage();
                                bRetVal = false;
                                goto Exit;

                            default:
                                break;
                            }    //switch
                        }        //if
                    }            //if (argcount + 1 < argc)
                }                //for

                if ((strOption == null) || (strValue == null) || ((String.Compare("0", strValue, true, CultureInfo.CurrentCulture) != 0) && (String.Compare("1", strValue, true, CultureInfo.CurrentCulture) != 0)))
                {
                    System.Console.WriteLine("Missing/Invalid args.");
                    GiveUsage();
                    bRetVal = false;
                    goto Exit;
                }
                //Connect to Fax Server
                objFaxServer = new FaxServerClass();
                objFaxServer.Connect(strServerName);
                bConnected = true;

                //Check the API version
                if (objFaxServer.APIVersion < FAX_SERVER_APIVERSION_ENUM.fsAPI_VERSION_3)
                {
                    bRetVal = false;
                    System.Console.WriteLine("This sample is compatible with Windows Vista");
                    goto Exit;
                }

                objFaxConfiguration = objFaxServer.Configuration;
                if (String.Compare("0", strValue, true, CultureInfo.CurrentCulture) == 0)
                {
                    bState = false;
                }
                if (String.Compare("1", strValue, true, CultureInfo.CurrentCulture) == 0)
                {
                    bState = true;
                }
                System.Console.WriteLine();
                System.Console.WriteLine("Current Configuration.");
                System.Console.WriteLine();
                if (!PrintGeneralConfig(objFaxConfiguration))
                {
                    //we dont want to log any error here as the error will be logged in the function itself
                    bRetVal = false;
                }

                //if PersonalCoverPages option is selected
                if (String.Compare("personalcoverpage", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!setAllowPersonalCoverPages(objFaxConfiguration, bState))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //if Branding option is selected
                if (String.Compare("branding", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!setBranding(objFaxConfiguration, bState))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //if IncomingFaxArePublic option is selected
                if (String.Compare("incomingfaxespublic", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!setIncomingFaxesArePublic(objFaxConfiguration, bState))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }
                //if AutoCreateAccount option is selected
                if (String.Compare("autocreateaccount", strOption.ToLower(CultureInfo.CurrentCulture), true, CultureInfo.CurrentCulture) == 0)
                {
                    if (!setAutoCreateAccountOnConnect(objFaxConfiguration, bState))
                    {
                        //we dont want to log any error here as the error will be logged in the function itself
                        bRetVal = false;
                    }
                }

                System.Console.WriteLine("Current Server settings after the changes... ");
                if (!PrintGeneralConfig(objFaxConfiguration))
                {
                    //we dont want to log any error here as the error will be logged in the function itself
                    bRetVal = false;
                }
            }
            catch (Exception excep)
            {
                System.Console.WriteLine("Exception Occured");
                System.Console.WriteLine(excep.Message);
            }
Exit:
            if (bConnected)
            {
                objFaxServer.Disconnect();
            }
            if (bRetVal == false)
            {
                System.Console.WriteLine("Function Failed");
            }
        }