public IActionResult GetProductSalesAgents(string CompanyId, string ProductSupplierId) { try { AgentDetails model = new AgentDetails(); request = new AgentGetReq() { CompanyId = CompanyId }; AgentGetRes response = agentProviders.GetAgentDetailedInfo(request, token).Result; model.CompanyId = CompanyId; model.Issupplier = response.AgentDetails.Issupplier ?? false; CompanyProducts product = response.AgentDetails.Products.Where(x => x.ProductSupplier_Id == ProductSupplierId).FirstOrDefault(); List <Branches> lst = new List <Branches>(); foreach (var s in product.SalesAgent) { Branches prod = new Branches(); prod.ParentCompanyId = s.Company_Id; prod.BranchCompanyId = s.ProductSupplierSalesAgent_Id; // Array Id assigned prod.BranchCompanyName = s.Company_Name; prod.BranchCompanyCode = s.Company_Code; lst.Add(prod); } model.Branches = lst.OrderBy(x => x.BranchCompanyName).ToList(); model.IsForSalesAgent = true; model.ProductSupplierId = ProductSupplierId; return(PartialView("_AgentDetailsBranches", model)); } catch (Exception ex) { throw; } }
private AddressesType BuildAddressesData(AgentDetails agentData) { var regionalConsultant = SupportTeamDetails != null?SupportTeamDetails.Where(t => t.JobTitle == "Regional Consultant").FirstOrDefault() : null; var internalConsultant = SupportTeamDetails != null?SupportTeamDetails.Where(t => t.JobTitle == "Internal Consultant").FirstOrDefault() : null; string rcName = regionalConsultant != null ? regionalConsultant.FirstName + " " + regionalConsultant.LastName : string.Empty; string icName = internalConsultant != null ? internalConsultant.FirstName + " " + internalConsultant.LastName : string.Empty; string userName = string.Empty; if (IsImpersonating) { userName = ImpersonatingUserProfile != null ? ImpersonatingUserProfile.Firstname + " " + ImpersonatingUserProfile.Lastname : string.Empty; } else { userName = UserProfile != null ? UserProfile.Firstname + " " + UserProfile.Lastname : string.Empty; } string billingAddress1 = userName.Trim(); string billingAddress2 = rcName.Trim(); string billingAddress3 = icName.Trim(); string billingAddress4 = agentData.PrimaryAdvisorID; return(new AddressesType() { SyncMode = SyncModeType.Auto, SyncModeSpecified = true, Address = new AddressType[] { BuildAddressData(string.Format("{0}_ShippingAddress1", agentData.APLId), agentData.Company, agentData.Address1, null, null, null, null, agentData.Phone, agentData.City, agentData.State, agentData.Zip, AddressTypes.Shipping), } }); }
protected void btnAgentsubmit_Click(object sender, EventArgs e) { BALAccounts Bal = new BALAccounts(); AgentDetails agentDetails = new AgentDetails { FirstName1 = txtAgentFname.Text, LastName1 = txtAgentLname.Text, Age1 = int.Parse(txtAgentAge.Text), Gender1 = ddlAgentGender.Text, DoB1 = txtAgentdob.Text, ContactNumber1 = double.Parse(txtAgentcntct.Text), AltContactNumber1 = double.Parse(txtAgentAltcntct.Text), EmailId1 = txtAgentEmail.Text, UserName1 = txtAgentUserName.Text, Password1 = txtAgentPasswd.Text, AddressLine11 = txtAgentAddress.Text, AddressLine21 = txtAgentAltAddress.Text, City1 = txtAgentcity.Text, State1 = txtAgentstate.Text, Zipcode1 = int.Parse(txtAgentzip.Text), Isapproved1 = false }; if (Bal.regagent(agentDetails)) { ClientScript.RegisterStartupScript(this.GetType(), "Popup", "regalert();", true); } }
private EditUserRequestType BuildEditUserRequestData(string aplId, AgentDetails agentData) { return(new EditUserRequestType() { Action = ActionType.Auto, User = BuildUserData(aplId, agentData) }); }
private UserGroupsType BuildUserGroups(AgentDetails agentData) { return(new UserGroupsType() { SyncMode = SyncModeType.Auto, SyncModeSpecified = true, UserGroup = new IDType[] { BuildIdData(UserGroupName) } }); }
public StandardRegisterLoginData MapToStandardRegisterData(AgentDetails agentData, IEnumerable <SupportTeamDetails> supportTeamContactDetails) { StandardRegisterLoginData data = new StandardRegisterLoginData(); data.CostCenter = CostCenterParam; data.Email = agentData.Email; data.FailureMessage = FailureMessageParam; data.FirstName = agentData.FirstName; data.LastName = agentData.LastName; data.Phone = FormatPhoneNumber(agentData.Phone); data.Role = GetMappingRole(agentData.APLId, agentData.Channel, agentData.PC_Status); data.ReturnUrl = ReturnUrlParam; data.SFDCID = agentData.PrimaryAdvisorID; data.SourceSystemName = SourceSystemNameParam; data.UpdateProfile = "true"; data.UserIdentity = agentData.APLId; data.Address = new PhysicalAddressData() { Line1 = agentData.Address1, City = agentData.City, PostalCode = agentData.Zip, State = agentData.State }; var regionalConsultant = supportTeamContactDetails != null?supportTeamContactDetails.Where(t => t.JobTitle == "Regional Consultant").FirstOrDefault() : null; var internalConsultant = supportTeamContactDetails != null?supportTeamContactDetails.Where(t => t.JobTitle == "Internal Consultant").FirstOrDefault() : null; data.AuxFields = new AuxField[5] { new AuxField() { Id = "1", Value = agentData.DivisionManagerWebUserId }, // Manager Identity new AuxField() { Id = "2", Value = regionalConsultant != null ? regionalConsultant.FirstName + " " + regionalConsultant.LastName : null }, // Regional Consultant Name new AuxField() { Id = "3", Value = internalConsultant != null ? internalConsultant.FirstName + " " + internalConsultant.LastName : null }, // Internal Consultant Name new AuxField() { Id = "4", Value = agentData.Channel }, // Channel new AuxField() { Id = "5", Value = agentData.PC_Status } // PC Status }; return(data); }
private UserType BuildUserData(string aplId, AgentDetails agentData) { return(new UserType() { ID = BuildIdData(aplId), Properties = BuildUserPropertiesData(agentData.FirstName, agentData.LastName, agentData.Email, agentData.APLId, MarketingLogic.SHA1Hash(aplId)), Settings = BuildSettingsData(Settings), UserGroups = BuildUserGroups(agentData), Addresses = BuildAddressesData(agentData) }); }
private UserType BuildUserData(string aplId, MyProfileInformation profile, AgentDetails agentData, bool isImpersonatingUser) { var settingsParam = isImpersonatingUser ? ImpersonatingSettings : Settings; return(new UserType() { ID = BuildIdData(aplId), Properties = BuildUserPropertiesData(profile.Firstname, profile.Lastname, profile.Email, aplId, MarketingLogic.SHA1Hash(aplId)), Settings = BuildSettingsData(settingsParam), UserGroups = BuildUserGroups(profile, isImpersonatingUser), Addresses = BuildAddressesData(aplId, profile), Impersonation = BuildImpersonationData(profile, isImpersonatingUser) }); }
/// <summary> /// Add or update agent information in agent cache. /// </summary> /// <param name="agentId">Identifier for the agent.</param> /// <param name="value">Details of the Agent. See <see cref="AgentDetails"/>.</param> private void AddOrUpdateAgent(string agentId, AgentDetails value) { if (!string.IsNullOrWhiteSpace(agentId)) { AgentCacheEntry newEntry = new AgentCacheEntry(); newEntry.agent = value; newEntry.timeStamp = DateTime.Now; _agentCache.AddOrUpdate(agentId.ToLower(), newEntry, (existingKey, oldValue) => newEntry); if (_agentCache.Count > maxCacheEntries) { TryRemoveAgent(_agentCache.OrderBy(o => o.Value.timeStamp).FirstOrDefault().Key); } } }
/// <inheritdoc/> public async Task <AgentDetails> GetAgentDetails(string agentId) { AgentCacheEntry cacheEntry; bool result = _agentCache.TryGetValue(agentId.ToLower(), out cacheEntry); if (result) { return(cacheEntry.agent); } else { AgentDetails currAgent = new AgentDetails(); string uri = $"/agents/{agentId}"; try { HttpResponseMessage response = await MakeGetCallToFreshChat(uri); string responseContent = await response.Content.ReadAsStringAsync(); var jsonResponse = JToken.Parse(responseContent); currAgent.Id = agentId; currAgent.FirstName = (string)jsonResponse["first_name"]; currAgent.LastName = (string)jsonResponse["last_name"]; currAgent.Email = (string)jsonResponse["email"]; currAgent.Avatar = new Avatar() { Url = (string)jsonResponse["avatar"].Value <JToken>("url") }; // Add to cache for future lookups AddOrUpdateAgent(currAgent.Id, currAgent); return(currAgent); } catch (Exception ex) { InternalEventBody kustoLog = new InternalEventBody(); kustoLog.EventType = "FreshChatLoggingUnhandledException"; kustoLog.EventContent = $"FreshChatException. Unhandled {ex.GetType().ToString()} exception while calling FreshChat server to fetch sender details. URI: {uri}"; await LogToKusto(kustoLog); throw ex; } } }
public bool RegAgentDetails(AgentDetails agentDetails) { try { if (agentDetails != null) { SqlConnection _sqlConnection = ConnectionHandler.GetConnection(); _sqlConnection.Open(); SqlCommand _sqlCommand = new SqlCommand("Registeragentdetails", _sqlConnection); _sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; _sqlCommand.Connection = _sqlConnection; _sqlCommand.Parameters.AddWithValue("@Firstname", agentDetails.FirstName1); _sqlCommand.Parameters.AddWithValue("@Lastname", agentDetails.LastName1); _sqlCommand.Parameters.AddWithValue("@Age", agentDetails.Age1); _sqlCommand.Parameters.AddWithValue("@Gender", agentDetails.Gender1); _sqlCommand.Parameters.AddWithValue("@DoB", agentDetails.DoB1); _sqlCommand.Parameters.AddWithValue("@ContactNumber", agentDetails.ContactNumber1); _sqlCommand.Parameters.AddWithValue("@AltContactNumber", agentDetails.AltContactNumber1); _sqlCommand.Parameters.AddWithValue("@Emailid", agentDetails.EmailId1); _sqlCommand.Parameters.AddWithValue("@UserName", agentDetails.UserName1); _sqlCommand.Parameters.AddWithValue("@Password", agentDetails.Password1); _sqlCommand.Parameters.AddWithValue("@AddressLine1", agentDetails.AddressLine11); _sqlCommand.Parameters.AddWithValue("@AddressLine2", agentDetails.AddressLine21); _sqlCommand.Parameters.AddWithValue("@City", agentDetails.City1); _sqlCommand.Parameters.AddWithValue("@State", agentDetails.State1); _sqlCommand.Parameters.AddWithValue("@Zipcode", agentDetails.Zipcode1); //_sqlCommand.Parameters.AddWithValue("@Isapproved", doctorDetails.Isapproved1); //_sqlCommand.Parameters.AddWithValue("@IsApprovedOn", doctorDetails.Isapproved_On1); int result = _sqlCommand.ExecuteNonQuery(); _sqlConnection.Close(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
protected void gdvAgentDetails_RowDeleting(object sender, GridViewDeleteEventArgs e) { BALAccounts Bal = new BALAccounts(); GridViewRow row = gdvAgentDetails.Rows[e.RowIndex]; string name = (row.FindControl("lblAgentfname") as Label).Text; AgentDetails agentDetails = new AgentDetails(); AgentDetailsSql agentDetailsSql = new AgentDetailsSql(); List <AgentDetails> agndetails = Bal.displayagentdetails(); if (agndetails.Count > 0) { for (int i = 0; i < agndetails.Count; i++) { if (agndetails[i].FirstName1 == name) { agndetails.RemoveAt(i); } } Bal.removeagent(name); lblStatusAgent.Text = "Agent Details Deleted Successfully"; GetAgent(); } }
/// <summary> /// Used to pass agent details from the pool of the players current agents /// </summary> /// <param name="details">Details of a given agent</param> public void CreateNewAgent(AgentDetails details, WeaponType weapon, ArmourType armour) { CreateNewAgent(details.IdTag, details.PersonName, details.Portrait, details.AgentClass, details.MaxHealth, details.Health, weapon, armour); }
private EditUserRequestType BuildEditUserRequestData(string aplId, MyProfileInformation profile, AgentDetails agentData, bool isImpersonatingUser) { return(new EditUserRequestType() { Action = ActionType.Auto, User = BuildUserData(aplId, profile, agentData, isImpersonatingUser) }); }
public static Boolean AddAgentToFile(AgentDetails agentDetails, int registersCount) { try { DateTime processDateTime = DateTime.Now; String agentsWorkingFileName = "temp_AgentsToRegister.txt"; String groupsFileNamePath = _readyFilesFolder + "GroupMappings_" + processDateTime.ToString("yyyyMMddhhmmssfff") + ".txt"; String agentsWorkingFilePath = _tempWorkingFolder + agentsWorkingFileName; Boolean isNewFile = (!File.Exists(agentsWorkingFilePath)); if (!isNewFile) { isNewFile = File.ReadLines(agentsWorkingFilePath).Count() == 0; } StreamWriter agentsFile = new StreamWriter(agentsWorkingFilePath, true); lock (agentsFile) { // Verificar que el archivo este vacio para escribir el Header if (isNewFile) { agentsFile.WriteLine("##HEADER"); } String record = String.Format("{0};{1};{2};" + '"' + "{3}" + '"' + ";{4};{5};{6};{7};{8};{9};{10};{11};{12};{13};{14};{15};{16};{17};{18};{19};{20};{21};{22}", agentDetails.Agent, agentDetails.Name, agentDetails.LegalName, agentDetails.Address, agentDetails.PhoneNumber, _countryID, agentDetails.ProvinceID, agentDetails.CityID, agentDetails.ContactName, agentDetails.BirthDate.ToString("yyyyMMdd"), agentDetails.Gender.ToString(), agentDetails.NationalIDType, agentDetails.NationalID, agentDetails.PhoneNumber, agentDetails.SMSAddress, agentDetails.Email, agentDetails.Referrer, agentDetails.MNO1, agentDetails.MNO2, agentDetails.MNO3, agentDetails.MNO4, agentDetails.MNO5, "agent"); agentsFile.WriteLine(record); agentsFile.Flush(); agentsFile.Close(); // RP 20111018 - Ahora chequeo según la cantidad de registros de la llamada al Bulk String[] fileLines = File.ReadLines(agentsWorkingFilePath).ToArray(); if (fileLines.Length >= registersCount) //_agentsPerFile) //if (File.ReadLines(workingFilePath).Count() >= (_agentsPerFile+1)) { StreamWriter groupsFile = new StreamWriter(groupsFileNamePath, true); groupsFile.WriteLine("##HEADER"); for (int i = 1; i < fileLines.Length; i++) { groupsFile.WriteLine(fileLines[i].Split(new char[] { ';' }).ElementAt(0) + "," + ConfigurationManager.AppSettings["DefaultAgentGroupID"]); } groupsFile.WriteLine("##FOOTER"); groupsFile.Flush(); groupsFile.Close(); StreamWriter footerWriter = new StreamWriter(agentsWorkingFilePath, true); footerWriter.WriteLine("##FOOTER"); footerWriter.Flush(); footerWriter.Close(); String newFileName = "NewAgents_" + processDateTime.ToString("yyyyMMddhhmmssfff") + ".txt"; File.Move(agentsWorkingFilePath, _readyFilesFolder + newFileName); SendFilesByEmail(_readyFilesFolder + newFileName, groupsFileNamePath); } } } catch (Exception) { //Log(Logger.LogMessageType.Error, "Error ejecutando Registration.AddAgentToFile: " + e.ToString(), Logger.LoggingLevelType.Low); return(false); } //Log(Logger.LogMessageType.Info, "-> -------------------- Termina la ejecución del método Registration.AddAgentToFile", Logger.LoggingLevelType.Medium); return(true); }
public bool regagent(AgentDetails agentdetails) { return(agentdetailssql.RegAgentDetails(agentdetails)); }
public void Add(AgentDetails agentDetails) { _agentDetails = agentDetails; }
public static SSOMessage BuildMarcomCentralAuthenticationRequest(string aplId, string pageName, string productId) { SSOMessage ssoMessage = null; NameValueCollection settings = null; NameValueCollection impersonatingSettings = null; AgentDetails agentData = null; IEnumerable <SupportTeamDetails> supportTeamData = null; MyProfileInformation profileData = null; MyProfileInformation impersonatingProfileData = null; SalesforceUser impersonatingSalesforceUser = null; SalesforceUser salesforceInternalUser = null; string settingsItemPath = "/sitecore/content/Home/Marketing/Portal"; string settingsTemplate = "Marcom Central Setting"; string settingsField = "Settings"; string userGroupNameField = "User Group Name"; string userGroupName = string.Empty; string impersonatingUserGroupName = string.Empty; string parameters = string.Empty; try { var client = new ServiceClient(); Authorization currentAuthorization = Authorization.CurrentAuthorization; var agents = currentAuthorization.Claim.Roles.Where(r => r.RoleId == 6).Select((a) => a.APLId).Distinct().ToArray(); var ssoDataAttributes = client.GetUserAttributes(currentAuthorization.Claim.LoggedInSSOGuid, null); bool isExternalUser = agents.Length > 0; string currentUserId = aplId; string marcomCentralUserId = string.Empty; string marcomCentralImpersonatingUserId = string.Empty; if (ssoDataAttributes != null && ssoDataAttributes.UserData != null) { var attributes = ssoDataAttributes.UserData.FirstOrDefault(); currentUserId = attributes.AplId; } bool isImpersonating = !string.IsNullOrWhiteSpace(currentUserId) && currentAuthorization.Claim.SSOGuid != currentAuthorization.Claim.LoggedInSSOGuid; var roleClaim = currentAuthorization.Claim.Roles.Where(r => r.APLId == aplId).FirstOrDefault(); var item = ContextExtension.CurrentDatabase.GetItem(settingsItemPath); if (item != null) { var itemList = item.GetChildrenOfTemplate(settingsTemplate).Where(i => HasChannel(i, roleClaim.ChannelType) && HasPCStatus(i, roleClaim.PC_Status)); var settingsItem = itemList.FirstOrDefault(); if (settingsItem != null) { parameters = settingsItem[settingsField]; userGroupName = settingsItem[userGroupNameField]; settings = Sitecore.Web.WebUtil.ParseUrlParameters(parameters); } } if (isImpersonating) { var impersonatingSettingsItem = ContextExtension.CurrentDatabase.GetItem(MarketingLogic.MarcomCentralImpersonatingSettingsPath); if (impersonatingSettingsItem != null) { parameters = impersonatingSettingsItem[settingsField]; impersonatingUserGroupName = impersonatingSettingsItem[userGroupNameField]; impersonatingSettings = Sitecore.Web.WebUtil.ParseUrlParameters(parameters); } } if (isExternalUser) { var agentDetailsResponse = client.GetAgentDetails(aplId); var supportTeamResponse = client.GetSupportTeamDetails(aplId); agentData = agentDetailsResponse.AgentDetails != null?agentDetailsResponse.AgentDetails.FirstOrDefault() : null; supportTeamData = supportTeamResponse.SupportTeamDetails; profileData = GetUserInfo(currentUserId); marcomCentralUserId = aplId; if (isImpersonating) { impersonatingProfileData = GetUserInfo(currentUserId); impersonatingSalesforceUser = GetSalesforceUser(currentUserId); marcomCentralImpersonatingUserId = marcomCentralUserId; marcomCentralUserId = TruncateSalesforceId(impersonatingSalesforceUser, currentUserId); } var regionalConsultant = supportTeamData != null?supportTeamData.Where(t => t.JobTitle == "Regional Consultant").FirstOrDefault() : null; var internalConsultant = supportTeamData != null?supportTeamData.Where(t => t.JobTitle == "Internal Consultant").FirstOrDefault() : null; string rcName = regionalConsultant != null ? regionalConsultant.FirstName + " " + regionalConsultant.LastName : string.Empty; string icName = internalConsultant != null ? internalConsultant.FirstName + " " + internalConsultant.LastName : string.Empty; string userName = string.Empty; if (isImpersonating) { userName = impersonatingProfileData != null ? impersonatingProfileData.Firstname + " " + impersonatingProfileData.Lastname : string.Empty; } else { userName = profileData != null ? profileData.Firstname + " " + profileData.Lastname : string.Empty; } settings.Add("User.GenericField1", userName.Trim()); settings.Add("User.GenericField2", agentData.PrimaryAdvisorID); settings.Add("User.GenericField3", rcName.Trim()); settings.Add("User.GenericField4", icName.Trim()); } else { // it's an internal user or employee profileData = GetUserInfo(aplId); salesforceInternalUser = GetSalesforceUser(aplId); marcomCentralUserId = TruncateSalesforceId(salesforceInternalUser, aplId); if (isImpersonating) { impersonatingProfileData = GetUserInfo(currentUserId); impersonatingSalesforceUser = GetSalesforceUser(currentUserId); marcomCentralImpersonatingUserId = marcomCentralUserId; marcomCentralUserId = TruncateSalesforceId(impersonatingSalesforceUser, currentUserId); } } var mapper = new MarcomCentralDataMapper() { MarcomCentralUserId = marcomCentralUserId, MarcomCentralImpersonatingUserId = marcomCentralImpersonatingUserId, SalesforceInternalUser = salesforceInternalUser, ImpersonatingSalesforceUser = impersonatingSalesforceUser, PageName = pageName, ProductId = productId, IsExternalUser = isExternalUser, IsImpersonating = isImpersonating, AgentData = agentData, SupportTeamDetails = supportTeamData, UserProfile = profileData, ImpersonatingUserProfile = impersonatingProfileData, Settings = settings, ImpersonatingSettings = impersonatingSettings, UserGroupName = userGroupName, ImpersonatingUserGroupName = impersonatingUserGroupName }; ssoMessage = mapper.MapToMarcomCentralData(); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error("Unable to build Marcom Central authentication request for user " + aplId, ex, typeof(Controller)); } return(ssoMessage); }