コード例 #1
0
        public async Task <IHttpActionResult> RepeatSubCalendarEvent([FromBody] getEventModel repeatSubEventRequestData)
        {
            this.authenticateUser(repeatSubEventRequestData);
            UserAccount retrievedUser = await repeatSubEventRequestData.getUserAccount(db);

            await retrievedUser.Login();

            retrievedUser.getTilerUser().updateTimeZoneTimeSpan(repeatSubEventRequestData.getTimeSpan);
            PostBackData    retValue = new PostBackData("", 1);
            DateTimeOffset  refNow   = repeatSubEventRequestData.getRefNow();
            DB_UserActivity activity = new DB_UserActivity(refNow, UserActivity.ActivityType.Repeat);
            JObject         json     = JObject.FromObject(repeatSubEventRequestData);

            activity.updateMiscelaneousInfo(json.ToString());
            if (retrievedUser.Status)
            {
                string CalendarType = repeatSubEventRequestData.ThirdPartyType.ToLower();

                switch (CalendarType)
                {
                case "google":
                {
                    CustomErrors error = new CustomErrors(CustomErrors.Errors.TilerConfig_Repeat_Third_Party);
                    retValue = new PostBackData(error);
                }
                break;

                case "tiler":
                {
                    HashSet <string> calendarIds = new HashSet <string>()
                    {
                        repeatSubEventRequestData.EventID
                    };
                    Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db);
                    DB_Schedule schedule = new DB_Schedule(retrievedUser, refNow, repeatSubEventRequestData.getCurrentLocation(), retrievalOptions: DataRetrievalSet.scheduleManipulationWithUpdateHistory, calendarIds: calendarIds);
                    schedule.CurrentLocation = repeatSubEventRequestData.getCurrentLocation();
                    var thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false);

                    schedule.updateDataSetWithThirdPartyData(thirdPartyData);
                    activity.eventIds.Add(repeatSubEventRequestData.EventID);
                    retrievedUser.ScheduleLogControl.updateUserActivty(activity);
                    schedule.RepeatEvent(repeatSubEventRequestData.EventID, schedule.CurrentLocation);
                    await schedule.WriteFullScheduleToLog().ConfigureAwait(false);

                    retValue = new PostBackData("\"Success\"", 0);
                }
                break;

                default:
                    break;
                }
            }

            await AnalysisController.updateSuggestionAnalysis(retrievedUser.ScheduleLogControl).ConfigureAwait(false);

            TilerFront.SocketHubs.ScheduleChange scheduleChangeSocket = new TilerFront.SocketHubs.ScheduleChange();
            scheduleChangeSocket.triggerRefreshData(retrievedUser.getTilerUser());
            return(Ok(retValue.getPostBack));
        }
コード例 #2
0
        public async Task <IHttpActionResult> DeleteCalEvent([FromBody] getEventModel myUser)
        {
            this.authenticateUser(myUser);
            UserAccount retrievedUser = await myUser.getUserAccount(db);// new UserAccount(myUser.UserName, myUser.UserID);

            await retrievedUser.Login();

            retrievedUser.getTilerUser().updateTimeZoneTimeSpan(myUser.getTimeSpan);
            PostBackData retValue;

            if (retrievedUser.Status)
            {
                HashSet <string> calendarIds = new HashSet <string>()
                {
                    myUser.EventID
                };
                Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db);
                DB_Schedule schedule = new DB_Schedule(retrievedUser, myUser.getRefNow(), myUser.getCurrentLocation(), calendarIds: calendarIds);
                schedule.CurrentLocation = myUser.getCurrentLocation();
                var thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false);

                schedule.updateDataSetWithThirdPartyData(thirdPartyData);
                DB_UserActivity activity = new DB_UserActivity(myUser.getRefNow(), UserActivity.ActivityType.DeleteCalendarEvent, new List <String>()
                {
                    myUser.EventID
                });
                JObject json = JObject.FromObject(myUser);
                activity.updateMiscelaneousInfo(json.ToString());
                retrievedUser.ScheduleLogControl.updateUserActivty(activity);
                CustomErrors messageReturned = await schedule.deleteCalendarEventAndReadjust(myUser.EventID).ConfigureAwait(false);

                await schedule.WriteFullScheduleToLog().ConfigureAwait(false);

                int errorCode = messageReturned?.Code ?? 0;
                retValue = new PostBackData(messageReturned, errorCode);
            }
            else
            {
                retValue = new PostBackData("", 1);
            }

            TilerFront.SocketHubs.ScheduleChange scheduleChangeSocket = new TilerFront.SocketHubs.ScheduleChange();
            await AnalysisController.updateSuggestionAnalysis(retrievedUser.ScheduleLogControl).ConfigureAwait(false);

            scheduleChangeSocket.triggerRefreshData(retrievedUser.getTilerUser());
            return(Ok(retValue.getPostBack));
        }