protected string GetLocalDateTime(object StartDate, object TimeLess) { if ((bool)TimeLess) { DateTime startDate = Convert.ToDateTime(StartDate); string dateString = startDate.ToShortDateString() + " (timeless)"; return(dateString); } return(_timeZone.UTCDateTimeToLocalTime(Convert.ToDateTime(StartDate)).ToString("g")); }
protected string GetLocalDateTime(object startDateObj, object timeLess) { DateTime startDate = Convert.ToDateTime(startDateObj); if ((bool)timeLess) { return(startDate.ToShortDateString() + " (timeless)"); } return(_timeZone.UTCDateTimeToLocalTime(startDate).ToString("g")); }
private void SetActivityDetail() { IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string timePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern; if (_CurrentActivity != null) { switch (_CurrentActivity.Type) { case Sage.Entity.Interfaces.ActivityType.atAppointment: ActivityType.Text = GetLocalResourceObject("DeleteConfirmation_ActivityType_Meeting").ToString(); break; case Sage.Entity.Interfaces.ActivityType.atToDo: ActivityType.Text = GetLocalResourceObject("DeleteConfirmation_ActivityType_ToDo").ToString(); break; case Sage.Entity.Interfaces.ActivityType.atPhoneCall: ActivityType.Text = GetLocalResourceObject("DeleteConfirmation_ActivityType_Call").ToString(); break; case Sage.Entity.Interfaces.ActivityType.atPersonal: ActivityType.Text = GetLocalResourceObject("DeleteConfirmation_ActivityType_Personal").ToString(); break; default: ActivityType.Text = _CurrentActivity.Type.ToString(); break; } StartDate.Text = _CurrentActivity.Timeless ? _CurrentActivity.StartDate.ToShortDateString() + " (timeless)" : timeZone.UTCDateTimeToLocalTime(_CurrentActivity.StartDate).ToString(datePattern + " " + timePattern); Regarding.Text = _CurrentActivity.Description; ContactId.LookupResultValue = _CurrentActivity.ContactId; AccountId.LookupResultValue = _CurrentActivity.AccountId; OpportunityId.LookupResultValue = _CurrentActivity.OpportunityId; Phone.Text = _CurrentActivity.PhoneNumber; From.LookupResultValue = GetFromUserId(); To.LookupResultValue = _UserId; Action.Text = _UserNotify.Type; Reply.Text = _UserNotify.Notes; ApplicationPage page = Page as ApplicationPage; if (page == null) { return; } } }
private string GetCreateUser() { IUser createUser = User.GetById(Activity.CreateUser); string userName = createUser != null ? createUser.UserInfo.UserName : Activity.CreateUser; string timezonestring = TimeZone != null ? TimeZone.UTCDateTimeToLocalTime(Activity.CreateDate).ToShortDateString() : string.Empty; string originally = Activity.Timeless ? Activity.StartDate.ToShortDateString() : TimeZone.UTCDateTimeToLocalTime(Activity.StartDate).ToShortDateString(); return(string.Format("{0} {1} {2} {3} {4} {5}", GetLocalResourceObject("Const_ScheduledBy"), userName, GetLocalResourceObject("Const_On"), timezonestring, GetLocalResourceObject("Const_originally_for"), originally)); }
private void SetDetail() { IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string timePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern; if (_CurrentEntity != null) { if (_CurrentEntity.SendDate.HasValue) { StartDate.Text = timeZone.UTCDateTimeToLocalTime(_CurrentEntity.SendDate.Value).ToString(datePattern + " " + timePattern); } if (!String.IsNullOrEmpty(_CurrentEntity.Notes)) { Regarding.Text = _CurrentEntity.Notes; } From.LookupResultValue = _CurrentEntity.FromUserId; To.LookupResultValue = _CurrentEntity.ToUserId; } }
/// <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"))); }
private void SetActivityDetail() { if (_CurrentActivity != null && grdActivityReminders.Rows.Count > 0) { if (string.IsNullOrEmpty(_CurrentActivity.Description)) { lnkRegarding.Text = _CurrentActivity.TypeDisplay; } else { lnkRegarding.Text = _CurrentActivity.Description; } lnkRegarding.NavigateUrl = _CurrentActivity.Recurring ? String.Format("javascript:Link.editActivityOccurrence('{0}', '{1}')", _CurrentActivity.ActivityId, _CurrentActivity.StartDate.ToString()) : String.Format("javascript:Link.editActivity('{0}');", _CurrentActivity.ActivityId); imgActivity.ImageUrl = Page.ResolveUrl(ActivityTypeImageUrls[_CurrentActivity.Type]); if (_CurrentActivity.Timeless) { lblStartDate.Text = String.Format("{0} {1}", _CurrentActivity.StartDate.ToShortDateString(), GetLocalResourceObject("lblTimeless.Text")); } else { DateTime endTime = TimeZone.UTCDateTimeToLocalTime(_CurrentActivity.StartDate).AddMinutes(_CurrentActivity.Duration); lblStartDate.Text = String.Format("{0} - {1}", TimeZone.UTCDateTimeToLocalTime(_CurrentActivity.StartDate), endTime.ToLongTimeString()); } if (IsLead(_CurrentActivity)) { lblContact.Text = GetLocalResourceObject("lblLead.Text").ToString(); lnkContactName.Text = _CurrentActivity.LeadName; lnkContactName.Enabled = !String.IsNullOrEmpty(_CurrentActivity.LeadId); lnkContactName.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "LEAD", _CurrentActivity.LeadId)); lblAccount.Text = GetLocalResourceObject("lblCompany.Text").ToString(); lnkAccount.Text = _CurrentActivity.AccountName; lnkAccount.Enabled = !String.IsNullOrEmpty(_CurrentActivity.LeadId); lnkAccount.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "LEAD", _CurrentActivity.LeadId)); } else { lblContact.Text = GetLocalResourceObject("lblContact.Text").ToString(); lnkContactName.Text = _CurrentActivity.ContactName; lnkContactName.Enabled = !String.IsNullOrEmpty(_CurrentActivity.ContactId); lnkContactName.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "CONTACT", _CurrentActivity.ContactId)); lblAccount.Text = GetLocalResourceObject("lblAccount.Text").ToString(); lnkAccount.Text = _CurrentActivity.AccountName; lnkAccount.Enabled = !String.IsNullOrEmpty(_CurrentActivity.AccountId); lnkAccount.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "ACCOUNT", _CurrentActivity.AccountId)); } phnPhone.Text = _CurrentActivity.PhoneNumber; lnkOpportunity.Text = _CurrentActivity.OpportunityName; lnkOpportunity.Enabled = !String.IsNullOrEmpty(_CurrentActivity.OpportunityId); lnkOpportunity.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "OPPORTUNITY", _CurrentActivity.OpportunityId)); lnkTicket.Text = _CurrentActivity.TicketNumber; lnkTicket.Enabled = !String.IsNullOrEmpty(_CurrentActivity.TicketId); lnkTicket.NavigateUrl = Page.ResolveClientUrl(String.Format("../../{0}.aspx?entityId={1}", "TICKET", _CurrentActivity.TicketId)); txtNotes.Text = _CurrentActivity.LongNotes; lblPriorityDisplay.Text = _CurrentActivity.Priority; lblLeaderDisplay.Text = User.GetById(_CurrentActivity.UserId).ToString(); if (_CurrentActivity.Attendees.Current.Status.Equals(UserActivityStatus.asUnconfirmed)) { divConfirmActivity.Style.Add(HtmlTextWriterStyle.Display, "inline"); divActivityOptions.Style.Add(HtmlTextWriterStyle.Display, "none"); divDeleteConfirmation.Style.Add(HtmlTextWriterStyle.Display, "none"); lnkRegarding.NavigateUrl = Page.ResolveClientUrl(String.Format("../../ConfirmActivity.aspx?entityid={0}", _CurrentActivity.ActivityId)); } else { divActivityOptions.Style.Add(HtmlTextWriterStyle.Display, "inline"); divConfirmActivity.Style.Add(HtmlTextWriterStyle.Display, "none"); divDeleteConfirmation.Style.Add(HtmlTextWriterStyle.Display, "none"); } SetDuration(); //Recurring context imgRecurImage.ImageUrl = Page.ResolveUrl(RecurImageUrls[_CurrentActivity.Recurring]);; lnkComplete.Visible = !_CurrentActivity.Recurring; imgComplete.Visible = !_CurrentActivity.Recurring; } else { lnkRegarding.Text = GetLocalResourceObject("lblNoActivity.Text").ToString(); imgActivity.ImageUrl = Page.ResolveUrl("images/icons/Calendar_16x16.gif"); lnkContactName.Text = String.Empty; lnkContactName.NavigateUrl = String.Empty; phnPhone.Text = String.Empty; lnkAccount.Text = String.Empty; txtNotes.Text = String.Empty; lnkOpportunity.Text = String.Empty; lnkTicket.Text = String.Empty; btnSnooze.Enabled = false; btnSnoozeAll.Enabled = false; } }
/// <summary> /// Formats the email body. /// </summary> /// <param name="opportunity">The opportunity.</param> /// <returns></returns> private string FormatEmailBody(IOpportunity opportunity) { IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string oppProducts = String.Empty; bool oppWon = GetOpportunityStatusMatch(opportunity, "ClosedWon"); bool oppLost = GetOpportunityStatusMatch(opportunity, "ClosedLost"); string emailBody = String.Format("{0} \r\n", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppDesc.Caption"), CheckForNullValue(opportunity.Description)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppAccount.Caption"), CheckForNullValue(opportunity.Account != null ? opportunity.Account.AccountName : String.Empty)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppAcctMgr.Caption"), CheckForNullValue(opportunity.AccountManager)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppReseller.Caption"), CheckForNullValue(opportunity.Reseller)); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppEstClose.Caption"), opportunity.EstimatedClose.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime)opportunity.EstimatedClose).ToString (datePattern) : String.Empty); emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppCloseProb.Caption"), CheckForNullValue(opportunity.CloseProbability)); emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppComments.Caption"), CheckForNullValue(opportunity.Notes)); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppValue.Caption")); //emailBody += BusinessRuleHelper.AccountingSystemHandlesSO() // ? String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"), // curERPOpenBaseSalesPotential.FormattedText) // : String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"), // curOpenBaseSalesPotential.FormattedText); emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppWeighted.Caption"), curBaseWeighted.FormattedText); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppSummary.Caption")); if (oppWon || oppLost) { emailBody += String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppWonLostSummary.Caption").ToString(), dtpClosedWonSummary.Text, Convert.ToString(opportunity.DaysOpen))); emailBody += oppWon ? String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppReasonWon.Caption").ToString(), CheckForNullValue(opportunity.Reason))) : String.Format("{0} \r\n", String.Format( GetLocalResourceObject("EmailOppReasonLost.Caption").ToString(), CheckForNullValue(opportunity.Reason))); } else { emailBody += String.Format("{0} \r\n", String.Format(GetLocalResourceObject("EmailOppStageSummary.Caption").ToString(), CheckForNullValue(opportunity.Stage))); } emailBody += String.Format("{0} \r\n\r\n", String.Format(GetLocalResourceObject("lblEmailOppType.Caption").ToString(), CheckForNullValue(opportunity.Type))); emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppProducts.Caption")); oppProducts = Enumerable.Aggregate(opportunity.Products, oppProducts, (current, oppProduct) => current + String.Format("{0} ({1}); ", oppProduct.Product, oppProduct.Quantity)); if (!string.IsNullOrEmpty(oppProducts)) { emailBody += String.Format("{0} \r\n\r\n", CheckForNullValue(oppProducts.Substring(0, oppProducts.Length - 2))); } if (oppWon || oppLost) { emailBody += String.Format("{0} \r\n{1} \r\n\r\n", GetLocalResourceObject("EmailOppCompetitors.Caption"), GetOpportunityCompetitors()); } emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppContacts.Caption")); emailBody = Enumerable.Aggregate(opportunity.Contacts, emailBody, (current, oppContact) => current + String.Format("{0} \r\n", String.Format("{0}, {1}; {2}", oppContact.Contact.Name, oppContact.Contact.Title, oppContact.SalesRole))); return(HttpUtility.JavaScriptStringEncode(emailBody)); }
private void LoadQuoteTasks(EntityPage page) { if (page.IsDetailMode) { divEntityQuoteList.Style.Add("display", "none"); divEntityQuoteDetails.Style.Add("display", "block"); IQuote quote = EntityFactory.GetRepository <IQuote>().Get(page.EntityContext.EntityID); if (quote == null) { HideIntegration(); return; } else { IBackOffice backOffice = Utilities.GetBackOfficeByLogicalID(quote.ErpLogicalId); if (backOffice == null) { backOffice = Utilities.GetBackOfficeByLogicalID(account.ErpLogicalId); } IAccount account = quote.Account; // First validation is if the associated Account is Synced if (account == null || account.ErpExtId == null) { // If associated Account is not in Sync throw error throw new ValidationException(GetLocalResourceObject("Error_Account_NotPromoted").ToString()); } // Second Validation is if the Quote had line items var quoteItems = quote.QuoteItems; if (quoteItems == null || quoteItems.Count() <= 0) { throw new ValidationException(GetLocalResourceObject("Error_Quote_NoLineItems").ToString()); } //Get the BOD Mapping from Quote entity. IBODMapping bodMapping = Utilities.GetBODMappingByEntityBackoffice("SalesOrder", backOffice); if (bodMapping != null && bodMapping.IsActive == true) { if (quote.SyncStatus != null && quote.SyncStatus.Equals(GetLocalResourceObject("LinkQuote.Caption").ToString()) || quote.ErpExtId != null) { lblLinkQuote.Visible = false; imgLinkQuote.Visible = false; } else { lblLinkQuote.Visible = true; imgLinkQuote.Visible = true; } } else { HideQuotePromotion(); } lblLastUpdate.Text = String.Format(GetLocalResourceObject("lblLastUpdate.Caption").ToString(), TimeZone.UTCDateTimeToLocalTime((DateTime)quote.ModifyDate)); } if (page.IsNewEntity) { updateQuotePanel.Update(); } } }