Nav Menu

Before Login
------------
Login
Search
Categories
Browse
Gallary
Recent Submissions
Recent Redemptions
About Us
Contact Us
-------------
After Login
-------------
Search
Categories
Browse
Submit Information
Submission Status
Gallary
My Account
Logout
---------------
My Account
---------------
Update Profile
Change Password
My Points
Redeem Points
Redeemption Status
Invite
------------------
Submit Information
-------------------
Add New Place
Add Place Contact Details
Etc etc.
Recent Submissions
Recent Redemptions
-------------------


http://nyshah-002-site1.1tempurl.com/





User Custom Action

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$RootUrl = "https://<PORTAL>.sharepoint.com" #Make sure no '/' at the end
$UrlCollection = "https://<PORTAL>.sharepoint.com","https://<PORTAL>.sharepoint.com/search"
$SiteAssetFolderPath = "$($PSScriptRoot)\SiteAssets"

$UserName = "O365 USERNAME/EMAIL"
$Password = "" #If not set, script will show dialog to enter password at runtime.


if($Password) {
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
}
else {
    $SecurePassword = Read-Host -Prompt "Enter the password" -AsSecureString
}

Function Activate-Script([string]$Title,[int]$Sequence,[string]$ScriptSrc)
{
    $SingleCustomAction = $CustomActions | ?{$_.Title -eq $Title }
    if($SingleCustomAction)
    {
        $cAction = $SingleCustomAction[0];
        $cAction.Location = "ScriptLink";
        $cAction.Sequence = $Sequence;
        $cAction.ScriptBlock = "";
        $cAction.ScriptSrc = $ScriptSrc;
        $cAction.Update();
        $CustomActions.Update();
        #$site.Update();
        $Context.ExecuteQuery();
        Write-Host "Applying $($ScriptSrc) to $($site.Url) as UserCustomAction $($Title) [Updating]";
Write-Host ""
    }
    else
    {
        $cAction = $CustomActions.Add();
        $cAction.Title = $Title;
        $cAction.Location = "ScriptLink";
        $cAction.Sequence = $Sequence;
        $cAction.ScriptBlock = "";
        $cAction.ScriptSrc = $ScriptSrc;
        $cAction.Update();
        #$site.Update();
        $CustomActions.Update();
        $Context.ExecuteQuery();
        Write-Host "Applying $($ScriptSrc) to $($site.Url) as UserCustomAction $($Title) [Adding]";
Write-Host ""
    }
}
Function Activate-ScriptBlock([string]$Title,[int]$Sequence,[string]$ScriptBlock)
{
    $SingleCustomAction = $CustomActions | ?{$_.Title -eq $Title }
    if($SingleCustomAction) # AB Dev note, looks to be duplication of code here, can we consolidate?
    {
        $cAction = $SingleCustomAction[0];
        $cAction.Location = "ScriptLink";
        $cAction.ScriptBlock = $ScriptBlock;     
        $cAction.Sequence = $Sequence;
        $cAction.Update();
        $CustomActions.Update();
        #$site.Update();
        $Context.ExecuteQuery();
        Write-Host "Applying $($ScriptBlock) to $($site.Url) as UserCustomAction $($Title) [Updating]";
Write-Host ""
    }
    else
    {
        $cAction = $CustomActions.Add();
        $cAction.Title = $Title;
        $cAction.Location = "ScriptLink";
        $cAction.Sequence = $Sequence;
        $cAction.ScriptBlock = $ScriptBlock;
        $cAction.Update();
        #$site.Update();
        $CustomActions.Update();
        $Context.ExecuteQuery();
        Write-Host "Applying $($ScriptBlock) to $($site.Url) as UserCustomAction $($Title) [Adding]";
Write-Host ""
    }
}

Function Upload-AllFiles([Microsoft.SharePoint.Client.Web] $SPWeb, [string]$ListName, [string]$FolderPath)
{
    $List = $SPWeb.Lists.GetByTitle($ListName)
    $Context.Load($List)
    $Context.ExecuteQuery()

    Foreach ($File in (dir $FolderPath -File))
    {
        $FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
        $FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
        $FileCreationInfo.Overwrite = $true
        $FileCreationInfo.ContentStream = $FileStream
        $FileCreationInfo.URL = $File
        $Upload = $List.RootFolder.Files.Add($FileCreationInfo)
        $Context.Load($Upload)
        $Context.ExecuteQuery()
        $FileStream.Close()
    }
}

# Upload files to root site's Site Assets Library.

Write-Host $RootUrl
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($RootUrl)
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
$Context.Credentials = $Credentials


$web = $Context.Web
 
$Context.Load($web);
$Context.ExecuteQuery();

Upload-AllFiles -SPWeb $web -ListName "Site Assets" -FolderPath $SiteAssetFolderPath

foreach($Url in $UrlCollection)
{
    Write-Host $Url
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
    $Context.Credentials = $Credentials

    $site = $Context.Site
    $CustomActions = $site.UserCustomActions

    $Context.Load($site);
    $Context.Load($CustomActions);
    $Context.ExecuteQuery();
 
    $dateStamp = Get-Date -format "ddMMMyyyyHHmmss"

    Activate-Script -Title "<PORTAL> JQuery" -Sequence 1000 -ScriptSrc "$($RootUrl)/SiteAssets/jquery-1.8.0.min.js?v=$($dateStamp)";
    Activate-Script -Title "<PORTAL> Navigation JS" -Sequence 1002 -ScriptSrc "$($RootUrl)/SiteAssets/Navigation.js?v=$($dateStamp)";
    Activate-Script -Title "<PORTAL> Google Analytics JS" -Sequence 1002 -ScriptSrc "$($RootUrl)/SiteAssets/GoogleAnalytics.js?v=$($dateStamp)";

    Activate-ScriptBlock -Title "<PORTAL> CSS" -Sequence 1001 -ScriptBlock "document.write('<link rel=""stylesheet"" href=""$($RootUrl)/SiteAssets/Styles.css?v=$($dateStamp)"" />');";
    Activate-ScriptBlock -Title "<PORTAL> Navigation CSS" -Sequence 1005 -ScriptBlock "document.write('<link rel=""stylesheet"" href=""$($RootUrl)/SiteAssets/Navigation.css?v=$($dateStamp)"" />');";

    $Context.Dispose();
}


Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#$RootUrl = "https://<PORTAL>.sharepoint.com" #Make sure no '/' at the end
$UrlCollection = "https://<PORTAL>.sharepoint.com","https://<PORTAL>.sharepoint.com/search"

$UserName = "O365 USERNAME/EMAIL"
$Password = ""

if($Password) {
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
}
else {
//If we set password as empty, it will prompt from here.
    $SecurePassword = Read-Host -Prompt "Enter the password" -AsSecureString
}

foreach($Url in $UrlCollection)
{
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
    $Context.Credentials = $Credentials

    $Context.Load($Context.Site.UserCustomActions)
    $Context.ExecuteQuery();

    $Context.Site.UserCustomActions | Select Title

    $Context.Site.UserCustomActions.Clear()
    $Context.ExecuteQuery();
}


-------

{"postalcodes":[{"adminCode2":"474","adminName3":"Gandhinagar","adminCode1":"09","adminName2":"Ahmedabad","lng":73.063043,"countryCode":"IN","postalcode":"382481","adminName1":"Gujarat","placeName":"Chandlodia","lat":23.994149},{"adminCode2":"473","adminName3":"Gandhi Nagar","adminCode1":"09","adminName2":"Gandhi Nagar","lng":73.063043,"countryCode":"IN","postalcode":"382481","adminName1":"Gujarat","placeName":"Dr.Baou","lat":23.994149},{"adminCode2":"474","adminName3":"Daskroi","adminCode1":"09","adminName2":"Ahmedabad","lng":72.1960228926951,"countryCode":"IN","postalcode":"382481","adminName1":"Gujarat","placeName":"Gota","lat":22.709981466664846},{"adminCode2":"474","adminName3":"Ahmadabad City","adminCode1":"09","adminName2":"Ahmedabad","lng":73.063043,"countryCode":"IN","postalcode":"382481","adminName1":"Gujarat","placeName":"Nirnaynagar","lat":23.994149}]}

.Net Data Helper

This class file will help you to write .net SQL Operations easily.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace GMS.DAL {
public class DALHelper {#region Fields

public SqlConnection _Connection = null;

#endregion Fields

#region Constructors

public DALHelper(string connectionString) {
_Connection = new SqlConnection(connectionString);
}

#endregion Constructors

#region Methods

public static DataTable GetDatatable(List < string > dataList, string tableName, List < string > columnList) {
DataTable dt;
dt = new DataTable(tableName);

foreach(string column in columnList) {
dt.Columns.Add(column, typeof(string));
}

foreach(string item in dataList) {
dt.Rows.Add(item);
}

return dt;
}

public static DataTable GetDataTableOneColumn(List < object > dataList, string tableName, string columnName, Type columnType) {
DataTable dt;
dt = new DataTable(tableName);
dt.Columns.Add(columnName, columnType);

foreach(object item in dataList) {
dt.Rows.Add(item);
}

return dt;
}

public static SqlParameter SqlParameter(string parameterName, SqlDbType parameterType, object parameterValue) {
SqlParameter paramParameter = new SqlParameter("@" + parameterName, parameterType);
paramParameter.Value = parameterValue;
return paramParameter;
}

public void Dispose() {
try {
if (_Connection != null && _Connection.State != ConnectionState.Closed) _Connection.Close();
}
catch(Exception e) {
throw e;
}
}

public int ExecuteNonQuery(string query, params SqlParameter[] parameters) {
int returnValue = 0;
try {
Open();
SqlCommand oCommand = new SqlCommand(query, _Connection);
if (parameters != null) oCommand.Parameters.AddRange(parameters);

returnValue = oCommand.ExecuteNonQuery();
oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}

return returnValue;
}

public int ExecuteNonQueryProcedure(string storedProcName, params SqlParameter[] parameters) {
int returnValue = 0;
try {
Open();
SqlCommand oCommand = GetSqlCommandObject(storedProcName, parameters);
returnValue = oCommand.ExecuteNonQuery();
oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}

return returnValue;
}

public DataSet ExecuteProcedureReader(string storedProcName, params SqlParameter[] parameters) {
DataSet Result = new DataSet();
SqlDataAdapter objSqlDataAdapter = null;
try {
Open();
SqlCommand oCommand = GetSqlCommandObject(storedProcName, parameters);
oCommand.CommandTimeout = 240;
objSqlDataAdapter = new SqlDataAdapter(oCommand);
objSqlDataAdapter.Fill(Result);
oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}
return Result;
}

public DataSet ExecuteQueryReader(string query, params SqlParameter[] parameters) {
DataSet Result = new DataSet();
SqlDataAdapter objSqlDataAdapter = null;
try {
Open();

SqlCommand oCommand = new SqlCommand(query, _Connection);

if (parameters != null) oCommand.Parameters.AddRange(parameters);

objSqlDataAdapter = new SqlDataAdapter(oCommand);
objSqlDataAdapter.Fill(Result);

oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}
return Result;
}

public int ExecutScalarProcedure(string storedProcName, params SqlParameter[] parameters) {
int returnValue = 0;
try {
Open();
SqlCommand oCommand = GetSqlCommandObject(storedProcName, parameters);
returnValue = Convert.ToInt32(oCommand.ExecuteScalar());
oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}

return returnValue;
}

public string ExecutScalarProcedureString(string storedProcName, params SqlParameter[] parameters) {
string returnValue = string.Empty;
try {
Open();
SqlCommand oCommand = GetSqlCommandObject(storedProcName, parameters);
returnValue = oCommand.ExecuteScalar().ToString();
oCommand.Dispose();
Dispose();
}
catch(Exception e) {
throw e;
}

return returnValue;
}

internal static SqlParameter SqlParameter(string parameterName, SqlDbType parameterType, int parameterSize, string parameterValue) {
SqlParameter paramParameter = new SqlParameter("@" + parameterName, parameterType, parameterSize);
paramParameter.Value = parameterValue;
return paramParameter;
}

private SqlCommand GetSqlCommandObject(string storedProcName, params SqlParameter[] parameters) {
SqlCommand oCommand = new SqlCommand(storedProcName, _Connection);
oCommand.CommandType = CommandType.StoredProcedure;
if (parameters != null) oCommand.Parameters.AddRange(parameters);
return oCommand;
}

private void Open() {
try {
if (_Connection != null && _Connection.State == ConnectionState.Closed) _Connection.Open();
}
catch(Exception) {}
}

#endregion Methods
}
}

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...