Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

powershell - Help inserting db query results to a CSV file -


i have table contains information pointing files stored on file server. i'm trying write powershell script verify each record in table has physical file associated on server, if not write csv file. i'm not having luck wit csv portion , hoping help?

here have far (please let me know if there better ways this, im brand new powershell). want add records csv if test-path fails find file in question.

[reflection.assembly]::loadfile("c:\ora10g\odp.net\bin\2.x\oracle.dataaccess.dll") $connectionstring = "data source=xxxxxx;user id=xxxx;password=xxxxxxxx;" $connection = new-object oracle.dataaccess.client.oracleconnection($connectionstring) $connection.open() $querystring = "select key, sequence, type, file filetable type in (2, 5)"  $command = new-object oracle.dataaccess.client.oraclecommand($querystring, $connection) $mediaobjrs = $command.executereader()  # loop through recordset while ($mediaobjrs.read()) {     # assign variables recordset.    $objectkey = $mediaobjrs.getstring(0)    $objectseq = $mediaobjrs.getdecimal(1)    $objecttype = $mediaobjrs.getdecimal(2)    $objectfilename = $mediaobjrs.getstring(3)          # check if file exists based on filetype.         if($objecttype -eq 2){             # type 2 = ole             $filelocation = "\\fileserver\d$\files\" + $objectfilename         }elseif($objecttype -eq 5){               # type 5 = file              $filelocation = $objectfilename                 }         $fileexists = test-path $filelocation         if($fileexists -eq $false){                 #write output file                 $objectkey | export-csv missingfiles.csv                 $objectseq | export-csv missingfiles.csv                 $objecttype | export-csv missingfiles.csv                 $objectfilename | export-csv missingfiles.csv         } }  $connection.close() 

each time write missingfiles.cs clobber previous one. plus cmdlet oriented towards saving objects each property represents 1 of comma separated values.

the simplest way manually write (append) csv file:

if(!$fileexists) {     #write output file     "`"$objectkey`",`"$objectseq`",`"$objecttype`",`"$objectfilename`" >> foo.csv } 

the "slick" powershell way create object each file , put in array , when you're done, export array of object csv file e.g.:

$files = @() # initialize array outside loop ... if (!$fileexists) {     $obj = new-object -psobject -prop @{                key = $objectkey                seq = $objectseq                type = $objecttype                filename = $objectfilename            }     $files += obj } ... # outside of loop, export array of objects csv $files | export-csv missingfiles.csv 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -