levitra prijs cialis prijs viagra kaufen viagra generika cialis kaufen viagra kaufen viagra bestellen viagra generika viagra bestellen schweiz viagra schweiz rezeptfrei viagra schweiz viagra preis schweiz cialis kaufen cialis 20 mg cialis compendium levitra schweiz levitra compendium levitra 20mg preis schweiz levitra compendium levitra kaufen levitra bestellen kamagra gel kamagra gel kaufen kamagra schweiz kamagra kaufen kamagra bestellen cialis erfahrung kamagra bestellen cialis original cialis kaufen kamagra 100mg kamagra 100
The Lazy Developer http://thelazydeveloper.com.au So so lazy.... Wed, 27 Feb 2019 02:06:35 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.10 Operating system error 5(Access is denied.). http://thelazydeveloper.com.au/?p=127 Wed, 27 Feb 2019 02:06:35 +0000 http://thelazydeveloper.com.au/?p=127 When creating backup need to set the permissions of the folder. Set the security permissions to allow ‘Authenticated Users’ to have read write permissions to the folder. Then run backup scripts again.

 

backup database <DATABASE NAME> to disk = <LOCATION>

 

]]>
Get the Top 10 of each distinct column value http://thelazydeveloper.com.au/?p=124 Tue, 18 Dec 2018 02:34:50 +0000 http://thelazydeveloper.com.au/?p=124

select Pub.Code, Pub.Name, WeekdayName = DateName(weekday,Cast(Cast(EditionDate as nvarchar) as datetime)), EditionDate 
from
(
   SELECT *,
         --adds a row number
         ROW_NUMBER() OVER (PARTITION BY lnkpublicationID ORDER BY EditionDate DESC) AS rn
   FROM src_PublicationEdition
   where EditionDate between 20140101 and 20180101
) a
Inner Join src_Publication PUB on PUB.IDPublication = a.lnkPublicationID
--we can then limit by row number
where rn <= 10


--- OR

;with MAIN As
(
select Pub.Code, Pub.Name, WeekdayName = DateName(weekday,Cast(Cast(EditionDate as nvarchar) as datetime)), EditionDate, rn 
from
(
   SELECT *,
         ROW_NUMBER() OVER (PARTITION BY lnkpublicationID ORDER BY EditionDate DESC) AS rn
   FROM src_PublicationEdition
   where EditionDate between 20140101 and 20180101
) a
Inner Join src_Publication PUB on PUB.IDPublication = a.lnkPublicationID
)
select * from MAIN
where rn < 10
order by Code

 

]]>
Submit Post with error catch http://thelazydeveloper.com.au/?p=121 Wed, 21 Nov 2018 04:10:52 +0000 http://thelazydeveloper.com.au/?p=121

$.post('balbal.html', json, function(data) {
    // ... my code ...
})
.fail(function(response) {
    alert('Error: ' + response.responseText);
});

 

]]>
Async Calls http://thelazydeveloper.com.au/?p=119 Wed, 21 Nov 2018 04:09:09 +0000 http://thelazydeveloper.com.au/?p=119

Private Sub get_data()
        Dim client = New RestClient()
        client.BaseUrl = "http://www.bing.com"

        Dim request = New RestRequest()
        request.Resource = "search?q=""widget+foo"""
        request.Method = Method.POST

        'Async call made with sub class
        client.ExecuteAsync(request, Sub(res)
                                         MessageBox.Show(res.Content) 'Show Data Content Here with Message Box
                                      End Sub)


     End Sub

 

]]>
WPF DataGrid Add right click for each row http://thelazydeveloper.com.au/?p=116 Wed, 17 Oct 2018 05:30:08 +0000 http://thelazydeveloper.com.au/?p=116

<UserControl x:Class="Booking.Components.BookingArtworkListGridView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:bhvr="clr-namespace:APS.Synergy.Client.Framework.Infrastructure.Behaviours;assembly=APS.Synergy.Client.Framework.Infrastructure.WPF"
             xmlns:local="clr-namespace:APS.Synergy.Client.Main.Views"
             mc:Ignorable="d"
             d:DesignHeight="100"
             d:DesignWidth="800">
    <UserControl.Resources>
        <local:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
        <local:ReverseBooleanVisibilityConverter x:Key="ReverseBooleanVisibilityConverter" />
        <local:HasContentToRowHeightConvertor x:Key="HasContentToRowHeightConvertor" />
        <local:CopyStatusBorderStyler x:Key="CopyStatusBorderStyler" />
        <local:CopyStatusTextBrushStyler x:Key="CopyStatusTextBrushStyler" />
        <ContextMenu x:Key="RowMenu"
                     DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
            <MenuItem Header="Preview Artwork"
                 Visibility="{Binding Path=CanPreviewArtwork, Converter={StaticResource BooleanVisibilityConverter}}"
                 Command="{Binding Path=CommandPreviewArtwork}" />
            <Separator />
            <MenuItem Header="Edit Artwork"
                 Visibility="{Binding Path=CanEditArtwork, Converter={StaticResource BooleanVisibilityConverter}}"
                 Command="{Binding Path=CommandEditArtwork}" />
            <Separator Visibility="{Binding Path=CanEditArtwork, Converter={StaticResource BooleanVisibilityConverter}}" />
            <MenuItem Header="Print Artwork Job"
                 Command="{Binding Path=CommandPrintArtwork}" />
        </ContextMenu>
        <Style x:Key="DefaultRowStyle"
               BasedOn="{StaticResource DefaultDataGridRowStyle}"
               TargetType="{x:Type DataGridRow}">
            <Setter Property="ContextMenu"
                    Value="{StaticResource RowMenu}" />
        </Style>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <DataGrid Grid.Row="0"
                  x:Name="AllArtwork"
                  ColumnReordered="AllArtwork_ColumnReordered"
                  AutoGenerateColumns="False"
                  AlternatingRowBackground="LightSkyBlue"
                  HorizontalScrollBarVisibility="Auto"
                  ItemsSource="{Binding Path=FilteredArtworks}"
                  SelectedItem="{Binding Path=SelectedArtwork, Mode=TwoWay}"
                  RowStyle="{StaticResource DefaultRowStyle}">           
            <i:Interaction.Behaviors>               
                <bhvr:DataGridEnterKeyPressBehavior Command="{Binding Path=CommandEditSelectedArtwork}" />
                <bhvr:DataGridRowDoubleClickBehavior Command="{Binding Path=CommandEditSelectedArtwork}" />
            </i:Interaction.Behaviors>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.ArtworkNumber, Mode=OneWay}"
                                    Header="ArtworkNumber1"
                                    x:Name="ArtworkNumber"
                                    CanUserSort="True" />                
  
                <DataGridTemplateColumn Header="Type"
                                        x:Name="Type"
                                        SortMemberPath="ParentArtwork.CopyDataType.DisplayName"
                                        CanUserSort="True">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>


                            <StackPanel Orientation="Horizontal"
                                        Grid.Row="0"
                                        Grid.Column="1">
                                <TextBlock Style="{StaticResource NonEditableDataStacked}"
                                           Text="{Binding Path=ParentArtwork.CopyDataType.DisplayName}" />

                                <Border Style="{StaticResource TagInlineSectionTypeWeb}"
                                        Margin="10,0,0,0"
                                        VerticalAlignment="Center"
                                        Visibility="{Binding Path=IsAdvertisingContentType, Converter={StaticResource ReverseBooleanVisibilityConverter}}">
                                    <TextBlock Text="{Binding Path=ContentType}"
                                               Style="{StaticResource TagInlineTextSectionTypeWeb}" />
                                </Border>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.ActualSize, Mode=OneWay}"
                                    Header="Size"
                                    x:Name="Size"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.RawWordCount, Mode=OneWay}"
                                    Header="Unit Count"
                                    x:Name="UnitCount"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ArtworkThumbnail.ArtworkContent}"
                                    Header="Text"
                                    x:Name="Text"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.HasImages}"
                                    Header="Has Images"
                                    x:Name="HasImages"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.HasBackgroundColour}"
                                    Header="Has Bkg Col"
                                    x:Name="HasBackgroundColour"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.HasBorderColour}"
                                    Header="Has Bdr Col"
                                    x:Name="HasBorderColour"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.HasTextColour}"
                                    Header="Has Text Col"
                                    x:Name="HasTextColour"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.Colour}"
                                    Header="Colour"
                                    x:Name="Colour"
                                    CanUserSort="True" />
                <DataGridTemplateColumn Header="Status"
                                        x:Name="Status"
                                        SortMemberPath="ParentArtwork.CopyStatus.DisplayName"
                                        CanUserSort="True">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border Style="{Binding Path=ParentArtwork.CopyStatus, Converter={StaticResource CopyStatusBorderStyler}}"
                                    Grid.Row="3"
                                    Grid.Column="1"
                                    CornerRadius="2"
                                    Padding="0"
                                    Margin="3,0"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Left">
                                <TextBlock Text="{Binding Path=ParentArtwork.CopyStatus.DisplayName}"
                                           Margin="4,0"
                                           Foreground="{Binding Path=ParentArtwork.CopyStatus, Converter={StaticResource CopyStatusTextBrushStyler}}" />
                            </Border>
                        </DataTemplate>

                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.CopySourceType.DisplayName}"
                                    Header="Source"
                                    x:Name="Source"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.CopyDelivery.Name}"
                                    Header="Delivery"
                                    x:Name="Delivery"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.ProofType.DisplayName}"
                                    Header="Proof"
                                    x:Name="Proof"
                                    CanUserSort="True" />
                <DataGridTextColumn Binding="{Binding Path=ParentArtwork.InsertionDates}"
                                    Header="Insertion Date(s)"
                                    x:Name="InsertionDates"
                                    CanUserSort="True" />
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Preview"
                                        Style="{StaticResource DataGridHyperlinkButtonStyle}"
                                        Visibility="{Binding Path=CanPreviewArtwork, Converter={StaticResource BooleanVisibilityConverter}}"
                                        Command="{Binding Path=CommandPreviewArtwork}" />
                                <Button Content="Manage"
                                        Style="{StaticResource DataGridHyperlinkButtonStyle}"
                                        Visibility="{Binding Path=CanEditArtwork, Converter={StaticResource BooleanVisibilityConverter}}"
                                        Command="{Binding Path=CommandEditArtwork}" />
                            </StackPanel>                            
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
            
        </DataGrid>
       
    </Grid>
</UserControl>

 

]]>
WPF C# DataGrid Column Sort http://thelazydeveloper.com.au/?p=113 Tue, 16 Oct 2018 04:43:05 +0000 http://thelazydeveloper.com.au/?p=113

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using System.Windows.Controls.Primitives;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.ComponentModel;

namespace APS.Synergy.Client.Framework.Infrastructure.DataGridExtender
{
    public class DataGridExtender : DataGrid
    {
        public DataGridExtender()
        {
            this.ColumnReordered += DataGridControl_ColumnReordered;
            
            //Cannot use layoutupdated for saving as it will save before datagrid is loaded
            //this.LayoutUpdated += DataGridControl_LayoutUpdated;
            //this.AutoGeneratedColumns += DataGridControl_AutoGenerateColumns;
            this.Loaded += DataGridControl_Loaded;
        }

        private void DataGridControl_Loaded(object sender, RoutedEventArgs e)
        {
            var lcolumnList = ReadColumnsFromDisk();

            try
            {
                if (lcolumnList != null && lcolumnList.Count > 0)
                {

                    foreach (var column in lcolumnList)
                    {

                        //var litem = lcolumnList.FirstOrDefault(x => x.Header == GetColumnIdentifier(column));
                        var litem = this.Columns.FirstOrDefault(x => GetColumnIdentifier(x).Equals(column.Header));
                        if (column.ColumnWidth > 0)
                        {
                            litem.Width = new DataGridLength(column.ColumnWidth, DataGridLengthUnitType.Pixel);
                        }
                            
                        if (litem != null)
                        {
                            //find display index and put it at the end. Let datagridcolum sort do its thing and itll push up all the way to missing columndisplayindex
                            //Need to do it this way otherwise if the displayindex exists in another item it does weird stuff
                            this.Columns.FirstOrDefault(x => x.DisplayIndex == litem.DisplayIndex).DisplayIndex = this.Columns.Count - 1;
                            
                        }
                    }
                }


                //Column resize event doesnt exist so need to set one
                PropertyDescriptor pd = DependencyPropertyDescriptor.FromProperty(DataGridColumn.ActualWidthProperty, typeof(DataGridColumn));

                //add event to each column
                foreach (DataGridColumn column in this.Columns)
                {
                    //Add a listener for this column's width
                    pd.AddValueChanged(column, new EventHandler(ColumnWidthPropertyChanged));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("DATAGRIDEXTENDER: [Loaded] Error reloading the column layout for grid {0}: {1}", (String.IsNullOrWhiteSpace(this.ControlName) ? this.ControlName : this.DataContext.ToString()), ex.GetBaseException().Message));
                Debug.WriteLine(ex.ToString());
            }
        }

        public static readonly DependencyProperty ControlNameProperty = DependencyProperty.Register("ControlName", typeof(string), typeof(DataGridExtender));

        public string ControlName
        {
            get
            {
                return System.Convert.ToString(GetValue(ControlNameProperty));
            }
            set
            {
                SetValue(ControlNameProperty, value);
            }
        }

        private void DataGridControl_Unloaded(object sender, RoutedEventArgs e)
        {
            SaveColumnLayout();
        }

        private void DataGridControl_AutoGenerateColumns(object sender, EventArgs e)
        {
            var lcolumnList = ReadColumnsFromDisk();

            try
            {
                if (lcolumnList != null && lcolumnList.Count > 0)
                {
                    foreach (var column in this.Columns)
                    {
                        var litem = lcolumnList.FirstOrDefault(x => x.Header.Replace(" ", "") == GetColumnIdentifier(column).Replace(" ", ""));
                        if (litem != null)
                        {
                            column.DisplayIndex = litem.DisplayIndex;
                            column.Width = (litem.ColumnWidth > 0) ? new DataGridLength(litem.ColumnWidth) : Double.NaN;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("DATAGRIDEXTENDER: [AutoGenerateColumns] Error reloading the column layout for grid {0}: {1}", (String.IsNullOrWhiteSpace(this.ControlName) ? this.ControlName : this.DataContext.ToString()), ex.GetBaseException().Message));
                Debug.WriteLine(ex.ToString());
            }

        }

        private string GetColumnIdentifier(DataGridColumn column)
        {
            // If the column has am x:Name set, then use that is the 
            // identifer, otherwise try the header, otherwise make something up
            if (column is DataGridTextColumnExtender && !String.IsNullOrWhiteSpace(((DataGridTextColumnExtender)column).ColumnName))
            {
                return ((DataGridTextColumnExtender)column).ColumnName;
            }
            if (column is DataGridTemplateColumnExtender && !String.IsNullOrWhiteSpace(((DataGridTemplateColumnExtender)column).ColumnName))
            {
                return ((DataGridTemplateColumnExtender)column).ColumnName;
            }
            if (column is DataGridCheckBoxColumnExtender && !String.IsNullOrWhiteSpace(((DataGridCheckBoxColumnExtender)column).ColumnName))
            {
                return ((DataGridCheckBoxColumnExtender)column).ColumnName;
            }
            if (column is DataGridComboBoxColumnExtender && !String.IsNullOrWhiteSpace(((DataGridComboBoxColumnExtender)column).ColumnName))
            {
                return ((DataGridComboBoxColumnExtender)column).ColumnName;
            }
            if (column is DataGridHyperlinkColumnExtender && !String.IsNullOrWhiteSpace(((DataGridHyperlinkColumnExtender)column).ColumnName))
            {
                return ((DataGridHyperlinkColumnExtender)column).ColumnName;
            }

            if (column.Header != null && !String.IsNullOrWhiteSpace(column.Header.ToString()))
            {
                return column.Header.ToString();
            }
            return "column_" + this.Columns.IndexOf(column);

            // Everything has failed so we need to try and use something else
        }

        private void DataGridControl_ColumnReordered(object sender, DataGridColumnEventArgs e)
        {
            SaveColumnLayout();
        }

        private void DataGridControl_LayoutUpdated(object sender, EventArgs e)
        {
            SaveColumnLayout();
        }

        private void SaveColumnLayout()
        {
            List<ColumnItem> lColumnList = new List<ColumnItem>();
            ColumnItem lColumnItem;
            foreach (var column in this.Columns)
            {
                lColumnItem = new ColumnItem() { DisplayIndex = column.DisplayIndex, Header = GetColumnIdentifier(column), ColumnWidth = column.Width.DesiredValue };
                lColumnList.Add(lColumnItem);
            }
            lColumnList = lColumnList.OrderBy(x => x.DisplayIndex).ToList();
            WriteColumnsToDisk(lColumnList);
        }

        private void WriteColumnsToDisk(List<ColumnItem> columnList)
        {
            string file = string.Empty;
            try
            {
                file = GetDataGridFileName();
                var path = System.IO.Path.GetDirectoryName(file);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                var contents = Newtonsoft.Json.JsonConvert.SerializeObject(columnList);
                System.IO.File.WriteAllText(GetDataGridFileName(), contents);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to save datagrid columns to {0} : {1}", file, ex.GetBaseException().Message);
                Debug.WriteLine(ex.ToString());
            }
        }

        private List<ColumnItem> ReadColumnsFromDisk()
        {
            string file = string.Empty;
            try
            {
                file = GetDataGridFileName();
                if (System.IO.File.Exists(file))
                {
                    var contents = System.IO.File.ReadAllText(file);
                    if (!string.IsNullOrWhiteSpace(contents))
                    {
                        List<ColumnItem> columnList;
                        columnList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ColumnItem>>(contents);
                        return columnList;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to read datagrid columns to {0} : {1}", file, ex.GetBaseException().Message);
                Debug.WriteLine(ex.ToString());
            }
            return null;
        }

        private string GetDataGridFileName()
        {
            if (String.IsNullOrEmpty(this.ControlName))
            {
                return System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "APS", "Synergy3", "Client", "Settings", this.DataContext.ToString() + "_datagrid.json");
            }
            return System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "APS", "Synergy3", "Client", "Settings", this.ControlName + "_datagrid.json");
        }


        //column width change for mouse click stuff
        private bool _columnWidthChanging;
        private void ColumnWidthPropertyChanged(object sender, EventArgs e)
        {
            // listen for when the mouse is released
            _columnWidthChanging = true;
            if (sender != null)
                Mouse.AddPreviewMouseUpHandler(this, BaseDataGrid_MouseLeftButtonUp);
        }

        void BaseDataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (_columnWidthChanging)
            {
                _columnWidthChanging = false;

                SaveColumnLayout();

            }
        }
    }

    public class ColumnItem
    {
        public int DisplayIndex { get; set; }
        public string Header { get; set; }
        public double ColumnWidth { get; set; }
    }

    public class DataGridTextColumnExtender : DataGridTextColumn
    {

        public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.Register("ColumnName", typeof(string), typeof(DataGridTextColumnExtender));

        public string ColumnName
        {
            get
            {
                return System.Convert.ToString(GetValue(ColumnNameProperty));
            }
            set
            {
                SetValue(ColumnNameProperty, value);
            }
        }
    }

    public class DataGridTemplateColumnExtender : DataGridTemplateColumn
    {
        public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.Register("ColumnName", typeof(string), typeof(DataGridTemplateColumnExtender));

        public string ColumnName
        {
            get
            {
                return System.Convert.ToString(GetValue(ColumnNameProperty));
            }
            set
            {
                SetValue(ColumnNameProperty, value);
            }
        }
    }

    public class DataGridComboBoxColumnExtender : DataGridComboBoxColumn
    {
        public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.Register("ColumnName", typeof(string), typeof(DataGridComboBoxColumnExtender));

        public string ColumnName
        {
            get
            {
                return System.Convert.ToString(GetValue(ColumnNameProperty));
            }
            set
            {
                SetValue(ColumnNameProperty, value);
            }
        }
    }

    public class DataGridCheckBoxColumnExtender : DataGridCheckBoxColumn
    {
        public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.Register("ColumnName", typeof(string), typeof(DataGridCheckBoxColumnExtender));

        public string ColumnName
        {
            get
            {
                return System.Convert.ToString(GetValue(ColumnNameProperty));
            }
            set
            {
                SetValue(ColumnNameProperty, value);
            }
        }
    }

    public class DataGridHyperlinkColumnExtender : DataGridHyperlinkColumn
    {
        public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.Register("ColumnName", typeof(string), typeof(DataGridHyperlinkColumnExtender));

        public string ColumnName
        {
            get
            {
                return System.Convert.ToString(GetValue(ColumnNameProperty));
            }
            set
            {
                SetValue(ColumnNameProperty, value);
            }
        }
    }

}

 

]]>
Create new vue js with task Runner Razor MVC http://thelazydeveloper.com.au/?p=107 Tue, 09 Oct 2018 05:32:40 +0000 http://thelazydeveloper.com.au/?p=107 Create new Project.

In the root of the project create the following files:
– webpack.config.js
– package.json

package.json (replace the default values within <<>>)

{
  "name": "<>",
  "description": "<>",
  "version": "<>",
  "author": "<>",
  "license": "MIT",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
  },
  "dependencies": {
    "vue": "^2.5.11"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ],
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-env": "^1.6.0",
    "babel-preset-stage-3": "^6.24.1",
    "cross-env": "^5.0.5",
    "css-loader": "^0.28.7",
    "file-loader": "^1.1.4",
    "vue-loader": "^13.0.5",
    "vue-template-compiler": "^2.4.4",
    "webpack": "^3.6.0",
    "webpack-dev-server": "^2.9.1"
  }
}

webpack.config.js

/// <binding BeforeBuild='Run - Development' />
"use strict";
var path = require('path');
var webpack = require('webpack');
var fs = require('fs');
var projectRoot = path.resolve(__dirname)


module.exports = {
  entry: () => {

    const ENTRYCONTAINER = "./Scripts/Views";

    function getFiles(startPath) {

      var results = [];

      if (!fs.existsSync(startPath)) {
        console.log("no dir ", startPath);
        return;
      }

      var files = fs.readdirSync(startPath);
      for (var i = 0; i < files.length; i++) {
        var filename = path.join(startPath, files[i]);
        var stat = fs.lstatSync(filename);
        if (stat.isDirectory()) {
          results = results.concat(getFiles(filename))
        }
        else if (filename.indexOf('.js') >= 0 && filename.indexOf('.dist.') == -1) {
          results.push(filename);
        }
      }
      return results;
    };

    var entryPoints = {};

    getFiles(ENTRYCONTAINER).forEach(function (file) {

      entryPoints[file.replace('.js', '')] = './' + file;

    });

    return entryPoints;
  },
  output: {
    path: path.resolve(__dirname, './'),
    filename: "[name].dist.js"
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
            // the "scss" and "sass" values for the lang attribute to the right configs here.
            // other preprocessors should work out of the box, no loader config like this nessessary.
            'scss': 'vue-style-loader!css-loader!sass-loader',
            'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.common.js'
    }
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}

Open cmd and in the directory where package.json file is located. Run the following npm install

Add the following in the _layout.vbhtml file.

'At the top
@Code

  Dim controller = HttpContext.Current.Request.RequestContext.RouteData.Values("Controller").ToString
  Dim action = HttpContext.Current.Request.RequestContext.RouteData.Values("Action").ToString
  Dim hasPageScript = System.IO.File.Exists(Server.MapPath("~/Scripts/Views/" + controller + "/" + action + ".dist.js"))

End Code


'Under the @Scripts.Render... section
@If hasPageScript Then
    @RenderSection("serverdata", required:=False)
    @<script src="~/Scripts/Views/@(controller)/@(action).dist.js"></script>
End If

Now in visual studio Select ‘View’ -> ‘Other Windows’ -> ‘Task Runner Explorer’. Just run the ‘Run – Development’ task. Can even build while project is running.

]]>
Clear sql buffer and cache http://thelazydeveloper.com.au/?p=102 Tue, 19 Jun 2018 02:01:58 +0000 http://thelazydeveloper.com.au/?p=102

DBCC FREESYSTEMCACHE ('userdatabase') -- cleans cache for specific user database
DBCC FREESYSTEMCACHE ('tempdb')  -- clears cache for tempdb
DBCC FREESYSTEMCACHE ('Temporary Tables & Table Variables')
Go
DBCC FLUSHPROCINDB (8) -- 8 is the databaseid of Dec_ProdStats
GO
-- Clean all the caches with entries specific to the resource pool named "default".  
DBCC FREESYSTEMCACHE ('ALL', default);

--MARK_IN_USE_FOR_REMOVAL clause to release entries from all current caches once the entries become unused.
DBCC FREESYSTEMCACHE ('ALL') WITH MARK_IN_USE_FOR_REMOVAL;  

--Suppresses all informational messages.
DBCC FREEPROCCACHE with NO_INFOMSGS

DBCC DROPCLEANBUFFERS --clears clean (unmodified) pages from the buffer pool
Precede that with a CHECKPOINT to flush any dirty pages to disk first
DBCC FLUSHPROCINDB --clears execution plans for that database

]]>
Numbers Table http://thelazydeveloper.com.au/?p=98 Mon, 26 Feb 2018 03:50:25 +0000 http://thelazydeveloper.com.au/?p=98

select * from master..spt_values 
where type ='P'
order by number


--Great for adding dates ie. Adding all Wednesdays between two dates
DECLARE @Date1 DATE, @Date2 DATE
SET @Date1 = '20190131'
SET @Date2 = '20200105'

SELECT 
--Change date to isodate
Convert(varchar, DATEADD(DAY,number+1,@Date1), 112) [Date]
FROM master..spt_values
WHERE type = 'P'
and Datename(dw, Cast(Cast(DATEADD(DAY,number+1,@Date1) as varchar) as datetime)) = 'Wednesday'
AND DATEADD(DAY,number+1,@Date1) < @Date2

]]>
Reference parent datacontext binding. http://thelazydeveloper.com.au/?p=94 Thu, 01 Feb 2018 04:55:57 +0000 http://thelazydeveloper.com.au/?p=94

<Button Content="Reload Reports"
                       Grid.Row="2"
                        Grid.Column="1"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Right"
                        Command="{Binding Path=CommandReloadReports,RelativeSource={RelativeSource TemplatedParent}}" />

]]>