/// <summary> /// Read a file containing users and their followers, and return a user mapping /// </summary> /// <param name="userFile"></param> /// <returns></returns> public static UserMappings BuildUserList(string userFileName) { var users = new UserMappings(); string[] fileLines = File.ReadAllLines(userFileName); foreach (var line in fileLines) { var splitLine = line.Split(new string[] { Settings.Default.FollowsPattern, Settings.Default.Seperator }, StringSplitOptions.RemoveEmptyEntries); if (splitLine != null && splitLine.Length > 1) { var followerName = splitLine[0].Trim(); for (int index = splitLine.Length - 1; index > 0; --index) { var userName = splitLine[index].Trim(); users.AddUserAndFollower(userName, followerName); } } else { throw new FormatException(Validation.USER_FILE_FORMAT); } } return(users); }
private void UserMappingsClick(object sender, EventArgs e) { var userMappings = new UserMappings(_settings); userMappings.ShowDialog(this); _userList.RefreshUserPanelVisibility(); }
public ActionResult Logout(string keyResponseDomainSite, string userName) { ScrLogout model = new ScrLogout(keyResponseDomainSite); //For each domain that user can see we need to add image tag with source that is pointing out to signout handler that will return image after clean up //only exception in domain list is domain that was initialy used to signout. IDBDataAccess db = new DBDataAccess(); UserMappings currentAccount = db.GetUsermappings(keyResponseDomainSite, userName); if (currentAccount != null) { List <UserMappings> domainUserAccounts = db.GetUsermappings(currentAccount.UserAccountID); foreach (UserMappings userMappings in domainUserAccounts) { if (userMappings.DomainName != keyResponseDomainSite) { model.DomainNames.Add(userMappings.DomainName); } } } string[] cookies = this.Request.Cookies.AllKeys; foreach (var cookie in cookies) { this.Request.Cookies[cookie].Expires = DateTime.Now.AddDays(-1); this.Response.Cookies.Add(this.Request.Cookies[cookie]); } return(View(model)); }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); try { UserMappings mappings = new UserMappings(); mappings.CreateMapping(); IKernel kernel = new StandardKernel(); kernel.Bind <IUserRepository>().To <UserRepository>(); BusinessLayer businessLayer = kernel.Get <BusinessLayer>(); for (int i = 1; i < 4; i++) { var user = businessLayer.GetUserById(i); if (user == null) { Console.WriteLine("Benutzer mit ID {0} wurde nicht gefunden", i); } else { Console.WriteLine("Benutzer mit ID {0} gefunden ({1} {2})", i, user.FirstName, user.Name); } } } catch (Exception exception) { Console.WriteLine(exception); } Console.ReadLine(); }
private void IsADuplicateClick(object sender, EventArgs e) { WithSelectedUser(selectedPerson => { AddMapping addMapping = new AddMapping(_settings, selectedPerson.RawName); addMapping.ShowDialog(this); var userMappings = new UserMappings(_settings); userMappings.ShowDialog(this); RefreshUserPanelVisibility(); }); }
/// <summary> /// Constructor for VSTS work Item Helper /// </summary> /// <param name="conn">Team Foundation Connection</param> /// <param name="witName">Work Item Type Name</param> /// <param name="maps">Field Maps reference</param> /// <param name="userMap">User Maps refernce</param> /// <param name="sourceConvIndex">Source Converter Index</param> public VSTSWorkItemHelper(VSTSConnection conn, string witName, FieldMaps maps, UserMappings userMap, int sourceConvIndex, string fieldMapFile) { m_vstsConnection = conn; m_maps = maps; m_witName = witName; m_userMappings = userMap; m_fieldMapFile = fieldMapFile; // validate the field mappings ValidateFieldMaps(); // build the field mappings BuildFieldMappings(); CurClient.WorkItemType witType = m_vstsConnection.GetWorkItemType(m_witName); m_convSourceIndex = sourceConvIndex; // Check if the Duplicate WI ID is used by CQ! if (witType.FieldDefinitions.Contains(m_duplicateWiId) && !m_fieldMappings.Contains(m_duplicateWiId)) { m_canSetDuplicateWiId = true; } m_wi = CreateNewWorkItem(); // prepare intial work item snapshot with all required and available field values foreach (string reqField in m_requiredFieldsForCreatingWI) { Field fld = m_wi.Fields[reqField]; Debug.Assert(fld != null, "Null handle for core field while preparing initial snapshot"); if (fld != null) { Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Base WI Snapshot - Field [{0}], Value [{1}]", fld.ReferenceName, fld.Value); m_baseWiSnapShot.Add(fld.ReferenceName, fld.Value); } } m_baseWiSnapShot.Add(VSTSConstants.CreatedDateFieldRefName, VSTSConstants.CurrentDate); m_baseWiSnapShot.Add(VSTSConstants.CreatedByFieldRefName, "Converter"); m_MigStatusField = m_wi.Fields[m_migrationStatusFieldName]; VSTSConstants.MigrationStatusField = m_MigStatusField.ReferenceName; // initialize web service URI's WSHelper.SetupProxy(conn.Tfs.Name); }
public static void StoreUserMap(UserMappings userMap) { var connectionString = CloudConfigurationManager.GetSetting("AzureWebJobsStorage"); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("BotMappings"); table.CreateIfNotExists(); TableOperation insertOperation = TableOperation.InsertOrReplace(userMap); table.Execute(insertOperation); }
public static void MapUser(string userid, string accessToken, string serviceUrl) { var UserMappings = new UserMappings(userid, accessToken, serviceUrl); var connectionString = CloudConfigurationManager.GetSetting("AzureWebJobsStorage"); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("BotMappings"); table.CreateIfNotExists(); TableOperation insertOperation = TableOperation.InsertOrReplace(UserMappings); table.Execute(insertOperation); }
/// <summary> /// /// </summary> /// <param name="keyResponseDomainSite">E.g. localhost:63256 or dcatest.claimshub.eu</param> /// <param name="userName">Username for the keyResponseDomainSite</param> private void CreateOrRefreshAllCookies(string keyResponseDomainSite, string userName) { IDBDataAccess db = new DBDataAccess(); UserMappings currentAccount = db.GetUsermappings(keyResponseDomainSite, userName); if (currentAccount != null) { List <UserMappings> domainUserAccounts = db.GetUsermappings(currentAccount.UserAccountID); foreach (UserMappings userMappings in domainUserAccounts) { CreateOrRefreshCookie(userMappings); } } }
/// <summary> /// Generate User Mappings based on the Clearquest users /// Each User mapping generates the same user name in to section also /// </summary> private void GenerateDefaultUserMaps(string userMapFileName) { Logger.WritePerf(LogSource.CQ, "Generating Default User Map"); AdminSession cqAdminSess = m_cqConnection.GetAdminSession(); OAdUsers users = CQWrapper.GetUsers(cqAdminSess); // create a instance of usermap.xml file UserMappings userMaps = new UserMappings(userMapFileName); for (int userindx = 0; userindx < users.Count; userindx++) { object userObj = (object)userindx; OAdUser aUser = CQWrapper.GetUser(users, ref userObj); userMaps.Add(aUser.Name, aUser.Name); } userMaps.Flush(); Logger.WritePerf(LogSource.CQ, "Default User Map Generation Done"); } // end of GenerateDefaultUserMaps()
/// <summary> /// /// </summary> /// <param name="domainName">Domain.DomainName e.g. localhost:62650 or dcatest.claimshub.eu .</param> /// <param name="domainUsername">DomainUserAccount.DomainUsername is user's username on the domain. </param> /// <returns></returns> public UserMappings GetUsermappings(string domainName, string domainUsername) { UserMappings tmpUserMappings = null; using (IDbConnection tmpConnection = GetConnection(null)) { var parameters = new { DomainName = domainName, DomainUsername = domainUsername }; tmpUserMappings = tmpConnection.Query <UserMappings>(StoredProcedures.GetUsermappings, parameters, commandType: CommandType.StoredProcedure ).FirstOrDefault(); } return(tmpUserMappings); }
/// <summary> /// /// </summary> /// <param name="domainSite">E.g. localhost:63256 or dcatest.claimshub.eu</param> /// <param name="sDomainSource">E.g. DCA or CLAIMSHUB</param> /// <param name="um"></param> //private void CreateOrRefreshCookie(string domainSite,string sDomainSource, UserMappings um) private void CreateOrRefreshCookie(UserMappings um) { HttpCookie cookie = HttpContext.Request.Cookies.Get(um.DomainName); if (cookie == null) { //Create cookie. cookie = new HttpCookie(um.DomainName); //cookie["domainSource"] = sDomainSource; cookie["userName"] = um.DomainUsername; cookie.Expires = DateTime.Now.AddMinutes(60); HttpContext.Response.Cookies.Add(cookie); } else { //Refresh cookie. cookie.Expires = DateTime.Now.AddMinutes(60); } }
/// <summary> /// Format tweets by user and their feed /// </summary> /// <param name="users"></param> /// <param name="tweets"></param> /// <returns></returns> private string FormatFeed(UserMappings users, List <Tweet> tweets) { StringBuilder stringBuilder = new StringBuilder(); var sortedUsers = users.AllUsers; foreach (string user in sortedUsers) { stringBuilder.AppendLine(user); // get the current user's tweets List <Tweet> feed = GetTweetsForFeed(tweets, user); // get the current user's tweets from whomever they follow if (users.FollowerUserMapping.ContainsKey(user)) { feed.AddRange(GetTweetsForFeed(tweets, users.FollowerUserMapping[user])); } foreach (Tweet tweet in feed) { stringBuilder.AppendLine($"\t{ tweet }"); } } return(stringBuilder.ToString()); }
public void UserMappingRuleEvaluator_TryMapUserIdentityTest() { NotifyingCollection <UserMappings> userMappings = new NotifyingCollection <UserMappings>(); UserMappings mappings = new UserMappings(); mappings.DirectionOfMapping = MappingDirectionEnum.LeftToRight; UserMapping mapping = new UserMapping(); mapping.LeftUser = new User(); mapping.LeftUser.Alias = "alias1"; mapping.LeftUser.Domain = "domain1"; mapping.RightUser = new User(); mapping.RightUser.Alias = "alias1_target"; mapping.RightUser.Domain = "domain1_target"; mappings.UserMapping.Add(mapping); userMappings.Add(mappings); UserMappingRuleEvaluator target = new UserMappingRuleEvaluator(userMappings); RichIdentity sourceUserIdentity = new RichIdentity(); sourceUserIdentity.Alias = "alias1"; sourceUserIdentity.Domain = "domain1"; sourceUserIdentity.DisplayName = "random"; IdentityLookupContext context = new IdentityLookupContext(Guid.Empty, Guid.Empty); context.MappingDirection = MappingDirectionEnum.LeftToRight; RichIdentity mappedUserIdentity = new RichIdentity(); bool expected = true; bool actual; actual = target.TryMapUserIdentity(sourceUserIdentity, context, mappedUserIdentity); Assert.AreEqual(expected, actual); Assert.AreEqual(mappedUserIdentity.Alias, "alias1_target"); Assert.AreEqual(mappedUserIdentity.Domain, "domain1_target"); Assert.AreEqual(mappedUserIdentity.DisplayName, string.Empty); sourceUserIdentity.Alias = "alias2"; mappedUserIdentity = new RichIdentity(); actual = target.TryMapUserIdentity(sourceUserIdentity, context, mappedUserIdentity); Assert.AreNotEqual(expected, actual); sourceUserIdentity.Alias = "alias1"; sourceUserIdentity.Domain = "different_domain"; mappedUserIdentity = new RichIdentity(); actual = target.TryMapUserIdentity(sourceUserIdentity, context, mappedUserIdentity); Assert.AreNotEqual(expected, actual); // add another rule mappings = new UserMappings(); mappings.DirectionOfMapping = MappingDirectionEnum.RightToLeft; mapping = new UserMapping(); mapping.LeftUser = new User(); mapping.LeftUser.Alias = "default_alias"; mapping.LeftUser.Domain = "default_domain"; mapping.RightUser = new User(); mapping.RightUser.Alias = "*"; mapping.RightUser.Domain = "domain1"; mappings.UserMapping.Add(mapping); userMappings.Add(mappings); target = new UserMappingRuleEvaluator(userMappings); // switch mapping direction context.MappingDirection = MappingDirectionEnum.RightToLeft; sourceUserIdentity.Alias = "random alias"; sourceUserIdentity.Domain = "domain1"; mappedUserIdentity = new RichIdentity(); actual = target.TryMapUserIdentity(sourceUserIdentity, context, mappedUserIdentity); Assert.AreEqual(expected, actual); Assert.AreEqual(mappedUserIdentity.Alias, "default_alias"); Assert.AreEqual(mappedUserIdentity.Domain, "default_domain"); Assert.AreEqual(mappedUserIdentity.DisplayName, string.Empty); }
public void Save() { try { using (var r = UserAppDataRegistryForWriting) { SetBoolean(r, "AutoStart", AutoStart); SetBoolean(r, "AutoMinimize", AutoMinimize); //SetBoolean(r, "DetailedErrorResponse", DetailedErrorResponse); SetBoolean(r, "BindToWorld", BindToWorld); SetEnum(r, "UsePlainTextConverterEnum", UsePlainTextConverter); SetBoolean(r, "PostsAreAlwaysFormatFlowed", PostsAreAlwaysFormatFlowed); SetInt32(r, "Port", Port); SetInt32(r, "ListPageSize", ListPageSize); SetInt32(r, "ArticlePageSize", ArticlePageSize); SetString(r, "DomainName", DomainName); SetString(r, "UserEmail", UserEmail); SetString(r, "UserName", UserName); #if LIVECONNECT SetString(r, "ClientId", ClientId); SetString(r, "RefreshToken", RefreshToken); SetString(r, "Scopes", Scopes); #else SetString(r, "AuthenticationBlob", AuthenticationBlob); #endif SetInt32(r, "AutoLineWrap", AutoLineWrap); SetString(r, "EncodingForClient", EncodingForClient); SetString(r, "UserGuid", UserGuid.ToString()); SetEnum(r, "InMimeUse", InMimeUse); SetBoolean(r, "UseAnswersForums", UseAnswersForums); SetBoolean(r, "UseSocialForums", UseSocialForums); SetString(r, "UserDefinedTags", UserDefinedTags.GetString()); SetString(r, "UserMappings", UserMappings.GetString()); SetBoolean(r, "DisableUserAgentInfo", DisableUserAgentInfo); SetBoolean(r, "DisableLISTGROUP", DisableLISTGROUP); SetBoolean(r, "ShowUserNamePostfix", ShowUserNamePostfix); SetInt32(r, "TabAsSpace", TabAsSpace); SetBoolean(r, "AddHistoryToArticle", AddHistoryToArticle); SetEnum(r, "UseAppInsights", UseAppInsights); } } catch (Exception exp) { Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error saving settings to the registry: {0}", NNTPServer.Traces.ExceptionToString(exp)); } }
public override async Task OnDisconnectedAsync(Exception exception) { UserMappings.RemoveDeviceConnected(Context.ConnectionId); await base.OnDisconnectedAsync(exception); }
public async Task ReceiveDeviceConnected(string deviceId, string areaName, string locationNumber) { UserMappings.AddDeviceConnected(deviceId, Context.ConnectionId); LocationMappings.MapDeviceToLocation(locationNumber, Context.ConnectionId); await Groups.AddToGroupAsync(Context.ConnectionId, areaName); }
public void Save() { lock (this) { try { using (var r = UserAppDataRegistryForWriting) { SetBoolean(r, "AutoStart", AutoStart); SetBoolean(r, "AutoMinimize", AutoMinimize); //SetBoolean(r, "DetailedErrorResponse", DetailedErrorResponse); SetBoolean(r, "BindToWorld", BindToWorld); SetEnum(r, "UsePlainTextConverterEnum", UsePlainTextConverter); SetBoolean(r, "PostsAreAlwaysFormatFlowed", PostsAreAlwaysFormatFlowed); SetInt32(r, "Port", Port); //SetInt32(r, "ListPageSize", ListPageSize); //SetInt32(r, "ArticlePageSize", ArticlePageSize); SetString(r, "DomainName", DomainName); //SetString(r, "UserEmail", UserEmail); //SetString(r, "UserName", UserName); SetString(r, "ClientId", ClientId); SetString(r, "RefreshToken", RefreshToken); SetString(r, "Scopes", Scopes); //SetString(r, "AuthenticationBlob", AuthenticationBlob); SetInt32(r, "AutoLineWrap", AutoLineWrap); SetString(r, "EncodingForClient", EncodingForClient); //SetString(r, "UserGuid", UserGuid.ToString()); SetEnum(r, "InMimeUse", InMimeUse); //SetBoolean(r, "UseAnswersForums", UseAnswersForums); //SetBoolean(r, "UseSocialForums", UseSocialForums); SetString(r, "UserDefinedTags", UserDefinedTags.GetString()); SetString(r, "UserMappings", UserMappings.GetString()); SetBoolean(r, "DisableUserAgentInfo", DisableUserAgentInfo); SetBoolean(r, "DisableLISTGROUP", DisableLISTGROUP); SetBoolean(r, "ShowUserNamePostfix", ShowUserNamePostfix); SetInt32(r, "TabAsSpace", TabAsSpace); SetBoolean(r, "UseCodeColorizer", UseCodeColorizer); SetBoolean(r, "AddHistoryToArticle", AddHistoryToArticle); SetInt32(r, "MaxThreadCountOnFirstretrival", MaxThreadCountOnFirstRetrival); SetEnum(r, "MetaInfo", MetaInfo); SetBoolean(r, "ShowUsersSignature", ShowUsersSignature); SetEnum(r, "UpdateInfoMode", UpdateInfoMode); SetEnum(r, "MessageInfos", MessageInfos); SetBoolean(r, "SendSupersedesHeader", SendSupersedesHeader); SetBoolean(r, "UpdateAsync", UpdateAsync); } } catch (Exception exp) { Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error saving settings to the registry: {0}", NNTPServer.Traces.ExceptionToString(exp)); } } }