Wednesday, October 3, 2012

Silverlight DataContext Changed Event (VB translate)

Silverlight DataContext Changed Event (VB.NET)


#Region "Interfaces"

Public Interface IDataContextChangedHandler(Of T As FrameworkElement)
    Sub DataContextChanged(sender As T, e As DependencyPropertyChangedEventArgs)
End Interface

Public NotInheritable Class DataContextChangedHelper(Of T As {FrameworkElement, IDataContextChangedHandler(Of T)})
    Private Const INTERNAL_CONTEXT As String = "InternalDataContext"
    Public Shared ReadOnly InternalDataContextProperty As DependencyProperty =
        DependencyProperty.Register(INTERNAL_CONTEXT, GetType([Object]), GetType(T), New PropertyMetadata(AddressOf _DataContextChanged))
    Public Shared Sub _DataContextChanged(sender As Object, e As DependencyPropertyChangedEventArgs)
        Dim control As T = DirectCast(sender, T)
        control.DataContextChanged(control, e)
    End Sub
    Public Shared Sub Bind(control As T)
        control.SetBinding(InternalDataContextProperty, New Binding)
    End Sub
End Class
#End Region




Authored originally by the Jeremy Likness

Wednesday, August 1, 2012

Great to see the workflow was taken off from the SharePoint

Used to mess up between SharePoint workflow object model and .Net framework object model. I was thinking why not separate the workflow off SharePoint. Now Microsoft made it through SharePoint 2013. Very nice!

VB.NET Function to Rotate Row Image with Bitmap in Silverlight


Couldn't find a good one to rotate images in Silverlight. The build-in RenderTransform is only for rendering on page instead of updating original. Here's the function I wrote for rotating the original images, it can be saved to bytes.

Public Function iImageRotate(ByRef bi As BitmapImage, ByVal CounterclockwiseAngle As Integer) As WriteableBitmap
        Try
            Dim wb As WriteableBitmap = New WriteableBitmap(bi)
            Dim wb_arr(,) As Integer
            ReDim Preserve wb_arr(wb.PixelWidth, wb.PixelHeight)
            For c As Integer = 0 To wb.PixelWidth
                For r As Integer = 0 To wb.PixelHeight
                    wb_arr(c, r) = wb.Pixels(wb.PixelWidth * r + c)
                Next
            Next
            Dim wb2 As WriteableBitmap
            Dim wb_arr_2(,) As Integer
            If (CounterclockwiseAngle = 0 Or CounterclockwiseAngle Mod 360 = 0) Then '0 360 plus degree
                wb2 = New WriteableBitmap(wb.PixelWidth, wb.PixelHeight)
                ReDim Preserve wb_arr_2(wb.PixelWidth, wb.PixelHeight)
                wb_arr_2 = wb_arr
            ElseIf (CounterclockwiseAngle = 90 Or CounterclockwiseAngle Mod 450 = 0) Then '90 450 plus degree
                wb2 = New WriteableBitmap(wb.PixelHeight, wb.PixelWidth)
                ReDim Preserve wb_arr_2(wb.PixelHeight, wb.PixelWidth)
                For c As Integer = 0 To (wb_arr.GetLength(0) - 1) 'width i
                    For r As Integer = 0 To (wb_arr.GetLength(1) - 1) 'height j
                        wb_arr_2(r, wb_arr.GetLength(0) - c - 1) = wb_arr(c, r) '90 Out[j, Right-i-1] = In[i, j]
                    Next
                Next
            ElseIf (CounterclockwiseAngle = 180 Or CounterclockwiseAngle Mod 540 = 0) Then '180 540 plus degree
                wb2 = New WriteableBitmap(wb.PixelWidth, wb.PixelHeight)
                ReDim Preserve wb_arr_2(wb.PixelWidth, wb.PixelHeight)
                For c As Integer = 0 To (wb_arr.GetLength(0) - 1) 'width i
                    For r As Integer = 0 To (wb_arr.GetLength(1) - 1) 'height j
                        wb_arr_2(wb_arr.GetLength(0) - c - 1, wb_arr.GetLength(1) - r - 1) = wb_arr(c, r) '180 Out[Right-i-1, Bottom-j-1] = In[i, j]
                    Next
                Next
            ElseIf (CounterclockwiseAngle = 270 Or CounterclockwiseAngle Mod 630 = 0) Then '270 630 plus degree
                wb2 = New WriteableBitmap(wb.PixelWidth, wb.PixelHeight)
                ReDim Preserve wb_arr_2(wb.PixelWidth, wb.PixelHeight)
                For c As Integer = 0 To (wb_arr.GetLength(0) - 1) 'width i
                    For r As Integer = 0 To (wb_arr.GetLength(1) - 1) 'height j
                        wb_arr_2(wb_arr.GetLength(1) - r - 1, c) = wb_arr(c, r) '270 Out[Bottom-j-1,i] = In[i, j]
                    Next
                Next
            Else
                Return Nothing
            End If

            For r As Integer = 0 To (wb_arr_2.GetLength(1) - 1)
                For c As Integer = 0 To (wb_arr_2.GetLength(0) - 1)
                    wb2.Pixels(wb2.PixelWidth * r + c) = wb_arr_2(c, r)
                Next
            Next

            Return wb2
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Wednesday, July 18, 2012

Endeca - Enable rollup counts


App.config
line 400

    --spl
      --dym
      --whymatch
      --back_compat
      510
      --xquery_path
      ./data/dgraphs/local_xquery
  
   --threads
      2
      --stat-abins

Endeca - Debug spelling information


The --spell_msg flag generates useful spelling debugging information displayed to the MDEX Engine stderr, both on startup and on a per-query basis.

      --spl
      --dym
      --spell_msg
      --whymatch
      --back_compat
      510
      --xquery_path
      ./data/dgraphs/local_xquery

Endeca - Baseline Error: Too many *.esp files


ERROR: Too many *.esp files in directory C:/Endeca/apps/xxx/data/complete_index_config

Solution: Remove the abundant .esp file from the folder C:\Endeca\apps\nfm\config\pipeline and reload the files.


SEVERE: Utility 'emgr_update_set_instance_config_from_dir_C-Endeca-apps-xxx-data-complete-index-config' failed. Refer to utility logs in [ENDECA_CONF]/logs/shell on host ITLHost.
Occurred while executing line 39 of valid BeanShell script:
[[

36|        ConfigManager.cleanDirs();
37|        Forge.getPostForgeDimensions();
38|        ConfigManager.updateWsDimensions();
39|       ConfigManager.updateWsConfig();
40|       
41|        // archive state files, index
42|        Forge.archiveState();

]]

[08.31.11 08:34:25] SEVERE: Caught an exception while invoking method 'run' on object 'BaselineUpdate'. Releasing locks.

Caused by java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl invoke0 - null
Caused by com.endeca.soleng.eac.toolkit.exception.AppControlException
com.endeca.soleng.eac.toolkit.script.Script runBeanShellScript - Error executing valid BeanShell script.
Caused by com.endeca.soleng.eac.toolkit.exception.EacComponentControlException
com.endeca.soleng.eac.toolkit.utility.Utility run - Utility 'emgr_update_set_instance_config_from_dir_C-Endeca-apps-nfm-data-complete-index-config' failed. Refer to utility logs in [ENDECA_CONF]/logs/shell on host ITLHost.

ERROR: on file nfm.emgr_update_set_instance_config_from_dir_C-Endeca-apps-xxx-data-complete-index-config.log

Endeca - FATAL ERROR


Solution: Delete the file autogen_dimensions.xml.gz and copy the one from autogen_dimensions.xml.external.gz and rename to autogen_dimensions.xml.gz.


 FATAL     08/29/11 19:00:41.205 UTC   FORGE           {config}: Unable to open C:\Endeca\apps\xxx\data\state\autogen_dimensions.xml.gz for input: I/O Exception: compression format exception:            


ERROR          08/29/11 19:00:41.221 UTC   FORGE           {config}: Forge failed with 1 error and 0 warnings. 

Endeca - Solution for cleanDir_processing failed

Solution is removing the file processing from folder E:\Endeca\apps\xxx2011\data and recreate folder E:\Endeca\apps\xxx2011\data\processing and then re-run baseline update.



INFO: [ITLHost] Starting shell utility 'cleanDir_processing'.
Aug 5, 2011 9:43:10 AM com.endeca.soleng.eac.toolkit.script.Script runBeanShellScript
SEVERE: Utility 'cleanDir_processing' failed. Refer to utility logs in [ENDECA_CONF]/logs/shell on host ITLHost.
Occurred while executing line 17 of valid BeanShell script:
[[

14|        }
15|       
16|        // clean directories
17|        Forge.cleanDirs();
18|        PartialForge.cleanCumulativePartials();
19|        Dgidx.cleanDirs();
20|       

]]

Aug 5, 2011 9:43:10 AM com.endeca.soleng.eac.toolkit.Controller execute
SEVERE: Caught an exception while invoking method 'run' on object 'BaselineUpdate'. Releasing locks.

SharePoint - Create pages with left navigaion

There are plenty of internet pages that teach you how to add left navigation while you create a site page by using SharePoint designer, however, this is definitely not necessary. Any pages changed by SharePoint designer will turned to ungosted and not good for program package. A straight way is locating the correct entry to create page. Here follows steps.
1. Site Action - Manage Content and Structure
2. Click the small right triangle beside folder "Pages" from the left navigation menu. Click New - Page.
3. Name the title, URL and choose page layout. I tried the Blank Web Part page.

It works great for me.