Tuesday, September 15, 2015

Problem resolved - Remote debugging the windows service

Problem resolved - Remote debugging the windows service

The following error happens when trying to debug the windows service via remote debugger by visual studio.  You will find the breakpoints you set shows a cycle instead of substantial. It points the debugger issue. The application I need to debug is windows service with installation package. It finally works with copy directly the services application into the running folder instead of running installation package to setup. So, when the debugger runs with issue, try the direct from source to target and use copy instead of any other deployment or delivery way. It'll get you straight approaching.


The breakpoint will not currently be hit. No symbols have been loaded for this document




Thursday, February 26, 2015

SharePoint Error - You do not have appropriate permissions to create a new workbook in the specified location

Error that happening during generating a excel document in a SharePoint document library.


Error:

Cannot open file "You do not have appropriate permissions to create a new workbook in the specified location".
Correlation ID: c9fe6615-10bb-4542-b6de-9429258b99db
Date and Time: 2/26/2015 2:34:55 PM



02/26/2015 14:32:32.54 w3wp.exe (0x2EB0)                       0x2438 SharePoint Foundation         Runtime                       tkau Unexpected System.Runtime.InteropServices.COMException: Cannot open file "You do not have appropriate permissions to create a new workbook in the specified location".    at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew)     at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) 0b836823-fd28-4d03-944a-8a89b8e12892


Solution:

  1. add the permissions of excel service owner to the db
  2. remove the Excel Services Service application
  3. recreate the excel service application as well as the following proxy
  4. set the URI of excel document library in SharePoint  excel services application - Trusted File Locations.

Wednesday, February 25, 2015

Web service or WCF interface issue. The maximum nametable character count quota (16384) has been exceeded while reading XML data.

I have a proxy application that pass the same functionality outside of our corp network. It consumes internal web service (ASMX) through SSL required and opens through SharePoint web service port. It pops up the following error when I added some new functions which supposed to hit the default max limit. There a bunch solutions from internet and basically, most of them are targeting the configuration file (app.xml etc). As the proxy application is consuming the web service through encapsulated internal layer. So the solution that finally solved the issue is via the code. Here lists the proxy call function that specify the max limit value (2147483647).


Error: 

The maximum nametable character count quota (16384) has been exceeded while reading XML data. 



Solution function:


Public Shared Function SecureProxyCall(Of T)(targetUrl As String, programaticUserID As String, programaticPassword As String, domain As String) As T
        Dim binding As New BasicHttpBinding()
        Dim timeout As New TimeSpan(0, 20, 0)

        binding.MaxReceivedMessageSize = 2147483647
        binding.MaxBufferSize = 2147483647
        binding.ReaderQuotas.MaxStringContentLength = 2147483647
        binding.ReaderQuotas.MaxNameTableCharCount = 2147483647
        binding.SendTimeout = timeout
        binding.ReceiveTimeout = timeout

        Dim address As New EndpointAddress(targetUrl)
        Dim securedClient = Activator.CreateInstance(GetType(T), New Object() {binding, address})
        If String.IsNullOrEmpty(programaticUserID) Then
            'Force to anonymous
            binding.Security.Mode = BasicHttpSecurityMode.None
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
        Else
            binding.Security.Mode = BasicHttpSecurityMode.Transport
            securedClient.ClientCredentials.Windows.ClientCredential = New Net.NetworkCredential(programaticUserID, programaticPassword, "nfm")
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows
        End If
        Return securedClient
    End Function

Thursday, February 19, 2015

SharePoint Error solution.

Error Message of SharePoint Log:


02/19/2015 09:41:32.81 w3wp.exe (0x0674)                       0x2468 SharePoint Foundation         Runtime                       tkau Unexpected System.MissingMethodException: Method not found: 'System.String Microsoft.Office.Server.UserProfiles.SynchronizationRunStatus.get_ConnectionName()'.    at Microsoft.SharePoint.Portal.WebControls.UserProfileServiceImportStatisticsWebPart.RenderSectionContents(HtmlTextWriter writer)     at Microsoft.SharePoint.Portal.WebControls.UserProfileServiceImportStatisticsWebPart.RenderWebPart(HtmlTextWriter writer)     at Microsoft.SharePoint.WebPartPages.WebPart.Render(HtmlTextWriter writer)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)     at System.Web.UI.HtmlControls.Html... 54625c4e-29c1-4b1c-bca1-117563688d20



Solution:


  1. Delete the old User Profile Service Application (SharePoint Central Administration).
  2. Delete the User Profile Sync Database (Keep the Profile DB and Social DB)
  3. Recreate User Profile Service Application (Specify new name of DBs)
  4. Set Administrators for User Profile Service Application (Add the farm account and user account in)
  5. Reboot the server.




Wednesday, April 3, 2013

Silverlight listbox item selection binding with dynamic border setting

The requirement needs the listboxitem with a dynamic border by a binding property. Once I implemented this by adding a border tag over the ContentPresenter, it automatically overwrote the default selection border. That means when you click the item from listbox, there's nothing happening with the border. It took me a few of days to fight on the dynamic borders of Silverlight listbox items. Finally it comes up with the VSM (VisualStateManager) solution as following code. One special thing that happening on my case is if you click once to select the item, the first item would be always auto selected, you'd have to click other item or other area once again to dime the first item border selection. The fix will be commenting the Storeboard of Focused VisualState. Here shows you the entire code.

(Notice: The 2 converters by binding Tag were my custom function to give the BorderBrush a custom color by listbox sourceitem property, it will need to implement IValueConverter as a reference class as the bottom code)

Xaml:

<ListBox x:Name="SKUImageListBox" Height="250" Width="600" SelectionMode="Single" HorizontalContentAlignment="Left" TabIndex="1"

HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,2,115,0" DataContext="{Binding}">

<ListBox.ItemContainerStyle>

<Style TargetType="ListBoxItem">

<Setter Property="Padding" Value="3" />

<Setter Property="HorizontalContentAlignment" Value="Left" />

<Setter Property="VerticalContentAlignment" Value="Top" />

<Setter Property="Background" Value="Transparent" />

<Setter Property="BorderThickness" Value="1"/>

<Setter Property="TabNavigation" Value="Local" />

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="ListBoxItem">

<Grid Background="{TemplateBinding Background}">

<vsm:VisualStateManager.VisualStateGroups>

<vsm:VisualStateGroup x:Name="CommonStates">

<vsm:VisualState x:Name="Normal" >

<Storyboard>

<DoubleAnimation Storyboard.TargetName="BorderSquare" Storyboard.TargetProperty="Opacity" Duration="0" To=".50"/>

</Storyboard>

</vsm:VisualState>

<vsm:VisualState x:Name="MouseOver">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="Opacity" Duration="0" To=".35"/>

</Storyboard>

</vsm:VisualState>

<vsm:VisualState x:Name="Disabled">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="ContentPresenterImg" Storyboard.TargetProperty="Opacity" Duration="0" To=".55" />

</Storyboard>

</vsm:VisualState>

</vsm:VisualStateGroup>

<vsm:VisualStateGroup x:Name="SelectionStates">

<vsm:VisualState x:Name="Unselected" />

<vsm:VisualState x:Name="Selected">

<Storyboard>

<DoubleAnimation Storyboard.TargetName="fillColor2" Storyboard.TargetProperty="Opacity" Duration="0" To=".75"/>

</Storyboard>

</vsm:VisualState>

</vsm:VisualStateGroup>

<vsm:VisualStateGroup x:Name="FocusStates">

<vsm:VisualState x:Name="Focused">

<!--<Storyboard>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">

<DiscreteObjectKeyFrame KeyTime="0">

<DiscreteObjectKeyFrame.Value>

<Visibility>Visible</Visibility>

</DiscreteObjectKeyFrame.Value>

</DiscreteObjectKeyFrame>

</ObjectAnimationUsingKeyFrames>

</Storyboard>-->

</vsm:VisualState>

<vsm:VisualState x:Name="Unfocused"/>

</vsm:VisualStateGroup>

</vsm:VisualStateManager.VisualStateGroups>

<Rectangle x:Name="fillColor" Opacity="0" Fill="#FFBADDE9" IsHitTestVisible="False" RadiusX="1" RadiusY="1" />

<Rectangle x:Name="fillColor2" Opacity="0" Fill="#FFBADDE9" IsHitTestVisible="False" RadiusX="1" RadiusY="1" />

<Border x:Name="BorderSquare" Opacity="0" IsHitTestVisible="False" BorderBrush="{Binding Tag,Converter={StaticResource SquareImageBorderBrushConverter}}" BorderThickness="{Binding Tag,Converter={StaticResource SquareImageBorderThicknessConverter}}"/>

<ContentPresenter x:Name="ContentPresenterImg" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>

<Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed" RadiusX="1" RadiusY="1" />

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</ListBox.ItemContainerStyle>

<ListBox.ItemsPanel>

<ItemsPanelTemplate>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20"/>

</ItemsPanelTemplate>

</ListBox.ItemsPanel>

<ListBox.ItemTemplate>

<DataTemplate>

<StackPanel Orientation="Horizontal">

<StackPanel Orientation="Vertical">

<Image Source="{Binding Path=Source}">

</Image>

</StackPanel>

</StackPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>


Converter:


Namespace Converters
    Public Class SquareBorderBrushConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare And Not img.IsNew Then
                        returnValue = "Red"
                    Else
                        returnValue = "Transparent"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class

End Namespace


Namespace Converters
    Public Class SquareBorderThicknessConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare Then
                        returnValue = "4"
                    Else
                        returnValue = "3"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class

End Namespace

Thursday, February 28, 2013

Silverlight Listbox Binding Image and Tag

It took me couple days to figure this out. The requirement needs me to show the images to the listbox. I do already have the ObservableCollection of Images to set as Item Source. Only way to get specified way is through some kind of style. Here I use background of ItemContainerStyle with converter to my custom highlighting on wanted images. Xaml Code follows:

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="SkuMaintain.SKUDetailUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:localFormatter="clr-namespace:SkuMaintain.SkuDetailFormatter" >


<UserControl.Resources>
<localFormatter:SquareBackgroundConverter x:Key="SquareImageConverter"/>
</UserControl.Resources>


<ListBox x:Name="SKUImageListBox" Height="250" Width="600" SelectionMode="Single"  HorizontalContentAlignment="Left" TabIndex="1"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,2,115,0" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="{Binding Tag,Converter={StaticResource SquareImageConverter}}"></Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<Image Source="{Binding Path=Source}"></Image>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

Converter file definition (DetailFomatter.vb)


Imports System.Windows.Data
Imports System.IO

Namespace SkuDetailFormatter
    Public Class SquareBackgroundConverter
        Implements IValueConverter

        Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim returnValue As String = String.Empty
            Dim img As New SkuOpsSvcRef.SKUImage
            Try
                If value IsNot Nothing Then
                    img = CType(value, SkuOpsSvcRef.SKUImage)
                    If Not img.IsSquare Then
                        returnValue = "Red"
                    End If
                Else
                    returnValue = String.Empty
                End If
            Catch
                returnValue = String.Empty
            End Try
            Return returnValue
        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
            Return Nothing
        End Function
    End Class
End Namespace

Wednesday, February 20, 2013

Regular Expression - Regex for numeric


    Public Function IsNumeric(ByVal inputStr As String) As Boolean
        Dim _isNumber As Regex = New Regex("(^[+-]?\d+(,?\d*)*\.?\d*([Ee][+-]\d*)?$)|(^[\(]?[\$]?[+-]?\d?(,?\d*)*\.\d+([Ee][+-]\d*)?[\)]?$)")
        Return _isNumber.Match(inputStr).Success
    End Function



    Public Function IsPositiveNumeric(ByVal inputStr As String) As Boolean
        Dim _isNumber As Regex = New Regex("(^[+]?\d+(,?\d*)*\.?\d*([Ee][+]\d*)?$)|(^[\(]?[\$]?[+]?\d?(,?\d*)*\.\d+([Ee][+]\d*)?[\)]?$)")
        Return _isNumber.Match(inputStr).Success
    End Function



    Public Function IsNegative(ByVal inputStr As String) As Boolean
        Dim _isNegativeNumber As Regex = New Regex("^[\(]?[\$]?[-]+\d+(,?\d*)*\.?\d*([Ee][-]+\d*)?[\)]?$|^[-]+[\(]?[\$]?\d+(,?\d*)*\.?\d*([Ee][-]+\d*)?[\)]?$")
        Return _isNegativeNumber.Match(inputStr).Success
    End Function


Silverlight Auto Focus on InputBox of TabItem when TabControl changed.


    Private Sub SkuTabControl_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Handles SkuTabControl.SelectionChanged
        If SkuTabControl.SelectedItem IsNot Nothing Then
            Dim itemTab As TabItem = SkuTabControl.SelectedItem
            Dim itemGrid As Grid = itemTab.Content
            AddHandler itemGrid.Loaded, AddressOf itemGrid_Loaded
            'itemGrid.LoadedEvent()
        End If
    End Sub

    Private Sub itemGrid_Loaded(ByVal sender As Object, ByVal e As EventArgs)
        Dim itemTab As TabItem = SkuTabControl.SelectedItem
        Dim itemGrid As Grid = itemTab.Content
        Dim customInputBoxes = GetInputBoxControls(itemGrid).OfType(Of CustomTextBox.CustomTextBox)()
        Dim cTextBox As CustomTextBox.CustomTextBox
        For Each cTextBox In customInputBoxes.ToList
            If CType(cTextBox.Background, SolidColorBrush).Color = Color.FromArgb(255, 255, 255, 0) Then
                cTextBox.Focus()
                Exit For
            End If
        Next
    End Sub

    Private Function GetInputBoxControls(ByVal root As DependencyObject) As IEnumerable(Of DependencyObject)
        Try
            Dim customBoxList As New List(Of DependencyObject)()
            customBoxList.Add(root)
            For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(root) - 1
                customBoxList.AddRange(GetInputBoxControls(VisualTreeHelper.GetChild(root, i)))
            Next i
            Return customBoxList
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Monday, January 14, 2013

Silverlight twoway binding helper

For real twoway binding on textbox of silverlight, you have to define a helper class and implement INotifyPropertyChanged


Partial Public Class SKUDetailUserControl
    Inherits UserControl
    Implements INotifyPropertyChanged


    ''Define multiple for two way mode
    Public Event PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged


Helper class:



    Public Class BindingHelper
        Public Shared Function GetUpdateSourceOnChange(obj As DependencyObject) As Boolean
            Return obj.GetValue(UpdateSourceOnChangeProperty)
        End Function
        Public Shared Sub SetUpdateSourceOnChange(obj As DependencyObject, value As Boolean)
            obj.SetValue(UpdateSourceOnChangeProperty, value)
        End Sub
        Public Shared ReadOnly UpdateSourceOnChangeProperty As DependencyProperty =
        DependencyProperty.RegisterAttached("UpdateSourceOnChange", GetType(Boolean), GetType(BindingHelper), New PropertyMetadata(False, AddressOf OnPropertyChanged))

        Private Shared Sub OnPropertyChanged(obj As DependencyObject, e As DependencyPropertyChangedEventArgs)
            Dim TxtBox As TextBox = obj
            If TxtBox IsNot Nothing Then
                If e.NewValue Then
                    AddHandler TxtBox.TextChanged, AddressOf OnTextChanged
                Else
                    RemoveHandler TxtBox.TextChanged, AddressOf OnTextChanged
                End If
            End If
        End Sub
        Private Shared Sub OnTextChanged(sender As Object, e As TextChangedEventArgs)
            Dim TxtBox As TextBox = sender
            If TxtBox IsNot Nothing Then
                Dim be = TxtBox.GetBindingExpression(TextBox.TextProperty)
                If be IsNot Nothing Then
                    be.UpdateSource()
                End If
            End If
        End Sub
    End Class


XAML :




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.

Thursday, September 29, 2011

jQuery UI slider twisting for both iPad and iPhone, or any tablet.

I was working for improving our slider to be avaiable for both iPad and iPhone, however, from the reference of official jQuery UI, it addressed to target only for iPhone(http://bugs.jqueryui.com/ticket/4143). The one (http://bugs.jqueryui.com/ticket/7001) targeting to iPad is using the same of iPhone. It words well with iPhone but not iPad. By checking the code, I found it is a small trick to adjust the code to work for both of them or even more. Here follows the solution.

You want to first put code change as cscott's post first (https://github.com/cscott/jquery-ui/commit/3744712e13271fa06a502be19bb8b3854fe66c59) , then modify the code of file (jquery.ui.mouse.js or ui.mouse.js), finding the following one (around line No. 17th) and do following 2 steps:
Step 1. Modify code:
(deleted) var iPhone = (navigator.userAgent.indexOf('iPad') != -1);
(added) var iPhonePad = (navigator.userAgent.indexOf('iPad') != -1) ||(navigator.userAgent.indexOf('iPhone') != -1);

Step 2. Replace all the keyword "iPhone" to "iPhonePad".