Exemplo n.º 1
0
        /// <summary>
        /// Main entry point of the service.
        /// </summary>
        /// <returns></returns>
        protected override ServiceOutcome DoWork()
        {
            BasicReportServiceService panamaService = new BasicReportServiceService();
            BasicReportRequest        panamaReport  = new BasicReportRequest();

            // Initalize Panama sevice parameters.
            InitalizePanamaService(panamaService);

            if (_endPointLocation != null && _endPointLocation != "")
            {
                panamaService.Url = _endPointLocation + "/V4/BasicReportService";
            }

            _retrievelDate = DateTime.Now.AddDays(-1);
            // Initalize date parameters.
            panamaReport.startDate          = _retrievelDate;
            panamaReport.endDate            = _retrievelDate;
            panamaReport.dateRangeSpecified = false;
            panamaReport.endDateSpecified   = true;
            panamaReport.startDateSpecified = true;


            // http://searchmarketing.yahoo.com/developer/docs/V4/reference/reportDetails.php
            panamaReport.reportType = BasicReportType.AdvancedAdKeywordPerformanceByDay;

            panamaReport.reportTypeSpecified = true;
            panamaReport.reportName          = "Test";


            // Initalzie report FileOutputFormat to XML.
            FileOutputFormat reportFileFormat = new FileOutputFormat();

            reportFileFormat.fileOutputType          = FileOutputType.XML;
            reportFileFormat.fileOutputTypeSpecified = true;

            Retrieve(panamaService, panamaReport, reportFileFormat);

            return(ServiceOutcome.Success);
        }
Exemplo n.º 2
0
        /*=========================*/
        #endregion

        #region

        private void InitalizePanamaService(BasicReportServiceService panamaService)
        {
            panamaService.masterAccountIDValue      = new Easynet.Edge.Services.Yahoo.Panama.PanamaReportServiceV4.masterAccountID();
            panamaService.masterAccountIDValue.Text = new String[] { PanamaMasterAccountID };
            panamaService.licenseValue                         = new Easynet.Edge.Services.Yahoo.Panama.PanamaReportServiceV4.license();
            panamaService.licenseValue.Text                    = new String[] { License };
            panamaService.SecurityValue                        = new Easynet.Edge.Services.Yahoo.Panama.PanamaReportServiceV4.Security();
            panamaService.SecurityValue.UsernameToken          = new Easynet.Edge.Services.Yahoo.Panama.PanamaReportServiceV4.UsernameToken();
            panamaService.SecurityValue.UsernameToken.Username = Username;
            panamaService.SecurityValue.UsernameToken.Password = Password;

            try
            {
                if (_endPointLocation == null)
                {
                    _locationService     = new LocationServiceService();
                    _locationService.Url = (string)(EWS_ACCESS_HTTP_PROTOCOL + "://" + EWS_LOCATION_SERVICE_ENDPOINT + "/services/V4/LocationService");

                    _locationService.masterAccountIDValue      = new PanamaLocationServiceV4.masterAccountID();
                    _locationService.masterAccountIDValue.Text = new String[] { PanamaMasterAccountID };

                    _locationService.SecurityValue = new PanamaLocationServiceV4.Security();
                    _locationService.SecurityValue.UsernameToken          = new PanamaLocationServiceV4.UsernameToken();
                    _locationService.SecurityValue.UsernameToken.Username = Username;
                    _locationService.SecurityValue.UsernameToken.Password = Password;

                    _locationService.licenseValue      = new PanamaLocationServiceV4.license();
                    _locationService.licenseValue.Text = new String[] { License };

                    //use LocationService to get the address prefix for the rest of the services
                    _endPointLocation = _locationService.getMasterAccountLocation();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the data from Panama to and save the data into xml file.
        /// </summary>
        /// <param name="panamaService"></param>
        /// <param name="panamaReport"></param>
        /// <param name="reportFileFormat"></param>
        private void Retrieve(BasicReportServiceService panamaService, BasicReportRequest panamaReport, FileOutputFormat reportFileFormat)
        {
            // Get report ID from Panama.
            long reportID = panamaService.addReportRequestForAccountID(PanamaAccountID, panamaReport);

            if (reportID == 0)
            {
                throw new Exception("Can't get data from Panama, report id = 0.");
            }

            // Get report url.
            string reportStatus = panamaService.getReportOutputUrl(reportID, reportFileFormat);

            try
            {
                while (reportStatus == ReportPending)
                {
                    reportStatus = panamaService.getReportOutputUrl(reportID, reportFileFormat);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            string reportUrl = reportStatus;

            //if (url == "failed")
            //{
            //    throw new Exception("Panama return invaild url, report creation failed.");
            //}

            string fileName = WriteResultToFile(reportUrl, _retrievelDate, true);

            // Insert the data to DB.
            SaveFilePathToDB(PanamaServiceType, fileName);
        }