Пример #1
0
        public DateTime ConvertUtcTimeToUserTime(DateTime utcDate)
        {
            // Get the local time zone and the current local time and year.
            TimeZone localZone = TimeZone.CurrentTimeZone;
            string   timezone  = localZone.StandardName;

            var response = (LocalTimeFromUtcTimeResponse)_context.Execute(new LocalTimeFromUtcTimeRequest
            {
                TimeZoneCode = _timeZoneCode.Value,
                UtcTime      = utcDate
            });

            return(response.LocalTime);
        }
Пример #2
0
        public void SetWorkItemStatus(Guid workItemId, Guid technicianId, bool isComplete, HttpPostedFileBase note)
        {
            bool hasAttachment = note != null && note.ContentLength > 0;
            Dictionary <string, int> workItemStatuses = GetWorkItemStatuses();

            _context.Execute(new SetStateRequest
            {
                EntityMoniker = new EntityReference(ars_workitem.EntityLogicalName, workItemId),
                State         = new OptionSetValue((int)(isComplete ? ars_workitemState.Inactive : ars_workitemState.Active)),
                Status        = new OptionSetValue(workItemStatuses[isComplete ? "Complete" : "Incomplete"])
            });

            if (hasAttachment)
            {
                string techName = _technicianService.GetTechnicianName(technicianId);

                var annotation = new Annotation
                {
                    NoteText     = String.Format("{0} changed status of work item to '{1}'", techName, isComplete ? "Complete" : "Incomplete"),
                    ObjectId     = new EntityReference(ars_workitem.EntityLogicalName, workItemId),
                    FileName     = note.GetNonEmptyFileName(),
                    DocumentBody = note.ConvertToBase64()
                };

                _context.AddObject(annotation);
                _context.SaveChanges();
            }
        }