/// <summary> /// Builds the up email body. /// </summary> /// <returns></returns> private string BuildUpEmailBody(ITicket ticket) { String emailBody = String.Empty; String ticketRef = String.Empty; if (ticket != null) { emailBody = (ticket.ReceivedDate == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Received").ToString(), ticket.ReceivedDate.Value, "%0A%0A"); emailBody += (ticket.CompletedDate == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Completed").ToString(), ticket.CompletedDate.Value, "%0A%0A"); if (ticket.TicketProblem != null) { emailBody += (ticket.TicketProblem.Notes == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Description").ToString(), "%0A", HttpUtility.UrlEncode(ticket.TicketProblem.Notes.Trim()), "%0A%0A"); } if (ticket.TicketSolution != null) { emailBody += (ticket.TicketSolution.Notes == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Resolution").ToString(), "%0A", HttpUtility.UrlEncode(ticket.TicketSolution.Notes.Trim()), "%0A%0A"); } /* Add the TicketID, required by Send SLX. */ if (ticket.Id != null) { ticketRef = HttpUtility.UrlEncode(ticket.Id.ToString()); } emailBody += string.Format("{0}TICKETID: {1}{2}", "%0A%0A", ticketRef, "%0A%0A"); } //pluses are not used for spaces in mailto: encoding return(PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20"))); }
/// <summary> /// Sends an email to the system administrator containing the error message. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SendEmail(object sender, EventArgs e) { try { string emailTo = String.Empty; var adminUser = EntityFactory.GetById <IUser>("ADMIN "); if (adminUser != null) { emailTo = adminUser.UserInfo.Email; } string subject = PortalUtil.JavaScriptEncode(String.Format(GetLocalResourceObject("error_LinkingAccount").ToString(), IntegrationManager.SourceAccount.AccountName)); string emailBody = PortalUtil.JavaScriptEncode(IntegrationManager.LinkAccountError).Replace(Environment.NewLine, "%0A"); ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format( "<script type='text/javascript'>window.location.href='mailto:{0}?subject={1}&body={2}';</script>", emailTo, subject, emailBody), false); } catch (Exception ex) { log.Error(ex.Message); } }
/// <summary> /// Builds the up email body. /// </summary> /// <returns></returns> private string BuildUpEmailBody(ITicket ticket) { String emailBody = String.Empty; String ticketRef = String.Empty; if (ticket != null) { IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern; emailBody = (ticket.ReceivedDate == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Received").ToString(), timeZone.UTCDateTimeToLocalTime((DateTime)ticket.ReceivedDate).ToString(datePattern), "%0A%0A"); emailBody += (ticket.CompletedDate == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Completed").ToString(), timeZone.UTCDateTimeToLocalTime((DateTime)ticket.CompletedDate).ToString(datePattern), "%0A%0A"); if (ticket.TicketProblem != null) { emailBody += (ticket.TicketProblem.Notes == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Description").ToString(), "%0A", HttpUtility.UrlEncode(ticket.TicketProblem.Notes.Trim()), "%0A%0A"); } if (ticket.TicketSolution != null) { emailBody += (ticket.TicketSolution.Notes == null) ? String.Empty : string.Format(GetLocalResourceObject("SendTicketEmail_EmailBody_Resolution").ToString(), "%0A", HttpUtility.UrlEncode(ticket.TicketSolution.Notes.Trim()), "%0A%0A"); } /* Add the TicketID, required by Send SLX. */ if (ticket.Id != null) { ticketRef = HttpUtility.UrlEncode(ticket.Id.ToString()); } emailBody += string.Format("{0}TICKETID: {1}{2}", "%0A%0A", ticketRef, "%0A%0A"); } //pluses are not used for spaces in mailto: encoding return(PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20"))); }
protected void grdPicklistItems_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Get the LinkButton control for the Delete if ((DeleteColumnIndex >= 0) && (DeleteColumnIndex < e.Row.Cells.Count)) { var dialogBody = PortalUtil.JavaScriptEncode(GetLocalResourceObject("ConfirmMessage").ToString()); TableCell cell = e.Row.Cells[DeleteColumnIndex]; foreach (Control c in cell.Controls) { LinkButton btn = c as LinkButton; if (btn != null) { var script = new StringBuilder(); script.AppendLine(" javascript: return confirmation();"); script.AppendLine(" function confirmation() { "); script.AppendLine(" var answer = confirm('" + dialogBody + "');"); script.AppendLine(" if (answer) {"); script.AppendLine(" var x = new Sage.UI.Controls.PickList({});x.clear(x._storageNameSpace);"); script.AppendLine(" }"); script.AppendLine(" return answer;"); script.AppendLine(" }"); btn.Attributes.Add("onclick", script.ToString()); } } } } }
/// <summary> /// Handles the Init event of the Page control. /// </summary> private void RegisterClientScript() { StringBuilder sb = new StringBuilder(GetLocalResourceObject("CampaignTargets_ClientScript").ToString()); sb.Replace("@chkShowContacts", chkContacts.ClientID); sb.Replace("@chkShowLeads", chkLeads.ClientID); sb.Replace("@chkGroup", chkGroup.ClientID); sb.Replace("@lbxGroup", lbxGroups.ClientID); sb.Replace("@chkResponded", chkResponded.ClientID); sb.Replace("@chkPriority", chkPriority.ClientID); sb.Replace("@lbxPriority", lbxPriority.ClientID); sb.Replace("@chkStatus", chkStatus.ClientID); sb.Replace("@lbxStatus", lbxStatus.ClientID); sb.Replace("@chkStage", chkStage.ClientID); sb.Replace("@lbxStage", lbxStages.ClientID); sb.Replace("@chkExternalListId", chkExternalList.ClientID); sb.Replace("@confirmExternalListMsg", PortalUtil.JavaScriptEncode(GetLocalResourceObject("confirm_ExternalList_Msg").ToString())); sb.Replace("@cmdExternalListId", cmdExternalList.ClientID); sb.Replace("@txtConfirmExternalListId", txtConfirmExternalList.ClientID); sb.Replace("@targetsGridId", grdTargets.ClientID); sb.Replace("@txtSelectedTargetId", txtSelectedTargetId.ClientID); sb.Replace("@noTargetSelectedMsg", PortalUtil.JavaScriptEncode(GetLocalResourceObject("error_NoTarget_Selected").ToString())); sb.Replace("@txtSelectedTargetContextId", txtSelectContext.ClientID); sb.Replace("@txtSelectedTargetsId", txtSelectedTargets.ClientID); sb.Replace("@txtShowFilterId", txtShowFilter.ClientID); sb.Replace("@filterDivId", filterDiv.ClientID); sb.Replace("@lnkFiltersId", lnkFilters.ClientID); sb.Replace("@lnkHideFilters", PortalUtil.JavaScriptEncode(GetLocalResourceObject("lnkHideFilters.Text").ToString())); sb.Replace("@lnkShowFilters", PortalUtil.JavaScriptEncode(GetLocalResourceObject("lnkShowFilters.Text").ToString())); sb.Replace("@divExternalId", divExternal.ClientID); sb.Replace("@divDisplayGridId", divDisplayGrid.ClientID); ScriptManager.RegisterStartupScript(Page, GetType(), "TargetsScript", sb.ToString(), false); }
/// <summary> /// Registers the client script. /// </summary> private void RegisterClientScript() { StringBuilder sb = new StringBuilder(GetLocalResourceObject("MergeRecords_ClientScript").ToString()); sb.Replace("@lnkShowAllWizardId", lnkShowAllWizard.ClientID); sb.Replace("@txtShowAllId", txtShowAll.ClientID); sb.Replace("@lnkShowAllCaption", PortalUtil.JavaScriptEncode(GetLocalResourceObject("lnkShowAll.Caption").ToString())); sb.Replace("@lnkHideDupsCaption", PortalUtil.JavaScriptEncode(GetLocalResourceObject("lnkHideDups.Caption").ToString())); ScriptManager.RegisterStartupScript(Page, GetType(), "MergeRecords", sb.ToString(), false); }
/// <summary> /// Derived components should override this method to wire up event handlers. /// </summary> protected override void OnWireEventHandlers() { cmdReset.Attributes.Add("onclick", "return false;"); cmdClearAll.Attributes.Add("onclick", "return ct_ClearAll();"); cmdSelectAll.Attributes.Add("onclick", "return ct_SelectAll();"); lnkFilters.Attributes.Add("onclick", "return false;"); cmdDelete.Attributes.Add("onclick", "javascript: return confirm('" + PortalUtil.JavaScriptEncode(GetLocalResourceObject("confirmDeleteMsg").ToString()) + "');"); chkExternalList.Attributes.Add("onclick", "confirmExternalListCheck()"); base.OnWireEventHandlers(); }
/// <summary> /// Register javascript include. /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); ScriptManager.RegisterClientScriptResource(this, GetType(), "OpenSlx.Lib.Web.Controls.JS.formatted.js"); String script = String.Format("{{ EnterOnlyNumbers: '{0}', EnterOnlyWholeNumbers: '{1}' }}", PortalUtil.JavaScriptEncode(Resources.EnterOnlyNumbers, true), PortalUtil.JavaScriptEncode(Resources.EnterOnlyWholeNumbers, true)); ScriptManager.RegisterClientScriptBlock(this, GetType(), "OpenSlx.FormattedField.Strings", "OpenSlx.FormattedField.Strings = " + script + ";", true); }
/// <summary> /// Convenience function to show an alert message to the user, without using /// the javascript (modal) function. /// Note that you can generally only show 1 per page. /// </summary> /// <param name="ctl"></param> /// <param name="msg"></param> /// <param name="callback">Can specify javascript code to be run when user closes the message box. /// This needs to be specified as a Javascript function, for example "function() { alert('boo') }"</param> public static void MessageBox(this UserControl ctl, String msg, String callback = null) { String script = "Ext.MessageBox.alert('', '" + PortalUtil.JavaScriptEncode(msg) + "'"; if (!String.IsNullOrEmpty(callback)) { script += ", " + callback; } script += ");"; ctl.JavaScript(script); }
private void IntRegisterClientScripts() { StringBuilder script = new StringBuilder(); script.AppendLine( string.Format( " {0}_obj = new AddEditContactAssociation(\"{1}\", \"{2}\", \"{3}\", \"{4}\", \"{5}\", \"{6}\");", ClientID, Mode.ClientID, luToIDDialog.ClientID, lblBackRelationTo_Contact.ClientID, hdtContactId.ClientID, cmdClose.ClientID, PortalUtil.JavaScriptEncode(GetLocalResourceObject("MSGCanNotAssociateToSelf").ToString()))); script.AppendLine(); ScriptManager.RegisterClientScriptBlock(Page, GetType(), ClientID, script.ToString(), true); }
private string GenerateRowApporiateDeletionWarning(string pickListItemId) { var deleteAll = !string.IsNullOrEmpty(pickListItemId) && PickList.IsItemADefaultLanguageItem(pickListItemId); var msg = new StringBuilder(); msg.Append(GetLocalResourceObject("ConfirmMessage")); if (deleteAll) { msg.Append(Environment.NewLine); msg.Append(GetLocalResourceObject("DeleteAllAddendum")); } return(PortalUtil.JavaScriptEncode(msg.ToString())); }
private void GenerateScript() { StringBuilder jscript = new StringBuilder(); jscript.AppendFormat("var AccountManager_rsc=\"{0}\";", PortalUtil.JavaScriptEncode(GetLocalResourceObject("AccountManager_rsc").ToString())); jscript.AppendFormat("var AddToForecast_rsc=\"{0}\";", PortalUtil.JavaScriptEncode(GetLocalResourceObject("AddToForecast_rsc").ToString())); jscript.AppendFormat("var CloseProb_rsc=\"{0}\";", PortalUtil.JavaScriptEncode(GetLocalResourceObject("CloseProb_rsc").ToString())); jscript.AppendFormat("var Comments_rsc=\"{0}\";", PortalUtil.JavaScriptEncode(GetLocalResourceObject("Comments_rsc").ToString())); jscript.AppendFormat("var EstClose_rsc=\"{0}\";", PortalUtil.JavaScriptEncode(GetLocalResourceObject("EstClose_rsc").ToString())); jscript.AppendFormat("var ddl = '{0}'; ChangeUpdateItems();", ddlUpdateOppDropDown.ClientID); ScriptManager.RegisterStartupScript(Page, GetType(), ClientID, jscript.ToString(), true); }
/// <summary> /// Sends the email. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SendEmail(object sender, EventArgs e) { try { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { string emailTo = String.Empty; string emailCC = String.Empty; if (salesOrder.RequestedBy != null) { if (!salesOrder.RequestedBy.Equals(salesOrder.ShippingContact) || !salesOrder.RequestedBy.Equals(salesOrder.BillingContact)) { emailCC = salesOrder.RequestedBy.Email; } } if (salesOrder.ShippingContact != null) { emailTo = String.Format("{0};", salesOrder.ShippingContact.Email); } if (salesOrder.BillingContact != null && !salesOrder.BillingContact.Equals(salesOrder.ShippingContact)) { emailTo += salesOrder.BillingContact.Email; } string subject = PortalUtil.JavaScriptEncode( String.Format(GetLocalResourceObject("lblEmailSubject.Caption").ToString(), salesOrder.SalesOrderNumber, salesOrder.Account.AccountName)).Replace( Environment.NewLine, "%0A"); string emailBody = FormatEmailBody(salesOrder).Replace(Environment.NewLine, "%0A"); if (!String.IsNullOrEmpty(emailCC)) { ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format( "<script type='text/javascript'>window.location.href='mailto:{0}?cc={1}&subject={2}&body={3}';</script>", emailTo, emailCC, subject, emailBody), false); } else { ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format( "<script type='text/javascript'>window.location.href='mailto:{0}?subject={1}&body={2}';</script>", emailTo, subject, emailBody), false); } } } catch (Exception ex) { log.Error(ex.Message); } }
private string GetDeleteConfirm() { string deleteMessage = GetLocalResourceObject("Const_DeleteMessage").ToString(); if (Activity.UserId != Form.CurrentUserId) { UserActivity attendee = Activity.Attendees.FindAttendee(Form.CurrentUserId); if (attendee != null) { deleteMessage = attendee.Status != UserActivityStatus.asDeclned ? GetLocalResourceObject("Const_DeclineMessage").ToString() : GetLocalResourceObject("Const_DeleteAllMessage").ToString(); } } return("return confirm('" + PortalUtil.JavaScriptEncode(deleteMessage) + "');"); }
/// <summary> /// Gets the email address. /// </summary> /// <param name="emailType">Type of the email.</param> /// <param name="ticket">The ticket.</param> /// <returns></returns> private static string GetEmailAddress(int emailType, ITicket ticket) { string email = String.Empty; if (ticket != null) { switch (emailType) { case 0: //Contact if (ticket.Contact != null) { email = (string.IsNullOrEmpty(ticket.Contact.Email) ? String.Empty : ticket.Contact.Email); } break; case 1: //AssignedTo if (ticket.AssignedTo != null && ticket.AssignedTo.User != null) { email = ((ticket.AssignedTo.User.UserInfo.Email == String.Empty) ? String.Empty : ticket.AssignedTo.User.UserInfo.Email); } break; case 2: //AcctMgr if (ticket.Account != null && ticket.Account.AccountManager != null) { email = (string.IsNullOrEmpty(ticket.Account.AccountManager.UserInfo.Email) ? String.Empty : ticket.Account.AccountManager.UserInfo.Email); } break; case 3: //MyMgr SLXUserService service = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService; if (service != null) { //User UserContext = service.GetUser(); //if (UserContext != null && UserContext.Manager != null && UserContext.Manager.UserInfo != null) // email = ((UserContext.Manager.UserInfo.Email == String.Empty) ? String.Empty : UserContext.Manager.UserInfo.Email); } break; } } return(email != null?PortalUtil.JavaScriptEncode(email.Replace("+", "%20")) : email); }
/// <summary> /// Gets the email subject. /// </summary> /// <returns></returns> private string GetEmailSubject(ITicket ticket) { string ticketStatus = String.Empty; if (!String.IsNullOrEmpty(ticket.StatusCode)) { PickList picklist = PickList.GetPickListById(ticket.StatusCode); if (picklist != null) { ticketStatus = picklist.Text; } } return (PortalUtil.JavaScriptEncode(HttpUtility.UrlEncode( String.Format( GetLocalResourceObject("SendTicketEmail_EmailMessageSubject").ToString(), ticket.ToString(), ticketStatus, ticket.Subject)).Replace("+", "%20"))); }
/// <summary> /// Sends the email. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SendEmail(object sender, EventArgs e) { try { var salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { const string scriptFmtString = @"dojo.require('Sage.Utility.Email');Sage.Utility.Email.writeEmail('{0}', '{1}', '{2}');"; var to = new List <EmailTo>(); var cc = new EmailTo(); if (salesOrder.RequestedBy != null) { if (!Equals(salesOrder.RequestedBy, salesOrder.ShippingContact) && !Equals(salesOrder.RequestedBy, salesOrder.BillingContact)) { cc.firstName = salesOrder.RequestedBy.FirstName; cc.lastName = salesOrder.RequestedBy.LastName; cc.emailAddress = salesOrder.RequestedBy.Email; } } if (salesOrder.ShippingContact != null) { to.Add(new EmailTo(salesOrder.ShippingContact.FirstName, salesOrder.ShippingContact.LastName, salesOrder.ShippingContact.Email)); } if (salesOrder.BillingContact != null && !Equals(salesOrder.BillingContact, salesOrder.ShippingContact)) { to.Add(new EmailTo(salesOrder.BillingContact.FirstName, salesOrder.BillingContact.LastName, salesOrder.BillingContact.Email)); } var emailTo = new { to = to, cc = cc, bcc = string.Empty }; string subject = PortalUtil.JavaScriptEncode( string.Format(GetLocalResourceObject("lblEmailSubject.Caption").ToString(), salesOrder.SalesOrderNumber, salesOrder.Account.AccountName)); string emailBody = FormatEmailBody(salesOrder); ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format(scriptFmtString, JsonConvert.SerializeObject(emailTo), subject, emailBody), true); } } catch (Exception ex) { log.Error(ex.Message); } }
private new void RegisterClientScripts() { Page.ClientScript.RegisterClientScriptInclude("timeobj", "jscript/timeobjs.js"); if (!Page.ClientScript.IsClientScriptBlockRegistered("timezonecalc_clientscript")) { StringBuilder sb = new StringBuilder(GetLocalResourceObject("timezonecalc_clientscript").ToString()); sb.Replace("@rsMore", PortalUtil.JavaScriptEncode(GetLocalResourceObject("jsMore").ToString(), true)); sb.Replace("@rsLess", PortalUtil.JavaScriptEncode(GetLocalResourceObject("jsLess").ToString(), true)); sb.Replace("@morelessClientID", moreless.ClientID); sb.Replace("@lzComparisonTimeZones", PortalUtil.JavaScriptEncode( GetLocalResourceObject("localizeComparisonTimeZones.Text").ToString())); ScriptManager.RegisterClientScriptBlock(Page, GetType(), "timezonecalc_clientscript", sb.ToString(), true); //for more/less } string timeZoneCalcCSS = "<style type=\"text/css\">" + GetLocalResourceObject("timezonecalc_style") + "</style>"; Page.ClientScript.RegisterClientScriptBlock(GetType(), "timezonecalc_css", timeZoneCalcCSS); }
private string BuildLitRequestWarnings() { StringBuilder script = new StringBuilder(); script.AppendFormat("LitWarning_SelectTemplate = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_SelectTemplate").ToString())); script.AppendFormat("LitWarning_UnableToParseQuantity = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_UnableToParseQuantity").ToString())); script.AppendFormat("LitWarning_QtyGreaterThanZero = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_QtyGreaterThanZero").ToString())); script.AppendFormat("LitWarning_MaxOneBillion = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_MaxOneBillion").ToString())); script.AppendFormat("LitWarning_MustSelectTemplate = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_MustSelectTemplate").ToString())); script.AppendFormat("LitWarning_SendByDate = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_SendByDate").ToString())); script.AppendFormat("LitWarning_SelectContact = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_SelectContact").ToString())); script.AppendFormat("LitWarning_DescriptionLessThan64 = '{0}';", PortalUtil.JavaScriptEncode(GetLocalResourceObject("LitWarning_DescriptionLessThan64").ToString())); return(script.ToString()); }
/// <summary> /// Sends the email. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SendEmail(object sender, EventArgs e) { try { IOpportunity opportunity = BindingSource.Current as IOpportunity; if (opportunity != null) { string scriptFmtString = @"dojo.require('Sage.Utility.Email');Sage.Utility.Email.writeEmail('{0}', '{1}', '{2}');"; string emailTo = String.Empty; string subject = PortalUtil.JavaScriptEncode(String.Format(GetLocalResourceObject("lblEmailSubject.Caption").ToString(), opportunity.Description, opportunity.Account.AccountName)); string emailBody = FormatEmailBody(opportunity); ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format(scriptFmtString, emailTo, subject, emailBody), true); } } catch (Exception ex) { log.Error(ex); } }
/// <summary> /// Formats the email body. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <returns></returns> private string FormatEmailBody(ISalesOrder salesOrder) { IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); bool isMultiCurr = BusinessRuleHelper.IsMultiCurrencyEnabled(); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string products = String.Empty; string emailBody = String.Format("{0} %0A", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailAccount.Caption"), CheckForNullValue(salesOrder.Account.AccountName)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailOpportunity.Caption"), CheckForNullValue(salesOrder.Opportunity != null ? salesOrder.Opportunity.Description : String.Empty)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDateCreated.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.CreateDate).ToString(datePattern)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDateRequested.Caption"), salesOrder.OrderDate.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.OrderDate).ToString( datePattern) : String.Empty); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDatePromised.Caption"), salesOrder.DatePromised.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.DatePromised).ToString( datePattern) : String.Empty); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailSalesOrderId.Caption"), salesOrder.SalesOrderNumber); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailType.Caption"), CheckForNullValue(salesOrder.OrderType)); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("lblEmailStatus.Caption"), CheckForNullValue(salesOrder.Status)); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("lblEmailComments.Caption"), CheckForNullValue(salesOrder.Comments)); emailBody += String.Format("{0} %0A", GetLocalResourceObject("lblEmailValue.Caption")); curBaseTotal.Text = salesOrder.GrandTotal.ToString(); emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("lblEmailBaseGrandTotal.Caption").ToString(), curBaseTotal.FormattedText)); if (isMultiCurr) { curTotal.CurrentCode = salesOrder.CurrencyCode; curTotal.Text = salesOrder.GrandTotal.ToString(); emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("lblEmailSalesOrderGrandTotal.Caption").ToString(), curTotal.FormattedText)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailCurrencyCode.Caption"), CheckForNullValue(salesOrder.CurrencyCode)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRate.Caption"), CheckForNullValue(salesOrder.ExchangeRate)); if (salesOrder.ExchangeRateDate.HasValue) { emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.ExchangeRateDate). ToString(datePattern)); } else { emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), GetLocalResourceObject("lblNone.Caption")); } } emailBody += String.Format("%0A{0} %0A", GetLocalResourceObject("lblEmailProducts.Caption")); foreach (ISalesOrderItem item in salesOrder.SalesOrderItems) { products += String.Format("{0} ({1}); ", item.Product, item.Quantity); } emailBody += String.Format("{0} %0A", CheckForNullValue(products)); emailBody += String.Format("%0A{0} %0A", GetLocalResourceObject("lblEmailBillShipAddress.Caption")); emailBody += String.Format("{0} %0A", GetLocalResourceObject("lblEmailBillingAddress.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailBillingAddressName.Caption"), salesOrder.BillingContact == null ? String.Empty : salesOrder.BillingContact.NameLF); emailBody += salesOrder.BillingAddress.FormatFullSalesOrderAddress().Replace("\r\n", "%0A"); emailBody += String.Format("%0A %0A{0} %0A", GetLocalResourceObject("lblEmailShippingAddress.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailShippingAddressName.Caption"), salesOrder.ShippingContact == null ? String.Empty : salesOrder.ShippingContact.NameLF); emailBody += salesOrder.ShippingAddress.FormatFullSalesOrderAddress().Replace("\r\n", "%0A"); return(PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20"))); }
/// <summary> /// Called when [wire event handlers]. /// </summary> protected override void OnWireEventHandlers() { txtCode.Attributes.Add("onChange", string.Format("javascript: return CS_OnCodeChange(this,'{0}');", PortalUtil.JavaScriptEncode(GetLocalResourceObject("CodeChangeMSG").ToString()))); base.OnWireEventHandlers(); }
/// <summary> /// Formats the email body. /// </summary> /// <param name="quote">The sales order.</param> /// <returns></returns> private string FormatEmailBody(IQuote quote) { var context = ApplicationContext.Current.Services.Get <IContextService>(true); var timeZone = (TimeZone)context.GetContext("TimeZone"); bool isMultiCurr = BusinessRuleHelper.IsMultiCurrencyEnabled(); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string products = string.Empty; string emailBody = string.Format("{0} \r\n", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailAccount.Caption"), CheckForNullValue(quote.Account.AccountName)); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOpportunity.Caption"), CheckForNullValue(quote.Opportunity != null ? quote.Opportunity.Description : string.Empty)); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailDateCreated.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)quote.CreateDate).ToString(datePattern)); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailQuoteId.Caption"), quote.QuoteNumber); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailType.Caption"), CheckForNullValue(quote.Type)); emailBody += string.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("lblEmailStatus.Caption"), CheckForNullValue(quote.Status)); emailBody += string.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("lblEmailComments.Caption"), CheckForNullValue(quote.Comments)); emailBody += string.Format("{0} \r\n", GetLocalResourceObject("lblEmailValue.Caption")); curBaseTotal.Text = quote.GrandTotal.ToString(); emailBody += string.Format("{0} \r\n", string.Format(GetLocalResourceObject("lblEmailGrandTotal.Caption").ToString(), curBaseTotal.FormattedText)); if (isMultiCurr) { curTotal.CurrentCode = quote.CurrencyCode; curTotal.Text = quote.DocGrandTotal.ToString(); emailBody += string.Format("{0} \r\n", string.Format(GetLocalResourceObject("lblEmailGrandTotal.Caption").ToString(), curTotal.FormattedText)); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailCurrencyCode.Caption"), CheckForNullValue(quote.CurrencyCode)); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailExchangeRate.Caption"), CheckForNullValue(quote.ExchangeRate)); if (quote.ExchangeRateDate.HasValue) { emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)quote.ExchangeRateDate). ToString(datePattern)); } else { emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), GetLocalResourceObject("lblNone.Caption")); } } emailBody += string.Format("\r\n{0} \r\n", GetLocalResourceObject("lblEmailProducts.Caption")); products = quote.QuoteItems.Aggregate(products, (current, item) => current + string.Format("{0} ({1}); ", item.Product, item.Quantity)); emailBody += string.Format("{0} \r\n", CheckForNullValue(products)); emailBody += string.Format("\r\n{0} \r\n", GetLocalResourceObject("lblEmailBillShipAddress.Caption")); emailBody += string.Format("{0} \r\n", GetLocalResourceObject("lblEmailBillingAddress.Caption")); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailAddressName.Caption"), quote.BillingContact == null ? string.Empty : quote.BillingContact.NameLF); emailBody += quote.BillingAddress.FormatFullQuoteAddress().Replace("\r\n", "\r\n"); emailBody += string.Format("\r\n \r\n{0} \r\n", GetLocalResourceObject("lblEmailShippingAddress.Caption")); emailBody += string.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailAddressName.Caption"), quote.ShippingContact == null ? string.Empty : quote.ShippingContact.NameLF); emailBody += quote.ShippingAddress.FormatFullQuoteAddress().Replace("\r\n", "\r\n"); return(PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20"))); }
protected string GetScheduleLink(string activityType, string entityId, string entityDescription) { return("scheduleActivity(\"" + activityType + "\", \"" + entityId + "\", \"" + PortalUtil.JavaScriptEncode(entityDescription, true).Replace("\"", "\\\"") + "\");"); }
/// <summary> /// Handles the RowDataBound event of the grdStages control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param> protected void grdStages_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dr = (DataRowView)e.Row.DataItem; if (dr["Type"].ToString() == "TASK") { e.Row.Cells[0].Style.Value = "margin-left:20px"; e.Row.Cells[5].Text = String.Empty; LinkButton editTask = (LinkButton)e.Row.Cells[6].Controls[0]; editTask.Text = GetLocalResourceObject("grdStages.EditTask.RowCommand").ToString(); LinkButton completeTask = (LinkButton)e.Row.Cells[7].Controls[0]; completeTask.Text = GetLocalResourceObject("grdStages.CompleteTask.RowCommand").ToString(); LinkButton deleteCommnad = (LinkButton)e.Row.Cells[8].Controls[0]; deleteCommnad.Text = GetLocalResourceObject("grdStages.DeleteTask.RowCommand").ToString(); deleteCommnad.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", PortalUtil.JavaScriptEncode(GetLocalResourceObject("DeleteTaskMSG").ToString()))); if (dr["PercentComplete"] != null) { Label lblPercent = ((Label)e.Row.FindControl("lblPercent")); if (lblPercent != null) { try { lblPercent.Text = string.Format("{0}%", ((double)dr["PercentComplete"]) * 100); } catch { lblPercent.Text = string.Empty; } } } DateTimePicker dtpNeededDate = (DateTimePicker)e.Row.FindControl("dtpNeededDate"); if (dtpNeededDate != null) { try { dtpNeededDate.DateTimeValue = (DateTime)dr["NeededDate"]; } catch { dtpNeededDate.Text = string.Empty; } } } if (dr["Type"].ToString() == "STAGE") { e.Row.Cells[0].ColumnSpan = 5; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left; e.Row.Cells[0].Font.Bold = false; e.Row.BackColor = Color.FromArgb(220, 233, 247); e.Row.Cells[0].Text = string.Format("{0}: {1}", GetLocalResourceObject("Stage").ToString(), dr["Description"].ToString()); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); LinkButton deleteCommnad = (LinkButton)e.Row.Cells[4].Controls[0]; deleteCommnad.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", PortalUtil.JavaScriptEncode(GetLocalResourceObject("DeleteStageMSG").ToString()))); } if (dr["Type"].ToString() == "PLACE_HOLDER") { e.Row.Cells[0].ColumnSpan = 9; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left; e.Row.Cells[0].Font.Bold = false; e.Row.Cells[0].Style.Value = "margin-left:20px"; e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); } } }
/// <summary> /// This provides the data /// </summary> /// <returns></returns> protected string GenerateDataScript() { IList <DistanceDTO> results = null; StringBuilder script = new StringBuilder(); string fromLoc = Request.QueryString["from"]; double fromLat = Convert.ToDouble(Request.QueryString["fromlat"] ?? "0"); double fromLon = Convert.ToDouble(Request.QueryString["fromlon"] ?? "0"); string entityType = Request.QueryString["type"]; double distance = Convert.ToDouble(Request.QueryString["dist"] ?? "0"); string accountType = Request.QueryString["atype"]; string accountSubType = Request.QueryString["asub"]; string sortBy = Request.QueryString["sort"]; bool sortAsc = Convert.ToBoolean(Request.QueryString["asc"] ?? true.ToString()); int count = Convert.ToInt32(Request.QueryString["cnt"] ?? "0"); string selected = Request.QueryString["selected"]; IList <string> selections = null; if (!string.IsNullOrEmpty(selected)) { selections = new List <string>(selected.Split(';')); } // Contact Prox Search string contactType = Request.QueryString["ctype"]; string contactStatus = Request.QueryString["cstat"]; // Map Group string group = Request.QueryString["grp"]; if (entityType == null) { throw new Exception(GetLocalResourceObject("Error_EntityType_Null").ToString()); } if (fromLoc != null && Request.QueryString["fromlat"] != null && Request.QueryString["fromlon"] != null) { script.AppendFormat("data.addPoint({{latitude: {0}, longitude: {1}, name: '{2}', description: '', address: '', type: 'poi', id: 'poi'}}, true);\n", fromLat.ToString(CultureInfo.GetCultureInfo("en-US")), fromLon.ToString(CultureInfo.GetCultureInfo("en-US")), PortalUtil.JavaScriptEncode(fromLoc, true)); } if (string.IsNullOrEmpty(group)) { // Use the query from the prox search page switch (entityType.ToUpper()) { case "IACCOUNT": { results = DistanceSearchHelper.AccountDistanceSearch( fromLat, fromLon, distance, accountType, accountSubType, sortBy, sortAsc, count, 0, CurrentRegion.IsMetric); break; } case "ICONTACT": { results = DistanceSearchHelper.ContactDistanceSearch( fromLat, fromLon, distance, contactType, contactStatus, sortBy, sortAsc, count, 0, CurrentRegion.IsMetric); break; } } } else { results = GetGroupData(entityType, group, sortBy, sortAsc, count, selections); } // Add the points to the map if (results != null && results.Count > 0) { foreach (var dist in results) { // '*' is appended to descriptions when no geolocation data is avaialble. script.Append( string.Format("data.addPoint(new SlxDataPoint({{latitude: {0}, longitude: {1}, name: '{2}', address: '{3}', description: '{7}', id: '{4}', entityid: '{5}', url: '{6}', type: 'data'}}), true);\n", (dist.GeocodeLatitude.HasValue) ? dist.GeocodeLatitude.Value.ToString(CultureInfo.GetCultureInfo("en-US")) : "0.0", (dist.GeocodeLongitude.HasValue) ? dist.GeocodeLongitude.Value.ToString(CultureInfo.GetCultureInfo("en-US")) : "0.0", PortalUtil.JavaScriptEncode(string.Format("{0}{1}", (entityType.ToUpper().Equals("IACCOUNT")) ? dist.AccountName : dist.NameLF, (dist.GeocodeLatitude.HasValue) ? string.Empty : "*"), true), PortalUtil.JavaScriptEncode(dist.DisplayAddress, true), PortalUtil.JavaScriptEncode(dist.AddressId, true), PortalUtil.JavaScriptEncode((entityType.ToUpper().Equals("IACCOUNT")) ? dist.AccountId : dist.ContactId, true), GetEntityUrl(entityType, dist.AccountId, dist.ContactId), ((dist.GeocodeLatitude.HasValue) ? string.Empty : "<em>" + GetLocalResourceObject("AddressFailedToGeocode").ToString() + "</em><br/><br/>") + GetDescription(dist.MainPhone, dist.AccountManagerLF))); } } return(script.ToString()); }
public static void HandleDialogOpening(String providerId, Page page) { var controller = GetAuthorizationServiceViewController(providerId); HttpContext ctx = HttpContext.Current; String callbackUrl = GetCallbackUrl(providerId, HttpContext.Current.Request.Url); String authUrl = controller.GetAuthorizationUrl(callbackUrl); if (controller.provider.SupportsCallback ?? false) { ctx.Response.Redirect(authUrl); } else { ScriptManager.RegisterStartupScript(page, typeof(Page), "showprovider", String.Format("window.open('{0}', '_blank', 'toolbar=0;location=0;menubar=0;width=200px;height=200px;');", PortalUtil.JavaScriptEncode(authUrl, true)), true); } }
/// <summary> /// Handles the RowDataBound event of the grdStages control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param> protected void grdStages_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dr = (DataRowView)e.Row.DataItem; if (dr["Type"].ToString() == "TASK") { e.Row.Cells[0].Style.Value = "margin-left:20px"; e.Row.Cells[7].Text = String.Empty; LinkButton editTask = (LinkButton)e.Row.Cells[8].Controls[0]; editTask.Text = "Edit Task"; LinkButton completeTask = (LinkButton)e.Row.Cells[9].Controls[0]; completeTask.Text = "Complete Task"; LinkButton deleteCommnad = (LinkButton)e.Row.Cells[10].Controls[0]; deleteCommnad.Text = "Delete Task"; deleteCommnad.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", PortalUtil.JavaScriptEncode("Are you sure you want to Delete"))); //Setup the checkbox control to complete the tasks CheckBox cbComplete = ((CheckBox)e.Row.FindControl("chkComplete")); if (dr["Completed"].ToString() == "T") { cbComplete.Checked = true; } else { cbComplete.Checked = false; } //cbComplete.Attributes.Add("onClick", string.Format("return onCompleteStep('{0}','{1}','{2}');", cmdCompleteStep.ClientID, stepContext.ClientID, dr["Id"].ToString() + ":" + dr["Completed"])); cbComplete.Attributes.Add("onclick", string.Format("return onChecked('{0}','{1}','{2}');", cmdCompleteStep.ClientID, rowContext.ClientID, e.Row.RowIndex)); if (dr["WeightedPercentage"] != null) { Label lblPercent = ((Label)e.Row.FindControl("lblPercent")); if (lblPercent != null) { try { lblPercent.Text = string.Format("{0}%", ((double)dr["WeightedPercentage"]) * 100); } catch { lblPercent.Text = string.Empty; } } } DateTimePicker dtpNeededDate = (DateTimePicker)e.Row.FindControl("dtpNeededDate"); if (dtpNeededDate != null) { try { dtpNeededDate.DateTimeValue = (DateTime)dr["NeededDate"]; } catch { dtpNeededDate.Text = string.Empty; } } DateTimePicker dtpCompletedDate = (DateTimePicker)e.Row.FindControl("dtpCompleted"); if (dtpCompletedDate != null) { try { dtpCompletedDate.DateTimeValue = (DateTime)dr["CompletedDate"]; } catch { dtpCompletedDate.Text = string.Empty; } } } if (dr["Type"].ToString() == "STAGE") { e.Row.Cells[0].ColumnSpan = 5; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left; //e.Row.Cells[0].Font.Bold = false; e.Row.Cells[0].Font.Bold = true; e.Row.BackColor = Color.FromArgb(220, 233, 247); e.Row.Cells[0].Text = string.Format("{0}: {1}", "Stage", dr["Description"].ToString()); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); //e.Row.Cells.RemoveAt(1); LinkButton deleteCommnad = (LinkButton)e.Row.Cells[5].Controls[0]; deleteCommnad.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", PortalUtil.JavaScriptEncode("Are You Sure you want to Delete"))); } if (dr["Type"].ToString() == "PLACE_HOLDER") { e.Row.Cells[0].ColumnSpan = 10; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left; e.Row.Cells[0].Font.Bold = false; e.Row.Cells[0].Style.Value = "margin-left:20px"; e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); e.Row.Cells.RemoveAt(1); //e.Row.Cells.RemoveAt(1); } } }
protected void AccountAssociations_Grid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Get the LinkButton control for the Delete if ((DeleteColumnIndex >= 0) && (DeleteColumnIndex < e.Row.Cells.Count)) { TableCell cell = e.Row.Cells[DeleteColumnIndex]; foreach (Control c in cell.Controls) { LinkButton btn = c as LinkButton; if (btn != null) { btn.Attributes.Add("onclick", "javascript: return confirm('" + PortalUtil.JavaScriptEncode(GetLocalResourceObject("ConfirmMessage").ToString()) + "');"); return; } } } } }
public static string GetConfirmDeleteScript() { return(string.Format("return confirm('{0}');", PortalUtil.JavaScriptEncode(Resources.SalesLogix.ConfirmDelete))); }