Joseph Michael Pesch
VP Programming

xCode Support for IOS Device

by 24. November 2018 06:47

Trying to run xCode against connected iPhone and receive error message below:

Could not locate device support files. This iPhone 6s Plus is running iOS 12.0.1 (16A404), which may not be supported by this version of Xcode.

 

Download latest xCode from developer.apple.com (as .xip file), extract the .app file

Right click on latest xCode .app and select "Show Package Contents" and navigate to:

/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

Select the required version(s) and copy to:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

Tags:

XCode

xCode Facebook Login Integration Using CocoaPods

by 18. November 2018 09:26

Terminal window, navigated to root folder where xCode project exists and run the following commands:

  • $ sudo gem install cocoapods
  • $ pod init

This will create a file named Podfile in your project's root directory. Open the Podfile with a text editor and add the following:

  • pod 'FBSDKLoginKit'

Back in the Terminal window, run the following command:

  • $ pod install 

Register app with Facebook (follow steps in this link: https://developers.facebook.com/docs/facebook-login/ios/)

Configure the information property list file (info.plist) with an XML snippet that contains data about your app. Right-click info.plist, and choose Open As Source Code. Copy and paste the following XML snippet into the body of your file ( ...)

<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fb[APP_ID]</string>
  </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>

To use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, your application's info.plist also needs to include:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>

Go to the Project Navigator in Xcode and select your project to see project settings. Select Other Linker Flags for editing. Add the flag -ObjC to Other Linker Flags for all build targets. NOTE: Use the find feature to easily locate the Other Linker Flags in the settins area.

If you still have the xCode project open close it. Open the new Workspace that should have been created in the same root folder as the project (e.g. MyApp.xcodeproj should now have a MyApp.xcworkspace partner).

Update the applications AppDelegate method to include the FBSDKLoginKit import reference and methods with FBSDKApplicationDelegate and FBSDKAppEvents (sample shown below).

import UIKit
import FBSDKLoginKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        // FaceBook
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.

        // FaceBook
        FBSDKAppEvents.activateApp()
    }
    
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    }


    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

Build Project for Running to make sure everything compiles correctly.

 

Tags:

Facebook | XCode

Hosted Site Issues with Roslyn - This program is blocked by group policy. For more information, contact your system administrator

by 9. September 2018 12:24
NOTE: Had to remove package: Microsoft.CodeDom.Providers.DotNetCompilerPlatform
      Due to hosting limitation, throwing this error:
      This program is blocked by group policy. For more information, contact your system administrator
      Cannot execute a program. The command being executed was 
          "C:\InetPub\...\bin\roslyn\csc.exe" 
              /shared /keepalive:"10" /noconfig  
              /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\bd40b76f\3452b533\33n50imf.cmdline"
       
NOTE: See nuget url for package details:
      https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform
       
NOTE: Some of the new C# 6.0 language features if used in Views (MVC project) will not compile. 
      Many of my views use the ? null checking operator for accessing Model properties.  
      All of these views now return errors on my Godaddy hosted MVC 5 application.
      This error occurs because Views (by default) are compiled at runtime using the .NET pipeline (not pre-compiled).
      To resolve this issue, simply uncheck the "Allow precompiled site to be updatable" option in your publish profile settings.  
      This should pre-compile your views and allow your C# 6.0 (Latest version of Roslyn Compiler) to run like a champ.

Tags:

MVC

Angular 2 Compile Warning "Critical dependency: the request of a dependency is an expression"

by 28. February 2018 15:11

When compiling Angular 2 application I received compile warning "Critical dependency: the request of a dependency is an expression" when using the require() method with a variable vs. literal string value (see examples below).

 

This throws compile warning:

let path = 'path_to_item';

let item = require(path);

 

This does not throw compile warning:

let item = require('path_to_item');

 

Tags:

Angular

Angular Component StyleUrls Not Working

by 16. February 2018 15:08

Issue with component level styles not working, import "ViewEncapsulation: from @angular/core and add encapsulation: ViewEncapsoulation.None to the @Component decorator as shown below.

import { Component, OnInit, ViewEncapsulation } from '@angular/core';

@Component({

    selector: 'app-demo',

    templateUrl: './demo.component.html',

    styleUrls: ['./demo.component.css'],

    encapsulation: ViewEncapsulation.None

})

Tags:

Angular | JavaScript | TypeScript

JavaScript/TypeScript JSON Navigate by Dotted String Path

by 16. February 2018 15:00

Navigate a JSON object by a dotted string path (e.g. "somePath.subPath.anotherSubPath").

console.log('somePath.subPath.anotherSubPath'.split('.').reduce((o, i) => o[i], jsonObject));

Tags:

Angular | JavaScript | TypeScript

JavaScript/TypeScript Dotted String to Upper/Lower First Letter

by 16. February 2018 14:56

Take a dotted string (e.g. "someThing.someThingElse.another") and convert first letter of each dotted component to upper or lower case.

    dottedToUpper(str) {
        str = str.replace(/\./g, ' ');
        str = str.replace(/\w\S*/g, function (txt) {
            return txt.charAt(0).toUpperCase() + txt.substr(1);
        });
        return str.replace(/ /g, '.');
    }
    dottedToLower(str) {
        str = str.replace(/\./g, ' ');
        str = str.replace(/\w\S*/g, function (txt) {
            return txt.charAt(0).toLowerCase() + txt.substr(1);
        });
        return str.replace(/ /g, '.');
    }
 

Tags:

Angular | JavaScript | TypeScript

C# Name Tuple Items

by 1. February 2018 14:29

To name tuple items in C#, first install the NuGet package: Install-Package System.ValueTuple

Syntax: (string ItemName, DateTime ItemName, etc.) vs. Tuple<string, DateTime>

Tags:

ASP.Net | C#

Debug Windows Service Running as Interactive Console Application

by 1. February 2018 08:40

Before running in Visual Studio change the project output type from Windows Application to Console Application.  Below is sample Program.cs code to run interactively in Visual Studio.

using System;
using System.Reflection;
using System.ServiceProcess;
using System.Threading;

namespace DemoWindowsService
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            ServiceBase[] servicesToRun;
            servicesToRun = new ServiceBase[]
            {
                new DemoService()
            };
            if (Environment.UserInteractive) RunInteractive(servicesToRun);
            else ServiceBase.Run(servicesToRun);
        }

        static void RunInteractive(ServiceBase[] servicesToRun)
        {
            Console.WriteLine("Services running in interactive mode.");
            Console.WriteLine();

            MethodInfo onStartMethod = typeof(ServiceBase).GetMethod("OnStart",
                BindingFlags.Instance | BindingFlags.NonPublic);
            foreach (ServiceBase service in servicesToRun)
            {
                Console.Write("Starting {0}...", service.ServiceName);
                onStartMethod.Invoke(service, new object[] { new string[] { } });
                Console.Write("Started");
            }

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(
                "Press any key to stop the services and end the process...");
            Console.ReadKey();
            Console.WriteLine();

            MethodInfo onStopMethod = typeof(ServiceBase).GetMethod("OnStop",
                BindingFlags.Instance | BindingFlags.NonPublic);
            foreach (ServiceBase service in servicesToRun)
            {
                Console.Write("Stopping {0}...", service.ServiceName);
                onStopMethod.Invoke(service, null);
                Console.WriteLine("Stopped");
            }

            Console.WriteLine("All services stopped.");
            // Keep the console alive for a few seconds to allow the user to see the message.
            Thread.Sleep(5000);
        }
    }
}

Tags:

ASP.Net | C# | Windows Service

Mac OS Mount Windows or NAS File Share Path Using SMB/CIFS

by 11. November 2017 10:58

To mount a Windows or NAS file share path you can use either SMB or CIFS.  If you have issues using SMB try using CIFS as some versions of Mac OS have issues with SMB but work fine with CIFS.  Open the Finder window and press CMD+K to open the "Connect to Server" window.  Enter the file share path as either smb://... or cifs://...

Tags:

xCode Custom Icons - Tab Bar Item - System Item Custom - Bar Item Image

by 14. October 2017 09:56

The steps below are for creating an app icon fro an xCode/Swift iOS application.  The xCode steps are specifically for setting a custom icon on a tab of a  tabbed application.  

I use Gimp for image editing and follow these steps to create the icon:

  1. Import (or create) the image you want to use as the tab bar icon. NOTE: For importing an existing image it's best to use a black and white image so that you don't have to remove colors. Also, for your starting image it's best to have 75x75 pixel image (or larger) as the large image, then it can easily be scaled down to medium (50x50) and standard (25x25).
  2. Set the background to 'Transparent' rather than white.
  3. Remove all white from the image so that it was just a black image with a transparent background.
  4. Resize the image to be a square with dimensions 75x75 pixels, export/save as .png file format and name imageName@3x.png
  5. Resize the image to be a square with dimensions 50x50 pixels, export/save as .png file format and name imageName@2x.png
  6. Resize the image to be a square with dimensions 25x25 pixels, export/save as .png file format and name imageName.png

In xCode I perform the following steps:

  1. Drag the images into xCode project.
  2. Highlight select the images in xCode project, right-click and select 'New Group from Selection', name the image group iconImageName.
  3. Select the desired tab on the storyboard view.
  4. From the properties, set the 'Tab Bar Item' => 'System Item' = 'Custom'.
  5. From the properties, set the 'Bar Item' => 'Image' = 'imageName.png'
  6. NOTE: Do not set the 'Selected Image' under the 'Tab Bar Item' (leave this blank).

Tags:

XCode

Angular 4 with Bootstrap using CLI

by 21. July 2017 11:20

Angular 4 with Bootstrap using CLI

    ng new ...
    npm install --save @types/jquery
    npm install --save @types/bootstrap
    add to index.html (head tag):
        <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
        <script src="node_modules/jquery/dist/jquery.min.js "></script>
        <script src="node_modules/bootstrap/dist/js/bootstrap.js "></script>
        
TypeScript Guid class:        
class Guid {
    static newGuid() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
            var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
            return v.toString(16);
        });
    }
}

Tags:

SQL Table Valued Function to Parse JSON

by 18. May 2017 11:58

 

 

CREATE FUNCTION [dbo].[parseJSON]( @JSON NVARCHAR(MAX))

RETURNS @hierarchy TABLE
  (
   element_id INT IDENTITY(1, 1) NOT NULL,/* internal surrogate primary key gives the order of parsing and the list order */
   sequenceNo [int] NULL, /* the place in the sequence for the element */
   parent_ID INT,/* if the element has a parent then it is in this column. The document is the ultimate parent, so you can get the structure from recursing from the document */
   Object_ID INT,/* each list or object has an object id. This ties all elements to a parent. Lists are treated as objects here */
   NAME NVARCHAR(2000),/* the name of the object */
   StringValue NVARCHAR(MAX)NOT NULL,/*the string representation of the value of the element. */
   ValueType VARCHAR(10) NOT null/* the declared type of the value represented as a string in StringValue*/
  )
AS
BEGIN
  DECLARE
    @FirstObject INT, --the index of the first open bracket found in the JSON string
    @OpenDelimiter INT,--the index of the next open bracket found in the JSON string
    @NextOpenDelimiter INT,--the index of subsequent open bracket found in the JSON string
    @NextCloseDelimiter INT,--the index of subsequent close bracket found in the JSON string
    @Type NVARCHAR(10),--whether it denotes an object or an array
    @NextCloseDelimiterChar CHAR(1),--either a '}' or a ']'
    @Contents NVARCHAR(MAX),--the unparsed contents of the bracketed expression
    @Start INT, --index of the start of the token that you are parsing
    @end INT,--index of the end of the token that you are parsing
    @param INT,--the parameter at the end of the next Object/Array token
    @EndOfName INT,--the index of the start of the parameter at end of Object/Array token
    @token NVARCHAR(500),--either a string or object -- slayne 7/10/14: increased from 200 to 500
    @value NVARCHAR(MAX),-- the value as a string
    @SequenceNo int, -- the sequence number within a list
    @name NVARCHAR(200),--the name as a string
    @parent_ID INT,--the next parent ID to allocate
    @lenJSON INT,--the current length of the JSON String
    @characters NCHAR(36),--used to convert hex to decimal
    @result BIGINT,--the value of the hex symbol being parsed
    @index SMALLINT,--used for parsing the hex value
    @Escape INT --the index of the next escape character
  DECLARE @Strings TABLE /* in this temporary table we keep all strings, even the names of the elements, since they are 'escaped' in a different way, and may contain, unescaped, brackets denoting objects or lists. These are replaced in the JSON string by tokens representing the string */
    (
     String_ID INT IDENTITY(1, 1),
     StringValue NVARCHAR(MAX)
    )
  SELECT--initialise the characters to convert hex to ascii
    @characters='0123456789abcdefghijklmnopqrstuvwxyz',
    @SequenceNo=0,--set the sequence no. to something sensible.
  /* firstly we process all strings. This is done because [{} and ] aren't escaped in strings, which complicates an iterative parse. */
    @parent_ID=0;
  WHILE 1=1 --forever until there is nothing more to do
    BEGIN
      SELECT
        @start=PATINDEX('%[^a-zA-Z]["]%', @json collate SQL_Latin1_General_CP850_Bin);--next delimited string
      IF @start=0 BREAK--no more so drop through the WHILE loop
      IF SUBSTRING(@json, @start+1, 1)='"'
        BEGIN --Delimited Name
          SET @start=@Start+1;
          SET @end=PATINDEX('%[^\]["]%',RIGHT(@json, LEN(@json+'|')-@start)collate SQL_Latin1_General_CP850_Bin);
        END
      IF @end=0 --no end delimiter to last string
        BREAK --no more
      SELECT @token=SUBSTRING(@json, @start+1, @end-1)
      --now put in the escaped control characters
      SELECT @token=REPLACE(@token, FROMString, TOString)
      FROM
        (SELECT
          '\"' AS FromString,'"' AS ToString
         UNION ALL SELECT'\\', '\'
         UNION ALL SELECT'\/', '/'
         UNION ALL SELECT'\b', CHAR(08)
         UNION ALL SELECT'\f', CHAR(12)
         UNION ALL SELECT'\n', CHAR(10)
         UNION ALL SELECT'\r', CHAR(13)
         UNION ALL SELECT'\t', CHAR(09)
        ) substitutions
      SELECT @result=0, @escape=1
  --Begin to take out any hex escape codes
      WHILE @escape>0
        BEGIN
          SELECT @index=0,
          --find the next hex escape sequence
          @escape=PATINDEX('%\x[0-9a-f][0-9a-f][0-9a-f][0-9a-f]%', @token collate SQL_Latin1_General_CP850_Bin)
          IF @escape>0 --if there is one
            BEGIN
              WHILE @index<4 --there are always four digits to a \x sequence   
                BEGIN 
                  SELECT --determine its value
                    @result=@result+POWER(16, @index)
                    *(CHARINDEX(SUBSTRING(@token, @escape+2+3-@index, 1),
                                @characters)-1), @index=@index+1 ;
                END
                -- and replace the hex sequence by its unicode value
              SELECT @token=STUFF(@token, @escape, 6, NCHAR(@result))
            END
        END
      --now store the string away 
      INSERT INTO @Strings (StringValue) SELECT @token
      -- and replace the string with a token
      SELECT @JSON=STUFF(@json, @start, @end+1,
                    '@string'+CONVERT(NVARCHAR(5),@@identity))
    END
  -- all strings are now removed. Now we find the first leaf.  
  WHILE 1=1  --forever until there is nothing more to do
  BEGIN
  SELECT @parent_ID=@parent_ID+1
  --find the first object or list by looking for the open bracket
  SELECT @FirstObject=PATINDEX('%[{[[]%', @json collate SQL_Latin1_General_CP850_Bin)--object or array
  IF @FirstObject = 0 BREAK
  IF (SUBSTRING(@json, @FirstObject, 1)='{')
    SELECT @NextCloseDelimiterChar='}', @type='object'
  ELSE
    SELECT @NextCloseDelimiterChar=']', @type='array'
  SELECT @OpenDelimiter=@firstObject
  WHILE 1=1 --find the innermost object or list...
    BEGIN
      SELECT
        @lenJSON=LEN(@JSON+'|')-1
  --find the matching close-delimiter proceeding after the open-delimiter
      SELECT
        @NextCloseDelimiter=CHARINDEX(@NextCloseDelimiterChar, @json,
                                      @OpenDelimiter+1)
  --is there an intervening open-delimiter of either type
      SELECT @NextOpenDelimiter=PATINDEX('%[{[[]%',
             RIGHT(@json, @lenJSON-@OpenDelimiter)collate SQL_Latin1_General_CP850_Bin)--object
      IF @NextOpenDelimiter=0 
        BREAK
      SELECT @NextOpenDelimiter=@NextOpenDelimiter+@OpenDelimiter
      IF @NextCloseDelimiter<@NextOpenDelimiter 
        BREAK
      IF SUBSTRING(@json, @NextOpenDelimiter, 1)='{'
        SELECT @NextCloseDelimiterChar='}', @type='object'
      ELSE 
        SELECT @NextCloseDelimiterChar=']', @type='array'
      SELECT @OpenDelimiter=@NextOpenDelimiter
    END
  ---and parse out the list or name/value pairs
  SELECT
    @contents=SUBSTRING(@json, @OpenDelimiter+1,
                        @NextCloseDelimiter-@OpenDelimiter-1)
  SELECT
    @JSON=STUFF(@json, @OpenDelimiter,
                @NextCloseDelimiter-@OpenDelimiter+1,
                '@'+@type+CONVERT(NVARCHAR(5), @parent_ID))
  WHILE (PATINDEX('%[A-Za-z0-9@+.e]%', @contents collate SQL_Latin1_General_CP850_Bin))<>0 
    BEGIN
      IF @Type='Object'--it will be a 0-n list containing a string followed by a string, number,boolean, or null
        BEGIN
          SELECT
            @SequenceNo=0,@end=CHARINDEX(':',' '+@contents)--if there is anything, it will be a string-based name.
          SELECT  @start=PATINDEX('%[^A-Za-z@][@]%',' '+@contents collate SQL_Latin1_General_CP850_Bin)--AAAAAAAA
          SELECT @token=SUBSTRING(' '+@contents, @start+1, @End-@Start-1),
            @endofname=PATINDEX('%[0-9]%', @token collate SQL_Latin1_General_CP850_Bin),
            @param=RIGHT(@token,LEN(@token)-@endofname+1)
          SELECT
            @token=LEFT(@token, @endofname-1),
            @Contents=RIGHT(' '+@contents,LEN(' '+@contents+'|')-@end-1)
          SELECT  @name=stringvalue FROM @strings
            WHERE string_id=@param --fetch the name
        END
      ELSE 
        SELECT @Name=null,@SequenceNo=@SequenceNo+1 
      SELECT
        @end=CHARINDEX(',', @contents)-- a string-token, object-token, list-token, number,boolean, or null
      IF @end=0 
        SELECT  @end=PATINDEX('%[A-Za-z0-9@+.e][^A-Za-z0-9@+.e]%', @Contents+' ' collate SQL_Latin1_General_CP850_Bin)
          +1
       SELECT
        @start=PATINDEX('%[^A-Za-z0-9@+.e][A-Za-z0-9@+.e]%',' '+@contents collate SQL_Latin1_General_CP850_Bin)
      --select @start,@end, LEN(@contents+'|'), @contents  
      SELECT
        @Value=RTRIM(SUBSTRING(@contents, @start, @End-@Start)),
        @Contents=RIGHT(@contents+' ', LEN(@contents+'|')-@end)
      IF SUBSTRING(@value, 1, 7)='@object'
        INSERT INTO @hierarchy
          (NAME, SequenceNo, parent_ID, StringValue,Object_ID, ValueType)
          SELECT @name, @SequenceNo, @parent_ID, SUBSTRING(@value, 8, 5),
            SUBSTRING(@value, 8, 5), 'object'
      ELSE 
        IF SUBSTRING(@value, 1, 6)='@array'
          INSERT INTO @hierarchy
            (NAME, SequenceNo, parent_ID, StringValue,Object_ID, ValueType)
            SELECT @name, @SequenceNo, @parent_ID, SUBSTRING(@value, 7, 5),
              SUBSTRING(@value, 7, 5), 'array'
        ELSE 
          IF SUBSTRING(@value, 1, 7)='@string'
            INSERT INTO @hierarchy
              (NAME, SequenceNo, parent_ID, StringValue, ValueType)
              SELECT @name, @SequenceNo, @parent_ID, stringvalue, 'string'
              FROM @strings
              WHERE string_id=SUBSTRING(@value, 8, 5)
          ELSE 
            IF @value IN ('true','false') 
              INSERT INTO @hierarchy
                (NAME, SequenceNo, parent_ID, StringValue, ValueType)
                SELECT @name, @SequenceNo, @parent_ID, @value, 'boolean'
            ELSE 
              IF @value='null'
                INSERT INTO @hierarchy
                  (NAME, SequenceNo, parent_ID, StringValue, ValueType)
                  SELECT @name, @SequenceNo, @parent_ID, @value, 'null'
              ELSE 
                IF PATINDEX('%[^0-9]%', @value collate SQL_Latin1_General_CP850_Bin)>0 
                  INSERT INTO @hierarchy
                    (NAME, SequenceNo, parent_ID, StringValue, ValueType)
                    SELECT @name, @SequenceNo, @parent_ID, @value, 'real'
                ELSE 
                  INSERT INTO @hierarchy
                    (NAME, SequenceNo, parent_ID, StringValue, ValueType)
                    SELECT @name, @SequenceNo, @parent_ID, @value, 'int'
      if @Contents=' 'Select @SequenceNo=0
    END
  END
INSERT INTO @hierarchy (NAME, SequenceNo, parent_ID, StringValue,Object_ID, ValueType)
  SELECT '-',1,NULL, '', @parent_id-1, @type
--
   RETURN
END

GO

Tags:

SQL Server

TFS Select Multiple Items in Dropdown List by Using Custom Contol "MultiValueControl"

by 6. February 2017 06:01

The TFS standard dropdown list control only allows selecting a single item.  To allow selecting multiple items you can install a custom control.  The MultiValueControl allows selecting multiple items by displaying a checkbox next to each item in the list.  You need to install the control into the TFS server in order to use it on the TFS work item web portal and for use with TFS work items through Visual Studio you need to install the custom control on your PC.  Below are links to the Visual Studio 2013 and 2015 custom controls.

Web Controls Installation - http://witcustomcontrols.codeplex.com (http://witcustomcontrols.codeplex.com/releases/view/620316)

  • Navigate in your browser to the configuration panel for the web extension of TFS: http://servername:8080/tfs/admin/Extensions
  • Click on the '+'-sign and upload the CodePlex.WitCustomControls.MultiValueControl<version>.zip-file, make sure to use the .zip file matching you TFS server version.
  • Enable the extension.

VS2013: https://witcustomcontrols.codeplex.com/downloads/get/865716

VS2015: https://witcustomcontrols.codeplex.com/downloads/get/1629434

WitCustomControlSetup2015-1.3.2.5.zip (200.61 kb)

WitCustomControlSetup2013-1.2.2.0.zip (164.22 kb)

Tags:

TFS Download/Modify/Upload Office Field Mappings for Microsoft Project

by 5. January 2017 15:29

cd %programfiles%\Common Files\microsoft shared\Team Foundation Server\12.0

# Download the mapping file

TFSFieldMapping download /collection:http://az-tfs01:8080/tfs/impac /teamproject:apps /mappingfile:C:\tfs\fieldmappingfile.xml

# Upload the mapping file

TFSFieldMapping upload /collection:http://az-tfs01:8080/tfs/impac /teamproject:apps /mappingfile:"C:\tfs\fieldmappingfile.xml"

 

Tags:

TFS

TFS Add Custom Work Item Type

by 5. January 2017 07:35

The easiest way to create a work item type is to copy an existing one, rename it, and then edit it. In the procedure below, you'll export the Feature work item type and use it as the basis for the Initiative work item type. Throughout the examples, the project name is Phone Saver, and the server name is Fabrikam. The team project collection name is the default name, DefaultCollection.

  1. Open a Command Prompt window in administrator mode and change directories to where Visual Studio (or Team Explorer) is installed.

                  cd %programfiles%\Microsoft Visual Studio 12.0\Common7\IDE
                

    On 64-bit editions of Windows, use %programfiles(x86)%.

  2. Use the witadmin tool to download the Feature work item type definition and save it as Initiative.xml.

                  witadmin exportwitd /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /n:Feature /f:%userprofile%\documents\Initiative.xml
                
  3. Open the Initiative.xml file, replace <WORKITEMTYPE name="Feature"> with <WORKITEMTYPE name="Initiative">, and update the description.

                  <witd:WITD application="Work item type editor" version="1.0" xmlns:witd="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/typedef">
                  <WORKITEMTYPE name="Initiative">
                     <DESCRIPTION>Tracks an initiative that will be released with the product. </DESCRIPTION>
                
  4. Edit the Tab element labeled Implementation. Replace <Filter WorkItemType="Product Backlog Item" /> with <Filter WorkItemType="Feature" />. This will show features as children work items of initiatives.

                  <Tab Label="Implementation">
                   <Control Type="LinksControl" Name="Hierarchy" Label="" LabelPosition="Top">
                     <LinksControlOptions>
                        <LinkColumns>
                           <LinkColumn RefName="System.Id" />
                           <LinkColumn RefName="System.Title" />
                           <LinkColumn RefName="System.AssignedTo" />
                           <LinkColumn RefName="System.State" />
                        </LinkColumns>
                        <WorkItemLinkFilters FilterType="include">
                           <Filter LinkType="System.LinkTypes.Hierarchy" FilterOn="forwardname" />
                        </WorkItemLinkFilters>
                        <ExternalLinkFilters FilterType="excludeAll" />
                        <WorkItemTypeFilters FilterType="include">
                           <Filter WorkItemType="Feature" />
                        </WorkItemTypeFilters>
                     </LinksControlOptions>
                   </Control>
                  </Tab>
                
  5. Import the file.

                  witadmin importwitd /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\Initiative.xml
                

Now that you have an Initiative work item type, you'll want to add a category for initiatives to the set of categories visible in the team project.

  1. Export the Categories definition to an xml file.

                  witadmin exportcategories /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\categories.xml
                
  2. Open the file and add the Initiative category. Here's an example, where the Initiative category uses the company name to identify it as a customization:

                  <CATEGORY refname="Fabrikam.InitiativeCategory" name="InitiativeCategory">
                  <DEFAULTWORKITEMTYPE name="Initiative" />
                
  3. Just as you did before, import the file.

                  witadmin importcategories /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\categories.xml
                

Now all that's left to do is to add your initiatives to the hierarchy of work items that make up the portfolio backlog.

  1. Export the process configuration definition to an xml file.

                  witadmin exportprocessconfig /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\MyProcessConfiguration.xml
                
  2. Open the file and add a PortfolioBacklog section for Initiatives within the PortfolioBacklogs section. At the same time, modify the PortfolioBacklog element for FeatureCategory so that Initiatives will be parent work items for Features.

                  <PortfolioBacklogs>
                  <PortfolioBacklog category="Fabrikam.InitiativeCategory" pluralName="Initiatives" singularName="Initiative">
                  <AddPanel>
                  <Fields>
                  <Field refname="System.Title" />
                  </Fields>
                  </AddPanel>
                  <Columns>
                  <Column width="100" refname="System.WorkItemType" />
                  <Column width="400" refname="System.Title" />
                  <Column width="100" refname="System.State" />
                  <Column width="50" refname="Microsoft.VSTS.Common.BusinessValue" />
                  <Column width="100" refname="Microsoft.VSTS.Scheduling.TargetDate" />
                  <Column width="200" refname="System.Tags" />
                  </Columns>
                  <States>
                  <State type="Proposed" value="New" />
                  <State type="InProgress" value="In Progress" />
                  <State type="Complete" value="Done" />
                  </States>
                  </PortfolioBacklog>
                  <PortfolioBacklog category="Microsoft.FeatureCategory" parent="Fabrikam.InitiativeCategory" pluralName="Features" singularName="Feature">
                
  3. Add the color to use for Initiative to the WorkItemColors section.

                  <WorkItemColor primary="FFFF6600" secondary="FFFEB380" name="Initiative" />
                

    This assigns a bright orange color as the primary color to use in list displays, and a paler orange color to use on the task board and Kanban board.

  4. Import the file.

                  witadmin importprocessconfig /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\MyProcessConfiguration.xml
                

And you're done! You‘ve added a third backlog level called Initiatives.

 

Reference source: https://msdn.microsoft.com/en-us/library/dn306083(v=vs.120).aspx

Tags:

TFS Change the Maxiumum Allowed File Attachment Size

by 4. January 2017 13:58

http://localhost:8080/tfs/DefaultCollection/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx?op=SetMaxAttachmentSize

Max allowed is 2GB.

SetMaxAttachmentSize, ConfigurationSettingsService

Tags:

TFS

TFS Locate and Delete Unused Custom Fields

by 4. January 2017 12:18

# Get list of all unused fields
witadmin listfields /collection:http://tfs:8080/tfs/collection /unused

# Confirm specific field details
witadmin listfields /collection:http://tfs:8080/tfs/collection /n:FieldName

# Delete field from collection
witadmin deletefield /collection:http://tfs:8080/tfs/collection /n:FieldName

Tags:

TFS

Error Connecting Microsoft Project to TFS Work Items (TF80070)

by 23. December 2016 10:27

TF80070: Team Foundation encountered an error while performing the operation. It is recommended that you save your work and restart the application.

Create winproj.exe.config file with the following contents and put it in the folder contianing winproj.exe (e.g. C:\Program Files\Microsoft Office\Office15)

<configuration>
 <system.diagnostics>
 <switches>
 <add name="General" value="3" />
 </switches>
 <trace autoflush="false" indentsize="3">
  <listeners>
   <add name="winprojExeListener" type="System.Diagnostics.TextWriterTraceListener"
   initializeData="c:\Logs\winprojExeListener.log" />
  </listeners>
 </trace>
 </system.diagnostics>
</configuration>

Tags:

TFS

TFS Customizing Work Item Types

by 21. November 2016 06:40

To customize TFS work item types (i.e. adding custom fields, etc.) you can export the existing work item type definitions to XML files (using the below command line method "witadmin exportwitd"), edit the files and then import back into TFS (using the below command line method "witadmin importwitd").  Editing the XML files can be managed more easily by installing the "Microsoft Visual Studio Team Foundation Server Power Tools" which will then provide you a nice GUI editor inside of Visual Studio (once the power tools are installed simply open one of the exported XML files in Visual Studio and it should display inside the editor).

===============================================================================
Navigate to this path (may differ for your version of Visual Studio:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>
Then run the below commands to export the work item type definitions to XML.    
===============================================================================

witadmin exportwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /n:"Epic" /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Epic.xml"

witadmin exportwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /n:"Feature" /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Feature.xml"

witadmin exportwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /n:"Product Backlog Item" /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Product_Backlog_Item.xml"

witadmin exportwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /n:"Task" /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Task.xml"

witadmin exportwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /n:"Bug" /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Bug.xml"

===============================================================================
At this point you have exported the associated work item types as XML files.
Open each XML file in Visual Studio and edit accordingly.
Then run the below commands to import them back into TFS and apply the updates.
===============================================================================

witadmin importwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Epic.xml"

witadmin importwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Feature.xml"

witadmin importwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Product_Backlog_Item.xml"

witadmin importwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Task.xml"

witadmin importwitd /collection:http://tfs01:8080/tfs/COLLECTION_NAME_HERE /p:PROJECT_NAME_HERE /f:"c:\temp\TFS_COLLECTION_NAME_HERE_PROJECT_NAME_HERE_Bug.xml"

Tags:

TFS