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")));
    }
    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));
    }
    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);
    }
 private void PerformBinding()
 {
     if ((Visible) && (!_Loaded)) //|| (_Type.Equals("moreTabs") && this.ID.Equals("actTabPersonal")))
     {
         if ((Sort == ActivitySortOrder.soStartDate) && (ActivityGrid.CurrentSortExpression != "StartDate"))
         {
             ActivityGrid.ShowSortIcon = false;
         }
         _Context = ApplicationContext.Current.Services.Get<IContextService>(true);
         _TimeZone = (TimeZone)_Context.GetContext("TimeZone");
         ActivitySearchOptions aso = (ActivitySearchOptions)_Context.GetContext("ActivitySearchCriteria");
         if (aso == null)
         {
             aso = new ActivitySearchOptions();
             aso.UserIds.Add(_UserId);
             aso.StartDate = Activity.AdjustForClientTimezone(DateTime.Today.ToUniversalTime());
             aso.EndDate = Activity.AdjustForClientTimezone(DateTime.Today.AddDays(1).ToUniversalTime());
         }
         _Users = aso.UserIds;
         aso.IncludeUnconfirmed = false;
         aso.TheType = GetActivityType();
         aso.SortOrder = Sort;
         aso.SortDirection = SortDir;
         List<Activity> results;
         if (ID.Equals("actTabAlarms"))
         {
             results = new List<Activity>();
             foreach (string user in aso.UserIds)
             {
                 results.AddRange(Reminders.GetAlarms(user, aso.StartDate, aso.EndDate, Sort, SortDir));
             }
         }
         else
         {
             results = (List<Activity>)Activity.GetActivitiesFor(aso);
         }
         ActivityGrid.DataSource = ResultsToDataSet(results);
         ActivityGrid.DataBind();
         _Loaded = true;
     }
 }