Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var scheduleType = ConfigurationManager.AppSettings["ScheduleType"].ToString();

            Console.WriteLine("Initializing");

            ISchedule scheduler;

            switch (scheduleType)
            {
            case ScheduleTypes.ATTENDANCE:
                scheduler = new AttendanceSchedule();
                break;

            case ScheduleTypes.HOLIDAY:
                scheduler = new HolidaySchedule();
                break;

            case ScheduleTypes.EMPLOYEE_HOURS:
                scheduler = new EmployeeHoursSchedule();
                break;

            case ScheduleTypes.PAYROLL:
                scheduler = new EmployeePayrollSchedule();
                break;

            default:
                scheduler = null;
                break;
            }

            scheduler.Execute();
        }
Ejemplo n.º 2
0
        protected override Boolean isInputFieldsValid()
        {
            Util.sanitize(itxt_Description, itxt_Notes);
            if (itxt_Clients.ValueGuid == null)
            {
                return(itxt_Clients.isValueError("Please choose a Clients"));
            }
            else if (idtp_StartDate.Value == null)
            {
                return(idtp_StartDate.ValueError("Please choose a date"));
            }
            else if (itxt_DurationDays.ValueInt == 0)
            {
                return(itxt_DurationDays.isValueError("Please fill duration of holiday"));
            }
            else if (string.IsNullOrEmpty(itxt_Description.ValueText))
            {
                return(itxt_Description.isValueError("Please fill description of holiday"));
            }
            else if ((Mode != FormModes.Update && HolidaySchedule.isCombinationExist(null, (Guid)itxt_Clients.ValueGuid, (DateTime)idtp_StartDate.Value, itxt_Description.ValueText)) ||
                     (Mode == FormModes.Update && HolidaySchedule.isCombinationExist(selectedRowID(), (Guid)itxt_Clients.ValueGuid, (DateTime)idtp_StartDate.Value, itxt_Description.ValueText)))
            {
                return(itxt_DurationDays.isValueError("HolidaySchedule combination exists. Please change the date/description"));
            }

            return(true);
        }
Ejemplo n.º 3
0
 public UMAAHolidaySchedule(HolidaySchedule holiday)
 {
     this.Name             = holiday.Name;
     this.GreetingFileName = holiday.Greeting;
     this.StartDate        = holiday.StartDate.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture);
     this.EndDate          = holiday.EndDate.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture);
     this.StartDateDisplay = holiday.StartDate.ToString(EcpDateTimeHelper.GetUserDateFormat(), CultureInfo.CurrentCulture);
     this.EndDateDisplay   = holiday.EndDate.ToString(EcpDateTimeHelper.GetUserDateFormat(), CultureInfo.CurrentCulture);
 }
Ejemplo n.º 4
0
        protected override void populateInputFields()
        {
            HolidaySchedule obj = new HolidaySchedule(selectedRowID());

            itxt_Clients.setValue(obj.Clients_CompanyName, obj.Clients_Id);
            idtp_StartDate.Value       = obj.StartDate;
            itxt_DurationDays.Value    = obj.DurationDays;
            itxt_Description.ValueText = obj.Description;
            itxt_Notes.ValueText       = obj.Notes;
        }
Ejemplo n.º 5
0
 protected override void add()
 {
     HolidaySchedule.add(UserAccount.LoggedInAccount.Id,
                         (Guid)itxt_Clients.ValueGuid,
                         (DateTime)idtp_StartDate.Value,
                         itxt_DurationDays.ValueInt,
                         itxt_Description.ValueText,
                         itxt_Notes.ValueText
                         );
 }
Ejemplo n.º 6
0
 protected override void update()
 {
     HolidaySchedule.update(UserAccount.LoggedInAccount.Id,
                            selectedRowID(),
                            (DateTime)idtp_StartDate.Value,
                            itxt_DurationDays.ValueInt,
                            itxt_Description.ValueText,
                            itxt_Notes.ValueText
                            );
 }
Ejemplo n.º 7
0
 protected override System.Data.DataView loadGridviewDataSource()
 {
     return(HolidaySchedule.get(chkIncludeInactive.Checked,
                                null,
                                getFilterValue <Guid?>(itxt_Clients),
                                getFilterValue <DateTime?>(idtp_StartDate),
                                getFilterValue <int?>(itxt_DurationDays),
                                getFilterValue <string>(itxt_Description),
                                getFilterValue <string>(itxt_Notes)
                                ).DefaultView);
 }
Ejemplo n.º 8
0
        protected static object GetSingleProperty(object prop, Type type)
        {
            if (prop == null)
            {
                return(null);
            }
            object obj = null;

            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]);
            }
            else if (type == typeof(ADObjectId) && prop is PSObject)
            {
                obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString()));
            }
            else if (type == typeof(EnhancedTimeSpan))
            {
                obj = EnhancedTimeSpan.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <EnhancedTimeSpan>))
            {
                obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString());
            }
            else if (type == typeof(ByteQuantifiedSize))
            {
                obj = ByteQuantifiedSize.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <ByteQuantifiedSize>))
            {
                obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <int>))
            {
                obj = Unlimited <int> .Parse(prop.ToString());
            }
            else if (type == typeof(ProxyAddress))
            {
                obj = ProxyAddress.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpAddress))
            {
                obj = new SmtpAddress(prop.ToString());
            }
            else if (type == typeof(SmtpDomain))
            {
                obj = SmtpDomain.Parse(prop.ToString());
            }
            else if (type == typeof(CountryInfo))
            {
                obj = CountryInfo.Parse(prop.ToString());
            }
            else if (type == typeof(SharingPolicyDomain))
            {
                obj = SharingPolicyDomain.Parse(prop.ToString());
            }
            else if (type == typeof(ApprovedApplication))
            {
                obj = ApprovedApplication.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpDomainWithSubdomains))
            {
                obj = SmtpDomainWithSubdomains.Parse(prop.ToString());
            }
            else if (type == typeof(UMLanguage))
            {
                obj = UMLanguage.Parse(prop.ToString());
            }
            else if (type == typeof(UMSmartHost))
            {
                obj = UMSmartHost.Parse(prop.ToString());
            }
            else if (type == typeof(ScheduleInterval))
            {
                obj = ScheduleInterval.Parse(prop.ToString());
            }
            else if (type == typeof(NumberFormat))
            {
                obj = NumberFormat.Parse(prop.ToString());
            }
            else if (type == typeof(DialGroupEntry))
            {
                obj = DialGroupEntry.Parse(prop.ToString());
            }
            else if (type == typeof(CustomMenuKeyMapping))
            {
                obj = CustomMenuKeyMapping.Parse(prop.ToString());
            }
            else if (type == typeof(HolidaySchedule))
            {
                obj = HolidaySchedule.Parse(prop.ToString());
            }
            else if (type == typeof(UMTimeZone))
            {
                obj = UMTimeZone.Parse(prop.ToString());
            }
            else if (type == typeof(ServerVersion))
            {
                obj = ServerVersion.ParseFromSerialNumber(prop.ToString());
            }
            else if (type == typeof(X509Certificate2))
            {
                obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]);
            }
            else if (type == typeof(LocalizedString))
            {
                obj = new LocalizedString(prop.ToString());
            }
            else if (type == typeof(ExchangeObjectVersion))
            {
                obj = ExchangeObjectVersion.Parse(prop.ToString());
            }
            else if (type == typeof(bool))
            {
                obj = bool.Parse(prop.ToString());
            }
            else if (type == typeof(SecurityPrincipalIdParameter))
            {
                obj = new SecurityPrincipalIdParameter(prop.ToString());
            }
            else if (type == typeof(ActiveDirectoryAccessRule))
            {
                obj = (prop as ActiveDirectoryAccessRule);
            }
            else if (type == typeof(ObjectId))
            {
                string text = prop.ToString();
                if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/"))
                {
                    text = MockObjectCreator.ConvertDNFromTreeStructure(text);
                }
                obj = new ADObjectId(text);
            }
            else if (type.IsEnum)
            {
                try
                {
                    obj = Enum.Parse(type, prop.ToString());
                }
                catch (ArgumentException)
                {
                    obj = Enum.GetValues(type).GetValue(0);
                }
            }
            return(obj ?? prop);
        }
Ejemplo n.º 9
0
 protected override void updateActiveStatus(Guid id, Boolean activeStatus)
 {
     HolidaySchedule.updateActiveStatus(UserAccount.LoggedInAccount.Id, id, activeStatus);
 }
Ejemplo n.º 10
0
        protected override void ValidateWrite(List <ValidationError> errors)
        {
            base.ValidateWrite(errors);
            if (base.IsModified(ADObjectSchema.Name) && base.ObjectState != ObjectState.New)
            {
                errors.Add(new ObjectValidationError(DirectoryStrings.AACantChangeName, base.Id, string.Empty));
            }
            LocalizedString localizedString = this.ValidateSettings(this.BusinessHourSettings, AASettingsEnum.BusinessHourSettings, this.OperatorExtension);

            if (localizedString != LocalizedString.Empty)
            {
                errors.Add(new PropertyValidationError(localizedString, UMAutoAttendantSchema.BusinessHoursKeyMapping, this));
            }
            localizedString = this.ValidateSettings(this.AfterHourSettings, AASettingsEnum.AfterHourSettings, this.OperatorExtension);
            if (localizedString != LocalizedString.Empty)
            {
                errors.Add(new PropertyValidationError(localizedString, UMAutoAttendantSchema.AfterHoursKeyMapping, this));
            }
            if (this.InfoAnnouncementEnabled != InfoAnnouncementEnabledEnum.False && string.IsNullOrEmpty(this.InfoAnnouncementFilename))
            {
                localizedString = DirectoryStrings.InvalidAutoAttendantSetting("InfoAnnouncementEnabled", "InfoAnnouncementFilename");
                errors.Add(new ObjectValidationError(localizedString, base.Id, string.Empty));
            }
            if (!string.IsNullOrEmpty(this.InfoAnnouncementFilename) && !this.VerifyValidCustomGreetingFile(this.InfoAnnouncementFilename))
            {
                errors.Add(new ObjectValidationError(DirectoryStrings.InvalidCustomGreetingFilename("InfoAnnouncementFilename"), base.Id, string.Empty));
            }
            if (this.HolidaySchedule.Count > 0)
            {
                HolidaySchedule[] array = this.HolidaySchedule.ToArray();
                for (int i = 0; i < array.Length; i++)
                {
                    HolidaySchedule holidaySchedule = array[i];
                    if (!string.IsNullOrEmpty(holidaySchedule.Greeting) && !this.VerifyValidCustomGreetingFile(holidaySchedule.Greeting))
                    {
                        errors.Add(new ObjectValidationError(DirectoryStrings.InvalidCustomGreetingFilename("HolidaySchedule"), base.Id, string.Empty));
                    }
                    for (int j = i + 1; j < array.Length; j++)
                    {
                        if (i != j)
                        {
                            HolidaySchedule holidaySchedule2 = array[j];
                            if (string.Compare(holidaySchedule.Name, holidaySchedule2.Name, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                errors.Add(new ObjectValidationError(DirectoryStrings.DuplicateHolidaysError(holidaySchedule.Name), base.Id, string.Empty));
                                break;
                            }
                        }
                    }
                }
            }
            if ((this.CallSomeoneEnabled || this.SendVoiceMsgEnabled) && this.ContactScope == DialScopeEnum.AddressList && this.ContactAddressList == null)
            {
                errors.Add(new ObjectValidationError(DirectoryStrings.InvalidCallSomeoneScopeSettings("AddressList", "ContactAddressList"), base.Id, string.Empty));
            }
            if (base.IsModified(UMAutoAttendantSchema.DefaultMailboxLegacyDN))
            {
                ADUser aduser = this.DefaultMailbox;
                if (aduser != null && (!aduser.UMEnabled || aduser.UMRecipientDialPlanId == null || !aduser.UMRecipientDialPlanId.Equals(this.UMDialPlan) || string.IsNullOrEmpty(this.DefaultMailboxLegacyDN)))
                {
                    errors.Add(new ObjectValidationError(DirectoryStrings.InvalidDefaultMailbox, base.Id, string.Empty));
                }
            }
        }
Ejemplo n.º 11
0
        internal AutoAttendantSettings GetCurrentSettings(out HolidaySchedule holidaySettings, ref bool isBusinessHour)
        {
            ExTimeZone exTimeZone = null;
            string     timeZone   = this.TimeZone;

            if (string.IsNullOrEmpty(timeZone))
            {
                ExTraceGlobals.UMAutoAttendantTracer.TraceDebug <string>((long)this.GetHashCode(), "AA [Name = \"{0}\"] TZ Id = empty string, defaulting to using Current machine timezone", base.Name);
                exTimeZone = ExTimeZone.CurrentTimeZone;
            }
            else if (!ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName(this.TimeZone, out exTimeZone))
            {
                throw new InvalidOperationException(DirectoryStrings.InvalidTimeZoneId(this.TimeZone));
            }
            ExDateTime utcNow     = ExDateTime.UtcNow;
            ExDateTime exDateTime = exTimeZone.ConvertDateTime(utcNow);

            ExTraceGlobals.UMAutoAttendantTracer.TraceDebug((long)this.GetHashCode(), "AA [Name = \"{0}\"] UTC = {1} LOCAL = {2} TZ Id = {3}", new object[]
            {
                base.Name,
                utcNow.ToString("R"),
                exDateTime.ToString("R"),
                this.TimeZone
            });
            AutoAttendantSettings autoAttendantSettings            = null;
            HolidaySchedule       holidaySchedule                  = null;
            MultiValuedProperty <HolidaySchedule> holidaySchedule2 = this.HolidaySchedule;

            if (holidaySchedule2 != null && holidaySchedule2.Count > 0)
            {
                using (MultiValuedProperty <HolidaySchedule> .Enumerator enumerator = holidaySchedule2.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        HolidaySchedule holidaySchedule3 = enumerator.Current;
                        if ((ExDateTime)holidaySchedule3.StartDate.Date <= exDateTime.Date && (ExDateTime)holidaySchedule3.EndDate.Date >= exDateTime.Date)
                        {
                            ExTraceGlobals.UMAutoAttendantTracer.TraceDebug((long)this.GetHashCode(), "AA: {0} Call Time: {1} Matched with holiday: {2} {3}-{4}", new object[]
                            {
                                base.Name,
                                exDateTime.ToString("R"),
                                holidaySchedule3.Name,
                                holidaySchedule3.StartDate.ToString("R"),
                                holidaySchedule3.EndDate.ToString("R")
                            });
                            autoAttendantSettings = this.AfterHourSettings;
                            isBusinessHour        = false;
                            if (holidaySchedule == null)
                            {
                                holidaySchedule = holidaySchedule3;
                            }
                            else if (holidaySchedule3.StartDate.Date > holidaySchedule.StartDate.Date)
                            {
                                holidaySchedule = holidaySchedule3;
                            }
                            else if (holidaySchedule3.StartDate.Date == holidaySchedule.StartDate.Date)
                            {
                                int num = string.Compare(holidaySchedule.Name, holidaySchedule3.Name, StringComparison.OrdinalIgnoreCase);
                                holidaySchedule = ((num > 0) ? holidaySchedule3 : holidaySchedule);
                            }
                        }
                    }
                    goto IL_290;
                }
            }
            ExTraceGlobals.UMAutoAttendantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "AA: {0} Call Time: {1} No holiday schedule found", base.Name, exDateTime.ToString("R"));
IL_290:
            holidaySettings = holidaySchedule;
            if (autoAttendantSettings != null)
            {
                return(autoAttendantSettings);
            }
            autoAttendantSettings = this.AfterHourSettings;
            isBusinessHour        = false;
            foreach (ScheduleInterval scheduleInterval in this.BusinessHoursSchedule)
            {
                ExTraceGlobals.UMAutoAttendantTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "AA: {0} Call Time: {1} BusinessHour: {2}", base.Name, exDateTime.ToString("R"), scheduleInterval.ToString());
                if (scheduleInterval.Contains(new WeekDayAndTime((DateTime)exDateTime)))
                {
                    ExTraceGlobals.UMAutoAttendantTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "AA: {0} Call Time: {1} Matched with BusinessHour: {2}", base.Name, exDateTime.ToString("R"), scheduleInterval.ToString());
                    isBusinessHour        = true;
                    autoAttendantSettings = this.BusinessHourSettings;
                    break;
                }
            }
            if (!isBusinessHour)
            {
                ExTraceGlobals.UMAutoAttendantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "AA: {0} Call Time: {1} Returning AfterHour settings", base.Name, exDateTime.ToString("R"));
            }
            return(autoAttendantSettings);
        }