Beispiel #1
0
 public static void UploadLuYin(string path)
 {
     try
     {
         string url = "";
         jsonFile1.FileID = ResID;
         if (JsEvent.parameter != null && JsEvent.parameter.zimu != null && JsEvent.parameter.zimu != "")
         {
             jsonFile1.FileID = ResID + JsEvent.parameter.wordIndex;
         }
         jsonFile1.UserName      = thearID;
         jsonFile1.ResourceStyle = 101;
         string        JsonFile = JsEvent.EnSerialize <JsonFile>(jsonFile1);
         byte[]        bt       = client.UploadFile(UploadUrl + "?JsonFile=" + JsonFile, path);
         string        temp     = System.Text.Encoding.UTF8.GetString(bt);
         List <string> ls       = temp.Split(',').ToList();
         if (ls != null && ls.Count == 8)
         {
             List <string> ls2 = ls[6].Split(',').ToList();
             url = ls2[0].Replace("\"FilePath\":\"", "").Replace("\"}", "");
             string strGUID = System.Guid.NewGuid().ToString(); //直接返回字符串类型
             url += "?ran=" + strGUID;
             if (JsEvent.cbId != "-1")
             {
                 mesage msag = new mesage();
                 msag.code = 0;
                 msag.msg  = "";
                 msag.data = new data();
                 msag.data.recordFileUrl = url;
                 string res = JsEvent.EnSerialize <mesage>(msag);
                 bool   s   = JsEvent.wb.Enabled;
                 JsEvent.wb.ExecuteScriptAsync("sClassJSBridge.handleMessage('" + JsEvent.cbId + "','" + res + "');");
             }
             else
             {
                 JsEvent.wb.ExecuteScriptAsync("cpGetLuyinPath('" + url + "');");
             }
         }
         else
         {
             if (JsEvent.cbId != "-1")
             {
                 JsEvent.wb.ExecuteScriptAsync("sClassJSBridge.handleMessage('" + JsEvent.cbId + "','" + "上传失败" + "');");
             }
             else
             {
                 JsEvent.wb.ExecuteScriptAsync("cpGetLuyinPath('上传失败');");
             }
         }
     }
     catch (Exception ex)
     {
         new Helper().InsertErrorMsg(ex.StackTrace, ex.Message);
         throw;
     }
 }
Beispiel #2
0
        private int callback(IntPtr usrdata, string record_id, int type, byte[] message, int size)
        {
            if (stop == "is")
            {
                return(0);
            }
            int score = 0;

            if (type == AIENGINE_MESSAGE_TYPE_JSON)
            {
                IndexForm aiEngine = (IndexForm)GCHandle.FromIntPtr(usrdata).Target;
                aiEngine.result = Encoding.UTF8.GetString(message);
                string  mess  = Encoding.UTF8.GetString(message);
                message messg = JsEvent.DecodeJson <message>(mess);
                if (messg.result != null)
                {
                    score = int.Parse(messg.result.overall);
                }
            }
            try
            {
                if (JsEvent.parameter != null && JsEvent.parameter.zimu != null && JsEvent.parameter.zimu != "")
                {
                    if (JsEvent.cbId != "-1")
                    {
                        mesage msag = new mesage();
                        msag.code       = 0;
                        msag.msg        = "";
                        msag.data       = new data();
                        msag.data.score = score;
                        string res = JsEvent.EnSerialize <mesage>(msag);
                        JsEvent.wb.ExecuteScriptAsync("sClassJSBridge.handleMessage('" + JsEvent.cbId + "','" + res + "');");
                    }
                    else
                    {
                        JsEvent.wb.ExecuteScriptAsync("cpgetScore('" + score + "');");
                    }
                }
            }
            catch (Exception ee)
            {
                new Helper().InsertErrorMsg("窗体关闭" + ee.StackTrace, ee.Message);
                throw;
            }
            return(0);
        }
Beispiel #3
0
        /// <summary>
        /// 检测机器上面是否有麦克风,1.3版本
        /// </summary>
        /// <param name="zimuD"></param>
        /// <returns></returns>
        public void recordAuthority_n(string zimuD)
        {
            if (zimuD == "")
            {
                JsEvent.parameter = null;
            }
            else
            {
                parameter           = new parameter();
                parameter1          = Deserialize <parameter1>(zimuD);
                parameter.zimu      = parameter1.captions;
                parameter.wordIndex = parameter1.wordIndex.ToString();
                parameter.type      = parameter1.recordType;
            }
            IList <MicrophoneInformation> microphones = SoundDevice.GetMicrophones();
            bool existMicro = false;

            if (microphones != null && microphones.Count > 0)
            {
                foreach (MicrophoneInformation mi in microphones)
                {
                    if (mi.Name.Contains("麦克风") || mi.Name.ToLower().Contains("microphone"))
                    {
                        existMicro = true;
                    }
                }
            }
            mesage msag = new mesage();

            if (existMicro)
            {
                msag.code = 0;
                msag.msg  = "检测有麦克风";
                msag.data = null;
            }
            else
            {
                msag.code = 100;
                msag.msg  = "检测没有麦克风";
                msag.data = null;
            }
            string res = EnSerialize <mesage>(msag);

            JsEvent.wb.ExecuteScriptAsync("sClassJSBridge.handleMessage('" + parameter1.cbId + "','" + res + "');");
        }