initial oogynize check in _ this actually used to work!

This commit is contained in:
2016-02-14 21:16:31 -08:00
parent b183af5d55
commit 532ea133bc
337 changed files with 30692 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Foo.WorkspaceMgr.Launchers
{
internal interface ILaunch
{
FuncDepBoolType IQueryLaunch(string strArtifactLocation);
FuncDepBoolType ILaunch(string strArtifactLocation);
}
}

View File

@@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Foo.Platform.Win32;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;
namespace Foo.WorkspaceMgr.Launchers
{
internal class Launcher_Excel : ILaunch
{
#region ILaunch Members
/// <summary>
/// Checks to see if the file exists in the system i.e. can be reached over
/// the network. if FileExists fails, we shouldn't be able to launch it.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
if (File.Exists(strArtifactLocation))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.ArtifactLocationUnavailable;
}
else
{
return FuncDepBoolType.ParametersInvalid;
}
}
public const string Excel_ProgId = "Excel.Application";
/// <summary>
/// Generic Launcher should be able to handle any file type. Launched the .Net Way.
/// ~this is the same as if the User clicks on the file.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType ILaunch(string strArtifactLocation)
{
Microsoft.Office.Interop.Excel.Application app = null;
app = new Microsoft.Office.Interop.Excel.Application();
// Mark the Application as visible
app.Visible = true;
app.Workbooks.Open(strArtifactLocation, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value );
// Keep Track of all our Excel Instances
///WorkspaceState.Launched_ExcelInstances.Add(app);
return FuncDepBoolType.Success;
//if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
//{
// Process.Start(strArtifactLocation);
//}
//return FuncDepBoolType.ParametersInvalid;
}
#endregion
///// <summary>
///// To Do : Test This - Let's us know if the user has unsaved data
///// </summary>
///// <param name="strArtifactLocation"></param>
///// <returns></returns>
//public FuncDepBoolType QueryClose_MSExcel(string strArtifactLocation)
//{
// try
// {
// foreach (Microsoft.Office.Interop.Excel.Workbook book in app.Workbooks)
// {
// if (book.FullName.ToLower() == strArtifactLocation.ToLower())
// {
// if (book.Saved)
// return FuncDepBoolType.Success;
// else
// return FuncDepBoolType.Failed;
// }
// }
// }
// catch (Exception e)
// {
// string message = e.Message;
// message = message + "";
// // TODO: Log Something here
// return FuncDepBoolType.ErrorThrown;
// }
// return FuncDepBoolType.Failed;
//}
///// <summary>
///// *** Technically ** Here we want to close the Excel Workbook (Not Prompt the user at all)
///// **** we could close it with a WM_CLOSE or WM_SCLOSE or with the DOM. ~for now it's the
///// DOM, however more testing to be done here
///// </summary>
///// <param name="strArtifactLocation"></param>
///// <returns></returns>
//public FuncDepBoolType Close_MSExcel(string strArtifactLocation)
//{
// try
// {
// Microsoft.Office.Interop.Excel.Application app = null;
// app = Win32Functions.GetCOMObject(Excel_ProgId) as Microsoft.Office.Interop.Excel.Application;
// // For Debugging
// //int nCount = app.Workbooks.Count;
// foreach (Microsoft.Office.Interop.Excel.Workbook book in app.Workbooks)
// {
// if (book.FullName.ToLower() == strArtifactLocation.ToLower())
// {
// book.Close(true, strArtifactLocation, false);
// // Close Excel if this is the last Workbook
// if (app.Workbooks.Count == 0)
// app.Quit();
// return FuncDepBoolType.Success;
// }
// }
// }
// catch (Exception e)
// {
// string message = e.Message;
// message = message + "";
// // TODO: Log Something here
// return FuncDepBoolType.ErrorThrown;
// }
// return FuncDepBoolType.Failed;
//}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Foo.Platform.Win32;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Foo.WorkspaceMgr.Launchers
{
internal class Launcher_Generic : ILaunch
{
#region ILaunch Members
/// <summary>
/// Checks to see if the file exists in the system i.e. can be reached over
/// the network. if FileExists fails, we shouldn't be able to launch it.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
if (File.Exists(strArtifactLocation))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.ArtifactLocationUnavailable;
}
else
{
return FuncDepBoolType.ParametersInvalid;
}
}
/// <summary>
/// Generic Launcher should be able to handle any file type. Launched the .Net Way.
/// ~this is the same as if the User clicks on the file.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType ILaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
Process.Start(strArtifactLocation);
return FuncDepBoolType.Success;
}
return FuncDepBoolType.ParametersInvalid;
}
#endregion
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Foo.Platform.Win32;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Foo.WorkspaceMgr.Launchers
{
internal class Launcher_Shell : ILaunch
{
#region ILaunch Members
/// <summary>
/// Checks to see if the file exists in the system i.e. can be reached over
/// the network. if FileExists fails, we shouldn't be able to launch it.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
if (File.Exists(strArtifactLocation))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.ArtifactLocationUnavailable;
}
else
{
return FuncDepBoolType.ParametersInvalid;
}
}
/// <summary>
/// Generic Launcher should be able to handle any file type using Shell Execute
/// ~This is NOT the same as Process.start(). When using ShellExecute, Excel workbooks
/// launch in a different window (and for some reason Don't SHOW UP in the Excel DOM)
/// ~this is why this is broken out (more testing is needed)
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType ILaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
// Shellexecute works almost just like process.start except for the limitation
// mentioned:
// We could do process start but doing so means all excel docs open in the same
// excel window (just like powerpoint does) ~this may or may not be desirable
// ~excel docs won't show in the DOM, after being launched this way ~ - very odd
bool bIsValidExe = false;
string strExeOrDllPath = string.Empty;
bool bFound = Win32_WrapperFunc.FindExeOrDll(strArtifactLocation, out strExeOrDllPath, out bIsValidExe);
const int SEE_MASK_NOCLOSEPROCESS = 0x40;
ShellExecuteInfo sei = new ShellExecuteInfo();
sei.cbSize = Marshal.SizeOf(sei);
sei.lpVerb = "open";
sei.lpParameters = '\"' + strArtifactLocation + '\"';
sei.nShow = (int)WindowAction.SW_SHOWNORMAL;
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
// Use Shell32 or Explorer to launch the artifact
if (bFound && bIsValidExe)
sei.lpFile = strExeOrDllPath;
else
sei.lpFile = '\"' + Win32_WrapperFunc.GetWindowsPath() + "\\explorer.exe" + '\"';
if (Win32Functions.ShellExecuteEx(ref sei))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.Failed;
}
return FuncDepBoolType.ParametersInvalid;
}
#endregion
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Foo.Platform.Win32;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;
namespace Foo.WorkspaceMgr.Launchers
{
internal class Launcher_Visio : ILaunch
{
#region ILaunch Members
/// <summary>
/// Checks to see if the file exists in the system i.e. can be reached over
/// the network. if FileExists fails, we shouldn't be able to launch it.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
if (File.Exists(strArtifactLocation))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.ArtifactLocationUnavailable;
}
else
{
return FuncDepBoolType.ParametersInvalid;
}
}
public const string Excel_ProgId = "Visio.Application";
/// <summary>
/// Generic Launcher should be able to handle any file type. Launched the .Net Way.
/// ~this is the same as if the User clicks on the file.
/// </summary>
/// <param name="strArtifactLocation">location of the path + file to launch</param>
/// <returns></returns>
public FuncDepBoolType ILaunch(string strArtifactLocation)
{
Microsoft.Office.Interop.Visio.Application app = null;
app = new Microsoft.Office.Interop.Visio.Application();
// Mark the Application as visible
app.Visible = true;
app.Documents.Open(strArtifactLocation);
// Keep Track of all our Excel Instances
///WorkspaceState.Launched_ExcelInstances.Add(app);
return FuncDepBoolType.Success;
//if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
//{
// Process.Start(strArtifactLocation);
//}
//return FuncDepBoolType.ParametersInvalid;
}
#endregion
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Foo.WorkspaceMgr.Launchers
{
class Launcher_Web : ILaunch
{
#region ILaunch Members
/// <summary>
/// Checks to see if the url is valid
/// ~~( We could even check if the webpage is available here!!!) ~to do later?
/// </summary>
/// <param name="strArtifactLocation">url to launch</param>
/// <returns></returns>
public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
if (Uri.IsWellFormedUriString(strArtifactLocation, UriKind.Absolute))
return FuncDepBoolType.Success;
else
return FuncDepBoolType.Failed;
}
return FuncDepBoolType.ParametersInvalid;
}
/// <summary>
/// Generic Launcher should be able to handle any url type
/// </summary>
/// <param name="strArtifactLocation">url to launch</param>
public FuncDepBoolType ILaunch(string strArtifactLocation)
{
if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
{
Process.Start(strArtifactLocation);
return FuncDepBoolType.Success;
}
return FuncDepBoolType.ParametersInvalid;
}
#endregion
}
}