Exemplo n.º 1
0
        public static bool AppointmentsUpdate(AppointmentPnDbContext dbContext, string globalId,
                                              ProcessingStateOptions processingState, string body, string exceptionString, string response,
                                              bool completed, DateTime start_at, DateTime expire_at, int duration)
        {
//            log.LogEverything(t.GetMethodName("SQLController"), "AppointmentsUpdate called and globalId is " + globalId);

            try
            {
                var match = dbContext.Appointments.SingleOrDefault(x => x.GlobalId == globalId);

                if (match == null)
                {
                    return(false);
                }

                match.ProcessingState = processingState.ToString();
//                match.updated_at = DateTime.Now;
                match.StartAt  = start_at;
                match.ExpireAt = expire_at;
                match.Duration = duration;
                //match.completed = 0;
                #region match.body = body ...
                if (body != null)
                {
                    match.Body = body;
                }
                #endregion
                #region match.response = response ...
                if (response != null)
                {
                    match.Response = response;
                }
                #endregion
                #region match.expectionString = expectionString ...
                if (response != null)
                {
                    match.ExceptionString = exceptionString;
                }
                #endregion
//                match.version = match.version + 1;

                match.Update(dbContext);

                return(true);
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(false);
            }
        }
Exemplo n.º 2
0
            public ProcessStateDetails(ProcessingStateOptions processingState, List <CategorisedCharacterString> mediaQueryContent)
            {
                if (!Enum.IsDefined(typeof(ProcessingStateOptions), processingState))
                {
                    throw new ArgumentOutOfRangeException("processingState");
                }
                if ((processingState == ProcessingStateOptions.InMediaQueryWrappedSelector) || (processingState == ProcessingStateOptions.InMediaQueryWrappedStyleBlock))
                {
                    if (mediaQueryContent == null)
                    {
                        throw new ArgumentException("A mediaQueryContentBuilder must be specified for the InMediaQueryWrappedSelector and InMediaQueryWrappedStyleBlock processing states");
                    }
                }
                else
                {
                    if (mediaQueryContent != null)
                    {
                        throw new ArgumentException("A mediaQueryContentBuilder must not be specified for processing states other than InMediaQueryWrappedSelector and InMediaQueryWrappedStyleBlock");
                    }
                }

                ProcessingState   = processingState;
                MediaQueryContent = mediaQueryContent;
            }
        public bool CalendarItemUpdate(string globalId, DateTime start, ProcessingStateOptions workflowState, string body)
        {
            if (string.IsNullOrEmpty(globalId))
            {
                throw new ArgumentNullException("globalId cannot be null or empty");
            }
            if (string.IsNullOrEmpty(body))
            {
                throw new ArgumentNullException("body cannot be null or empty");
            }
            log.LogStandard(t.GetMethodName("OutlookOnlineController"), "CalendarItemUpdate incoming start is : " + start.ToString());
            log.LogStandard(t.GetMethodName("OutlookOnlineController"), "CalendarItemUpdate incoming globalId is : " + globalId);
            //Event item = AppointmentItemFind(globalId, start.AddHours(-36), start.AddHours(36)); // TODO!
            //Event item = GetEvent(globalId);
            //userEmailAddess = GetUserEmailAddress();
            Event item = outlookExchangeOnlineAPIClient.GetEvent(globalId, userEmailAddess);

            if (item == null)
            {
                return(false);
            }

            item.BodyPreview          = body;
            item.Location.DisplayName = workflowState.ToString();
            string Categories = null;

            #region item.Categories = 'workflowState'...
            switch (workflowState)
            {
            case ProcessingStateOptions.Planned:
                Categories = null;
                break;

            case ProcessingStateOptions.Processed:
                Categories = CalendarItemCategory.Processing.ToString();
                break;

            case ProcessingStateOptions.Created:
                Categories = CalendarItemCategory.Processing.ToString();
                break;

            case ProcessingStateOptions.Sent:
                Categories = CalendarItemCategory.Sent.ToString();
                break;

            case ProcessingStateOptions.Retrived:
                Categories = CalendarItemCategory.Retrived.ToString();
                break;

            case ProcessingStateOptions.Completed:
                Categories = CalendarItemCategory.Completed.ToString();
                break;

            case ProcessingStateOptions.Canceled:
                Categories = CalendarItemCategory.Revoked.ToString();
                break;

            case ProcessingStateOptions.Revoked:
                Categories = CalendarItemCategory.Revoked.ToString();
                break;

            case ProcessingStateOptions.Exception:
                Categories = CalendarItemCategory.Error.ToString();
                break;

            case ProcessingStateOptions.ParsingFailed:
                Categories = CalendarItemCategory.Error.ToString();
                break;
            }
            #endregion

            Event eresult = outlookExchangeOnlineAPIClient.UpdateEvent(userEmailAddess, item.Id, CalendarItemUpdateBody(item.BodyPreview, item.Location.DisplayName, Categories));
            if (eresult == null)
            {
                log.LogStandard(t.GetMethodName("OutlookOnlineController"), AppointmentPrint(item) + " NOT updated to " + workflowState.ToString());
                return(false);
            }
            else
            {
                log.LogStandard(t.GetMethodName("OutlookOnlineController"), AppointmentPrint(item) + " updated to " + workflowState.ToString());
                return(true);
            }
        }