コード例 #1
0
 private void StartLogToHistory_MethodInvoking(object sender, EventArgs e)
 {
     try
     {
         TimeSlotsInitiationData _data = TimeSlotsInitiationData.Deserialize(workflowProperties.InitiationData);
         StartLogToHistory_HistoryDescription = String.Format("Starting applying the template. From: {0}, Weeks: {1}", _data.StartDate, _data.Duration);;
     }
     catch (Exception ex)
     {
         string _frmt = "Worflow aborted in StartLogToHistory because of the error: {0}";
         throw new ApplicationException(String.Format(_frmt, ex.Message));
     }
 }
コード例 #2
0
 private void AddTimeslotsActivity_ExecuteCode(object sender, EventArgs e)
 {
     try
     {
         using (EntitiesDataContext _EDC = new EntitiesDataContext(workflowProperties.SiteUrl))
         {
             TimeSlotTimeSlot.DeleteExpired(_EDC);
             TimeSlotsInitiationData _data = TimeSlotsInitiationData.Deserialize(workflowProperties.InitiationData);
             ScheduleTemplate        _tmpl = Element.GetAtIndex <ScheduleTemplate>(_EDC.ScheduleTemplate, workflowProperties.ItemId.ToString());
             if (_tmpl.ShippingPointLookupTitle == null)
             {
                 throw new ApplicationException("Template does not have Shipingpoint assigned");
             }
             var _src = from _tst in _tmpl.TimeSlotsTemplate
                        group _tst by _tst.TimeSlotsTemplateDay.Value;
             Dictionary <TimeSlotsTemplateDay, IGrouping <TimeSlotsTemplateDay, TimeSlotsTemplate> > _dys = _src.ToDictionary(x => x.Key);
             Dictionary <DayOfWeek, TimeSlotsTemplateDay> _tt = new Dictionary <DayOfWeek, TimeSlotsTemplateDay>()
             {
                 { DayOfWeek.Friday, TimeSlotsTemplateDay.Friday },
                 { DayOfWeek.Monday, TimeSlotsTemplateDay.Monday },
                 { DayOfWeek.Saturday, TimeSlotsTemplateDay.Saturday },
                 { DayOfWeek.Sunday, TimeSlotsTemplateDay.Sunday },
                 { DayOfWeek.Thursday, TimeSlotsTemplateDay.Thursday },
                 { DayOfWeek.Tuesday, TimeSlotsTemplateDay.Tuesday },
                 { DayOfWeek.Wednesday, TimeSlotsTemplateDay.Wednesday },
             };
             for (int _week = 0; _week < _data.Duration; _week++)
             {
                 for (int _dayIdx = 0; _dayIdx < 7; _dayIdx++)
                 {
                     TimeSlotsTemplateDay _dayOfWeek = _tt[_data.StartDate.DayOfWeek];
                     if (_dys.ContainsKey(_dayOfWeek))
                     {
                         foreach (var _item in _dys[_dayOfWeek])
                         {
                             DateTime         _strt = CreateDateTime(_data, _item.TimeSlotsTemplateStartHour.Value.Hour2Int(), _item.TimeSlotsTemplateStartMinute.Value.Minute2Int());
                             DateTime         _end  = CreateDateTime(_data, _item.TimeSlotsTemplateEndHour.Value.Hour2Int(), _item.TimeSlotsTemplateStartMinute.Value.Minute2Int());
                             TimeSlotTimeSlot _nts  = new TimeSlotTimeSlot()
                             {
                                 StartTime = _strt,
                                 EndTime   = _end,
                                 TimeSlot2ShippingPointLookup = _tmpl.ShippingPointLookupTitle,
                                 EntryTime = _strt,
                                 ExitTime  = _end,
                                 Occupied  = Occupied.Free,
                                 IsDouble  = false,
                                 TimeSpan  = (_end - _strt).TotalMinutes
                             };
                             _EDC.TimeSlot.InsertOnSubmit(_nts);
                             m_TimeSlotsCounter++;
                         }
                     } //!_tt.ContainsKey(_
                     _data.StartDate += TimeSpan.FromDays(1);
                 }
                 _EDC.SubmitChanges();
             }
         }
     }
     catch (Exception ex)
     {
         string _frmt = "Workflow aborted in AddTimeslotsActivity because of the error: {0}";
         throw new ApplicationException(String.Format(_frmt, ex.Message));
     }
 }