guanxf

我的博客:http://blog.sina.com.cn/17learning

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  71 随笔 :: 1 文章 :: 41 评论 :: 0 Trackbacks

#

一:JQuery验证表单:
     if($("#insertDABox").attr("checked")){ //如果选择插入编号
           $("#saveType").attr("value","insert");
            }else{
            $("#saveType").attr("value","add");
            }  
   }
     //校验表单
  function  checkDept(){
  if($("#deptAcct").val()=="" || null==$("#deptAcct").val() ){
               alert("请输入单位编号");
                $("#deptAcct").focus();
               return false;
           }
  if($("#deptAcct").val().length>4){
               alert("请输入单位编号太长");
                $("#deptAcct").focus();
               return false;
           }
           
           if($("#deptName").val()=="" || null==$("#deptName").val() ){
               alert("请输入单位名称");
               $("#deptName").focus();
               return false;
            }
           if($("#deptName").val().length>25){
               alert("输入的单位名称太长");
                $("#deptName").focus();
               return false;
           }
           var regEmail=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
           var rege = new RegExp(regEmail); 
           if($("#deptEmail").val().length>0){
          if(!rege.test($("#deptEmail").val())){ 
                alert("输入的邮件不正确!");
                $("#deptEmail").focus();
                 return false;
          }
           }
           
           if($("#deptTel").val().length>13){
                alert("输入电话号码不正确!");
                $("#deptTel").focus();
                 return false;
           }
2、使用javascript封装对象:
(1)、封装类:
function validate_required(field,alerttxt){
with (field) {
if (value==null||value=="")
 {alert(alerttxt);return false}
else {return true}
}
}
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2){
alert(alerttxt);return false}
else {return true}
}
}
(2)、前台调用:
function validate_form(thisform){
with (thisform){
  if (validate_required(issueName,"杂志名不能为空!")==false){
    issueName.focus();return false
    }
   if (validate_required(nextIssue,"下一期刊号不能为空!")==false){
    nextIssue.focus();return false
    }
}
return true;
  }

3、使用Ajax表单验证:
(1)、jsp页面
  $.post('${path}/deptServlet?method=insert&currentPage=${currentPage}',{
          deptAcct:$("#deptAcct").val(),
                     deptName:$("#deptName").val()
      },function(data){
      if('0'==data){
      alert("请单位编号错误,请重新输入!");
         $("#deptAcct").focus();
      return false;
      }else{
      alert("添加成功");
      window.location.href="${path}/deptServlet?method=goToInsert";
         }
      ///pages/rights/admin/dept/insert.jsp
      },'josn');
(2)、java:
sendJson(“你输入的信息不正确!!”, resp);
posted @ 2012-09-28 15:46 管先飞 阅读(1215) | 评论 (0)编辑 收藏

1、主要方法:
               String startDate = req.getParameter("startDate"); 
String endDate = req.getParameter("endDate");
UserVO users = (UserVO) req.getSession().getAttribute("users");
List<ReportBaseVO> titleList = MessageCountService.titleList();  //表列
List<ReportBaseVO> mentList=MessageCountService.findMentList(users,messType); //表行
                List<ReportDataVO> dataList=MessageCountService.findData(users,messType,startDate,endDate); //数据集
Map<String,String> dataMap = ReportService.getReport(dataList); //装入Map
2、方法实现:
//0:满意 1:非常满意2:不满意 
public static List<ReportBaseVO> titleList(){
List<ReportBaseVO> list = new ArrayList<ReportBaseVO>();
ReportBaseVO vo1 = new ReportBaseVO();
vo1.setCode("0");
vo1.setName("满意");
list.add(vo1);
ReportBaseVO vo2 = new ReportBaseVO();
vo2.setCode("1");
vo2.setName("基本满意");
list.add(vo2);
ReportBaseVO vo3 = new ReportBaseVO();
vo3.setCode("2");
vo3.setName("不满意");
list.add(vo3);
return list;
}

public static List<ReportBaseVO> findMentList(UserVO users,String type){
List<ReportBaseVO> list = new ArrayList<ReportBaseVO>();
         
if((users.isHave("0") && ("1".equals(type)||type==null||"".equals(type)))||users.isHave("1") && ("1".equals(type)||type==null||"".equals(type))){
ReportBaseVO vo1 = new ReportBaseVO();
vo1.setCode("1");
vo1.setName("局长信箱");
list.add(vo1);
}
}

public static List<ReportDataVO> findData(UserVO users, String messType,String startDate,String endDate){
               List<ReportDataVO> list = new ArrayList<ReportDataVO>();
String sql="select APPRAISAL as titleId,MESS_TYPE as mentId,count(ID) as count from act_message where DELETE_FLAG='0' and APPRAISAL<>'' and MESS_TYPE='1' group by MESS_TYPE,APPRAISAL";
List<ReportDataVO> reportDataList = DBBeanUtil.execute(conn, new ReportDataVO(),sql);
list.addAll(reportDataList);
return list;
}

public static Map<String,String> getReport(List<ReportDataVO> paraList){
Map<String, String> reportMap = new HashMap<String, String>();
for(int i=0;i<paraList.size();i++){
ReportDataVO p = paraList.get(i);
reportMap.put(p.getMentId()+"_"+p.getTitleId(), String.valueOf(p.getCount()));
}
return reportMap;
}

3、遍历数据:
Map<String,String> dataMap = ReportService.getReport(dataList);
String[][] data = new String[mentList.size()][titleList.size()];
for (int i = 0; i < mentList.size(); i++) {
mentList.get(i).getName();  
int typeAll=0;
for (int j = 0; j < titleList.size(); j++) {
String dateMa=mentList.get(i).getCode()+ "_" + titleList.get(j).getCode();
//             out.print("titleList.get(j).getCode():"+titleList.get(j).getCode());
String content = dataMap.get(dateMa);//IsTurn0
if (content == null || "".equals(content)) {
content = "0";
}
data[i][j] = content;
typeAll=Integer.parseInt(content)+typeAll;
}
BigDecimal point = new BigDecimal(0);
BigDecimal mcount=new BigDecimal(data[i][0]).add(new BigDecimal(data[i][1]));//满意发布件数
BigDecimal atotal=mcount.add(new BigDecimal(data[i][2]));//共发布件数
if(atotal.compareTo(new BigDecimal(0))!=0){
point = new BigDecimal(100).multiply(mcount.divide(atotal,2, RoundingMode.HALF_UP));
}
}
posted @ 2012-09-12 23:57 管先飞 阅读(334) | 评论 (0)编辑 收藏

一、提交表单:
function listUploadFileText(id,fileType,fileTextCategory){
  //执行修改
  $.post("scb/fileTextInfo.action",{
  approvalMaterialId:id,fileCategory:fileTextCategory
  },function(data,status){
  //alert(data);
  showFileTextList(data);
  },'json');  
}

二、上传附件:

function selFileUpload(baseid,fileUploadCategory){
//判断上传材料的合法性
$("#subUploadTextFileId").val($("#formatTextFileId").val());   //formatTextFileId为附件file文本的ID,subUploadTextFileId为隐藏域的ID
if($.trim($("#subUploadTextFileId").val())!="" && $("#subUploadTextFileId").val()!="null"){
var ext = GetExtensionFileName($("#subUploadTextFileId").val());  //GetExtensionFileName,得到文件的后缀名
if( !(ext == "doc" || ext == "docx" || ext=="xlsx" || ext=="xls" || ext=="jpg" || ext=="gif" || ext=="pdf")){
alert("上传文件格式错误,只能上传doc、docx、xlsx、xls、jpg、gif、pdf文档!");
return false;
}
}
     urlAction='scb/fileText.action?textFileCategory='+fileUploadCategory+'&sysFileTextId='+sysUpFileTextId;
}
    fileNameId="formatTextFileId";
    
    $.ajaxFileUpload(
     {  
     url:urlAction,            //需要链接到服务器地址    
     secureuri:false,
     fileElementId:fileNameId,                     //文件选择框的id属性
     dataType:'json',                              //服务器返回的格式
     success: function (data,status)   //回调会值
     //相当于java中try语句块的用法
    {    
      //alert(data);  //对象
    if(status == 'success'){
     addFileBack(data); 
    }else{
    alert(data.error);
    }    
     },
     error: function (data, status, e){            //相当于java中catch语句块的用    
//         alert("222.");
          alert(e);
      }
       } 
    );
}
posted @ 2012-06-08 14:58 管先飞 阅读(3254) | 评论 (1)编辑 收藏

1、在Struts2对于的action类中:
  FlowChart fcName;
  URLEncoder.encode(fcName.getFlowChartName(),"UTF-8")
2、在接受页面转码:
 String fcName= new String(request.getParameter("fcName").getBytes("ISO-8859-1"),"UTF-8");
3、JavaScript传中文值给Action出现乱码问题解决
new String(newFileName.getBytes("ISO-8859-1"),"UTF-8") ;
多学一点 

posted @ 2012-05-17 11:15 管先飞 阅读(359) | 评论 (0)编辑 收藏

1、配置文件(project.properties ):
  xzql.refFilePath=www.baidu.com
2、读取properties文件:
try{
        /* 创建输入流 */  
         InputStream is = this.getClass().getClassLoader().getResourceAsStream("project.properties"); 
          Properties p = new Properties();
      try {
     p.load(is);       //Properties 对象已生成,包括文件中的数据
      }catch(IOException e){
       e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
      }
      
      String refFp=p.getProperty("xzql.refFilePath");

posted @ 2012-05-17 11:02 管先飞 阅读(360) | 评论 (0)编辑 收藏

LotusScript代码如下:

 firstday=Evaluate(|@Weekday(@Date(| & Year(today) & |;1;1))|)  '得到元旦是星期几
 test=Evaluate(|@Date(|& Year(Today) &|;1;1)|)   '得到第一天
days=CInt((today-test(0)))   '用当前日期减掉第一天,计算出今年过了多少天。
jldays=days+firstday(0)   '第一周不固定,所以将第一周有几天加到距离今天的日期上 
        weeks=CInt(StrLeft(CStr((days+firstday(0)-1)/7),".") )+1   '取到当前日期的周数+第一周  
       If(weeks>9) Then 
thisyearweek=CStr(weeks)
Else 
thisyearweek="0"+Cstr(weeks)
    End If
thisyearweekText=Year(today) & "年第" & thisyearweek & "周"
MsgBox thisyearweekText

转载如下:

说明一下,我这里是以星期日作为一周的开始
思路如下:
首先要计算今天离元旦相差多少天,然后除以7就得出今天离元旦多少个星期了。
这里要判断有无余数,如果有余数,则把商加1,就得出今天相距元旦多少个星期了。
程序代码程序代码

REM {获取元旦};
yuandan := @ToTime(@Text(@Year(@Now))+"-01-01");
x:= @Integer(((@Today-yuandan)/(3600*24)+1)/7);
y:=((@Today-yuandan)/(3600*24)+1)/7;
@If(y-x>0;x+1;x)

但目前算出的只是今天相距元旦的星期数,并不是真正的周次。
因为每年元旦并不都是星期日,例如2006年的元旦是星期日,则本年的第一周是完整的一周(有7天)。
如果元旦不是星期日,则本年的第一周就只有(7-星期数)天。
例如2005年的元旦是星期六,则本年的第一周只有1天,1月2号就是第二周的开始了。 
所以如果只用上面的四行代码,是不符合实际情况的。

而且上面的代码还有bug,如果@Today是元旦,那会输出0。

要计算真正的周次,就要从第二周开始算起。
第一周的天数是7减元旦的星期数,
如果元旦是星期日, @Weekday(yuandan)返回1,星期一返回2。
所以星期数要减一。代码如下:

程序代码程序代码

yuandan := @ToTime(@Text(@Year(@Now))+"-01-01"); 
wd := @Weekday(yuandan);
t := 7-(wd-1); 



用@Today 减元旦,再减第一周天数t,再加一,就是@Today到第二周开始的天数t1。
这里要做个判断,
If @Today 就是第一周里的,那得出的结果t1就会是负数,我们可以直接输出@Today 所在周次是第一周。
Else  用 t1除以7,得出@Today 距离第二周有多少周。 然后加上1,就是加上第一周。就得出实际的周次了。

这里还有个需求就是,一年365天,就等于52周加1天。每年的第53周与下一年的第一周其实是同一周,
所以这里的周报只算52周,如果算到第53周,就改为下一年的第一周。
具体实现就是把53改为1,然后把年份那个域的值加1。

程序代码程序代码
@If(z=53;z:=1;z);

完整代码如下:

程序代码程序代码

REM {获取元旦};
yuandan := @ToTime(@Text(@Year(@Now))+"-01-01");
REM {判断元旦是否sunday,@Weekday(sunday)=1};
wd := @Weekday(yuandan);
@If(wd=1;
@Do(
x:= @Integer(((@Today-yuandan)/(3600*24)+1)/7);
y:=((@Today-yuandan)/(3600*24)+1)/7;
@If(y-x>0;x+1;x)
);
@Do(
t := 7-(wd-1);
t1 := (@Today-yuandan)/(3600*24)-t+1;
@If(t1>0;
@Do(
x:=@Integer(t1/7);
y:=t1/7;
@If(y-x>0;z:=x+2;z:=x+1);
@If(z=53;z:=1;z);
z
);
@Do(
1
))
)
)
1.计算当天所在周从周一到周日的天数
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
weekend:=@Adjust(weekstart;0;0;6;0;0;0);
Text(weekstart)+"至"+@Text(weekend)
2.计算当天所在周每一天的日期
星期一:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
@Text(weekstart;"D2")
星期二:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;1;0;0;0);
@Text(week;"D2")
星期三:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;2;0;0;0);
@Text(week;"D2")
星期四:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;3;0;0;0);
@Text(week;"D2")
星期五:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;4;0;0;0);
@Text(week;"D2")
星期六:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;5;0;0;0);
@Text(week;"D2")
星期天:
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-2);0;0;0);
week:=@Adjust(weekstart;0;0;6;0;0;0);
@Text(week;"D2")

3.计算任意一周的周一至周日
很简单,假设当周为CurrentWeekNo; 任意一周为:WeekNo;要计算任意一周的周一至周日公式就是:
tmp:=CurrentWeekNo-WeekNo;
step:=2-tmp*7;
rem {任意一周的周一,得到周一,那二/三/四...就很轻松得到};
weekstart:=@Adjust(@Today;0;0;-(@Weekday(@Today)-step);0;0;0);
posted @ 2012-02-20 22:36 管先飞 阅读(1595) | 评论 (0)编辑 收藏

创建文档显示如下:
厂家名称           公司得分        时间
厂家A                 200            @create
厂家B                  300         @create
 厂家a                 300          @create

显示结果:
    厂家名称           公司得分        时间  
 厂家A                 500            @create 
  厂家B               200            @create 
代码如下:
Sub Initialize
On  Error  GoTo  errorHandle
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument  
Dim valueCategory As String
Dim nowTime As   Variant
Set db = session.CurrentDatabase
Set view = db.GetView("showCategory")
Set doc = view.GetFirstDocument()
      If Not doc Is Nothing Then
      valueCategory=CStr(doc.sortCategory(0))      ‘从前台获得显示条件
      Else
      valueCategory="总排行"     
      End If
While Not(doc Is Nothing)
Call doc.Remove(True)
Set doc = view.GetFirstDocument()
Wend
Call showContent(valueCategory)
Exit Sub
 errorHandle:
MsgBox  "showFddl  error:"+CStr(Erl)+"行"+Error
Exit Sub
End Sub
Function  showContent(valueCategory As String)
On Error GoTo eHandle
Dim s As New NotesSession
Dim db As NotesDatabase,view As NotesView
Dim entryc As NotesViewEntryCollection,entryA As NotesViewEntry,entryB As NotesViewEntry
Dim nav As NotesViewNavigator
Dim value As Integer    '每个评分
Dim comcount As Integer '一个公司的评分次数
Dim comarr  As Variant ,valuearr  As Variant  '公司和评分数组
Dim entry As NotesViewEntry
Dim com As String
Dim comnew As String
Dim comlast As String 
Dim comString As String
Dim  valueString As String
Dim count As Integer
Dim doc,doc2,doc3 As NotesDocument
Dim valueb As  Integer
Dim  oldtime As  String
Dim  nowTime As String
Dim rview As NotesView
Dim  rdoc As NotesDocument
Dim docTime1,docTime2,docTime3 As String '保存的文档时间
'清空视图
Set db=s.Currentdatabase
Set rview= db.GetView("s_showFddl")
Set rdoc = rview.GetFirstDocument()
While Not(rdoc Is Nothing)
Call rdoc.Remove(True)
Set rdoc = rview.getfirstdocument()
Wend
'遍历视图
Set db=s.currentdatabase
Set view = db.getview("showFddl")
Set nav=view.createviewnav()   '遍历器
Set entryA=nav.getfirst
comcount=0
If Not entryA Is Nothing Then
com = entryA.Columnvalues(1)  '得到公司名称
value =CInt(entryA.Columnvalues(0)) '得到总分
oldtime =entryA.Columnvalues(2)  '得到文档的时间
comcount=1
comlast=com
If valueCategory="本周排行"  Then   '根据条件进行帅选
firstday=Evaluate(|@Weekday(@Date(| & Year(Today) & |;1;1))|)
test=Evaluate(|@Date(|& Year(Today) &|;1;1)|)'第一天(元旦)
days=CInt((today-test(0)))  
      weeks=CInt(StrLeft(CStr((days+firstday(0)-1)/7),".") )+1
If(weeks>9) Then
thisyearweek=CStr(weeks)
Else 
thisyearweek="0"+Cstr(weeks)
End If
nowTime=CStr(Year(Today)&"#"& thisyearweek)
tempOldTime=CDat(Format(oldtime,"yyyy-m-d"))
firstday2=Evaluate(|@Weekday(@Date(| & Year(oldtime) & |;1;1))|)
test2=Evaluate(|@Date(|&Year(oldtime) &|;1;1)|)'第一天(元旦)
days2=CInt(tempOldTime-test2(0))  
   weeks2=CInt(StrLeft(CStr((days2+firstday2(0)-1)/7),".") )+1
If(weeks2>9) Then
thisyearweek2=CStr(weeks2)
Else 
thisyearweek2="0"+Cstr(weeks2)
End If
docTime1=CStr(Year(oldTime))+"#"+CStr(thisyearweek2)
ElseIf   valueCategory="本月排行" Then
nowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
docTime1=CStr(Year(oldtime))+"#"+CStr(Month(oldtime))
ElseIf   valueCategory="本季度排行" Then
tempNowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
rNowTime=StrRight(tempNowTime,"#")
lNowTime=StrLeft(tempNowTime,"#")
            tempDocTime1=CStr(Year(oldtime))+"#"+CStr(Month(oldtime))
RDocTime1=StrRight(tempDocTime1,"#")
lDocTime1=StrLeft(tempDocTime1,"#")
If lNowTime=lDocTime1    Then
If (0<rNowTime<4) And (0<rDocTime1<4) Then
nowTime="=="
docTime1="==" 
End If
If (4<=rNowTime<7) And (4<=rDocTime1<7) Then
nowTime="=="
docTime1="==" 
End If
If (7<=rNowTime<10) And (7<=rDocTime1<10) Then
nowTime="=="
docTime1="==" 
End If
If (10<=rNowTime<13) And (10<=rDocTime1<13) Then
nowTime="=="
docTime1="==" 
End If
Else
                nowTime="=="
docTime1="!=="  
End If
  ElseIf   valueCategory="总排行" Then
nowtime=""
    docTime1=""
End If
Set entryB = nav.getnext(entryA)
If Not entryB Is Nothing Then 
comnew = entryB.Columnvalues(1)
If Not comnew=comlast Then            
If(nowtime=docTime1)  Then    '和当前时间做对比
Set doc = New NotesDocument(db)  '保存新文档显示到s_showWhxf视图中
doc.form="pjSumfile"
doc.S_unitName=com
doc.S_no1=value
doc.S_time=Evaluate("@Now")
doc.S_category="电缆防盗器厂家"
Call doc.Save(True,True)
                    comString=comString+"#:"+com       '公司名称字符串
valueString=valueString+"#"+CStr(value) '公司评分字符串
      End If 
com=""
value=0
comcount=0
comnew=""
End If
Else 
If(nowTime=docTime1)  Then
Set doc = New NotesDocument(db)
doc.form="pjSumfile"
doc.S_unitName=com
doc.S_no1=value
doc.S_time=Evaluate("@Now")
doc.S_category="电缆防盗器厂家"
Call doc.Save(True,True)
End If
End If
End If
If Not (nowTime=docTime1)   Then 
value=0 '第一个文档的时间
comcount=0
End If
While Not entryB Is Nothing
com = entryB.Columnvalues(1)
valueNext=entryB.Columnvalues(2)
If  valueCategory="本月排行" Then
nowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
docTime2=CStr(Year(valueNext))+"#"+CStr(Month(valueNext))
ElseIf valueCategory="本周排行" Then
firstday=Evaluate(|@Weekday(@Date(| & Year(Today) & |;1;1))|)
test=Evaluate(|@Date(|& Year(Today) &|;1;1)|)'第一天(元旦)
days=CInt((today-CDat(test(0))))  
weeks=CInt(StrLeft(CStr((days+firstday(0)-1)/7),".") )+1
If(weeks>9) Then
thisyearweek=CStr(weeks)
Else 
thisyearweek="0"+Cstr(weeks)
End If
nowTime=CStr(Year(Today)&"#"& thisyearweek)
tempOldTime2=CDat(Format(valueNext,"yyyy-m-d"))
firstday2=Evaluate(|@Weekday(@Date(| & Year(valueNext) & |;1;1))|)
test2=Evaluate(|@Date(|&Year(valueNext) &|;1;1)|)'第一天(元旦)
days2=CInt(CDat(tempOldTime2)-CDat(test2(0)))  
weeks2=CInt(StrLeft(CStr((days2+firstday2(0)-1)/7),".") )+1
If(weeks2>9) Then
thisyearweek2=CStr(weeks2)
Else 
thisyearweek2="0"+Cstr(weeks2)
End If
docTime2=CStr(Year(valueNext))+"#"+CStr(thisyearweek2)
  ElseIf   valueCategory="本季度排行" Then
tempNowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
rNowTime=StrRight(tempNowTime,"#")
lNowTime=StrLeft(tempNowTime,"#")
tempDocTime2=CStr(Year(valueNext))+"#"+CStr(Month(valueNext))
RDocTime2=StrRight(tempDocTime2,"#")
lDocTime2=StrLeft(tempDocTime2,"#")
If lNowTime=lDocTime2    Then
If (0<rNowTime<4) And (0<rDocTime2<4) Then
nowTime="=="
docTime2="==" 
End If
If (4<=rNowTime<7) And (4<=rDocTime2<7) Then
nowTime="=="
docTime2="==" 
End If
If (7<=rNowTime<10) And (7<=rDocTime2<10) Then
nowTime="=="
docTime2="==" 
End If
If (10<=rNowTime<13) And (10<=rDocTime2<13) Then
nowTime="=="
docTime2="==" 
End If
Else
nowTime="=="
docTime2="!=="  
End If
ElseIf   valueCategory="总排行" Then
nowtime=""
docTime2=""
End If
If( nowTime=docTime2)   Then
value=value+entryB.Columnvalues(0) '第二个文档的值
   comcount=comcount+1   '有几个相同的值
End If
If(nowTime=docTime3)  Then 
    valueb=valueb+entryB.Columnvalues(0) '最后一个文档的值
End If
comlast=com
Set entryB = nav.getnext(entryB)
If Not entryB Is Nothing Then
comnew = entryB.Columnvalues(1)
If   valueCategory="本月排行" Then
nowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
docTime3=CStr(Year(valueNext))+"#"+CStr(Month(valueNext))
ElseIf valueCategory="本周排行" Then
firstday=Evaluate(|@Weekday(@Date(| & Year(Today) & |;1;1))|)
test=Evaluate(|@Date(|& Year(Today) &|;1;1)|)'第一天(元旦)
days=CInt((today-test(0)))  
weeks=CInt(StrLeft(CStr((days+firstday(0)-1)/7),".") )+1
If(weeks>9) Then
thisyearweek=CStr(weeks)
Else 
thisyearweek="0"+Cstr(weeks)
End If
nowTime=CStr(Year(Today)&"#"& thisyearweek)
tempOldTime=CDat(Format(valueNext,"yyyy-m-d"))
firstday3=Evaluate(|@Weekday(@Date(| & Year(valueNext) & |;1;1))|)
test3=Evaluate(|@Date(|&Year(valueNext) &|;1;1)|)'第一天(元旦)
days3=CInt(tempOldTime-test3(0))  
weeks3=CInt(StrLeft(CStr((days3+firstday3(0)-1)/7),".") )+1
If(weeks3>9) Then
thisyearweek3=CStr(weeks3)
Else 
thisyearweek3="0"+Cstr(weeks3)
End If
docTime3=CStr(Year(valueNext))+"#"+CStr(thisyearweek3)
 ElseIf   valueCategory="本季度排行" Then
tempNowTime=CStr(Year(Now))+"#"+CStr(Month(Now))
rNowTime=StrRight(tempNowTime,"#")
lNowTime=StrLeft(tempNowTime,"#")
tempDocTime3=CStr(Year(valueNext))+"#"+CStr(Month(valueNext))
rDocTime3=StrRight(tempDocTime3,"#")
lDocTime3=StrLeft(tempDocTime3,"#")
If lNowTime=lDocTime3    Then
If (0<rNowTime<4) And (0<rDocTime3<4) Then
nowTime="=="
docTime3="==" 
End If
If (4<=rNowTime<7) And (4<=rDocTime3<7) Then
nowTime="=="
docTime3="==" 
End If
If (7<=rNowTime<10) And (7<=rDocTime3<10) Then
nowTime="=="
docTime3="==" 
End If
If (10<=rNowTime<13) And (10<=rDocTime3<13) Then
nowTime="=="
docTime3="==" 
End If
Else
nowTime="=="
docTime3="!=="  
End If
ElseIf   valueCategory="总排行" Then
nowtime=""
docTime3=""
End If
If Not comnew=comlast Then   '公司变了
If(nowTime=docTime2)  Then
Set doc2 = New NotesDocument(db)
doc2.form="pjSumfile"
doc2.S_unitName=com
doc2.S_no1=value/comcount
doc2.S_time=Evaluate("@Now")
doc2.S_category="电缆防盗器厂家"
Call doc2.Save(True,True)
                     comString=comString+"#:"+com 
valueString=valueString+"#"+Cstr(value/comcount)
valueb=CInt(entryB.Columnvalues(0))
End If
com=""
value=0
valueb=0
comcount=0
comnew=""
docTime2=""
docTime3=""
End If
Else      '最后一个公司
If(nowTime=docTime3)  Then 
Set doc3 = New NotesDocument(db)
doc3.form="pjSumfile"
doc3.S_unitName=com
doc3.S_no1=valueb/comcount
doc3.S_time=Evaluate("@Now")
doc3.S_category="电缆防盗器厂家"
Call doc3.Save(True,True)
                                 comString=comString+"#:"+com
valueString=valueString+"#"+Cstr(valueb/comcount)
End If
End If  
Wend
'comarr=Split(StrRight(comString,"#"),"#")
'valuearr=Split(StrRight(valueString,"#"),"#")
Exit Function 
eHandle:
MsgBox  "sumFddl showContent错误"+CStr(Erl)+"行"+Error
Exit Function 
End Function
posted @ 2012-02-20 22:30 管先飞 阅读(521) | 评论 (0)编辑 收藏

1、简单方法:
问题automation服务器不能创建对象
解决办法:如果javascript脚本中报这个错误是因为IE的安全设置不允许运行未标记为安全的activeX控件 更改IE的安全设置,把相应的选项打开即可。

Sub Initialize
Dim s As New NotesSession
Dim curdoc As NotesDocument
Dim curdb As NotesDatabase
Dim vw As NotesView
Dim doc As NotesDocument
Dim et As NotesViewEntry
Dim i
i=3
Set curdb=s.CurrentDatabase
Set vw=curdb.GetView("UmSafetyInfo")
Set doc=vw.GetFirstDocument
'Dim x As Variant
'tempstr=|@name([OU2];'|+curdoc.remote_user(0)+|')|
'x=Evaluate(tempstr)
'Msgbox x(0)
Print |
<script language=javascript>
var xls = new ActiveXObject ( "Excel.Application" );
//xls.visible = "false";
var xlBook = xls.Workbooks.Add;
var xlsheet = xlBook.Worksheets(1);
xls.Cells.Select;
xlsheet.Cells(2,1).Value="部门";
xlsheet.Cells(2,2).Value="姓名";
xlsheet.Cells(2,3).Value="分机";
xlsheet.Cells(2,4).Value="移动电话";
xlsheet.Cells(2,5).Value="手机小号";
xlsheet.Cells(2,6).Value="电子邮件";
xlsheet.Cells(2,7).Value="直拨电话";
xlsheet.Rows(2).Font.Bold=1;
xlsheet.Rows(2).Font.Name="宋体";
xlsheet.Range("A1","G1").MergeCells = 1;
xlsheet.Cells(1,1).Value="某某公司";
xlsheet.Range("A1","A1").HorizontalAlignment = 3
//xlsheet.Range("A2","G2").ColorIndex = 48
xlsheet.Rows(1).Font.Bold=1;
xlsheet.Rows(1).Font.Name="黑体";
xlsheet.Rows(1).Font.Size=16;
xlsheet.Rows(2).Font.Size=9;
xlsheet.Columns(1).ColumnWidth = 25
xlsheet.Columns(2).HorizontalAlignment=3
xlsheet.Columns(3).HorizontalAlignment=3
xlsheet.Columns(4).HorizontalAlignment=3
xlsheet.Columns(4).ColumnWidth = 13.63
xlsheet.Columns(5).HorizontalAlignment=3
xlsheet.Columns(6).HorizontalAlignment=3
xlsheet.Columns(6).ColumnWidth = 25
xlsheet.Columns(7).HorizontalAlignment=3
xlsheet.Columns(7).ColumnWidth = 13.63
|

Do While Not (doc Is Nothing)
Print |xlsheet.Rows(|+i|).Font.Size=9;|
Print |xlsheet.Cells(| +i+|,1).Value='|+"Mid(doc.department(0),1)"+|';|
Print |xlsheet.Cells(| +i+|,2).Value='|+"doc.name(0)"+|';|
Print |xlsheet.Cells(| +i+|,3).Value='|+"Cstr(doc.OfficeTelExt(0))"+|';|
Print |xlsheet.Cells(| +i+|,4).Value='|+"Cstr(doc.Cellphone(0))"+|';|
Print |xlsheet.Cells(| +i+|,5).Value='|+"Cstr(doc.CellphoneLittle(0))"+|';|
Print |xlsheet.Cells(| +i+|,6).Value='|+"doc.Email(0)"+|';|
Print |xlsheet.Cells(| +i+|,7).Value='|+"Cstr(doc.OfficeTel(0))"+|';|
i=i+1
Set doc=vw.GetNextDocument(doc)
Loop
Print |
xlBook.SaveAs("c:\\通讯录.xls");
xlBook.Close ();

xls.Quit();
xls=null;
alert("已经保存在C盘 通讯录.xls文件中");
Temp=window.location.href.toLowerCase();

Temp=Temp.substring(0,Temp.lastIndexOf(".nsf")+5)+"UmSafetyInfo?openview";
window.location=Temp;

</script>
|
End Sub

 

 2、常用方法:

 Sub Initialize
 On Error GoTo errormsg  
 Dim session As New NotesSession
 Dim cdoc As NotesDocument
 Dim doc As NotesDocument
 Dim view As NotesView
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Set db=session.currentdatabase
 Set cdoc=session.documentcontext
 Set view=db.GetView("UmSafetyInfo") 
 
 tempDir=session.GetEnvironmentString("Directory", True)  '获取环境变量,将代理权限设低
 If InStr(tempDir, "/") <> 0 And Right(tempDir, 1) <> "/" Then
   tempDir = tempDir & "/domino/html/"
 End If 
 If InStr(tempDir, "\") <> 0 And Right(tempDir, 1) <> "\" Then
   tempDir = tempDir & "\domino\html\"
 End If
    filename="中国电信四川公司安全管理人员数据库.xls" 
 filepath=tempDir & filename
 
 Print |<script language="javascript">alert(|+filepath+|)</script>|
 If Dir(filePath)<>"" Then Kill filePath
 Dim excelapplication As Variant
 Dim excelworkbook As Variant
 Dim excelsheet As Variant
 Dim i As Integer
 Dim uvcols As Integer
 Dim selection As Variant
 Set excelapplication=CreateObject("Excel.Application")
 excelapplication.statusbar="正在创建工作表,请稍等.."
 excelapplication.Visible=False
 Set excelWorkbook = excelApplication.Workbooks.Add
 Set excelSheet = excelWorkbook.Worksheets("sheet1")
 excelsheet.name="中国电信四川公司安全管理人员数据库" '工作表的名字
 
 Dim rows As Integer
 Dim cols As Integer
 Dim maxcols As Integer
 Dim fieldname As String
 Dim fitem As NotesItem
 rows=1 
 excelapplication.statusbar="正在创建单元格,请稍等.."  
 excelapplication.Range(excelsheet.Cells(rows, 1), excelsheet.Cells

(rows, 12)).Merge   '设置title跨几行显示
  
  rows=2
 excelsheet.Rows(2).Font.Bold=1
 excelsheet.Rows(2).Font.Name="宋体"
 excelsheet.Range("A1","L1").MergeCells = 1
 excelsheet.Cells(1,1).Value="中国电信四川公司安全管理人员数据库"
 excelsheet.Range("A1","A1").HorizontalAlignment = 3
 REM  设置风格
 excelsheet.Rows(1).Font.Bold=1
 excelsheet.Rows(1).Font.Name="黑体"
 excelsheet.Rows(1).Font.Size=16
 excelsheet.Rows(2).Font.Size=9
 excelsheet.Columns(1).ColumnWidth = 25
 excelsheet.Columns(2).HorizontalAlignment=3
 excelsheet.Columns(3).HorizontalAlignment=3
 excelsheet.Columns(4).HorizontalAlignment=3
 excelsheet.Columns(4).ColumnWidth = 13.63
 excelsheet.Columns(5).HorizontalAlignment=3
 excelsheet.Columns(6).HorizontalAlignment=3
 excelsheet.Columns(6).ColumnWidth = 25
 excelsheet.Columns(7).HorizontalAlignment=3
 excelsheet.Columns(7).ColumnWidth = 13.63
 
 excelsheet.Cells(rows,1).value="单位名称"
 excelsheet.Cells(rows,2).value="分管领导"
 excelsheet.Cells(rows,3).value="姓名"
 excelsheet.Cells(rows,4).value="安办职务"
 excelsheet.Cells(rows,5).value="性别"
 excelsheet.Cells(rows,6).value="出生年月"
 excelsheet.Cells(rows,7).value="学历"
 excelsheet.Cells(rows,8).value="岗位名称"
 excelsheet.Cells(rows,9).value="是否兼职"
 excelsheet.Cells(rows,10).value="兼职名称"
 excelsheet.Cells(rows,11).value="联系电话"
 excelsheet.Cells(rows,12).value="手机"
 
 cols=12
 maxcols=cols-1 
 excelapplication.statusbar="正在导出数据,请稍等.."
 Set doc=view.Getfirstdocument()
 While Not doc Is Nothing
  rows=rows+1  
  excelsheet.Cells(rows,1).value=doc.UmDeptName(0)
  excelsheet.Cells(rows,2).value=doc.UmManageLeader(0)
  excelsheet.Cells(rows,3).value=doc.UmUserName(0)
  excelsheet.Cells(rows,4).value=doc.UmWorking(0)
  excelsheet.Cells(rows,5).value=doc.UmSex(0)
  excelsheet.Cells(rows,6).value=doc.UmBirtyday(0)
  excelsheet.Cells(rows,7).value=doc.UmEducation(0)
  excelsheet.Cells(rows,8).value=doc.UmWorkName(0)
  excelsheet.Cells(rows,9).value=doc.UmIsFullTime(0)
  excelsheet.Cells(rows,10).value=doc.UmPartTimeWork(0)
  excelsheet.Cells(rows,11).value=doc.UmTel(0)
  excelsheet.Cells(rows,12).value=doc.UmMoblie(0)
  Set doc = view.GetNextDocument(doc)
 Wend
 excelapplication.statusbar="数据导入完成。" 
 excelWorkbook.SaveAs(filePath)
 excelApplication.Quit  
 Set excelapplication=Nothing
  Print "<script>location.href='/"+ filename  +"'</script>" 
 Exit Sub
 
errormsg:
 MsgBox "OutExcel Error:" & Str(Erl) & "  " & Error 
End Sub

 

posted @ 2012-01-05 17:15 管先飞 阅读(2761) | 评论 (0)编辑 收藏

Sub Initialize
 
 On Error Goto errormsg
 Dim session As New notessession
 Dim cdoc As notesdocument
 Dim doc As notesdocument
 Dim view As notesview
 Dim db As notesdatabase
 Dim db_user As NotesDatabase
 Set db=session.currentdatabase
 Set cdoc=session.documentcontext
 Dim mdoc As NotesDocument
 cdocUnid = cdoc.UniversalID
 Set db_user = session.GetDatabase(db.Server,"sctel\lyuser.nsf")
 
 NotesMacro$ = |@AttachmentNames|
 attList = Evaluate(NotesMacro$,cdoc)
 attNames = ""
 For i = Lbound(attList) To Ubound(attList)
  If Trim(attList(i))<> "" Then
   If attNames = "" Then
    attNames = attList(i)
   Else
    attNames = attNames + "," + attList(i)
   End If
  End If
 Next
 Set view=db.getview("SMS_showFile")
 For i=0 To Ubound(cdoc.alldeptName)  
  If Len(Trim(cdoc.alldeptName(i)))>0 Then    
   key=cdocUnid+cdoc.alldeptName(i)
   Msgbox "key;"+key
   Set dc=view.getalldocumentsbykey(key,True)
   Msgbox "dc.count:"+Cstr(dc.count)
   If dc.count>0 Then
    Set doc=dc.getfirstdocument
   Else
    Set doc = New NotesDocument(db)
    Dim authorsItem As New NotesItem(doc, "Author",  _
    "admin", Readers)
    Dim readersItem As New NotesItem(doc, "yhuser",  _
    Trim(cdoc.alldeptName(i)), Authors)
   End If  
   doc.HYUNID=cdocUnid
   doc.SMS_Subject=cdoc.SMS_Subject(0)
   '根据人员取出部门,部门编号
   Set view_user = db_user.GetView("viewShowfileByUserName")
   Set doc_user = view_user.GetDocumentByKey(cdoc.alldeptName(i),True)
   If Not doc_user Is Nothing Then
    doc.TypeNum = doc_user.TypeNum(0)
    Set view_dept = db_user.GetView("viewDeptByNum")
    Set doc_dept = view_dept.getdocumentbykey(doc_user.TypeNum(0),True)
    If Not doc_dept Is Nothing Then
     doc.TypeName = doc_dept.Type(0)
     doc.deptNa = doc_dept.Type(0)
    End If
   End If
   Call doc.save(True,True)'存储    
   Dim SendTo(1) As String   
   SendTo(0) = cdoc.alldeptName(i)
   Call sendMessge(SendTo)
  End If   
 Next
 cdoc.htmls="消息已经发送!"
 'doc.SMS_riqi=Evaluate("@Created")  '重新创建时间
 Call cdoc.save(True,True)'存储 
 cdoc.htmls="<script>alert('发送成功!');</script>" 
 Exit Sub
errormsg:
 Msgbox "save Error:" & Str(Erl) & "  " & Error
 
End Sub


Sub sendMessge(SendTo As Variant)
 On Error  Goto processError 
 Dim session As New notessession
 Set db=session.currentdatabase
 Set cdoc=session.documentcontext
 Dim doc As NotesDocument
 Dim view As NotesView
 Dim UserDB As NotesDatabase
 Dim tel As String
 Dim content As String
 query = cdoc.Query_String_Decoded(0)
 Dim smsitem As NotesItem
 Set smsitem =cdoc.GetFirstItem("SMS_Body") 
 content="您好!请即时处理委机关办公系统中的《"+cdoc.foldername(0)+":"+smsitem.Text+"》文件,谢谢!["+cdoc.PUser(0)+"]"
 'Msgbox"短信内容:"+content
 Dim i,j As Integer
 i = 0
 Set UserDB = session.GetDatabase("","sctel/lyuser.nsf")
 Set view = UserDB.GetView( "cellPhoneByUser" )
 content=Replace(content,">",">")
 content=Replace(content,"<","<")
 Forall p In SendTo
  If p <> "" Then
   '获取处理人号码
   Set doc = view.GetDocumentByKey (p)
   If Not (doc Is Nothing) Then
    tel=doc.CellPhoneNumber(0)
    'Msgbox "tel--->"+tel
    If tel <> "" Then
     Msgbox "开始测试短信"
     Dim xmlhttp As Variant
     Dim data, URL  As String
     Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
     data = |<?xml version="1.0" encoding="utf-8"?>|
     data = data + |<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">|
     data = data + |<soap:Body>|
     data = data+|<sendMessageToNextPerson xmlns="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1">|
     data = data +|<senderaddr>|+Trim(tel)+|</senderaddr>|
     data = data + |<content>|+content+|</content>|
     data = data + |</sendMessageToNextPerson>|
     data = data + |</soap:Body>|
     data = data +|</soap:Envelope>|
     URL="http://localhost:82/sendSMS/gzwSendSM.asmx?op=sendMessageToNextPerson"
     xmlhttp.Open "POST",url, False
     xmlhttp.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
     xmlhttp.SetRequestHeader "Content-Length", "length"
     xmlhttp.SetRequestHeader "SOAPAction","http://Ip:5080/isag/North/SMS/SendSms"
     xmlhttp.Send(data)
    Else     
     Msgbox "未找到号码"
    End If
   Else
    Messagebox "未找到号码"
   End If 
  End If
 End Forall
 
 Exit Sub
 
processError:
 Dim sTemp As String
 sTemp = "ini出错行:" + Cstr(Erl()) + " 出错信息:" + Error() +  " 请与管理员联系!"
 Print |<script>alert("|+sTemp+|")</script>|
 
 Exit Sub
 
End Sub
posted @ 2011-12-29 17:59 管先飞 阅读(336) | 评论 (0)编辑 收藏

1、FTSearch搜索:
    Set dc=db.Ftsearch("name",0)  
         '0位置为最大的查询数,0为所有匹配的文件  FTSearch必须创建数据库索引
 Set doc=dc.Getfirstdocument()、
2、Item:
   Set doc=dc.Getfirstdocument()
 While Not doc  Is Nothing
   ForAll ritem In doc.Items
      MsgBox ritem.name
   End ForAll
 Wend
3、取出特定的域
 Set doc=view.getFirstdocument()
 If doc.HashItem("yu") <> "" Then
    Set item=doc.getfirstitem("yu")
          Set doc=view.getNextdocument(doc)
 End If
4、使用文本属性
If doc.Hashitem("yu") <> ""  Then
 Set doc=dc.Getfirstdocument()
  While Not doc Is  Nothing
    ForAll itemValue In doc.yu
              itemValue = "Anonymous"
          End ForAll   
      Set doc=dc.Getnextdocument(doc)
  Wend
End If
5、获取域值:
   ForAll itemValue In doc.Getitemvalue("yu")
6、添加域
  set item =new NotesItem(doc,"newYu",session.UserName)
  Call doc.Appenditemvalue("newYu",Newvalue)
7、替换值:
  1)、 While Not doc Is Nothing
  Call doc.Replaceitemvalue("resName","newValue")
  Set doc=dc.getnextdocument(doc)
 Wend

   2)、Set doc=dc.Getfirstdocument()
 While Not doc Is Nothing
  'Call doc.Replaceitemvalue("resName","newValue")
  Set item =doc.Getfirstitem("yu")
  While Not item Is Nothing
     ForAll resitems In doc.Itemsv(0)
        resitems="newVlaue"
     End ForAll
     doc.name= doc.Itemsv(0)
     Set item =doc.getnextitem(item)
  Wend
  Set doc=dc.getnextdocument(doc)
 Wend
8、拷贝域
         Set item =doc.Getitemvalue("name")
  call item.Copyitemtodocument(doc, "name")
         call doc.save(true,false)
      Call doc1.Copyallitems(doc2,true)  ‘替换所有的
9、删除指定的域:
     1)、 For j=1 To dc.count
   Set item=doc.Getitemvalue("name")
   While Not item Is  Nothing
    Call item.Remove()
    Call doc.Save(true,false)
   Wend
  Set doc=dc.Getnthdocument(j)
     Next
     2)、For j=1 To dc.count  
  While Not doc.Hasitem("name")
    Call doc.Removeitem("name")
    Call doc.Save(True,false)
  Wend 
   Set doc=dc.Getnthdocument(j)   
 Next
10、RTF文本域的输出:
 Set item=doc.GetFirstItem("RtfYU")
 MsgBox item.Text
11、在代理中使用公式:

     temp=Evaluate("@ReplaceSubstring(aa;bb;cc)",doc)
12、 嵌入对象:
 ForAll csx In doc.Embeddedobjects
    csx.name
 End ForAll
    Set doc=dc.Getnthdocument(j)
       Next
13、激活嵌入对象:
    Call doc.EmbeddedObjects(0).Activate(True)
14、if的用法
    Set doc=dc.Getfirstdocument()
    If Not IsEmpty(db.Agents) Then
    ForAll agent In db.Agents
     MsgBox agent.name
    End ForAll
     End If

 

posted @ 2011-12-26 00:46 管先飞 阅读(1335) | 评论 (0)编辑 收藏

仅列出标题
共7页: 上一页 1 2 3 4 5 6 7 下一页