//+--------------------------------------------------------------------------- // // function: setTSID // // Synopsis: sets the value of TSID for a FaxDevice // // Arguments: [objFaxDevices] - FaxDevices object pointing to the list of devices on the server // [lDeviceId] - Device Id of the device to be set // [strTSID] - value of the TSID // // Returns: bool: true if passed successfully // //---------------------------------------------------------------------------- static bool setTSID(FAXCOMEXLib.IFaxDevices objFaxDevices, int iDeviceId, string strTSID) { FaxDevice objFaxDevice = null; if (objFaxDevices != null && String.IsNullOrEmpty(strTSID) == false) { objFaxDevice = objFaxDevices.get_ItemById(iDeviceId); //set TSID objFaxDevice.TSID = strTSID; //Save it objFaxDevice.Save(); System.Console.WriteLine("New TSID is set"); return(true); } System.Console.WriteLine("setTSID: Parameter is NULL"); return(false); }
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"); } }