public HttpResponseMessage CheckVersion(string Version) { try { string NowVersion = ServerProfile.GetInstance().VendorVesion; string NowVersionNew = ServerProfile.GetInstance().VendorVesionNew; if (Version != NowVersion && Version != NowVersionNew) { _logger.Error("版本不正確,登入者的廠商APP版本:" + Version); return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(false, "版本不正確", 0, false))); } else { return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(true, "版本正確", 1, true))); } } catch (Exception ex) { _logger.Error(ex.Message + ",登入者的廠商APP版本:" + Version); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"{ ex.GetType().Name}:Message:{ex.Message}")); } }
private async Task LoadModsFromProfile() { // build a list of mods to be processed var modIdList = new List <string>(); var serverMapModId = ServerProfile.GetProfileMapModId(_profile); if (!string.IsNullOrWhiteSpace(serverMapModId)) { modIdList.Add(serverMapModId); } if (!string.IsNullOrWhiteSpace(_profile.TotalConversionModId)) { modIdList.Add(_profile.TotalConversionModId); } modIdList.AddRange(ModUtils.GetModIdList(_profile.ServerModIds)); modIdList = ModUtils.ValidateModList(modIdList); var response = await GetModDetails(modIdList); var modDetails = ModDetailList.GetModDetails(response, Path.Combine(_profile.InstallDirectory, Config.Default.ServerModsRelativePath), modIdList); UpdateModDetailsList(modDetails); ModDetailsChanged = false; }
WorkshareProfileCollection IWorkshareProfileProvider.GetProfiles() { WorkshareProfileCollection profiles = new WorkshareProfileCollection(); int profileCount = _provider.GetProfilesCount(); for (int i = 0; i < profileCount; i++) { Notes.IProfile profile = _provider.GetProfile(i); ServerProfile serverProfile = new ServerProfile(profile.GetName(), profile.GetDescription(), profile.GetDisplayName(), profile.GetEmailAddress()); if (string.IsNullOrEmpty(serverProfile.Name) || string.IsNullOrEmpty(serverProfile.EmailAddress)) { Logger.LogError("Failed to add the Server Profile to the collection. Either the Name or EmailAddress is invalid."); continue; } Logger.LogDebug(string.Format( "Adding server profile \"{0}\" with email address \"{1}\".", serverProfile.Name, serverProfile.EmailAddress)); profiles.Add(i, serverProfile); } // Always insert a "Workshare Default Server Profile at the end" // The Workshare default is defined by an email address with an empty string. Logger.LogDebug("Adding default server profile with empty email address."); profiles.Add(profiles.Count + 1, new ServerProfile( DefaultServerProfileName, DefaultServerProfileDescription, string.Empty, 0, string.Empty)); return profiles; }
static void InviteMemberButton_clicked(object obj) { WorkspaceInfo wkInfo = (WorkspaceInfo)obj; CurrentUserAdminCheckResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(50); waiter.Execute( /*threadOperationDelegate*/ delegate { RepositorySpec repSpec = PlasticGui.Plastic.API.GetRepositorySpec(wkInfo); ServerProfile serverProfile = CmConnection.Get().GetProfileManager().GetProfileForServer(repSpec.Server) ?? ClientConfig.Get().GetDefaultProfile(); string authToken = CmConnection.Get() .BuildWebApiTokenForCloudEditionForProfileAndOrg( serverProfile); response = WebRestApiClient.PlasticScm.IsUserAdmin( ServerOrganizationParser.GetOrganizationFromServer(repSpec.Server), authToken); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "IsUserAdmin", waiter.Exception); return; } if (response.Error != null) { Debug.LogErrorFormat( "Error checking if the user is the organization admin: {0}", string.Format("Unable to get IsUserAdminResponse: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode)); return; } if (response.IsCurrentUserAdmin) { Application.OpenURL("https://www.plasticscm.com/dashboard/cloud/" + response.OrganizationName + "/users-and-groups"); return; } GuiMessage.ShowInformation( PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersTitle), PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersMessage)); }); }
public HttpResponseMessage GetcompressionCallog(string filePath) { //頭貼路徑 var path = ServerProfile.GetInstance().CALLOG_PATH; //完整路徑 var img = Image.FromFile(path + filePath); Bitmap bit = new Bitmap(img, 100, 150); using (MemoryStream ms = new MemoryStream()) { bit.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/Jpeg"); result.Headers.CacheControl = new CacheControlHeaderValue() { NoStore = true, NoCache = true, MustRevalidate = true }; img.Dispose(); ms.Dispose(); return(result); } }
public HttpResponseMessage SaveLogHQ() { try { HttpMultipartParser.MultipartFormDataParser parser = new HttpMultipartParser.MultipartFormDataParser(HttpContext.Current.Request.InputStream); var Files = parser.Files; var user = ((PtcIdentity)this.User.Identity).currentUser; string url = ServerProfile.GetInstance().LOG_PATH; if (Files == null || Files.Count() == 0) { throw new ArgumentNullException($"[ERROR]=>上傳LOG FILE時,並未給入檔案"); } foreach (var file in Files) { string fullPath = $"{url}/{user.CompCd}/{user.RoleId}/{user.UserId}/"; FileUtil.Save(fullPath, file.Name, file.Data); } } catch (Exception ex) { _logger.Error(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"{ ex.GetType().Name}:message:{ex.Message}")); } return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(true, "上傳LOG FILE成功", 1, true))); }
private void btnSchedule_Click(object sender, EventArgs e) { if (profileSelectionIndex > -1) { int index = GetServerHostIndex(Config.Profiles[profileSelectionIndex].ID); if (index > -1) { ScheduleDialog dialog = new ScheduleDialog(); dialog.SetMinecraftServerPath(Config.Profiles[profileSelectionIndex].Path); // Pass the existing schedules to the dialog dialog.ScheduleProfiles = Config.Profiles[profileSelectionIndex].Schedules; dialog.ShowDialog(this); // Retrieve the schedules from the dialog ServerProfile profile = Config.Profiles[profileSelectionIndex]; profile.Schedules = dialog.ScheduleProfiles; Config.Profiles[profileSelectionIndex] = profile; Config.Save(true); dialog.Dispose(); UpdateRestartManager(); } } }
public HttpResponseMessage GetSticker(string filePath) { //頭貼路徑 var path = ServerProfile.GetInstance().STICKER_PATH; //完整路徑 var img = Image.FromFile(path + filePath); using (MemoryStream ms = new MemoryStream()) { img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); result.Headers.CacheControl = new CacheControlHeaderValue() { NoStore = true, NoCache = true, MustRevalidate = true }; img.Dispose(); ms.Dispose(); return(result); } }
private void AttachToProfileCore(ServerProfile profile) { UnregisterForUpdates(); this.ProfileSnapshot = new RuntimeProfileSnapshot { InstallDirectory = profile.InstallDirectory, QueryPort = profile.ServerPort, ServerConnectionPort = profile.ServerConnectionPort, ServerIP = String.IsNullOrWhiteSpace(profile.ServerIP) ? IPAddress.Loopback.ToString() : profile.ServerIP, LastInstalledVersion = profile.LastInstalledVersion, ProfileName = profile.ProfileName, RCONEnabled = profile.RCONEnabled, RCONPort = profile.RCONPort, ServerName = profile.ServerName, ServerArgs = profile.GetServerArgs(), AdminPassword = profile.AdminPassword }; Version lastInstalled; if (Version.TryParse(profile.LastInstalledVersion, out lastInstalled)) { this.Version = lastInstalled; } RegisterForUpdates(); }
private void AttachToProfileCore(ServerProfile profile) { UnregisterForUpdates(); this.ProfileSnapshot = new RuntimeProfileSnapshot { ProfileName = profile.ProfileName, InstallDirectory = profile.InstallDirectory, AltSaveDirectoryName = profile.AltSaveDirectoryName, AdminPassword = profile.AdminPassword, ServerName = profile.ServerName, ServerArgs = profile.GetServerArgs(), ServerIP = String.IsNullOrWhiteSpace(profile.ServerIP) ? IPAddress.Loopback.ToString() : profile.ServerIP, ServerConnectionPort = profile.ServerConnectionPort, QueryPort = profile.ServerPort, UseRawSockets = profile.UseRawSockets, RCONEnabled = profile.RCONEnabled, RCONPort = profile.RCONPort, SotFServer = profile.SOTF_Enabled, ServerMap = ServerProfile.GetProfileMapName(profile), ServerMapModId = ServerProfile.GetProfileMapModId(profile), TotalConversionModId = profile.TotalConversionModId ?? string.Empty, ServerModIds = ModUtils.GetModIdList(profile.ServerModIds), LastInstalledVersion = string.IsNullOrWhiteSpace(profile.LastInstalledVersion) ? new Version(0, 0).ToString() : profile.LastInstalledVersion, }; Version lastInstalled; if (Version.TryParse(profile.LastInstalledVersion, out lastInstalled)) { this.Version = lastInstalled; } RegisterForUpdates(); }
private async Task UpdatePlayerDetails() { if (!String.IsNullOrEmpty(rconParams.InstallDirectory)) { var savedArksPath = ServerProfile.GetProfileSavePath(rconParams.InstallDirectory, rconParams.AltSaveDirectoryName, rconParams.PGM_Enabled, rconParams.PGM_Name); var arkData = await ArkData.ArkDataContainer.CreateAsync(savedArksPath); await arkData.LoadSteamAsync(Config.Default.SteamAPIKey); TaskUtils.RunOnUIThreadAsync(() => { foreach (var playerData in arkData.Players) { var playerToUpdate = this.Players.FirstOrDefault(p => p.SteamId == Int64.Parse(playerData.SteamId)); if (playerToUpdate != null) { playerToUpdate.UpdateArkDataAsync(playerData).DoNotWait(); } else { var newPlayer = new PlayerInfo() { SteamId = Int64.Parse(playerData.SteamId), SteamName = playerData.SteamName }; newPlayer.UpdateArkDataAsync(playerData).DoNotWait(); this.Players.Add(newPlayer); } } }).DoNotWait(); } }
private async Task LoadModsFromProfile() { // build a list of mods to be processed var modIdList = new List <string>(); var serverMapModId = ServerProfile.GetProfileMapModId(_profile); if (!string.IsNullOrWhiteSpace(serverMapModId)) { modIdList.Add(serverMapModId); } if (!string.IsNullOrWhiteSpace(_profile.TotalConversionModId)) { modIdList.Add(_profile.TotalConversionModId); } modIdList.AddRange(ModUtils.GetModIdList(_profile.ServerModIds)); modIdList = ModUtils.ValidateModList(modIdList); var response = await Task.Run(() => SteamUtils.GetSteamModDetails(modIdList)); var workshopFiles = WorkshopFiles; var modsRootFolder = Path.Combine(_profile.InstallDirectory, Config.Default.ServerModsRelativePath); var modDetails = ModDetailList.GetModDetails(modIdList, modsRootFolder, workshopFiles, response); UpdateModDetailsList(modDetails); ModDetailsStatusMessage = modDetails.Count > 0 && response?.publishedfiledetails == null?_globalizer.GetResourceString("ModDetails_ModDetailFetchFailed_Label") : string.Empty; ModDetailsChanged = false; }
/// <summary> /// 取得技能證書 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public ActionResult GetLicense(string filePath) { try { var url = ServerProfile.GetInstance().LICENSE_PATH; var fullPath = url + filePath; if (!System.IO.File.Exists(fullPath)) { fullPath = ServerProfile.GetInstance().NON_FILE_PATH; } if (string.IsNullOrEmpty(fullPath)) { throw new NullReferenceException($"no find data"); } return(File(fullPath, fullPath.GetContentType())); } catch (Exception ex) { _logger.Error(ex.Message); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
private void UpdateServerStatus(int serverHostID, ServerStatus newStatus) { int serverProfileIndex = GetServerProfileIndex(serverHostID); if (serverProfileIndex > -1) { /* * Status: * 0 = Stopped * 1 = Starting up * 2 = Running * 3 = Stopping / shutting down * */ if (Config.Profiles[serverProfileIndex].Status != (byte)newStatus) { ServerProfile profile = Config.Profiles[serverProfileIndex]; profile.Status = (byte)newStatus; if (newStatus == ServerStatus.Stopping) { profile.PlayerCount = 0; } Config.Profiles[serverProfileIndex] = profile; // Force an update of the UI Invalidate(); } } }
private void InitializeFromProfile(ServerProfile profile) { this.Profile = profile; this.Runtime = new ServerRuntime(); this.Runtime.AttachToProfile(this.Profile).Wait(); this.Runtime.StatusUpdate += Runtime_StatusUpdate; }
private async Task UpdatePlayerDetails() { if (updatingPlayerDetails) { return; } updatingPlayerDetails = true; if (!String.IsNullOrEmpty(rconParams.InstallDirectory)) { var savedArksPath = ServerProfile.GetProfileSavePath(rconParams.InstallDirectory, rconParams.AltSaveDirectoryName, rconParams.PGM_Enabled, rconParams.PGM_Name); var arkData = await ArkData.ArkDataContainer.CreateAsync(savedArksPath); try { await arkData.LoadSteamAsync(SteamUtils.SteamWebApiKey); } catch (Exception ex) { Debug.WriteLine($"Error: UpdatePlayerDetails - arkData.LoadSteamAsync - {ex.Message}"); } TaskUtils.RunOnUIThreadAsync(() => { // create a new temporary list List <PlayerInfo> players = new List <PlayerInfo>(this.Players.Count + arkData.Players.Count); players.AddRange(this.Players); try { foreach (var playerData in arkData.Players) { var player = players.FirstOrDefault(p => p.SteamId == Int64.Parse(playerData.SteamId)); if (player == null) { player = new PlayerInfo() { SteamId = Int64.Parse(playerData.SteamId), SteamName = playerData.SteamName }; players.Add(player); } if (player != null) { player.UpdateArkDataAsync(playerData).DoNotWait(); } } this.Players = new SortableObservableCollection <PlayerInfo>(players); OnPlayerCollectionUpdated(); } finally { updatingPlayerDetails = false; } }).DoNotWait(); } }
public void ImportFromPath(string path, ServerProfile profile = null) { var loadedProfile = ServerProfile.LoadFrom(path, profile); if (loadedProfile != null) { InitializeFromProfile(loadedProfile); } }
private void btnEditServerProfile_Click(object sender, RoutedEventArgs e) { var addServerDialog = new AddServerDialog(ManageProcess.Update, _config.GetServerProfile(new Guid(((Button)sender).Tag.ToString()))); if (addServerDialog.ShowDialog() == true) { ChangedServer = addServerDialog.ChangedProfile; } }
public void LoadServerProfiles() { if (Properties.Settings.Default.Servers != null) { var currentProfiles = Properties.Settings.Default.Servers; Dispatcher?.Invoke(() => { IServerProfilesMenu.Items.Clear(); }); for (int i = IMainContent.Items.Count - 4; i <= 0; i++) { IMainContent.Items.RemoveAt(i); } foreach (var profile in currentProfiles.ServerProfiles) { ListBoxItem newItem = new ListBoxItem { Name = profile.SafeName, Content = profile.DisplayName }; Dispatcher?.Invoke(() => { IServerProfilesMenu.Items.Add(newItem); }); newItem.Selected += MenuItem_Selected; var duplicate = false; foreach (TabItem tab in IMainContent.Items) { if (profile.SafeName == tab.Name) { duplicate = true; } } if (!duplicate) { var tabControls = new ServerProfile(profile); TabItem newTab = new TabItem { Name = profile.SafeName, Content = tabControls, Header = profile.SafeName }; Dispatcher?.Invoke(() => { IMainContent.Items.Add(newTab); }); } } } }
public ModDetailsWindow(ServerProfile profile) { InitializeComponent(); WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile); _profile = profile; this.Title = string.Format(_globalizer.GetResourceString("ModDetails_ProfileTitle"), _profile?.ProfileName); this.DataContext = this; }
public static Server FromPath(string path) { var loadedProfile = ServerProfile.LoadFrom(path); if (loadedProfile == null) { return(null); } return(new Server(loadedProfile)); }
public static Server FromDefaults() { var loadedProfile = ServerProfile.FromDefaults(); if (loadedProfile == null) { return(null); } return(new Server(loadedProfile)); }
private void addServerNew(object parameter) { ServerProfile server = new ServerProfile(); if (new DialogServerConfig(server).ShowDialog() is bool update && update == true) { int added = addServer(server); App.ShowNotify($"{added} {sr_config_x_added}"); } }
internal void UpdateServerProfile(ServerProfile serverProfile) { var profileToUpdate = Config.ServerProfiles.FirstOrDefault(x => x.Id == serverProfile.Id); if (profileToUpdate == null) { return; } profileToUpdate = serverProfile; SaveChanges(); }
public ProfileSyncWindow(ServerManager serverManager, ServerProfile profile) { InitializeComponent(); WindowUtils.RemoveDefaultResourceDictionary(this); this.Title = string.Format(_globalizer.GetResourceString("ProfileSyncWindow_ProfileTitle"), profile?.ProfileName); this.ServerManager = serverManager; this.Profile = profile; this.DataContext = this; }
public Config() { IsTransmitEnabled = false; SystemProxyPort = 0; GlobalSocks5Port = 0; RemoteServer = null; ConnectionTimeouts = 3; PingTimeouts = 1; }
private int addServer(ServerProfile server) { int added = 0; if (ObServerInfoList.FirstOrDefault(predicate: x => x.vServerProfile.Equals(server)) == null) { ObServerInfoList.Add(new ServerProfileView(server)); ++added; } return(added); }
public WorldSaveRestoreWindow(ServerProfile profile) { InitializeComponent(); WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile); _profile = profile; this.Title = string.Format(_globalizer.GetResourceString("WorldSaveRestore_ProfileTitle"), _profile?.ProfileName); WorldSaveFiles = new WorldSaveFileList(); this.DataContext = this; }
public ActionResult ResetPasswordConfirmation() { if (ServerProfile.GetInstance().Debugger == "0") { return(View()); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } }
public static ServerProfileSnapshot Create(ServerProfile profile) { return(new ServerProfileSnapshot { ProfileId = profile.ProfileID, ProfileName = profile.ProfileName, InstallDirectory = profile.InstallDirectory, AltSaveDirectoryName = profile.AltSaveDirectoryName, PGM_Enabled = profile.PGM_Enabled, PGM_Name = profile.PGM_Name, AdminPassword = profile.AdminPassword, ServerName = profile.ServerName, ServerArgs = profile.GetServerArgs(), ServerIP = string.IsNullOrWhiteSpace(profile.ServerIP) ? IPAddress.Loopback.ToString() : profile.ServerIP.Trim(), ServerPort = profile.ServerPort, ServerPeerPort = profile.ServerPeerPort, QueryPort = profile.QueryPort, RCONEnabled = profile.RCONEnabled, RCONPort = profile.RCONPort, ServerMap = ServerProfile.GetProfileMapName(profile), ServerMapModId = ServerProfile.GetProfileMapModId(profile), TotalConversionModId = profile.TotalConversionModId ?? string.Empty, ServerModIds = ModUtils.GetModIdList(profile.ServerModIds), MOTD = profile.MOTD, MotDDuration = Math.Max(profile.MOTDDuration, 10), MOTDIntervalEnabled = profile.MOTDInterval.HasValue && !string.IsNullOrWhiteSpace(profile.MOTD), MOTDInterval = Math.Max(1, Math.Min(int.MaxValue, profile.MOTDInterval.Value)), ForceRespawnDinos = profile.ForceRespawnDinos, BranchName = profile.BranchName, BranchPassword = profile.BranchPassword, SchedulerKey = profile.GetProfileKey(), EnableAutoBackup = profile.EnableAutoBackup, EnableAutoUpdate = profile.EnableAutoUpdate, EnableAutoShutdown1 = profile.EnableAutoShutdown1, RestartAfterShutdown1 = profile.RestartAfterShutdown1, UpdateAfterShutdown1 = profile.UpdateAfterShutdown1, EnableAutoShutdown2 = profile.EnableAutoShutdown2, RestartAfterShutdown2 = profile.RestartAfterShutdown2, UpdateAfterShutdown2 = profile.UpdateAfterShutdown2, AutoRestartIfShutdown = profile.AutoRestartIfShutdown, SotFEnabled = profile.SOTF_Enabled, MaxPlayerCount = profile.MaxPlayers, ServerUpdated = false, LastInstalledVersion = profile.LastInstalledVersion ?? new Version(0, 0).ToString(), LastStarted = profile.LastStarted, }); }
private async Task LoadWorldSaveFiles() { var cursor = this.Cursor; try { Application.Current.Dispatcher.Invoke(() => this.Cursor = System.Windows.Input.Cursors.Wait); await Task.Delay(500); WorldSaveFiles.Clear(); var saveFolder = ServerProfile.GetProfileSavePath(_profile); if (!Directory.Exists(saveFolder)) { return; } var saveFolderInfo = new DirectoryInfo(saveFolder); var mapName = ServerProfile.GetProfileMapFileName(_profile); var mapFileName = $"{mapName}{Config.Default.MapExtension}"; var searchPattern = $"{mapName}*{Config.Default.MapExtension}"; var saveFiles = saveFolderInfo.GetFiles(searchPattern); foreach (var file in saveFiles) { WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) }); } var backupFolder = ServerApp.GetServerBackupFolder(_profile.ProfileName); if (Directory.Exists(backupFolder)) { var backupFolderInfo = new DirectoryInfo(backupFolder); searchPattern = $"{mapName}*{Config.Default.BackupExtension}"; var backupFiles = backupFolderInfo.GetFiles(searchPattern); foreach (var file in backupFiles) { WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = true, IsActiveFile = false }); } } WorldSaveFiles.Sort(f => f, new WorldSaveFileComparer()); } finally { Application.Current.Dispatcher.Invoke(() => this.Cursor = cursor); } }
private void ConfirmDeleteProfile() { try { //Delete from Database db = new SQLiteDatabase(); db.Delete("profileList", String.Format("profilName = '{0}'", profileSelected.ProfilName)); loginDataView.ServersProfiles.Remove(profileSelected); this.profileSelected = null; NotifyBox.Show( (DrawingImage)this.FindResource("SearchDrawingImage"), "Profil Manager", "Profil supprimé avec succès !", false); } catch (Exception e) { MessageDialog.ShowAsync( "Exception !", "Problème lors de la suppression du profil selectionné, annulation !", MessageBoxButton.OK, MessageDialogType.Light, this); Logger.ExceptionLogger.Error("Attempt to delete from database error : " + profileSelected.ToString() + "\n" + e.ToString()); } }
private WorkshareProfileCollection GetServerProfile() { var profiles = new WorkshareProfileCollection(); if (_provider == null) { Logger.LogError("Provider (Outlook.Application) is null or has not been set."); return profiles; } if (string.IsNullOrEmpty(_distributionListName)) { Logger.LogError("DistributionListName is null or has not been set."); return profiles; } RecipientsProxy.OutlookSecurity.Instance.Disable(); try { Redemption.RDOSession session = RedemptionLoader.new_RDOSession(); session.MAPIOBJECT = _provider.Session.MAPIOBJECT; Redemption.RDOAddressEntry dl = FindAddressEntry(session.AddressBook.GAL.ResolveNameEx(_distributionListName), _distributionListName); if (dl == null) { Redemption.IRDOAddressList con = FindAddressList(session.AddressBook.AddressLists(), "Contacts"); if (con != null) { dl = FindAddressEntry(con.AddressEntries, _distributionListName); } if (dl == null) { Logger.LogError("DistributionList not found in either GAL or Contacts"); return profiles; } } int profileIndex = 1; foreach (Redemption.RDOAddressEntry entry in dl.Members) { string profileDescription = entry.Name; try { // Profile description will be specified in 'Notes' property for a contact in Exchange Server // 'Notes' property is available through 'Comments' property of ExhchangeUser. profileDescription = entry.Comments; } catch (Exception ex) { Logger.LogError("Unable to find Profile Description. Setting to Profile Name."); Logger.LogError(ex); } ServerProfile sp = new ServerProfile(entry.Name, profileDescription, String.IsNullOrWhiteSpace(entry.SMTPAddress) ? entry.Address : entry.SMTPAddress); profiles.Add(profileIndex - 1, sp); profileIndex++; Logger.LogDebug(string.Format("Server profile \"{0}\" and email address \"{1}\" added", sp.Name, sp.EmailAddress)); } return profiles; } finally { if (_provider == null) { RecipientsProxy.OutlookSecurity.Instance.Enable(); } } }
public void UpdateUIUsingCollection() { int index = this.ListBoxServers.SelectedIndex; Logger.MonitoringLogger.Debug("Selection changed to index " + index); Boolean activeButton = false; String hostnameValue = ""; String portValue = ""; String passwordValue = ""; Boolean autoReconnectValue = false; //Checks if index is selected or unselected if (index != -1) { activeButton = true; foreach (ServerProfile prof in loginDataView.ServersProfiles) { if (loginDataView.ServersProfiles.IndexOf(prof) == index) profileSelected = prof; }; //Set UI hostnameValue = profileSelected.Hostname; portValue = profileSelected.Port.ToString(); passwordValue = profileSelected.Password; autoReconnectValue = profileSelected.AutoReconnect; } //Now update the UI Logger.MonitoringLogger.Debug("Updating UI with new parameters"); this.HostnameValue.Text = hostnameValue; this.PortValue.Text = portValue; this.PasswordValue.Password = passwordValue; this.AutoReconnectSwitch.IsChecked = autoReconnectValue; this.ConnectButton.IsEnabled = activeButton; this.ModifyButton.IsEnabled = activeButton; this.DeleteButton.IsEnabled = activeButton; }
void LoadedEventHandler(object sender, RoutedEventArgs e) { Logger.MonitoringLogger.Debug("Login window loaded event"); LoadFromConfigurationFile(); try { Logger.MonitoringLogger.Info("Populate profile list with information from the database"); db = new SQLiteDatabase(); DataTable resultQuery; String query = "select * FROM profileList;"; resultQuery = db.GetDataTable(query); // Loop over all data foreach (DataRow r in resultQuery.Rows) { ServerProfile serverProfile = new ServerProfile(r["profilName"].ToString(), r["hostname"].ToString(), Int32.Parse(r["port"].ToString()), r["password"].ToString(), Boolean.Parse(r["autoReconnect"].ToString())); loginDataView.ServersProfiles.Add(serverProfile); Logger.MonitoringLogger.Info(r.ToString()); } } catch (Exception databaseException) { MessageDialog.ShowAsync( "Erreur de lecture de la base de donnée", "Erreur de lecture de la base de donnée ! Informations de debug :\n" + databaseException.ToString(), MessageBoxButton.OK, MessageDialogType.Light, this); } NotifyBox.Show( (DrawingImage)this.FindResource("SearchDrawingImage"), "Astuce", "Un clic droit permet d'ouvrir le menu application !", false); Logger.MonitoringLogger.Debug(WINDOW_NAME + " loaded function ended"); }