Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Integrate Version Control to Your ECM Application

26 Mar 2013 1  
Integrate Version Control to Your ECM Application

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

SourceAnywhere is a SQL Server based version control tool. It is a light yet powerful tool designed for local and remote development teams. The tool provides different kinds of clients, including the GUI client, IDE plug-ins and the Java Client, in order to satisfy various requirements and to adapt to different development environments.

One of the version control clients, the SDK client of SourceAnywhere, allows you to embed the version control features - such as check-in, check-out, get, share, branch and more - into your own applications as well as incorporate file versioning to the workflow of your system automatically. For example, within an Enterprise content management (ECM) system, you can submit the documents to the source control database where the history changes of the files will be kept and specific versions can be retrieved as needed.

If you are interested in SourceAnywhere, the 30-day free trial can be downloaded from Dynamsoft’s website. The COM/Java SDK, along with the other clients, is available on the download page.

Key Features

  • Various source control clients, including the GUI client, SDK, and plug-ins for IDEs, are provided for access and management of your data.
  • Robust: be able to handle 500+ concurrent connections globally.
  • Efficient: unique caching mechanism to boost up the version control performance.
  • Secure: with SSL, Blowfish encryption, password policy and database encryption, your data is in good hands.

In this article, I’ll show you how to integrate SourceAnywhere to your own application and customize the version control operations.

1. Embed SourceAnywhere to your application

Let’s take a Visual Studio C# program as an example. In the Solution Explorer click menu Project | Add Reference | Browse, select "SAWSSDK.dll" in the installation folder of SourceAnywhere COM SDK and click OK.

2. Connect to the database

Call ConnectToServer to connect to the remote server. You can define the target server and whether or not to connect through the proxy server.

After successfully connecting to the server, you can specify your user name, password and the target database and repository in the Login property.

The following sample code will let you connect and access the demo server provided by Dynamsoft. The server and login info can be found below:

Server: demo.dynamsoft.com
Port: 7777

User name: dynamsoft1
Password: saw

You can also check out the SourceAnywhere Online Demo page to learn the details.

        private void Connect_Click(object sender, EventArgs e)
        {
            string ServerIP = "demo.dynamsoft.com";
            int ServerPort = 7777;
            bool OnlyTrial;
            SAWSSDKLib.Enum_EncryptType EncryptType;
            int LeftTrialDays;
            bool RealServer;
            bool Cancelled;
            string ResultDescription;
            string DBServerName;
            string DBName;

            long ResultValue;
            ResultValue = sdkObject.ConnectToServer(ServerIP, ServerPort, Enum_ProxyType.Enum_NOPROXY, "", 0, "", "", false, "", out EncryptType, out  OnlyTrial, out LeftTrialDays, out RealServer, out DBServerName, out DBName, out Cancelled, out ResultDescription);

            if (ResultValue != 0)
                MessageBox.Show("Failed to connect to server");
            else
            {
                SAWSSDKLib.SAWSKeyFileSet KeyFileSet = new SAWSKeyFileSet();
                bool MustChangePassword;
                int DayOfExpiration;

                long ResultValue1;
                ResultValue1 = sdkObject.Login("dynamsoft1", "saw", "demo.dynamsoft.com", "default", KeyFileSet, out MustChangePassword, out DayOfExpiration, out Cancelled, out ResultDescription);

                if (ResultValue1 != 0)
                    MessageBox.Show("Failed to log in");
                else
                    MessageBox.Show("Log in successfully");

            }
        }

3. Check out a file

After connecting to the server, the following sample code enables you to check out the file "$/test/local.txt" from the version control tool. Use CheckOutFile.LocalFileName to define the check out folder.

        private void CheckOut_Click(object sender, EventArgs e)
        {
            SAWSSDKLib.SAWSCheckoutFileSet CheckOutFileSet = new SAWSCheckoutFileSet();
            SAWSSDKLib.SAWSDiffMergeParam MergeParam = new SAWSDiffMergeParam();
            bool Cancelled;
            string ResultDiscription;
            SAWSSDKLib.SAWSOperationResultSet OperationResultSet = new SAWSOperationResultSet();

            SAWSSDKLib.SAWSCheckoutFile CheckOutFile = new SAWSCheckoutFile();
            CheckOutFile.FileToCheckout = "$/test/local.txt";
            CheckOutFile.LocalFileName = "D:\\Temp\\1.txt";
            CheckOutFileSet.Add(CheckOutFile);

            long ResultValue;
            ResultValue = sdkObject.CheckoutFiles(CheckOutFileSet, true, "", false, Enum_ModifiedFileHandling.Enum_AskModifiedFile, Enum_EOL.Enum_EOLNative, Enum_CompareFileBy.Enum_CompareFileByChecksum, Enum_SetLocalFileTime.Enum_SetLocalFileTimeModification, MergeParam, out Cancelled, out ResultDiscription, out OperationResultSet);

            if (ResultValue != 0)
                MessageBox.Show("Check out failed");
            else
                MessageBox.Show("Check out successfully");
        }

4. Check in a file

After modifying the checked out file, you can use CheckInFiles to check in the file from your folder.

CheckInFile.FileToCheckin specifies the file planned to be checked in. CheckInFile.LocalFileName specifies the check out folder.

        private void CheckIn_Click(object sender, EventArgs e)
        {
            SAWSSDKLib.SAWSCheckinFileSet CheckinFileSet = new SAWSCheckinFileSet();
            SAWSSDKLib.SAWSCheckinFile CheckInFile = new SAWSCheckinFile();
            CheckInFile.FileToCheckin = "$/test/local.txt";
            CheckInFile.LocalFileName = "D:\\temp\\1.txt";
            CheckinFileSet.Add(CheckInFile);

            SAWSSDKLib.SAWSDiffMergeParam MergeParam = new SAWSDiffMergeParam();
            bool Cancelled;
            string ResultDescription;
            SAWSSDKLib.SAWSOperationResultSet OperationResultSet = new SAWSOperationResultSet();

            long ResultValue;
            ResultValue = sdkObject.CheckInFiles(CheckinFileSet, false, false, Enum_CompareFileBy.Enum_CompareFileByChecksum, Enum_EOL.Enum_EOLNative, true, false, Enum_SetLocalFileTime.Enum_SetLocalFileTimeModification, Enum_CheckinUnchangedFileHandling.Enum_AskCheckinUnchangedFile, "", MergeParam, out Cancelled, out ResultDescription, out OperationResultSet);

            if (ResultValue != 0)
                MessageBox.Show("Check in failed");
            else
                MessageBox.Show("Check in successfully.");
        }

Besides the features showed above, operations, such as Label, Show History, Share and Branch, are also supported by the SourceAnywhere SDK Client. You can fully customize the application based on your requirements.

Resource

To play with the SDK by yourself, you can download the 30-day free trial from Dynamsoft’s website.

SourceAnywhere 30-Day Free Trial

The online demo is also available for you.

SourceAnywhere Guide & Online Demo

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here