コード例 #1
0
        public Appointment Parse(IList <string> stringValue, DateTime start, DateTime end)
        {
            iCalendarEntryParser    parser         = new iCalendarEntryParser();
            iCalendarEntryContainer entryContainer = parser.ParseString(String.Join("\n", stringValue.ToArray()));

            this.rule = entryContainer.GetPropertyValue <VRecurrenceRule>(RecurrenceRuleProperty.TokenName);
            if (this.rule == null)
            {
                return(null);
            }

            Appointment pattern = Storage.CreateAppointment(AppointmentType.Pattern);

            pattern.Start = start;
            pattern.End   = end;
            iCalendarHelper.ApplyRecurrenceInfo(pattern.RecurrenceInfo, start, rule);
            ExceptionDateTimesProperty exceptionProperty = entryContainer.GetProperty(ExceptionDateTimesProperty.TokenName) as ExceptionDateTimesProperty;

            if (exceptionProperty != null)
            {
                exceptionProperty.ApplyTimeZone();
                OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
                foreach (var item in exceptionProperty.Values)
                {
                    int indx = calculator.FindOccurrenceIndex(item, pattern);
                    if (indx < 0)
                    {
                        continue;
                    }
                    pattern.CreateException(AppointmentType.DeletedOccurrence, indx);
                }
            }
            return(pattern);
        }
        private void btnTest_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            #region #OccurrenceCalculator
            // Calculate occurrences for the first recurrent series.
            Appointment pattern = schedulerStorage1.Appointments.Items.FirstOrDefault(item => item.Type == AppointmentType.Pattern);
            if (pattern == null)
            {
                return;
            }
            OccurrenceCalculator      calc = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
            TimeInterval              processedInterval     = new TimeInterval(DateTime.Today, DateTime.Today.AddDays(7));
            AppointmentBaseCollection calculatedOccurrences = calc.CalcOccurrences(processedInterval, pattern);

            // Create normal appointments in place of occurrences.
            schedulerStorage1.BeginUpdate();
            for (int i = 0; i < calculatedOccurrences.Count; i++)
            {
                Appointment resultAppointment = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
                resultAppointment.Subject     = String.Format("Occurrence {0} - {1}", calculatedOccurrences[i].Subject, i);
                resultAppointment.Description = calculatedOccurrences[i].Description;
                resultAppointment.Start       = calculatedOccurrences[i].Start;
                resultAppointment.End         = calculatedOccurrences[i].End;
                schedulerStorage1.Appointments.Add(resultAppointment);
            }
            schedulerStorage1.EndUpdate();

            // Remove the pattern and occurrences.
            schedulerStorage1.Appointments.Remove(pattern);
            #endregion #OccurrenceCalculator
        }
        AppointmentBaseCollection PrepareAppointmentsToSelect(XPAppointment[] rows)
        {
            AppointmentBaseCollection appoitnments = new AppointmentBaseCollection();

            for (int i = 0; i < rows.Length; i++)
            {
                Appointment apt = FindAppointmentByRow(rows[i]);
                if (apt != null)
                {
                    switch (apt.Type)
                    {
                    case AppointmentType.Pattern:
                        TimeIntervalCollection    tiCollection  = schedulerControl1.ActiveView.GetVisibleIntervals();
                        OccurrenceCalculator      calc          = OccurrenceCalculator.CreateInstance(apt.RecurrenceInfo);
                        AppointmentBaseCollection aptCollection = calc.CalcOccurrences(tiCollection.Interval, apt);
                        appoitnments.AddRange(aptCollection);
                        break;

                    case AppointmentType.DeletedOccurrence:
                        break;

                    default:
                        appoitnments.Add(apt);
                        break;
                    }
                }
            }
            return(appoitnments);
        }
 private void btnCalculateSeriesInterval_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     #region #OccurrenceCalculatorCalcSequenceInterval
     // Calculate a time interval occupied by the first recurrent series.
     Appointment pattern = schedulerStorage1.Appointments.Items.FirstOrDefault(item => item.Type == AppointmentType.Pattern);
     if (pattern == null)
     {
         return;
     }
     OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
     TimeInterval         ti   = calc.CalcSequenceInterval(pattern);
     MessageBox.Show(ti.ToString(), "Time Interval of the First Recurrent Series");
     #endregion #OccurrenceCalculatorCalcSequenceInterval
 }
        void ExportAppointment(Appointment apt)
        {
            AppointmentType aptType = apt.Type;

            if (aptType == AppointmentType.Pattern)
            {
                EnsurePatternId(apt);
            }
            else if (aptType != AppointmentType.Normal)
            {
                string eventPatternId = EnsurePatternId(apt.RecurrencePattern);
                Debug.Assert(!String.IsNullOrEmpty(eventPatternId));
                if (aptType == AppointmentType.Occurrence)
                {
                    return;
                }
                EventsResource.InstancesRequest instancesRequest = CalendarService.Events.Instances(CalendarEntry.Id, eventPatternId);
                OccurrenceCalculator            calculator       = OccurrenceCalculator.CreateInstance(apt.RecurrencePattern.RecurrenceInfo);
                instancesRequest.OriginalStart = GoogleCalendarUtils.ConvertEventDateTime(calculator.CalcOccurrenceStartTime(apt.RecurrenceIndex)).DateTimeRaw;
                Events occurrenceEvents = instancesRequest.Execute();
                Debug.Assert(occurrenceEvents.Items.Count == 1);
                Event occurrence = occurrenceEvents.Items[0];
                if (aptType == AppointmentType.ChangedOccurrence)
                {
                    this.AssignProperties(apt, occurrence);
                }
                else if (aptType == AppointmentType.DeletedOccurrence)
                {
                    occurrence.Status = "cancelled";
                }
                Event changedOccurrence = CalendarService.Events.Update(occurrence, CalendarEntry.Id, occurrence.Id).Execute();
                apt.CustomFields["eventId"] = changedOccurrence.Id;
                Log.WriteLine(String.Format("Exported {0} occurrance: {1}, id={2}", (aptType == AppointmentType.ChangedOccurrence) ? "changed" : "deleted", apt.Subject, changedOccurrence.Id));
                return;
            }

            Event instance = this.CreateEvent(aptType);

            AssignProperties(apt, instance);

            Event result = CalendarService.Events.Insert(instance, CalendarEntry.Id).Execute();

            Log.WriteLine(String.Format("Exported appointment: {0}, id={1}", apt.Subject, result.Id));
        }
        string GetNextDateDisplayText(Appointment appointment)
        {
            const string ScheduledJobExpired       = "Never (expired)";
            const string ScheduledJobExpiredFormat = "Never (expired on {0:d})";
            var          calculator = OccurrenceCalculator.CreateInstance(appointment.RecurrenceInfo);
            var          nextDate   = calculator.FindNextOccurrenceTimeAfter(DateTime.Now, appointment);

            if (nextDate != DateTime.MaxValue)
            {
                return(nextDate.ToString("g"));
            }
            else
            {
                var lastDate = GetLastDate(appointment, calculator);
                return(lastDate != null
                    ? string.Format(ScheduledJobExpiredFormat, lastDate)
                    : ScheduledJobExpired);
            }
        }
        int CalculateOccurrenceIndex(Appointment pattern, EventDateTime originalStartTime)
        {
            OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);

            return(calculator.FindOccurrenceIndex(ConvertDateTime(originalStartTime), pattern));
        }
コード例 #8
0
ファイル: NewScheduler.aspx.cs プロジェクト: jehan2898/root
    protected void ASPxScheduler1_AppointmentsChanged(object sender, PersistentObjectsEventArgs e)
    {
        //Delete Schedule

        DevExpress.XtraScheduler.Internal.Implementations.AppointmentInstance AppointmentInstance = (DevExpress.XtraScheduler.Internal.Implementations.AppointmentInstance)e.Objects[0];
        DeleteSchedule objSchedule = new DeleteSchedule();

        objSchedule.Index = 0;
        if (AppointmentInstance.Type == AppointmentType.Normal)
        {
            objSchedule.AppointmentID = Convert.ToInt32(AppointmentInstance.Id);
        }
        else if (AppointmentInstance.Type == AppointmentType.Pattern)
        {
            objSchedule.AppointmentID = Convert.ToInt32(AppointmentInstance.RecurrencePattern.Id);
        }
        switch (AppointmentInstance.Type)
        {
        case AppointmentType.ChangedOccurrence:
            break;

        case AppointmentType.DeletedOccurrence:
        case AppointmentType.Pattern:
            objSchedule.Index = -1;
            billSysDeleteBO.DeleteEventSchedular(objSchedule);
            break;

        case AppointmentType.Normal:
            // billSysDeleteBO.DeleteEventSchedular(objSchedule);
            break;

        case AppointmentType.Occurrence:

            break;

        default:
            break;
        }



        if (AppointmentInstance.Type == AppointmentType.Pattern)
        {
            OccurrenceCalculator      oc    = OccurrenceCalculator.CreateInstance(AppointmentInstance.RecurrenceInfo);
            TimeInterval              ttc   = new TimeInterval(AppointmentInstance.RecurrenceInfo.Start, AppointmentInstance.RecurrenceInfo.End.Add(AppointmentInstance.Duration));
            AppointmentBaseCollection appts = oc.CalcOccurrences(ttc, AppointmentInstance);

            foreach (Appointment item in appts)
            {
                int index = item.RecurrenceIndex;
                #region Data insert to TXN_CALENDAR
                try
                {
                    ArrayList         objAdd;
                    Bill_Sys_Calender _bill_Sys_Calender = new Bill_Sys_Calender();
                    objAdd = new ArrayList();
                    objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(AppointmentInstance.CustomFields[0].ToString()));
                    objAdd.Add(item.Start);
                    objAdd.Add(item.Start.Hour + "." + item.Start.Minute);
                    objAdd.Add(AppointmentInstance.Description);
                    objAdd.Add(AppointmentInstance.CustomFields[2]);
                    objAdd.Add("TY000000000000000003");
                    objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    objAdd.Add(AppointmentInstance.Start.ToString("tt", CultureInfo.InvariantCulture));
                    int    endMin  = Convert.ToInt32(item.End.Minute);
                    int    endHr   = Convert.ToInt32(item.End.Hour);
                    string endTime = item.End.Hour + "." + item.End.Minute;
                    if (endMin >= 60)
                    {
                        endMin = endMin - 60;
                        endHr  = endHr + 1;
                        if (endHr > 12)
                        {
                            endHr = endHr - 12;
                            if (AppointmentInstance.End.Hour != 12)
                            {
                                if (endTime == "AM")
                                {
                                    endTime = "PM";
                                }
                                else if (endTime == "PM")
                                {
                                    endTime = "AM";
                                }
                            }
                        }
                        else if (endHr == 12)
                        {
                            if (AppointmentInstance.End.Hour != 12)
                            {
                                if (endTime == "AM")
                                {
                                    endTime = "PM";
                                }
                                else if (endTime == "PM")
                                {
                                    endTime = "AM";
                                }
                            }
                        }
                    }
                    objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                    objAdd.Add(item.End.ToString("tt", CultureInfo.InvariantCulture));
                    objAdd.Add(AppointmentInstance.StatusKey);
                    objAdd.Add(item.CustomFields["VISIT_TYPE_ID"]);
                    objAdd.Add(AppointmentInstance.Id);
                    objAdd.Add(index);
                    _bill_Sys_Calender.SaveEventFromSchedular(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                    index++;
                }
                catch (Exception ex)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                }
                #endregion
            }
            return;
        }
        else if (AppointmentInstance.Type == AppointmentType.Normal)
        {
            string[]          clientData         = AppointmentInstance.Location.Split(new char[] { '-' });
            Bill_Sys_Calender _bill_Sys_Calender = new Bill_Sys_Calender();
            int index = 0;
            if (clientData[2].Trim() != "null")
            {
                if (_bill_Sys_Calender.CHECKVISIT_FOR_APPOINTMENT(Convert.ToInt32(AppointmentInstance.Id), index, ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID))
                {
                    #region Data Update to TXN_CALENDAR
                    try
                    {
                        ArrayList objAdd;

                        objAdd = new ArrayList();
                        objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(clientData[2]));
                        objAdd.Add(AppointmentInstance.Start);
                        objAdd.Add(AppointmentInstance.Start.Hour + "." + AppointmentInstance.Start.Minute);
                        objAdd.Add(AppointmentInstance.Description);
                        objAdd.Add(clientData[1]);
                        objAdd.Add("TY000000000000000003");
                        objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                        objAdd.Add(AppointmentInstance.Start.ToString("tt", CultureInfo.InvariantCulture));
                        int    endMin  = Convert.ToInt32(AppointmentInstance.End.Minute);
                        int    endHr   = Convert.ToInt32(AppointmentInstance.End.Hour);
                        string endTime = AppointmentInstance.End.Hour + "." + AppointmentInstance.End.Minute;
                        if (endMin >= 60)
                        {
                            endMin = endMin - 60;
                            endHr  = endHr + 1;
                            if (endHr > 12)
                            {
                                endHr = endHr - 12;
                                if (AppointmentInstance.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                            else if (endHr == 12)
                            {
                                if (AppointmentInstance.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                        }
                        objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                        objAdd.Add(AppointmentInstance.End.ToString("tt", CultureInfo.InvariantCulture));
                        objAdd.Add(AppointmentInstance.StatusKey);
                        objAdd.Add(clientData[0]);
                        objAdd.Add(AppointmentInstance.Id);
                        objAdd.Add(index);
                        objAdd.Add(AppointmentInstance.Id);
                        _bill_Sys_Calender.UPDATEEventByAppointmentId(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                        index++;
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                    }
                    #endregion
                }
                else
                {
                    #region Data insert to TXN_CALENDAR
                    try
                    {
                        ArrayList objAdd;

                        objAdd = new ArrayList();
                        objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(clientData[2]));
                        objAdd.Add(AppointmentInstance.Start);
                        objAdd.Add(AppointmentInstance.Start.Hour + "." + AppointmentInstance.Start.Minute);
                        objAdd.Add(AppointmentInstance.Description);
                        objAdd.Add(clientData[1]);
                        objAdd.Add("TY000000000000000003");
                        objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                        objAdd.Add(AppointmentInstance.Start.ToString("tt", CultureInfo.InvariantCulture));
                        int    endMin  = Convert.ToInt32(AppointmentInstance.End.Minute);
                        int    endHr   = Convert.ToInt32(AppointmentInstance.End.Hour);
                        string endTime = AppointmentInstance.End.Hour + "." + AppointmentInstance.End.Minute;
                        if (endMin >= 60)
                        {
                            endMin = endMin - 60;
                            endHr  = endHr + 1;
                            if (endHr > 12)
                            {
                                endHr = endHr - 12;
                                if (AppointmentInstance.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                            else if (endHr == 12)
                            {
                                if (AppointmentInstance.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                        }
                        objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                        objAdd.Add(AppointmentInstance.End.ToString("tt", CultureInfo.InvariantCulture));
                        objAdd.Add(0);
                        objAdd.Add(clientData[0]);
                        objAdd.Add(AppointmentInstance.Id);
                        objAdd.Add(index);
                        _bill_Sys_Calender.SaveEventFromSchedular(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                    }
                    #endregion
                }
            }
        }
        else if (AppointmentInstance.Type == AppointmentType.DeletedOccurrence)
        {
            //Deleted code in TXN_CALENDER_EVENTS
            //DeleteSchedule objSchedule = new DeleteSchedule();
            //objSchedule.Index = apt.RecurrenceIndex;
            //objSchedule.AppointmentID = Convert.ToInt32(apt.RecurrencePattern.Id);
            //billSysDeleteBO.DeleteEventSchedular(objSchedule);
            //return;
        }
        else if (AppointmentInstance.Type == AppointmentType.ChangedOccurrence)
        {
            string[] clientData = AppointmentInstance.Location.Split(new char[] { '-' });

            int index = AppointmentInstance.RecurrenceIndex;
            #region Data Update to TXN_CALENDAR
            try
            {
                ArrayList         objAdd;
                Bill_Sys_Calender _bill_Sys_Calender = new Bill_Sys_Calender();
                objAdd = new ArrayList();
                objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(clientData[2]));
                objAdd.Add(AppointmentInstance.Start);
                objAdd.Add(AppointmentInstance.Start.Hour + "." + AppointmentInstance.Start.Minute);
                objAdd.Add(AppointmentInstance.Description);
                objAdd.Add(clientData[1]);
                objAdd.Add("TY000000000000000003");
                objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                objAdd.Add(AppointmentInstance.Start.ToString("tt", CultureInfo.InvariantCulture));
                int    endMin  = Convert.ToInt32(AppointmentInstance.End.Minute);
                int    endHr   = Convert.ToInt32(AppointmentInstance.End.Hour);
                string endTime = AppointmentInstance.End.Hour + "." + AppointmentInstance.End.Minute;
                if (endMin >= 60)
                {
                    endMin = endMin - 60;
                    endHr  = endHr + 1;
                    if (endHr > 12)
                    {
                        endHr = endHr - 12;
                        if (AppointmentInstance.End.Hour != 12)
                        {
                            if (endTime == "AM")
                            {
                                endTime = "PM";
                            }
                            else if (endTime == "PM")
                            {
                                endTime = "AM";
                            }
                        }
                    }
                    else if (endHr == 12)
                    {
                        if (AppointmentInstance.End.Hour != 12)
                        {
                            if (endTime == "AM")
                            {
                                endTime = "PM";
                            }
                            else if (endTime == "PM")
                            {
                                endTime = "AM";
                            }
                        }
                    }
                }
                objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                objAdd.Add(AppointmentInstance.End.ToString("tt", CultureInfo.InvariantCulture));
                objAdd.Add(AppointmentInstance.StatusKey);
                objAdd.Add(clientData[0]);
                objAdd.Add(AppointmentInstance.RecurrencePattern.Id);
                objAdd.Add(index);
                objAdd.Add(AppointmentInstance.Id);
                _bill_Sys_Calender.UPDATEEventByAppointmentId(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                index++;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
            #endregion
        }
    }
コード例 #9
0
ファイル: NewScheduler.aspx.cs プロジェクト: jehan2898/root
    protected void ASPxScheduler1_AppointmentsInserted(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
    {
        //Task.Factory.StartNew(() =>
        //{
        Appointment apt = (Appointment)e.Objects[0];

        string[] clientData = apt.Location.Split(new char[] { '-' });
        if (clientData[2].Trim() != "null")
        {
            if (apt.Type == AppointmentType.Pattern)
            {
                OccurrenceCalculator      oc    = OccurrenceCalculator.CreateInstance(apt.RecurrenceInfo);
                TimeInterval              ttc   = new TimeInterval(apt.RecurrenceInfo.Start, apt.RecurrenceInfo.End.Add(apt.Duration));
                AppointmentBaseCollection appts = oc.CalcOccurrences(ttc, apt);

                foreach (Appointment item in appts)
                {
                    int index = item.RecurrenceIndex;
                    #region Data insert to TXN_CALENDAR
                    try
                    {
                        ArrayList         objAdd;
                        Bill_Sys_Calender _bill_Sys_Calender = new Bill_Sys_Calender();
                        objAdd = new ArrayList();
                        objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(clientData[2]));
                        objAdd.Add(item.Start);
                        objAdd.Add(item.Start.Hour + "." + item.Start.Minute);
                        objAdd.Add(apt.Description);
                        objAdd.Add(clientData[1]);
                        objAdd.Add("TY000000000000000003");
                        objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                        objAdd.Add(apt.Start.ToString("tt", CultureInfo.InvariantCulture));
                        int    endMin  = Convert.ToInt32(item.End.Minute);
                        int    endHr   = Convert.ToInt32(item.End.Hour);
                        string endTime = item.End.Hour + "." + item.End.Minute;
                        if (endMin >= 60)
                        {
                            endMin = endMin - 60;
                            endHr  = endHr + 1;
                            if (endHr > 12)
                            {
                                endHr = endHr - 12;
                                if (apt.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                            else if (endHr == 12)
                            {
                                if (apt.End.Hour != 12)
                                {
                                    if (endTime == "AM")
                                    {
                                        endTime = "PM";
                                    }
                                    else if (endTime == "PM")
                                    {
                                        endTime = "AM";
                                    }
                                }
                            }
                        }
                        objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                        objAdd.Add(item.End.ToString("tt", CultureInfo.InvariantCulture));
                        objAdd.Add(apt.StatusId);
                        objAdd.Add(clientData[0]);
                        objAdd.Add(apt.Id);
                        objAdd.Add(index);
                        _bill_Sys_Calender.SaveEventFromSchedular(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                        index++;
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                    }
                    #endregion
                }
                return;
            }
            else if (apt.Type == AppointmentType.Normal)
            {
                #region Data insert to TXN_CALENDAR
                try
                {
                    ArrayList         objAdd;
                    Bill_Sys_Calender _bill_Sys_Calender = new Bill_Sys_Calender();
                    objAdd = new ArrayList();
                    objAdd.Add(_bill_Sys_Calender.GetCaseIDByPatient(clientData[2]));
                    objAdd.Add(apt.Start);
                    objAdd.Add(apt.Start.Hour + "." + apt.Start.Minute);
                    objAdd.Add(apt.Description);
                    objAdd.Add(clientData[1]);
                    objAdd.Add("TY000000000000000003");
                    objAdd.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    objAdd.Add(apt.Start.ToString("tt", CultureInfo.InvariantCulture));
                    int    endMin  = Convert.ToInt32(apt.End.Minute);
                    int    endHr   = Convert.ToInt32(apt.End.Hour);
                    string endTime = apt.End.Hour + "." + apt.End.Minute;
                    if (endMin >= 60)
                    {
                        endMin = endMin - 60;
                        endHr  = endHr + 1;
                        if (endHr > 12)
                        {
                            endHr = endHr - 12;
                            if (apt.End.Hour != 12)
                            {
                                if (endTime == "AM")
                                {
                                    endTime = "PM";
                                }
                                else if (endTime == "PM")
                                {
                                    endTime = "AM";
                                }
                            }
                        }
                        else if (endHr == 12)
                        {
                            if (apt.End.Hour != 12)
                            {
                                if (endTime == "AM")
                                {
                                    endTime = "PM";
                                }
                                else if (endTime == "PM")
                                {
                                    endTime = "AM";
                                }
                            }
                        }
                    }
                    objAdd.Add(endHr.ToString().PadLeft(2, '0').ToString() + "." + endMin.ToString().PadLeft(2, '0').ToString());
                    objAdd.Add(apt.End.ToString("tt", CultureInfo.InvariantCulture));
                    objAdd.Add(0);
                    objAdd.Add(clientData[0]);
                    objAdd.Add(apt.Id);
                    objAdd.Add(0);
                    _bill_Sys_Calender.SaveEventFromSchedular(objAdd, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString());
                }
                catch (Exception ex)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                }
                #endregion
                return;
            }
            else if (apt.Type == AppointmentType.DeletedOccurrence)
            {
                //Deleted code in TXN_CALENDER_EVENTS
                DeleteSchedule objSchedule = new DeleteSchedule();
                objSchedule.Index         = apt.RecurrenceIndex;
                objSchedule.AppointmentID = Convert.ToInt32(apt.RecurrencePattern.Id);
                billSysDeleteBO.DeleteEventSchedular(objSchedule);
                return;
            }
            else if (apt.Type == AppointmentType.ChangedOccurrence)
            {
                return;
            }
        }
    }
コード例 #10
0
        /*
         * protected void ASPxDataView3_DataBound(object sender, EventArgs e)
         * {
         *      if (ASPxDataView3.Items.Count > 0)
         *      {
         *              for (int i = 0; i < ASPxDataView3.Items.Count; i++)
         *              {
         *                      ASPxLabel lbl = new ASPxLabel();
         *                      lbl = (ASPxLabel)ASPxDataView3.FindItemControl("ASPxLabel3", ASPxDataView3.Items[i]);
         *                      lbl.Text = (ASPxDataView3.Items[i].DataItem as DataRowView)["Type"].ToString() + " List";
         *
         *                      ASPxDataView dataview = new ASPxDataView();
         *                      dataview = (ASPxDataView)ASPxDataView3.FindItemControl("ASPxDataView2", ASPxDataView3.Items[i]);
         *
         *                      DataTable dt2 = VSWebBL.DashboardBL.DashboardBL.Ins.GetStatusGrid((ASPxDataView3.Items[i].DataItem as DataRowView)["Type"].ToString());
         *                      dataview.DataSource = dt2;
         *                      dataview.DataBind();
         *
         *
         *                      //if (dataview.Items.Count > 0)
         *                      //{
         *                        //  for (int j = 0; j < dataview.Items.Count; j++)
         *                              //{
         *                                //  ASPxPanel panel = new ASPxPanel();
         *                                 // panel = (ASPxPanel)dataview.FindItemControl("ASPxPanel1",dataview.Items[j]);
         *                                      //panel.BackColor = GetColor(dataview.Items[j].DataItem);
         *
         *                                      //ASPxLabel lbl = new ASPxLabel();
         *                                      //lbl = (ASPxLabel)panel.FindControl("ASPxLabel1");
         *                                      //lbl = (ASPxLabel)ASPxDataView2.FindItemControl("ASPxLabel1", ASPxDataView2.VisibleItems[i]);
         *                                      //lbl.Text = (dataview.Items[j].DataItem as DataRowView)["Name"].ToString();
         *
         *                                      //ASPxImage img = new ASPxImage();
         *                                      //img = (ASPxImage)panel.FindControl("ASPxImage1");
         *                                      //img = (ASPxImage)ASPxDataView2.FindItemControl("ASPxImage1", ASPxDataView2.Items[i]);
         *                                      //img.ImageUrl = (dataview.Items[j].DataItem as DataRowView)["imgsource"].ToString();
         *
         *                                      //ASPxLabel lbl2 = new ASPxLabel();
         *                                      //lbl2 = (ASPxLabel)panel.FindControl("ASPxLabel2");
         *                                      //lbl2.Text = (dataview.Items[j].DataItem as DataRowView)["Status"].ToString();
         *                              //}
         *                      //}
         *              }
         *      }
         * }*/



        protected void BtnApply_Click(object sender, EventArgs e)
        {
            //    Mukund 10Jun2014
            //VSPLUS-673: Executive Summary should have the same right-click menu as other screens

            try
            {
                // DataRow row = (DataRow)Session["myRow"];
                //if (row != null)
                if (hfName.Value != null)
                {
                    List <string> serverIDValues     = new List <string>();
                    List <string> servertypeIDValues = new List <string>();
                    Random        random             = new Random((int)DateTime.Now.Ticks);
                    //RandomString(5, random);
                    //string Name = row["Name"].ToString() + "-Temp-" + DateTime.Now.ToLongDateString();
                    string        Name          = hfName.Value + "-Temp-" + DateTime.Now.ToString();    //.ToLongDateString();
                    string        StartDate     = DateTime.Now.ToShortDateString();
                    string        StartTime     = DateTime.Now.ToShortTimeString();
                    DateTime      sdt           = Convert.ToDateTime(StartDate);
                    string        Duration      = TbDuration.Text;
                    string        EndDate       = DateTime.Now.ToShortDateString();
                    DateTime      edt           = Convert.ToDateTime(EndDate);
                    string        MaintType     = "1";
                    string        MaintDaysList = "";
                    string        altime        = DateTime.Now.ToShortTimeString();
                    DateTime      al            = Convert.ToDateTime(altime);
                    ASPxScheduler sh            = new ASPxScheduler();
                    Appointment   apt           = sh.Storage.CreateAppointment(AppointmentType.Pattern);
                    Reminder      r             = apt.CreateNewReminder();

                    //int min = Convert.ToInt32(MaintDurationTextBox.Text);
                    int min = Convert.ToInt32(TbDuration.Text);
                    r.AlertTime = al.AddMinutes(min);
                    //3/24/2015 NS modified for DevExpress upgrade 14.2
                    //ReminderXmlPersistenceHelper reminderHelper = new ReminderXmlPersistenceHelper(r, DateSavingType.LocalTime);
                    ReminderXmlPersistenceHelper reminderHelper = new ReminderXmlPersistenceHelper(r);
                    string rem = reminderHelper.ToXml().ToString();

                    RecurrenceInfo reci = new RecurrenceInfo();
                    reci.BeginUpdate();
                    reci.AllDay      = false;
                    reci.Periodicity = 10;
                    reci.Range       = RecurrenceRange.EndByDate;
                    reci.Start       = sdt;
                    reci.End         = edt;
                    reci.Duration    = edt - sdt;
                    reci.Type        = RecurrenceType.Yearly;


                    OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(reci);
                    TimeInterval         ttc  = new TimeInterval(reci.Start, reci.End + new TimeSpan(1, 0, 0));


                    var bcoll = calc.CalcOccurrences(ttc, apt);
                    if (bcoll.Count != 0)
                    {
                        reci.OccurrenceCount = bcoll.Count;
                    }
                    else
                    {
                        reci.OccurrenceCount = 1;
                    }
                    reci.Range = RecurrenceRange.OccurrenceCount;
                    reci.EndUpdate();
                    string s = reci.ToXml();

                    string EndDateIndicator = "";
                    //DataTable dt = VSWebBL.SecurityBL.ServersBL.Ins.GetServerDetailsByName(row["Name"].ToString());
                    DataTable dt = VSWebBL.SecurityBL.ServersBL.Ins.GetServerDetailsByName(hfName.Value);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        //VSPLUS-833:Suspend temporarily is not working correctly
                        //19Jul14, Mukund, The below two were reversely assigned so suspend wasnt working.
                        servertypeIDValues.Add(dt.Rows[0][2].ToString());
                        serverIDValues.Add(dt.Rows[0][0].ToString());
                    }
                    bool update = false;
                    if (servertypeIDValues != null && servertypeIDValues.Count > 0)
                    {
                        update = VSWebBL.ConfiguratorBL.MaintenanceBL.Ins.UpdateMaintenanceWindows(null, Name, StartDate, StartTime, Duration,
                                                                                                   EndDate, MaintType, MaintDaysList, EndDateIndicator, serverIDValues, s, rem, 1, true, servertypeIDValues, "true", "1");
                    }
                    if (update == true)
                    {
                        //SuccessMsg.InnerHtml = "Monitoring for " + row["Name"].ToString() + " has been temporarily suspended for a duration of " + TbDuration.Text + " minutes.";
                        //10/3/2014 NS modified for VSPLUS-990
                        SuccessMsg.InnerHtml = "Monitoring for " + hfName.Value + " has been temporarily suspended for a duration of " + TbDuration.Text + " minutes." +
                                               "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>";

                        SuccessMsg.Style.Value = "display: block";

                        BindDataView();
                    }
                    else
                    {
                        //10/3/2014 NS modified for VSPLUS-990
                        ErrorMsg.InnerHtml = "The Settings were NOT updated." +
                                             "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>";
                        ErrorMsg.Style.Value = "display: block";
                    }
                    SuspendPopupControl.ShowOnPageLoad = false;
                }
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
        }
コード例 #11
0
        public IHttpActionResult GetMyMarketRoutes(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            var result = new MarketRouteSyncCollection();

            var warehouseId = terminal.WarehouseId;

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                warehouseId = mobileLocation.WarehouseId;
            }

            var allRoutes = _vanSalesService.GetMyMarketRoutes(terminal.TenantId, warehouseId, reqDate);

            var results = new List <MarketRouteSync>();

            foreach (var p in allRoutes)
            {
                DateTime       nextAppointment = DateTime.MinValue;
                DateTime       lastAppointment = DateTime.MinValue;
                RecurrenceInfo info            = new RecurrenceInfo();
                var            appt            = _vanSalesService.GetMarketRouteScheduleById(p.RouteScheduleId);

                Appointment newAppt = DevExpress.XtraScheduler.Compatibility.StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern);
                newAppt.RecurrenceInfo.FromXml(appt.RecurrenceInfo);
                newAppt.Start = appt.StartTime;
                newAppt.End   = appt.EndTime;

                if (appt.RecurrenceInfo != null)
                {
                    info.FromXml(appt.RecurrenceInfo);

                    OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(info);
                    nextAppointment = calc.FindNextOccurrenceTimeAfter(new DateTime(reqDate.Year, reqDate.Month, reqDate.Day, 0, 0, 0), newAppt);

                    if (!newAppt.SameDay && nextAppointment.Date != reqDate.Date)
                    {
                        var reqDate2 = reqDate.AddDays(-1);
                        nextAppointment = calc.FindNextOccurrenceTimeAfter(new DateTime(reqDate2.Year, reqDate2.Month, reqDate2.Day, 0, 0, 0), newAppt);
                    }
                }

                else
                {
                    nextAppointment = newAppt.Start;

                    if (!newAppt.SameDay && nextAppointment.Date != reqDate.Date)
                    {
                        nextAppointment = newAppt.Start.AddDays(1);
                    }
                }

                if (reqDate.Date == nextAppointment.Date && appt.WarehouseId == warehouseId || (!newAppt.SameDay && reqDate.Date == nextAppointment.Date.AddDays(1)))
                {
                    var sync   = new MarketRouteSync();
                    var mapped = Mapper.Map(p, sync);
                    results.Add(mapped);
                }
            }

            result.Count         = results.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, results.Count, terminal.TerminalId, TerminalLogTypeEnum.DayMarketRouteSync).TerminalLogId;
            result.MarketRoutes  = results;
            return(Ok(result));
        }