Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Sage.Platform.Application.IContextService context =
                Sage.Platform.Application.ApplicationContext.Current.Services.Get <IContextService>(true);
            Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)context.GetContext("TimeZone");

            string uid = ApplicationContext.Current.Services.Get <IUserService>().UserId.Trim();

            IUser u = EntityFactory.GetById <IUser>(uid);
            if (u == null)
            {
                log.ErrorFormat("TimeZone: Failed to get userid '{0}'", uid);
            }
            else
            {
                if (u.UserInfo.TimeZone != tz.KeyName)
                {
                    u.UserInfo.TimeZone = tz.KeyName;
                    u.Save();
                }
            }
        }
        catch (Exception ex)
        {
            log.ErrorFormat(String.Format("TimeZone: Failed to set timezone: {0}", ex.Message));
        }
    }
Example #2
0
    private double ServerToClientBias()
    {
        double ServerBias = -1 * System.TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
        double ClientBias = TimeZone.BiasForGivenDate(DateTime.Now);

        return(-1 * (ClientBias - ServerBias));
    }
    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;
            }
        }
    }
Example #4
0
    /// <summary>
    /// Gets the UTC time from local time.
    /// </summary>
    /// <param name="dateTime">The date time.</param>
    /// <returns></returns>
    public static DateTime GetUTCTimeFromLocalTime(DateTime dateTime)
    {
        IContextService context = ApplicationContext.Current.Services.Get <IContextService>(true);

        if (context.HasContext("TimeZone"))
        {
            Sage.Platform.TimeZone timeZone = (Sage.Platform.TimeZone)context.GetContext("TimeZone");
            return(timeZone.LocalDateTimeToUTCTime(dateTime));
        }
        return(dateTime);
    }
Example #5
0
 void CompDateValue_DateTimeValueChanged(object sender, EventArgs e)
 {
     if ((CompDateValue.DateTimeValue != null))
     {
         TimeZones tzones      = new TimeZones();
         TimeZone  comptz      = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName);
         DateTime  newDateTime = (DateTime)(CompDateValue.DateTimeValue);
         newDateTime = newDateTime.AddMinutes(-1 * TimeZone.BiasForGivenDate(newDateTime));
         CurrDateValue.DateTimeValue = newDateTime.AddMinutes(comptz.BiasForGivenDate(newDateTime));
     }
 }
    private IList<ILitRequest> GetLiterature()
    {
        ActivitySearchOptions aso;
        ActivitySearchOptions temp;
        _Context = ApplicationContext.Current.Services.Get<IContextService>(true);
        _TimeZone = (TimeZone) _Context.GetContext("TimeZone");
        temp = (ActivitySearchOptions)_Context.GetContext("ActivitySearchCriteria");
        aso = new ActivitySearchOptions();
        if (temp == null)
        {
            aso.UserIds.Add(_UserId);
        }
        else
        {
            aso.UserIds.AddRange(temp.UserIds);
        }
        aso.StartDate = null;
        aso.EndDate = null;
        using (new SessionScopeWrapper())
        {
            IRepository<ILitRequest> eventRep = EntityFactory.GetRepository<ILitRequest>();
            IQueryable qry = (IQueryable)eventRep;
            IExpressionFactory ef = qry.GetExpressionFactory();
            ICriteria crit = qry.CreateCriteria();
            IExpression userExp = ef.Eq("RequestUser", User.GetById(aso.UserIds[0]));
            IExpression dateRangeExp = null;
            if (_SortDir.Equals("Ascending"))
            {
                crit.AddOrder(ef.Asc(_SortColumn));
            }
            else
            {
                crit.AddOrder(ef.Desc(_SortColumn));
            }

            if (aso.StartDate.HasValue)
            {
                dateRangeExp = ef.And(ef.Ge("RequestDate", aso.StartDate.Value), ef.Lt("RequestDate", aso.EndDate.Value));
            }

            IList<ILitRequest> events;
            if (dateRangeExp != null)
            {
                events = crit.Add(
                    ef.And(userExp, dateRangeExp)).List<ILitRequest>();
            }
            else
            {
                events = crit.Add(userExp).List<ILitRequest>();
            }
            return events;
        }
    }
Example #7
0
 void CurrDateValue_DateTimeValueChanged(object sender, EventArgs e)
 {
     if ((CurrDateValue.DateTimeValue != null))
     {
         TimeZones tzones      = new TimeZones();
         TimeZone  comptz      = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName);
         DateTime  newDateTime = (DateTime)(CurrDateValue.DateTimeValue);
         newDateTime = newDateTime.AddMinutes(TimeZone.BiasForGivenDate(newDateTime));
         CompDateValue.DateTimeValue = newDateTime.AddMinutes(-1 * comptz.BiasForGivenDate(newDateTime));
         chkCompDltAdjust.Disabled   = (!comptz.ObservervesDaylightTime);
         lblCompDltAdjust.Disabled   = (!comptz.ObservervesDaylightTime);
     }
 }
    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;
        }
    }
Example #10
0
    private void BuildTimeZoneSelect(TimeZone tz, string clientTimeZone)
    {
        // option...............
        CompTzSelect.Items.Add(new ListItem(tz.DisplayName));
        if (clientTimeZone != tz.KeyName)
        {
            return;
        }

        CompTzSelect.SelectedValue = tz.DisplayName;
        currTZDispName.InnerText   = tz.DisplayName;
        currTZStdDltName.InnerText =
            tz.DateFallsWithinDaylightSaving(Activity.StartDate) ? tz.DaylightName : tz.StandardName;
        localtimezone.Value        = tz.KeyName;
        lblLocalTimeZone.InnerText = tz.DisplayName;
        localbias.Value            = tz.BiasForGivenDate(Activity.StartDate).ToString();
        localnodltbias.Value       = tz.Bias.ToString();
        chkCurrDltAdjust.Disabled  = (!tz.ObservervesDaylightTime);
        lblCurrDltAdjust.Disabled  = (!tz.ObservervesDaylightTime);
        chkCompDltAdjust.Disabled  = (!tz.ObservervesDaylightTime);
        lblCompDltAdjust.Disabled  = (!tz.ObservervesDaylightTime);
    }
Example #11
0
    /// <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 IList<IEvent> GetEvents()
    {
        ActivitySearchOptions aso;
        _Context = ApplicationContext.Current.Services.Get<IContextService>(true);
        _TimeZone = (TimeZone) _Context.GetContext("TimeZone");
        aso = (ActivitySearchOptions)_Context.GetContext("ActivitySearchCriteria");
        if (aso == null)
        {
            aso = new ActivitySearchOptions();
            aso.UserIds.Add(_UserId);
            aso.StartDate = DateTime.Today.ToUniversalTime();
            aso.EndDate = DateTime.Today.AddDays(1).ToUniversalTime();
        }
        using ( new SessionScopeWrapper())
        {
            IRepository<IEvent> eventRep = EntityFactory.GetRepository<IEvent>();
            IQueryable qry = (IQueryable)eventRep;
            IExpressionFactory ef = qry.GetExpressionFactory();
            ICriteria crit = qry.CreateCriteria();
            IExpression userExp = ef.Eq("UserId", aso.UserIds[0]);
            IExpression dateRangeExp = null;
            if (_SortDir.Equals("Ascending"))
            {
                crit.AddOrder(ef.Asc(_SortColumn));
            }
            else
            {
                crit.AddOrder(ef.Desc(_SortColumn));
            }

            if (aso.UserIds.Count > 1)
            {
                userExp = ef.In("UserId", aso.UserIds);
            }
            if (aso.StartDate.HasValue)
            {
                dateRangeExp = ef.And(ef.Ge("StartDate", aso.StartDate.Value), ef.Lt("StartDate", aso.EndDate.Value));
            }

            IList<IEvent> events;
            if (dateRangeExp != null)
            {
                events = crit.Add(
                    ef.And(userExp, dateRangeExp)).List<IEvent>();
            }
            else
            {
                events = crit.Add(userExp).List<IEvent>();
            }
            return events;
        }
    }
    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();
            }
        }
    }
    protected void Save(object sender, EventArgs e)
    {
        if (SendBy.DateTimeValue < DateTime.Now.AddDays(-1))
        {
            return;
        }
        if (RequestedFor.LookupResultValue != null)
        {
            IContextService        conserv = ApplicationContext.Current.Services.Get <IContextService>(true);
            Sage.Platform.TimeZone tz      = (Sage.Platform.TimeZone)conserv.GetContext("TimeZone");

            ILitRequest    lr             = EntityFactory.Create <ILitRequest>();
            SLXUserService slxUserService = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService;
            if (slxUserService != null)
            {
                lr.RequestUser = slxUserService.GetUser();
            }
            String[] arClientData = clientdata.Value.ToString().Split('|');
            lr.RequestDate = DateTime.Now.AddMinutes(tz.BiasForGivenDate(DateTime.Now));
            lr.CoverId     = arClientData[0];
            lr.Contact     = (IContact)RequestedFor.LookupResultValue;
            lr.ContactName = lr.Contact.LastName + ", " + lr.Contact.FirstName;
            lr.Description = Description.Text;
            lr.SendDate    = SendBy.DateTimeValue;
            lr.SendVia     = SendVia.PickListValue;
            lr.Priority    = Priority.PickListValue;
            lr.Options     = PrintLiteratureList.SelectedIndex;

            lr.Save();

            Activity act = new Activity();
            act.Type         = ActivityType.atLiterature;
            act.AccountId    = lr.Contact.Account.Id.ToString();
            act.AccountName  = lr.Contact.Account.AccountName;
            act.ContactId    = lr.Contact.Id.ToString();
            act.ContactName  = lr.ContactName;
            act.PhoneNumber  = lr.Contact.WorkPhone;
            act.StartDate    = (DateTime)lr.RequestDate;
            act.Duration     = 0;
            act.Description  = lr.Description;
            act.Alarm        = false;
            act.Timeless     = true;
            act.Rollover     = false;
            act.UserId       = lr.RequestUser.Id.ToString();
            act.OriginalDate = (DateTime)lr.RequestDate;
            act.Save();

            // save litRequest item
            double totalCost = 0.0;
            string coverId   = arClientData[0];

            // get cover name
            for (int i = 1; i < arClientData.Length; i++)
            {
                string[] clientData = arClientData[i].Split('=');
                string   litItemId  = clientData[0];
                int      qty        = Int32.Parse(clientData[1]);

                // get literature item cost
                ILiteratureItem litItem = EntityFactory.GetById <ILiteratureItem>(litItemId);
                totalCost += (double)qty * (litItem.Cost.HasValue ? (double)litItem.Cost.Value : (double)0.0);

                // add the literature request item
                ILitRequestItem lrItem = EntityFactory.Create <ILitRequestItem>();
                lrItem.Qty            = qty;
                lrItem.LitRequest     = lr;
                lrItem.LiteratureItem = litItem;

                lr.LitRequestItems.Add(lrItem);
            }

            lr.TotalCost = totalCost;

            // get cover name
            string coverName = GetCoverName(coverId);
            lr.CoverName = coverName;

            lr.Save();  //must make ids match, and id prop is read only, so....

            SynchronizeLitRequestId(act.Id, lr.Id.ToString());

            // re-get entity with new activity id
            lr = EntityFactory.GetById <ILitRequest>(act.Id);

            // process the lit request if handle fulfillment locally is checked
            if (chkHandleLocal.Checked)
            {
                // show printer dialog for fulfillment
                FulfillRequestLocally(lr);

                // call business rule to update the entity properties
                lr.FulfillLitRequest();
            }
            else
            {
                Response.Redirect("Contact.aspx?entityId=" + lr.Contact.Id.ToString());
            }
        }
    }
Example #15
0
    private void BuildTimeZoneSelect(TimeZone tz, string clientTimeZone)
    {
        // option...............
        CompTzSelect.Items.Add(new ListItem(tz.DisplayName));
        if (clientTimeZone != tz.KeyName) return;

        CompTzSelect.SelectedValue = tz.DisplayName;
        currTZDispName.InnerText = tz.DisplayName;
        currTZStdDltName.InnerText =
            tz.DateFallsWithinDaylightSaving(Activity.StartDate) ? tz.DaylightName : tz.StandardName;
        localtimezone.Value = tz.KeyName;
        lblLocalTimeZone.InnerText = tz.DisplayName;
        localbias.Value = tz.BiasForGivenDate(Activity.StartDate).ToString();
        localnodltbias.Value = tz.Bias.ToString();
        chkCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime);
        lblCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime);
        chkCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime);
        lblCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     m_SLXUserService = ApplicationContext.Current.Services.Get<IUserService>() as SLXUserService;
     _UserOptions = ApplicationContext.Current.Services.Get<IUserOptionsService>();
     _Context = ApplicationContext.Current.Services.Get<IContextService>(true);
     _TimeZone = (TimeZone)_Context.GetContext("TimeZone");
     object cacheDisplayRem = _Context.GetContext("ActivityRemindersDisplay");
     if (cacheDisplayRem != null)
     {
         string[] temp = cacheDisplayRem.ToString().Split('|');
         _DisplayReminders = Convert.ToBoolean(temp[0]);
         _Alarms = Convert.ToBoolean(temp[1]);
         _PastDue = Convert.ToBoolean(temp[2]);
         _Confirms = Convert.ToBoolean(temp[3]);
     }
     else
     {
         _DisplayReminders = (_UserOptions.GetCommonOption("DisplayActivityReminders", "Calendar") != "F");
         _Alarms = (_UserOptions.GetCommonOption("RemindAlarms", "Calendar") != "F");
         _PastDue = (_UserOptions.GetCommonOption("RemindPastDue", "Calendar") != "F");
         _Confirms = (_UserOptions.GetCommonOption("RemindConfirmations", "Calendar") != "F");
         string value = string.Format("{0}|{1}|{2}|{3}", _DisplayReminders, _Alarms, _PastDue, _Confirms);
         _Context.SetContext("ActivityRemindersDisplay", value);
     }
     _UserId = m_SLXUserService.GetUser().Id;
 }
    /// <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));
    }