web公文留痕(word插件实现方式)

aspx页面代码(通过asp代码实现,不需要cs页面),控件去dev-club下载

<%@ Page language="c#" Codebehind="SendPaperDocument.aspx.cs" AutoEventWireup="false" Inherits="KMP50._2052.Aspx.Paper.Aspx.SendPaperDocument" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>发文正文</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="
http://schemas.microsoft.com/intellisense/ie5">
  <LINK href="../../../css/OceanSoft.css" type="text/css" rel="stylesheet">
  <script language="vbscript">
 Dim bDocOpen
 Dim pFileName
 Dim bIsViewHistory
 
'页面加载
 Sub PageLoad(UserName)
 SendPaperDocument.oframe.caption="发文正文"
 OpenLastDoc()
 SendPaperDocument.oframe.ActiveDocument.Application.UserName=UserName
 'SendPaperDocument.oframe.EnableFileCommand(dsoFileNew) = False
 HideButton()
 end sub
 
'获取最后文件
 Sub OpenLastDoc()
 Url=GetLastDoc(SendPaperDocument.txtPaperGuid.value)
 if Url<>"new" then 
  SendPaperDocument.oframe.open Url
  SendPaperDocument.oframe.ActiveDocument.TrackRevisions = True
  pFileName=SendPaperDocument.txtFileName.value
 else
  NewDoc()
 end if
 End Sub
 
 '接受修订
 Sub AcceptRevisions() 
 if window.confirm("你确定要清稿吗?") then
 On Error Resume Next
 SendPaperDocument.oframe.ActiveDocument.AcceptAllRevisionsShown
 SendPaperDocument.oframe.ActiveDocument.AcceptAllRevisions
 end if
 End Sub
 
 
 
 '打开文件
 Sub OpenDoc()
   On Error Resume Next
   SendPaperDocument.oframe.showdialog 1 'dsoDialogOpen
   pFileName=GetFileName()
   bIsViewHistory=false
    'if err.number then
      'MsgBox "Unable to Open Document: " & err.description
   'end if
 End Sub
 
 '查看模板
 Sub OpenWebDoc()
   Dim sUrl
   On Error Resume Next
   window.open "SendPaperTemplateList.aspx?PaperGuid="+SendPaperDocument.txtPaperGuid.value,"sptl","width=220,height=340,top=120,left=200"
 End Sub
 
 '打开模板
  Sub AfterOpenWebDoc(sUrl,fileName,ptitle)  
   On Error Resume Next  
   If Len(sUrl) Then  
     SendPaperDocument.oframe.open sUrl,,"Word.Document"
     pFileName=fileName
      SendPaperDocument.oframe.caption="发文正文"&":"&ptitle&" "
      bIsViewHistory=false
     if err.number then
       MsgBox "不能打开路径: " & err.description
     end if
   End If
 End Sub
 
 '查看历史文件
 Sub ViewHistory()
   On Error Resume Next
    window.open "SendPaperViewHistory.aspx?PaperGuid="+SendPaperDocument.txtPaperGuid.value,"sptl","width=360,height=280,top=120,left=200" 
 End Sub
 
 '打开历史文件
 Sub AfterViewHistory(sUrl,ptitle)  
   On Error Resume Next  
   If Len(sUrl) Then
   'msgbox ptitle
     SendPaperDocument.oframe.open sUrl,,"Word.Document"    
      SendPaperDocument.oframe.caption="发文正文"&":"&ptitle&" "
      bIsViewHistory=true
      'SendPaperDocument.cmdOpenTemplate.style="display:none"
     
     if err.number then
       MsgBox "不能打开路径: " & err.description
     end if
   End If
 End Sub
 
 '保存文件
 Sub UploadDoc(pUrl)
   On Error Resume Next 
   if bIsViewHistory then
   MsgBox "历史文件只能查看,不能被修改!",0,"提示"
   exit sub  
   end if
   If Not bDocOpen Then
      MsgBox "你没有打开文件!",0,"提示"
   Else
    '把文件保存到硬盘 路径前缀+文件名 例如:
http://ding/doc/ & f9842dc2-4819-46bf-8ee1-d93b79636cc6.doc  
       SendPaperDocument.oframe.Save  pUrl&pFileName,true
       '把相关信息保存到数据库
       PostData SendPaperDocument.txtPaperGuid.value,pFileName,SendPaperDocument.txtAction.value
      
             
   End If
   'if err.number then
      'MsgBox "Unable to Open Document: " & err.description
   'end if
 End Sub
 
Sub AddPicture(Url)
  On Error Resume Next
    window.open "SelectSeal.aspx","ss","width=360,height=160,top=140,left=200" 
 
 End Sub
 
 '盖章
 Sub AfterAddPicture(Url)
  dim m
 ' m = SendPaperDocument.oframe.ActiveDocument.InlineShapes.Count
  'm = m + SendPaperDocument.oframe.ActiveDocument.Shapes.Count
    On Error Resume Next
 SendPaperDocument.oframe.ActiveDocument.ActiveWindow.Selection.InlineShapes.AddPicture Url,false,true
 
 m = SendPaperDocument.oframe.ActiveDocument.InlineShapes.Count
 m = m + SendPaperDocument.oframe.ActiveDocument.Shapes.Count
 
 
 SendPaperDocument.oframe.ActiveDocument.InlineShapes(m).ConvertToShape
 
 End Sub
 
 '保护文件
 Sub ProtectDoc(pUrl)
 SendPaperDocument.oframe.ActiveDocument.Protect 1
 UploadDoc(pUrl)
 End Sub

 Sub oframe_OnDocumentOpened(str, obj)
    Dim s, s2
    On Error Resume Next
    bDocOpen = True

    if len(str) = 0 then
      str = "New Document"
    else
      Dim x
      x = InStr(str, "\")
      if x then
         do
            str = mid(str, x+1)
            x = Instr(str, "\")
         loop while x > 0
      else
         x = Instr(str, "/")
         if x Then
           do
              str = mid(str, x+1)
              x = Instr(str, "/")
           loop while x > 0
         end if
      end if
    end if

    s = obj.Application.Name
    if len(s) = 0 then s = "Unknown Server"

    'document.all.tstat.InnerHTML = "File: " & str & "<br>Server: " & s
 End Sub

 Sub oframe_OnDocumentClosed()
   bDocOpen = False  
   'document.all.tstat.InnerHTML = "Try another file."
 End Sub

 Sub NewDoc()
   On Error Resume Next
   'SendPaperDocument.oframe.showdialog 0 'dsoDialogNew
   'if err.number then
     ' MsgBox "不能创建新的对象: " & err.description
  ' end if
  SendPaperDocument.oframe.CreateNew "Word.Document"
  ' Let user edit the document, then save it.
  'SendPaperDocument.oframe.Save "
http://ding/doc/test.ppt"
  'SendPaperDocument.oframe.ActiveDocument.TrackRevisions = True
  pFileName=GetFileName()
  bIsViewHistory=false
 End Sub

 

 Sub OpenWebDoc1()
   Dim sUrl
   On Error Resume Next
   sUrl = InputBox("打开文件的Web地址...","提示" ,"
http://ding/doc/1.doc")
   If Len(sUrl) Then
     SendPaperDocument.oframe.open sUrl,,"Word.Document"
     if err.number then
       MsgBox "不能打开路径: " & err.description
     end if
   End If
 End Sub
 
 

 Sub SaveCopyDoc()
   On Error Resume Next
   If Not bDocOpen Then
      MsgBox "你没有打开文件!"
   Else
      SendPaperDocument.oframe.showdialog 3 'dsoDialogSaveCopy
   End If
 End Sub

 Sub ChgLayout()
   On Error Resume Next
   If Not bDocOpen Then
      MsgBox "你没有打开文件!"
   Else
      SendPaperDocument.oframe.showdialog 5 'dsoDialogPageSetup
   End If
 End Sub

 Sub PrintDoc()
   On Error Resume Next
   If Not bDocOpen Then
      MsgBox "你没有打开文件!"
   Else
      SendPaperDocument.oframe.printout True
   End If
 End Sub

 Sub CloseDoc()
   On Error Resume Next  
  If Not bDocOpen Then
      'MsgBox "你没有打开文件!",0,"提示"
   Else 
   msgbox SendPaperDocument.oframe.ActiveDocument.saved
      if SendPaperDocument.oframe.ActiveDocument.saved then
  SendPaperDocument.oframe.close
    else
       rt=msgbox("当前文件没有保存,您是否需要保存?",4,"提示")
       if rt=6 then
   'UploadDoc pUrl
       end if
    end if
   End If  
 End Sub
 
 

 Sub ToggleTitlebar()
   Dim x
   On Error Resume Next
   x = SendPaperDocument.oframe.Titlebar
   SendPaperDocument.oframe.Titlebar = Not x
 End Sub

 Sub ToggleToolbars()
   Dim x
   On Error Resume Next
   x = SendPaperDocument.oframe.Toolbars
   SendPaperDocument.oframe.Toolbars = Not x
 End Sub
 
 
  </script>
  <script language="javascript">
   function PostData(PaperGuid,fileName,action)
   {
    var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
    xmldoc.loadXML("<root><paperguid>"+PaperGuid+"</paperguid><filename>"+fileName+"</filename><action>"+action+"</action></root>");
       
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", "SendPaperTemplateList.aspx?Act=1", false);
    xmlhttp.Send(xmldoc); 
    alert("保存成功!");
   }
   
   function GetLastDoc(PaperGuid)
   {
    var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
    xmldoc.loadXML("<root><paperguid>"+PaperGuid+"</paperguid></root>");
       
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", "SaveRepaire.aspx?Act=GetLastDoc", false);
    xmlhttp.Send(xmldoc); 
    var destxml=new ActiveXObject("Microsoft.XMLDOM"); 
    destxml=xmlhttp.responseXML
    //alert(destxml.xml);
    SendPaperDocument.oframe.caption="发文正文"+":"+destxml.documentElement.childNodes[1].text+" "    
    SendPaperDocument.txtFileName.value=destxml.documentElement.childNodes[2].text
    return destxml.documentElement.childNodes[0].text;    
   }
   
   function GetFileName()
   {
    var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
    xmldoc.loadXML("<root>1</root>");
       
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", "SaveRepaire.aspx?Act=GetFileName", false);
    xmlhttp.Send(xmldoc); 
    var destxml=new ActiveXObject("Microsoft.XMLDOM"); 
    destxml=xmlhttp.responseXML       
    return destxml.text;  
   }
   
   function HideButton()
   {
    if(SendPaperDocument.txtAction.value!="Entry" && SendPaperDocument.txtAction.value!="Record")
    {
     SendPaperDocument.cmdOpen.style.display="none";
     SendPaperDocument.cmdOpenTemplate.style.display="none";
    }
    else
    {
     SendPaperDocument.oframe.ActiveDocument.TrackRevisions = false
    }
    
    if(SendPaperDocument.txtAction.value=="POH")
    {
     SendPaperDocument.cmdOpen.style.display="none";
     SendPaperDocument.cmdOpenTemplate.style.display="none";
     SendPaperDocument.cmdAccept.style.display="none";
     SendPaperDocument.cmdAddPicture.style.display="none";
     SendPaperDocument.cmdSave.style.display="none"; 
    }
    
    if(SendPaperDocument.txtAction.value=="Record")
    {
     SendPaperDocument.cmdProtect.style.display=""; 
    }   
   }
  </script>
 </HEAD>
 <BODY leftMargin="0" topMargin="0" onload="PageLoad('<%=Session["WAF_UserCName"]%>')">
  <form id="SendPaperDocument" method="post" runat="server">
   <FONT face="宋体">
    <TABLE id="Table1" height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
     <TR>
      <TD>
       <!--OBJECT language="vbscript" id="oframe" height="99.96%" width="100%" classid="clsid:00460182-9E5E-11d5-B7C8-B8269041DD57" name="oframe" VIEWASTEXT-->
       <OBJECT language="vbscript" id="oframe" height="99.96%" width="100%" CLASSID="CLSID:00460182-9E5E-11d5-B7C8-B8269041DD57" CODEBASE="dsoframerctl.CAB#version=1,0,0,0" name="oframe" VIEWASTEXT>
        <PARAM NAME="_ExtentX" VALUE="15954">
        <PARAM NAME="_ExtentY" VALUE="13573">
        <PARAM NAME="BorderColor" VALUE="-2147483632">
        <PARAM NAME="BackColor" VALUE="-2147483643">
        <PARAM NAME="ForeColor" VALUE="-2147483640">
        <PARAM NAME="TitlebarColor" VALUE="52479">
        <PARAM NAME="TitlebarTextColor" VALUE="0">
        <PARAM NAME="BorderStyle" VALUE="1">
        <PARAM NAME="Titlebar" VALUE="0">
        <PARAM NAME="Toolbars" VALUE="1">
       </OBJECT>
      </TD>
     </TR>
     <TR height="30">
      <TD>
       <INPUT class="button" style="display:none" onclick="NewDoc" type="button" value="新建文件" id="cmdNew">&nbsp;<INPUT class="button" onclick="OpenDoc" type="button" value="打开文件" id="cmdOpen">
       <INPUT class="button" onclick="OpenWebDoc" type="button" value="打开模板" id="cmdOpenTemplate"> <INPUT class="button" onclick="UploadDoc('<%Response.Write(System.Configuration.ConfigurationSettings.AppSettings["SendPaperDocPath"].ToString());%>')" type="button" value="保存文件" id="cmdSave"> <INPUT class="button" onclick="ViewHistory" type="button" value="查看历史" id="cmdViewHistory">
        <INPUT class="button" onclick="AcceptRevisions" type="button" value="清稿" id="cmdAccept">
         <INPUT class="button" onclick="AddPicture('<%Response.Write(System.Configuration.ConfigurationSettings.AppSettings["SendPaperDocOpenPath"].ToString());%>')" type="button" value="用印" id="cmdAddPicture">
          <INPUT class="button" onclick="PrintDoc" type="button" value="打印" id="cmdPrint">
          <INPUT class="button" style="display:none" onclick="ProtectDoc('<%Response.Write(System.Configuration.ConfigurationSettings.AppSettings["SendPaperDocPath"].ToString());%>')" type="button" value="保护文件" id="cmdProtect">
       <INPUT class="button" style="display:none" onclick="CloseDoc('')" type="button" value="关闭文件"> <INPUT id="txtPaperGuid" style="DISPLAY: none" type="text" runat="server" NAME="txtPaperGuid">
       <INPUT id="txtAction" style="DISPLAY: none" type="text" runat="server" NAME="txtAction">
       <INPUT id="txtFileName" style="DISPLAY: none" type="text" NAME="txtFileName"></TD>
     </TR>
    </TABLE>
   </FONT>
  </form>
 </BODY>
</HTML>

posted @ 2004-06-04 07:58  mp3 swf  阅读(8322)  评论(16编辑  收藏  举报