tag:blogger.com,1999:blog-92023092542274135372024-03-05T04:07:10.386-08:00Peretz.NetFun stuff with .NET and C#Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.comBlogger77125tag:blogger.com,1999:blog-9202309254227413537.post-68756010936313651632019-08-12T05:18:00.003-07:002019-08-12T05:19:39.563-07:00Working with JIRA Working with JIRA is simpler with this chrome extension I coded:<br />
<br />
<a href="https://chrome.google.com/webstore/detail/jira-ticket-copy/dnnhgpjgcipbklhmmjiikalolmambaem?authuser=1">https://chrome.google.com/webstore/detail/jira-ticket-copy/dnnhgpjgcipbklhmmjiikalolmambaem?authuser=1</a><br />
<br />
it allows copy past from any JIRA ticket to your anything... Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-62414322510186146212017-02-09T07:21:00.000-08:002017-02-09T07:24:38.259-08:00How to restore nuget packages with Package Manager Console <p>
Make sure your project has all the packages it needs in packages.config.
Open the Package Manager Console.
</p>
<p>
<code>Update-Package -Reinstall</code>
</p>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-18549489010515773572016-10-11T13:17:00.000-07:002016-10-11T13:17:00.096-07:00How to upload a file with progress indicator using WEB APII really wanted to put a very simple example on how you can upload a file using Web API and get a progress indicator on the client. The client code here is using a console application, but I tested the code with portable libraries and it should work just fine.
This is not production code! there is no security, not error handling, this is the code I used to prototype and decided to share it, it is a bare bones example.
<h2>Server code</h2>
<h3>Controller code</h3>
<pre>
public class ValuesController : ApiController
{
[HttpGet]
[Route("upload/movie")]
public string SayHello()
{
return "Hello World";
}
/// <summary>
/// Upload a file
/// </summary>
/// <returns>The file information</returns>
[HttpPost]
[Route("upload/movie")]
[ResponseType(typeof(List<FileUploadModel>))]
public async Task<HttpResponseMessage> SaveFileAttachment()
{
List<FileUploadModel> model = await FileUploader.UploadAttachment(Request);
return Request.CreateResponse(HttpStatusCode.Created, model);
}
}</pre>
<h3>The helper code on the server to upload a file</h3>
<pre>
public class FileUploader
{
const string UPLOAD_PATH = "C:\\UPLOAD";
public static async Task<List<FileUploadModel>> UploadAttachment(HttpRequestMessage request)
{
// Verify that this is a file upload request
if (!request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
}
// Create a stream provider for setting up output streams
var streamProvider = new MultipartFormDataStreamProvider(UPLOAD_PATH);
MultipartFormDataStreamProvider resultProvider = null;
try
{
resultProvider = await request.Content.ReadAsMultipartAsync(streamProvider);
}
catch(Exception ex)
{
var x = ex.Message; // for debugging
throw ex;
}
var files = new List<FileUploadModel>();
// Collect uploaded files
foreach (MultipartFileData file in resultProvider.FileData)
{
string localFileName = Path.GetFileName(file.LocalFileName);
string originalFileName = file.Headers.ContentDisposition.FileName;
if (string.IsNullOrEmpty(localFileName) || string.IsNullOrEmpty(originalFileName))
{
continue;
}
string fileName = originalFileName.Trim().Trim('"');
files.Add(new FileUploadModel
{
FileName = fileName,
LocalFullPath = Path.Combine(UPLOAD_PATH, localFileName),
Comment = String.Empty
});
}
return files;
}
}</pre>
<h3>The client code</h3>
Console Application (notice there is a callback here to get the updated status)
<pre>
class Program
{
static void Main(string[] args)
{
string fileName = @"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv";
FileStream stream = File.Open(fileName, FileMode.Open);
var response = UploadMe.UploadFile(stream, "Wild Life - uploaded.wmv", (progress) => { Console.WriteLine(progress); });
Console.ReadLine();
}</pre>
<h3>Client Helper</h3>
<pre>
public class UploadMe
{
public static async Task<List<FileUploadModel>> UploadFile(Stream fileStream, string fileName, Action<int> callback)
{
ProgressMessageHandler progress = new ProgressMessageHandler();
progress.HttpSendProgress += new EventHandler<HttpProgressEventArgs>((e, args) => { callback(args.ProgressPercentage); });
MultipartFormDataContent content = new MultipartFormDataContent();
// the request
HttpRequestMessage message = new HttpRequestMessage();
content.Add(new StreamContent(fileStream), "file", fileName);
message.Method = HttpMethod.Post;
message.Content = content;
message.RequestUri = new Uri("http://localhost/UploadFileNoSecurity/upload/movie");
var client = HttpClientFactory.Create(progress);
client.Timeout = TimeSpan.FromHours(1);
var response = await client.SendAsync(message);
if (response.IsSuccessStatusCode)
{
Task<string> httpResponse = response.Content.ReadAsStringAsync();
List<FileUploadModel> json = JsonConvert.DeserializeObject<List<FileUploadModel>>(httpResponse.Result);
return json;
}
return null;
}
}</pre>
<h3>The DTO code </h3>
<pre>
namespace UploadModel
{
public class FileUploadModel
{
public string FileName { get; set; }
public string LocalFullPath { get; set; }
public string Comment { get; set; }
}
}</pre>
Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com2tag:blogger.com,1999:blog-9202309254227413537.post-80886710940536394882015-11-04T05:13:00.004-08:002015-11-04T05:13:49.428-08:00C# Indexer not using the propertyItemC# will use the property <code>item</code> when using indexers, but if you already have a property with that name you will have problem. To solve it use the attribute on your indexer with another name
<code>[IndexerName("MyItem")]</code>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-6403783717374172272015-10-30T11:02:00.001-07:002015-10-30T11:02:57.386-07:00Specflow - how to create steps in another assembly For some reason having steps in another assembly doesn't always work. When I tried this I found out there is a bug with specflow, that if you don't put your step class in the root of the assembly, it might not bind it correctly. So, place your step class directly in the root (not in a sub-folder).
Also, in the app.config of your project with your feature files you need to have this configuration
<p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuH9N5KQfXDE_W10W9dyjB2CnJR5qZTTkNS_jgrKzvxefVBDTCToT4Cr3iygLi-m9rwPnL9ioaBqP6_HN6laNLWiNd2VMslxXWgvI7WzfFe27VPu4Eti3v-wz-9yEc6NybtU5Uns_hcyqa/s1600/configstep.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuH9N5KQfXDE_W10W9dyjB2CnJR5qZTTkNS_jgrKzvxefVBDTCToT4Cr3iygLi-m9rwPnL9ioaBqP6_HN6laNLWiNd2VMslxXWgvI7WzfFe27VPu4Eti3v-wz-9yEc6NybtU5Uns_hcyqa/s1600/configstep.png" /></a></div>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-38451412726097764032015-03-20T06:32:00.001-07:002015-03-20T06:32:43.706-07:00Testing internal classes with C# and MSTestput an attribute in the assemblyinfo.cs file in the project under test, pointing to the test assembly
Project under test will have
<pre>
[assembly: InternalsVisibleTo("MyTest")]
</pre>
Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-15788615720583749792014-06-26T07:02:00.001-07:002014-06-26T07:05:34.939-07:00How to make Alerts fade in and fade out with Bootstrap 3.0<p>I wanted to make the alerts work a little nicer by using fade in and fade out. I know there are classes in the CSS to handle the fade in, but they don't work in all browsers. So I wanted to implement some Javascript to make it work</p>
<h1>Create a div for your alerts</h1>
<pre>
<div id="alerts">
</div>
</pre>
<h1>We need to create unique Ids, I have used this function to do so</h1>
<pre>
function createUUID() {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid;
}</pre>
<h1>Make a function to show the alert, by adding it dynamically</h1>
<pre>
function addAlert(message) {
var id = createUUID();
var JQueryId = "#" + id;
$('#alerts').append(
'<div style="display:none;" class="alert alert-warning" id="' + id + '">' +
'<button type="button" class="close" data-dismiss="alert">' +
'×</button>' + message + '</div>');
$(JQueryId).fadeIn(5000);
window.setTimeout(function () {
// closing the popup
$(JQueryId).fadeTo(300, 0.5).slideUp(2000, function () {
$(JQueryId).alert('close');
});
}, 10000);
}</pre>
<p>Notice that when adding the alert, it is hidden. The JQuery fadeIn API will create the fade effect when the alert is showing. Using setTimeout, we start fading out, and then closing the alert. You can play with the numbers to have the effect you want, but this seems to work nice and make alerts popup nice, and close on their own</p>
<h1>Testing the Alerts</h1>
<pre>
$(document).ready(function () {
addAlert("test");
window.setTimeout(function () {
addAlert("test1");
}, 1000);
window.setTimeout(function () {
addAlert("test2");
}, 10000);
window.setTimeout(function () {
addAlert("test3");
}, 20000);
window.setTimeout(function () {
addAlert("test4");
}, 20000);
});</pre>
<h1>The code</h1>
You can see the code and the full effect here
<a href="http://www.bootply.com/Sfn68ySAnB">http://www.bootply.com/Sfn68ySAnB</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com1tag:blogger.com,1999:blog-9202309254227413537.post-39361332317304462532014-06-18T06:00:00.001-07:002014-06-18T06:00:12.043-07:00Membership and roles as a WCF service<p>In case you want to have your membership and roles exposed as a service</p>
<a href="http://msdn.microsoft.com/en-us/library/bb398990.aspx">Click here for more information</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-18607359294035732652014-06-18T03:46:00.000-07:002014-06-18T03:46:27.141-07:00How to create a web thumbnail<p>I found a lot of tools that do this but I think the one I am going to really give a try is this one</p>
<a href="http://webthumbnail.org/">webthumbnail.org</a>
<p>And I am going to try to add a link to CNN here:</p>
<img src="http://api.webthumbnail.org?width=500&height=400&screen=1024&url=www.cnn.com" alt="Generated by WebThumbnail.org" />Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-29218735046780136182014-06-04T08:37:00.001-07:002014-06-05T06:27:02.077-07:00How to make technical demos better<p>
If you are showing code, a power point and then switching to a view of the application it can be challenging so here are some tips to improve your technical demo</p>
<h2>I don’t want to see your dog</h2>
<p>
You should not show your family or dog in your background, it is better to keep your background black or with a logo of your demo or company. You should also consider that it takes longer to render images when people view your demo in a remote location.
<h2>I don't want to see e-mail popups</h2>
<p>I don’t want to see an e-mail pop from your wife telling you to pick up milk on the way home during a demo.
For the demo, consider sharing your secondary monitor and not the main monitor. This way you don’t need to close all these items on the task bar, you don’t want to show what you have open to everyone. It also solves the issues of notifications from e-mail. Normally these e-mails notifications can pop during the demo and normally they are on the main screen. Putting your demo on the secondary screen will make sure no one sees these notifications. Of course, you can also just close your e-mail program before the demo.</p>
<h2>I can’t see that! Can you make it bigger?</h2>
<p>
Well, there is an app for that. Download the application <a href="http://technet.microsoft.com/en-ca/sysinternals/bb897434.aspx">ZoomIt</a> and it will allow you to zoom into parts of the screen you want to explain. ZoomIt has cool features that allows you to draw arrows and boxes around items on your screen. The best part is that it’s free!</p>
<h2>Hold on let me find that code…</h2>
<p>
Nothing is more annoying than a developer looking for the code he wants to show in the solution. The solution to this is actually simple. In Visual Studio use Bookmarks, using bookmarks you can mark the parts of the code you want to go to. Bookmarks can be enabled from the Edit Menu. You can see all your bookmarks in a bookmark view window (in the View menu).</p>
<h2>Oh no! Not another slide</h2>
<p>
Don’t make too many slides full of text – no matter what you are showing you are likely to put your audience to sleep. Keep your slide short, put more graphics and diagrams into them. The reason is simply because the human brain works better with visuals. However, keep most of your demo interactive as much as possible. Best demos can be when you code with the audience and explain what you are doing. Which brings me to my next point...</p>
<h2>How do I code without errors during my demo?</h2>
<p>
If you choose to be brave and code during the demo, you better make sure your code will work. The best way to know your code will work, is to code everything and test everything before the demo. If you have a working version of your code, launch it on the main screen, and share your secondary screen with the audience (running a second version of Visual Studio). You can also have notepad with code snippets on the main as a reference. Copy pasting is another technique, however, don’t use copy past too much, you may lose the audience with large snippets. Best thing is to type it as you go… this way you keep everyone watching…</p>
<p>The cool thing is that your audience doesn't know you have a working reference on the first screen, and they can't see your task bar (showing 2 version of Visual Studio), so to everyone it looks like you are doing it from memory and on the fly. Making you look like a true Master Jedi.</p>
<h2>How to make sure people are not falling asleep</h2>
<p>
Try to keep the subject interesting, pop a few jokes and get your audience to participate. A few tips to get the audience involved is to simply ask them questions. Take breaks in the demo, and let the audience have a chance to ask questions and go into more details.</p>
<p>
So there it is – have a great demo and good luck not getting that blue screen.
</p>
Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-54283503678644572502014-06-03T05:56:00.000-07:002014-06-03T05:56:39.083-07:00How to do Control-Alt-Delete on Remote DesktopI am tiered of looking this up all the time, so here it is:
<p>
Press: <code>CONTROL-ALT-END</code>
</p>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-34696008094461967932014-06-01T18:23:00.001-07:002014-06-02T15:38:41.046-07:00Knockout, Mapping plug-in, Typescript and ASP.NET MVC playing nice. <h2>MVVM</h2>
<p>
In this article I will show how you can use the MVVM pattern to the fullest using the Knockout.JS framework, with the mapping plug-in add-on. The goal of this article is to show that you can define your view model at the back-end only, and have it "mapped" dynamically at the client side without the need to code it by hand. To make the coding simpler I have decided to use Typescript and test it with JQuery, and Knockout.
You can learn more about the mapping plug-in <a href="http://knockoutjs.com/documentation/plugins-mapping.html">here</a>.
</p>
<h2>Typescript</h2>
To learn more about typescript I recommend you visit <a href="http://www.typescriptlang.org/">this site</a>.
<h2>Lets get the environment setup</h2>
<p>You will need to get a few Nuget packages to get going... here are some of them:</p>"
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvT1iyrIxEZqVoofGixqVgKhSYs1FZPS9ahkMERpwxNX-_Q0Qr57B6BEppWC2MS9SPrDoq7vVNwZWRsyoE5RxDUPo0OjZk7YAfFnQNX7uQtC4XQCGh-cBoq1jDPt9LMLm09UkgWdMahZkS/s1600/Nuget.PNG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvT1iyrIxEZqVoofGixqVgKhSYs1FZPS9ahkMERpwxNX-_Q0Qr57B6BEppWC2MS9SPrDoq7vVNwZWRsyoE5RxDUPo0OjZk7YAfFnQNX7uQtC4XQCGh-cBoq1jDPt9LMLm09UkgWdMahZkS/s1600/Nuget.PNG" /></a>
<p>Next you will create a new TypeScript file and add the following dependencies:</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc2p9PdUwiLnt_1n89TduPFBtfvoa9NzL63rb99S7PtCuxNeSHwhdzMWSfeIM6rfo98erbfbomHS8u8yIR-OaboyuFGaQ71PB9sv1b2SchG9BEDYCMqVurmlsKyFjLS9oz76j_fmMR9m0Y/s1600/ref.PNG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc2p9PdUwiLnt_1n89TduPFBtfvoa9NzL63rb99S7PtCuxNeSHwhdzMWSfeIM6rfo98erbfbomHS8u8yIR-OaboyuFGaQ71PB9sv1b2SchG9BEDYCMqVurmlsKyFjLS9oz76j_fmMR9m0Y/s1600/ref.PNG" /></a>
<h2>The ViewModel</h2>
<p>Notice that I only define the view model properties at the back-end. You will not see the fields of the ViewModel on the client side</p>
<pre>
public class DomainItem
{
public string Name { get; set; }
public string Description { get; set; }
}
public class DomainViewModel
{
public DomainViewModel()
{
Items = new List<DomainItem>();
Status = "Loaded";
}
public string Name { get; set; }
public List<DomainItem> Items { get; set; }
public string Status { get; set; }
}</pre>
<h2>The Controller</h2>
<pre>
public class HomeController : Controller
{
//
// GET: /Configuration/
public ActionResult Index()
{
return View();
}
//
// GET: /Configuration/Details/5
public ActionResult List()
{
DomainViewModel vm = new DomainViewModel();
vm.Name = "Name1";
var list = new List<DomainItem>();
vm.Items.Add(new DomainItem { Name = "item 1", Description = "This is item 1" });
vm.Items.Add(new DomainItem { Name = "item 2", Description = "This is item 2" });
vm.Items.Add(new DomainItem { Name = "item 3", Description = "This is item 3" });
return Json(vm, JsonRequestBehavior.AllowGet);
}
public ActionResult Refresh()
{
Random random = new Random();
int number = random.Next(1, 50);
DomainViewModel vm = new DomainViewModel();
vm.Name = "Name" + number;
var list = new List<DomainItem>();
for (int i = 0; i < number; i++ )
{
vm.Items.Add(new DomainItem { Name = "item " + i, Description = "This is item " + i });
}
return Json(vm, JsonRequestBehavior.AllowGet);
}
[HttpPost]
public JsonResult SubmitViewModel(DomainViewModel viewModel)
{
viewModel.Status = "Saved...";
return Json(viewModel);
}
}</pre>
<ul>
<li><code>List</code> returns list of items, this data will be converted into a view model on the client
<li><code>Refresh</code> simulates a data update on the back-end and sending the updated the data to the client
<li><code>SubmitViewModel</code>Simulates a save operation on the view model, and updating the status field to "Saved..."
</ul>
<h2>The Dynamic ViewModel base class (in Typescript)</h2>
<p>This is the base class that holds the necessary operations to dynamically map the view model from the server into the client. It also contains some re-usable flags to indicates if we are in the process of getting data from the back-end, I use this data to notify the user when communication with the back-end occurs.</p>
<pre>
class DynamicViewModel {
// set to the true when the data is loaded from the back-end
isLoaded = ko.observable(false);
// set to true while the data is loading from the back-end
isLoading = ko.observable(false);
constructor() {
}
// show a hidden html id
show(id: string) {
$(id).show();
}
// does an http get to the server, take a url returns the viewmodel. Once the request
// is done, the view model is added to this class
httpGet(url: string, callback?: (vm) => void) {
// keep a pointer to this view model
var self = this;
// update flags
self.isLoaded(false);
self.isLoading(true);
// make the REST call using GET
$.ajax(url, {
type: "GET",
cache: false,
}).done((vm) =>
{
// map the view model data we got from the server into this viewmodel
ko.mapping.fromJS(vm, {}, self);
// update flags
self.isLoaded(true);
self.isLoading(false);
// if there is a callback, then call it.
if (callback !== undefined)
return callback(vm)
});
}
// makes a post call to the server, and updates the viewmodel response
httpPost(url: string, onSuccess?: (vm) => void) {
// keep a pointer to this viewmodel
var self = this;
// update flags
self.isLoaded(false);
self.isLoading(true);
// make a POST call to the server
$.ajax({
url: url,
type: 'post',
// pass this viewmodel
data: ko.mapping.toJSON(self),
contentType: 'application/json',
success: function (vm) {
// update flags
self.isLoaded(true);
self.isLoading(false);
// update the view model
ko.mapping.fromJS(vm, {}, self);
// if there is a callback, call it
if (onSuccess !== undefined)
return onSuccess(vm);
}
});
}
}</pre>
<ul>
<li><code>ko.mapping.fromJS(vm, {}, self);</code> this is the code that dynamically expends the view model, and adds the observable items based on the JSON coming back from the back-end</li>
<li><code>ko.mapping.toJSON(self)</code> is used to serialize the view model to JSON so it can be sent to the back-end (it is used on the post)
<li>Making making a post to the server, to send the view model, the <code>code ko.mapping.toJSON(self)</code> the magic
<li>Notice that I had to use self, that's because the this keyword changes scope even with Typescript</li>
<li>the url will be passed from the child class</li>
</ul>
<h2>Child ViewModel</h2>
<pre>
class DomainViewModel extends DynamicViewModel {
initUrl: string;
postUrl: string;
refreshUrl: string;
constructor(initUrl: string, refreshUrl: string, postUrl: string) {
super();
this.initUrl = initUrl;
this.postUrl = postUrl;
this.refreshUrl = refreshUrl;
}
// Initialize the view model for the first time.
initializeAction() {
super.httpGet(this.initUrl, (data) =>
{
// apply the binding
ko.applyBindings(this);
// show the window
super.show("#Main");
});
}
// Update the data on the UI
updateAction() {
super.httpGet(this.refreshUrl);
}
submitAction() {
super.httpPost(this.postUrl);
}
}</pre>
<p>Notice that the DomainViewModel deals mostly with commands and doesn't actually define the data in the view model. This is because the base class will handle injecting the data in when doing a GET or a Post</p>
<h2>The View</h2>
<pre>
@{
ViewBag.Title = "Index";
}
@section scripts
{
<script type="text/javascript">
$(document).ready(function () {
// get some url configuration for the view model to do its work
var initializeUrl = "@Url.Action("List")";
var refreshUrl = "@Url.Action("Refresh")";
var submitUrl = "@Url.Action("SubmitViewModel")";
var domainViewModel = new DomainViewModel(initializeUrl, refreshUrl, submitUrl);
// initialize the view model
domainViewModel.initializeAction();
});
</script>
@*typed scripted geneated*@
<script src="~/Scripts/TypeScript/ViewModel.js"></script>
}
<h2>Configuration Controller</h2>
<div id="Main" class="part" style="display : none">
<div class="part">
<h3>Binding to a selection box</h3>
<select data-bind="options: Items,
optionsText: 'Name',
optionsCaption: 'Choose...'" size="5" multiple="true"></select>
</div>
<div class="part">
<h3>Binding to a text box</h3>
<input type="text" data-bind="value: Name" />
</div>
<div class="part scrollDiv">
<h3>Binding to a table</h3>
<table class="table">
<thead>
<tr><th>First name</th><th>Last name</th></tr>
</thead>
<tbody data-bind="foreach: Items">
<tr>
<td data-bind="text: Name"></td>
<td data-bind="text: Description"></td>
</tr>
</tbody>
</table>
</div>
<div class="part">
<label data-bind="text: Status"></label>
</div>
<div class="part">
<button data-bind="click: updateAction">Refresh data</button>
</div>
<div class="part">
<button data-bind="click: submitAction">Submit data</button>
</div>
<div class="part">
<label data-bind="if:isLoading">Loading from server...</label>
<label data-bind="if:isLoaded"> Loading from server... done</label>
</div>
</div>
</pre>
<h2>No need to code the ViewModel by hand in Javascript anymore</h2>
<p>So thanks to the mapping plug-in for knockout, you don't need to worry about typing all the view model observable by hand anymore. You can use the base class view model and use it to do most of the work for you. This code is not production quality code, and only used to show the use of a dynamic view model using the knockout mapper plug-in</p>.
<h2>The full code</h2>
<a href="https://app.box.com/s/hr6g9yp4ifrest70wm0w">Click here for the full source code (compiled with Visual Studio 2013 Update 2)</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com2tag:blogger.com,1999:blog-9202309254227413537.post-4648609201998240402014-05-28T11:31:00.000-07:002014-05-28T11:31:22.833-07:00How to re-load without caching in Chrome<p>
Simple!
</p>
<code>
CTR + R then CTRL + F5</code>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-90041427739556863892014-05-23T13:15:00.002-07:002014-05-23T13:16:05.340-07:00SCRUM - How to deal with a team that doesn't talk<p>
So you are the SCRUM Master and you are in a team that no one likes to talk or you have very shy people. How do you deal with this… here is a list of tools that can help:
<ul>
<li>Use voting with your hand when making decisions. The technique is called fist of five voting (<a href="http://heymacagile.blogspot.ca/2011/08/fist-of-five-voting-for-team-consensus.html">click here for more info</a>)</li>
<li>Setup one on one meeting with every team member to see how they are doing during the sprint. They might open up more when it is just the two of you.</li>
<li>During the SCRUM ask each person by name how they are doing or if they are stuck. Don’t use generic questions such as “Is anyone stuck?”</li>
<li>Don’t make decisions for the team – try to encourage discussion and consensus. Do this by asking questions to people by name. For example “Tom what do you think about this idea?” Use first of five to get the feedback from the group when you think you reached a consensus </li>
<li>Keep meeting with the group low-stress and fun so people don’t feel on the spot or stressed, bring snakes or make jokes to keep the mood light</li>
<li>Managers attending SCRUM can cause team members to speak less, worrying that they may look bad if they are stuck. In this case, work with the manager or team member and explain that they should not worry about speaking up or saying that they are stuck.</li>
</ul>
Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-48430531759989623142014-05-23T07:20:00.002-07:002014-05-23T07:21:02.530-07:00Windows 7 setup for WAS under IIS
<a href="https://docs.tibco.com/pub/ems_transport_channel_for_wcf/1.2.0-march-2012/doc/html/TIB_emswcf_user/wwhelp/wwhimpl/common/html/wwhelp.htm#context=TIB_emswcf_user&file=WAS.5.2.htm">This is how to configure WAS on IIS 7 for Windows 7 and Windows 2008</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-76263657076555975182014-05-15T05:49:00.002-07:002014-05-15T05:53:16.350-07:00SCRUM - Should you add a story to the sprint backlog mid sprint?<p>
The question here is not that there is an emergency story that needs to be done ASAP. The situation is that there are free people during the sprint that are asking to bring a new story into the sprint. Although this sounds tempting - as a SCRUM Master you have to be careful. Even if a developer can bring a story and do the development - there might be no time for QA or documentation to be done. One idea is bring another story and start the development, the testing and documentation can be done in the following sprint - terrible idea. This will first most likely violate your own definition of done and create a QA debt that will be carried over to the following sprint. Instead, focus on working as team more, and my advice is that if someone is free, let him help someone that is not free. There are items in progress that need to be done, so let any free person assist in any way possible a busy person. They can pair, one can do the code and the other can write the unit tests. They can split the work (tasks) between them - anything to help would be beneficial. What you don’t want to have is 10 stories in progress by 10 people – each one doing his or her own story and swimming in his or her own private lane. You want people to help each other, work together, sit together, and work as a team.
However, although I feel helping someone else is the best option, sometimes everyone is doing fine and they don’t need help. Then what? What do you do if you finished everything? </p>
<p>
So I created this little chart to help you out with this…
</p>
<h2>I am free! and I want to bring a story to the sprint backlog (mid-sprint)</h2>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQQv6Ci528dMC0VC7IZC0mfQzLiSwehBeVh3fVD83h82uo9fBya6LFPB79nMV0DIguKYrRMPjHtoHEBivDcXdzxm51eZ6FiG5ONCJn0Q_Wj7aw4JLI-URUUlFZ5GjEDjxc7a-Y7zIuLmaT/s1600/mid+sprint2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; border:2px solid; box-shadow: 10px 10px 5px #888888;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQQv6Ci528dMC0VC7IZC0mfQzLiSwehBeVh3fVD83h82uo9fBya6LFPB79nMV0DIguKYrRMPjHtoHEBivDcXdzxm51eZ6FiG5ONCJn0Q_Wj7aw4JLI-URUUlFZ5GjEDjxc7a-Y7zIuLmaT/s1600/mid+sprint2.png" /></a></div>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-39970801087736381102014-04-21T07:36:00.002-07:002014-04-21T07:36:57.343-07:00WCF Service with no SVC file and no Endpoint configuration sample<p>I put this quick example so I have all the configuration settings I need in one simple example</p>
<a href="http://1drv.ms/1i7wF1U">Click here for the link to the code</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-8227066028727629512014-04-18T07:21:00.001-07:002014-04-18T07:21:14.190-07:00Visual Studio 2012 stop responding on start-up....possible fix<p>I don't really know what happened to my Visual Studio 2012 but removing and re-installing did not work. Visual Studio kept not responding when loading up. Finally what seems to have solved it was this simple command line: <code>devenv /ResetSettings</code>. I hope this saves you time...</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbkkn15mikpe5GmXeVAZYztq4SdPFL_MG3KkjQd9eJQfJE9TS7T1Yfj6x_RhUzva-O9i27Hxey_xju2hcbejIMhyWdqQfqnPRRtB1CT7KwRX8hX3Sb7oSoyU6Z-xl6HIj-RCc6vbT0nxx/s1600/resetsettings.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbkkn15mikpe5GmXeVAZYztq4SdPFL_MG3KkjQd9eJQfJE9TS7T1Yfj6x_RhUzva-O9i27Hxey_xju2hcbejIMhyWdqQfqnPRRtB1CT7KwRX8hX3Sb7oSoyU6Z-xl6HIj-RCc6vbT0nxx/s1600/resetsettings.png" /></a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com7tag:blogger.com,1999:blog-9202309254227413537.post-88230372152326219482014-04-12T19:16:00.000-07:002014-04-13T04:58:00.403-07:00How to debug the Seed() method when using EF 6.0Add this to the Seed() method
<pre>
if (System.Diagnostics.Debugger.IsAttached == false)
System.Diagnostics.Debugger.Launch();</pre>
I have tried to use <code>System.Diagnostics.Debugger.Break()</code>, but that crashed visual studio. Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com1tag:blogger.com,1999:blog-9202309254227413537.post-47606731250159608422014-04-12T17:26:00.002-07:002014-04-12T19:14:53.346-07:00NuGet putting the references in a diffrent folder location<p>
I didn't like the default folder Nuget used to put the references.
to change the default do the following:
<ul>
<li>Create a <code>nugget.config</code> file under the solution
<li>Put the following xml in it
<li>Add your nugget packages
</ul>
<pre>
<configuration>
<config>
<add key="repositoryPath" value="..\Bin\Packages" />
</config>
...
</configuration></pre>
That's it... you should see your references in a bin\packages folder.
(Tested in Visual Studio 2013)
</p>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-61418138817947105422014-04-12T14:09:00.000-07:002014-04-12T19:15:01.877-07:00Nuget - changing the default locationjust create a file called Nuget.config and put this inside
<configuration>
<config>
<add key="repositoryPath" value="..\Bin\Packages" />
</config>
</configuration>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-68935134926861541662014-04-12T04:30:00.003-07:002014-04-12T04:31:25.931-07:00A Good Database Resource (how to setup your environment for SQL sever and Oracle)If you want to debug SQL server stored procedure code, or if you want to debug Oracle stored procedures. I found this site to have all the right stuff.
<a href="http://database.ca/">Database.ca</a>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-44006628102673671882014-04-01T05:28:00.003-07:002014-04-13T05:00:07.964-07:00Some useful links<ul>
<li><a href="http://www.asp.net/web-api/overview/creating-web-apis/using-web-api-with-entity-framework/using-web-api-with-entity-framework,-part-5">A good example of Knockout JS</a></li>
<li><a href="http://www.ninject.org/">Ninject</a>
<li><a href="http://knockoutjs.com/">Knockout home page</a>
<li><a href="http://knockoutjs.com/documentation/plugins-mapping.html">Mapping with Knockout JS</a>
<li><a href="http://www.specflow.org/">Specflow</a>
<li><a href="http://modernizr.com">Modernizr.com</a>
<li><a href="http://html5boilerplate.com/">HTML5 Boilerplate</a>
<li><a href="http://www.html5canvastutorials.com/">HTML5 Canvas Tutorials</a>
<li><a href="http://www.w3schools.com/html/html5_svg.asp">SVG</a>
<li><a href="http://database.ca/">Database.ca</a>
</ul>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-24744449160870550652014-03-14T12:26:00.000-07:002014-03-14T12:29:40.833-07:00Really? there is no String.Truncate in C#...? so here is one...<pre>
public static class StringExtension
{
public static string Truncate(this string originalString, int maxSize)
{
// check for null
if (String.IsNullOrEmpty(originalString))
{
// return original
return originalString;
}
// validate the size
if (maxSize < 0)
{
throw new ApplicationException("Invalid maxSize for Truncating a string, value must be positive or zero");
}
if (originalString.Length > maxSize)
{
// trim it
return originalString.Substring(0, maxSize);
}
else
{
// return the original
return originalString;
}
}
}
</pre>
And the client code will look like this:
<pre>
string foo = "1234567890";
string newString = foo.Truncate(4);
</pre>Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0tag:blogger.com,1999:blog-9202309254227413537.post-44673590541828676712014-03-05T07:06:00.000-08:002014-03-05T07:06:54.699-08:00Accessing a file from a resourceThis is really simple, just I need to remember these little rules to get it to work. First the code of reading a text file from a resource looks like this:
<pre>
List<String> lines = new List<String>();
var assembly = Assembly.GetExecutingAssembly();
var stream = assembly.GetManifestResourceStream("MyNamepace.Resources.MyFile.txt");
var textStreamReader = new StreamReader(stream);
while (!textStreamReader.EndOfStream)
{
lines.Add(textStreamReader.ReadLine());
}
</pre>
<p>
Here are few points:
<p>
<ul>
<li>You can add the resource using the visual resource designer in your project properties</li>
<li>The resource id is the your project name space + any folder names it might be under (normally under a folder called Resource)</li>
<li>Make sure the file is an embedded resource, by right clicking on the file you can change its build actions</li>
</ul>
Mikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.com0