onsdag 19 september 2012

Print Properties of a Class

Private Sub PrintMemberClassInfo(ByVal memberClass As MemberClass)

    For Each propertyInfoItem As PropertyInfo In memberClass.GetType().GetProperties()
        Dim propValue = propertyInfoItem.GetValue(memberClass, Nothing)
        Dim value As String
        If Not propValue Is Nothing Then
            value = propValue.ToString()
            If propValue.ToString() = "MemberReg.Member" Then
                Dim member As Member = CType(propValue, Member)
                For Each propertyInfo2 As PropertyInfo In member.GetType().GetProperties()
                    Dim propValue2 = propertyInfo2.GetValue(member, Nothing)
                    Dim value2 As String
                    If Not propValue2 Is Nothing Then
                        value2 = propValue2.ToString()
                    Else
                        value2 = "Nothing"
                    End If
                    If value2 = "" Then value2 = """"""
                    Response.Write(" * " & propertyInfo2.Name & " : " & value2 & "
") Next End If Else value = "Nothing" End If If value = "" Then value = """""" Response.Write(propertyInfoItem.Name & " : " & value & "
") Next End Sub

måndag 9 juli 2012

PowerShell - Iterate folders and move items to parent

Get-ChildItem -Recurse | Where {$_.psIsContainer -eq $true} | Select-Object FullName | ForEach-Object {
    Set-Location $_.FullName;
    Move-Item *.* -Destination $loc;
    Set-Location $loc;
}

tisdag 19 juni 2012

VBScript - How to sort an array of objects

Function SortItemsByPubDate(items, intSort)
    Dim result : Set result = Server.CreateObject("Scripting.Dictionary")
    Dim objDict()
    Dim objKey
    Dim strKey,strItem, objItem
    Dim X,Y,itemCount
    Const DICT_KEY = 1
    Const DICT_ITEM = 2
    Dim oRssItem

    itemCount = items.Count
    
        If itemCount > 1 Then
        
        ReDim objDict(itemCount,2)
        X = 0
        
        ' Add key and the value to sort the array on
        For Each objKey In items
            objDict(X,DICT_KEY)  = CStr(objKey)
            objDict(X,DICT_ITEM) = items(objKey).pubDate
            X = X + 1
        Next
        
        
        For X = 0 to (itemCount - 2)
            For Y = X to (itemCount - 1)
                If StrComp(objDict(X,intSort),objDict(Y,intSort),vbTextCompare) > 0 Then
                    strKey  = objDict(X,DICT_KEY)
                    strItem = objDict(X,DICT_ITEM)
                    objDict(X,DICT_KEY)  = objDict(Y,DICT_KEY)
                    objDict(X,DICT_ITEM) = objDict(Y,DICT_ITEM)
                    objDict(Y,DICT_KEY)  = strKey
                    objDict(Y,DICT_ITEM) = strItem
                End If
            Next
        Next
        
        
        For X = 0 to (itemCount - 1)
            result.Add objDict(X,DICT_KEY), objDict(X,DICT_ITEM)
        Next

        Set SortItemsByPubDate = result
    Else

        Set SortItemsByPubDate = items
    End If
        
End Function

torsdag 3 maj 2012

JavaScript Scrapbook addition

A repeater with a nested GridView. All GridViews have their own UpdateProgress controls.
This hides all UpdateProgress divs but the one for the specific GridView that triggered the AJAX call.

$('.applicationRowAction').live("click", function () {
            var tableHeight = $(this).closest('table').height();
            var panelMarginTop = (tableHeight / 2)
            var appId = $(this).parent().parent().find('.divRowAppWrapperId').attr("id").substring(4);
            $('.updateProgress').css('margin-top', panelMarginTop + 'px');
            $('.updateProgress').each(function () {
                var divId = $(this).attr("id").substring(17)
                if (divId != appId) {
                    $(this).hide();
                }
            })
        });