// >> START recordings-downloader-step-1
        public static void authentication()
        {
            //OAuth
            clientId     = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_ID");
            clientSecret = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_SECRET");
            // orgRegion values example: us_east_1
            string orgRegion = Environment.GetEnvironmentVariable("GENESYS_CLOUD_REGION");

            // Set Region
            PureCloudRegionHosts region = Enum.Parse <PureCloudRegionHosts>(orgRegion);

            Configuration.Default.ApiClient.setBasePath(region);

            // >> START recordings-downloader-step-3
            // >> START recordings-downloader-step-2
            // Configure SDK Settings
            var accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);

            Configuration.Default.AccessToken = accessTokenInfo.AccessToken;
            // >> END recordings-downloader-step-2
            // >> END recordings-downloader-step-3
            // >> END recordings-downloader-step-1

            // >> START recordings-downloader-step-4
            // Create API instances
            conversationsApi = new ConversationsApi();
            recordingApi     = new RecordingApi();
            // >> END recordings-downloader-step-4

            Console.WriteLine("Working...");
        }
Exemple #2
0
        public static void authentication()
        {
            //OAuth input
            Console.Write("Enter Client ID: ");
            clientId = Console.ReadLine();
            Console.Write("Enter Client Secret: ");
            clientSecret = Console.ReadLine();

            // Get the Date Interval
            Console.Write("Enter Date Interval (YYYY-MM-DDThh:mm:ss/YYYY-MM-DDThh:mm:ss): ");
            dates = Console.ReadLine();

            Console.WriteLine("Working...");

            //Set Region
            PureCloudRegionHosts region = PureCloudRegionHosts.us_east_1;

            Configuration.Default.ApiClient.setBasePath(region);

            // Configure SDK Settings
            var accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);

            Configuration.Default.AccessToken = accessTokenInfo.AccessToken;

            // Create API instances
            conversationsApi = new ConversationsApi();
            recordingApi     = new RecordingApi();
        }
        /// <summary>
        /// Generate recordingId for every conversationId
        /// </summary>
        /// <param name="conversationId"></param>
        /// <returns></returns>
        private static void getRecordingMetaData(string conversationId)
        {
            RecordingApi     recordingApi   = new RecordingApi();
            List <Recording> recordingsData = recordingApi.GetConversationRecordingmetadata(conversationId);

            // Pass recordingsMetadata to a function
            iterateRecordingsData(recordingsData);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            // OAuth input
            Console.Write("Enter Client ID: ");
            string clientId = Console.ReadLine();

            Console.Write("Enter Client Secret: ");
            string clientSecret = Console.ReadLine();

            // Get the Date Interval
            Console.Write("Enter Date Interval (YYYY-MM-DDThh:mm:ss/YYYY-MM-DDThh:mm:ss): ");
            string interval = Console.ReadLine();

            Console.WriteLine("Working...");

            // Configure SDK Settings
            string accessToken = GetToken(clientId, clientSecret);

            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;

            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();
            RecordingApi     recordingApi     = new RecordingApi();

            // Get Conversation IDs and corresponding Media Type within a date interval
            Dictionary <string, AnalyticsSession.MediaTypeEnum> conversationsMapIDType = GetConversations(interval, conversationsApi);

            // Use the Conversation IDs and request a batch download for the conversations
            string jobId = RequestBatchDownload(conversationsMapIDType.Keys.ToList(), recordingApi);

            // Get all conversations with recordings
            List <BatchDownloadJobResult> jobResults = GetJobResults(jobId, recordingApi);

            // Download all the recordings and separate into folders named after the Conversation ID
            Console.WriteLine("Currently Downloading...");
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            path = path.Substring(0, path.LastIndexOf("bin"));

            foreach (var job in jobResults)
            {
                // Create the directories for each unique Conversation IDs
                System.IO.Directory.CreateDirectory(path + "\\recordings\\" + job.ConversationId);

                // Determine the file extension to assign
                string extension = GetExtensionFromMediaType(conversationsMapIDType[job.ConversationId]);

                DownloadRecording(job.ResultUrl, path + "recordings\\" + job.ConversationId, extension);
            }

            // Final Output
            Console.WriteLine("DONE");

            if (Debugger.IsAttached)
            {
                Console.ReadKey();
            }
        }
 private void SetupApis()
 {
     Error = new ErrorApi {
         Client = this
     };
     Account = new AccountApi {
         Client = this
     };
     Application = new ApplicationApi {
         Client = this
     };
     AvailableNumber = new AvailableNumberApi {
         Client = this
     };
     Bridge = new BridgeApi {
         Client = this
     };
     Domain = new DomainApi {
         Client = this
     };
     Call = new CallApi {
         Client = this
     };
     Conference = new ConferenceApi {
         Client = this
     };
     Message = new MessageApi {
         Client = this
     };
     NumberInfo = new NumberInfoApi {
         Client = this
     };
     PhoneNumber = new PhoneNumberApi {
         Client = this
     };
     Recording = new RecordingApi {
         Client = this
     };
     Transcription = new TranscriptionApi {
         Client = this
     };
     Media = new MediaApi {
         Client = this
     };
     Endpoint = new EndpointApi {
         Client = this
     };
     V2 = new ApiV2 {
         Message = new Bandwidth.Net.ApiV2.MessageApi {
             Client = this
         }
     };
 }
Exemple #6
0
        protected override void _TurnOn()
        {
            Utility.AppConfig config = Utility.AppConfig.Instance;
            config.LoadConfig(MEHoloConstant.NetworkConfigFile);
            serverHost = Utility.AppConfig.Instance.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Host", "127.0.0.1");

            ui.TurnOn();

            Debug.Log("App[" + MEHoloEntrance.Instance.AppID + "] Get Storage From " + serverHost);
            assetAPI     = new AssetApi("http://" + serverHost, 80);
            recordingAPI = new RecordingApi("http://" + serverHost, 80);

            downloadWorker = new BackgroundWorker();
            downloadWorker.StartWorker();
        }
Exemple #7
0
        /// <summary>
        /// Get the results of the batch job with recording urls
        /// </summary>
        /// <param name="jobId"></param>
        /// <param name="api"></param>
        /// <returns></returns>
        private static List <BatchDownloadJobResult> GetJobResults(string jobId, RecordingApi api)
        {
            int expectedCount = (int)api.GetRecordingBatchrequest(jobId).ExpectedResultCount;
            int resultCount   = 0;

            // Concurrently update every 5 seconds if job has finished processing.
            do
            {
                Thread.Sleep(5000);
                resultCount = (int)api.GetRecordingBatchrequest(jobId).ResultCount;
                Console.WriteLine("Processed: " + resultCount + " / " + expectedCount);
            } while (resultCount < expectedCount);

            // Filter the list to only include those with recording urls
            return(api.GetRecordingBatchrequest(jobId).Results.Where(x => x.ResultUrl != null).ToList());
        }
Exemple #8
0
        /// <summary>
        /// Request a job to download recordings assosciated with the specified conversations
        /// </summary>
        /// <param name="conversationIDs"></param>
        /// <param name="api"></param>
        /// <returns></returns>
        private static string RequestBatchDownload(List <string> conversationIDs, RecordingApi api)
        {
            // Convert List of Strings to List of BatchDownloadRequests
            List <BatchDownloadRequest> batchRequest = new List <BatchDownloadRequest>();

            foreach (string id in conversationIDs)
            {
                BatchDownloadRequest batchDownloadRequest = new BatchDownloadRequest(ConversationId: id);
                batchRequest.Add(batchDownloadRequest);
            }

            // Create the batch job with the request list
            BatchDownloadJobSubmission batchSubmission = new BatchDownloadJobSubmission(BatchDownloadRequestList: batchRequest);

            return(api.PostRecordingBatchrequests(batchSubmission).Id);
        }
        /// <summary>
        /// Plot conversationId and recordingId to request for batchDownload Recordings
        /// </summary>
        /// <param name="iterateRecordings"></param>
        /// <returns></returns>
        private static void getSpecificRecordings(Recording iterateRecordings)
        {
            List <BatchDownloadRequest> batchRequest         = new List <BatchDownloadRequest>();
            BatchDownloadRequest        batchDownloadRequest = new BatchDownloadRequest(ConversationId: iterateRecordings.ConversationId, RecordingId: iterateRecordings.Id);

            batchRequest.Add(batchDownloadRequest);

            // Create the batch job with the request list
            BatchDownloadJobSubmission batchSubmission = new BatchDownloadJobSubmission(BatchDownloadRequestList: batchRequest);

            BatchDownloadJobSubmissionResult recordingBatchRequestId = new BatchDownloadJobSubmissionResult();
            RecordingApi recordingApi = new RecordingApi();

            recordingBatchRequestId = recordingApi.PostRecordingBatchrequests(batchSubmission);

            recordingStatus(recordingBatchRequestId);
        }
        protected override void _TurnOn()
        {
            Utility.AppConfig config = Utility.AppConfig.Instance;
            config.LoadConfig(MEHoloConstant.NetworkConfigFile);
            serverHost = Utility.AppConfig.Instance.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Host", "127.0.0.1:8848");
            int.TryParse(Utility.AppConfig.Instance.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Port", "8848"), out serverPort);

            ui.TurnOn();

            Debug.Log("App[" + MEHoloEntrance.Instance.AppID + "] Get Storage From " + serverHost);
            //下面的暂时只能使用https:// 无法去掉
            assetAPI     = new AssetApi(serverHost, serverPort);
            recordingAPI = new RecordingApi(serverHost, serverPort);
            directorAPI  = new DirectorApi(serverHost, serverPort);

            downloadWorker = new BackgroundWorker();
            downloadWorker.StartWorker();
        }
        /// <summary>
        /// Check status of generating url for downloading, if the result is still unavailble. The function will be called again until the result is available.
        /// </summary>
        /// <param name="recordingBatchRequestId"></param>
        /// <returns></returns>
        private static void recordingStatus(BatchDownloadJobSubmissionResult recordingBatchRequestId)
        {
            BatchDownloadJobStatusResult getRecordingBatchRequestData = new BatchDownloadJobStatusResult();
            RecordingApi recordingApi = new RecordingApi();

            getRecordingBatchRequestData = recordingApi.GetRecordingBatchrequest(recordingBatchRequestId.Id);

            if (getRecordingBatchRequestData.ExpectedResultCount == getRecordingBatchRequestData.ResultCount)
            {
                // Pass the getRecordingBatchRequestData to getExtension function
                getExtension(getRecordingBatchRequestData);
            }
            else
            {
                Thread.Sleep(5000);
                recordingStatus(recordingBatchRequestId);
            }
        }
Exemple #12
0
 public void Init()
 {
     instance = new RecordingApi();
 }