/// <summary> /// Creates the app item. /// </summary> /// <param name="_appUnit">The application unit.</param> /// <returns></returns> private ListViewItem CreateAppItem(ApplicationUnit _appUnit) { ListViewItem item = null; try { if (_appUnit == null) { return(item); } Image img = ExtractAppIcon(_appUnit.Path); item = new ListViewItem(); item.Text = _appUnit.Label; item.Tag = _appUnit; if (img != null) { imageList.Images.Add(img); item.ImageIndex = imageList.Images.Count - 1; } } catch (Exception exp) { Logger.WriteError(exp, "3d1874d7-8be3-46dc-98ff-3c1f67dfbcd1"); } return(item); }
/// <summary> /// Runs the as2. /// </summary> private void RunAs2() { try { AdminEntity admin = new AdminEntity(m_sEncEntity); ApplicationUnit appUnit = null; string sWorkingDirectory = string.Empty; if (listView.SelectedItems.Count > 0) { appUnit = (ApplicationUnit)listView.SelectedItems[0].Tag; } if (appUnit == null) { return; } ProcessStartInfo myProcess = new ProcessStartInfo(appUnit.Path); if (string.IsNullOrEmpty(admin.Domain) == false) { myProcess.Domain = admin.Domain; } sWorkingDirectory = Path.GetDirectoryName(appUnit.Path); myProcess.UseShellExecute = false; myProcess.LoadUserProfile = true; myProcess.UserName = admin.UserName; myProcess.Password = admin.PwdToSecureString(); myProcess.Arguments = appUnit.Params; myProcess.WorkingDirectory = sWorkingDirectory; Process.Start(myProcess); if (checkBox_CloseWhenRun.Checked == true) { button_Exit_Click(null, null); } } catch (Exception exp) { Logger.WriteError(exp, "6645a4a8-bab8-4643-af3b-7312bf00e240"); } }
/// <summary> /// Adds the item to list view. /// </summary> /// <param name="_appUnit">The application unit.</param> private void AddItemToListView(ApplicationUnit _appUnit) { try { if (_appUnit != null) { ListViewItem item = CreateAppItem(_appUnit); if (item != null) { listView.Items.Add(item); } } } catch (Exception exp) { Logger.WriteError(exp, "7105d17e-8d8a-44bf-9e23-3deacf064c95"); } }
/// <summary> /// Handles the Click event of the button_Add control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void button_Add_Click(object sender, EventArgs e) { try { if (CanDoAction() == false) { return; } using (AddAppForm addForm = new AddAppForm()) { if (addForm.ShowDialog(this) == DialogResult.OK) { ApplicationUnit appUnit = addForm.ApplicationUnit; AddItemToListView(appUnit); } } } catch (Exception exp) { Logger.WriteError(exp, "80ce4d8a-2d4a-434c-9edb-3560a62b7956"); } }