public static void EuroOnAfterTicketInsert(ITicket ticket) { //========================================================================= // Needed to Update IT Tickets to the Correct Owner //========================================================================= string result; if (ticket.ITTicketLevel != null && ticket.ITTicketLevel != string.Empty) { //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); if (currentuser.Id.ToString() == "ADMIN ") { //Set it to the default Assigned to result = GetField <string>("ASSIGNEDTOID", "EUROTICKETDEFAULTS", ""); } else { //Not the Admin User result = Extentions.GetField <string>("ORIGINATORSECCODEID", "EUROXTICKETMAPPING", "USERID = '" + currentuser.Id.ToString() + "'"); if (result == null) { //Set it to the default Assigned to as there is no Origniator Team to be found. result = GetField <string>("ASSIGNEDTOID", "EUROTICKETDEFAULTS", ""); } } Sage.Entity.Interfaces.IOwner MyOwner = Sage.Platform.EntityFactory.GetById <Sage.Entity.Interfaces.IOwner>(result); ticket.Owner = MyOwner; ticket.Save(); } }
private static Boolean IsMember(string TeamName, string Type) { Boolean blnReturn = false; // Intialize False //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); // get the DataService to get a connection string to the database string SQL = ""; SQL = "select accessid from secrights where seccodeid = "; SQL += " (select seccodeid from seccode where (seccodedesc = '" + TeamName + "') "; SQL += " and (seccodetype = '" + Type + "')) and (accessid = '" + currentuser.Id.ToString() + "')"; Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>(); using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString())) { conn.Open(); using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(SQL, conn)) { OleDbDataReader reader = cmd.ExecuteReader(); //loop through the reader while (reader.Read()) { if (reader["accessid"].ToString() != string.Empty) { blnReturn = true; } } reader.Close(); } } return(blnReturn); }
public static void btnPrint_OnClickStep(IRNReportDetails form, EventArgs args) { // TODO: Complete business rule implementation IAttachment attachment = null; string pluginid = string.Empty; Sage.Entity.Interfaces.IRNReport parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IRNReport; if (ReportsHelper.GetPluginId("RNReport:Irnreport", out pluginid)) { WebReportingClass reporting = new WebReportingClass(); Sage.Platform.Data.IDataService datasvc = MySlx.Data.CurrentConnection; Sage.Entity.Interfaces.IUser user = MySlx.Security.CurrentSalesLogixUser; string tempPath = Rules.GetTempAttachmentPath(); string ConnectionString = datasvc.GetConnectionString(); string report = reporting.GenerateReport(ConnectionString, datasvc.Server, DatabaseServer.dsMSSQL, tempPath, false, false, "RNREPORT.RNREPORTID", "", pluginid, "", "", "", "SELECT RNREPORT.RNREPORTID FROM RNREPORT", string.Format("(RNREPORT.RNREPORTID = '{0}')", parentEntity.Id), user.Id.ToString(), user.UserName.ToString()); ReportDocument doc = new ReportDocument(); report = string.Format("{0}run\\{1}", tempPath, report); doc.Load(report); string filename = string.Format("{0}\\{1}_v{2}.pdf", Rules.GetAttachmentPath(), parentEntity.ReferenceNumber.Replace(" ", "_"), 1); doc.ExportToDisk(ExportFormatType.PortableDocFormat, filename); doc.Close(); attachment = Sage.Platform.EntityFactory.Create <IAttachment>(); attachment.Description = string.Format("{0} v{1}", parentEntity.ReferenceNumber, 1); attachment.InsertFileAttachment(filename); attachment.RNREPORTID = Convert.ToString(parentEntity.Id); attachment.Save(); System.IO.File.Delete(report); } }
public static void EuroGetTicketOriginatorTeam(ITicket ticket, out String result) { //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); if (currentuser.Id.ToString() == "ADMIN ") { //Set it to the default Assigned to result = GetField <string>("ASSIGNEDTOID", "EUROTICKETDEFAULTS", ""); } else { //Not the Admin User result = Extentions.GetField <string>("ORIGINATORSECCODEID", "EUROXTICKETMAPPING", "USERID = '" + currentuser.Id.ToString() + "'"); if (result == null) { //Set it to the default Assigned to as there is no Origniator Team to be found. result = GetField <string>("ASSIGNEDTOID", "EUROTICKETDEFAULTS", ""); } } }
protected void _changePassword_Click(object sender, EventArgs e) { // *** 10.06.11 kw Moving the logic for validating the password to the User.Rules business rule // *** var optionSvc = ApplicationContext.Current.Services.Get <Sage.SalesLogix.Services.ISystemOptionsService>(true); // get the new password string newPassword = _newPassword.Text; // if the value in the new password textbox and the confirm textbox match, attempt to save if (newPassword == _confirmPassword.Text) { // set up the change pwd options ChangePasswordOptions options = ChangePasswordOptions.CreateNew(); // Check to see if the current user is ADMIN or just normal user var slxUserService = (Sage.SalesLogix.Security.ISlxUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(true); var currentUser = slxUserService.GetUser(); if (currentUser.UserName.ToString().Trim().ToUpper() == "ADMIN") { // Get the user name of the person selected from the lookup to change their password Sage.Entity.Interfaces.IUser us = User.LookupResultValue as IUser; if (us == null) { us = currentUser; } // validate the new password against all system pwd options try { us.ValidateUserPassword(newPassword); } catch (ValidationException ex) { lblMessage.Text = ex.Message; return; } // passed validation, assign new pwd options.NewPassword = newPassword; options.UserId = us.Id.ToString(); options.Save(); // If Admin is changing their password then re-authenticate if (us.UserName == currentUser.UserName) { var data = (Sage.SalesLogix.SLXDataService)ApplicationContext.Current.Services.Get <IDataService>(true); var auth = (Sage.SalesLogix.Web.SLXWebAuthenticationProvider)data.AuthenticationProvider; auth.AuthenticateWithContext(currentUser.UserName, newPassword); } } else { // regular user attempting to change their own password if (!currentUser.ValidateCurrentPassword(_currentPassword.Text)) { lblMessage.Text = this.GetLocalResourceObject("currentPasswordValidationFailure").ToString(); return; } // validate the new password against all system pwd options try { currentUser.ValidateUserPassword(newPassword); } catch (ValidationException ex) { lblMessage.Text = ex.Message; return; } // passed validation, assign new pwd options.NewPassword = newPassword; options.UserId = currentUser.Id.ToString(); options.Save(); //re-authenticate user with new password var data = (Sage.SalesLogix.SLXDataService)ApplicationContext.Current.Services.Get <IDataService>(true); var auth = (Sage.SalesLogix.Web.SLXWebAuthenticationProvider)data.AuthenticationProvider; auth.AuthenticateWithContext(currentUser.UserName, newPassword); } lblMessage.Text = this.GetLocalResourceObject("passwordChangeSuccess").ToString(); if (string.IsNullOrEmpty(newPassword)) { lblMessage.Text = this.GetLocalResourceObject("PasswordBlank").ToString(); } } else { _newPassword.Text = string.Empty; lblMessage.Text = this.GetLocalResourceObject("PasswordNotMatch").ToString(); } }
protected void _changePassword_Click(object sender, EventArgs e) { var optionSvc = ApplicationContext.Current.Services.Get <Sage.SalesLogix.Services.ISystemOptionsService>(true); SByte minPasswordLength = optionSvc.MinPasswordLength; bool noBlankPassword = optionSvc.NoBlankPassword; bool alphaNumPassword = optionSvc.AlphaNumPassword; bool noNameInPassword = optionSvc.NoNameInPassword; Regex objAlphaNumericPattern = new Regex("[a-zA-Z][0-9]"); string changingUser = string.Empty; // Get the user name of the person who's getting their password changed Sage.Entity.Interfaces.IUser us = User.LookupResultValue as IUser; if (us != null) { changingUser = us.UserName; } else { changingUser = slxUserService.UserName; } string newPassword = _newPassword.Text; if (Convert.ToInt32(minPasswordLength) != 0) { if (newPassword.Length < Convert.ToInt32(minPasswordLength)) { lblMessage.Text = string.Format(GetLocalResourceObject("minPasswordLength").ToString(), minPasswordLength); // "Password length must be {0} chars or greater!" return; } if (alphaNumPassword && !objAlphaNumericPattern.IsMatch(newPassword)) { lblMessage.Text = GetLocalResourceObject("alphaNumPassword").ToString();// "Passwords must be alphanumeric!"; return; } } else if (noBlankPassword && newPassword.Length == 0) { lblMessage.Text = GetLocalResourceObject("noBlankPassword").ToString();//Passwords can not be blank!"; return; } if (noNameInPassword && newPassword.ToUpper().Contains(changingUser.ToUpper())) { if (curUser.ToUpper().Contains("ADMIN") && !changingUser.ToUpper().Contains("ADMIN")) { lblMessage.Text = GetLocalResourceObject("noNameInPasswordAdmin").ToString(); // "Passwords cannot contain the user name!"; } else { lblMessage.Text = GetLocalResourceObject("noNameInPasswordUser").ToString(); //"Passwords cannot contain your user name!"; } return; } // save values if (newPassword == _confirmPassword.Text) { ChangePasswordOptions options = new ChangePasswordOptions(); options.NewPassword = newPassword; string curUser = slxUserService.GetUser().Id.ToString(); if (curUser.ToString().Trim() != "ADMIN") { options.UserId = curUser; } else { options.UserId = ((IUser)this.User.LookupResultValue).Id.ToString(); } options.Save(); var webAuthProvider = ApplicationContext.Current.Services.Get <IAuthenticationProvider>() as SLXWebAuthenticationProvider; if (webAuthProvider != null) { // reset the authentication token, otherwise the OleDb connection string will be out of sync until the next logon webAuthProvider.AuthenticateWithContext(changingUser, newPassword); } if (_newPassword.Text.Length == 0) { lblMessage.Text = GetLocalResourceObject("PasswordBlank").ToString(); } else { lblMessage.Text = string.Empty; } } else { lblMessage.Text = GetLocalResourceObject("PasswordNotMatch").ToString(); } }
protected void btnSaveHistory_ClickAction(object sender, EventArgs e) { ILead CurrentLead = this.BindingSource.Current as ILead; //TAC Code Here to Create the Linked Activity. // Create Activity Record Sage.Entity.Interfaces.IHistory History = Sage.Platform.EntityFactory.Create <Sage.Entity.Interfaces.IHistory>(); //History.AccountId = oppfulfiltask.Opportunity.Account.Id.ToString(); //History.AccountName = oppfulfiltask.Opportunity.Account.AccountName; //History.OpportunityId = oppfulfiltask.Opportunity.Id.ToString(); //History.OpportunityName = oppfulfiltask.Opportunity.Description; //todo.ContactId = histContactID; //todo.ContactName = histContactName; History.LeadId = CurrentLead.Id.ToString(); History.LeadName = CurrentLead.LeadNameFirstLast; History.Type = HistoryType.atPhoneCall; //todo.Category = histCategory; // get the current user as a User Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser user = usersvc.GetUser(); History.UserId = user.Id.ToString(); History.Duration = 5; History.StartDate = System.DateTime.UtcNow.AddMinutes(-5); History.OriginalDate = System.DateTime.UtcNow.AddMinutes(-5); History.CompletedDate = System.DateTime.UtcNow; History.CompletedUser = user.Id.ToString(); History.Description = Left(Description.PickListValue, 64); History.LongNotes = Notes.Text; History.Notes = Left(Notes.Text, 255); History.Timeless = false; History.Result = Left(Result.PickListValue, 64); History.ResultCode = "COMP"; try { History.Save(); //ListBox lbFollowUp = FindCompActControl("FollowUp") as ListBox; //if (lbFollowUp == null) return false; //CheckBox cxCarryOverNotes = FindCompActControl("CarryOverNotes") as CheckBox; //if (cxCarryOverNotes == null) return false; //CheckBox cxCarryOverAttachments = FindCompActControl("CarryOverAttachments") as CheckBox; //if (cxCarryOverAttachments == null) return false; if (CurrentLead.FirstName == null && CurrentLead.LastName == null) { CurrentLead.FirstName = "No"; CurrentLead.LastName = "Name"; } CurrentLead.CfxLastCallResult = Left(Result.PickListValue, 64); CurrentLead.ModifyUser = user.Id.ToString(); // Force Modify User and Modify Date to be set CurrentLead.ModifyDate = DateTime.UtcNow; CurrentLead.ValidateLead(); CurrentLead.Save(); //Refresh if (this.PageWorkItem != null) { Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = PageWorkItem.Services.Get <Sage.Platform.WebPortal.Services.IPanelRefreshService>(); if (refresher != null) { refresher.RefreshAll(); } else { Response.Redirect(Request.Url.ToString()); } } if (Followup.Checked) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("type", "atPhoneCall"); //if (cxCarryOverNotes.Checked || cxCarryOverAttachments.Checked) //{ args.Add("historyid", History.Id.ToString()); //} //if (cxCarryOverNotes.Checkeod) //{ args.Add("carryovernotes", "true"); //} //if (cxCarryOverAttachments.Checked) //{ // args.Add("carryoverattachments", "true"); //} args.Add("aid", History.AccountId); args.Add("cid", History.ContactId); args.Add("oid", History.OpportunityId); args.Add("tid", History.TicketId); args.Add("lid", History.LeadId); args.Add("leadname", History.LeadName); args.Add("description", History.Description); // if we're in batch mode (multiple complete from ActivityReminders) // pass that fact on to ScheduleActivity, so it can link to next activity in batch Link.ScheduleActivity(args); } //=================================================== // Initialize //=================================================== Result.PickListValue = String.Empty; Description.PickListValue = String.Empty; Notes.Text = String.Empty; Followup.Checked = false; } catch (Exception) { //Exception But Continue } }
public static void GetManagerStep(IUser user, out Sage.Entity.Interfaces.IUser result) { result = EntityFactory.GetById <IUser>(user.ManagerId); }