Wed 25 Sep 2019

HandleMunafiq()
{
     switch (Amanat)
     {
          case Khayanat:
               Put_Munafiq_in_Dozakh();
          break;
          .
          .
          .
          .
          .
     }

}

HandleHypocrite()
{
     switch (Trust)
     {
          case Breach_of_Trust:
               Put_Hypocrite_in_Hell();
          break;
          .
          .
          .
          .
          .
     }

}

Categories : Thoughts / Lessons
Comments here
Sat 6 Oct 2018

Comments here
Thu 8 Nov 2012

If you want to show records (Parent Child concatenation), then following SQL Server recursive query could help you in achieve. For a clear picture have a look at following snap

 

 Recursive+Qeury+Parent+Child+Concatenation.jpg

Recursive Query showing only child Records

                           

with parentChildResult as

(

       select ItemId,

                     ItemDescription,

                     ItemCategoryId,

                     cast('' as nvarchar(max)) as ParentNames

       from Items

       where ItemCategoryId is null

        union all

        select i2.ItemId,

                     i2.ItemDescription,

                     i2.ItemCategoryId,

                     parentChildResult.ParentNames + ' > ' + parentChildResult.ItemDescription

       from Items as i2

       inner join parentChildResult

              on parentChildResult.ItemId = i2.ItemCategoryId

)     

 select ItemId,

              stuff(ParentNames, 1, 3, '') + ' > ' + ItemDescription as ParentNames

from parentChildResult

 where ItemId in

(

       SELECT i.ItemId FROM Items i

       WHERE NOT EXISTS(SELECT 1 FROM Items I2 WHERE i.ItemId = I2.ItemCategoryId)

)

 

order by ParentNames

 

  

Recursive Query showing All parents and Child Records

 

with parentChildResult as

(

       select ItemId,

                     ItemDescription,

                     ItemCategoryId,

                     cast('' as nvarchar(max)) as ParentNames

       from Items

       where ItemCategoryId is null

        union all

        select i2.ItemId,

                     i2.ItemDescription,

                     i2.ItemCategoryId,

                     parentChildResult.ParentNames + ' > ' + parentChildResult.ItemDescription

       from Items as i2

       inner join parentChildResult

              on parentChildResult.ItemId = i2.ItemCategoryId

)     

 select ItemId,

              stuff(ParentNames, 1, 3, '') + ' > ' + ItemDescription as ParentNames

from parentChildResult

 order by ParentNames

 

Comments here
Wed 25 Apr 2012

In sharepoint, if it is required to disable the filter and to keep only the sorting, then following workaround could be the solution one.
(Following change are done to sharepoint 2010 using sharepoint designer 2010, might be it works for 2007 aswell)

Please keep the copy of file(s) which you are going to change, incase if some mishap happen J

·         Open the desired sharepoint site in sharepoint designer

·         Select Lists and Libraries from the Site Objects

·         Select desired list / library

·         Select the desired view from the views list where you want to remove to remove filter

·         Click on advance mode

·         Search for the <ViewFields> inside <XmlDefinition>

·         Now add following desired attribute to all desired columns. (All column are  <FieldRef Name="ModifiedOn" />)

as

 <FieldRef Name=" ModifiedOn " LinkToItem="TRUE" Filterable="FALSE" FilterDisableMessage="No filter available "/>

After that, edit the page where the list / library webpart exists or add webpart (list / library) if not already added on the page,  edit webpart properties and select the desired view again then click apply button to reflect changes.

 

In above,

·         You can change the default text for disabled filter using FilterDisableMessage="No filter available " attribute

·         By adding Filterable="FALSE", now the filter will not be available

·         If you want to make a particular column clickable, then add LinkToItem="TRUE"

 

Comments (4)
Wed 26 Jan 2011

Get-SPSite | where {$_.url -like "http://a *"}

Get-SPFarm | Format-List Id, BuildVersion, Servers, Solutions

Add-PSSnapin Microsoft.SharePoint.Powershell

===========

ExecuteHelloWorldScript from batchfile

powershell -Command "& {.\Hello.ps1}" -NoExit
pause


powershell -Command "& {Set-ExecutionPolicy bypass}" -NoExit


===========

CreateContosoSite

if($args) {
  $SiteName = $args[0]
  $SiteUrl = "http://a:3811/sites/ " + $SiteName
  Write-Host "Begin creating Contoso site at" $SiteUrl
  Write-Host
  $NewSite = New-SPSite -URL $SiteUrl -OwnerAlias Administrator -Template STS#1 -Name $SiteName
  $RootWeb = $NewSite.RootWeb
  $RootWeb.Title = "Contoso Site: " + $SiteName
  $RootWeb.Update()
  Write-Host "New Contoso site successfully created"
  Write-Host "-------------------------------------"
  Write-Host "Title:" $RootWeb.Title -foregroundcolor Yellow
  Write-Host "URL:" $RootWeb.Url -foregroundcolor Yellow
  Write-Host "ID:" $RootWeb.Id.ToString() -foregroundcolor Yellow
}
Else {
  Write-Host "ERROR: You must supply Name as parameter when calling CreateContosoSite.ps1"
}


===========

GetSharePointDlls

$path = "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14"

Get-ChildItem $path -recurse |
  Where-Object {$_.name -like "*SharePoint*.dll"} |
  Sort-Object -Property Name -unique |
  Format-Table Name


===========


GetSharePointPublishingFeatures

Get-SPFeature -Limit ALL |
  Where-Object {$_.DisplayName -like "*Publishing*"} |
  Sort-Object -Property Scope
  Format-Table DisplayName, Id, Scope

 

===========

.\GetSharePointPublishingFeatures.ps1
Get-SPFarm | Format-List
Get-SPSite | where {$_.url -like "http://a *"}
.\CreateContosoSite.ps1 lab01test


===========

Comments here
Mon 15 Mar 2010

This post posted by Vladimir Kuzin on 15th Oct 2009. For Quick reference posted here.

Few weeks ago I was working on project which required data to be encrypted using C# and then decrypted using JavaScript. In my case JavaScript was an internal scripting language, which wasn’t exposed to public so I didn’t have to worry about people accessing encryption keys. Project objective was to encode parameter in URL preventing users from substituting it with sequential numbers.

Research:

At first I’ve decided to use symmetric algorithm and looked online for available JavaScript libraries. In my search I’ve found few AES libraries to choose form. After further analysis it was determined that most people had good luck with slowAES, and I’ve attempted to implement it. After spending some time I was unable to decrypt any data encoded with RijndaelManaged class in C#. Since I had to find solution fast I’ve moved on.

Next I’ve decided to try asymmetric encryption algorithm, and after quick research I went with RSA. After downloading most popular RSA library for JavaScript I’ve run into several issues with its implementation. I was able to use C# to decode everything what was encoded in JavaScript, but it didn’t work when data was flowing in opposite direction. After looking into the issue it appeared that JavaScript library was missing padding, however using patched versionof the library didn’t help.

Solution:

Due to lack of time I’ve decided to use simpler encryption algorithm and went with RC4. After downloading RC4 JavaScriptlibrary I’ve got it to work within minutes. Since there is no such thing as RC4 cryptographic provider in the Security.Cryptography namespace I had to use open source RC4 library.

After encrypting data I’ve also converted it to hex (base 16) in the same way as it was done on the JavaScript RC4 demo page.

Encrypting URL parameter with RC4 didn’t completely meet the objective, since it still was possible for users to use sequential numbers. Take a look at example of encrypted data below:

Input Output
10001 49845da1c0
10002  49845da1c3

Notice that only last digit of the encrypted data has changed, therefore substituting it with sequential numbers will cause an issue. To solve this I’ve added random prefix and suffix blocks to data before encrypting. Prefix and suffix blocks consisted from random letters and were anywhere between 10 and 25 characters in length. Now data looked like this:

Input:
JQNLAZXAHHSHMIL;10001;GURUOTCBBNHDCZUNFXIGKP
Output:
32e523ddb00fbf2465002bc1b4251dd12876677d47d6a 6a3101a68517dfb6a86fa525139300d65225e365a38

Every time encrypted value is changing, since it’s generated from new random data. After transferring and decrypting this data on the JavaScript side I’ve spited string by semicolon to get the actual parameter value.

I am sure there are different and possibly better solutions somewhere out there, but this one worked for my client and was implemented within a small project budget.

This is post is from original Post @ vkuzin.com/post/Passing-encrypted-data-between-C-and-JavaScript.aspx

 

Tags: , ,
Comments (3)
Fri 12 Feb 2010

SPWeb has two sharepoint cross-site group collection, SPWeb.Groups and SPWeb.SiteGroups.

SPWeb.Groups returns collection of cross-site groups which has some permission on the site. So if you add group from a site without any permission on the site, then this group wont appear in SPWeb.Groups collection, but it will appear in SPWeb.SiteGroups collection.

You can not use SPWeb.Groups.Add method to add new cross-site group, you need to use SPWeb.SiteGroup.Add method for this purpose.

In addition to this SPWeb has a property AssociatedOwnerGroup, which will return the required SPGroup. You can iterate the SPGroup users to get the list of all owners of the site.

 foreach (SPUser user in web.AssociatedOwnerGroup.Users)
 {
      // .. list all the users                        
 }

 

Finding and adding group

SPGroup  group = GetSiteGroup(web, "groupName");
if (null == group)
{
 web.SiteGroups.Add("groupName", web.AssociatedOwnerGroup, null, "Test Group description");
}

 


private static SPGroup GetSiteGroup(SPWeb web, string name)
{
    foreach (SPGroup group in web.SiteGroups)
    {
 if (group.Name.ToLower() == name.ToLower())
 {
     return group;
 }
    }
 return null;
}

 

 

Tags: , ,
Comments here




Ads