我有一个在系统启动后立即启动的移动应用程序(用于 Windows Mobile 6.1 的 .NET CF2)。
我想强制加载表单,然后他们调用 Web 服务。还有一个手动调用 WS 的按钮。
到目前为止,我还没有设法首先加载表单。首先,它调用服务,然后它们显示表单。
你能帮助我吗?
下面是我正在使用的代码。
//APP主窗体
使用系统;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
namespace AtualizaColetores
{
public partial class frmInicio : Form
{
public frmInicio()
{
InitializeComponent();
Program.ShowHide.ShowTopStatusbar(false);
ThreadPool.QueueUserWorkItem(delegate
{
Thread.Sleep(1000);
//incia animação para indicar processamento em segundo plano
Cursor.Current = Cursors.WaitCursor;
Cursor.Show();
Atualizador executar = new Atualizador();
executar.AtualizaColetor();
});
try
{
Process firstProc = new Process();
firstProc.StartInfo.FileName = @"\WOPT\RF_WOPT.exe";
firstProc.EnableRaisingEvents = true;
firstProc.Start();
firstProc.WaitForExit();
this.Activate();
Form destino = new frmControles();
destino.Show();
}
catch (Exception ex)
{
MessageBox.Show("Erro na incialização do programa: " + ex.Message);
return;
}
//Para a animação para indicar processamento em segundo plano
Cursor.Current = Cursors.Default;
Cursor.Show();
}
}
}
//此处的中心代码ODE下载并替换应用程序的当前版本,如果需要的话
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using Ionic.Zip;
namespace AtualizaColetores
{
class Atualizador
{
public void AtualizaColetor()
{
if (File.Exists(@"\WOPT\About.xml"))
{
string versaoAplicativo = "", LocalAplicativo = "", tipoColetor = "";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"\WOPT\About.xml");
XmlNodeList xnList = xmlDoc.GetElementsByTagName("VersaoRF");
foreach (XmlNode xn in xnList)
{
versaoAplicativo = xn["versaoAplicativo"].InnerText;
LocalAplicativo = xn["localAplicativo"].InnerText;
tipoColetor = xn["tipoColetor"].InnerText;
}
ConectorWOPT.WOPT executar = new ConectorWOPT.WOPT();
//inserir tratamento de erro aqui.
byte[] arquivo = executar.AtualizaColetores(LocalAplicativo, versaoAplicativo, tipoColetor);
string caminhoWOPT = @"\WOPT";
if (arquivo.Length > 0)
{
try
{
MemoryStream ms = new MemoryStream(arquivo);
FileStream fs = new FileStream(
@"\novaVersao.zip", FileMode.Create);
ms.WriteTo(fs);
ms.Close();
fs.Close();
fs = null;
ms = null;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
if (System.IO.Directory.Exists(caminhoWOPT))
{
try
{
System.IO.Directory.Delete(caminhoWOPT, true);
if (!System.IO.File.Exists(caminhoWOPT))
{
System.IO.Directory.CreateDirectory(caminhoWOPT);
}
}
catch (IOException e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
}
if (File.Exists(@"\novaVersao.zip"))
{
using (ZipFile zip = ZipFile.Read(@"\novaVersao.zip"))
{
foreach (ZipEntry e in zip)
{
e.Extract(@"\WOPT\", ExtractExistingFileAction.OverwriteSilently); // overwrite == true
}
}
System.IO.File.Delete(@"\novaVersao.zip");
System.Windows.Forms.MessageBox.Show("Coletor atualizado com sucesso");
}
else
{
System.Windows.Forms.MessageBox.Show("Falha na atualização");
}
}
}
else
{
System.Windows.Forms.MessageBox.Show("O aplicativo não está instalado neste coletor. Contate um supervisor.");
}
}
}
}