Tuesday, May 10, 2011

View All the AD Group that you had been added in ASP.Net

I need to know all the group  that i had been assigned, then i can use 
the corrected AD group for my application test.

here is  the code sinppet that all the application to list all the AD group  
 
IdentityReferenceCollection IRCollection=((System.Security.Principal.WindowsIdentity)
(Context.User.Identity)).Groups;
 foreach (IdentityReference ir in IRCollection)
 {
 //Response.Write("<b>GroupName:" + ir.ToString() + "</b><br />"); 
 IdentityReference idRef = ir.Translate(typeof(NTAccount));
 Response.Write("AD Group Name:" + idRef.ToString() + "<br />");
 }

Extract Embedded File From Powerpoint Presentation

i attended a sharepoint seminar few week ago. the Presentation is awesome and view informative. The speaker show us some great demo. he told us that those source code had been embedded in the powerpoint file.

I download the PPTX file, and try to extrac the embedded file via the Powerpoint software interface. But there is no such option or functio to allow me to get the task done.

i google the internet and finally get the solution from Microsoft Office Web site.

the main point of the solution is to rename the PPTX file to a Zip file and use a zip utility software to open the zip file, the you will be able to find embedded file in the embeddings folder.














































please read the following link for complete detail instruction.

Extract files or objects from a PowerPoint 2010 file

Monday, May 9, 2011

How to prevent duplicate insertion in sqlbulkcopy operation

i need to import multiple excel file sheet into Sql Server Database. i implement an ASP.Net Application to allow user upload those excel file and read all the data into the database. However i had found an issue that the sqlbulkcopy can quickly copy and import all the data into sql server. However the sqlbulkcopy is a straight copy. there is no option to detect the duplicate record or duplicate import during the process.

though we can enforce the duplciation detection in the sqlbulkcopy action. we still are able to prevent the duplicate records insertion in the table level.. we only create a unique table index for the target table then the index will filter all those duplciate record out during the quick imported by sqlbulkcopy.



here is a sample sinppet of sql code.

CREATE UNIQUE NONCLUSTERED INDEX [MyIndexName] ON [dbo].[MyTable]
(
    [Column1] ASC,
    [Column2] ASC,
    [Column3] ASC,
    [Column4] ASC,
   )
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = ON, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO


the criteria to create a UNIQUE NONCLUSTERED INDEX is to select all the columns that can unqiuely identify the record in the target imported table