using System;
using System.Configuration;
using System.Data;
using System.Text;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Diagnostics;
public partial class RecPlay_RecPlay : System.Web.UI.Page
{
public string RecName;
public string PathTo_wav
{
get { return ViewState["pathTo_wav"].ToString(); }
set { ViewState["pathTo_wav"] = value; }
}
public string PathTo_voc
{
get { return ViewState["pathTo_voc"].ToString(); }
set { ViewState["pathTo_voc"] = value; }
}
public string ServiceID
{
get { return Request.QueryString["serviceid"].ToString(); }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
// BuildWav(ServiceID);
}
}
private void BuildWav(string serviceID)
{
if (!string.IsNullOrEmpty(serviceID))
{
if (this.Connect("10.6.27.8", "10086", ""))
{
string sql = "select REC_VOC_FILE from dc_servicelist where ServiceID='"+this.ServiceID+"'";
if (gDAO.SqlText.ExecuteScalar(sql)!=null)
{
if (gDAO.SqlText.ExecuteScalar(sql).ToString().IndexOf(".voc") != -1)
{
string path = @"//10.6.27.8/rec/rec/" + gDAO.SqlText.ExecuteScalar(sql).ToString();
///Request.Cookies["UserInfo"]["userid"].ToString()
Do(path, "894");
}
}
}
}
}
public void Do(string pathSource, string agentID)
{
string[] arr_path_target = pathSource.Split(new Char[] { '//' });//--0043957.voc
string filename_voc = agentID + "_" + arr_path_target[arr_path_target.Length - 1].ToString();
string filename_wav = filename_voc.Replace("voc", "wav");//--0043957.wav
//string pathTo_voc = Server.MapPath(arr_path_target[arr_path_target.Length-1].ToString());
string pathTo_voc = Server.MapPath("voc//" + filename_voc);
string pathTo_wav = pathTo_voc.Replace("voc//" + filename_voc, "wav//" + filename_wav);
this.PathTo_wav = pathTo_wav;//存储-用于关闭时候的删除wav文件动作;
this.PathTo_voc = pathTo_voc;//存储-用于关闭时候的删除voc文件动作;
if ((File.Exists(this.PathTo_voc)) && (File.Exists(this.PathTo_voc)))
{
this.RecName = this.PathTo_wav;
return;
}
File.Copy(pathSource, pathTo_voc);
int result=DjVocConvert.PcmtoWave(pathTo_voc, pathTo_wav);
if (result > 0)
{
this.RecName = this.PathTo_wav;
}
}
///
/// Agent退出播放时候,只删除对应AgentID的录音wav
///
public void Close()
{
//if (File.Exists(this.PathTo_wav))
//{
// File.Delete(this.PathTo_wav);
//}
//if (File.Exists(this.PathTo_voc))
//{
// File.Delete(this.PathTo_voc);
//}
// Response.Write(""); //---Dialog.js
string scripts = "";//--tipswindown.js
Response.Write(scripts);
}
protected void BtnClose_Click(object sender, EventArgs e)
{
Close();
}
///
/// 远程连接服务器;
///
///
///
///
///
public bool Connect(string remoteHost, string userName, string passWord)
{
bool Flag = true;
Process proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
try
{
proc.Start();
string command = @"net use //" + remoteHost + " " + passWord + " " + " /user:" + userName + ">NUL";
proc.StandardInput.WriteLine(command);
command = "exit";
proc.StandardInput.WriteLine(command);
while (proc.HasExited == false)
{
proc.WaitForExit(1000);
}
string errormsg = proc.StandardError.ReadToEnd();
if (errormsg != "")
Flag = false;
proc.StandardError.Close();
}
catch (Exception ex)
{
Flag = false;
}
finally
{
proc.Close();
proc.Dispose();
}
return Flag;
}
}
-----------------------------------------------------------------------------/
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestJqueryMprPlugin2.aspx.cs" Inherits="RecPlay_TestJqueryMprPlugin2" %>
///-------------------------------------------------------------------------
//jQuery弹出窗口 By Await [2009-11-22]
//--------------------------------------------------------------------------
/*参数:[可选参数在调用时可写可不写,其他为必写]
----------------------------------------------------------------------------
title: 窗口标题
content: 内容(可选内容为){ text | id | img | url | iframe }
width: 内容宽度
height: 内容高度
drag: 是否可以拖动(ture为是,false为否)
time: 自动关闭等待的时间,为空是则不自动关闭
showbg: [可选参数]设置是否显示遮罩层(0为不显示,1为显示)
cssName: [可选参数]附加class名称
------------------------------------------------------------------------*/
//示例:
//------------------------------------------------------------------------
//simpleWindown("例子","text:例子","500","400","true","3000","0","exa")
//------------------------------------------------------------------------
var showWindown = true;
var templateSrc = "http://leotheme.cn/wp-content/themes/Dreamy"; //设置loading.gif路径
function tipsWindown(title,content,width,height,drag,time,showbg,cssName) {
$("#windown-box").remove(); //请除内容
var width = width>= 950?this.width=950:this.width=width; //设置最大窗口宽度
var height = height>= 527?this.height=527:this.height=height; //设置最大窗口高度
if(showWindown == true) {
var simpleWindown_html = new String;
simpleWindown_html = "
加载数据出错...
");加载数据出错...
");加载数据出错...
");
因为先前遇到的问题,所以我考虑采用 IFRAME 来隔离不同的脚本,从而实现我需要的效果。
在框架中,我用 JavaScript 获取 JSON 数据,组织成 HTML 代码,最后将其填充至上层文档的一个元素中。按照一般的写法,我们需要用到类似如下的语句:
1.
window.parent.document.getElementById(
"myEle"
).innerHTML = html;
使用 jQuery ,写法如下:
即指明了是在 window.parent.document 中查找 id=myEle 的元素。
随着前面的问题的解决(其实是对 jQuery 的了解不够),现在两种方案都可以实现我需要的效果了。
另外还有一种实现方式,代码如下:
1.
parent.$(
"#myEle"
).html(html);
这种方法要求父文档也要调用 jQuery 。
演示:使用 jQuery 实现 window.parent.document.getElementById().innerHTML
个人感觉 jquery 就是强啦!!!