Milestones Professional Automation: C# Automation Example

Warning: The information on these pages should only be used by software developers who are familiar with a Windows programming environment. KIDASA does not take responsibility for any damage caused to your information or computer due to programming errors.

This is an example of using Milestones Professional’s OLE Automation interface with the C# programming language.

Contents of WebPage.ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebPage.aspx.cs" Inherits="WebPage" Debug="true" %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>

<p></p>Welcome to the Milestones C# Sample<p>
</p><img src=http://yourwebsite.com/images/samplex.png>

</div>

</form>
</body>
</html>


Contents of WebPage.aspx.cs:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Type oType = System.Type.GetTypeFromProgID("Milestones");

object o = System.Activator.CreateInstance(oType);

oType.InvokeMember("Activate", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { });
oType.InvokeMember("Use20Columns", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { });
oType.InvokeMember("PutCell", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "1", "1", "From ASP.NET" });
oType.InvokeMember("PutCell", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "2", "1", "&sysdate" });
oType.InvokeMember("PutCell", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "3", "1", "&systime" });
oType.InvokeMember("SaveBitmap", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { @"c:inetpubyourwebsite.comimagessamplex.png" });

oType.InvokeMember("Close", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "nosave"});

oType = null;
o = null;
}
}


Contents of web.config


<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>