Produced by Araxis Merge on 11/9/2018 12:16:35 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | MigrateFacilityDataScheduleTask.ps1 | Sun Aug 19 22:20:06 2018 UTC |
2 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | MigrateFacilityDataScheduleTask.ps1 | Fri Nov 9 14:50:40 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 426 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | <# | |
2 | ||
3 | .SYNOPSIS | |
4 | Period ically upd ate the su bsite Appl icationFac ilityLooku p list fro m the appl ication li st | |
5 | ||
6 | .DESCRIPTI ON | |
7 | Run fr om the sch eduled tas k every 10 minutes t o update t he Applica tionFacili tyLookup f rom the Ap plication list. | |
8 | Loops through al l applicat ion items and adds a n entry in the Appli cationFaci lityLookup list for the site l isted in | |
9 | the Ap plication List Facil ities Look up. The Ap plicationF acilityLoo kup list i s at the s ubsite lev el so the | |
10 | applic ation look ups on the calendars can show applicatio ns for the facility. | |
11 | ||
12 | .EXAMPLE | |
13 | #when run from c ommand lin e | |
14 | .\Migr ateFacilit yDataSched uleTask.ps 1 -localSi teUrl $sit eUrl | |
15 | #> | |
16 | Param( [Pa rameter(Ma ndatory=$T rue)] | |
17 | [strin g]$localSi teUrl | |
18 | ) | |
19 | ||
20 | Add-PSSnap in Microso ft.SharePo int.Powers hell | |
21 | ||
22 | ||
23 | $facilitie s = @{ | |
24 | } | |
25 | ||
26 | $recordCou nts = @{ | |
27 | } | |
28 | ||
29 | $recordCha ngedCounts = @{ | |
30 | } | |
31 | ||
32 | function G etAllWebs( $url) { | |
33 | #try { | |
34 | wr ite-host " $([String] ::Format(" Procesing web {0}",$ w.Url))" - foreground Color cyan | |
35 | $a pplication list =$w.L ists["Appl ication"] | |
36 | $a pplication items = $a pplication list.items | |
37 | ||
38 | #L oop throug h List | |
39 | #G et Facilit ies Lookup | |
40 | #C opy record to correc t list | |
41 | fo reach ($it em in $app licationit ems) { | |
42 | $applica tionStatus Field = $i tem["Appli cation Sta tus"] | |
43 | $applica tionStudyT itleField = $item["S tudy Title "] | |
44 | $applica tionStudyI DField = $ item["Stud y_ID"] | |
45 | $applica tionTitleF ield = $it em["Title" ]; | |
46 | $idField = $item[" ID"] | |
47 | $applica tionFacili tyLookup=$ item["Faci lities Loo kup"] | |
48 | if ($app licationFa cilityLook up -ne $nu ll) { | |
49 | $app licationFa cilityLook up = $appl icationFac ilityLooku p.Substrin g(3) | |
50 | } | |
51 | if($w.We bs.Count - gt 0 -and $applicati onFacility Lookup) { | |
52 | fore ach($web i n $w.Webs) { | |
53 | $facilityN ameKey=$we b.Url; | |
54 | $facilityN ameLookup= $facilitie s.Item($we b.Url); | |
55 | if($facili tyNameLook up -eq $ap plicationF acilityLoo kup -and $ applicatio nStatusFie ld -ne 'Dr aft') { | |
56 | Migrat eToNewList $web $app licationSt atusField $applicati onStudyTit leField $i dField $ap plicationS tudyIDFiel d $applica tionTitleF ield | |
57 | } | |
58 | } | |
59 | } | |
60 | } | |
61 | #} cat ch { | |
62 | # w rite-host "$([String ]::Format( "Error pro cessing we b at $url, with Exce ption: {0} ", $_.Exce ption.Mess age))" -fo regroundCo lor Red | |
63 | # i f ($($_.Ex ception.Er rorRecord) ) { write- host "$($_ .Exception .ErrorReco rd)" -fore groundColo r Red } | |
64 | # i f ($($_.Ex ception.st acktrace)) { write-h ost "$($_. Exception. stacktrace )" -foregr oundColor Red } | |
65 | # i f ($($_.Sc riptStackT race)) { w rite-host "$($_.Scri ptStackTra ce)" -fore groundColo r Red } | |
66 | #} | |
67 | } | |
68 | ||
69 | function g etAllFacil ities ($ro otSiteColl ectionUrl) { | |
70 | #Get t he target SP Web | |
71 | $scWeb = Get-SPW eb -identi ty $rootSi teCollecti onUrl | |
72 | ||
73 | #Get t he Source List | |
74 | $facil ityList = $scWeb.Lis ts["Facili ties"] | |
75 | $facil ityitems = $facility List.items | |
76 | ||
77 | foreac h($facilit yItem in $ facilityit ems) { | |
78 | $f acilityNam e=$facilit yItem["Fac ility Name "] | |
79 | $f ldurl=new- object Mic rosoft.Sha rePoint.SP FieldUrlVa lue($facil ityItem["F acilitySub site"]) | |
80 | $f acilitySub site=$fldu rl.URL | |
81 | $f acilityId= $facilityI tem["ID"] | |
82 | #w rite-host "Adding fa cilities N ame=$facil ityName ID =$facility Id URL=$fa cilitySubs ite" -fore groundColo r Green | |
83 | $f acilities. add($facil itySubsite , $facilit yName) | |
84 | } | |
85 | } | |
86 | ||
87 | function g etRecordCo unts ($roo tSiteColle ctionUrl) { | |
88 | $appli cationlist =$w.Lists ["Applicat ion"] | |
89 | $appli cationitem s = $appli cationlist .items | |
90 | $count = 0 | |
91 | ||
92 | #Loop through Li st | |
93 | #Get F acilities Lookup | |
94 | #Copy record to correct li st | |
95 | foreac h ($item i n $applica tionitems) { | |
96 | $c ount++ | |
97 | $a pplication FacilityLo okup=$item ["Faciliti es Lookup" ] | |
98 | ||
99 | if ($applica tionFacili tyLookup - ne $null - and $appli cationFaci lityLookup -ne "") { | |
100 | $applica tionFacili tyLookup = $applicat ionFacilit yLookup.Su bstring(3) | |
101 | $current FacilityCo unt = $rec ordCounts. Item($appl icationFac ilityLooku p) | |
102 | ||
103 | if ($cur rentFacili tyCount -n e $null) { | |
104 | $cur rentFacili tyCount++ | |
105 | $rec ordCounts. Remove($ap plicationF acilityLoo kup) | |
106 | $rec ordCounts. add($appli cationFaci lityLookup , $current FacilityCo unt) | |
107 | } else { | |
108 | $cur rentFacili tyCount=1 | |
109 | $rec ordCounts. add($appli cationFaci lityLookup , $current FacilityCo unt) | |
110 | } | |
111 | } | |
112 | } | |
113 | $record Counts.add ("Applicat ionTotalCo unt", $cou nt) | |
114 | } | |
115 | ||
116 | function M igrateToNe wList($sub site, $app licationSt atusField, $applicat ionStudyTi tleField, $idField, $studyIDFi eld, $appl icationTit leField) { | |
117 | #Get t he target SP Web | |
118 | $scWeb = Get-SPW eb -identi ty $subsit e.URL | |
119 | ||
120 | #Get t he Source List | |
121 | $appli cationFaci lityLookup List = $sc Web.Lists[ "Applicati onFacility Lookup"] | |
122 | $looku pRecordite ms = $appl icationFac ilityLooku pList.item s | |
123 | ||
124 | $appli cationReco rdIDField= "Applicati onRecordID " | |
125 | $facil ityLookupI tems = $ap plicationF acilityLoo kupList.It ems | wher e {$_[$app licationRe cordIDFiel d] -eq $id Field} | |
126 | ||
127 | $updat edKey = $s ubsite.Tit le + "-Upd ated" | |
128 | $updat edCounts = $recordCh angedCount s.Item($up datedKey) | |
129 | ||
130 | $newKe y = $subsi te.Title + "-New" | |
131 | $newCo unts = $re cordChange dCounts.It em($newKey ) | |
132 | ||
133 | $listN ame = "App licationFa cilityLook up" | |
134 | if ($f acilityLoo kupItems - eq $null) { | |
135 | $l ist = $web .Lists[$li stname] | |
136 | if ($list -n e $null) { | |
137 | write-ho st "Migrat e To New L ist $($sub site.Title )" -Foregr oundColor White | |
138 | $newItem = $list.A ddItem() | |
139 | $newItem ["Applicat ion Status "] = $appl icationSta tusField | |
140 | $newItem ["Study Ti tle"] = $a pplication StudyTitle Field | |
141 | $newItem ["Applicat ionRecordI D"] = $idF ield | |
142 | $newItem ["Study_ID "] = $stud yIDField | |
143 | $newItem ["Title"] = $applica tionTitleF ield | |
144 | $newItem .update() | |
145 | ||
146 | if ($rec ordChanged Counts.con tains($new Key)) { | |
147 | $new Counts++ | |
148 | $rec ordChanged Counts.Rem ove($newKe y); | |
149 | $rec ordChanged Counts.Add ($newKey, $newCounts ) | |
150 | } else { | |
151 | $new Counts = 1 | |
152 | $rec ordChanged Counts.Add ($newKey, $newCounts ) | |
153 | } | |
154 | } | |
155 | } else { | |
156 | fo reach($old Item in $f acilityLoo kupItems) { | |
157 | $oldItem ["Applicat ion Status "] = $appl icationSta tusField | |
158 | $oldItem ["Study Ti tle"] = $a pplication StudyTitle Field | |
159 | $oldItem ["Applicat ionRecordI D"] = $idF ield | |
160 | $oldItem ["Study_ID "] = $stud yIDField | |
161 | $oldItem ["Title"] = $applica tionTitleF ield | |
162 | $oldItem .update() | |
163 | ||
164 | if ($rec ordChanged Counts.con tains($upd atedKey)) { | |
165 | $upd atedCounts ++ | |
166 | $rec ordChanged Counts.Rem ove($updat edKey) | |
167 | $rec ordChanged Counts.Add ($updatedK ey, $updat edCounts) | |
168 | } else { | |
169 | $upd atedCounts = 1 | |
170 | $rec ordChanged Counts.Add ($updatedK ey, $updat edCounts) | |
171 | } | |
172 | } | |
173 | } | |
174 | write- host "Migr ated for: $scWeb" -f oregroundC olor Green | |
175 | } | |
176 | ||
177 | function O utputStats ToLog($sta rtTime, $e ndTime) { | |
178 | $time = Get-Date -Format " yyyyMMddHH mmss" | |
179 | ||
180 | $fileP ath = "C:\ temp\" + " MigrateFac ilityData- " + $time + ".log" | |
181 | ||
182 | $curre ntLine ="S tart Time $startTim e End Time $endTime " | |
183 | Write- Output $cu rrentLine | Out-File -FilePath $filepath -Append | |
184 | ||
185 | $curre ntLine ="S ummary Of Record Cou nts" | |
186 | Write- Output $cu rrentLine | Out-File -FilePath $filepath -Append | |
187 | $recor dCounts.Ge tEnumerato r() | % { | |
188 | $c urrentKey= $($_.key) | |
189 | $c urrentValu e=$($_.val ue) | |
190 | $c urrentLine = "$curre ntKey Tota l Records= $currentVa lue" | |
191 | Wr ite-Output $currentL ine | Out- File -File Path $file path -Appe nd | |
192 | } | |
193 | ||
194 | $curre ntLine ="S ummary Of New/Update d Records" | |
195 | Write- Output $cu rrentLine | Out-File -FilePath $filepath -Append | |
196 | $recor dChangedCo unts.GetEn umerator() | % { | |
197 | $c urrentKey= $($_.key) | |
198 | $u pdatedName = $curren tKey.repla ce("-New", " New Reco rds") | |
199 | $u pdatedName = $update dName.repl ace("-Upda ted"," Upd ated Recor ds") | |
200 | $c urrentValu e=$($_.val ue) | |
201 | $c urrentLine = "$updat edName $currentVa lue" | |
202 | Wr ite-Output $currentL ine | Out- File -File Path $file path -Appe nd | |
203 | } | |
204 | } | |
205 | ||
206 | #This is t o test the driver co ntains a $ localSiteU rl | |
207 | $startTime = Get-Dat e -Format "yyyyMMddH Hmmss" | |
208 | #$localSit eUrl="http s:// DNS . URL /sites/IRB Applicatio ns/"; | |
209 | $w = Get-S PWeb $loca lSiteUrl | |
210 | getAllFaci lities $lo calSiteUrl | |
211 | getRecordC ounts $loc alSiteUrl | |
212 | GetAllWebs $localSit eUrl | |
213 | $endTime = Get-Date -Format "y yyyMMddHHm mss" | |
214 | OutputStat sToLog $st artTime $e ndTime |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.