Exemple #1
0
        public string GetReportFax(string userName, string password, string faxID)
        {
            string status = string.Empty;

            switch (Configuration.Config.Environment())
            {
            case Configuration.TIMEnvironment.Development:
            case Configuration.TIMEnvironment.Demo:
            case Configuration.TIMEnvironment.Test:
                Array     values            = System.Enum.GetValues(typeof(FaxResult));
                Random    random            = new Random();
                int       randomValueCustom = GetRandomValue(values);
                FaxResult randomStatus      = (FaxResult)values.GetValue(randomValueCustom);
                status = randomStatus.ToString();
                break;

            case Configuration.TIMEnvironment.Production:
            {
                Faxolution201203Client client = new Faxolution201203Client();
                reportRequest          report = new reportRequest();
                report.username = userName;
                report.password = password;
                report.jobId    = faxID;
                reportResponse reportResponse = client.getFaxReport(report);

                status = reportResponse.faxRecipient[0].status;
            }
            break;

            default: break;
            }
            return(status);
        }
Exemple #2
0
        public virtual string SendFax(string userName, string password, string faxNumber, string fileName, byte[] fileContent)
        {
            string faxID = string.Empty;

            try
            {
                faxNumber = faxNumber.Replace("+", "00")
                            .Replace("(", string.Empty)
                            .Replace(")", string.Empty)
                            .Replace("/", string.Empty)
                            .Replace("-", string.Empty)
                            .Replace(" ", string.Empty).Trim();
                if (!faxNumber.StartsWith("00"))
                {
                    faxNumber = "00" + faxNumber;
                }
                switch (Configuration.Config.Environment())
                {
                case Configuration.TIMEnvironment.Development:
                case Configuration.TIMEnvironment.Demo:
                case Configuration.TIMEnvironment.Test:
                    faxID = Guid.NewGuid().ToString();
                    break;

                case Configuration.TIMEnvironment.Production:
                {
                    Faxolution201203Client client     = new Faxolution201203Client();
                    jobRequest             jobRequest = new jobRequest();
                    // Authentication:
                    jobRequest.username = userName;
                    jobRequest.password = password;
                    // Add recipient to request:
                    jobRequest.faxRecipient = new faxRecipient[1];

                    faxRecipient rcpt = new faxRecipient();
                    rcpt.number = faxNumber;

                    jobRequest.faxRecipient[0] = rcpt;
                    // Add document to request:

                    documentWithData[] documentList = new documentWithData[1];

                    documentWithData document = new documentWithData();
                    document.name   = fileName;
                    document.data   = fileContent;
                    documentList[0] = document;

                    jobRequest.document = documentList;

                    // Add options to request:
                    options options = new options();
                    options.resolution   = resolution.HIGH;
                    options.billingCode  = "";
                    options.jobReference = "";
                    //options.header = "Fax from " + options.csid + " to " + faxNumber;
                    jobRequest.options    = options;
                    jobRequest.reportMail = new reportMail();
                    jobRequest.reportMail.failureAddress = "*****@*****.**";
                    jobRequest.reportMail.successAddress = "*****@*****.**";
                    jobResponse jobResponse = client.sendFaxJob(jobRequest);
                    faxID = jobResponse.jobId;
                }
                break;

                default: break;
                }

                return(faxID);
            }
            catch (Exception ex)
            {
                T2P._2015.Cross.Utility.ExceptionHandling.ExceptionHelper.GetDetailMessageAndLog(ex);
                return(faxID);
            }
        }