SvnBackup - Backup Tool For Subversion Repositories

Overview

The SvnBackup command line tool is used to create backup copies of your subversion repositories. The source code is the life blood of your application. Keeping the source repository backed up is major part in keeping your team going in case something goes wrong with your repository.

Features

  • Backup repository using hotcopy command
  • Backup folder management
  • Support repository parent directory
  • Keep x number of backups
  • Compress backups

Backup Process

SvnBackup follows the recommend way of backing up your subversion repository. While you can xcopy your repository, it may not always be the safest. SvnBackup automates the process by using svnadmin hotcopy command. The hotcopy command is the only safe way to make a backup copy of your repository.

SvnBackup also support starting from a parent folder that has all your repositories. The tool will loop through all the repositories in that folder backing each up. The following folder layout contains imaginary repositories: calculator, calendar, and spreadsheet.

repo/
   calculator/
   calendar/
   spreadsheet/

The backups are stored in a root backup folder. SvnBackup will create a subfolder for each repository. Then it will create a folder for the current revision being backed up. The hotcopy will be placed in the revision folder. This allows you to keep multiple backup versions of your repository. The following is an example of the backup folder structure created by SvnBackup.

backup/
   calculator/
      v0000001/
      v0000008/
      v0000017/
   calendar/
      v0000001/
      v0000014/
      v0000127/
   spreadsheet/
      v0000001/
      v0000023/
      v0000047/

SvnBackup supports pruning your backups to only keep so many. For example, you can keep the last 10 backups.

Another feature of SvnBackup is to compress the backup. If you have a lot of repositories, zipping up the backup can save a lot of space.

Command Line Options

SvnBackup.exe /r:<directory> /b:<directory> /c

     - BACKUP OPTIONS -

/history:<int>        Number of backups to keep. (/n)
/compress             Compress backup folders. (/c)
/repository:<string>  Repository root folder. (/r)
/backup:<string>      Backup root folder. (/b)
/svn:<string>         Path to subversion bin folder. (/s)

Project Page


Caching the results from LinqDataSource

I wanted to be able to cache the results of a query from the LinqDataSource that was used in multiple places on the page.  I whipped up this little class to do the work of caching for me.  The class, LinqCacheDataSource, handles the Selecting and Selected events.  The Selected handler inserts the result of the query into cache.  The Selecting handler gets the result from the cache.  If it doesn’t find the result, the query runs as normal.  The caching will only work for selecting data.  It works great for dropdowns and other fairly static data.

The Code …

/// <summary>
/// A LinqDataSource that provides caching for Linq queries.
/// </summary>
public class LinqCacheDataSource : LinqDataSource
{
    /// <summary>
    /// Initializes a new instance of the <see cref="LinqCacheDataSource"/> class.
    /// </summary>
    public LinqCacheDataSource()
        : base()
    {
        this.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(OnSelecting);
        this.Selected += new EventHandler<LinqDataSourceStatusEventArgs>(OnSelected);
    }
 
    private void OnSelecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        if (!EnableCache)
            return;
 
        string key = GetKey();
        object source = Context.Cache[key];
        if (source == null)
            return;
 
        Debug.WriteLine("Cache Hit: " + key);
        e.Result = source;
    }
 
    private void OnSelected(object sender, LinqDataSourceStatusEventArgs e)
    {
        if (!EnableCache)
            return;
 
        if (e.Exception != null || e.Result == null)
            return;
 
        string key = GetKey();
        object source = Context.Cache[key];
        if (source != null)
            return;
 
        Debug.WriteLine("Cache Insert: " + key);
        Context.Cache.Insert(key, e.Result, null,
            DateTime.Now.AddSeconds(Duration), Cache.NoSlidingExpiration);
    }
 
    private string GetKey()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append(this.ContextTypeName);
        sb.Append(" from ");
        sb.Append(this.TableName);
 
        if (!string.IsNullOrEmpty(this.Select))
        {
            sb.Append(" select ");
            sb.Append(this.Select);
        }
        if (!string.IsNullOrEmpty(this.Where))
        {
            sb.Append(" where ");
            sb.Append(this.Where);
        }
        if (!string.IsNullOrEmpty(this.OrderBy))
        {
            sb.Append(" OrderBy ");
            sb.Append(this.OrderBy);
        }
        return sb.ToString();
    }
 
    /// <summary>
    /// Gets or sets a value indicating whether query caching is enabled.
    /// </summary>
    [DefaultValue(true)]
    [Category("Cache")]
    [Description("Enable caching the linq query result.")]
    public bool EnableCache
    {
        get
        {
            object result = this.ViewState["EnableCache"];
            if (result != null)
                return (bool)result;
 
            return true;
        }
        set
        {
            this.ViewState["EnableCache"] = value;
        }
    }
 
    /// <summary>
    /// Gets or sets the time, in seconds, that the query is cached.
    /// </summary>
    [DefaultValue(30)]
    [Category("Cache")]
    [Description("The time, in seconds, that the query is cached.")]
    public int Duration
    {
        get
        {
            object result = this.ViewState["Duration"];
            if (result != null)
                return (int)result;
 
            return 30;
        }
        set
        {
            this.ViewState["Duration"] = value;
        }
    }
} 

PLINQO - CodeSmith LINQ to SQL Templates

PLINQO, which stands for Professional LINQ to Objects, is a collection of CodeSmith templates that are meant to replace and extend the LINQ to SQL designers that are included with Visual Studio 2008.

Features

  • Generate or update a LINQ to SQL dbml file from a database schema.
    • Includes all tables, stored procedures, functions, and views with the ability to exclude objects based on regex patterns.
    • Ability to automatically remove object prefix and suffixes (ie. tbl_ and usp_).
    • Dbml file can still be customized with the normal Visual Studio 2008 designer.
    • Dbml file can be refreshed based on the current database schema without losing customizations. (See Safe Attributes)
  • Generation of the LINQ to SQL DataContext class.
  • Generation of the LINQ to SQL entity classes.
    • Generates one file per entity instead of one massive file.
    • Generates partial classes where custom code can be written and won’t be overwritten.
    • Generated entity files are added to the project as code behind files to their corresponding custom entity files.
  • Generation of entity manager classes.
    • Adds customizable business rules engine to enforce entity validation, business and security rules.
    • Provides access to common queries based on primary keys, foreign keys, and indexes.
    • Common queries are exposed as IQueryable so they can be extended.
  • All templates can be customized to meet your needs.

Read More

http://community.codesmithtools.com/blogs/pwelter/archive/2007/08/08/plinqo.aspx

Download

http://www.codeplex.com/codesmith/Release/ProjectReleases.aspx


Easier way to page Linq queries.

The following query extension will make paging a query more natural then skip and take. Simply append Paginate(page, pageSize) to your query.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Linq
{
    public static class PageQuery
    {
         public static IQueryable<T> Paginate<T>(
            this IQueryable<T> query, int page, int pageSize)
        {
            int skip = Math.Max(pageSize * (page - 1), 0);
            return query.Skip(skip).Take(pageSize);
        }
    }
} 

Calculator.NET - Calculator that evaluates math expressions

I’d like to announce the release of a little project I’ve been working on. I call it Calculator.NET. I started this project for a couple reasons. First, I was annoyed that Windows Vista doesn’t come with a better calculator. Windows XP has Power Calculator, but that doesn’t work on Vista. Next, I was reading a blog about DynCalc by Bart De Smet on how to do mathematical calculations. That gave me the starting point on how to create Calculator.NET.

As part of the project, I created a MathExpressions library that does the bulk of work. The library supports math expressions, functions unit conversion and variables. Below are some examples of using the library directly.

MathEvaluator eval = new MathEvaluator();
//basic math
double result = eval.Evaluate("(2 + 1) * (1 + 2)");
//calling a function
result = eval.Evaluate("sqrt(4)");
//evaluate trigonometric 
result = eval.Evaluate("cos(pi * 45 / 180.0)");
//convert inches to feet
result = eval.Evaluate("12 [in->ft]");
//use variable
result = eval.Evaluate("answer * 10");
//add variable
eval.Variables.Add("x", 10);
result = eval.Evaluate("x * 10");

Calculator that evaluates math expressions.

Calculator.NET

Calculator.NET Features

  • Evaluate math expressions including grouping
  • Support trigonometry and other function
  • Common unit conversion of the following types
    • Length
    • Mass
    • Speed
    • Temperature
    • Time
    • Volume
  • Variable support including last answer

Download

https://github.com/loresoft/Calculator/releases