本文整理汇总了C#中Application类的典型用法代码示例。如果您正苦于以下问题:C# Application类的具体用法?C# Application怎么用?C# Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于命名空间,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteWork
// The sheets of the workbook are:
// Sheet number 1: INPUTS
// Sheet number 2: OUTPUTS
// Sheet number 3: Cover
// Sheet number 4: Amendment Record
// Sheet number 5: Reference documents
// Sheet number 6: Introduction
// Sheet number 7: ETCS DMI inputs => to import
// Sheet number 8: ETCS DMI outputs => to import
// Sheet number 9: INPUT ITEMS
// Sheet number 10: OUTPUT ITEMS
// Sheet number 11: ANALYSIS
/// <summary>
/// Launches import of the excel file in the background task
/// </summary>
/// <param name="arg"></param>
public override void ExecuteWork()
{
if (TheDictionary != null)
{
Application application = new Application();
if (application != null)
{
Workbook workbook = application.Workbooks.Open(FileName);
if (workbook.Sheets.Count == 11)
{
Specification newSpecification = (Specification) acceptor.getFactory().createSpecification();
newSpecification.Name = "Start Stop Conditions";
TheDictionary.appendSpecifications(newSpecification);
Chapter newChapter = (Chapter) acceptor.getFactory().createChapter();
newChapter.setId("1 - DMI inputs");
newSpecification.appendChapters(newChapter);
Worksheet aWorksheet = workbook.Sheets[7] as Worksheet;
importParagraphs(newChapter, "1", aWorksheet);
newChapter = (Chapter) acceptor.getFactory().createChapter();
newChapter.setId("2 - DMI outputs");
newSpecification.appendChapters(newChapter);
aWorksheet = workbook.Sheets[8] as Worksheet;
importParagraphs(newChapter, "2", aWorksheet);
}
workbook.Close(false);
}
else
{
Log.ErrorFormat("Error while opening the excel file");
}
application.Quit();
}
}
示例2: Main
static void Main(string[] args)
{
try
{
Application oApp = null;
if (args.Length < 1)
oApp = new Application();
else
oApp = new Application(args[0]);
Application.SBO_Application.StatusBar.SetSystemMessage("Start installing UDO's", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
AddonInfoInfo.InstallUDOs();
Application.SBO_Application.StatusBar.SetSystemMessage("UDO's installed successfully", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
Menu MyMenu = new Menu();
AddonInfoInfo.SetFormFilter();
Application.SBO_Application.StatusBar.SetSystemMessage("Adding menus", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
MyMenu.AddMenuItems();
Application.SBO_Application.StatusBar.SetSystemMessage("Menus Added Successfully", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
Application.SBO_Application.StatusBar.SetSystemMessage("Register listeners", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
var bListeners = new ApplicationHandlers();
Application.SBO_Application.StatusBar.SetSystemMessage("Items Transfer Add-on installed successfully.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
oApp.Run();
}
catch (Exception ex)
{
Utilities.LogException(ex);
}
}
示例3: ExcelViewProvider
public ExcelViewProvider(Application excelApplication)
{
workbooks = new Dictionary<Workbook, List<Window>>();
this.excelApplication = excelApplication;
var monitor = new WorkbookClosedMonitor(excelApplication);
monitor.WorkbookClosed += MonitorWorkbookClosed;
}
示例4: ChannelsViewForm
private Mutex mutex = null; // синхронизатор
#endregion Fields
#region Constructors
public ChannelsViewForm(Application _app)
{
app = _app;
InitializeComponent();
mutex = new Mutex();
}
示例5: WordDocTargetHost
public WordDocTargetHost(Application app)
{
_app = app;
_app.DocumentOpen += OnMsWordDocumentOpen;
_app.DocumentBeforeClose += OnMsWordDocumentBeforeClose;
}
示例6: Main
static void Main(string[] args)
{
try
{
Application oApp = null;
if (args.Length < 1)
{
oApp = new Application();
}
else
{
oApp = new Application(args[0]);
}
Menu MyMenu = new Menu();
MyMenu.AddMenuItems();
oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent);
Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
// openGRPO();
// updateLandedCost();
//testLandedCost();
AddLandedCostXML();
oApp.Run();
}
catch (Exception ex)
{
//SAPbobsCOM.Company oCompany = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
//string s = oCompany.GetLastErrorDescription();
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
示例7: AddChildNodesToGroupTest
public void AddChildNodesToGroupTest()
{
Application application = new Application();
try
{
// Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
// wither null or actual application object.
ThisAddIn_Accessor.ExcelApplication = application;
Group childGroup = new Group("Earth", GroupType.ReferenceFrame, null);
Layer layer = new Layer();
layer.Name = "Layer1";
layer.Group = childGroup;
LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
localLayerMap.MapType = LayerMapType.Local;
GroupChildren groupChild = LayerMapExtensions_Accessor.AddChildNodesToGroup(localLayerMap);
Assert.AreEqual("Earth", groupChild.Name);
Assert.AreEqual(1, groupChild.AllChildren.Count);
Assert.AreEqual(1, groupChild.Layers.Count);
foreach (Layer layerVal in groupChild.Layers)
{
Assert.AreEqual("Layer1", layerVal.Name);
}
}
finally
{
application.Close();
}
}
示例8: Startup
static Startup()
{
CommandModel commandModel =
new CommandModel("sc").AddArgument("port", new CommandArgument("type", "number"))
.AddArgument("path", new CommandArgument("type", "string"))
.AddArgument("logs", new CommandArgument("type", "boolean"));
ApplicationOptions options;
try {
options = (ApplicationOptions)CommandLine.Parse(commandModel);
options.Port = Script.Or(options.Port, Number.ParseInt(Node.Process.Environment["PORT"]), 1337);
options.Path = Script.Or(options.Path, Node.Process.GetCurrentDirectory());
Runtime.EnableTrace = options.Logs;
}
catch (Exception e) {
Console.Log(e.Message);
Console.Log(commandModel.ToString());
return;
}
Application app = new Application(options);
app.Run();
}
示例9: ExportToExcel
public void ExportToExcel(object sender, EventArgs e)
{
var tableRow = _table.Rows;
//Open Excel and get worksheet
var app = new Application();
var workbook = app.Workbooks.Add();
var worksheet = workbook.Worksheets[1] as Microsoft.Office.Interop.Excel.Worksheet;
//Add headers
worksheet.Cells[1, 1] = "Reference #";
worksheet.Cells[1, 2] = "Part #";
worksheet.Cells[1, 3] = "Description | Serial #";
worksheet.Cells[1, 4] = "Quantity";
worksheet.Cells[1, 5] = "Additional Information";
for (int x = 0; x < _table.Rows.Count; x++)
{
worksheet.Cells[x + 2, 1] = tableRow[x].ItemArray[0];
worksheet.Cells[x + 2, 2] = tableRow[x].ItemArray[1];
worksheet.Cells[x + 2, 3] = tableRow[x].ItemArray[2];
worksheet.Cells[x + 2, 4] = tableRow[x].ItemArray[3];
worksheet.Cells[x + 2, 5] = tableRow[x].ItemArray[4];
}
//save
gvDetails.DataSource = _table;
gvDetails.DataBind();
HttpContext.Current.Session["name"] = _table;
//Response.WriteFile(workbook.SaveAs("C:\\test2.xlsx"));
}
示例10: TestDomainAdminAccessOtherDomain
public void TestDomainAdminAccessOtherDomain()
{
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
account.AdminLevel = eAdminLevel.hAdminLevelDomainAdmin;
account.Save();
SingletonProvider<TestSetup>.Instance.AddDomain("example.com");
var newApplication = new Application();
newApplication.Authenticate("[email protected]", "test");
Assert.AreEqual(1, newApplication.Domains.Count);
Domains domains = SingletonProvider<TestSetup>.Instance.GetApp().Domains;
Assert.AreEqual(2, domains.Count);
try
{
Domain secondDomain = newApplication.Domains.get_ItemByName("example.com");
Assert.Fail("Was able to access other domain.");
}
catch (COMException ex)
{
Assert.IsTrue(ex.Message.Contains("Invalid index."));
}
}
示例11: FirstWhileWaiting
public void FirstWhileWaiting()
{
var trigger = true;
var expected = TestHelper.CreateElement("Expected", "Expected");
var application = new Application(null);
var host = TestHelper.CreateMock<ElementHost>(application, null);
var element = TestHelper.CreateElement("Root", "Root", host.Object);
host.Object.Application.Timeout = TimeSpan.FromSeconds(1);
host.Setup(x => x.Refresh())
.Returns(() =>
{
trigger = !trigger;
if (trigger)
{
host.Object.Children.Add(expected);
}
return host.Object;
});
var actual = host.Object.First(expected.Id);
Assert.IsNotNull(actual);
Assert.AreEqual(expected, actual);
}
示例12: Initialize
public override void Initialize(ContentRepository.Content context, string backUri, Application application, object parameters)
{
base.Initialize(context, backUri, application, parameters);
//if (string.Compare(PortalContext.Current.AuthenticationMode, "windows", StringComparison.CurrentCultureIgnoreCase) != 0)
// this.Forbidden = true;
}
示例13: WordOpen
bool WordOpen(string file)
{
var tmp = CopyFile(file);
var application = new Application();
using (new ComRelease(application))
{
try
{
var documents = application.Documents;
using (new ComRelease(documents))
{
var document = documents.Open(tmp);
using (new ComRelease(document))
{
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
document.Close(ref saveChanges);
return true;
}
}
}
finally
{
application.Quit();
File.Delete(tmp);
}
}
}
示例14: Guards
public async void Guards()
{
Application application = new Application("OrchestrateApiKey");
var client = new Client(application);
var exception = await Assert.ThrowsAsync<ArgumentException>(
() => client.CreateCollectionAsync(string.Empty, string.Empty, string.Empty)
);
Assert.Equal("collectionName", exception.ParamName);
exception = await Assert.ThrowsAsync<ArgumentNullException>(
() => client.CreateCollectionAsync(null, string.Empty, string.Empty)
);
Assert.Equal("collectionName", exception.ParamName);
exception = await Assert.ThrowsAsync<ArgumentException>(
() => client.CreateCollectionAsync(collectionName, string.Empty, string.Empty)
);
Assert.Equal("key", exception.ParamName);
exception = await Assert.ThrowsAsync<ArgumentNullException>(
() => client.CreateCollectionAsync(collectionName, null, string.Empty)
);
Assert.Equal("key", exception.ParamName);
exception = await Assert.ThrowsAsync<ArgumentNullException>(
() => client.CreateCollectionAsync<object>(collectionName, "jguid", null)
);
Assert.Equal("item", exception.ParamName);
}
示例15: ImportDataFile
public void ImportDataFile(ClassDataFile file)
{
try
{
string newFileLoc = this.UpdateTemplate(file);
Application app = new Application();
Package package = null;
//Load the SSIS Package which will be executed
package = app.LoadPackage(newFileLoc, null);
//Pass the varibles into SSIS Package
//Execute the SSIS Package and store the Execution Result
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
//Check the results for Failure and Success
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
string err = "";
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
{
string error = local_DtsError.Description.ToString();
err = err + error;
}
}
}
catch (Exception ex)
{
throw ex;
}
}