private static void internalEventHandler(FeedbackInput sender, ElementGroup group, object value, Func <ButtonPressedEvent, ColorCode> handler) { var ret = new ButtonPressedEvent() { Sender = sender, Value = value, ComponentGroup = group, SystemTime = DateTime.Now, UnityTime = new Time() }; switch (handler(ret)) { case ColorCode.Success: group.VisibleText.color = SuccessColor; break; case ColorCode.Hint: group.VisibleText.color = HintColor; break; default: group.VisibleText.color = MistakeColor; break; } }
public ActionResult CreateFeedBack([FromBody] FeedbackInput data) { var apiRep = new APIResponse(); apiRep.Data = _feedbackService.Create(data); return(Ok(apiRep)); }
public ActionResult Edit(FeedbackInput input) { if (!ModelState.IsValid) { return View("Create", input); } var feedback = repo.Get(input.Id); feedback.Comments = HtmlUtil.SanitizeHtml(input.Comments); repo.Save(); return Json(new { }); }
public ActionResult Edit(FeedbackInput input) { if (!ModelState.IsValid) { return(View("Create", input)); } var feedback = repo.Get(input.Id); feedback.Comments = HtmlUtil.SanitizeHtml(input.Comments); repo.Save(); return(Json(new { })); }
public Feedback Create(FeedbackInput input) { var feedback = new Feedback { Description = input.Description, Email = input.Email, OrderId = input.OrderId, Title = input.Title, IsRead = false, CreatedDate = DateTime.Now }; _Feedbacks.InsertOne(feedback); return(feedback); }
public ActionResult Create(FeedbackInput input) { if (!ModelState.IsValid) { return View(input); } input.Comments = HtmlUtil.SanitizeHtml(input.Comments); var feedback = new Feedback { Comments = input.Comments }; feedback = repo.Insert(feedback); repo.Save(); Session["lastFeedback"] = feedback.Id; return Json(new { }); }
/// <summary> /// Add feedback. /// /// Adds feedback in the form of _labels_ from a subject-matter expert (SME) to a governing document. /// **Important:** Feedback is not immediately incorporated into the training model, nor is it guaranteed to be /// incorporated at a later date. Instead, submitted feedback is used to suggest future updates to the training /// model. /// </summary> /// <param name="feedbackData">An object that defines the feedback to be submitted.</param> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="FeedbackReturn" />FeedbackReturn</returns> public FeedbackReturn AddFeedback(FeedbackInput feedbackData, Dictionary <string, object> customData = null) { if (feedbackData == null) { throw new ArgumentNullException(nameof(feedbackData)); } if (string.IsNullOrEmpty(VersionDate)) { throw new ArgumentNullException("versionDate cannot be null."); } FeedbackReturn result = null; try { IClient client = this.Client; if (_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/feedback"); restRequest.WithArgument("version", VersionDate); restRequest.WithBody <FeedbackInput>(feedbackData); if (customData != null) { restRequest.WithCustomData(customData); } restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=AddFeedback"); result = restRequest.As <FeedbackReturn>().Result; if (result == null) { result = new FeedbackReturn(); } result.CustomData = restRequest.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
public ActionResult Create(FeedbackInput input) { if (!ModelState.IsValid) { return(View(input)); } input.Comments = HtmlUtil.SanitizeHtml(input.Comments); var feedback = new Feedback { Comments = input.Comments }; feedback = repo.Insert(feedback); repo.Save(); Session["lastFeedback"] = feedback.Id; return(Json(new { })); }
public override IEnumerator RunTest() { LogSystem.InstallDefaultReactors(); contractAFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/contract_A.pdf"; contractBFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/contract_B.pdf"; tableFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/TestTable.pdf"; string objectStorageCredentialsInputFilepath = "../sdk-credentials/cloud-object-storage-credentials-input.json"; string objectStorageCredentialsOutputFilepath = "../sdk-credentials/cloud-object-storage-credentials-output.json"; #region Get Credentials VcapCredentials vcapCredentials = new VcapCredentials(); fsData data = null; string result = null; string credentialsFilepath = "../sdk-credentials/credentials.json"; // Load credentials file if it exists. If it doesn't exist, don't run the tests. if (File.Exists(credentialsFilepath)) { result = File.ReadAllText(credentialsFilepath); } else { yield break; } // Add in a parent object because Unity does not like to deserialize root level collection types. result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES"); // Convert json to fsResult fsResult r = fsJsonParser.Parse(result, out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Convert fsResult to VcapCredentials object obj = vcapCredentials; r = _serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Set credentials from imported credntials Credential credential = vcapCredentials.GetCredentialByname("compare-comply-sdk")[0].Credentials; _url = credential.Url.ToString(); // Create credential and instantiate service TokenOptions tokenOptions = new TokenOptions() { IamApiKey = credential.IamApikey }; #endregion Credentials credentials = new Credentials(tokenOptions, credential.Url); // Wait for tokendata while (!credentials.HasIamTokenData()) { yield return(null); } compareComply = new CompareComply(credentials); compareComply.VersionDate = versionDate; byte[] contractA = File.ReadAllBytes(contractAFilepath); byte[] contractB = File.ReadAllBytes(contractBFilepath); byte[] table = File.ReadAllBytes(tableFilepath); byte[] objectStorageCredentialsInputData = File.ReadAllBytes(objectStorageCredentialsInputFilepath); byte[] objectStorageCredentialsOutputData = File.ReadAllBytes(objectStorageCredentialsOutputFilepath); compareComply.ConvertToHtml(OnConvertToHtml, OnFail, contractA, fileContentType: "application/pdf"); while (!convertToHtmlTested) { yield return(null); } compareComply.ClassifyElements(OnClassifyElements, OnFail, contractA); while (!classifyElementsTested) { yield return(null); } compareComply.ExtractTables(OnExtractTables, OnFail, table); while (!extractTablesTested) { yield return(null); } compareComply.CompareDocuments(OnCompareDocuments, OnFail, contractA, contractB, file1ContentType: "application/pdf", file2ContentType: "application/pdf"); while (!compareDocumentsTested) { yield return(null); } DateTime before = new DateTime(2018, 11, 15); DateTime after = new DateTime(2018, 11, 14); compareComply.ListFeedback( successCallback: OnListFeedback, failCallback: OnFail, feedbackType: "element_classification", before: before, after: after, documentTitle: "unity-test-feedback-doc", modelId: "contracts", modelVersion: "2.0.0", categoryRemoved: "Responsibilities", categoryAdded: "Amendments", categoryNotChanged: "Audits", typeRemoved: "End User:Exclusion", typeAdded: "Disclaimer:Buyer", typeNotChanged: "Obligation:IBM", pageLimit: 1 ); while (!listFeedbackTested) { yield return(null); } #region Feedback Data FeedbackInput feedbackData = new FeedbackInput() { UserId = "user_id_123x", Comment = "Test feedback comment", FeedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, Text = "1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing infrastructure.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = "Responsibilities", ProvenanceIds = new List <string>() { } }, new Category() { Label = "Amendments", ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = "Responsibilities", }, new Category() { Label = "Audits" } } } } }; #endregion compareComply.AddFeedback( successCallback: OnAddFeedback, failCallback: OnFail, feedbackData: feedbackData ); while (!addFeedbackTested) { yield return(null); } // temporary fix for a bug requiring `x-watson-metadata` header Dictionary <string, object> customData = new Dictionary <string, object>(); Dictionary <string, string> customHeaders = new Dictionary <string, string>(); customHeaders.Add("x-watson-metadata", "customer_id=sdk-test-customer-id"); customData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, customHeaders); compareComply.GetFeedback( successCallback: OnGetFeedback, failCallback: OnFail, feedbackId: feedbackId, modelId: "contracts", customData: customData ); while (!getFeedbackTested) { yield return(null); } compareComply.DeleteFeedback( successCallback: OnDeleteFeedback, failCallback: OnFail, feedbackId: feedbackId, modelId: "contracts" ); while (!deleteFeedbackTested) { yield return(null); } compareComply.ListBatches( successCallback: OnListBatches, failCallback: OnFail ); while (!listBatchesTested) { yield return(null); } compareComply.CreateBatch( successCallback: OnCreateBatch, failCallback: OnFail, function: "html_conversion", inputCredentialsFile: objectStorageCredentialsInputData, inputBucketLocation: "us-south", inputBucketName: "compare-comply-integration-test-bucket-input", outputCredentialsFile: objectStorageCredentialsOutputData, outputBucketLocation: "us-south", outputBucketName: "compare-comply-integration-test-bucket-output" ); while (!createBatchTested) { yield return(null); } compareComply.GetBatch( successCallback: OnGetBatch, failCallback: OnFail, batchId: batchId ); while (!getBatchTestsed) { yield return(null); } compareComply.UpdateBatch( successCallback: OnUpdateBatch, failCallback: OnFail, batchId: batchId, action: "rescan", modelId: "contracts" ); while (!updateBatchTested) { yield return(null); } Log.Debug("TestCompareComplyV1.RunTests()", "Compare and Comply integration tests complete!"); }
public void Feedback_Success() { DateTime before = DateTime.Now; DateTime after = new DateTime(2018, 11, 13); var ListFeedbackResult = service.ListFeedback( feedbackType: "element_classification", before: before, after: after, documentTitle: "doc title", modelId: "contracts", modelVersion: "11.00", categoryRemoved: "categoryRemoved", categoryAdded: "categoryAdded", categoryNotChanged: "categoryUnchanged", typeRemoved: "nature:party", typeAdded: "nature:party", typeNotChanged: "nature:party", pageLimit: 3, sort: "sort" ); FeedbackInput feedbackData = new FeedbackInput() { UserId = "user_id_123x", Comment = "Test feedback comment", FeedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, Text = "1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing infrastructure.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnum.RESPONSIBILITIES, ProvenanceIds = new List <string>() { } }, new Category() { Label = Category.LabelEnum.AMENDMENTS, ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnum.RESPONSIBILITIES, }, new Category() { Label = Category.LabelEnum.AUDITS } } } } }; var addFeedbackResult = service.AddFeedback(feedbackData); string feedbackId = addFeedbackResult.FeedbackId; // temporary fix for a bug requiring `x-watson-metadata` header Dictionary <string, object> customData = new Dictionary <string, object>(); Dictionary <string, string> customHeaders = new Dictionary <string, string>(); customHeaders.Add("x-watson-metadata", "customer_id=sdk-test-customer-id"); customData.Add(Constants.CUSTOM_REQUEST_HEADERS, customHeaders); var getFeedbackResult = service.GetFeedback(feedbackId, customData: customData); var deleteFeedbackResult = service.DeleteFeedback(feedbackId); Assert.IsNotNull(deleteFeedbackResult); Assert.IsNotNull(getFeedbackResult); Assert.IsNotNull(addFeedbackResult); Assert.IsNotNull(ListFeedbackResult); }
private IEnumerator Examples() { contractAFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/contract_A.pdf"; contractBFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/contract_B.pdf"; tableFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/compare-comply/TestTable.pdf"; string objectStorageCredentialsInputFilepath = "../sdk-credentials/cloud-object-storage-credentials-input.json"; string objectStorageCredentialsOutputFilepath = "../sdk-credentials/cloud-object-storage-credentials-output.json"; byte[] contractA = File.ReadAllBytes(contractAFilepath); byte[] contractB = File.ReadAllBytes(contractBFilepath); byte[] table = File.ReadAllBytes(tableFilepath); byte[] objectStorageCredentialsInputData = File.ReadAllBytes(objectStorageCredentialsInputFilepath); byte[] objectStorageCredentialsOutputData = File.ReadAllBytes(objectStorageCredentialsOutputFilepath); compareComply.ConvertToHtml(OnConvertToHtml, OnFail, contractA, fileContentType: "application/pdf"); while (!convertToHtmlTested) { yield return(null); } compareComply.ClassifyElements(OnClassifyElements, OnFail, contractA); while (!classifyElementsTested) { yield return(null); } compareComply.ExtractTables(OnExtractTables, OnFail, table); while (!extractTablesTested) { yield return(null); } compareComply.CompareDocuments(OnCompareDocuments, OnFail, contractA, contractB, file1ContentType: "application/pdf", file2ContentType: "application/pdf"); while (!compareDocumentsTested) { yield return(null); } DateTime before = new DateTime(2018, 11, 15); DateTime after = new DateTime(2018, 11, 14); compareComply.ListFeedback( successCallback: OnListFeedback, failCallback: OnFail, feedbackType: "element_classification", before: before, after: after, documentTitle: "unity-test-feedback-doc", modelId: "contracts", modelVersion: "2.0.0", categoryRemoved: "Responsibilities", categoryAdded: "Amendments", categoryNotChanged: "Audits", typeRemoved: "End User:Exclusion", typeAdded: "Disclaimer:Buyer", typeNotChanged: "Obligation:IBM", pageLimit: 1 ); while (!listFeedbackTested) { yield return(null); } #region Feedback Data FeedbackInput feedbackData = new FeedbackInput() { UserId = "user_id_123x", Comment = "Test feedback comment", FeedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, Text = "1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing infrastructure.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = "Responsibilities", ProvenanceIds = new List <string>() { } }, new Category() { Label = "Amendments", ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = "Responsibilities", }, new Category() { Label = "Audits" } } } } }; #endregion compareComply.AddFeedback( successCallback: OnAddFeedback, failCallback: OnFail, feedbackData: feedbackData ); while (!addFeedbackTested) { yield return(null); } // temporary fix for a bug requiring `x-watson-metadata` header Dictionary <string, object> customData = new Dictionary <string, object>(); Dictionary <string, string> customHeaders = new Dictionary <string, string>(); customHeaders.Add("x-watson-metadata", "customer_id=sdk-test-customer-id"); customData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, customHeaders); compareComply.GetFeedback( successCallback: OnGetFeedback, failCallback: OnFail, feedbackId: feedbackId, modelId: "contracts", customData: customData ); while (!getFeedbackTested) { yield return(null); } compareComply.DeleteFeedback( successCallback: OnDeleteFeedback, failCallback: OnFail, feedbackId: feedbackId, modelId: "contracts" ); while (!deleteFeedbackTested) { yield return(null); } compareComply.ListBatches( successCallback: OnListBatches, failCallback: OnFail ); while (!listBatchesTested) { yield return(null); } compareComply.CreateBatch( successCallback: OnCreateBatch, failCallback: OnFail, function: "html_conversion", inputCredentialsFile: objectStorageCredentialsInputData, inputBucketLocation: "us-south", inputBucketName: "compare-comply-integration-test-bucket-input", outputCredentialsFile: objectStorageCredentialsOutputData, outputBucketLocation: "us-south", outputBucketName: "compare-comply-integration-test-bucket-output" ); while (!createBatchTested) { yield return(null); } compareComply.GetBatch( successCallback: OnGetBatch, failCallback: OnFail, batchId: batchId ); while (!getBatchTestsed) { yield return(null); } compareComply.UpdateBatch( successCallback: OnUpdateBatch, failCallback: OnFail, batchId: batchId, action: "rescan", modelId: "contracts" ); while (!updateBatchTested) { yield return(null); } Log.Debug("ExampleCompareComplyV1.RunTests()", "Compare and Comply examples complete!"); }
// Start is called before the first frame update void Start() { FeedbackInput = GameObject.Find("InputField"); script = FeedbackInput.GetComponent <FeedbackInput>(); }