コード例 #1
0
        public void TestDocumentCensorJobCommit()
        {
            try
            {
                SubmitDocumentCensorJobRequest request = new SubmitDocumentCensorJobRequest(bucket);
                request.SetUrl("https://calibre-ebook.com/downloads/demos/demo.docx");
                request.SetDetectType("P**n,Terrorism");
                SubmitCensorJobResult result = QCloudServer.Instance().cosXml.SubmitDocumentCensorJob(request);
                string id = result.censorJobsResponse.JobsDetail.JobId;
                Assert.NotNull(id);
                Assert.AreEqual(200, result.httpCode);
                // 等待审核任务跑完
                Thread.Sleep(50000);
                GetDocumentCensorJobRequest getRequest = new GetDocumentCensorJobRequest(bucket, id);
                GetDocumentCensorJobResult  getResult  = QCloudServer.Instance().cosXml.GetDocumentCensorJob(getRequest);
                Assert.AreEqual(200, getResult.httpCode);
                // 参数检查
                Assert.NotNull(getResult.resultStruct.JobsDetail.State);
                Assert.NotNull(getResult.resultStruct.JobsDetail.JobId);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Code);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Message);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Suggestion);
                Assert.NotNull(getResult.resultStruct.JobsDetail.CreationTime);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Url);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageCount);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Labels);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PornInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PornInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PornInfo.Score);

                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PoliticsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PoliticsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.Labels.PoliticsInfo.Score);
                 */
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.Url);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.Text);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PageNumber);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.SheetNumber);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.SubLabel);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.Score);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.OcrResults);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.OcrResults.Text);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PornInfo.OcrResults.Keywords);

                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.SubLabel);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.Score);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.OcrResults);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.OcrResults.Text);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.OcrResults.Keywords);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.ObjectResults);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PageSegment.Results.PoliticsInfo.ObjectResults.Name);
                 */
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }
コード例 #2
0
        public void TestAudioCensorJob()
        {
            try
            {
                SubmitAudioCensorJobRequest request = new SubmitAudioCensorJobRequest(bucket);
                request.SetCensorObject(audioKey);
                request.SetDetectType("P**n,Terrorism");
                SubmitCensorJobResult result = QCloudServer.Instance().cosXml.SubmitAudioCensorJob(request);
                string id = result.censorJobsResponse.JobsDetail.JobId;
                Assert.NotNull(id);
                Assert.AreEqual(200, result.httpCode);
                // get audio censor job
                Thread.Sleep(60000);

                GetAudioCensorJobRequest getRequest = new GetAudioCensorJobRequest(bucket, id);
                GetAudioCensorJobResult  getResult  = QCloudServer.Instance().cosXml.GetAudioCensorJob(getRequest);
                Assert.AreEqual(200, getResult.httpCode);
                // 成功时不返回
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Code);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Message);
                Assert.NotNull(getResult.resultStruct.JobsDetail.JobId);
                Assert.NotNull(getResult.resultStruct.JobsDetail.State);
                Assert.NotNull(getResult.resultStruct.JobsDetail.CreationTime);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Object);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Result);
                Assert.NotNull(getResult.resultStruct.JobsDetail.AudioText);

                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.Score);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.Label);

                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.Score);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.Label);

                Assert.NotNull(getResult.resultStruct.JobsDetail.Section);

                Assert.NotZero(getResult.resultStruct.JobsDetail.Section.Count);
                for (int i = 0; i < getResult.resultStruct.JobsDetail.Section.Count; i++)
                {
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].Url);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].OffsetTime);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].Duration);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].Text);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.HitFlag);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.Score);
                    // 没有命中关键词时不返回
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.Keywords);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].TerrorismInfo);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].TerrorismInfo.HitFlag);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].TerrorismInfo.Score);
                    // 没有命中关键词时不返回
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].TerrorismInfo.Keywords);
                }
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }
コード例 #3
0
        public void TestTextCensorJobCommit()
        {
            try
            {
                SubmitTextCensorJobRequest request = new SubmitTextCensorJobRequest(bucket);
                request.SetCensorObject(textKey);
                request.SetDetectType("P**n,Terrorism");
                SubmitCensorJobResult result = QCloudServer.Instance().cosXml.SubmitTextCensorJob(request);
                string id = result.censorJobsResponse.JobsDetail.JobId;
                Assert.NotNull(id);
                Assert.AreEqual(200, result.httpCode);
                // 等待审核任务跑完
                Thread.Sleep(30000);
                GetTextCensorJobRequest getRequest = new GetTextCensorJobRequest(bucket, id);
                GetTextCensorJobResult  getResult  = QCloudServer.Instance().cosXml.GetTextCensorJob(getRequest);
                Assert.AreEqual(200, getResult.httpCode);
                // 只有失败时返回
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Code);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Message);
                Assert.NotNull(getResult.resultStruct.JobsDetail.JobId);
                Assert.NotNull(getResult.resultStruct.JobsDetail.State);
                Assert.NotNull(getResult.resultStruct.JobsDetail.CreationTime);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Object);
                Assert.NotNull(getResult.resultStruct.JobsDetail.SectionCount);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Result);

                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.Count);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.Count);

                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo.Count);
                 */
                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo.Count);
                 */
                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.IllegalInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.IllegalInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.IllegalInfo.Count);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AbuseInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AbuseInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AbuseInfo.Count);
                 */

                Assert.NotNull(getResult.resultStruct.JobsDetail.Section);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Section.Count);
                for (int i = 0; i < getResult.resultStruct.JobsDetail.Section.Count; i++)
                {
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].StartByte);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo);
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.Code);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.HitFlag);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.Score);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PornInfo.Keywords);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].TerrorismInfo);
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].PoliticsInfo);
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].AdsInfo);
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].IllegalInfo);
                    //Assert.NotNull(getResult.resultStruct.JobsDetail.Section[i].AbuseInfo);
                }
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }
コード例 #4
0
        public void TestVideoCensorJobCommit()
        {
            try
            {
                SubmitVideoCensorJobRequest request = new SubmitVideoCensorJobRequest(bucket);
                request.SetCensorObject(videoKey);
                request.SetDetectType("P**n,Terrorism");
                request.SetSnapshotMode("Average");
                request.SetSnapshotCount("100");
                SubmitCensorJobResult result = QCloudServer.Instance().cosXml.SubmitVideoCensorJob(request);
                Assert.NotNull(result.censorJobsResponse.JobsDetail.JobId);
                Assert.NotNull(result.censorJobsResponse.JobsDetail.State);
                Assert.NotNull(result.censorJobsResponse.JobsDetail.CreationTime);
                string id = result.censorJobsResponse.JobsDetail.JobId;
                Thread.Sleep(120000);

                // get video censor job
                GetVideoCensorJobRequest getRequest = new GetVideoCensorJobRequest(bucket, id);
                GetVideoCensorJobResult  getResult  = QCloudServer.Instance().cosXml.GetVideoCensorJob(getRequest);
                Assert.AreEqual(200, getResult.httpCode);

                Assert.NotNull(getResult.resultStruct.JobsDetail);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Code);
                //Assert.NotNull(getResult.resultStruct.JobsDetail.Message);
                Assert.NotNull(getResult.resultStruct.JobsDetail.JobId);
                Assert.NotNull(getResult.resultStruct.JobsDetail.State);
                Assert.NotNull(getResult.resultStruct.JobsDetail.CreationTime);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Object);
                Assert.NotNull(getResult.resultStruct.JobsDetail.SnapshotCount);
                Assert.NotNull(getResult.resultStruct.JobsDetail.Result);

                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.PornInfo.Count);

                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.HitFlag);
                Assert.NotNull(getResult.resultStruct.JobsDetail.TerrorismInfo.Count);

                /*
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.PoliticsInfo.Count);
                 *
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo.HitFlag);
                 * Assert.NotNull(getResult.resultStruct.JobsDetail.AdsInfo.Count);
                 */
                Assert.NotZero(getResult.resultStruct.JobsDetail.Snapshot.Count);
                for (int i = 0; i < getResult.resultStruct.JobsDetail.Snapshot.Count; i++)
                {
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i]);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].Url);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].Text);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].SnapshotTime);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PornInfo);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PornInfo.HitFlag);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PornInfo.Score);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PornInfo.Label);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PornInfo.SubLabel);

                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].TerrorismInfo);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].TerrorismInfo.HitFlag);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].TerrorismInfo.Score);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].TerrorismInfo.Label);
                    Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].TerrorismInfo.SubLabel);

                    /*
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PoliticsInfo);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PoliticsInfo.HitFlag);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PoliticsInfo.Score);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PoliticsInfo.Label);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].PoliticsInfo.SubLabel);
                     *
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].AdsInfo);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].AdsInfo.HitFlag);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].AdsInfo.Score);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].AdsInfo.Label);
                     * Assert.NotNull(getResult.resultStruct.JobsDetail.Snapshot[i].AdsInfo.SubLabel);
                     */
                }
                Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection);

                /*
                 * Assert.NotZero(getResult.resultStruct.JobsDetail.AudioSection.Count);
                 * for(int i = 0; i < getResult.resultStruct.JobsDetail.AudioSection.Count; i++)
                 * {
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i]);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].Url);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].OffsetTime);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].Duration);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].Text);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PoliticsInfo);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PoliticsInfo.HitFlag);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PoliticsInfo.Score);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PoliticsInfo.Keywords);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PornInfo);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PornInfo.HitFlag);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PornInfo.Score);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].PornInfo.Keywords);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].TerrorismInfo);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].TerrorismInfo.HitFlag);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].TerrorismInfo.Score);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].TerrorismInfo.Keywords);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].AdsInfo);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].AdsInfo.HitFlag);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].AdsInfo.Score);
                 *  Assert.NotNull(getResult.resultStruct.JobsDetail.AudioSection[i].AdsInfo.Keywords);
                 * }
                 */
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }