コード例 #1
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");
            }
        }
コード例 #2
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");
        }