public static string OpenReadFile(FileInfo fileinfo) { if (null == fileinfo) { return(string.Empty); } string values = string.Empty; FileStream fsr = fileinfo.OpenRead(); byte[] datar = new byte[(int)fsr.Length]; int bRead = 0; while (bRead < (int)fsr.Length) { int resultRead = fsr.Read(datar, bRead, (int)fsr.Length - bRead); if (resultRead == -1) { Log4NetHelper.BaseLog("read error"); } bRead += resultRead; } values = System.Text.Encoding.Default.GetString(datar); fsr.Close(); return(values); }
private void Btn_Ok_Click(object sender, RoutedEventArgs e) { if (null == _voice || 0 == _videoList.Count || string.IsNullOrEmpty(tb_path.Text) || null == _videoList || -1 == Cb_Device.SelectedIndex) { return; } var item = _videoList[Cb_Device.SelectedIndex]; if (null == item) { return; } var info = JsonUtil.ToJson(new VoiceSnapShot() { deviceIndex = item.deviceIndex, height = DEAULT_SIZE, width = DEAULT_SIZE, filePath = tb_path.Text }); try { var res = _voice.SnapShot(info); Log4NetHelper.ActionLog("Voice", "SnapShot", res); } catch (COMException exc) { Log4NetHelper.BaseLog(exc.Message); } }
/// <summary> /// reload language resource /// </summary> /// <param name="language"></param> public static void ReloadLanguageResource(string language) { if (string.IsNullOrEmpty(language)) { return; } if (!"EN-US".Equals(language.ToUpper()) && !"ZH-CN".Equals(language.ToUpper())) { return; } try { List <ResourceDictionary> dictionaryList = new List <ResourceDictionary>(); foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries) { dictionaryList.Add(dictionary); } ResourceDictionary resourceDictionary = (ResourceDictionary)Application.LoadComponent(new Uri("Src/Language/" + language + ".xaml", UriKind.Relative)); if (null == resourceDictionary || 0 == resourceDictionary.Count) { Log4NetHelper.BaseLog("load resource dictionary failed."); } if (resourceDictionary != null) { Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary); Application.Current.Resources.MergedDictionaries.Add(resourceDictionary); } } catch (Exception exc) { Log4NetHelper.ExcepLog("Sys", "ReloadLanguageResource", exc.Message); } }
/// <summary> /// qry button click /// </summary> /// <param name="sender">button</param> /// <param name="e">click event</param> private void btn_qry_Click(object sender, EventArgs e) { tb_msgshow.Text = string.Empty; if (string.IsNullOrEmpty(tb_pageNo.Text) || string.IsNullOrEmpty(tb_pageSize.Text)) { return; } var instance = (AgentGatewayBusiness)BusinessAdapter.GetBusinessInstance(); if (null == instance) { Log4NetHelper.BaseLog("Instance is null"); return; } var qryParm = new CallSessionQryParm() { startTime = TransferDateToTimeStamp(tb_startTime.Text), endTime = TransferDateToTimeStamp(tb_endTime.Text), pageNo = tb_pageNo.Text, pageSize = tb_pageSize.Text, callType = tb_callType.Text, caller = tb_caller.Text, called = tb_called.Text, mediaType = "1", subMediaType = "2", realCaller = "", callerName = "" }; var qryInfo = HuaweiAgentGateway.Utils.JsonUtil.ToJson(qryParm); try { var res = instance.QryCallSession(qryInfo); if (null == res) { MessageBox.Show(LanguageResource.FindResourceMessageByKey("textchat_qryfailed")); return; } Log4NetHelper.ActionLog("Agw", "QryCallSession", res.retcode); if (null == res.result) { return; } lbl_totalPage.Content = res.result.totalPageNo; lbl_totalCount.Content = res.result.totalCount; UIViewHelper.SelectorResetSource(dgrd_callsession, res.result.weccCallBillList); } catch (Exception exc) { Log4NetHelper.BaseLog(exc.Message); } }
/// <summary> /// component(implement Selector interface) reset source /// </summary> /// <param name="obj">object that needs reset source</param> /// <param name="src">new itemsource</param> public static void SelectorResetSource(Selector obj, IEnumerable src) { try { if (null == obj) { return; } obj.ItemsSource = null; obj.Items.Clear(); obj.ItemsSource = src; } catch (Exception exc) { Log4NetHelper.BaseLog("[selector_resetsrc_failed] obj:" + obj + " msg:" + exc.Message); } }
/// <summary> /// qry button click /// </summary> /// <param name="sender">button</param> /// <param name="e">click event</param> private void btn_qry_Click(object sender, EventArgs e) { tb_msgshow.Text = string.Empty; if (string.IsNullOrEmpty(tb_pageNo.Text) || string.IsNullOrEmpty(tb_pageSize.Text)) { return; } try { if (BusinessAdapter.CurrentBusinessType == BusinessType.OCX) { Log4NetHelper.BaseLog("Instance is ocx"); return; } if (null == BusinessAdapter.GetBusinessInstance()) { Log4NetHelper.BaseLog("Instance is null"); return; } var res = ((AgentGatewayBusiness)BusinessAdapter.GetBusinessInstance()).QryCallContent(tb_callID.Text, tb_pageSize.Text, tb_pageNo.Text); if (null == res) { MessageBox.Show(LanguageResource.FindResourceMessageByKey("textchat_qryfailed")); return; } Log4NetHelper.ActionLog("Agw", "QryCallContent", res.retcode); if (null == res.result) { return; } lbl_totalPage.Content = res.result.totalPageNo; lbl_totalCount.Content = res.result.totalCount; UIViewHelper.SelectorResetSource(dgrd_callcontent, res.result.weccCallContentList); } catch (Exception exc) { Log4NetHelper.BaseLog(exc.Message); } }
/// <summary> /// transfer time string to timestamp /// </summary> /// <param name="time">time string</param> /// <returns>timestamp</returns> private string TransferDateToTimeStamp(string time) { if (string.IsNullOrEmpty(time)) { return(time); } var timeStamp = time; try { var dt = Convert.ToDateTime(time); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0)); var intResult = (dt.Ticks - startTime.Ticks) / 10000; //除10000调整为13位 timeStamp = intResult + string.Empty; } catch (Exception exc) { Log4NetHelper.BaseLog(exc.Message); } return(timeStamp); }
private void Btn_Qry_Click(object sender, RoutedEventArgs e) { if (null == _voice) { return; } try { var res = _voice.GetDeviceVideo(); var item = JsonUtil.DeJson <DeviceList>(res); _videoList = item.GetDeviceList(); if (null == _videoList || 0 == _videoList.Count) { return; } UIViewHelper.SelectorResetSource(Cb_Device, _videoList.Select(dev => dev.deviceName).ToList()); Cb_Device.SelectedIndex = 0; } catch (Exception exc) { Log4NetHelper.BaseLog(exc.Message); } }
private void btnOK_Click(object sender, EventArgs e) { try { var mainUrl = ValidateString(txtUrl, true, "Server"); var backUrl = ValidateString(txtBoxBackUpAddress, false, "BackupServer"); if (chkAgw.IsChecked.Value) { var urlhead = chkUseHttps.IsChecked.Value ? "https" : "http"; mainUrl = string.Format(AGW_URLPARM, urlhead, mainUrl, tbSerPort.Text); if (!string.IsNullOrEmpty(txtBoxBackUpAddress.Text) && !string.IsNullOrEmpty(tbSerPort1.Text)) { backUrl = string.Format(AGW_URLPARM, urlhead, backUrl, tbSerPort1.Text); } } if (null == Settings) { Settings = new Dictionary <string, string>(); } else { Settings.Clear(); } Settings.Add(MAIN_URL, ValidateString(txtUrl, true, "Server")); Settings.Add(BACK_URL, ValidateString(txtBoxBackUpAddress, false, "BackupServer")); Settings.Add(AUTO_ANS, (bool)chkAutoAnswer.IsChecked + ""); Settings.Add(ENTR_WRK, (bool)chkAutoEnterWork.IsChecked + ""); Settings.Add(TIME_OUT, txtOverTime.Text); var serType = chkOCX.IsChecked.Value ? "OCX" : "Agent"; Settings.Add(BUSS_TYP, serType); Settings.Add(PROG_ID, tbProgID.Text); Settings.Add(USAG_SSL, chkUseHttps.IsChecked.Value + ""); Settings.Add("tbSerPort", tbSerPort.Text); Settings.Add("tbSerPort1", tbSerPort1.Text); Settings.Add("mainUrl", mainUrl); Settings.Add("backUrl", backUrl); Settings.Add("agentType", m_dicAgentType[cbAgentType.Text]); Settings.Add(USAG_VOI, chkOpenEye.IsChecked.Value + ""); Settings.Add("SipIP", tbxSIPIP.Text); Settings.Add("SipPort", tbxSIPPort.Text); Settings.Add("SipIP2", tbxSIPIP2.Text); Settings.Add("SipPort2", tbxSIPPort2.Text); Settings.Add("VoiceAccount", tbxName2.Text); Settings.Add(VOIC_DOM, tbDomain.Text); Settings.Add("LongCall", chkLongCall.IsChecked.Value + ""); Settings.Add("ChkCerti", chk_certifile.IsChecked.Value + ""); MainWindow.VoicePwd = tbxPass2.Password; } catch (Exception excep) { MessageBox.Show(excep.Message); Log4NetHelper.BaseLog("[config_excep] Msg:" + excep.Message); } finally { this.DialogResult = true; } }