コード例 #1
0
        readonly static string[] POSITIVE_PRESSURE_VALUE_ROLES = new string[] { "D", "B", "R", "H" };            //these roles are above 0 millibars

        #endregion

        /// <summary>
        /// Determines whether a given element corresponds to a positive pressure value (value >= ~10mB) or not.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static bool ElementHasPositivePressure(ProfileElements element, string letter)
        {
            if (string.IsNullOrEmpty(letter))
            {
                throw new ArgumentNullException("letter", "Is empty: " + (letter != null));
            }

            if (element == ProfileElements.Stamps)
            {
                if (POSITIVE_PRESSURE_VALUE_STAMPS.Contains(letter))
                {
                    return(true);
                }
                else if (NEGATIVE_PRESSURE_VALUE_STAMPS.Contains(letter))
                {
                    return(false);
                }
            }
            else if (element == ProfileElements.Roles)
            {
                if (POSITIVE_PRESSURE_VALUE_ROLES.Contains(letter))
                {
                    return(true);
                }
                else if (NEGATIVE_PRESSURE_VALUE_ROLES.Contains(letter))
                {
                    return(false);
                }
            }

            throw new UnknownProfileElementException()
                  {
                      Element = element, Letter = letter
                  };
        }
コード例 #2
0
        public void Apply(ProfileElements e, User u)
        {
            if (e.Email)
            {
                u.Email = Email;
            }
            if (e.Name)
            {
                u.FirstName = FirstName;
                u.LastName  = LastName;
            }
            if (e.DateOfBirth)
            {
                u.DateBirth = DateBirth;
            }
            if (e.DateOfHire)
            {
                u.DateHired = DateHired;
            }
            if (e.HomeAddress)
            {
                u.HomeAddress = HomeAddress;
            }
            if (e.WorkAddress)
            {
                u.WorkAddress = WorkAddress;
            }
            if (e.HomePhone)
            {
                u.HomePhone = HomePhone;
            }
            if (e.WorkPhone)
            {
                u.WorkPhone = WorkPhone;
            }
            if (e.MobilePhone)
            {
                u.MobilePhone = MobilePhone;
            }
            if (e.CustomFields)
            {
                u.Custom = Custom;
            }
            if (e.Password &&
                !String.IsNullOrEmpty(Password) &&
                !String.IsNullOrEmpty(PasswordConfirmation) &&
                Password == PasswordConfirmation)
            {
                u.SetPassword(Password);
            }

            u.LastUpdatedProfile = DateTime.UtcNow;
        }
コード例 #3
0
 public static ProfileEditModel FromDomain(ProfileElements elements, string[] custom, User u)
 {
     return(new ProfileEditModel()
     {
         Elements = elements,
         Login = u.Login,
         Email = u.Email,
         FirstName = u.FirstName,
         LastName = u.LastName,
         DateBirth = u.DateBirth,
         DateHired = u.DateHired,
         HomeAddress = u.HomeAddress,
         WorkAddress = u.WorkAddress,
         HomePhone = u.HomePhone,
         WorkPhone = u.WorkPhone,
         MobilePhone = u.MobilePhone,
         Custom = custom.ToDictionary(
             x => x,
             x => (u.Custom != null && u.Custom.ContainsKey(x)) ? u.Custom[x] : ""),
     });
 }
        /// <summary>
        /// Gets the pressure value in millibars associated with the given profile element.
        /// If the element has no positive pressure value, 0 is returned.
        /// </summary>
        /// <param name="stamp"></param>
        /// <returns></returns>
        /// <exception cref="UnknownProfileElementException">Thrown when the provided element is either empty or unknown.</exception>
        public static int GetPressureValueForElement(ProfileElements element, string letter)
        {
            if (element == ProfileElements.OrthonicBars)
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                case "T":
                case "K":
                    return(0);    //negative pressure value bars have no pressure value (must be 0)

                case "A":
                    return(20);

                case "B":
                    return(70);

                case "R":
                    return(127);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Letter = letter, Element = element
                          };
                }
            }

            throw new UnknownProfileElementException()
                  {
                      Letter = letter, Element = element
                  };
        }
        /// <summary>
        /// Gets the negative evacuation time in seconds associated with the given element.
        /// If the element has a positive pressure value, 0 is returned.
        /// </summary>
        /// <param name="letter"></param>
        /// <returns>A negative time value in seconds.</returns>
        /// <exception cref="UnknownProfileElementException">Thrown when the provided element is either empty or unknown.</exception>
        public static int GetEvacuationTimeForElement(ProfileElements element, string letter)
        {
            if (element == ProfileElements.OrthonicBars)
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                    return(-6);

                case "T":
                    return(-4);

                case "K":
                    return(-2);

                case "A":      //bars with a positive pressure value don't need to be evacuated
                case "B":
                case "R":
                    return(0);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Element = element, Letter = letter
                          };
                }
            }

            throw new UnknownProfileElementException()
                  {
                      Element = element, Letter = letter
                  };
        }
コード例 #6
0
        /// <summary>
        /// Gets the pressure value in millibars associated with the given profile element.
        /// If the element has no positive pressure value, 0 is returned.
        /// </summary>
        /// <param name="stamp"></param>
        /// <returns></returns>
        /// <exception cref="UnknownProfileElementException">Thrown when the provided element is either empty or unknown.</exception>
        public static int GetPressureValueForElement(ProfileElements element, string letter)
        {
            if (element == ProfileElements.Stamps)
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                case "T":
                    return(0);    //negative pressure value stamps have no pressure value (must be 0)

                case "K":
                    return(0);

                case "S":
                case "D":     //silver in other applications
                    return(15);

                case "L":
                    return(20);

                case "B":
                    return(30);

                case "R":
                    return(50);

                case "H":     //"H" is a special stamp that is not actually existing, but is used as "hardest" value in the Ergonometer NL software
                    return(127);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Letter = letter, Element = element
                          };
                }
            }
            else if (element == ProfileElements.Roles) //these values differ sligthly from the Stamps
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                case "T":
                    return(0);    //negative pressure value stamps have no pressure value (must be 0)

                case "K":
                    return(0);

                case "D":
                    return(20);

                case "B":
                    return(70);

                case "R":
                    return(127);

                case "H":     //"H" is a special stamp that is not actually existing, but is used as "hardest" value in the Ergonometer NL software
                    return(127);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Letter = letter, Element = element
                          };
                }
            }

            throw new UnknownProfileElementException()
                  {
                      Letter = letter, Element = element
                  };
        }
コード例 #7
0
        /// <summary>
        /// Gets the negative evacuation time in seconds associated with the given element.
        /// If the element has a positive pressure value, 0 is returned.
        /// </summary>
        /// <param name="letter"></param>
        /// <returns>A negative time value in seconds.</returns>
        /// <exception cref="UnknownProfileElementException">Thrown when the provided element is either empty or unknown.</exception>
        public static int GetEvacuationTimeForElement(ProfileElements element, string letter)
        {
            if (element == ProfileElements.Stamps)
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                    return(-7);    //evacuate 7 secs

                case "T":
                    return(-5);    //evacuate 5 (4800ms) secs

                case "K":
                    return(-2); //evacuate 2 (2100ms) secs

                case "D":       //stamps with a positive pressure value don't need to be evacuated
                case "S":
                case "L":
                case "B":
                case "R":
                case "H":
                    return(0);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Element = element, Letter = letter
                          };
                }
            }
            else if (element == ProfileElements.Roles) //these values differ sligthly from the Stamps version and have another base value (20mb) from which the evacuation starts
            {
                switch (letter)
                {
                case null:
                case "":
                    return(0);

                case "W":
                    return(-7);    //evacuate 7 secs

                case "T":
                    return(-5);    //evacuate 5 (4800ms) secs

                case "K":
                    return(-3); //evacuate 2 (2100ms) secs

                case "D":       //roles with a positive pressure value don't need to be evacuated
                case "S":
                case "L":
                case "B":
                case "R":
                case "H":
                    return(0);

                default:
                    throw new UnknownProfileElementException()
                          {
                              Element = element, Letter = letter
                          };
                }
            }

            throw new UnknownProfileElementException()
                  {
                      Element = element, Letter = letter
                  };
        }
コード例 #8
0
 public void Initialize()
 {
     //initialize Driver
     Driver  = Actions.InitializeDriver();
     profile = new ProfileElements(Driver);
 }