声音开发
金蝶云社区-assassinl10
assassinl10
1人赞赏了该文章 1,050次浏览 未经作者许可,禁止转载编辑于2018年11月29日 17:34:01

[password]123456[/password]

[code]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;

namespace YEA.K3.BD.BarCode.Business.Plugin
{
[Description("公共插件:播放语音文件")]
public static class PlaySound
{
///


/// 播放声音文件
///

/// 表单
/// 音频控件标识
/// 声音文件名称
public static void Paly(IDynamicFormView view, string mark, string tag)
{
if (view.ClientType == ClientType.WPF)
{
object[] array = new object[] { tag };
view.GetControl(mark).InvokeControlMethod("DoCustomMethod", new object[]
{
"OnPlaySound",
array
});
//view.GetControl(mark).InvokeControlMethod("Play", null);
//Control aPlay = view.GetControl(mark);
//aPlay.SetCustomPropertyValue("audioonserver", @"/Audio/BarCodeAudio/" + tag + ".mp3"); //声音文件
//aPlay.InvokeControlMethod("Play", null);
}
}
}

}
[/code]


[code]using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using System;
using System.ComponentModel;
using System.IO;
using Kingdee.BOS;

namespace YEA.K3.BD.BarCode.Business.Plugin
{
[Description("声音播放服务端表单构建插件")]
public class PlaySoundFormBuilderPlugIn : AbstractDynamicWebFormBuilderPlugIn
{
public override void CreateControl(CreateControlEventArgs e)
{
base.CreateControl(e);
if (StringUtils.EqualsIgnoreCase(e.ControlAppearance.Key, "FAudioPlay"))
{
if (base.Context.ClientType != ClientType.WPF)
{
return;
}
e.Control["Assembly"] = "YEA.K3.Business.CustomerControlPlugIn";
e.Control["ClassName"] = "PlaySound";
e.Control["DeployPath"] = "";
e.Control["NameSpace"] = "YEA.K3.Business.CustomerControlPlugIn";
e.Control["IsExtended"] = true;
string text = AppDomain.CurrentDomain.BaseDirectory +
"ClientBin\\CustomControl\\WPF\\YEA.K3.Business.CustomerControlPlugIn.dll";
e.Control["SourcePath"] = text;
string value = "";
try
{
if (File.Exists(Path.Combine(base.GetType().Assembly.CodeBase, text)))
{

byte[] array = File.ReadAllBytes(Path.Combine(base.GetType().Assembly.CodeBase, text));
value = Extentions.ToMD5String(array);
}
}
catch
{
value = "";
}
e.Control["MD5String"] = value;
e.Control["xtype"] = "kdcustomcontroldef";
}
}
}
}
[/code]


[code]using Kingdee.BOS.Client.Core;
using System;
using System.ComponentModel;
using System.IO;
using System.Media;
using System.Reflection;
using System.Windows.Controls;
namespace YEA.K3.Business.CustomerControlPlugIn
{
[Description("声音播放客制化控件桌面客户端")]
public class PlaySound : ContentControl, IKDCustomControl
{
public IKDCustomControlProxy Proxy { get; set; }

protected void FireOnCustomEvent(CustomEventArgs e)
{
if (this.Proxy != null)
{
this.Proxy.FireCustomEvent(e);
}
}

public void InitComponent()
{
}

public void Release()
{
base.Content = null;
}

public void OnPlaySound(string fileName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string path = System.Environment.CurrentDirectory + @"\controlplugins\";
fileName = path + fileName + ".wav";
string arg110 = executingAssembly.GetName().Name;
if (File.Exists(fileName))
{
SoundPlayer soundPlayer = new SoundPlayer(fileName);
soundPlayer.LoadAsync();
soundPlayer.Play();
}
}
}
}
[/code]

1.单据上添加面板控件




2.注册表单构建插件


YEA.K3.BD.BarCode.Business.Plugin.PlaySoundFormBuilderPlugIn,YEA.K3.BD.BarCode.Business.Plugin
3.代码更新


类库修改:YEA.K3.BD.BarCode.Business.Plugin

增加 PlaySoundFormBuilderPlugIn.cs

替换 PlaySound.cs

添加类库 YEA.K3.Business.CustomerControlPlugIn



4.服务器更新

客户端插件注册

生成插件 YEA.K3.Business.CustomerControlPlugIn.dll

放置在服务器目录下 Kingdee\K3Cloud\WebSite\ClientBin\CustomControl\WPF

压缩插件

启动WebSite\ClientBin\ClientTools\Kingdee.BOS.XPF.Updater.exe,点击“...”按钮选择文件,点击“Zip”按钮压缩生成.kdz,“ServerPath”文本框修改为“/ClientBin/CustomControl/WPF”,最后点击“Generate”按钮

工具位置






5.音频文件更新