Friday, February 25, 2011

SharePoint wildcard searching:

http://www.novolocus.com/2009/05/27/sharepoint-can-have-wildcard-searching/

Friday, February 4, 2011

PDF iFilter 9 for WSS

Ever tried it and failed? Most likely you have.

I followed these instructions: http://www.jackson-delaney.co.uk/blog.html and it worked. Just have some patience while the search service reindexes your content.

Tuesday, February 2, 2010

Tuesday, January 26, 2010

Create PDF in .Net

Seems like there is an easy way to create PDF-files with the ise of iTextSharp, came across it here. http://techdotnets.blogspot.com/

Datagrid Export, troublesome templatecolumn

Ran into a problem today, which had me puzzled for couple of hours.

I have a Datagrid to which I add TemplateColumns dynamicly. Works like a charm until the customer wanted to export all the data.

So I happily assumed that al I had to do was:

System.IO.StringWriter sw= new System.IO.StringWriter
HtmlTextWriter writer = new HtmlTextWriter(sw);

dg.RenderControl(writer)

Response.write(sw.ToString());
Response.End();

Works very well as long as the columns are bound. Hower the TemplateColumns are completely blank. I couldn´t figure it out so I did a little googling and came across this blog: http://www.c-sharpcorner.com/uploadfile/dipalchoksi/exportaspnetdatagridtoexcel11222005041447am/exportaspnetdatagridtoexcel.aspx

Just pass your datagrid to this method and it transforms the TemplateColumn (and others) to a Literalcontrol with a text property, and tada..... The vaules appear in the export.

private void ClearControls(Control control)
{
for (int i=control.Controls.Count -1; i>=0; i--)
{
ClearControls(control.Controls[i]);
}
if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
LiteralControl literal =
new LiteralControl();
control.Parent.Controls.Add(literal);
try
{literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control,null);
}
catch
{
}
control.Parent.Controls.Remove(control);
}
else
if
(control.GetType().GetProperty("Text") != null)
{
LiteralControl literal =
new LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text = (
string)control.GetType().GetProperty("Text").GetValue(control,null);
control.Parent.Controls.Remove(control);
}
}
return;
}


Monday, February 25, 2008

Remoting server

Welcome back.

The hosting server looks like this, remember to add a reference to system.runtime.remoting and to your own server side objects.

Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Serialization

Public Class HostingServer
Shared Sub main()
Dim _Server As New BinaryServerFormatterSinkProvider
Dim _Client As New BinaryClientFormatterSinkProvider
Dim _props As IDictionary = New Hashtable
Dim _channel As TcpChannel

_Server.TypeFilterLevel = _
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full

_props("port") = 8080

_channel = New TcpChannel(_props, _Client, _Server)

ChannelServices.RegisterChannel(_channel, True)

RemotingConfiguration.RegisterWellKnownServiceType _
(GetType(Server_Objects.Server), _
"Serv", WellKnownObjectMode.Singleton)


Console.WriteLine("Press any key to quit.")
Console.ReadLine()
ChannelServices.UnregisterChannel(_channel)
End Sub
End Class

The first part sets the security settings no need to bog down in that. Then we instanciate the channel with the security settings and set it to listen to the port 8080. You can use any port you like that is availible. Register the channel so that the app listens for requests.
Now make the server object "reachable" and as a singleton. This is so that all clients will connect to the same server object.

Now create a new project within the same solution or a new one.

Public Class Server
Inherits MarshalByRefObject

Implements Interfaces.IServer
Private arr As New ArrayList

Public Sub SendToAll(ByVal str As String) Implements Interfaces.IServer.SendToAll

For Each obj As Interfaces.IRemoteClient In arr
obj.Data(str)

Next
End Sub

Public Sub Attach(ByVal irc As Interfaces.IRemoteClient) _
Implements Interfaces.IServer.Attach

arr.Add(irc)
Console.WriteLine(irc.Name & " has entered the chat.")

End Sub

Public Sub Detach(ByVal irc As Interfaces.IRemoteClient) _
Implements Interfaces.IServer.Detach

arr.Remove(irc)
Console.WriteLine(irc.Name & " has left the chat.")

End Sub

Public Function NumOfClients() As Integer _
Implements Interfaces.IServer.NumOfClients

Return arr.Count
End Function

End Class

Now when i´m trying to explain the code I realize that we probably should have started with the Interfaces. Well, well... Just paste the code into your project, as you see its straight forward. The server object implements tha Iserver interface and inherits the Marshalbyrefobject. This is the object that is made public by the hostingserver. All it does is attaching client interfaces to an arraylist, detaches them and counting them and the most importing thing, sending messages to all clients

Next up the mixed files.

Wednesday, February 20, 2008

Simple remoting

I've searched the web for a good and simple remoting example. Some were good, some bad and some simply awful. The trouble with the good ones I found, was that none of them where "complete" or lacked certain features that I was in need of. So I've scanned the web, took the parts I liked and put them togheter to create a good example on which one can build a remoting solution. I'm using .net 2.0.

My goal is to create a simple chatroom solution. I don't want the clients to be polling for messages. I want the messages to be distributed to them. For this project i have created three solutions with VS2005. They are called ServerSide, Mixed and ClientSide.




ServerSide:
On the server side we have the hosting server. It´s a console application. All that this app does is making other objects reachable. I´ll show you the code soon. Then we have what I call the server object. This can be whatever as long as it inherits from the marshalbyrefobject. This is the object that does the "server work". In this example the serverobject "is" the chat server.

ClientSide:
On the client side there is the ClientApplication and a client object. The client application instanciates a client object and "Attaches" it to a server object.

Mixed
For lack of a better word I call this the mixed files. Files that will be shared by the client and server side. The thing is that the server and client side are not aware of each other. What enables them to interact are interfaces. Both sides have references to these interfaces.

In my next post I´ll start to show you the server code.