private int CalculateActualSyncInterval(int spinValue, SyncUnit syncUnit) { int actualSyncInterval; switch (syncUnit) { case SyncUnit.Seconds: actualSyncInterval = spinValue; // No conversion break; case SyncUnit.Minutes: actualSyncInterval = spinValue * 60; break; case SyncUnit.Hours: actualSyncInterval = spinValue * 60 * 60; break; case SyncUnit.Days: actualSyncInterval = spinValue * 60 * 60 * 24; break; default: actualSyncInterval = 0; break; } return(actualSyncInterval); }
private int CalculateSyncSpinValue(int syncInterval, SyncUnit syncUnit) { int convertedInterval; switch (syncUnit) { case SyncUnit.Seconds: convertedInterval = syncInterval; // No conversion break; case SyncUnit.Minutes: convertedInterval = syncInterval / 60; break; case SyncUnit.Hours: convertedInterval = syncInterval / 60 / 60; break; case SyncUnit.Days: convertedInterval = syncInterval / 60 / 60 / 24; break; default: convertedInterval = 0; break; } return(convertedInterval); }
private void WaitingForPlayers() { foreach (string line in Config.Lines) { SyncUnit unit = new SyncUnit { UnitName = line, SpawnableTeam = (byte)SpawnableTeamType.NineTailedFox }; RespawnManager.Singleton.NamingManager.AllUnitNames.Add(unit); } }
private void OnAutoSyncButton(object o, EventArgs args) { if (AutoSyncCheckButton.Active == true) { SyncSpinButton.Sensitive = true; SyncUnitsComboBox.Sensitive = true; SyncUnitsComboBox.Changed -= new EventHandler(OnSyncUnitsChanged); SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; currentSyncUnit = SyncUnit.Minutes; SaveSyncUnitConfig(); SyncUnitsComboBox.Changed += new EventHandler(OnSyncUnitsChanged); SyncSpinButton.Value = 5; } else { if (oneMinuteLimitNotifyWindow != null) { oneMinuteLimitNotifyWindow.Hide(); oneMinuteLimitNotifyWindow.Destroy(); oneMinuteLimitNotifyWindow = null; } try { ifws.SetDefaultSyncInterval(-1); } catch (Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); return; } SyncSpinButton.ValueChanged -= new EventHandler(OnSyncIntervalChanged); SyncSpinButton.Value = 0; SyncSpinButton.Sensitive = false; SyncUnitsComboBox.Sensitive = false; SyncSpinButton.ValueChanged += new EventHandler(OnSyncIntervalChanged); } }
private int CalculateActualSyncInterval(int spinValue, SyncUnit syncUnit) { int actualSyncInterval; switch (syncUnit) { case SyncUnit.Seconds: actualSyncInterval = spinValue; break; case SyncUnit.Minutes: actualSyncInterval = spinValue * 60; break; case SyncUnit.Hours: actualSyncInterval = spinValue * 60 * 60; break; case SyncUnit.Days: actualSyncInterval = spinValue * 60 * 60 * 24; break; default: actualSyncInterval = 0; break; } return actualSyncInterval; }
private int CalculateSyncSpinValue(int syncInterval, SyncUnit syncUnit) { int convertedInterval; switch (syncUnit) { case SyncUnit.Seconds: convertedInterval = syncInterval; break; case SyncUnit.Minutes: convertedInterval = syncInterval / 60; break; case SyncUnit.Hours: convertedInterval = syncInterval / 60 / 60; break; case SyncUnit.Days: convertedInterval = syncInterval / 60 / 60 / 24; break; default: convertedInterval = 0; break; } return convertedInterval; }
private void PopulateWidgets() { if(ClientConfig.Get(ClientConfig.KEY_SHOW_CREATION, "true") == "true") ShowConfirmationButton.Active = true; else ShowConfirmationButton.Active = false; if(ClientConfig.Get(ClientConfig.KEY_NOTIFY_USERS, "true") == "true") NotifyUsersButton.Active = true; else NotifyUsersButton.Active = false; if(ClientConfig.Get(ClientConfig.KEY_NOTIFY_COLLISIONS, "true") == "true") NotifyCollisionsButton.Active = true; else NotifyCollisionsButton.Active = false; if(ClientConfig.Get(ClientConfig.KEY_NOTIFY_IFOLDERS, "true") == "true") NotifyiFoldersButton.Active = true; else NotifyiFoldersButton.Active = false; try { lastSyncInterval = ifws.GetDefaultSyncInterval(); if(lastSyncInterval <= 0) SyncSpinButton.Value = 0; else { string syncUnitString = ClientConfig.Get(ClientConfig.KEY_SYNC_UNIT, "Minutes"); switch (syncUnitString) { case "Seconds": currentSyncUnit = SyncUnit.Seconds; SyncUnitsComboBox.Active = (int)SyncUnit.Seconds; SyncSpinButton.Adjustment.Lower = 60; break; case "Minutes": currentSyncUnit = SyncUnit.Minutes; SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; break; case "Hours": currentSyncUnit = SyncUnit.Hours; SyncUnitsComboBox.Active = (int)SyncUnit.Hours; break; case "Days": currentSyncUnit = SyncUnit.Days; SyncUnitsComboBox.Active = (int)SyncUnit.Days; break; default: break; } SyncSpinButton.Value = CalculateSyncSpinValue(lastSyncInterval, currentSyncUnit); } } catch(Exception e) { lastSyncInterval = -1; SyncSpinButton.Value = 0; } if (lastSyncInterval <= 0) { AutoSyncCheckButton.Active = false; SyncSpinButton.Sensitive = false; SyncUnitsComboBox.Sensitive = false; } else { AutoSyncCheckButton.Active = true; SyncSpinButton.Sensitive = true; SyncUnitsComboBox.Sensitive = true; } AutoSyncCheckButton.Toggled += new EventHandler(OnAutoSyncButton); SyncSpinButton.ValueChanged += new EventHandler(OnSyncIntervalChanged); SyncUnitsComboBox.Changed += new EventHandler(OnSyncUnitsChanged); }
private void OnSyncUnitsChanged(object o, EventArgs args) { if (oneMinuteLimitNotifyWindow != null) { oneMinuteLimitNotifyWindow.Hide(); oneMinuteLimitNotifyWindow.Destroy(); oneMinuteLimitNotifyWindow = null; } int syncSpinValue = (int)SyncSpinButton.Value; currentSyncUnit = (SyncUnit)SyncUnitsComboBox.Active; if (currentSyncUnit == SyncUnit.Seconds) { SyncSpinButton.Adjustment.Lower = 60; if (syncSpinValue < 60) { oneMinuteLimitNotifyWindow = new NotifyWindow( SyncSpinButton, Util.GS("Synchronization Interval Limit"), Util.GS("The synchronization interval cannot be set to less than one minute. It was automatically changed to 60 seconds."), Gtk.MessageType.Info, 10000); oneMinuteLimitNotifyWindow.ShowAll(); SyncSpinButton.ValueChanged -= new EventHandler(OnSyncIntervalChanged); SyncSpinButton.Value = 60; syncSpinValue = 60; SyncSpinButton.ValueChanged += new EventHandler(OnSyncIntervalChanged); } } else { SyncSpinButton.Adjustment.Lower = 1; } int syncInterval = CalculateActualSyncInterval(syncSpinValue, currentSyncUnit); try { lastSyncInterval = syncInterval; if(lastSyncInterval <= 0) { ifws.SetDefaultSyncInterval(-1); } else { ifws.SetDefaultSyncInterval(lastSyncInterval); } SaveSyncUnitConfig(); } catch(Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); return; } }
private void OnAutoSyncButton(object o, EventArgs args) { if(AutoSyncCheckButton.Active == true) { SyncSpinButton.Sensitive = true; SyncUnitsComboBox.Sensitive = true; SyncUnitsComboBox.Changed -= new EventHandler(OnSyncUnitsChanged); SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; currentSyncUnit = SyncUnit.Minutes; SaveSyncUnitConfig(); SyncUnitsComboBox.Changed += new EventHandler(OnSyncUnitsChanged); SyncSpinButton.Value = 5; } else { if (oneMinuteLimitNotifyWindow != null) { oneMinuteLimitNotifyWindow.Hide(); oneMinuteLimitNotifyWindow.Destroy(); oneMinuteLimitNotifyWindow = null; } try { ifws.SetDefaultSyncInterval(-1); } catch(Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); return; } SyncSpinButton.Value = 0; SyncSpinButton.Sensitive = false; SyncUnitsComboBox.Sensitive = false; } }
private void InitializeWidgets() { this.Spacing = Util.SectionSpacing; this.BorderWidth = Util.DefaultBorderWidth; VBox appSectionBox = new VBox(); appSectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(appSectionBox, false, true, 0); Label appSectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Application") + "</span>"); appSectionLabel.UseMarkup = true; appSectionLabel.Xalign = 0; appSectionBox.PackStart(appSectionLabel, false, true, 0); HBox appSpacerBox = new HBox(); appSectionBox.PackStart(appSpacerBox, false, true, 0); Label appSpaceLabel = new Label(" "); appSpacerBox.PackStart(appSpaceLabel, false, true, 0); VBox appWidgetBox = new VBox(); appSpacerBox.PackStart(appWidgetBox, false, true, 0); appWidgetBox.Spacing = Util.SectionTitleSpacing; ShowConfirmationButton = new CheckButton(Util.GS( "_Show Confirmation dialog when creating iFolders")); appWidgetBox.PackStart(ShowConfirmationButton, false, true, 0); ShowConfirmationButton.Toggled += new EventHandler(OnShowConfButton); Label strtlabel = new Label("<span style=\"italic\">" + Util.GS("To start up iFolder at login, leave iFolder running when you log out and save your current setup.") + "</span>"); strtlabel.UseMarkup = true; strtlabel.LineWrap = true; appWidgetBox.PackStart(strtlabel, false, true, 0); VBox notifySectionBox = new VBox(); notifySectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(notifySectionBox, false, true, 0); Label notifySectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Notification") + "</span>"); notifySectionLabel.UseMarkup = true; notifySectionLabel.Xalign = 0; notifySectionBox.PackStart(notifySectionLabel, false, true, 0); HBox notifySpacerBox = new HBox(); notifySectionBox.PackStart(notifySpacerBox, false, true, 0); Label notifySpaceLabel = new Label(" "); notifySpacerBox.PackStart(notifySpaceLabel, false, true, 0); VBox notifyWidgetBox = new VBox(); notifySpacerBox.PackStart(notifyWidgetBox, true, true, 0); notifyWidgetBox.Spacing = 5; NotifyiFoldersButton = new CheckButton(Util.GS("Notify of share_d iFolders")); notifyWidgetBox.PackStart(NotifyiFoldersButton, false, true, 0); NotifyiFoldersButton.Toggled += new EventHandler(OnNotifyiFoldersButton); NotifyCollisionsButton = new CheckButton(Util.GS("Notify of conflic_ts")); notifyWidgetBox.PackStart(NotifyCollisionsButton, false, true, 0); NotifyCollisionsButton.Toggled += new EventHandler(OnNotifyCollisionsButton); NotifyUsersButton = new CheckButton(Util.GS("Notify when a _user joins")); notifyWidgetBox.PackStart(NotifyUsersButton, false, true, 0); NotifyUsersButton.Toggled += new EventHandler(OnNotifyUsersButton); VBox syncSectionBox = new VBox(); syncSectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(syncSectionBox, false, true, 0); Label syncSectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Synchronization") + "</span>"); syncSectionLabel.UseMarkup = true; syncSectionLabel.Xalign = 0; syncSectionBox.PackStart(syncSectionLabel, false, true, 0); HBox syncSpacerBox = new HBox(); syncSectionBox.PackStart(syncSpacerBox, false, true, 0); Label syncSpaceLabel = new Label(" "); syncSpacerBox.PackStart(syncSpaceLabel, false, true, 0); VBox syncWidgetBox = new VBox(); syncSpacerBox.PackStart(syncWidgetBox, false, true, 0); syncWidgetBox.Spacing = 10; HBox syncHBox0 = new HBox(); syncWidgetBox.PackStart(syncHBox0, false, true, 0); syncHBox0.Spacing = 10; AutoSyncCheckButton = new CheckButton(Util.GS("Automatically S_ynchronize iFolders")); syncHBox0.PackStart(AutoSyncCheckButton, false, false, 0); HBox syncHBox = new HBox(); syncHBox.Spacing = 10; syncWidgetBox.PackStart(syncHBox, true, true, 0); Label spacerLabel = new Label(" "); syncHBox.PackStart(spacerLabel, true, true, 0); Label syncEveryLabel = new Label(Util.GS("Synchronize iFolders Every")); syncEveryLabel.Xalign = 1; syncHBox.PackStart(syncEveryLabel, false, false, 0); SyncSpinButton = new SpinButton(1, Int32.MaxValue, 1); syncHBox.PackStart(SyncSpinButton, false, false, 0); SyncUnitsComboBox = ComboBox.NewText(); syncHBox.PackStart(SyncUnitsComboBox, false, false, 0); SyncUnitsComboBox.AppendText(Util.GS("seconds")); SyncUnitsComboBox.AppendText(Util.GS("minutes")); SyncUnitsComboBox.AppendText(Util.GS("hours")); SyncUnitsComboBox.AppendText(Util.GS("days")); SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; currentSyncUnit = SyncUnit.Minutes; }
/// <summary> /// Set up the widgets /// </summary> /// <returns> /// Widget to display /// </returns> private void InitializeWidgets() { this.Spacing = Util.SectionSpacing; this.BorderWidth = Util.DefaultBorderWidth; //------------------------------ // Application Settings //------------------------------ // create a section box VBox appSectionBox = new VBox(); appSectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(appSectionBox, false, true, 0); Label appSectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Application") + "</span>"); appSectionLabel.UseMarkup = true; appSectionLabel.Xalign = 0; appSectionBox.PackStart(appSectionLabel, false, true, 0); // create a hbox to provide spacing HBox appSpacerBox = new HBox(); appSectionBox.PackStart(appSpacerBox, false, true, 0); Label appSpaceLabel = new Label(" "); // four spaces appSpacerBox.PackStart(appSpaceLabel, false, true, 0); // create a vbox to actually place the widgets in for section VBox appWidgetBox = new VBox(); appSpacerBox.PackStart(appWidgetBox, false, true, 0); appWidgetBox.Spacing = Util.SectionTitleSpacing; ShowConfirmationButton = new CheckButton(Util.GS( "_Display confirmation dialog on successful creation of iFolder")); appWidgetBox.PackStart(ShowConfirmationButton, false, true, 0); ShowConfirmationButton.Toggled += new EventHandler(OnShowConfButton); /* ShowNetworkstatusButton = * new CheckButton(Util.GS( * "Show _Network Events messages when iFolder is started")); * appWidgetBox.PackStart(ShowNetworkstatusButton, false, true, 0); * ShowNetworkstatusButton.Toggled += * new EventHandler(OnShowNetworkButton); */ Label strtlabel = new Label("<span style=\"italic\">" + Util.GS("To start up iFolder at login, leave iFolder running when you log out and save your current setup.") + "</span>"); strtlabel.UseMarkup = true; strtlabel.LineWrap = true; appWidgetBox.PackStart(strtlabel, false, true, 0); HideMainWindowButton = new CheckButton(Util.GS("Hide ifolder _main window at startup")); appWidgetBox.PackStart(HideMainWindowButton, false, true, 0); HideMainWindowButton.Toggled += new EventHandler(OnHideMainWindowButton); HideSyncLogButton = new CheckButton(Util.GS("Display synchronization _logs")); appWidgetBox.PackStart(HideSyncLogButton, false, true, 0); HideSyncLogButton.Toggled += new EventHandler(OnHideSyncLogButton); //------------------------------ // Notifications //------------------------------ // create a section box VBox notifySectionBox = new VBox(); notifySectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(notifySectionBox, true, true, 0); Label notifySectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Notification") + "</span>"); notifySectionLabel.UseMarkup = true; notifySectionLabel.Xalign = 0; notifySectionBox.PackStart(notifySectionLabel, false, true, 0); // create a hbox to provide spacing HBox notifySpacerBox = new HBox(); notifySectionBox.PackStart(notifySpacerBox, true, true, 0); Label notifySpaceLabel = new Label(" "); // four spaces notifySpacerBox.PackStart(notifySpaceLabel, false, true, 0); // create a vbox to actually place the widgets in for section VBox notifyWidgetBox = new VBox(); notifySpacerBox.PackStart(notifyWidgetBox, true, true, 0); notifyWidgetBox.Spacing = 5; VBox notificationPreferences = new NotificationPrefsBox(this.topLevelWindow); notifyWidgetBox.PackStart(notificationPreferences, true, true, 0); //------------------------------ // Sync Settings //------------------------------ // create a section box VBox syncSectionBox = new VBox(); syncSectionBox.Spacing = Util.SectionTitleSpacing; this.PackStart(syncSectionBox, false, true, 0); Label syncSectionLabel = new Label("<span weight=\"bold\">" + Util.GS("Synchronization") + "</span>"); syncSectionLabel.UseMarkup = true; syncSectionLabel.Xalign = 0; syncSectionBox.PackStart(syncSectionLabel, false, true, 0); // create a hbox to provide spacing HBox syncSpacerBox = new HBox(); syncSectionBox.PackStart(syncSpacerBox, false, true, 0); Label syncSpaceLabel = new Label(" "); // four spaces syncSpacerBox.PackStart(syncSpaceLabel, false, true, 0); // create a vbox to actually place the widgets in for section VBox syncWidgetBox = new VBox(); syncSpacerBox.PackStart(syncWidgetBox, false, true, 0); syncWidgetBox.Spacing = 10; HBox syncHBox0 = new HBox(); syncWidgetBox.PackStart(syncHBox0, false, true, 0); syncHBox0.Spacing = 10; AutoSyncCheckButton = new CheckButton(Util.GS("Automatically S_ynchronize iFolders")); syncHBox0.PackStart(AutoSyncCheckButton, false, false, 0); HBox syncHBox = new HBox(); syncHBox.Spacing = 10; syncWidgetBox.PackStart(syncHBox, true, true, 0); Label spacerLabel = new Label(" "); syncHBox.PackStart(spacerLabel, true, true, 0); Label syncEveryLabel = new Label(Util.GS("Synchronize iFolders Every")); syncEveryLabel.Xalign = 1; syncHBox.PackStart(syncEveryLabel, false, false, 0); SyncSpinButton = new SpinButton(1, Int32.MaxValue, 1); syncHBox.PackStart(SyncSpinButton, false, false, 0); SyncUnitsComboBox = ComboBox.NewText(); syncHBox.PackStart(SyncUnitsComboBox, false, false, 0); SyncUnitsComboBox.AppendText(Util.GS("seconds")); SyncUnitsComboBox.AppendText(Util.GS("minutes")); SyncUnitsComboBox.AppendText(Util.GS("hours")); SyncUnitsComboBox.AppendText(Util.GS("days")); SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; currentSyncUnit = SyncUnit.Minutes; }
private void OnSyncUnitsChanged(object o, EventArgs args) { if (oneMinuteLimitNotifyWindow != null) { oneMinuteLimitNotifyWindow.Hide(); oneMinuteLimitNotifyWindow.Destroy(); oneMinuteLimitNotifyWindow = null; } int syncSpinValue = (int)SyncSpinButton.Value; currentSyncUnit = (SyncUnit)SyncUnitsComboBox.Active; if (currentSyncUnit == SyncUnit.Seconds) { if (syncSpinValue < 5) { oneMinuteLimitNotifyWindow = new NotifyWindow( SyncSpinButton, Util.GS("Synchronization Interval Limit"), Util.GS("The synchronization interval cannot be set to less than 5 Seconds. It will automatically change to 5 seconds."), Gtk.MessageType.Info, 10000); oneMinuteLimitNotifyWindow.ShowAll(); SyncSpinButton.ValueChanged -= new EventHandler(OnSyncIntervalChanged); SyncSpinButton.Value = 5; syncSpinValue = 5; SyncSpinButton.ValueChanged += new EventHandler(OnSyncIntervalChanged); } SyncSpinButton.Adjustment.Lower = 1; } else { SyncSpinButton.Adjustment.Lower = 1; } int syncInterval = CalculateActualSyncInterval(syncSpinValue, currentSyncUnit); try { lastSyncInterval = syncInterval; if (lastSyncInterval <= 0) { ifws.SetDefaultSyncInterval(-1); } else { ifws.SetDefaultSyncInterval(lastSyncInterval); } SaveSyncUnitConfig(); } catch (Exception e) { iFolderExceptionDialog ied = new iFolderExceptionDialog( topLevelWindow, e); ied.Run(); ied.Hide(); ied.Destroy(); return; } }
/// <summary> /// Set the Values in the Widgets /// </summary> private void PopulateWidgets() { //------------------------------ // Set up all of the default values //------------------------------ if ((bool)ClientConfig.Get(ClientConfig.KEY_SHOW_CREATION)) { ShowConfirmationButton.Active = true; } else { ShowConfirmationButton.Active = false; } if ((bool)ClientConfig.Get(ClientConfig.KEY_SHOW_SYNC_LOG)) { HideSyncLogButton.Active = true; } else { HideSyncLogButton.Active = false; } if ((bool)ClientConfig.Get(ClientConfig.KEY_IFOLDER_WINDOW_HIDE)) { HideMainWindowButton.Active = true; } else { HideMainWindowButton.Active = false; } try { lastSyncInterval = ifws.GetDefaultSyncInterval(); if (lastSyncInterval <= 0) { SyncSpinButton.Value = 0; } else { string syncUnitString = (string) ClientConfig.Get(ClientConfig.KEY_SYNC_UNIT); switch (syncUnitString) { case "Seconds": currentSyncUnit = SyncUnit.Seconds; SyncUnitsComboBox.Active = (int)SyncUnit.Seconds; // Prevent the user from setting a sync interval less than // five seconds. SyncSpinButton.Adjustment.Lower = 1; break; case "Minutes": currentSyncUnit = SyncUnit.Minutes; SyncUnitsComboBox.Active = (int)SyncUnit.Minutes; break; case "Hours": currentSyncUnit = SyncUnit.Hours; SyncUnitsComboBox.Active = (int)SyncUnit.Hours; break; case "Days": currentSyncUnit = SyncUnit.Days; SyncUnitsComboBox.Active = (int)SyncUnit.Days; break; default: break; } SyncSpinButton.Value = CalculateSyncSpinValue(lastSyncInterval, currentSyncUnit); } } catch (Exception) { lastSyncInterval = -1; SyncSpinButton.Value = 0; } if (lastSyncInterval <= 0) { AutoSyncCheckButton.Active = false; SyncSpinButton.Sensitive = false; SyncUnitsComboBox.Sensitive = false; } else { AutoSyncCheckButton.Active = true; SyncSpinButton.Sensitive = true; SyncUnitsComboBox.Sensitive = true; } AutoSyncCheckButton.Toggled += new EventHandler(OnAutoSyncButton); SyncSpinButton.ValueChanged += new EventHandler(OnSyncIntervalChanged); SyncUnitsComboBox.Changed += new EventHandler(OnSyncUnitsChanged); }
/// <summary> /// /// </summary> /// <returns></returns> public SyncUnits SyncAllUnit() { SyncUnits collection = new SyncUnits(); DataTable dtSource = this.poxy.GetAllSchool(); if (dtSource != null && dtSource.Rows.Count > 0) { foreach (DataRow row in dtSource.Rows) { SyncUnit data = new SyncUnit(); data.UnitCode = Convert.ToString(row["DWDM"]); data.UnitName = Convert.ToString(row["DWMC"]); data.UnitType = Convert.ToString(row["DWLBM"]); collection.Add(data); } } return collection; }
/// <summary> /// 获取全部的学校单位。 /// </summary> /// <returns></returns> public SyncUnits SyncAllUnit() { string err = null; DataTable dtSource = this.poxy.SyncAllUnit(out err); if (!string.IsNullOrEmpty(err)) { throw new Exception("获取学校单位数据时发生异常:" + err); } SyncUnits units = new SyncUnits(); if (dtSource != null && dtSource.Rows.Count > 0) { foreach (DataRow row in dtSource.Rows) { SyncUnit su = new SyncUnit(); su.UnitCode = string.Format("{0}", row["UnitCode"]); su.UnitName = string.Format("{0}", row["UnitName"]); su.UnitType = string.Format("{0}", row["UnitType"]); units.Add(su); } } return units; }