blog.easyciel.net author="Patrick Rabian" about="c#, sharepoint, biztalk, team system resources" more="news, samples, tips for .NET world's developers !"

How to modify Microsoft Office document properties (Excel, Word, Powerpoint) without Office installed ?

Friday, 23 December 2005 18:10 by prabian

From your Visual Studio’s projet (.NET 2003 or 2005), add a reference to the pre-registered dll DSOFILE.DLL downloaded from : Support Microsoft

You can use this sample which do the following :

  • Open a office document in read-only mode
  • Compare the custom property named ‘connectionStringCustomProperty’ with a new value
  • If the value is already set : return
  • Else re-open the document in read-write mode and set the new value

private void UpdateConnectionString(string filePath,string connectionStringCustomProperty, string newConnectionString)
{

OleDocumentPropertiesClass document = new OleDocumentPropertiesClass();
bool mustUpdate = false;

try        
{
//Verifions si la modification est nécessaire en mode read-only

document.Open(filePath, true, dsoFileOpenOptions.dsoOptionDefault);
foreach (CustomProperty property in document.CustomProperties)
{

if (property.Name == connectionStringCustomProperty)
{

object value = property.get_Value();

if (!value.ToString().Equals(newConnectionString))
{
mustUpdate =
true;
}
}
}
}

finally        
{
document.Close(
false);
}

if (!mustUpdate) return;

//Modification de la propriété        

try        
{
document.Open(filePath,
false, dsoFileOpenOptions.dsoOptionDefault);
foreach (CustomProperty property in document.CustomProperties)
{

if (property.Name == connectionStringCustomProperty)
{

object value = (object)newConnectionString;
property.set_Value(
ref value);
}
}

if (document.IsDirty)
document.Save();
}

finally        
{
document.Close(
false);
}
}

French title : Comment modifier les propriétés personnalisées d’un fichier Microsoft Office Excel, Word ou PowerPoint ?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Office
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Controlling Your Computer with X10…

Tuesday, 13 December 2005 23:03 by prabian

Presentation video on coding4fun :

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   News
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Ms Speech SDK : your computer speak

Tuesday, 13 December 2005 22:57 by prabian

The SDK can be downloaded on : http://www.microsoft.com/downloads

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   News
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Article MSDN : WebParts en ASP.NET 2.0

Tuesday, 13 December 2005 22:50 by prabian

Personnalisez votre portail grâce aux contrôles utilisateur et aux composants WebPart personnalisés

http://www.microsoft.com/france/msdn/aspnet/webpart_aspnet20.mspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Get age from date of birth in Transact Sql

Monday, 12 December 2005 11:55 by prabian

Calculate the age of a person from his date of birth.

Parameters :

@dateNaissance = Date of birth
@dateActuelle = Current date (from GetDate())

CREATE FUNCTION [dbo].[fnGetAge] (@dateNaissance SMALLDATETIME, @dateActuelle SMALLDATETIME)
RETURNS INT AS
BEGIN
DECLARE @age INT
SET @age = FLOOR(DateDiff(dd,@dateNaissance,@dateActuelle)/365.25)

IF (Day(@dateNaissance) = Day(@dateActuelle)) AND (Month(@dateNaissance) = Month(@dateActuelle))
   BEGIN
      SET @age = @age + 1
   END

RETURN @age
END

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   DAL | Sql
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

10 useful addins for VS.NET

Monday, 12 December 2005 09:27 by prabian

10 useful addins for Visual Studio .NET : http://msdn.microsoft.com/msdnmag/issues/05/12/VisualStudioAddins/default.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Javascript : Select all check boxes of a form

Wednesday, 7 December 2005 14:43 by prabian

function SelectAll(value)
{

var formblock;
var forminputs;

formblock = document.forms[0];
forminputs = formblock.getElementsByTagName(
‘input’);

for (i = 0; i < forminputs.length; i++)
{


var regex = new RegExp(‘checkbox’, ‘i’);
if (regex.test(forminputs[i].getAttribute(‘type’)))
{

if (value == ‘1′)
{
forminputs[i].checked =
true;
}

else
{
forminputs[i].checked =
false;
}
}
}
}

Keywords : javascript selectall input form checkbox

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Javascript | css
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Simple Impersonate in c# and ASP.NET account rights

Friday, 2 December 2005 10:47 by prabian

If you want to execute a portion of code in a différent sécurity context, you can use this class “Impersonate”.

Just create a instance in a using block.

using(new Impersonate(domain, user, password))
{
      //Code with different execution rights
}

Download the class here : Impersonate.cs in zip

Under Windows Server 2003, you will prefer : WindowsIdentity.Impersonate()

Warning : an error 1314 can occured on Windows 2000 system :
Read the note at the end of this article and read this article
You can change the ‘Act as part of the operating system’ in :
- From Administrative Tools, open Local Security Policy. If the Administrative Tools window is no longer open, navigate to Start > Settings > Control Panel> Administrative Tools> Local Security Policy.
- Navigate to Security settings > Local Policies > User Rights Assignment
- Double-click Act as part of the operating system under the policy column in the right-hand pane.
- The Local Security Policy Setting dialog appears. Select Add
(Then, if the account added is the one that is currently logged…logout and login again !)

For more details on implementation, read those Microsoft resources :
How to use impersonation and delegation with ASP.NET 2.0 
Create a service account for an ASP.NET 2.0 application
ASP.NET Application security in hosted environment

Access control list : ASP.NET process account must have the following right to work correctly

Location Access type Account Comments

%SystemRoot%\Microsoft.NET\Framework\ versionNumber\Temporary ASP.NET Files

Read/write

Process or configured impersonation.

This is the location for dynamically compiled files. Beneath this location, application code generation takes place in a discrete directory for each application. You can configure the root location using the tempDir attribute of the <compilation> configuration section.

%SystemRoot%\assembly

Read

Process or configured impersonation.

This is the location of the global assembly cache (GAC).

%SystemRoot%\System32

Read

Process

Contains system DLLs loaded by the .NET Framework.

%SystemRoot%\Temp

Read/write/delete

Process

Used for Web services support.

User profile directory

Read/write

Process

Used by the GAC cache lock files and the security configuration caching mechanism of the common language runtime. If the user profile directory for the account does not exist, ASP.NET uses the default user profile directory.

Web application directory

Read

Process or configured impersonation.

This is the location for application files.

Web application directory\App_Data

Read/write

Process or configured impersonation.

This is the default location for data files in an ASP.NET Web application. If your application uses the App_Data subdirectory, the ASP.NET process must be able to write to the directory and for some databases, to be able to create temporary files in the subdirectory.

%SystemRoot%\Microsoft.NET\Framework\ version and subdirectories

Read

Process or configured impersonation

ASP.NET must be able to access the system assemblies referenced in the Machine.config file in the CONFIG subdirectory under %SystemRoot%\Microsoft.NET\Framework\version\.

Question : I met a problem in ASP.NET 1.1 context to read the ConfigurationSettings.AppSettings values within an impersonation context ! A idea ?

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET Projects
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

SharePoint Focus

Friday, 2 December 2005 00:00 by prabian

FOCUSING ON EVENTS

Articles :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tsptDocLibEvents_SV01034973.asp

Samples :
Episode 1 : The recycle bin
MSDN Article : http://msdn.microsoft.com/msdnmag/issues/05/02/RecycleBinforWSS/default.aspx

FOCUSING ON SQL SERVER

Impact of direct SQL access to SharePoint’s SQL Server database
Read this article : http://blogs.msdn.com/mikefitz/archive/2005/04/01/404802.aspx.
It talks about this tool :
A few lines on locks : http://www.mssqlcity.com/Articles/General/sql2000_locking.htm

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   SharePoint
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Chris’s Free Developer Tools

Thursday, 1 December 2005 02:13 by prabian

A lot of tools useful for developers !

For example :

  • ADO.NET CsvFileTester
  • .NET FormatDesigner
  • XmlSerializerPreCompiler
  • Filter Files With Unknown Extensions For XP
  • .NET ResourceExplorer
  • Scancode Mapper
  • TAPI Explorer
  • .NET XsdClassesGen
  • Giving VS.NET That XP Look
  • .NET CollectionGen
  • RegexDesigner.NET
  • .NET IM Client Classes
  • Genghis
  • SafeFormatter for .NET
  • VS.NET Fun Facts
  • CorPub
  • UrlRun
  • .NET XML Checker and Validator
  • Setting the Completion Character

Goto : http://www.sellsbrothers.com/tools/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET Projects
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed