protected override void Execute(CodeActivityContext context) { string text1 = Text1.Get(context); string text2 = Text2.Get(context); string apiKey = APIKey.Get(context); string seKey = SecretKey.Get(context); try { var client = new Baidu.Aip.Nlp.Nlp(apiKey, seKey); //修改超时时间 client.Timeout = 60000; //设置可选参数 var options = new Dictionary <string, object> { { "model", model } }; //带参数调用短文本相似度 string result = client.Simnet(text1, text2, options).ToString(); Result.Set(context, result); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message); } }
public override void Draw(GameTime gameTime, Frame frame) { var ir = new ImperativeRenderer(frame, Materials, samplerState: SamplerState.LinearClamp); ir.AutoIncrementLayer = true; ir.Clear(color: ClearColor); Text.Position = TopLeft; Text2.LineBreakAtX = Text.LineBreakAtX = BottomRight.X - TopLeft.X; Text.WrapIndentation = Text2.WrapIndentation = Indent.Value ? 64 : 0; ir.OutlineRectangle(new Bounds(TopLeft, BottomRight), Color.Red); var layout = Text.Get(); if (ShowOutlines.Value) { foreach (var dc in layout.DrawCalls) { ir.OutlineRectangle(dc.EstimateDrawBounds(), Color.Blue); } } var m = Materials.Get(Materials.ScreenSpaceShadowedBitmap, blendState: BlendState.AlphaBlend); m.Parameters.ShadowColor.SetValue(new Vector4(0, 0, 0, 0.66f)); m.Parameters.ShadowOffset.SetValue(new Vector2(3.5f, 3.5f)); ir.OutlineRectangle(Bounds.FromPositionAndSize(Text.Position, layout.Size), Color.Yellow * 0.75f); ir.DrawMultiple(layout, material: m); if (Which.Value) { Text2.Position = TopLeft + new Vector2(0, layout.Size.Y + 20); layout = Text2.Get(); if (ShowOutlines.Value) { foreach (var dc in layout.DrawCalls) { ir.OutlineRectangle(dc.EstimateDrawBounds(), Color.Blue); } } ir.OutlineRectangle(Bounds.FromPositionAndSize(Text2.Position, layout.Size), Color.Yellow * 0.75f); ir.DrawMultiple(layout, material: m); } }