Markieren und Kopieren in der Konsole
3 December, 2009 at 8:22 pm | In variouse code | Leave a CommentHeute hat mir ein netter Kollege einen netten Trick gezeigt. Man kann die gute alte Konsole komfortabler zum Markieren und Kopieren bringen.
Einfach den Haken in den Einstellungen setzen:
Nach der Änderung lässt sich bei gedrückter linker Maustaste bequem markieren und per Entertaste in die Zwischenablage übernehmen.
Ein Hoch auf die Produktivität
T-SQL SUM is giving null result but 0 expected
16 October, 2009 at 7:24 pm | In Reporting Services | Leave a CommentThis is a personal reminder that we can easily write
SELECT
isnull(sum(columnToCalculate), 0)
FROM…
to get the number zero instead of nothing.
This tactic reduces code in the layers above.
MS CRM showing time on queue entered column
13 October, 2009 at 4:38 pm | In Dynamics CRM | Leave a CommentAfter searching hours and finding only parts of the puzzle – here is the quite easy solution for showing the time on the “Entered queue” time stamp of a queue view:
1. execute this script on you crm database:
update EntityView
set iscustomizable = 1 where name = ‘queueitem’
(of course unsupported by MS)
2. Go for Settings => Customizations
Search the now available queue item => go for Attributes => enteredon => change for “Date and Time”
Save, Publish => here we go:
Nice result, we can see the date and the time directly on the queue
More information about changing views you can find here:
- http://icu-mscrm.blogspot.com/2005/07/customizing-activity-views.html
- http://www.eggheadcafe.com/conversation.aspx?messageid=31293608&threadid=31293605
- http://blogs.inetium.com/blogs/vbullinger/archive/2007/10/18/modifying-queue-views-in-crm.aspx
ASP.NET und Entity Framework Fehlermeldung: Der Typ "System.Data.Objects.DataClasses.EntityObject" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" hinzu.
3 August, 2009 at 5:26 pm | In Entity Framework, variouse code | Leave a CommentHallo,
wer versucht EntityFramework und ASP.NET MVC zusammen zubringen und dabei auf diese Fehlermeldung stößt:
Der Typ “System.Data.Objects.DataClasses.EntityObject” ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly “System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ hinzu
dem kann geholfen werden. Ihr müsst 2 Dinge erledigen:
- Referenz auf die System.Data.Entity hinzufügen
- WebConfig um folgende Zeile erweitern:
<add assembly=”System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″/>
C# override settings of referenced dll
26 July, 2009 at 10:34 pm | In variouse code | Leave a CommentThe article describes how to use and override settings in multiple dlls of .NET applications.
A common scenario for the technique is to have different stages (i.e.: development, test, production) and adjust the settings as required for each stage.
The challenge is that the settings for the logic are usually located in the dll referenced by the executing assembly. For this article I use a class library for the referenced logic assembly and a console application for the executing one. The aim is to override settings in the logic assembly by the configuration file of the console application.
The namespace of the class library are set up like this:
Step 1: Create a settings file and create a simple string setting:
Step 2: Check the result in the app.config of the logic assembly:
Step 3: Create a test class using the setting:
Step 4: Using the dll in the executing assembly and get the original setting
Step 5: Override the setting of the referenced dll by inserting config section in the config file of the executing assembly
This article is first of all a reminder for my self, hope it helps you as well.
Query MS Dynamics CRM Date only correctly with time zone offset
16 July, 2009 at 10:24 pm | In Dynamics CRM | Leave a CommentThe MS CRM date time data type can be defined during the customization as date only.
When you use the crm date pick control, the time will be set to the database as picked date with time 00:00:00 +/- the time zone off set as the time is stored as UTC.
Example: the stored time in the data base for picking the 2009-07-02 by the UI will be:
2009-07-01 22:00:00.000
(if your crm settings say that you live in a time zone with +2)
To run queries with correct results I found a efficient technique.
For Example I would like to have all records modified for yesterday (2009-07-02).
Step 1: create a CRM date/time and subtract 24 hours:
CrmDateTime crmDate = new CrmDateTime(DateTime.Now.AddHours(-24));
Step 2: create a date/time variable – assign the date part of the CrmDateTime and adjust the offset
DateTime rightTime = crmDate.DateTime.Date – (crmDate.DateTime – crmDate.UserTime);
Step 3: call rightTime.ToString(“s”)
will result “2009-07-01T22:00:00″.
This is exactly what we need for your search criteria for example by query expression object.
This technique works for each time zone as we adjust the offset in step two.
(as users can have different time zone settings)
MS Dynamics CRM activity preview, queue view customizing by http module
27 June, 2009 at 6:39 am | In Dynamics CRM | Leave a CommentThis post is about changing the activity preview in Microsoft Dynamic CRM to custom preview.
ASP.NET uses a feature for page processing, called HTTP modules. HTTP modules
participate in the processing of a request by handling application events.
A given request can flow through multiple HTTP modules.
So we are creating our own module and hook on the PreRequestHandlerExecute of the PageLiveCycle.
Creating HTTP Modules is an easy task . You simply need to
add a class that implements the System.Web.IHttpModule interface. You can then register your
module by adding it to the <httpModules> section of the web.config file of your CRM root.
Your web.config should have something like the following structure:
<system.web>
…
<httpModules>
<add name=”ExtensionModulActivity” type=”WebPages.HttpExtensionModul.ExtensionClass,WebPages.HttpExtensionModul” />
</httpModules>
…
Example Implementation for an http module – which is registering for the Event and filtering for the page we would like to change:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebPages.HttpExtensionModul
{
public class ExtensionClass : IHttpModule
{
public void Dispose()
{
;
}
public void Init(HttpApplication app)
{
//register events
app.PreRequestHandlerExecute += new EventHandler(this.OnPreRequestHandlerExecute);
}
public void OnPreRequestHandlerExecute(object o, EventArgs args)
{
HttpContext context = ((HttpApplication)o).Context;
IHttpHandler handler = context.Handler;
//Hookup into PreRender event of the Page
if (context.Request.AppRelativeCurrentExecutionFilePath.ToLower().EndsWith("preview.aspx"))
{
int type = (context.Request.QueryString["type"] != null) ? int.Parse(context.Request.QueryString["type"]) : -1;
Guid id = (context.Request.QueryString["id"] != null) ? new Guid(context.Request.QueryString["id"]) : Guid.Empty;
if (id != Guid.Empty && type == 4002 ) //4002 = email
{
context.Response.ContentType = "text/xml";
context.Response.Filter = new ActivityPreview(context.Response.Filter, type, id);
}
}
}
}
}
Example Implementation of a stream class, to add the custom text
namespace WebPages.HttpExtensionModul
{
public class ActivityPreview : MemoryStream
{
private Stream _stream;
private long _position;
private int _entityId;
private Guid _objectId;
public ActivityPreview(Stream stream, int entityId, Guid objectId)
{
_stream = stream;
_entityId = entityId;
_objectId = objectId;
}
public int EntityId
{
get { return _entityId; }
}
public Guid ObjectId
{
get { return _objectId; }
}
public override void Write(byte[] buffer, int offset, int count)
{
string html = System.Text.Encoding.UTF8.GetString(buffer, offset, count);
html = "<preview>The new module works we can show here our custom text
</preview>";
buffer = System.Text.Encoding.UTF8.GetBytes(html);
_stream.Write(buffer, 0, buffer.Length);
}
}
}
The good thing about this customisation that we do not change any CRM code or files, so even with the next CRM generation the code will probably work with little or no changes. And it is working directly with queue view, advanced find, history, activities view – anywhere the preview.aspx is originally requested.
The result – our own module is called as expected:
Attention: Check your sub applications after the http module is working, probably you have to remove the module there.
Just use <remove name=”ExtensionModulActivity”/>, here is a good post about removing.
Store object array in settings file
25 May, 2009 at 10:48 pm | In variouse code | 1 Comment2.) step is to create a second class as generic list to hold your objects.
Attention: you have to create the 2 classes outside of the assembly where you like to use the settings file to store the objects. So here it is done in the MyAssembly.dll. If you found out how to do it in the same assembly please leave me a comment.
namespace MyAssembly { public class AccountSet : List<Account> { } public class Account { public string UserName; public string Domain; } }
3.) step is to create the xml snippet. It is mandatory to use “ArrayOf” + your storage class as root element.
<?xml version="1.0" encoding="utf-16"?> <ArrayOfAccount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Account> <UserName>userA</UserName> <Domain>domain</Domain> </Account> <Account> <UserName>userB</UserName> <Domain>domain</Domain> </Account> </ArrayOfAccount>
4.) step create a new settings file and add a new property. In the type drop down use browse to select your assembly (do not forget to add reference and build first) and as value you paste the xml snippet from above.
5.) step use your stored objects of the settings file
foreach (MyAssembly.Account a in Settings1.Default.AllAccounts) { Console.WriteLine("Name = " + a.UserName); }
Like Anweisung in MySQL mit Parameter über ado.net data adapter oder Ähnliches
7 March, 2009 at 5:13 pm | In variouse code | Leave a CommentVersucht man über den dot net mysql connector bzw. via MySql.Data.dll like Anweisungen mit Parametern und like Filter abzusenden, bekommt man unter Umständen die Commands nicht so ausgeführt wie man glaubt.
Das Statement sieht wahrscheinlich so aus:
…Where spalte like ‘%@parameter%’ …
damit es funktioniert können die Prozentzeichen/Wildcards so übergeben werden:
…Where spalte like CONCAT(‘%’, parameter, ‘%’) …
Reporting Services Multi-Select and null values for parameters are possible
11 January, 2009 at 11:25 pm | In Reporting Services | Leave a CommentTags: multi select, null value, parameters, Reporting Services
Work around for using multi select Parameters in combination with null values within Reporting Services.
By default it is impossible to check “multi-value” and “Allow null-value” in the parameters settings.
We found several blogs and forums dealing with this topic. Usually the advised answer was a stored procedure with logic to deal with null values.
There is an easier work around:
First we create a dataset to use as query source for “available values” inside of report parameters.
And here we got the first trick, as reporting services does not allow null for the available values – we create our substitute for null. We used a GUID to be pretty unique.
SELECT currencyidname, currencyid
FROM currency
UNION
SELECT '(null)' AS Expr1, '{65F02099-8E4C-4483-91B8-90AEF2838E76}' AS Expr2
ORDER BY currencyidname
“(null)” will be shown up as selectable value of the parameter when we run the report.
Second step to achieve multi-select with null value is to build in the just created parameter to our main query.
The trick is to add the certain GUID hard coded and ask if our GUID is selected AND if the searched field is NULL.
SELECT…
FROM…
WHERE
booking.transactioncurrencyid IN (@Report_Parameter_transactioncurrencyidname)
OR ('65F02099-8E4C-4483-91B8-90AEF2838E76' IN (@Report_Parameter_transactioncurrencyidname)
AND FilteredAcando_booking.transactioncurrencyid IS NULL)
voila, very effective way of doing multi select including looking for null with reporting services.
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.