//************************************************************ //** 조회 버튼 Click //************************************************************ public void BtnSearch_Click() { try { con = Utility.SetOracleConnection(); OracleCommand cmd = con.CreateCommand(); cmd.CommandText = SQLStatement.SelectSQL1; cmd.Parameters.Add("bas_empno", OracleDbType.Varchar2).Value = sel_bas_empno.Text + "%"; cmd.Parameters.Add("bas_name", OracleDbType.Varchar2).Value = sel_bas_name.Text + "%"; cmd.Parameters.Add("bas_dept", OracleDbType.Varchar2).Value = Utility.GetCode(sel_bas_dept.Text) + "%"; cmd.Parameters.Add("bas_pos", OracleDbType.Varchar2).Value = sel_bas_pos.Text + "%"; OracleDataAdapter da = new OracleDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "TAB"); dataGrid2.ItemsSource = ds.Tables["TAB"].DefaultView; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { if (con != null) { con.Close(); } } myViewModel?.Clear(); sel_bas_empno.Text = ""; sel_bas_name.Text = ""; Utility.SetFuncBtn(MainBtn, "0"); }
public static void Load(GeneralSettings generalSettings, BindingList<Action> actions, string fileName) { var lines = new List<string>(); using (var stream = new StreamReader(fileName)) { string line; while ((line = stream.ReadLine()) != null) { lines.Add(line); } } var generalSettingsSections = GetSections(Strings.GeneralSettings, lines); var actionSections = GetSections(Strings.Action, lines); if (generalSettingsSections.Count > 0) { generalSettings.LoadFromStringList(generalSettingsSections[0]); } actions.Clear(); foreach (var actionSection in actionSections) { var action = Action.CreateFromActionName(actionSection); actions.Add(action); } }
private void GenerateFieldMappings(CancellationToken cancel, IProgress <ExecutionProgress> progress) { progress?.Report(new ExecutionProgress(NotificationType.Information, Properties.Resources.Dynamics365FieldOperationGenerateMappingsReadingDataSourceFields)); List <DataTableField> sourceFields = DataTableField.GetDataTableFields(DataSource?.GetDataColumns()); cancel.ThrowIfCancellationRequested(); progress?.Report(new ExecutionProgress(NotificationType.Information, Properties.Resources.Dynamics365FieldOperationGenerateMappingsReadingEntityFields)); List <Field> destinationFields = Entity.GetFields(Connection).Where(field => ((Dynamics365Field)field).CanUpdate || ((Dynamics365Field)field).CanCreate).ToList(); cancel.ThrowIfCancellationRequested(); values?.Clear(); foreach (DataTableField sourceField in sourceFields) { // Formats to match: // fieldLogicalName // entityLogicalName.fieldLogicalName // entityLogicalName.fieldLogicalName.Identifier // entityLogicalName.fieldLogicalName.Code // FieldDisplayName // FieldDisplayName (<other text>) // FieldDisplayName (Identifier) // FieldDisplayName (Code) string strippedColumnName = sourceField.ColumnName; if (strippedColumnName.EndsWith(".Identifier") || strippedColumnName.EndsWith(".Code")) { strippedColumnName = strippedColumnName.Substring(0, strippedColumnName.LastIndexOf(".")); } else if (strippedColumnName.EndsWith(" (Identifier)") || strippedColumnName.EndsWith(" (Code)")) { strippedColumnName = strippedColumnName.Substring(0, strippedColumnName.LastIndexOf(" ")); } // todo - also add option set support if just name is supplied Dynamics365Field destinationField = (Dynamics365Field)destinationFields.Find(field => strippedColumnName == ((Dynamics365Field)field).LogicalName || strippedColumnName == string.Concat(((Dynamics365Field)field).EntityLogicalName, ".", ((Dynamics365Field)field).LogicalName) || strippedColumnName == ((Dynamics365Field)field).DisplayName); if (destinationField != default(Dynamics365Field)) { // todo - use other fields ('name', 'entity') to correct set target and possibly create lookup data field values.Add(new Dynamics365DataSourceValue(this) { DestinationField = destinationField, SourceField = sourceField }); } cancel.ThrowIfCancellationRequested(); } progress?.Report(new ExecutionProgress(NotificationType.Information, string.Format(Properties.Resources.Dynamics365FieldOperationGenerateMappingsSuccessful, values.Count))); }
private void Reset() { startStopGaButton.Text = START_GA_BUTTON_TEXT; currentFunction = CurrentGaButtonFunction.Start; geneticAlgorithm = null; savedGaPopulations?.Clear(); displayPopulation = Population <PolygonIndividual, IPolygonGene> .EmptyPopulation(); logLines.Clear(); continueButton.Visible = false; ignoreTerminationConditionsAbsence = false; }
public Form1() { InitializeComponent(); FormClosing += new FormClosingEventHandler(Form1_FormClosing); _configuration = new BindingList<IPConfiguration>(); _configuration.Clear(); foreach (var s in Properties.Settings.Default.ConfigurationStrings ) { var cmd = new CmdLineHelper(); cmd.ParseString(s); var config = new IPConfiguration(); config.Configure(cmd); _configuration.Add(config); } UpdateContextMenu(); }
public MainViewModel() { if (MainViewModel.instance == null) { Width = 525; Height = 350; Threads = new BindingList<DownloadThread>(); fetch = new DelegateCommand<object>((s) => { Threads.Clear(); DownloadThread.Clear(); Downloader.count = 0; new DownloadThread(RootURL); }, (s) => { return !string.IsNullOrWhiteSpace(RootURL); }); RootURL = "http://www.apple.com"; MainViewModel.Instance = this; } else throw new Exception("There can only be one!!!!!"); }
private void ClearBtn_Click(object sender, EventArgs e) { _projectsDataSource.Clear(); _languages.Clear(); ReloadProjects(); }
//************************************************************ //** 조회 버튼 Click //************************************************************ public void BtnSearch_Click() { if (authority.Read.Equals("0")) { Utility.MsgAuthorityViolation("조회"); return; } myViewModel?.Clear(); //--DB Handling(Start)------------------------------------- try { con = Utility.SetOracleConnection(); OracleCommand cmd = con.CreateCommand(); cmd.CommandText = SQLStatement.SelectSQL; cmd.Parameters.Add("papp_appno", OracleDbType.Varchar2).Value = searchText.Text + "%"; OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { var data = new UcSubC17ViewModel { Papr_appno = dr.GetString(0), Papr_content = dr.GetString(1), Papr_num = Convert.ToInt32(dr.GetString(2)), Papr_date = dr.IsDBNull(3) ? "" : Utility.FormatDate(dr.GetString(3)), Key1 = dr.GetString(0), DataStatus = "" }; myViewModel.Add(data); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { if (con != null) { con.Close(); } } //--DB Handling(End)------------------------------------- SearchCount.Text = myViewModel.Count.ToString(); if (myViewModel.Count == 0) { UserMessage.Text = "조건을 만족하는 자료가 없습니다."; Utility.SetFuncBtn(MainBtn, "1"); return; } { UserMessage.Text = "자료가 정상적으로 조회 되었습니다."; //**-개인정보 조회 Loging---------------------------- if (PersonalInfo.Equals("1")) { Utility.PersonalInfo_Logging(UserId, UserNm, MyIpAddress, ProgramName, "조회", myViewModel.Count); } Utility.SelectingFocusingGridControl(dataGrid, tableView, 0); Utility.SetFuncBtn(MainBtn, "2"); } }
private void btClAll_Click(object sender, EventArgs e) { ClFild(); liststudents1?.Clear(); MessageBox.Show("Очищено", "Список студентов", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void Rechts_Click(object sender, EventArgs e) { _gekozenItems.AddRange(_htmlItemsList); _htmlItemsList.Clear(); }
public override void OnRunning() { stackentries.Clear(); }
private void LoadConfig() { mainTimer.Stop(); settingsCitiesList.Clear(); var vals = ConfigurationManager.AppSettings[SITIES].Split(';'); foreach (string val in vals) { CityDataSet dc = new CityDataSet(); var param = val.Split('|'); if (param.Length > 0 && settingsCities.ContainsKey(param[0])) { dc.City = settingsCities[param[0]]; dc.CityCode = param[0]; } if (param.Length > 1) { try { dc.Date = DateTime.ParseExact(param[1], Const.DateFormat, CultureInfo.InvariantCulture); } catch (Exception e) { Debug.WriteLine(e.ToString()); } } if (param.Length > 2) { dc.IsSelected = param[2] == "1"; } settingsCitiesList.Add(dc); } _listToMonitor.Clear(); foreach (CityDataSet city in settingsCitiesList) { if (city.IsSelected) { _listToMonitor.Add(city); } } _values.Clear(); dataGridViewResults.DataSource = null; txtIntMain.Text = ConfigurationManager.AppSettings[MainInterval]; txtInt.Text = ConfigurationManager.AppSettings[SubInterval]; dataGridViewSettings.DataSource = settingsCitiesList; cbxVisas.DataSource = settingsVisas; int visa = 1; int.TryParse(ConfigurationManager.AppSettings[TypeVisa], out visa); cbxVisas.SelectedIndex = visa; txtNotif.Text = ConfigurationManager.AppSettings[NotifCount]; int.TryParse(ConfigurationManager.AppSettings[NotifCount], out notifsett); _visaType = cbxVisas.SelectedItem.ToString(); _visaCode = getVisaId(_visaType); }
/// <summary> /// 停止UDP监听 /// </summary> /// <returns></returns> private void StopUDPServer() { udpserver.NetWork.Close(); lstClient.Clear(); isListen = false; }
private void BtnDltAllList_Click(object sender, EventArgs e) { phones.Clear(); listBoxPhone.DataSource = null; listBoxPhone.DataSource = phones; }
/// <summary> /// Do all of the tasks that this shipyard has assigned to it. /// </summary> /// <param name="CurrentFaction">Faction both the population and the shipyard belong to.</param> /// <param name="CurrentPopulation">Population the shipyard is on</param> /// <param name="SYInfo">Shipyard the tasks are happening at</param> private static void BuildShips(Faction CurrentFaction, Population CurrentPopulation, List<Installation.ShipyardInformation.ShipyardTask> SortedList) { BindingList<Installation.ShipyardInformation.ShipyardTask> TasksToRemove = new BindingList<Installation.ShipyardInformation.ShipyardTask>(); foreach(Installation.ShipyardInformation.ShipyardTask Task in SortedList) { if (Task.IsPaused() == true) continue; /// <summary> /// the Annual Build Rate(ABR) is the number of BP per year that will be devoted to this activity. this is the number of BP produced only this cycle. /// </summary> float CycleBuildRate = Task.ABR * Constants.Colony.ConstructionCycleFraction; /// <summary> /// How much of this task will be completed this construction cycle? /// </summary> float CurrentProgress = CycleBuildRate / (float)Task.Cost; if ((Task.Progress + (decimal)CurrentProgress) > 1.0m) { CurrentProgress = (float)(1.0m - Task.Progress); } /// <summary> /// Can this shipyard Task be built this construction cycle? /// </summary> bool CanBuild = CurrentPopulation.MineralRequirement(Task.minerialsCost, CurrentProgress); if (CanBuild == true && Task.CurrentTask != Constants.ShipyardInfo.Task.Scrap) { CurrentPopulation.HandleShipyardCost(Task.Cost, Task.minerialsCost, CurrentProgress); Task.Progress = Task.Progress + (decimal)CurrentProgress; } else if (Task.CurrentTask == Constants.ShipyardInfo.Task.Scrap) { /// <summary> /// Return money to the population from the scrap. /// </summary> CurrentPopulation.HandleShipyardCost(Task.Cost, Task.minerialsCost, (CurrentProgress * -1.0f)); Task.Progress = Task.Progress + (decimal)CurrentProgress; } else { String Entry = String.Format("Not enough minerals to finish task {0} at Shipyard {1} on Population {2}", Task.CurrentTask, CurrentPopulation.ShipyardTasks[Task], CurrentPopulation); MessageEntry NMsg = new MessageEntry(MessageEntry.MessageType.ColonyLacksMinerals, CurrentPopulation.Position.System, CurrentPopulation, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Entry); GameState.Instance.Factions[0].MessageLog.Add(NMsg); } /// <summary> /// handle standard task completion here. /// </summary> if (Task.Progress >= 1.0m) { TasksToRemove.Add(Task); switch (Task.CurrentTask) { case Constants.ShipyardInfo.Task.Construction: Task.AssignedTaskGroup.AddShip(Task.ConstructRefitTarget, Task.Title); CurrentPopulation.FuelStockpile = Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].Refuel(CurrentPopulation.FuelStockpile); break; case Constants.ShipyardInfo.Task.Repair: /// <summary> /// Set the Armor to fully repaired, set all components as not destroyed, and reduce the maintenance clock by a certain amount. /// </summary> #warning maintenance clock work should be performed here and in refit as well. Task.CurrentShip.ShipArmor.RepairAllArmor(); foreach (ComponentTN CurComp in Task.CurrentShip.ShipComponents) { CurComp.isDestroyed = false; } break; case Constants.ShipyardInfo.Task.Refit: /// <summary> /// need to remove the old ship, put in the new ship, copy over important information, adjust refueling,MSP,etc? /// </summary> /// <summary> /// Credit the population with the fuel and ordnance on the ship. the old ships MSP will be considered where the new ship got its MSP from. /// </summary> CurrentPopulation.FuelStockpile = CurrentPopulation.FuelStockpile + Task.CurrentShip.CurrentFuel; foreach (KeyValuePair<OrdnanceDefTN, int> OrdnancePair in Task.CurrentShip.ShipOrdnance) { CurrentPopulation.LoadMissileToStockpile(OrdnancePair.Key, (float)OrdnancePair.Value); } /// <summary> /// Destroy the ship. just use the existing code to remove the ship from the simulation, no point in reduplicating all of it. /// </summary> Task.CurrentShip.IsDestroyed = true; if (CurrentFaction.RechargeList.ContainsKey(Task.CurrentShip) == true) { if ((CurrentFaction.RechargeList[Task.CurrentShip] & (int)Faction.RechargeStatus.Destroyed) != (int)Faction.RechargeStatus.Destroyed) { CurrentFaction.RechargeList[Task.CurrentShip] = CurrentFaction.RechargeList[Task.CurrentShip] + (int)Faction.RechargeStatus.Destroyed; } } else { CurrentFaction.RechargeList.Add(Task.CurrentShip, (int)Faction.RechargeStatus.Destroyed); } /// <summary> /// Add in the "new" ship. /// </summary> Task.AssignedTaskGroup.AddShip(Task.ConstructRefitTarget,Task.CurrentShip.Name); Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].TFTraining = Task.CurrentShip.TFTraining; Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].ShipGrade = Task.CurrentShip.ShipGrade; CurrentPopulation.FuelStockpile = Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].Refuel(CurrentPopulation.FuelStockpile); break; case Constants.ShipyardInfo.Task.Scrap: /// <summary> /// All non-destroyed components from the ship need to be put into the population stockpile. /// This further includes fuel, MSP, and ordnance as well as eventually officers and crew. /// </summary> #warning Handle officers and crew on ship scrapping. BindingList<ComponentDefTN> CompDefList = Task.CurrentShip.ShipClass.ListOfComponentDefs; BindingList<short> CompDefCount = Task.CurrentShip.ShipClass.ListOfComponentDefsCount; BindingList<ComponentTN> ShipCompList = Task.CurrentShip.ShipComponents; BindingList<ushort> ComponentDefIndex = Task.CurrentShip.ComponentDefIndex; int DefCount = Task.CurrentShip.ShipClass.ListOfComponentDefs.Count; for (int CompDefIndex = 0; CompDefIndex < DefCount; CompDefIndex++) { ComponentDefTN CurrentCompDef = CompDefList[CompDefIndex]; short CurrentCompCount = CompDefCount[CompDefIndex]; int destCount = 0; for (int CompIndex = 0; CompIndex < CurrentCompCount; CompIndex++) { if (ShipCompList[ComponentDefIndex[CompDefIndex] + CompIndex].isDestroyed == true) { destCount++; } } if (destCount != CurrentCompCount) { CurrentPopulation.AddComponentsToStockpile(CurrentCompDef, (float)(CurrentCompCount - destCount)); } } CurrentPopulation.FuelStockpile = CurrentPopulation.FuelStockpile + Task.CurrentShip.CurrentFuel; CurrentPopulation.MaintenanceSupplies = CurrentPopulation.MaintenanceSupplies + Task.CurrentShip.CurrentMSP; foreach (KeyValuePair<OrdnanceDefTN, int> OrdnancePair in Task.CurrentShip.ShipOrdnance) { CurrentPopulation.LoadMissileToStockpile(OrdnancePair.Key, (float)OrdnancePair.Value); } /// <summary> /// Finally destroy the ship. just use the existing code to remove the ship from the simulation, no point in reduplicating all of it. /// </summary> Task.CurrentShip.IsDestroyed = true; if (CurrentFaction.RechargeList.ContainsKey(Task.CurrentShip) == true) { if ((CurrentFaction.RechargeList[Task.CurrentShip] & (int)Faction.RechargeStatus.Destroyed) != (int)Faction.RechargeStatus.Destroyed) { CurrentFaction.RechargeList[Task.CurrentShip] = CurrentFaction.RechargeList[Task.CurrentShip] + (int)Faction.RechargeStatus.Destroyed; } } else { CurrentFaction.RechargeList.Add(Task.CurrentShip, (int)Faction.RechargeStatus.Destroyed); } break; } } else { /// <summary> /// Update the timer since this project won't finish just yet. /// </summary> decimal CostLeft = Task.Cost * (1.0m - Task.Progress); float YearsOfProduction = (float)CostLeft / Task.ABR; DateTime EstTime = GameState.Instance.GameDateTime; if (YearsOfProduction < Constants.Colony.TimerYearMax) { float DaysInYear = (float)Constants.TimeInSeconds.RealYear / (float)Constants.TimeInSeconds.Day; int TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear); TimeSpan TS = new TimeSpan(TimeToBuild, 0, 0, 0); EstTime = EstTime.Add(TS); } Task.CompletionDate = EstTime; } } /// <summary> /// Remove all the tasks that are now completed. /// </summary> foreach (Installation.ShipyardInformation.ShipyardTask Task in TasksToRemove) { /// <summary> /// Sanity check here. /// </summary> if (Task.Progress >= 1.0m) { Installation.ShipyardInformation SYI = CurrentPopulation.ShipyardTasks[Task]; SYI.BuildingShips.Remove(Task); CurrentPopulation.ShipyardTasks.Remove(Task); } } TasksToRemove.Clear(); }
/// <summary> /// This function gets the list of shipclasses this shipyard can build. In order to be considered eligible the class must be locked, and thus not alterable. /// eligible classes are those that would cost within 20% of cost to refit this shipclass towards. /// </summary> /// <param name="CurrentFaction">Current faction from the economics handler.</param> /// <param name="SYInfo">Currently selected shipyard.</param> /// <param name="EligibleClassList">List of shipclasses that this shipyard can produce.</param> private static void GetEligibleClassList(Faction CurrentFaction, Installation.ShipyardInformation SYInfo, ref BindingList<ShipClassTN> EligibleClassList) { if (SYInfo.AssignedClass == null) { return; } EligibleClassList.Clear(); /// <summary> /// Shipyards may always build the ship that they are tooled for. /// </summary> EligibleClassList.Add(SYInfo.AssignedClass); /// <summary> /// If the total refit cost is less than this, the CurrentClass is eligible. /// </summary> decimal RefitThreshold = SYInfo.AssignedClass.BuildPointCost * 0.2m; /// <summary> /// component definition and count lists for the assigned class. for refit purposes we don't care about any specialized component functionality, just cost here. /// </summary> BindingList<ComponentDefTN> AssignedClassComponents = SYInfo.AssignedClass.ListOfComponentDefs; BindingList<short> AssignedClassComponentCounts = SYInfo.AssignedClass.ListOfComponentDefsCount; foreach (ShipClassTN CurrentClass in CurrentFaction.ShipDesigns) { /// <summary> /// Assigned class is already set to be built, and shouldn't ever be an "eligible class" /// </summary> if (CurrentClass == SYInfo.AssignedClass) continue; /// <summary> /// Military ships are not buildable at commercial yards. Naval yards can build commercial ships however. /// </summary> if (CurrentClass.IsMilitary == true && SYInfo.ShipyardType == Constants.ShipyardInfo.SYType.Commercial) continue; /// <summary> /// unlocked classes can be edited so I do not wish to have them included here. /// </summary> if(CurrentClass.IsLocked == true) { decimal TotalRefitCost = SYInfo.AssignedClass.GetRefitCost(CurrentClass); if (TotalRefitCost <= RefitThreshold) EligibleClassList.Add(CurrentClass); } } }
public void clearQso() { qsoList.Clear(); writeQsoList(); qsoFactory.no = 1; }
private void clearToolStripMenuItem_Click(object sender, EventArgs e) { HasChanged(); _hosts.Clear(); }
void ReloadDebitNotes(BindingList<PaymentNote> target) { target.Clear(); PaymentNote.ClearCategoryList(); using (System.Data.SQLite.SQLiteDataReader reader = DataBase.Instance.ExecuteReader("SELECT * FROM DebitNotes")) { while (reader.Read()) { reader.GetValue(0); PaymentNote debitNote = new PaymentNote( reader.GetInt32(0), //Id reader.GetInt32(1), //OwnerId reader.IsDBNull(2) ? string.Empty : reader.GetString(2), //Category reader.GetDateTime(3), //Date reader.IsDBNull(4) ? string.Empty : reader.GetString(4), //Services reader.IsDBNull(5) ? string.Empty : reader.GetString(5), //Advances reader.GetInt32(6), //Tax reader.GetInt32(7), //Total reader.IsDBNull(8) ? (Nullable<DateTime>)null : reader.GetDateTime(8) ); target.Add(debitNote); } } filterCategory.DataSource = null; filterCategory.DataSource = PaymentNote.CategoryList; filters_Changed(null, null); }
/// <summary> /// Get a list of the shipclasses in orbit. this wll be needed to help prune repair/refit/scrap operation options. /// </summary> /// <param name="CurrentFaction">Current faction from the economics handler</param> /// <param name="CurrentPopulation">Current Population from the economics handler.</param> /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param> private static void GetShipClassesInOrbit(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipClassTN> ClassesInOrbit) { ClassesInOrbit.Clear(); foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit) { if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction) { foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships) { if (ClassesInOrbit.Contains(CurrentShip.ShipClass) == false) ClassesInOrbit.Add(CurrentShip.ShipClass); } } } }
public void ProcessValues(RegistryKey key) { _values.Clear(); Errors.Clear(); var profiles = key.SubKeys.SingleOrDefault(t => t.KeyName == "Profiles"); if (profiles == null) { Errors.Add($"'Profiles' key missing!' "); return; } foreach (var profilesSubKey in profiles.SubKeys) { try { var rawCreated = profilesSubKey.Values.Single(t => t.ValueName == "DateCreated").ValueDataRaw; var rawLast = profilesSubKey.Values.Single(t => t.ValueName == "DateLastConnected").ValueDataRaw; var isManaged = profilesSubKey.Values.Single(t => t.ValueName == "DateLastConnected").ValueData == "0"; var profileName = profilesSubKey.Values.Single(t => t.ValueName == "ProfileName").ValueData; var networkName = string.Empty; if (!isManaged) { networkName = profileName; } var dnsSuffix = string.Empty; var macAddress = string.Empty; var typeNum = int.Parse(profilesSubKey.Values.Single(t => t.ValueName == "NameType").ValueData); var networkType = KnownNetwork.NameTypes.Unknown; if (typeNum > 0) { try { networkType = (KnownNetwork.NameTypes)typeNum; } catch (Exception) { Errors.Add($"Could not determine network type! Type value: {typeNum}"); } } var kn = new KnownNetwork(networkName, networkType, GetDateFrom128Bit(rawCreated), GetDateFrom128Bit(rawLast), isManaged, dnsSuffix, macAddress, profilesSubKey.KeyName); kn.BatchKeyPath = profilesSubKey.KeyPath; kn.BatchValueName = "Multiple"; _values.Add(kn); } catch (Exception e) { Errors.Add($"Error processing Profiles subkey '{profilesSubKey.KeyName}': {e.Message}"); } } var sigsKey = key.SubKeys.SingleOrDefault(t => t.KeyName == "Signatures"); if (sigsKey == null) { Errors.Add($"'Signatures' key missing!' "); return; } var unmanaged = sigsKey.SubKeys.SingleOrDefault(t => t.KeyName == "Unmanaged"); if (unmanaged == null) { Errors.Add($"'Unmanaged' key missing!' "); return; } foreach (var unmanagedKey in unmanaged.SubKeys) { try { var gatewayMacRaw = unmanagedKey.Values.Single(t => t.ValueName == "DefaultGatewayMac").ValueData; var dnsSuffix = unmanagedKey.Values.Single(t => t.ValueName == "DnsSuffix").ValueData; var profileGuid = unmanagedKey.Values.Single(t => t.ValueName == "ProfileGuid").ValueData; var firstNetwork = unmanagedKey.Values.Single(t => t.ValueName == "FirstNetwork").ValueData; var kn = _values.SingleOrDefault(t => t.ProfileGUID == profileGuid); kn?.UpdateInfo(gatewayMacRaw, dnsSuffix, firstNetwork, false); } catch (Exception e) { Errors.Add($"Error processing Unmanaged subkey '{unmanagedKey.KeyName}': {e.Message}"); } } var managed = sigsKey.SubKeys.SingleOrDefault(t => t.KeyName == "Managed"); if (managed == null) { Errors.Add("'Managed' key missing!' "); return; } foreach (var managedKey in managed.SubKeys) { try { var gatewayMacRaw = managedKey.Values.Single(t => t.ValueName == "DefaultGatewayMac").ValueData; var dnsSuffix = managedKey.Values.Single(t => t.ValueName == "DnsSuffix").ValueData; var profileGuid = managedKey.Values.Single(t => t.ValueName == "ProfileGuid").ValueData; var firstNetwork = managedKey.Values.Single(t => t.ValueName == "FirstNetwork").ValueData; var kn = _values.SingleOrDefault(t => t.ProfileGUID == profileGuid); kn?.UpdateInfo(gatewayMacRaw, dnsSuffix, firstNetwork, true); } catch (Exception e) { Errors.Add($"Error processing Managed subkey '{managedKey.KeyName}': {e.Message}"); } } }
protected override void OnTermination() { if (ChartControl != null) { //ToolStrip toolstrip = (ToolStrip)ChartControl.Controls["tsrTool"]; if (frm != null) { //remove the data grid view //this.dgv.CellClick -= new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_CellClick); frm.Controls.Remove(dgv); this.dgv.Dispose(); //remove the buttons this.btnSubmitOrder.Click -= new System.EventHandler(btnSubmitOrder_Click); frm.Controls.Remove(btnSubmitOrder); this.btnSubmitOrder.Dispose(); this.btnModifyOrder.Click -= new System.EventHandler(btnModifyOrder_Click); frm.Controls.Remove(btnModifyOrder); this.btnModifyOrder.Dispose(); this.btnCancelOrder.Click -= new System.EventHandler(btnCancelOrder_Click); frm.Controls.Remove(btnCancelOrder); this.btnCancelOrder.Dispose(); //remove the numeric up down boxes frm.Controls.Remove(nudStopPrice); this.nudStopPrice.Dispose(); frm.Controls.Remove(this.nudLmtPrice); this.nudLmtPrice.Dispose(); frm.Controls.Remove(nudQuantity); this.nudQuantity.Dispose(); //remove the combo box this.cbOrderType.SelectedIndexChanged -= new System.EventHandler(cbOrderType_SelectedIndexChanged); frm.Controls.Remove(cbOrderType); this.cbOrderType.Dispose(); frm.Controls.Remove(cbOrderAction); this.cbOrderAction.Dispose(); // frm.Controls.Remove(cbCompare); // this.cbCompare.Dispose(); frm.Controls.Remove(label1); label1.Dispose(); frm.Controls.Remove(label2); label2.Dispose(); frm.Controls.Remove(label3); label3.Dispose(); frm.Controls.Remove(label4); label4.Dispose(); frm.Controls.Remove(label5); label5.Dispose(); // frm.Controls.Remove(label6); // label6.Dispose(); frm.Controls.Remove(lblMsg); lblMsg.Dispose(); frm.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(frm_FormClosing); frm.Load -= new System.EventHandler(frm_Load); frm.Resize -= new System.EventHandler(frm_Resize); frm.Close(); frm.Dispose(); } if (blist != null) { blist.Clear(); } if (olist != null) { olist.Clear(); } } }
private void Worker_DoWork_ReceiverInput(object sender, DoWorkEventArgs e) { //to store names for data source input of ListBox BindingList <String> names = new BindingList <String>(); byte[] buffer = new byte[255]; UserConnection user = (UserConnection)e.Argument; string chunk = String.Empty; string dataReceived = String.Empty; while (true) { do { if (user.MySocket.Connected) { int rec; try { rec = user.MySocket.Receive(buffer);//, 0, buffer.Length, 0); } catch (SocketException) { return; } Array.Resize(ref buffer, rec); // Resize Array chunk = Encoding.Default.GetString(buffer); dataReceived += chunk; } } while (user.MySocket.Available > 0); if (dataReceived.StartsWith("notificationOfUsers")) { this.Dispatcher.Invoke(new Action(() => { names.Clear(); })); //if it is a notification parse it into strings foreach (String nameOfUser in dataReceived.Split(' ')) { this.Dispatcher.Invoke(new Action(() => { //do not add itself in list of notification if (nameOfUser != user.Username && nameOfUser != "notificationOfUsers" && nameOfUser.Trim() != "") { if (!names.Contains(nameOfUser) && nameOfUser != user.Username) { names.Add(nameOfUser); rtbNotificatons.AppendText(nameOfUser + " Joinded Chat\n"); } } })); } } else if (dataReceived.StartsWith("newSessionStarted")) { string[] parsedMessage = dataReceived.Split(':'); //from(to) -- this.Dispatcher.Invoke(new Action(() => { ChatSessionWindow newWindow = new ChatSessionWindow(parsedMessage[1], user, int.Parse(parsedMessage[3])); chatSessionsList.Add(newWindow); newWindow.Show(); })); } else if (dataReceived.Trim().StartsWith("Logout")) { string[] parsedMessage = dataReceived.Split(':'); dataset.Remove(parsedMessage[1]); // remove all the elements containg the name of loggedOutUser and notify foreach (var item in chatSessionsList) { //matches logged Out User to any of session's target name if (parsedMessage[1] == item.message_to) { chatSessionsList.Remove(item); this.Dispatcher.Invoke(() => { item.Close(); }); break; } } this.Dispatcher.Invoke(new Action(() => { lbUsers.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget(); rtbNotificatons.AppendText(parsedMessage[1] + " Logged Out" + "\n"); })); //TODO:Close all the windows containg the same username also } //There is a message to send else { string[] parsedMessage = dataReceived.Split(':'); foreach (var chatUser in chatSessionsList) { if (chatUser.uniqueIdentifier == int.Parse(parsedMessage[0])) { this.Dispatcher.Invoke(new Action(() => { chatUser.receivedMessage(parsedMessage[2] + ":" + parsedMessage[3] + "\n"); })); } } }//#if-else-if end this.Dispatcher.Invoke(new Action(() => { dataset = names; })); chunk = String.Empty; dataReceived = String.Empty; (sender as BackgroundWorker).ReportProgress(1); //report Progress changed try { if (!(user.MySocket.Available > 0)) { //if no data is available to read Thread.Sleep(2000); } } catch (ObjectDisposedException) { return; } // }//#end-lock //If There is a message send to the CLient //ChatSessionWindow.SendMessage("Data"); }//#end-while }
private void MenuDeleteAllMessages_Click(object sender, System.EventArgs e) { _messages.Clear(); _sessions.Clear(); }
private bool CheckLabelsListWithXml(out string summary_results) { TextWriter summary_file_csv = null; TextWriter summary_file_html = null; bool Is_LabelsList_Valid = true; summary_results = ""; string[] str_temp; try { DateTime start_time, end_time; TimeSpan ts, ts_start, ts_end, total_time, total_time_inv; string category, current_label, readline; //Create Summary Lists BindingList<string> List_Annotated = new BindingList<string>(); BindingList<string> List_NoAnnotated = new BindingList<string>(); BindingList<string> List_Invalid = new BindingList<string>(); BindingList<TimeSpan> List_Time = new BindingList<TimeSpan>(); BindingList<TimeSpan> List_Time_Inv = new BindingList<TimeSpan>(); BindingList<string> List_Current_XML; //Create the files for summarizing results // Create the csv file if (File.Exists(Folder_audioannotation + "AnnotationSummary.csv")) { File.Delete(Folder_audioannotation + "AnnotationSummary.csv"); } summary_file_csv = new StreamWriter(Folder_audioannotation + "AnnotationSummary.csv"); summary_file_csv.WriteLine("Label,Time(hh:mm:ss)"); // Create the html file if (File.Exists(Folder_audioannotation + "AnnotationSummary.html")) { File.Delete(Folder_audioannotation + "AnnotationSummary.html"); } summary_file_html = new StreamWriter(Folder_audioannotation + "AnnotationSummary.html"); summary_file_html.WriteLine("<table border=\"1\">\n"); summary_file_html.WriteLine("<tr><td>Label</td><td>Time(hh:mm:ss)</td></tr>"); // ---------- Load labels ------------------ int count = 0; int index = 0; for (int c = 1; c <= 2; c++) { //Initialize lists List_Annotated.Clear(); List_NoAnnotated.Clear(); List_Invalid.Clear(); List_Time.Clear(); List_Time_Inv.Clear(); total_time = TimeSpan.Zero; total_time_inv = TimeSpan.Zero; //Indicate the category if (c == 1) { count = LabelsList_1.Count; List_Current_XML = list_category_1; //category = "Postures"; category = list_category_name[0]; } else { count = LabelsList_2.Count; List_Current_XML = list_category_2; //category = "Activities"; category = list_category_name[1]; } //Read each item from the list for (int i = 0; i < count; i++) { if (c == 1) { readline = LabelsList_1[i]; } else { readline = LabelsList_2[i]; } string[] tokens = readline.Split(';'); //Check the row has valid start/end times if (tokens[0].CompareTo("ok") == 0) { current_label = tokens[5]; //filter labels comming from blank rows if (current_label.Trim().CompareTo("") != 0) { //Check if the label is valid according to the Xml protocol list //if not, flag the label as invalid if (List_Current_XML.Contains(current_label)) { //Start Time str_temp = tokens[3].Split('.'); start_time = DateTime.Parse(StartDate + " " + str_temp[0]); ts_start = (start_time - new DateTime(1970, 1, 1, 0, 0, 0)); //Stop Time str_temp = tokens[4].Split('.'); end_time = DateTime.Parse(EndDate + " " + str_temp[0]); ts_end = (end_time - new DateTime(1970, 1, 1, 0, 0, 0)); ts = ts_end.Subtract(ts_start); total_time = total_time + ts; if (!List_Annotated.Contains(current_label)) { List_Annotated.Add(current_label); List_Time.Add(ts); } else { index = List_Annotated.IndexOf(current_label); //ts_start = List_Time[index]; //ts = ts + ts_start; List_Time[index] = ts + List_Time[index]; } //Check if the total time spend on this label makes sense (greater than 0) //If so, add the label to the annotated list //Otherwise, highlighted as problematic and don't generate the xml file if ( ts.TotalSeconds == 0) { Is_LabelsList_Valid = false; #region highlight label in yellow int iloop = 0; int irow = 0; while(iloop <2) { if(iloop == 0) { //Highlight Start Row irow = Int32.Parse(tokens[1]); } else if(iloop == 1) { //Highlight End Row irow = Int32.Parse(tokens[2]); } iloop++; if (c == 1) { dataGridView1.Rows[irow].Cells[C1.category_label].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C1.category_label].Style.ForeColor = System.Drawing.Color.DimGray; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.ForeColor = System.Drawing.Color.DimGray; } else if (c == 2) { dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.DimGray; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.ForeColor = System.Drawing.Color.DimGray; } } #endregion } } // if label not found in xml protocol, flag as invalid else { Is_LabelsList_Valid = false; #region higlight row in red int iloop = 0; int irow = 0; while (iloop < 2) { if (iloop == 0) { //Highlight Start Row irow = Int32.Parse(tokens[1]); } else if (iloop == 1) { //Highlight End Row irow = Int32.Parse(tokens[2]); } iloop++; if (c == 1) { dataGridView1.Rows[irow].Cells[C1.category_label].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C1.category_label].Style.ForeColor = System.Drawing.Color.White; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.ForeColor = System.Drawing.Color.White; } else if (c == 2) { dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.White; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.ForeColor = System.Drawing.Color.White; } } #endregion //Start Time str_temp = tokens[3].Split('.'); start_time = DateTime.Parse(StartDate + " " + str_temp[0]); ts_start = (start_time - new DateTime(1970, 1, 1, 0, 0, 0)); //Stop Time str_temp = tokens[4].Split('.'); end_time = DateTime.Parse(EndDate + " " + str_temp[0]); ts_end = (end_time - new DateTime(1970, 1, 1, 0, 0, 0)); ts = ts_end.Subtract(ts_start); total_time_inv = total_time_inv + ts; if (!List_Invalid.Contains(current_label)) { List_Invalid.Add(current_label); List_Time_Inv.Add(ts); } else { index = List_Invalid.IndexOf(current_label); ts_start = List_Time_Inv[index]; ts = ts + ts_start; List_Time_Inv[index] = ts; } } } //else (if label == blank), do nothing }//if token ok }//for labels list per category //------------------------------------------ //Compute the No-Annotated Labels //check for blank labels foreach(string ilabel in List_Current_XML) { if (ilabel.Trim().CompareTo("") != 0) { if (!List_Annotated.Contains(ilabel)) { List_NoAnnotated.Add(ilabel); } } //else if(label == blank), do nothing } //------------------------------------------ // Write the summary of results to file //------------------------------------------- string font_color_open = ""; string font_color_close = ""; // Annotatated List summary_file_csv.WriteLine("Annotated "+ category + ","); summary_results = summary_results + "Annotated " + category + ":,," + "#" + ";"; summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong>Annotated " + category + "</strong></td><td> </td></tr>"); int it = 0; foreach (string clabel in List_Annotated) { ts = List_Time[it]; // Save record to the correspondent session summary_file_csv.WriteLine(clabel + "," + ts.ToString()); summary_file_html.WriteLine("<tr>\n<td>" + clabel + "</td><td>" + ts.ToString() + "</td></tr>"); summary_results = summary_results + clabel + "," + ts.ToString() + ";"; it++; } summary_file_csv.WriteLine("Total Time Annotated "+ category + "," + total_time.ToString()); summary_file_csv.WriteLine(""); font_color_open = "<strong><font color=\"#4E8975\">"; font_color_close = "</font><strong>"; summary_file_html.WriteLine("<tr>\n<td>"+ font_color_open +"Total Time Annotated " + category + font_color_close +"</td>" + "<td>"+ font_color_open + total_time.ToString() + font_color_close + "</td></tr>"); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + "Total Time Annotated " + category + "," + total_time.ToString() + ",##;"; summary_results = summary_results +";"; // No Annotated List summary_file_csv.WriteLine("No Annotated " + category + " in Xml Protocol,"); summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong>No Annotated " + category + " in Xml Protocol</strong></td><td> </td></tr>"); summary_results = summary_results + "No Annotated " + category + " in Xml Protocol:,,#" + ";"; foreach (string jlabel in List_NoAnnotated) { summary_file_csv.WriteLine(jlabel); summary_file_html.WriteLine("<tr>\n<td>" + jlabel + "</td><td> </td></tr>"); summary_results = summary_results + jlabel + ";"; } summary_file_csv.WriteLine(""); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + ";"; summary_file_csv.WriteLine("Invalid " + category + ","); summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong> Invalid " + category + "</strong></td><td> </td></tr>"); summary_results = summary_results + "Invalid " + category + ":,," + "#" + ";"; font_color_open = "<font color=\"#FA5858\">"; font_color_close = "</font>"; it = 0; foreach (string klabel in List_Invalid) { ts = List_Time_Inv[it]; // Save record to the correspondent session summary_file_csv.WriteLine(klabel + "," + ts.ToString()); summary_file_html.WriteLine("<tr>\n<td>" + font_color_open + klabel + font_color_close + "</td>" + "<td>" + font_color_open + ts.ToString() + font_color_close + "</td></tr>"); summary_results = summary_results + klabel + "," + ts.ToString() + ",###;"; it++; } summary_file_csv.WriteLine("Total Time Invalid " + category + "," + total_time_inv.ToString()); summary_file_csv.WriteLine(""); font_color_open = "<strong><font color=\"#FA5858\">"; font_color_close = "</font></strong>"; summary_file_html.WriteLine("<tr>\n<td>"+ font_color_open + "Total Time Invalid " + category + font_color_close+"</td>" + "<td>"+ font_color_open + total_time_inv.ToString() + font_color_close + "</td></tr>"); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + "Total Time Invalid " + category + "," + total_time_inv.ToString() + ",#-;"; summary_results = summary_results + ";"; //-------------------------------------------- }//for each category label // Close summary file csv summary_file_csv.Flush(); summary_file_csv.Close(); // Close summary file csv summary_file_html.WriteLine("</table>"); summary_file_html.Flush(); summary_file_html.Close(); return Is_LabelsList_Valid; } catch { Is_LabelsList_Valid = false; if (summary_file_csv != null) { summary_file_csv.Flush(); summary_file_csv.Close(); } if (summary_file_html != null) { summary_file_html.Flush(); summary_file_html.Close(); } return Is_LabelsList_Valid; } }
private void ClearLogsButton_ItemClick(object sender, ItemClickEventArgs e) { Logs.Clear(); ClearLogsButton.Enabled = false; }
private void btnImport_Click(object sender, EventArgs e) { if (cmbFileType.SelectedIndex == 0)//CSV { OpenFileDialog _openDialog = new OpenFileDialog(); _openDialog.RestoreDirectory = true; _openDialog.Filter = "CVS (*.csv)|*.csv"; _openDialog.CheckFileExists = true; _openDialog.Multiselect = false; if (_openDialog.ShowDialog() == DialogResult.OK) { //Clear existing items m_PersonList.Clear(); try { using (StreamReader _reader = new StreamReader(File.OpenRead(_openDialog.FileName))) { bool _isHeaderLine = true; string _csvLine = null; while (!_reader.EndOfStream) { _csvLine = _reader.ReadLine(); if (_isHeaderLine)//Skip first line, since it contains the column headers { _isHeaderLine = false; continue; } string[] _csvValues = _csvLine.Split(','); Person _person = new Person(); _person.GUID = _csvValues[0]; _person.Name = _csvValues[1]; _person.Surname = _csvValues[2]; _person.DateOfBirth = DateTime.Parse(_csvValues[3]); m_PersonList.Add(_person); } } } catch (Exception ex) { MessageBox.Show("An error occured. Message:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else if (cmbFileType.SelectedIndex == 1)//XML { OpenFileDialog _openDialog = new OpenFileDialog(); _openDialog.RestoreDirectory = true; _openDialog.Filter = "XML (*.xml)|*.xml"; _openDialog.CheckFileExists = true; _openDialog.Multiselect = false; if (_openDialog.ShowDialog() == DialogResult.OK) { //Clear existing items m_PersonList.Clear(); try { XmlSerializer _xmlSerializer = new XmlSerializer(typeof(BindingList <Person>)); using (StreamReader _reader = new StreamReader(File.OpenRead(_openDialog.FileName))) { BindingList <Person> _loadedList = (BindingList <Person>)_xmlSerializer.Deserialize(_reader); if (_loadedList != null) { for (int i = 0; i < _loadedList.Count; i++) { m_PersonList.Add(_loadedList[i]); } } } } catch (Exception ex) { MessageBox.Show("An error occured. Message:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void ProcessValues(RegistryKey key) { _values.Clear(); Errors.Clear(); var currentKey = string.Empty; try { foreach (var registryKey in key.SubKeys) // subkeys of FileExts { currentKey = registryKey.KeyName; var oe = new List <string>(); var op = new List <string>(); var uc = "(UserChoice key not present)"; if (registryKey.SubKeys.Count == 0) { var progId = registryKey.Values.SingleOrDefault(t => t.ValueName == "Progid"); if (progId != null) { op.Add(progId.ValueData); } var vo1 = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc); _values.Add(vo1); continue; } foreach (var subKey in registryKey.SubKeys) // subkey's subkeys { switch (subKey.KeyName) { case "OpenWithList": // contains values with name == char and value data of an executable name //there is an MRUList that contains the order the executables were selected var mruList = subKey.Values.SingleOrDefault(t => t.ValueName == "MRUList"); if (mruList != null) { //foreach slot in MRU, get the value and append it to our oe variable foreach (var mruPos in mruList.ValueData.ToCharArray()) { var exeName = subKey.Values.SingleOrDefault(t => t.ValueName == mruPos.ToString()); if (exeName != null) { oe.Add(exeName.ValueData); } else { oe.Add($"(Executable name for MRU slot '{mruPos}' not found!)"); } } } break; case "OpenWithProgids": foreach (var proIdValue in subKey.Values) { op.Add(proIdValue.ValueName); } break; case "UserChoice": var progId = subKey.Values.SingleOrDefault(t => t.ValueName == "ProgId"); if (progId != null) { uc = progId.ValueData; } break; } } //we have enough to add an entry var vo = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc); _values.Add(vo); } } catch (Exception ex) { Errors.Add($"Error processing FileExts subkey {currentKey}: {ex.Message}"); } if (Errors.Count > 0) { AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window"; } }
private void toolStripButton1_Click(object sender, EventArgs e) { string msg = null; try { XmlDocument doc = new XmlDocument(); doc.Load(AppDomain.CurrentDomain.BaseDirectory + "BugsBox.Pharmacy.AppClient.SalePriceType.xml"); XmlNode xmlNode = doc.SelectSingleNode("SalePriceType/SupplyDrugType"); if (xmlNode == null) { XmlNode SPTNode = doc.SelectSingleNode("SalePriceType"); XmlElement NewNode = doc.CreateElement("SupplyDrugType"); var result = MessageBox.Show("需要启用拟供药品过滤功能吗?如果启用,则需要在首营供货企业中填写拟供品种资料,并提交审核。(本功仅能针对生产企业,只提示一次,设置后无提示。)", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes; NewNode.SetAttribute("Type", result ? "1" : "0"); NewNode.InnerText = "设为1时根据拟供品种过滤,同时决定是否需要增加采购收货扫描图片"; SPTNode.AppendChild(NewNode); xmlNode = NewNode; doc.Save(AppDomain.CurrentDomain.BaseDirectory + "BugsBox.Pharmacy.AppClient.SalePriceType.xml"); } supplyDrugType = Convert.ToInt16(xmlNode.Attributes["Type"].Value); } catch (Exception ex) { MessageBox.Show("配置文件读取错误,请联系管理员!"); } if (this.toolStripComboBox1.ComboBox.Items.Count == 0) { return; } SupplyUnit su = (SupplyUnit)this.toolStripComboBox1.ComboBox.SelectedItem; Guid uid = su.Id; var all = PharmacyDatabaseService.GetDrugInfoBySupplyUnit(out msg, uid); if (all == null) { MessageBox.Show("无该供货商可销售药品,请查询其经营资质是否过期或其经营范围是否正确。"); this.dataGridView1.DataSource = null; return; } all = all.Where(r => r.Valid).ToArray(); //控制医疗器械 if (this.GoodsType == Common.GoodsTypeClass.医疗器械) { all = all.Where(r => r.BusinessScopeCode.Contains(this.GoodsType.ToString()) //|| r.BusinessScopeCode.Contains("I类") //|| r.BusinessScopeCode.Contains("II类") //|| r.BusinessScopeCode.Contains("III类") ) .ToArray(); } else { all = all.Where(r => r.BusinessScopeCode != "医疗器械" //&& r.BusinessScopeCode!="I类" //&& r.BusinessScopeCode!="II类" //&& r.BusinessScopeCode!="III类" ) .ToArray(); } if (all == null) { MessageBox.Show("无该供货商可销售药品,请查询其经营资质是否过期或其经营范围是否正确。"); this.dataGridView1.DataSource = null; return; } all = all.Except(addBL, new compareD()).ToArray(); bList.Clear(); string unitTypeName = PharmacyDatabaseService.GetUnitType(out msg, su.UnitTypeId).Name; if (supplyDrugType == 1 && unitTypeName == "生产企业") { //拟供品种过滤 string drugStr = su.SupplyProductClass; if (drugStr.IsNullOrTrimEmpty()) { MessageBox.Show("请检查该生产企业的拟供品种。"); return; } foreach (var c in all) { if (drugStr.Contains(c.ProductGeneralName)) { bList.Add(c); } } } else { foreach (var c in all) { bList.Add(c); } } this.dataGridView1.DataSource = bList; this.Supplyer = su.Name; this.Text = su.Name + " 采购品种选择"; this.SupplyerID = su.Id.ToString(); }
public void ProcessValues(RegistryKey key) { _values.Clear(); Errors.Clear(); var valuesList = new List <ValuesOut>(); var currentKey = string.Empty; try { //this key has folders stored in the root as well var mruVal1 = key.Values.SingleOrDefault(t => t.ValueName == "MRUList"); var mruListOrder1 = new ArrayList(); if (mruVal1 != null) { foreach (var c in mruVal1.ValueData.ToCharArray()) { mruListOrder1.Add(c.ToString()); } } foreach (var keyValue in key.Values) { if (keyValue.ValueName == "MRUList") { continue; } var mru1 = mruListOrder1.IndexOf(keyValue.ValueName); DateTimeOffset?openedOn1 = null; if (mru1 == 0) { openedOn1 = key.LastWriteTime; } var v1 = new ValuesOut("OpenSaveMRU", keyValue.ValueData, keyValue.ValueName, mru1, openedOn1); v1.BatchKeyPath = key.KeyPath; v1.BatchValueName = keyValue.ValueName; valuesList.Add(v1); } foreach (var registryKey in key.SubKeys) { currentKey = registryKey.KeyName; //get MRU key and read it in var mruVal = registryKey.Values.SingleOrDefault(t => t.ValueName == "MRUList"); var mruListOrder = new ArrayList(); if (mruVal != null) { foreach (var c in mruVal.ValueData.ToCharArray()) { mruListOrder.Add(c.ToString()); } } foreach (var keyValue in registryKey.Values) { if (keyValue.ValueName == "MRUList") { continue; } var mru = mruListOrder.IndexOf(keyValue.ValueName); DateTimeOffset?openedOn = null; if (mru == 0) { openedOn = registryKey.LastWriteTime; } var v = new ValuesOut(registryKey.KeyName, keyValue.ValueData, keyValue.ValueName, mru, openedOn); v.BatchKeyPath = registryKey.KeyPath; v.BatchValueName = keyValue.ValueName; valuesList.Add(v); } } } catch (Exception ex) { Errors.Add($"Error processing OpenSaveMRU subkey {currentKey}: {ex.Message}"); } if (Errors.Count > 0) { AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window"; } var v2 = valuesList.OrderBy(t => t.MruPosition); foreach (var source in v2.ToList()) { _values.Add(source); } }
public void ProcessValues(RegistryKey key) { _values.Clear(); Errors.Clear(); var valuesList = new List <ValuesOut>(); var currentKey = string.Empty; try { currentKey = key.KeyName; //get MRU key and read it in var mruVal = key.Values.SingleOrDefault(t => t.ValueName == "MRUList"); var mruListOrder = new ArrayList(); if (mruVal != null) { foreach (var c in mruVal.ValueData.ToCharArray()) { mruListOrder.Add(c.ToString()); } } foreach (var keyValue in key.Values) { if (keyValue.ValueName == "MRUList") { continue; } var segs = Encoding.Unicode.GetString(keyValue.ValueDataRaw).Split('\0'); var mru = mruListOrder.IndexOf(keyValue.ValueName); DateTimeOffset?openedOn = null; if (mru == 0) { openedOn = key.LastWriteTime; } var v = new ValuesOut(keyValue.ValueName, segs[0], segs[1], mru, openedOn); valuesList.Add(v); } } catch (Exception ex) { Errors.Add($"Error processing OpenSaveMRU subkey {currentKey}: {ex.Message}"); } if (Errors.Count > 0) { AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window"; } var v1 = valuesList.OrderBy(t => t.MruPosition); foreach (var source in v1.ToList()) { _values.Add(source); } }
private void Links_Click(object sender, EventArgs e) { _htmlItemsList.AddRange(_gekozenItems); _gekozenItems.Clear(); }
private void OnClearButtonClick(object sender, EventArgs e) { _gridItemList.Clear(); }
//************************************************************ //** 조회 버튼 Click //************************************************************ public void BtnSearch_Click() { if (authority.Read.Equals("0")) { Utility.MsgAuthorityViolation("조회"); return; } myViewModel?.Clear(); //--DB Handling(Start)------------------------------------- try { con = Utility.SetOracleConnection(); OracleCommand cmd = con.CreateCommand(); cmd.CommandText = SQLStatement.SelectSQL; cmd.BindByName = true; cmd.Parameters.Add("bas_empno", OracleDbType.Varchar2).Value = searchText.Text + "%"; cmd.Parameters.Add("bas_name", OracleDbType.Varchar2).Value = searchText_Copy.Text + "%"; cmd.Parameters.Add("bas_dept", OracleDbType.Varchar2).Value = Utility.GetCode(searchText_Copy2.Text) + "%"; cmd.Parameters.Add("bas_pos", OracleDbType.Varchar2).Value = searchText_Copy1.Text + "%"; OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { var data = new UcSubC02ViewModel { Bas_empno = dr.GetString(0), Bas_resno = dr.GetString(1), Bas_name = dr[2].ToString(), //dr.GetString(2), // 나중에 null못넣게 제거 Bas_cname = dr.IsDBNull(3) ? "" : dr.GetString(3), Bas_ename = dr.IsDBNull(4) ? "" : dr.GetString(4), Bas_sex = dr.IsDBNull(5) ? "" : dr.GetString(5), Bas_nat = dr.IsDBNull(6) ? "" : dr.GetString(6), Bas_ad1 = dr.IsDBNull(7) ? "" : dr.GetString(7), Bas_ad2 = dr.IsDBNull(8) ? "" : dr.GetString(8), Bas_pos = dr.IsDBNull(9) ? "" : dr.GetString(9), // 나중에 null못넣게 제거 Bas_pt1 = dr.IsDBNull(10) ? "" : dr.GetString(10), Bas_pt2 = dr.IsDBNull(11) ? "" : dr.GetString(11), Bas_pt3 = dr.IsDBNull(12) ? "" : dr.GetString(12), Bas_dut = dr.IsDBNull(13) ? "" : dr.GetString(13), // 나중에 null못넣게 제거 Bas_dept = dr.IsDBNull(14) ? "" : dr.GetString(14), // 나중에 null못넣게 제거 Bas_dept2 = dr.IsDBNull(15) ? "" : dr.GetString(15), Bas_cpodate = dr.IsDBNull(16) ? "" : Utility.FormatDate(dr.GetString(16)), Bas_cdudate = dr.IsDBNull(17) ? "" : Utility.FormatDate(dr.GetString(17)), Bas_cdedate = dr.IsDBNull(18) ? "" : Utility.FormatDate(dr.GetString(18)), Bas_subject = dr.IsDBNull(19) ? "" : dr.GetString(19), Bas_dean_dept = dr.IsDBNull(20) ? "" : dr.GetString(20), Bas_cont_mm = dr.IsDBNull(21) ? "" : dr.GetString(21), Bas_emp_sdate = dr.IsDBNull(22) ? "" : Utility.FormatDate(dr.GetString(22)), Bas_emp_edate = dr.IsDBNull(23) ? "" : Utility.FormatDate(dr.GetString(23)), Bas_emp_period = dr.IsDBNull(24) ? 0 : dr.GetDouble(24), Bas_femp_date = dr.IsDBNull(25) ? "" : Utility.FormatDate(dr.GetString(25)), Bas_cemp_date = dr.IsDBNull(26) ? "" : Utility.FormatDate(dr.GetString(26)), Bas_emp_date = dr.IsDBNull(27) ? "" : Utility.FormatDate(dr.GetString(27)), Bas_resdate = dr.IsDBNull(28) ? "" : Utility.FormatDate(dr.GetString(28)), Bas_retdate = dr.IsDBNull(29) ? "" : Utility.FormatDate(dr.GetString(29)), Bas_frq = dr.IsDBNull(30) ? "" : dr.GetString(30), Bas_passport = dr.IsDBNull(31) ? "" : dr.GetString(31), Bas_kfta = dr.IsDBNull(32) ? "" : dr.GetString(32), Bas_zip = dr.IsDBNull(33) ? "" : dr.GetString(33), Bas_zipaddr = dr.IsDBNull(34) ? "" : dr.GetString(34), Bas_hdpno = dr.IsDBNull(35) ? "" : dr.GetString(35), Bas_telno = dr.IsDBNull(36) ? "" : dr.GetString(36), Bas_email = dr.IsDBNull(37) ? "" : dr.GetString(37), Bas_bsks = dr.IsDBNull(38) ? "" : dr.GetString(38), Bas_job_comnm = dr.IsDBNull(39) ? "" : dr.GetString(39), Bas_job_pos = dr.IsDBNull(40) ? "" : dr.GetString(40), Bas_job_telno = dr.IsDBNull(41) ? "" : dr.GetString(41), Bas_levdate = dr.IsDBNull(42) ? "" : Utility.FormatDate(dr.GetString(42)), Bas_reidate = dr.IsDBNull(43) ? "" : Utility.FormatDate(dr.GetString(43)), Bas_wsta = dr.IsDBNull(44) ? "" : dr.GetString(44), Bas_sts = dr.IsDBNull(45) ? "" : dr.GetString(45), Bas_res = dr.IsDBNull(46) ? "" : dr.GetString(46), Bas_loa = dr.IsDBNull(47) ? "" : dr.GetString(47), Bas_univ_wys = dr.IsDBNull(48) ? 0 : dr.GetInt32(48), Bas_ind_wys = dr.IsDBNull(49) ? 0 : dr.GetInt32(49), Bas_mil_sta = dr.IsDBNull(50) ? "" : dr.GetString(50), Bas_mil_no = dr.IsDBNull(51) ? "" : dr.GetString(51), Bas_mil_mil = dr.IsDBNull(52) ? "" : dr.GetString(52), Bas_mil_rnk = dr.IsDBNull(53) ? "" : dr.GetString(53), Bas_mil_sdate = dr.IsDBNull(54) ? "" : Utility.FormatDate(dr.GetString(54)), Bas_mil_edate = dr.IsDBNull(55) ? "" : Utility.FormatDate(dr.GetString(55)), Bas_rmk = dr.IsDBNull(56) ? "" : dr.GetString(56), Key1 = dr.GetString(0), DataStatus = "" }; myViewModel.Add(data); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { if (con != null) { con.Close(); } } //--DB Handling(End)------------------------------------- SearchCount.Text = myViewModel.Count.ToString(); if (myViewModel.Count == 0) { UserMessage.Text = "조건을 만족하는 자료가 없습니다."; Utility.SetFuncBtn(MainBtn, "1"); } else { UserMessage.Text = "자료가 정상적으로 조회 되었습니다."; //**-개인정보 조회 Loging---------------------------- if (PersonalInfo.Equals("1")) { Utility.PersonalInfo_Logging(UserId, UserNm, MyIpAddress, ProgramName, "조회", myViewModel.Count); } Utility.SelectingFocusingGridControl(dataGrid, tableView, 0); Utility.SetFuncBtn(MainBtn, "2"); } }
/// <summary> /// Handles the Click event of the clearToolStripMenuItem 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 clearToolStripMenuItem_Click(object sender, EventArgs e) { data.Clear(); }
[Test] // bug #81771 public void DataSource_BindingList2 () { BindingList<string> list1 = new BindingList<string> (); list1.Add ("item 1"); BindingList<string> list2 = new BindingList<string> (); ListControlChild lc = new ListControlChild (); lc.DataSourceChanged += new EventHandler (ListControl_DataSourceChanged); Form form = new Form (); form.Controls.Add (lc); Assert.AreEqual (0, dataSourceChanged, "#1"); Assert.IsNull (lc.DataSource, "#2"); lc.DataSource = list1; Assert.AreEqual (1, dataSourceChanged, "#3"); Assert.AreSame (list1, lc.DataSource, "#4"); lc.DataSource = list2; Assert.AreEqual (2, dataSourceChanged, "#5"); Assert.AreSame (list2, lc.DataSource, "#6"); lc.DataSource = null; Assert.AreEqual (3, dataSourceChanged, "#7"); Assert.IsNull (lc.DataSource, "#8"); list1.Add ("item"); list1.Clear (); form.Dispose (); }
private void button1_Click(object sender, EventArgs e) { assetFiles.Clear(); }
/// <summary> /// This function produces a list of ships that have taken Armor or component damage. repair will need this. /// </summary> /// <param name="CurrentPopulation">Population selected by the economics handler.</param> /// <param name="DamagedShipsInOrbit">list of damaged ships this function will produce.</param> private static void GetDamagedShipList(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipTN> DamagedShipList) { DamagedShipList.Clear(); foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit) { if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction) { foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships) { /// <summary> /// Either a component is destroyed or the ship has taken armour damage. /// </summary> if (CurrentShip.DestroyedComponents.Count != 0 || CurrentShip.ShipArmor.isDamaged == true) DamagedShipList.Add(CurrentShip); } } } }
//************************************************** //* READ DATA //************************************************** private void getAllUsers() { usersList.Clear(); usersList = new BindingList <UsuariosRH>(_userPresenter.GetAllUsuarios()); usersGrid.ItemsSource = usersList; }
/// <summary> /// Need an updater function for this groupbox since the retool list can and will change. /// </summary> /// <param name="m_oSummaryPanel">Panel from economics</param> /// <param name="CurrentFaction">Current Faction</param> /// <param name="CurrentPopulation">Current Population</param> /// <param name="SYInfo">Shipyard information for the selected shipyard.</param> /// <param name="RetoolList">List of ships that this shipyard can be retooled to.</param> private static void RefreshSYCGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, Installation.ShipyardInformation SYInfo, BindingList<ShipClassTN> RetoolList) { #warning this doesn't update when a new shipclass is added on its own. the econ page is "shared" by all factions so an event may not be possible there. if (RetoolList != null && CurrentFaction != null && SYInfo != null) { m_oSummaryPanel.NewShipClassComboBox.Items.Clear(); RetoolList.Clear(); foreach (ShipClassTN Ship in CurrentFaction.ShipDesigns) { /// <summary> /// Ships that are too big may not be in the retool list, and military ships may not be built at commercial yards. /// Naval yards may build all classes of ships, but cap expansion for naval yards is very expensive. /// </summary> if (Ship.SizeTons <= SYInfo.Tonnage && !(Ship.IsMilitary == true && SYInfo.ShipyardType == Constants.ShipyardInfo.SYType.Commercial)) { RetoolList.Add(Ship); } } foreach (ShipClassTN Ship in RetoolList) { m_oSummaryPanel.NewShipClassComboBox.Items.Add(Ship); } if (RetoolList.Count != 0) m_oSummaryPanel.NewShipClassComboBox.SelectedIndex = 0; } }
private void clearAllButton_Click(object sender, EventArgs e) { drawings.Clear(); Redraw(); clickedPoints.Clear(); }
/// <summary> /// Now I want a list of the ships of a specific class that are in orbit. these will potentially be targets for repair, refit, or scrap operations. /// </summary> /// <param name="CurrentFaction">Economics handler selected faction.</param> /// <param name="CurrentPopulation">Population from the economics handler.</param> /// <param name="CurrentShipClass">Shipclass selected via the RepairRefitScrapClassComboBox</param> /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param> private static void GetShipsOfClassInOrbit(Faction CurrentFaction, Population CurrentPopulation, ShipClassTN CurrentShipClass, ref BindingList<ShipTN> ShipsOfClassInOrbit) { ShipsOfClassInOrbit.Clear(); foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit) { if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction) { foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships) { if (CurrentShip.ShipClass == CurrentShipClass) ShipsOfClassInOrbit.Add(CurrentShip); } } } }
public static void Build(BindingList<PnlPosRow> structure_, ReturnsEval.DataSeriesEvaluator parentEval_, ConstructGen<double> wts_, string[] wtsKeys_) { structure_.Clear(); if (parentEval_.InnerSeries.Count != wts_.ArrayLength) return; List<DateTime> pnlDates = new List<DateTime>(parentEval_.Daily.Dates); for(int i=0;i<parentEval_.InnerSeries.Count;++i) { ReturnsEval.DataSeriesEvaluator eval = parentEval_.InnerSeries[i]; PnlPosRow row = new PnlPosRow(eval.Name); int indexInWts = -1; for(int j=0;j<wtsKeys_.Length;++j) if (string.Compare(eval.Name, wtsKeys_[j]) == 0) { indexInWts = j; break; } if (indexInWts == -1) continue; double[] wtsColumn = wts_.GetColumnValues(indexInWts); DateTime startOfPeriod = wts_.Dates[0]; for (int j = 1; j < wts_.Dates.Count; ++j) { // has weight flipped if (Statistics.AreSameSign(wtsColumn[j], wtsColumn[j - 1]) == false) { DateTime endOfPeriod = wts_.Dates[j]; int indexOfStart = (startOfPeriod==wts_.Dates[0]) ? 0 : pnlDates.IndexOf(startOfPeriod); int indexOfEnd = pnlDates.IndexOf(endOfPeriod); double pnlOverPeriod = eval.Daily.CumulativeReturnSeries[indexOfEnd] - eval.Daily.CumulativeReturnSeries[indexOfStart]; row.Add(new PnlPosPeriodRow( getSide(wtsColumn[j-1]), pnlDates[indexOfStart], pnlDates[indexOfEnd], pnlOverPeriod), false); startOfPeriod = endOfPeriod; } } int indStart = pnlDates.IndexOf(startOfPeriod); int indEnd = pnlDates.Count-1; // need to add int last item row.Add(new PnlPosPeriodRow( getSide(wtsColumn[wtsColumn.Length - 1]), pnlDates[indStart], pnlDates[indEnd], eval.Daily.CumulativeReturnSeries[indEnd] - eval.Daily.CumulativeReturnSeries[indStart]), true); structure_.Add(row); } }