Friday, February 10, 2017

How to tell Visual Studio to copy the complete folder and sub folder/files to the output directory?

First add your folder(This is my folder: XULRunner21_0) to your project with all the items added to your project, and then go to your project's Properties>Build Events and write the following command line into Post-build event command line area. 

After building the solution, you should see under bin folder of your project, XULRunner21_0 folder will be created with all the items in it.
That is all, hope it help.

PS: While publishing, if we need to copy some folders into the bin folder, we need to follow this documentation and use target events for publishing.


xcopy /E /Y "$(ProjectDir)XULRunner21_0\*" "$(ProjectDir)$(OutDir)XULRunner21_0\"

Monday, January 30, 2017

SQL to Find Umbraco Nodes using a Certain Umbraco Document Type

In order to get the Umbraco nodes which use a certain umbraco Document Type, you can use the following SQL script. You can then simply login to umbraco backoffice and search for the nodeId value in there and find the node that you want.

SELECT * FROM cmsContent C
INNER JOIN cmsContentType CT ON C.contentType = CT.nodeId
INNER JOIN umbracoNode N ON C.nodeId = N.id
WHERE CT.alias = 'YourDocumentTypeAlias'

Tuesday, January 24, 2017

Upgrading from Umbraco Contour to Umbraco Forms: Fix for Could not load type 'Umbraco.Forms.Core.Services.RecordService' from assembly 'Umbraco.Forms.Core, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.

If your Umbraco website is already using Umbraco Contour and if you want to upgrade to Umbraco Forms then you might experience "Could not load type 'Umbraco.Forms.Core.Services.RecordService' from assembly 'Umbraco.Forms.Core, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'." while installing Umbraco Forms.

Please go to this Umbraco Forums url to see how I fixed my problem.

After installing the Umbraco Forms successfully, then you might want to remove Contour items from the Macro Dropdown List. To do that simply go to /Developer/Macros section and delete the Contour items.


That is all, hope this post helps.


















Monday, January 23, 2017

Tracking MS SQL CPU Usage

--T-SQL to identify the Top 20 most costly queries in terms of Total CPU:
SELECT TOP 20
    st.dbid,
    DB_NAME(st.dbid) AS Database_Name,
    qs.sql_handle,
    qs.execution_count,
    qs.total_worker_time AS Total_CPU,
    total_CPU_inSeconds = --Converted from microseconds
    qs.total_worker_time/1000000,
    average_CPU_inSeconds = --Converted from microseconds
    (qs.total_worker_time/1000000) / qs.execution_count,
    qs.total_elapsed_time,
    total_elapsed_time_inSeconds = --Converted from microseconds
    qs.total_elapsed_time/1000000,
    st.text,
    qp.query_plan
FROM
    sys.dm_exec_query_stats AS qs
        CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
        CROSS apply sys.dm_exec_query_plan (qs.plan_handle) AS qp
ORDER BY qs.total_worker_time DESC

--This shows the number of connections per each DB:
SELECT
    DB_NAME(dbid) as DBName,
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE
    dbid > 0
GROUP BY
    dbid, loginame

--And this gives the total:
SELECT
    COUNT(dbid) as TotalConnections
FROM
    sys.sysprocesses
WHERE

    dbid > 0

Thursday, December 15, 2016

Xamarin.Forms CarouselView

Xamarin.Forms has a nice control called CarouselView and it is very easy to add it to your Xamarin project. Below you can see the basic steps you need to follow in order to add it to your Xamarin project.
  • Install CarouselView Nuget package to your all projects (PCL, Android, iOS and Windows)
  • As the CarouselView is in a separate assembly, add CarouselView's namespace in root of your Xaml page and use it in your page like this;
 <?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XYZ.Mobile.App.Controls.ValidationControls.Confirmation"
             xmlns:valueconverters="clr-namespace:XYZ.Mobile.App.ValueConverters"
             xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView">

  <StackLayout Grid.Row="1"
                 Orientation="Vertical">

      <cv:CarouselView x:Name="ConfirmationQuestionsCarousel"
                       ItemsSource="{Binding ConfirmationQuestions}">
        <cv:CarouselView.ItemTemplate>
          <DataTemplate>
          <!--You can now add other Xamarin controls in to your CarouselView-->
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition/>
                <RowDefinition Height="50"/>
              </Grid.RowDefinitions>

              <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
              </Grid.ColumnDefinitions>

              <Label Grid.Row="0"
                     Grid.ColumnSpan="2"
                     Text="SOME TEXT"
                     FontAttributes="Bold" />
              <Label Grid.Row="1"
                     Grid.ColumnSpan="2"
                     Text="{Binding Question}"/>

              <Button Grid.Row="2"
                      Grid.Column="0"
                      Text="No"
                      StyleId="No"
                      CommandParameter="false"
                      Command="{Binding ToggleAgree}"
                      Clicked="OnQuestionAnswered"
                      BackgroundColor="{Binding Agreed, Converter={StaticResource BoolToToggleButtonColorConverter}, ConverterParameter='Invert'}"/>
              <Button Grid.Row="2"
                      Grid.Column="1"
                      Text="Yes"
                      StyleId="Yes"
                      CommandParameter="true"
                      Command="{Binding ToggleAgree}"
                      Clicked="OnQuestionAnswered"
                      BackgroundColor="{Binding Agreed, Converter={StaticResource BoolToToggleButtonColorConverter}}"/>

            </Grid>
          </DataTemplate>
        </cv:CarouselView.ItemTemplate>
      </cv:CarouselView>
    </StackLayout>
</ContentView>
  • When I used Xamarin.Forms's CarouselView for the first time, I experienced some problems while getting the Count of the CarouselView item. I needed this count information in order to swipe to the next item correctly. Whenever I tried to get the ConfirmationQuestionsCarousel.Count info, I got "Unknown Member" error, so I eventually used the following code in order to get the count information.
         private void OnQuestionAnswered(object sender, EventArgs args)
        {
            var buttonClicked = sender as Button;
            var buttonClickedAnswer = buttonClicked.StyleId;
            
            // Ugly way to get the count
            //var s = new List<object>(ConfirmationQuestionsCarousel.ItemsSource.Cast<object>()).Count;
            // Better way to get the count
            int count = 0;

            foreach (var item in ConfirmationQuestionsCarousel.ItemsSource)
            {
                count++;
            }

            // This is to set the Carosel's Position - this is unfinished code, I put it here only as an example
            ConfirmationQuestionsCarousel.Position = 3;
        }
  • That is all, happy coding.

Monday, December 5, 2016

IIS Binding Fix for “The certificate associated with this binding is also assigned to another site’s binding. Deleting this binding will cause the HTTPS binding of another site to be unstable. Do you still want to continue?”

If you add a binding to your website in the IIS interface and then try to remove that binding by using the interface again, you might see the following error message that says;

The certificate associated with this binding is also assigned to another site’s binding. Deleting this binding will cause the HTTPS binding of another site to be unstable. Do you still want to continue?”

In order to fix this; follow the steps below otherwise you might end up in a big trouble;

  1. Go to C:\Windows\System32\inetsrv\config and find applicationHost.config. Save a copy of this file before making any changes.
  2. Open it using Notepad - I normally use Notepad++ but this time I had to use Notepad in order to make this work.
  3. Search for website's name in the file until you find your web site's bindings. Simply delete the binding that you no longer need and then save the file.
  4. You might need an iisreset at this point but first re-open the IIS interface and check your website's bindings. You will see that you don't have that binding anymore.
That is all. Happy coding.

Thursday, August 11, 2016

Umbraco Advanced Publishing Shortcut

To get the umbraco site cache in order, we can refresh the node XML by just typing the following url and then click on "republish" on the screen.

After doing this, the website cache will be refreshed. All the published content will be updated, while unpublished content will stay unpublished.

http://YOURWEBSITEDOMAIN/Umbraco/dialogs/republish.aspx?xml=true