Example #1
0
    private void SetScheduledByLabel(IHistory history)
    {
        Sage.Platform.Application.IContextService context = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Application.IContextService>(true);
        Sage.Platform.TimeZone tz = context["TimeZone"] as Sage.Platform.TimeZone;

        if (tz != null)
        {
            string startDate  = tz.UTCDateTimeToLocalTime(history.StartDate).Date.ToShortDateString();
            string createdate = tz.UTCDateTimeToLocalTime(history.CreateDate).Date.ToShortDateString();
            if (history.Timeless)
            {
                startDate = history.StartDate.Date.ToShortDateString();
            }

            string userName;
            IUser  createUser = Sage.Platform.EntityFactory.GetById <IUser>(history.UserId);
            if (createUser != null)
            {
                userName = createUser.UserInfo.UserName;
            }
            else
            {
                if (history.CreateUser.ToUpper().Trim() == "PROCESS")
                {
                    userName = "******";
                }
                else
                {
                    userName = "******";
                }
            }

            CreateUser.Text = GetLocalResourceObject("rsScheduledOn") + " " + createdate + " " + GetLocalResourceObject("rsBy") + " " + userName + " " + GetLocalResourceObject("rsOriginallyFor") + " " + startDate;
        }
    }
    /// <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")));
    }
Example #3
0
 protected string GetLocalDateTime(object StartDate, object TimeLess)
 {
     if (TimeLess != null)
     {
         if ((bool)TimeLess)
         {
             DateTime startDate  = Convert.ToDateTime(StartDate);
             string   dateString = startDate.ToShortDateString() + " (" + GetLocalResourceObject("Const_Timeless") + ")";
             return(dateString);
         }
     }
     return(_timeZone.UTCDateTimeToLocalTime(Convert.ToDateTime(StartDate)).ToString("g"));
 }
    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;

        return(string.Format("{0} {1} {2} {3}",
                             GetLocalResourceObject("Const_ScheduledBy"), userName,
                             GetLocalResourceObject("Const_On"), timezonestring));
    }
Example #5
0
    ///// <summary>
    ///// Gets the local date time.
    ///// </summary>
    ///// <param name="StartDate">The start date.</param>
    ///// <param name="Timeless">The timeless.</param>
    ///// <returns></returns>
    ////protected string GetLocalDateTime(object StartDate, object Timeless)
    ////{
    ////    if (Convert.ToBoolean(Timeless))
    ////        return Convert.ToDateTime(StartDate).ToShortDateString();
    ////    const string cLocalDateTime = "g";
    ////    return _timeZone.UTCDateTimeToLocalTime(Convert.ToDateTime(StartDate)).ToString(cLocalDateTime);
    ////}

    protected string GetLocalDateTime(object completedDate)
    {
        var cd = completedDate as DateTime?;

        if (cd.HasValue)
        {
            if (cd.Value.Equals(cd.Value.Date.AddSeconds(5)))
            {
                return(cd.Value.ToShortDateString());
            }
            else
            {
                return(_timeZone.UTCDateTimeToLocalTime(cd.Value).ToString("g"));
            }
        }
        return(string.Empty);
    }
    private DataSet ResultsToDataSet(IList <Activity> results)
    {
        TimeZone  timeZone  = (TimeZone)_Context.GetContext("TimeZone");
        DataSet   dataSet   = new DataSet();
        DataTable dataTable = new DataTable("Reminders");

        dataTable.Columns.Add(new DataColumn("Type"));
        dataTable.Columns.Add(new DataColumn("TypeImage"));
        dataTable.Columns.Add(new DataColumn("StartDate"));
        dataTable.Columns.Add(new DataColumn("ContactName"));
        dataTable.Columns.Add(new DataColumn("AccountName"));
        dataTable.Columns.Add(new DataColumn("Description"));
        dataTable.Columns.Add(new DataColumn("Priority"));
        dataTable.Columns.Add(new DataColumn("Notes"));
        dataTable.Columns.Add(new DataColumn("SchedFor"));
        dataTable.Columns.Add(new DataColumn("Id"));

        //_CurrentActivity = null;
        foreach (Activity item in results)
        {
            //if (_CurrentActivity == null) { _CurrentActivity = item; }
            UserActivity ua = item.Attendees.FindAttendee(_UserId);
            _UserName = User.GetById(item.UserId).ToString();
            DataRow row = dataTable.NewRow();
            switch (item.Type)
            {
            case ActivityType.atAppointment:
                row[1] = Page.ResolveUrl("images/icons/Meeting_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atToDo:
                row[1] = Page.ResolveUrl("images/icons/To_Do_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atPhoneCall:
                row[1] = Page.ResolveUrl("images/icons/Call_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atPersonal:
                row[1] = Page.ResolveUrl("images/icons/Personal_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            default:
                row[1] = Page.ResolveUrl("images/icons/Calendar_16x16.gif");
                row[0] = item.TypeDisplay;
                break;
            }
            if (item.Timeless)
            {
                row[2] = item.StartDate.ToShortDateString() + " (timeless)";
            }
            else
            {
                row[2] = timeZone.UTCDateTimeToLocalTime(item.StartDate).ToString();
            }
            row[3] = item.ContactName;
            row[4] = item.AccountName;
            row[5] = item.Description;
            row[6] = item.Priority;
            row[7] = item.Notes;
            row[8] = _UserName;
            row[9] = item.Id;
            if (item.Id == Request["entityid"])
            {
                _highlightIndex = dataTable.Rows.Count;
            }
            dataTable.Rows.Add(row);
        }
        dataSet.Tables.Add(dataTable);
        return(dataSet);
    }