[实战5]-find out missing data from cdw report
2016-01-18 22:22
176 查看
'***********************************************************
'* Windows Script Source Code *
'*Used for collecting CDW Missing data report *
'*HM Senior IT: Eric Fu eric.fu@hm.com *
'*Date: 18 Jan 2016 *
'*Any Site can change infor depend on your request *
'**********************************************************
'on error resume next
sFolder = "C:\temp\cdw\source\"
Dim WDay(7),Wformat
WDay(1)="Sun"
WDay(2)="Mon"
WDay(3)="Tue"
WDay(4)="Wed"
WDay(5)="Thu"
WDay(6)="Fri"
WDay(7)="Sat"
Wformat=WDay(Weekday(Now))
'wscript.echo Wformat
Dim fs, oFolder, oFiles, oSubFolders
set fs = CreateObject("Scripting.FileSystemObject")
set oFolder = fs.GetFolder(sFolder) '获取文件夹
set oFiles = oFolder.Files '获取文件集合
for each file in oFiles
'sExt = fs.GetExtensionName(file) '获取文件扩展名
'sExt = LCase(sExt) '转换成小写
'message = "文件名:" & file.Name & ", 扩展名:" & sExt '获得文件名(含扩展名,不含路径)和扩展名
excelmessage=file.Name 'get excel file name
'MsgBox excelmessage
'====need to kill excel process first====
Next
dim oExcel,oWb,oSheet
Set oExcel= CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(sFolder & excelmessage)
'set oSheet = oWb.Sheets("Sheet1") 'MsgBox oSheet.Range("C4").Value
oExcel.WorkSheets(1).Activate
k=oExcel.ActiveSheet.Range("A65536").End(-4162).Row '获取A列最后个非空单元格行号
'wscript.echo k
'Msgbox oExcel.Cells(6,4).Value
set flog = fs.OpenTextFile("C:\temp\cdw\MissingStoreLog-"&Wformat&".log", 2,True)
flog.WriteLine("-----Missing Store Log data equal to 0 -----")
for i = 1 to k
if oExcel.Cells(i,4).Value = "0" then
'msgbox oExcel.Cells(i,3).Value
set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)
do until fcase.atendofstream
j = 0
strline=fcase.readline
MyArray=Split(strline," ",-1,1)
'msgbox MyArray(0)
'msgbox MyArray(1)
if oExcel.Cells(i,3).value = MyArray(0) then
j = j + 1
exit do
end if
loop
if j = 1 then
flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))
else
flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")
end if
set MyArray = nothing
j = 0
fcase.close
'flog.WriteLine (oExcel.Cells(i,3).Value)
end if
Next
'=========missing store log data equal to null==========
flog.WriteLine("-----Missing Store Log data equal to null -----")
for i = 1 to k
if oExcel.Cells(i,4).Value = "" then
'msgbox oExcel.Cells(i,3).Value
'flog.WriteLine (oExcel.Cells(i,3).Value)
set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)
do until fcase.atendofstream
j = 0
strline=fcase.readline
MyArray=Split(strline," ",-1,1)
'msgbox MyArray(0)
'msgbox MyArray(1)
if oExcel.Cells(i,3).value = MyArray(0) then
j = j + 1
exit do
end if
loop
if j = 1 then
flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))
else
flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")
end if
set MyArray = nothing
j = 0
fcase.close
end if
Next
wscript.sleep 1000
oExcel.WorkBooks.Close
oExcel.Quit
flog.Close()
set flog = nothing
set fs = nothing
本文出自 “Erick WAY” 博客,谢绝转载!
'* Windows Script Source Code *
'*Used for collecting CDW Missing data report *
'*HM Senior IT: Eric Fu eric.fu@hm.com *
'*Date: 18 Jan 2016 *
'*Any Site can change infor depend on your request *
'**********************************************************
'on error resume next
sFolder = "C:\temp\cdw\source\"
Dim WDay(7),Wformat
WDay(1)="Sun"
WDay(2)="Mon"
WDay(3)="Tue"
WDay(4)="Wed"
WDay(5)="Thu"
WDay(6)="Fri"
WDay(7)="Sat"
Wformat=WDay(Weekday(Now))
'wscript.echo Wformat
Dim fs, oFolder, oFiles, oSubFolders
set fs = CreateObject("Scripting.FileSystemObject")
set oFolder = fs.GetFolder(sFolder) '获取文件夹
set oFiles = oFolder.Files '获取文件集合
for each file in oFiles
'sExt = fs.GetExtensionName(file) '获取文件扩展名
'sExt = LCase(sExt) '转换成小写
'message = "文件名:" & file.Name & ", 扩展名:" & sExt '获得文件名(含扩展名,不含路径)和扩展名
excelmessage=file.Name 'get excel file name
'MsgBox excelmessage
'====need to kill excel process first====
Next
dim oExcel,oWb,oSheet
Set oExcel= CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(sFolder & excelmessage)
'set oSheet = oWb.Sheets("Sheet1") 'MsgBox oSheet.Range("C4").Value
oExcel.WorkSheets(1).Activate
k=oExcel.ActiveSheet.Range("A65536").End(-4162).Row '获取A列最后个非空单元格行号
'wscript.echo k
'Msgbox oExcel.Cells(6,4).Value
set flog = fs.OpenTextFile("C:\temp\cdw\MissingStoreLog-"&Wformat&".log", 2,True)
flog.WriteLine("-----Missing Store Log data equal to 0 -----")
for i = 1 to k
if oExcel.Cells(i,4).Value = "0" then
'msgbox oExcel.Cells(i,3).Value
set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)
do until fcase.atendofstream
j = 0
strline=fcase.readline
MyArray=Split(strline," ",-1,1)
'msgbox MyArray(0)
'msgbox MyArray(1)
if oExcel.Cells(i,3).value = MyArray(0) then
j = j + 1
exit do
end if
loop
if j = 1 then
flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))
else
flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")
end if
set MyArray = nothing
j = 0
fcase.close
'flog.WriteLine (oExcel.Cells(i,3).Value)
end if
Next
'=========missing store log data equal to null==========
flog.WriteLine("-----Missing Store Log data equal to null -----")
for i = 1 to k
if oExcel.Cells(i,4).Value = "" then
'msgbox oExcel.Cells(i,3).Value
'flog.WriteLine (oExcel.Cells(i,3).Value)
set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)
do until fcase.atendofstream
j = 0
strline=fcase.readline
MyArray=Split(strline," ",-1,1)
'msgbox MyArray(0)
'msgbox MyArray(1)
if oExcel.Cells(i,3).value = MyArray(0) then
j = j + 1
exit do
end if
loop
if j = 1 then
flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))
else
flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")
end if
set MyArray = nothing
j = 0
fcase.close
end if
Next
wscript.sleep 1000
oExcel.WorkBooks.Close
oExcel.Quit
flog.Close()
set flog = nothing
set fs = nothing
本文出自 “Erick WAY” 博客,谢绝转载!
相关文章推荐
- Flash动画导出到Cocos Studio动作编辑器
- Tachyon--以内存为核心的开源分布式存储系统
- centos6上RPM方式安装MySQL5.6
- android 学习入门小结1
- EditText 光标的颜色
- 58怎么玩数据库架构(upyun架构与运维大会速记)
- 架构师需要了解的Paxos原理、历程及实战
- 【第十三章】 测试 之 13.1 概述 13.2 单元测试 ——跟我学spring3
- Android 错误:IllegalStateException: Can not perform this action after onSaveInstanceState
- 4--mysql学习笔记--前面内容复习
- cacti安装后提示图形文件不存在
- Android 错误:IllegalStateException: Can not perform this action after onSaveInstanceState
- 学习小记--wlan基础知识
- Java关键字transient和volatile
- 好博客网址
- androidStudio集成讲解
- Java学习——多态
- Linkedin工程师是如何优化他们的Java代码的
- Android特效专辑(五)——自定义圆形头像和仿MIUI卸载动画—粒子爆炸
- 栈和队列的转换