예제 #1
0
파일: Plan.cs 프로젝트: baLR0n/Exi.Model
        /// <summary>
        /// Initializes a new instance of the <see cref="Plan"/> class.
        /// </summary>
        /// <param name="project">The project.</param>
        public Plan(Project project)
        {
            this.Project = project;
            this.scheduleCreator = new ScheduleCreator();

            this.Schedule = new List<ScheduleDay>();
        }
        private static async Task <DialogTurnResult> StoreMenuData(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            StoreOrderDuetime storeData;

            try
            {
                storeData =
                    JsonConvert.DeserializeObject <StoreOrderDuetime>(stepContext.Context.Activity.Value.ToString());
            }
            catch
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("OOPS! It seems you didn't choose any menu.") }, cancellationToken));
            }

            if (storeData.DueTime == null)
            {
                stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("OOPS! I don't know when will this order END. Please order again!") }, cancellationToken));
            }

            var startTime = (DateTime)stepContext.Values["OrderTime"];
            var endTime   = GetEndTime(startTime, storeData);

            if (startTime >= endTime)
            {
                stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("OOPS! The end time is earlier than start time. Please order again!") }, cancellationToken));
            }

            var sched = new Schedule()
            {
                ScheduleId     = Guid.NewGuid(),
                GroupId        = Guid.Empty,
                TriggerType    = 1,
                TriggerTime    = startTime,
                EndTime        = endTime,
                MenuUri        = storeData.Url,
                RepeatWeekdays = 0
            };

            // startTime = DateTime.Now.AddSeconds(5f);
            // endTime = DateTime.Now.AddSeconds(30f);
            var teamsChannelData = JsonConvert.DeserializeObject <dynamic>(stepContext.Context.Activity.ChannelData.ToString());
            var services         = await _schedulerFactory.GetAllSchedulers();

            var scheduler = new ScheduleCreator(services[0], stepContext.Context.Activity.From.Id, storeData.OrderID, sched.ScheduleId.ToString());

            scheduler.CreateSingleGroupBuy(startTime, endTime, teamsChannelData.channel.id.ToString());
            AddConversationReference(stepContext.Context.Activity as Activity);

            _schedRepo.Create(sched);
            _schedRepo.context.SaveChanges();

            await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(new CreateReservationCard().CreateReserveResult(storeData.StoreName, startTime, endTime)));

            await stepContext.Context.SendActivityAsync(MessageFactory.Text("The group buy has been reserved. I will notify you when the order start :D"));

            return(await stepContext.EndDialogAsync());
        }
예제 #3
0
        private static Result createReshoringLayoutSheets(UIDocument uiDoc)
        {
            Document _doc = uiDoc.Document;

            string _titleblockName           = "E1 30 x 42 Horizontal: E1 30x42 Horizontal";
            XYZ    _columnScheduleBottomLeft = new XYZ(2.3354130772204, 2.39482128194158, 0);
            XYZ    _viewCenter = new XYZ(1.45453036348288, 1.18116967618813, 0.871414246948733);
            XYZ    _levelScheduleBottomLeft = new XYZ(0.156336990263879, 2.37688649933288, 0);

            var _levels = Getters.GetLevels(_doc);

            Level _levelAbove  = null;
            Level _topLevel    = _levels.FirstOrDefault();
            Level _bottomLevel = _levels.LastOrDefault();

            List <Tuple <ViewSheet, View> > _sheetsWithViews = new List <Tuple <ViewSheet, View> >();


            foreach (Level _level in _levels)
            {
                if (_levelAbove == null)
                {
                    _levelAbove = _level;
                }

                BoundedViewCreator _boundedViewCreator = new BoundedViewCreator(_level, null, null);
                SheetCreator       _sheetCreator       = new SheetCreator(_doc);
                string             _viewName           = _boundedViewCreator.GetViewName(string.Empty, "FP");
                ViewSheet          _viewSheet          = _sheetCreator.CreateSheet(_titleblockName, _viewName, _viewName);
                ViewPlan           _viewPlan           = _boundedViewCreator.CreateViewPlan(80);
                _sheetsWithViews.Add(new Tuple <ViewSheet, View>(_viewSheet, _viewPlan));

                ViewSchedule          _columnSchedule = ScheduleCreator.CreateLayoutColumnSchedule(_doc, _level.Name, " Reshores");
                ScheduleSheetInstance _columnScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _columnSchedule.Id, _columnScheduleBottomLeft);

                ViewSchedule          _levelSchedule = ScheduleCreator.CreateLayoutLoadSchedule(_doc, _level.Name, " Loads");
                ScheduleSheetInstance _levelScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _levelSchedule.Id, _levelScheduleBottomLeft);

                _levelAbove = _level;
            }

            _doc.Regenerate();

            FamilySymbol _tagSymbol = new FilteredElementCollector(_doc)
                                      .OfCategory(BuiltInCategory.OST_MultiCategoryTags)
                                      .OfClass(typeof(FamilySymbol)).OfType <FamilySymbol>()
                                      .FirstOrDefault(p => p.FamilyName.Contains("Mark"));


            foreach (var _sheetWithView in _sheetsWithViews)
            {
                DimensionCreator.CreateDimensions(_sheetWithView.Item2);
                TagCreator.CreateTags(_sheetWithView.Item2, _tagSymbol);
                Viewport.Create(_doc, _sheetWithView.Item1.Id, _sheetWithView.Item2.Id, _viewCenter);
            }

            return(Result.Succeeded);
        }
        public void CreateScheduleTest()
        {
            var factory   = new Mock <Factory>().Object;
            var klaEvent  = new ConferencePlannerEvent(factory);
            var algorithm = new SchedulerAlgorithm(klaEvent, factory);

            string[] items = { "EUV Catch me if you Can (Home Expert) 30 min",
                               "Architecting the Intelligent Apps Engineer (Vignette)",
                               "Atomic Transistors -> Super Computing in your Palm (5 min)" };
            var      objScheduleCreator = new ScheduleCreator(klaEvent, algorithm);
            string   schedule           = objScheduleCreator.CreateSchedule(items);

            Assert.IsTrue(schedule.Length > 0);
        }
예제 #5
0
        private void button8_Click(object sender, EventArgs e)
        {
            ScheduleCreator SC     = new ScheduleCreator();
            var             output = SC.CreateAllItemsSchedule(_uidoc);

            if (output == Result.Succeeded)
            {
                BuildingCoderUtilities.InfoMsg("Schedules created successfully!");
            }
            else if (output == Result.Failed)
            {
                BuildingCoderUtilities.InfoMsg("Schedule creation failed for some reason.");
            }
        }
예제 #6
0
        private UIElement displayScheduleCreator(ScheduleCreator c)
        {
            EditingClassScheduleItemView itemViewEditing = new EditingClassScheduleItemView()
            {
                ScheduleCreator = c,
                Margin          = new Thickness(10, 0, 10, 20)
            };

            itemViewEditing.OnDelete += itemViewEditing_OnDelete;


            stackPanel.Children.Add(itemViewEditing);

            return(itemViewEditing);
        }
예제 #7
0
        public void CreateDefaultScheduleListTest()
        {
            this.creator = new ScheduleCreator();

            List <DayOfWeek> freedays = new List <DayOfWeek>();

            freedays.Add(DayOfWeek.Thursday);
            freedays.Add(DayOfWeek.Sunday);

            List <IDivisible> tests = new List <IDivisible>();

            int Chapter1Amount = 70;
            int Chapter2Amount = 90;
            int Chapter3Amount = 140;

            tests.Add(new Chapter("Kapitel 1", Chapter1Amount));
            tests.Add(new Chapter("Kapitel 2", Chapter2Amount));

            // Create list with 2 chapters.
            List <ScheduleDay> schedule = this.creator.CreateDefaultScheduleList(DateTime.Today, DateTime.Now.AddDays(12.0), freedays, tests);

            Assert.AreEqual(13, schedule.Count);
            Assert.AreEqual(DateTime.Today.AddDays(12.0), schedule[12].Date);
            Assert.AreEqual(Chapter1Amount,
                            schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 1")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter2Amount,
                            schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 2")).Sum(z => z.Amount)));

            tests.Add(new Chapter("Kapitel 3", Chapter3Amount));
            // Create list with 3 chapters.
            schedule = this.creator.CreateDefaultScheduleList(DateTime.Today, DateTime.Now.AddDays(12.0), freedays, tests);

            Assert.AreEqual(13, schedule.Count);
            Assert.AreEqual(DateTime.Today.AddDays(12.0), schedule[12].Date);
            Assert.AreEqual(Chapter1Amount,
                            schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 1")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter2Amount,
                            schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 2")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter3Amount,
                            schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 3")).Sum(z => z.Amount)));
        }
예제 #8
0
        public void CreateDefaultScheduleListTest()
        {
            this.creator = new ScheduleCreator();

            List<DayOfWeek> freedays = new List<DayOfWeek>();
            freedays.Add(DayOfWeek.Thursday);
            freedays.Add(DayOfWeek.Sunday);

            List<IDivisible> tests = new List<IDivisible>();

            int Chapter1Amount = 70;
            int Chapter2Amount = 90;
            int Chapter3Amount = 140;

            tests.Add(new Chapter("Kapitel 1", Chapter1Amount));
            tests.Add(new Chapter("Kapitel 2", Chapter2Amount));

            // Create list with 2 chapters.
            List<ScheduleDay> schedule = this.creator.CreateDefaultScheduleList(DateTime.Today, DateTime.Now.AddDays(12.0), freedays, tests);

            Assert.AreEqual(13, schedule.Count);
            Assert.AreEqual(DateTime.Today.AddDays(12.0), schedule[12].Date);
            Assert.AreEqual(Chapter1Amount,
                schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 1")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter2Amount,
                schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 2")).Sum(z => z.Amount)));
            
            tests.Add(new Chapter("Kapitel 3", Chapter3Amount));
            // Create list with 3 chapters.
            schedule = this.creator.CreateDefaultScheduleList(DateTime.Today, DateTime.Now.AddDays(12.0), freedays, tests);

            Assert.AreEqual(13, schedule.Count);
            Assert.AreEqual(DateTime.Today.AddDays(12.0), schedule[12].Date);
            Assert.AreEqual(Chapter1Amount,
                schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 1")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter2Amount,
                schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 2")).Sum(z => z.Amount)));
            Assert.AreEqual(Chapter3Amount,
                schedule.Sum(x => x.Pensum.Where(y => y.SubjectName.Equals("Kapitel 3")).Sum(z => z.Amount)));
        }
예제 #9
0
        private static Result createDeliverableSheets(UIDocument uiDoc)
        {
            //ToDo: these might be good as settings in a future UI
            string _titleblockName = "E1 30 x 42 Horizontal: E1 30x42 Horizontal";
            //string _elementName = "C-2"; // "EllisShore_LumberWithClamps";
            //
            //int _3dViewScale = 48;
            //XYZ _3dViewportCenter = new XYZ(2.21129429621462, 0.656294714474886, 0);
            //
            //int _sectionViewScale = 32;
            //XYZ _sectionViewportCenter = new XYZ(0.7791340191012, 1.72774616204266, 0);

            int _floorplanViewScale      = 20;
            XYZ _floorplanViewportCenter = new XYZ(1.13879414318027, 1.16675126090371, -0.025);

            XYZ _scheduleBottomLeft = new XYZ(1.9435380772204, 2.43263378194158, 0);

            Document _doc = uiDoc.Document;

            //Get a BoundedView3DDefinition for each Level - Scope Box in the project
            var _levels = Getters.GetLevels(_doc);

            var _scopeBoxes = Getters.GetScopeBoxes(_doc);

            var    _boundedViewCreators = new List <BoundedViewCreator>();
            double _extraExtents        = 0.5;

            foreach (Level _level in _levels)
            {
                Level _levelAbove = _levels.FirstOrDefault(p => p.Elevation > _level.Elevation);
                if (_levelAbove == null)
                {
                    continue;
                }

                foreach (Element _scopeBox in _scopeBoxes)
                {
                    BoundingBoxXYZ _scopeBoxBounds = _scopeBox.get_BoundingBox(null);
                    BoundingBoxXYZ _viewBounds     = new BoundingBoxXYZ
                    {
                        Min = new XYZ(
                            _scopeBoxBounds.Min.X - _extraExtents,
                            _scopeBoxBounds.Min.Y - _extraExtents,
                            _level.Elevation - _extraExtents),
                        Max = new XYZ(
                            _scopeBoxBounds.Max.X + _extraExtents,
                            _scopeBoxBounds.Max.Y + _extraExtents,
                            _levelAbove.Elevation + _extraExtents)
                    };

                    _boundedViewCreators.Add(new BoundedViewCreator(_level, _scopeBox, _viewBounds));
                }
            }

            //Generate Views, set their Boundaries & Names, Adjust Visiblity Graphics
            OverrideGraphicSettings _70Transparent = new OverrideGraphicSettings();

            _70Transparent.SetSurfaceTransparency(70);

            List <Tuple <ElementId, string, List <View> > > _createdSheetIdViewIdSets = new List <Tuple <ElementId, string, List <View> > >();

            foreach (var _boundedViewCreator in _boundedViewCreators)
            {
                SheetCreator    _sheetCreator    = new SheetCreator(_doc);
                ScheduleCreator _scheduleCreator = new ScheduleCreator(_doc);

                //Create Sheet
                string    _pourName  = _boundedViewCreator.GetViewName(string.Empty);
                ViewSheet _sheetView = _sheetCreator.CreateSheet(_titleblockName, _pourName, _pourName);

                ////Create 3D View
                //View3D _3DView = _boundedViewCreator.CreateView3D(_3dViewScale);
                //_3DView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_3DView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Floorplan View
                ViewPlan _floorPlanView = _boundedViewCreator.CreateViewPlan(_floorplanViewScale);
                _floorPlanView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                _floorPlanView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                ////Create Section View
                //ViewSection _sectionView = _boundedViewCreator.CreateViewSection(_sectionViewScale);
                //_sectionView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_sectionView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //ToDo: get necessary parameters into shared parameters, so that they are visible in Project
                // //Create Schedule
                // ViewSchedule _viewSchedule = _scheduleCreator.CreateSchedule(false, _pourName + " Shoring");
                // ScheduleField _comments = _scheduleCreator.AppendField(_viewSchedule, "Comments"); //Pour Name
                // ScheduleField _count = _scheduleCreator.AppendField(_viewSchedule, "Count");
                // ScheduleField _familyAndType = _scheduleCreator.AppendField(_viewSchedule, "Family and Type");
                // //ScheduleField _material = _scheduleCreator.AppendField(_viewSchedule, "Material");
                // //ScheduleField _clampSpacing = _scheduleCreator.AppendField(_viewSchedule, "Clamp Spacing");
                // //ScheduleField _lowerShoreLength = _scheduleCreator.AppendField(_viewSchedule, "Lower Shore Length");
                // //ScheduleField _upperShoreLength = _scheduleCreator.AppendField(_viewSchedule, "Upper Shore Length");
                // ScheduleField _height = _scheduleCreator.AppendField(_viewSchedule, "Height");
                // ScheduleField _clearShoreHeight = _scheduleCreator.AppendField(_viewSchedule, "Clear Shore Height"); //Total Shore Length
                // //ScheduleField _shoreLength = _scheduleCreator.AppendField(_viewSchedule, "Shore Overlap");
                // //ScheduleField _lumberWidth = _scheduleCreator.AppendField(_viewSchedule, "Lumber Width");
                // //ScheduleField _lumberThickness = _scheduleCreator.AppendField(_viewSchedule, "Lumber Thickness");
                // ScheduleField _loadCapacity = _scheduleCreator.AppendField(_viewSchedule, "Load Capacity"); //Safe Working Load
                //
                // _scheduleCreator.AppendSortField(_viewSchedule, _familyAndType);
                // //_scheduleCreator.AppendSortField(_viewSchedule, _lowerShoreLength);
                // //_scheduleCreator.AppendSortField(_viewSchedule, _upperShoreLength);
                // _scheduleCreator.AppendSortField(_viewSchedule, _clearShoreHeight);
                //
                // _scheduleCreator.AppendFilter(_viewSchedule, _comments, ScheduleFilterType.Equal, _pourName);
                //
                // ScheduleSheetInstance _scheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _sheetView.Id, _viewSchedule.Id, _scheduleBottomLeft);

                _createdSheetIdViewIdSets.Add(new Tuple <ElementId, string, List <View> >(
                                                  _sheetView.Id,
                                                  _pourName,
                                                  new List <View> { /*_3DView,*/
                    _floorPlanView,                                 /*_sectionView*/
                }
                                                  ));
            }

            _doc.Regenerate();

            foreach (var _createdSheetIdViewIdSet in _createdSheetIdViewIdSets)
            {
                foreach (View _view in _createdSheetIdViewIdSet.Item3)
                {
                    if (_view == null)
                    {
                        continue;
                    }

                    //if (_view is View3D) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _3dViewportCenter);
                    else if (_view is ViewPlan)
                    {
                        DimensionCreator.CreateDimensions(_view, _createdSheetIdViewIdSet.Item2);
                        Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _floorplanViewportCenter);
                    }
                    //else if (_view is ViewSection) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _sectionViewportCenter);
                }
            }

            return(Result.Succeeded);
        }
예제 #10
0
        private static Result createPourSheets(UIDocument uiDoc)
        {
            //ToDo: these might be good as settings in a future UI
            string _titleblockName = "E1 30 x 42 Horizontal: E1 30x42 Horizontal";
            //string _elementName = "C-2"; // "EllisShore_LumberWithClamps";
            //
            //int _3dViewScale = 48;
            //XYZ _3dViewportCenter = new XYZ(2.21129429621462, 0.656294714474886, 0);
            //
            //int _sectionViewScale = 32;
            //XYZ _sectionViewportCenter = new XYZ(0.7791340191012, 1.72774616204266, 0);

            int _floorplanViewScale      = 24;
            XYZ _floorplanViewportCenter = new XYZ(1.23473112570493, 1.15208223453682, 0);

            XYZ _columnScheduleBottomLeft = new XYZ(2.31721454780864, 2.37688649933288, 0);
            XYZ _levelScheduleBottomLeft  = new XYZ(0.156336990263879, 2.37688649933288, 0);

            Document _doc = uiDoc.Document;

            //Get a BoundedView3DDefinition for each Level - Scope Box in the project
            var _levels = Getters.GetLevels(_doc);

            var _scopeBoxes = Getters.GetScopeBoxes(_doc);

            var    _boundedViewCreators = new List <BoundedViewCreator>();
            double _extraExtents        = 0.5;

            foreach (Level _level in _levels)
            {
                Level _levelAbove = _levels.FirstOrDefault(p => p.Elevation > _level.Elevation);
                if (_levelAbove == null)
                {
                    continue;
                }

                foreach (Element _scopeBox in _scopeBoxes)
                {
                    BoundingBoxXYZ _scopeBoxBounds = _scopeBox.get_BoundingBox(null);
                    BoundingBoxXYZ _viewBounds     = new BoundingBoxXYZ
                    {
                        Min = new XYZ(
                            _scopeBoxBounds.Min.X - _extraExtents,
                            _scopeBoxBounds.Min.Y - _extraExtents,
                            _level.Elevation - _extraExtents),
                        Max = new XYZ(
                            _scopeBoxBounds.Max.X + _extraExtents,
                            _scopeBoxBounds.Max.Y + _extraExtents,
                            _levelAbove.Elevation + _extraExtents)
                    };

                    _boundedViewCreators.Add(new BoundedViewCreator(_level, _scopeBox, _viewBounds));
                }
            }

            //Generate Views, set their Boundaries & Names, Adjust Visiblity Graphics
            OverrideGraphicSettings _70Transparent = new OverrideGraphicSettings();

            _70Transparent.SetSurfaceTransparency(70);

            List <Tuple <ElementId, string, List <View> > > _createdSheetIdViewIdSets = new List <Tuple <ElementId, string, List <View> > >();

            foreach (var _boundedViewCreator in _boundedViewCreators)
            {
                SheetCreator _sheetCreator = new SheetCreator(_doc);


                //Create Sheet
                string    _pourName  = _boundedViewCreator.GetViewName(string.Empty, string.Empty);
                ViewSheet _viewSheet = _sheetCreator.CreateSheet(_titleblockName, _pourName, _pourName);

                ////Create 3D View
                //View3D _3DView = _boundedViewCreator.CreateView3D(_3dViewScale);
                //_3DView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_3DView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Floorplan View
                ViewPlan _floorPlanView = _boundedViewCreator.CreateViewPlan(_floorplanViewScale);
                _floorPlanView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                _floorPlanView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                ////Create Section View
                //ViewSection _sectionView = _boundedViewCreator.CreateViewSection(_sectionViewScale);
                //_sectionView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_sectionView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Schedules
                ViewSchedule          _columnSchedule = ScheduleCreator.CreatePourColumnSchedule(_doc, _pourName, " Reshores");
                ScheduleSheetInstance _columnScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _columnSchedule.Id, _columnScheduleBottomLeft);

                ViewSchedule          _levelSchedule = ScheduleCreator.CreatePourLoadSchedule(_doc, _boundedViewCreator.Level?.Name, " - " + _boundedViewCreator.ScopeBox?.Name + " Loads");
                ScheduleSheetInstance _levelScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _levelSchedule.Id, _levelScheduleBottomLeft);

                _createdSheetIdViewIdSets.Add(new Tuple <ElementId, string, List <View> >(
                                                  _viewSheet.Id,
                                                  _pourName,
                                                  new List <View> { /*_3DView,*/
                    _floorPlanView,                                 /*_sectionView*/
                }
                                                  ));
            }

            _doc.Regenerate();

            FamilySymbol _tagSymbol = new FilteredElementCollector(_doc)
                                      .OfCategory(BuiltInCategory.OST_MultiCategoryTags)
                                      .OfClass(typeof(FamilySymbol)).OfType <FamilySymbol>()
                                      .FirstOrDefault(p => p.FamilyName.Contains("Mark"));

            foreach (var _createdSheetIdViewIdSet in _createdSheetIdViewIdSets)
            {
                foreach (View _view in _createdSheetIdViewIdSet.Item3)
                {
                    if (_view == null)
                    {
                        continue;
                    }

                    //if (_view is View3D) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _3dViewportCenter);
                    else if (_view is ViewPlan)
                    {
                        DimensionCreator.CreateDimensions(_view);
                        TagCreator.CreateTags(_view, _tagSymbol);
                        Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _floorplanViewportCenter);
                    }
                    //else if (_view is ViewSection) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _sectionViewportCenter);
                }
            }

            return(Result.Succeeded);
        }
예제 #11
0
        protected override async Task <TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken)
        {
            var factory   = new AdaptiveCardDataFactory(turnContext, taskModuleRequest);
            var fetchType = factory.GetCardActionType();

            if (fetchType?.Equals("ResultStoreCard") == true)
            {
                //create group buy card
                var orderId = Guid.NewGuid().ToString();
                var data    = factory.GetGroupBuyCard(orderId);
                _orderService.CreateOrder(orderId, turnContext.Activity.ChannelId, data.StoreName);
                var cardService = new CreateCardService2();
                await turnContext.SendActivityAsync(MessageFactory.Attachment(cardService.GetStore(data)));

                //create scheduler
                var services = await SchedulerFactory.GetAllSchedulers();

                var scheduler = new ScheduleCreator(services[0], turnContext.Activity.From.Id, orderId);
                var dueTime   = DateTime.Parse(data.DueTime);
                scheduler.CreateSingleGroupBuy(dueTime);
                AddConversationReference(turnContext.Activity as Activity);

                return(null);
            }
            if (fetchType?.Equals("FetchSelectedFoods") == true)
            {
                var card = new CreateCardService2().GetChosenFoodFromMenu(factory);

                if (card.Name?.Contains("error") == true)
                {
                    var taskInfo = new TaskModuleTaskInfo();
                    taskInfo.Card = card;
                    return(await Task.FromResult(taskInfo.ToTaskModuleResponse()));
                }
                else
                {
                    await turnContext.SendActivityAsync(MessageFactory.Attachment(card));

                    new CreateCardService2().GetChosenFoodFromMenuCreateOrderDetail(factory, turnContext.Activity.From.Id);
                    return(null);
                }
            }
            else if (fetchType?.Equals("GetCustomizedStore") == true)
            {
                //get order data
                var data = factory.GetCardData <StoreOrderDuetime>();
                data.DueTime = JObject.FromObject(factory.Request.Data).GetValue("DueTime").ToString();
                data.OrderID = Guid.NewGuid().ToString();

                //create an order and group-buy card
                _orderService.CreateOrder(data.OrderID, turnContext.Activity.ChannelId, data.StoreName);
                await turnContext.SendActivityAsync(MessageFactory.Attachment(_menuOrderService.GetStore(factory, data.OrderID)));

                //create scheduler
                var services = await SchedulerFactory.GetAllSchedulers();

                var scheduler = new ScheduleCreator(services[0], turnContext.Activity.From.Id, data.OrderID);
                var dueTime   = DateTime.Parse(data.DueTime);
                scheduler.CreateSingleGroupBuy(dueTime);
                AddConversationReference(turnContext.Activity as Activity);
                return(null);
            }
            //ting 按下按鈕傳資料到data
            else if (fetchType?.Equals("GetCustomizedMenu") == true)
            {
                var teamsId = turnContext.Activity.GetChannelData <TeamsChannelData>()?.Tenant?.Id;
                var menu    = _menuService.CreateMenu(factory, teamsId);
                if (menu == null)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text("Please create your store first!"));
                }
                else
                {
                    _menuService.CreateMenuDetail(factory, menu.MenuId);
                    await turnContext.SendActivityAsync(MessageFactory.Text("Create Successfully!"));

                    var NewId          = factory.GetCardData <StoreInfoData>().Name;
                    var CustomMenucard = _customMenuService.CallCustomeCard(NewId);
                    var activity       = MessageFactory.Attachment(CustomMenucard);
                    activity.Id = NewId; //指定要更新的activity
                    await turnContext.UpdateActivityAsync(activity, cancellationToken);
                }
                return(null);
            }
            else if (fetchType?.Equals("GetCustomizedMenuDetail") == true)
            {
                var menu = factory.GetCardData <StoreInfoData>().Guid;
                _menuService.CreateMenuDetail(factory, Guid.Parse(menu));
                await turnContext.SendActivityAsync(MessageFactory.Text("Create Successfully!"));

                return(null);
            }
            else if (fetchType?.Equals("reserveStore") == true)
            {
                var orderId = Guid.NewGuid().ToString();
                var data    = factory.GetGroupBuyCard(orderId);
                turnContext.Activity.Value = JsonConvert.SerializeObject(data);
                turnContext.Activity.Type  = "message";
                await Dialog.RunAsync(turnContext, ConversationState.CreateProperty <DialogState>(nameof(DialogState)), cancellationToken);

                return(null);
            }
            //育銨
            else
            {
                var TaskInfo = new TaskModuleTaskInfo();
                TaskInfo.Card = new CreateCardService2().GetResultCustomizedModification(factory);
                new CreateCardService2().SetTaskInfo(TaskInfo, TaskModuleUIConstants.UpdateMenu);
                return(await Task.FromResult(TaskInfo.ToTaskModuleResponse()));
            }
        }