Microsoft Team Foundation Server–Undoing checkout for a workspace that no longer exists

February 2, 2016 Leave a comment

Every once in a while, you get a request from your developer telling you that they have reformatted their machine and unfortunately there is still one or 2 files inside that workspace that they forgot to checkout

Visual studio comes with tools that allows you to undo checkout. Unfortunately it runs from the CLI

  1. Goto the visual studio folder
    cd “C:\Program Files (x86)\Microsoft Visual Studio 14.0”
  2. List workspaces of the user
    tf workspaces /collection:http://mytfsserver:8080/tfs/defaultcollection /owner:JohnDoe

    Collection: http://mytfsserver:8080/tfs/defaultcollection
    Workspace Owner          Computer  Comment
    ——— ————– ——— ————————————————————————————
    JD-PC JohnDoe JD-PC
    JD-PC2     JohnDoe JD-PC2
    JD-PC3    JohnDoe JD-PC3

  3. Figure out which workspace contains the file to undo and fire up the undo command

    tf undo /workspace:JD-PC2;JohnDoe /s:http://mytfsserver:8080/tfs $/Path/To/The/File.cs

if it works, you will get the following reply:

The operation completed successfully.  Because the workspace JD-PC2;JohnDoe is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Easy way to IMAP sync 2 mailboxes

February 2, 2016 Leave a comment

Linux has a great tool to sync 2 different mailboxes, this is especially useful when you need to migrate from one mailbox to another

  1. First install imapsync
  2. Then run the following command

imapsync –host1 –user1 –password1 –host2 [destination server] –user2 [destination email] –password2 [destination password]

Categories: CentOS, Open Source, Ubuntu

Selenium WebDriver – Element is not clickable at point

February 2, 2016 Leave a comment

Selenium is a fantastic tool for website automation, you simply nuget it into your .NET project and you will be able to use it to automate testing using Firefox

Nuget link: https://www.nuget.org/packages/Selenium.WebDriver

 

However, if you are upgrading from versions < 2.48 to the latest version, you will realize that a lot of your codes will suddenly throw the following error

OpenQA.Selenium.WebDriverException: Unexpected error. Element is not clickable at point (x, y). Other element would receive the click:

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)

 

This is due to the way Selenium handles Mouse Clicks from version 2.48 onwards, version 2.50 is the currently “safer” version to use

https://github.com/SeleniumHQ/selenium/issues/1202

image

 

Of course all of these does not fix the issues you have with the code, here are some possible ways to fix them

#1: Use SendKeys

SendKeys automatically focuses to the element that it needs to send keys to, however this is restricted to input elements

e.g Element.SendKeys(Keys.Escape)

 

#2 Use MoveToElement

MoveToElement is another way to move focus to the element.

e.g new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(elem).Perform();

#3 Use Javascript

Javascript allows you to pretty much do anything

e.g. ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(" + elem.Location.X + "," + elem.Location.Y + ")")

 

#4 Use ScrollIntoView

ScrollIntoView is another  possible javascript that you can use

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);

ASP.NET vNext – EntityFramework 7.0 Database First (RC1)

February 2, 2016 Leave a comment

This is the updated version using RC1 for https://jefferytay.wordpress.com/2015/11/04/asp-net-vnext-entityframework-7-0-database-first/

Changes from beta8 are colored in red

EF 7.0 supports both code first aka POCO as well as database first. However you do need a bit of tweaking in order to get EF to generate the classes for you. Take note that edmx files are no longer used for EF 7.0.

Step by step guide
  • Starting with a blank project, add the following dependencies

"EntityFramework.Commands": "7.0.0-rc1-final",
  "EntityFramework.Core": "7.0.0-rc1-final",
  "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
  "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",

Which should make your dependencies look like this

image

  • Visual Studio 2015 should then run nuget in the background to obtain the new libraries. Once that is done, your dependencies list in VS should show the RC1 libraries

You will also need to add the following item into your list of commands

    "ef": "EntityFramework.Commands"

Which will then make your commands list look like

image

  • Now you need to run a command prompt and browse to the project directory, and then run the following command, replacing the brackets with actual data

dnx ef dbcontext scaffold –c [DBContextName] –o [Output folder] [SQLConnection string] EntityFramework.SqlServer

e.g

dnx ef dbcontext scaffold -c TestDbContext -o Models "Data Source=.; Initial Catalog=Test;User ID=myusername;Password=P@ssw0rd"  EntityFramework.MicrosoftSqlServer

image

Common errors that you will typically encounter when you see “One or more errors occurred.”:

Take note that the stack trace is VERY long, so you will need to scroll right to the front to see the error message

System.AggregateException: One or more errors occurred. —>Microsoft.Data.Entity.Design.OperationException: Unable to find design-time provider assembly. Please install the EntityFramework.SqlServer.Design NuGet package and ensure that the package is referenced by the project. —> System.IO.FileNotFoundException: Could not load file or assembly ‘EntityFramework.SqlServer.Design’ or one of its dependencies. The system cannot find the file specified.

-> this means project.json does not have the EntityFramework.SqlServer.Design, save the project file and do a dnu restore to ensure that all the packages are restored

System.AggregateException: One or more errors occurred. —>System.Data.SqlClient.SqlException: Login failed for user ‘myusername’.

-> obvious, means you entered the wrong password or are connecting to the wrong database server

InvoicePlane–Enabling friendly filenames when downloading PDF

January 29, 2016 Leave a comment

Modify /application/helpers/mpdf_helper.pdf       

Look for this particular code segment

if (!empty($invoice_array) AND $isGuest) {
            rsort($invoice_array);
            header(‘Content-type: application/pdf’);
return readfile($invoice_array[0]);       

 

then modify it to

if (!empty($invoice_array) AND $isGuest) {
            rsort($invoice_array);
            header(‘Content-type: application/pdf’);
header(‘Content-Disposition: attachment; filename="’.basename($invoice_array[0]).’"’); //<– add this line
return readfile($invoice_array[0]);       

Categories: Invoice Plane, Open Source

InvoicePlane–Adding custom recurring periods

January 29, 2016 Leave a comment

By default, invoice plans comes with recurring periods up to 1 year. However sometimes you need to add in additional recurring periods

To do so, you will need to edit 2 files

File #1: application\modules\invoices\models\mdl_invoices_recurring.php

Look for $recur_frequencies and then add in the periods you want e.g in this example, I added in 2, 3,4 and 5 years

image

File #2: application\language\english\custom_lang.php

You will need to map each of the values with an appropriate language value, e.g in this case 2_year maps to the phrase 2 Years

If you support more than the english language, you will need to do the same for the additional language

image

Categories: Invoice Plane, Open Source

IdentityServer 3.0–HTTP 404 for /assets resources

January 28, 2016 Leave a comment

IdentityServer 3.0 (https://identityserver.github.io/Documentation/) works as an OAuth provider, especially useful when you want to roll your own authentication.

However should you mimic the samples incorrectly, you may get the following screen, where the /assets resources are not found.

image

Because ID3 packages everything in a DLL, you will need to ensure that  runAllManagedModulesForAllRequests (RAMMR) is enabled in web.config

image

 

Once you have enabled RAMMR, simply save web.config and reload the page and viola

image

Categories: ASP.NET, IdentityServer 3
Follow

Get every new post delivered to your Inbox.