static string GetInvalidMessage(InvalidType type)
        {
            switch (type)
            {
            case InvalidType.isNull:             return("is null.");

            case InvalidType.unexpected:         return("is unexpected.");

            case InvalidType.outOfBounds:        return("is out of bounds.");

            case InvalidType.minLargerThanMax:   return("is larger than max.");

            case InvalidType.countIsZero:        return("has a count/length of 0, which is unexpected.");

            case InvalidType.unexpectedId:       return("is an unexpected identification.");

            case InvalidType.indistinctItems:    return("does not contain indistinct items.");

            case InvalidType.foundDuplicate:     return("is already present and a duplicate of a current object.");

            case InvalidType.readonlyAssignment: return("is semi-readonly (can only be assigned once).");

            case InvalidType.readonlyNoData:     return("is semi-readonly and needs an assignment before accessing.");

            case InvalidType.notFound:           return("cannot be found in the collection.");
            }

            throw NotPossible;
        }
Beispiel #2
0
        public static Layout AsInvalid(Layout l, InvalidType type)
        {
            Layout copy = new Layout(l);

            for (int i = 0; i < l.Size.X; i++)
            {
                for (int j = 0; j < l.Size.Y; j++)
                {
                    var content = l.Content[i, j];
                    if (type == InvalidType.Door)
                    {
                        if (content == Settings.DoorKey)
                        {
                            copy.Content[i, j] = Settings.InvalidKey;
                        }
                    }
                    else if (type == InvalidType.Pos)
                    {
                        if (content != Settings.DoorKey &&
                            content != Settings.EmptyKey &&
                            content != Settings.WallKey)
                        {
                            copy.Content[i, j] = Settings.InvalidKey;
                        }
                    }
                }
            }
            return(copy);
        }
        public void WhenIncorrectParentTypeForSensitivityTestNotEmptyWithoutComment_IsTreatedAsValid()
        {
            var target  = new InvalidType();
            var context = new ValidationContext(target);
            var results = new List <ValidationResult>();

            var isValid = Validator.TryValidateObject(target, context, results, true);

            Assert.That(isValid, Is.True);
        }
Beispiel #4
0
        ///<summary>Simplest way to use the new fKey and FKeyType. Set isBroadcast=true to process signals immediately on workstation.</summary>
        public static void SetInvalid(InvalidType iType, KeyType fKeyType, long fKey)
        {
            //Remoting role check performed in the Insert.
            Signalod sig = new Signalod();

            sig.IType       = iType;
            sig.DateViewing = DateTime.MinValue;
            sig.FKey        = fKey;
            sig.FKeyType    = fKeyType;
            Insert(sig);
        }
    void F()
    {
        var v = new InvalidType();

        Debug.Assert(v.a.b, "This is true");

        new CounterCreationData()
        {
            CounterHelp = string.Empty, CounterType = v.Type
        };
    }
Beispiel #6
0
        public void SendSms_Invalid(InvalidType validType, string expectedCode, string expectedMessage)
        {
            using (var resources = new Resources())
            {
                //Given
                var requestModel = new SendSmsCommandModel
                {
                    MessageId   = validType == InvalidType.InvalidMessageId ? null : Guid.NewGuid().ToString(),
                    PhoneNumber = validType == InvalidType.InvalidPhone? null : "+27846005192",
                    TextMessage = validType == InvalidType.InvalidMessage ? null : "This is a test SMS Message"
                };

                //setup SmsGateway SendSms
                resources.SmsGateway.Setup(x => x.SendSms(It.Is <Provider1SmsRequest>(m =>
                                                                                      m.UniqueId == requestModel.MessageId &&
                                                                                      m.Phone == requestModel.PhoneNumber &&
                                                                                      m.Message == requestModel.TextMessage))).Returns(new HttpResponseMessage(System.Net.HttpStatusCode.OK));


                //When
                var result = resources.Controller.SendSms(requestModel) as BadRequestObjectResult;

                //Then
                Assert.IsNotNull(result);
                Assert.IsTrue(result.StatusCode == 400);

                var validResult = result.Value as ValidationResult;

                Assert.False(validResult.IsValid);
                Assert.IsNotEmpty(validResult.Messages);

                var validationMessage = validResult.Messages[0];
                Assert.AreEqual(expectedCode, validationMessage.Code);
                Assert.AreEqual(expectedMessage, validationMessage.MessageText);

                //verify no calls were made
                resources.LogHelper.Verify(x => x.LogMessage(It.Is <string>(m =>
                                                                            m == $"SMS sent for messageId: { requestModel.MessageId}")), Times.Never);

                resources.SmsGateway.Verify(x => x.SendSms(It.Is <Provider1SmsRequest>(m =>
                                                                                       m.UniqueId == requestModel.MessageId &&
                                                                                       m.Phone == requestModel.PhoneNumber &&
                                                                                       m.Message == requestModel.TextMessage)), Times.Never);

                resources.EventBus.Verify(x => x.PublishEvent(It.Is <SmsSentEvent>(m =>
                                                                                   m.MessageId == requestModel.MessageId &&
                                                                                   m.PhoneNumber == requestModel.PhoneNumber &&
                                                                                   m.TextMessage == requestModel.TextMessage)), Times.Never);

                resources.LogHelper.VerifyNoOtherCalls();
                resources.SmsGateway.VerifyNoOtherCalls();
                resources.EventBus.VerifyNoOtherCalls();
            }
        }
Beispiel #7
0
        public bool ValidateType(InvalidType _type, string _rules, string _text)
        {
            Regex  regex;
            string rules;

            switch (_type)
            {
            case InvalidType.Empty:
                if (_text.Trim() == "")
                {
                    return(false);
                }
                break;

            case InvalidType.Phone:
                if (_text.Trim() != "")
                {
                    rules = @"((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)";    //电话号码 或 手机号码
                    regex = new Regex(rules);
                    return(regex.IsMatch(_text.Trim()));
                }
                break;

            case InvalidType.IDcard:
                if (_text.Trim() != "")
                {
                    rules = @"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$";    //身份证
                    regex = new Regex(rules);
                    return(regex.IsMatch(_text.Trim()));
                }
                break;

            case InvalidType.Custom:
                if (_text.Trim() != "")
                {
                    rules = _rules;
                    regex = new Regex(rules);
                    return(regex.IsMatch(_text.Trim()));
                }
                break;
            }
            return(true);
        }
 ///<summary>Determines the DateTime the given signal was refreshed since the given DateTime.</summary>
 public static DateTime GetDateTimeRefreshed(InvalidType iType)
 {
     InitIfNecessary();
     lock (_lockInvalidTypes) {
         if (iType == InvalidType.Appointment)
         {
             //Appointments signals are being stored locally so they can be played back for a given Xam session.
             //This will allow a determination to be made if there are any stale op views for the session within the given timeframe.
             //If there are no signals currently cached then assume there is nothing stale (DateTime.MinValue).
             //If there are signals then assume that the of the most recent signal is the latest stale time.
             //Any sessions that have not updated since the latest signal time will be assumed to be stale and should ask for appointment changes.
             return(ListApptSinceSignalCache.Count == 0 ? DateTime.MinValue : ListApptSinceSignalCache.Max(x => x.SigDateTime));
         }
         if (_dictInvalidTypes.TryGetValue(iType, out DateTime date))
         {
             return(date);
         }
     }
     return(DateTime.MinValue);
 }
        protected void SetTextBoxValidity(TextBox textBox, bool isValid, InvalidType invalidType = InvalidType.Error)
        {
            if (isValid)
            {
                textBox.BackColor = System.Drawing.Color.White;
            }
            else
            {
                switch (invalidType)
                {
                case InvalidType.Error:
                    textBox.BackColor = System.Drawing.ColorTranslator.FromHtml(hex_error);
                    break;

                case InvalidType.Warning:
                    textBox.BackColor = System.Drawing.ColorTranslator.FromHtml(hex_warning);
                    break;
                }
            }
        }
Beispiel #10
0
        ///<summary>Process all Signals and Acks Since a given DateTime.  Only to be used by OpenDentalWebService.
        ///Returns latest valid signal Date/Time and the list of InvalidTypes that were refreshed.
        ///Can throw exception.</summary>
        public static List <InvalidType> RefreshForWeb()
        {
            InvalidTypeHistory.InitIfNecessary();
            int defaultProcessSigsIntervalInSecs = 7;

            ODException.SwallowAnyException(() => defaultProcessSigsIntervalInSecs = PrefC.GetInt(PrefName.ProcessSigsIntervalInSecs));
            if (DateTime.Now.Subtract(SignalLastRefreshedWeb) <= TimeSpan.FromSeconds(defaultProcessSigsIntervalInSecs))
            {
                return(new List <InvalidType>());
            }
            InvalidType[] arrayInvalidTypes = new InvalidType[0];
            //No need to check RemotingRole; no call to db.
            List <Signalod> listSignals = new List <Signalod>();

            try {
                if (SignalLastRefreshedWeb.Year < 1880)                //First signals for this session so go back in time a bit.
                {
                    SignalLastRefreshedWeb = MiscData.GetNowDateTime().AddSeconds(-1);
                }
                listSignals = Signalods.RefreshTimed(SignalLastRefreshedWeb);
                if (listSignals.Count > 0)                  //Next lower bound is current upper bound.
                {
                    SignalLastRefreshedWeb = listSignals.Max(x => x.SigDateTime);
                }
                arrayInvalidTypes = Signalods.GetInvalidTypesForWeb(listSignals);
                //Get all invalid types since given time and refresh the cache for those given invalid types.
                Cache.Refresh(arrayInvalidTypes);
            }
            catch (Exception e) {
                //Most likely cause for an exception here would be a thread collision between 2 consumers trying to refresh the cache at the exact same instant.
                //There is a chance that performing as subsequent refresh here would cause yet another collision but it's the best we can do without redesigning the entire cache pattern.
                Cache.Refresh(InvalidType.AllLocal);
                //Reset the last signal process time.
                DateTime dateTimeNow = DateTime.Now;
                ODException.SwallowAnyException(() => dateTimeNow = OpenDentBusiness.MiscData.GetNowDateTime());
                SignalLastRefreshedWeb = dateTimeNow;
                throw new Exception("Server cache may be invalid. Please try again. Error: " + e.Message);
            }
            InvalidTypeHistory.UpdateStatus(SignalLastRefreshedWeb, listSignals, arrayInvalidTypes);
            return(arrayInvalidTypes.ToList());
        }
Beispiel #11
0
        ///<summary>Process all Signals and Acks Since a given DateTime.  Only to be used by OpenDentalWebService.
        ///Returns latest valid signal Date/Time and the list of InvalidTypes that were refreshed.
        ///Can throw exception.</summary>
        public static List <InvalidType> RefreshForWeb()
        {
            int defaultProcessSigsIntervalInSecs = 7;

            ODException.SwallowAnyException(() => defaultProcessSigsIntervalInSecs = PrefC.GetInt(PrefName.ProcessSigsIntervalInSecs));
            if (DateTime.Now.Subtract(_signalLastRefreshedWeb) <= TimeSpan.FromSeconds(defaultProcessSigsIntervalInSecs))
            {
                return(new List <InvalidType>());
            }
            InvalidType[] arrayInvalidTypes = new InvalidType[0];
            //No need to check RemotingRole; no call to db.
            try {
                if (_signalLastRefreshedWeb.Year < 1880)
                {
                    _signalLastRefreshedWeb = MiscData.GetNowDateTime();
                }
                arrayInvalidTypes = Signalods.GetInvalidTypesForWeb(Signalods.RefreshTimed(_signalLastRefreshedWeb));
                //Get all invalid types since given time and refresh the cache for those given invalid types.
                Cache.Refresh(arrayInvalidTypes);
            }
            catch (Exception e) {
                //Most likely cause for an exception here would be a thread collision between 2 consumers trying to refresh the cache at the exact same instant.
                //There is a chance that performing as subsequent refresh here would cause yet another collision but it's the best we can do without redesigning the entire cache pattern.
                Cache.Refresh(InvalidType.AllLocal);
                throw new Exception("Server cache may be invalid. Please try again. Error: " + e.Message);
            }
            finally {
                DateTime dateTimeNow = DateTime.Now;
                try {
                    dateTimeNow = OpenDentBusiness.MiscData.GetNowDateTime();
                }
                catch (Exception) { }
                _signalLastRefreshedWeb = dateTimeNow;
            }
            return(arrayInvalidTypes.ToList());
        }
Beispiel #12
0
Datei: Cache.cs Projekt: mnisl/OD
		///<summary>This is only called from the UI.  Its purpose is to refresh the cache for one type on both the workstation and server.  DataValid.SetInvalid() should be used when all other workstations in the office need to refresh their cache as well.</summary>
		public static void Refresh(InvalidType itype) {
			int intItype=(int)itype;
			RefreshCache(intItype.ToString());
		}
Beispiel #13
0
        ///<summary>This is only called from the UI.  Its purpose is to refresh the cache for one type on both the workstation and server.  This can be used instead of DataValid.SetInvalid() when it is unnecessary to tell all the other workstations to refresh their cache.</summary>
        public static void Refresh(InvalidType itype)
        {
            int intItype = (int)itype;

            RefreshCache(intItype.ToString());
        }
Beispiel #14
0
        public override bool check(CodeContext context)
        {
            if (is_checked)
            {
                return(!error);
            }

            is_checked = true;

            if (inner != null)
            {
                inner.check(context);
            }

            foreach (DataType type_arg in type_argument_list)
            {
                type_arg.check(context);
            }

            Symbol    base_symbol    = null;
            Parameter this_parameter = null;
            bool      may_access_instance_members = false;
            bool      may_access_klass_members    = false;

            symbol_reference = null;

            if (qualified)
            {
                base_symbol      = context.analyzer.root_symbol;
                symbol_reference = context.analyzer.root_symbol.scope.lookup(member_name);
            }
            else if (inner == null)
            {
                if (member_name == "this")
                {
                    if (!context.analyzer.is_in_instance_method())
                    {
                        error = true;
                        Report.error(source_reference, "This access invalid outside of instance methods");
                        return(false);
                    }
                }

                base_symbol = context.analyzer.current_symbol;

                // track whether method has been found to make sure that access
                // to instance member is denied from within static lambda expressions
                bool method_found = false;

                var sym = context.analyzer.current_symbol;
                while (sym != null && symbol_reference == null)
                {
                    if (!method_found)
                    {
                        if (sym is CreationMethod)
                        {
                            var cm = (CreationMethod)sym;
                            this_parameter = cm.this_parameter;
                            may_access_instance_members = true;
                            may_access_klass_members    = true;
                            method_found = true;
                        }
                        else if (sym is Property)
                        {
                            var prop = (Property)sym;
                            this_parameter = prop.this_parameter;
                            may_access_instance_members = (prop.binding == MemberBinding.INSTANCE);
                            may_access_klass_members    = (prop.binding != MemberBinding.STATIC);
                            method_found = true;
                        }
                        else if (sym is Constructor)
                        {
                            var c = (Constructor)sym;
                            this_parameter = c.this_parameter;
                            may_access_instance_members = (c.binding == MemberBinding.INSTANCE);
                            may_access_klass_members    = true;
                            method_found = true;
                        }
                        else if (sym is Destructor)
                        {
                            var d = (Destructor)sym;
                            this_parameter = d.this_parameter;
                            may_access_instance_members = (d.binding == MemberBinding.INSTANCE);
                            may_access_klass_members    = true;
                            method_found = true;
                        }
                        else if (sym is Method)
                        {
                            var m = (Method)sym;
                            this_parameter = m.this_parameter;
                            may_access_instance_members = (m.binding == MemberBinding.INSTANCE);
                            may_access_klass_members    = (m.binding != MemberBinding.STATIC);
                            method_found = true;
                        }
                    }

                    symbol_reference = SemanticAnalyzer.symbol_lookup_inherited(sym, member_name);

                    if (symbol_reference == null && sym is TypeSymbol && may_access_instance_members)
                    {
                        // used for generated to_string methods in enums
                        symbol_reference = this_parameter.variable_type.get_member(member_name);

                        if (symbol_reference != null && is_instance_symbol(symbol_reference))
                        {
                            // implicit this
                            inner                        = new MemberAccess(null, "this", source_reference);
                            inner.value_type             = this_parameter.variable_type.copy();
                            inner.value_type.value_owned = false;
                            inner.symbol_reference       = this_parameter;

                            symbol_reference = inner.value_type.get_member(member_name);
                        }
                    }

                    if (symbol_reference == null)
                    {
                        if (sym is TypeSymbol)
                        {
                            // do not allow instance access to outer classes
                            this_parameter = null;
                            may_access_instance_members = false;
                            may_access_klass_members    = false;
                        }
                    }

                    sym = sym.parent_symbol;
                }

                if (symbol_reference == null && source_reference != null)
                {
                    foreach (UsingDirective ns in source_reference.using_directives)
                    {
                        var local_sym = ns.namespace_symbol.scope.lookup(member_name);
                        if (local_sym != null)
                        {
                            if (symbol_reference != null && symbol_reference != local_sym)
                            {
                                error = true;
                                Report.error(source_reference, "`%s' is an ambiguous reference between `%s' and `%s'".printf(member_name, symbol_reference.get_full_name(), local_sym.get_full_name()));
                                return(false);
                            }
                            symbol_reference = local_sym;
                        }
                    }
                }
            }
            else
            {
                if (inner.error)
                {
                    /* if there was an error in the inner expression, skip this check */
                    error = true;
                    return(false);
                }

                if (inner.value_type is PointerType)
                {
                    var pointer_type = inner.value_type as PointerType;
                    if (pointer_type != null && pointer_type.base_type is ValaValueType)
                    {
                        // transform foo->bar to (*foo).bar
                        inner = new PointerIndirection(inner, source_reference);
                        inner.check(context);
                        pointer_member_access = false;
                    }
                }

                if (inner is MemberAccess)
                {
                    var ma = (MemberAccess)inner;
                    if (ma.prototype_access)
                    {
                        error = true;
                        Report.error(source_reference, "Access to instance member `%s' denied".printf(inner.symbol_reference.get_full_name()));
                        return(false);
                    }
                }

                if (inner is MemberAccess || inner is BaseAccess)
                {
                    base_symbol = inner.symbol_reference;

                    if (symbol_reference == null && (base_symbol is Namespace || base_symbol is TypeSymbol))
                    {
                        symbol_reference = base_symbol.scope.lookup(member_name);
                        if (inner is BaseAccess)
                        {
                            // inner expression is base access
                            // access to instance members of the base type possible
                            may_access_instance_members = true;
                            may_access_klass_members    = true;
                        }
                    }
                }

                if (symbol_reference == null && inner.value_type != null)
                {
                    if (pointer_member_access)
                    {
                        symbol_reference = inner.value_type.get_pointer_member(member_name);
                    }
                    else
                    {
                        if (inner.value_type.data_type != null)
                        {
                            base_symbol = inner.value_type.data_type;
                        }
                        symbol_reference = inner.value_type.get_member(member_name);
                    }
                    if (symbol_reference != null)
                    {
                        // inner expression is variable, field, or parameter
                        // access to instance members of the corresponding type possible
                        may_access_instance_members = true;
                        may_access_klass_members    = true;
                    }
                }

                if (symbol_reference == null && inner.value_type != null && inner.value_type.is_dynamic)
                {
                    // allow late bound members for dynamic types
                    var dynamic_object_type = (ObjectType)inner.value_type;
                    if (parent_node is MethodCall)
                    {
                        var invoc = (MethodCall)parent_node;
                        if (invoc.call == this)
                        {
                            // dynamic method
                            DataType ret_type;
                            if (invoc.target_type != null)
                            {
                                ret_type             = invoc.target_type.copy();
                                ret_type.value_owned = true;
                            }
                            else if (invoc.parent_node is ExpressionStatement)
                            {
                                ret_type = new VoidType();
                            }
                            else
                            {
                                // expect dynamic object of the same type
                                ret_type = inner.value_type.copy();
                            }
                            var m = new DynamicMethod(inner.value_type, member_name, ret_type, source_reference);
                            m.invocation = invoc;
                            var err = new ErrorType(null, null);
                            err.dynamic_error = true;
                            m.add_error_type(err);
                            m.access = SymbolAccessibility.PUBLIC;
                            m.add_parameter(Parameter.with_ellipsis());
                            dynamic_object_type.type_symbol.scope.add(null, m);
                            symbol_reference = m;
                        }
                    }
                    else if (parent_node is Assignment)
                    {
                        var a = (Assignment)parent_node;
                        if (a.left == this &&
                            (a.Operator == AssignmentOperator.ADD ||
                             a.Operator == AssignmentOperator.SUB))
                        {
                            // dynamic signal
                            var s = new DynamicSignal(inner.value_type, member_name, new VoidType(), source_reference);
                            s.handler = a.right;
                            s.access  = SymbolAccessibility.PUBLIC;
                            dynamic_object_type.type_symbol.scope.add(null, s);
                            symbol_reference = s;
                        }
                        else if (a.left == this)
                        {
                            // dynamic property assignment
                            var prop = new DynamicProperty(inner.value_type, member_name, source_reference);
                            prop.access       = SymbolAccessibility.PUBLIC;
                            prop.set_accessor = new PropertyAccessor(false, true, false, null, null, prop.source_reference);
                            prop.owner        = inner.value_type.data_type.scope;
                            dynamic_object_type.type_symbol.scope.add(null, prop);
                            symbol_reference = prop;
                        }
                    }
                    else if (parent_node is MemberAccess && inner is MemberAccess && parent_node.parent_node is MethodCall)
                    {
                        var ma = (MemberAccess)parent_node;
                        if (ma.member_name == "connect" || ma.member_name == "connect_after")
                        {
                            // dynamic signal
                            var s     = new DynamicSignal(inner.value_type, member_name, new VoidType(), source_reference);
                            var mcall = (MethodCall)parent_node.parent_node;
                            // the first argument is the handler
                            if (mcall.get_argument_list().Count > 0)
                            {
                                s.handler = mcall.get_argument_list()[0];
                            }
                            s.access = SymbolAccessibility.PUBLIC;
                            dynamic_object_type.type_symbol.scope.add(null, s);
                            symbol_reference = s;
                        }
                    }
                    if (symbol_reference == null)
                    {
                        // dynamic property read access
                        var prop = new DynamicProperty(inner.value_type, member_name, source_reference);
                        if (target_type != null)
                        {
                            prop.property_type = target_type;
                        }
                        else
                        {
                            // expect dynamic object of the same type
                            prop.property_type = inner.value_type.copy();
                        }
                        prop.access       = SymbolAccessibility.PUBLIC;
                        prop.get_accessor = new PropertyAccessor(true, false, false, prop.property_type.copy(), null, prop.source_reference);
                        prop.owner        = inner.value_type.data_type.scope;
                        dynamic_object_type.type_symbol.scope.add(null, prop);
                        symbol_reference = prop;
                    }
                    if (symbol_reference != null)
                    {
                        may_access_instance_members = true;
                        may_access_klass_members    = true;
                    }
                }
            }

            if (symbol_reference == null)
            {
                error = true;

                string base_type_name = "(null)";
                if (inner != null && inner.value_type != null)
                {
                    base_type_name = inner.value_type.ToString();
                }
                else if (base_symbol != null)
                {
                    base_type_name = base_symbol.get_full_name();
                }

                Report.error(source_reference, "The name `%s' does not exist in the context of `%s'".printf(member_name, base_type_name));
                return(false);
            }

            var  member   = symbol_reference;
            var  access   = SymbolAccessibility.PUBLIC;
            bool instance = false;
            bool klass    = false;
            bool generics = false;

            if (!member.check(context))
            {
                return(false);
            }

            if (member is LocalVariable)
            {
                var local = (LocalVariable)member;
                var block = local.parent_symbol as Block;
                if (block != null && context.analyzer.find_parent_method_or_property_accessor(block) != context.analyzer.current_method_or_property_accessor)
                {
                    // mark all methods between current method and the captured
                    // block as closures (to support nested closures)
                    Symbol sym = context.analyzer.current_method_or_property_accessor;
                    while (sym != block)
                    {
                        var method = sym as Method;
                        if (method != null)
                        {
                            method.closure = true;
                            // consider captured variables as used
                            // as we require captured variables to be initialized
                            method.add_captured_variable(local);
                        }
                        sym = sym.parent_symbol;
                    }

                    local.captured = true;
                    block.captured = true;
                }
            }
            else if (member is Parameter)
            {
                var param = (Parameter)member;
                var m     = param.parent_symbol as Method;
                if (m != null && m != context.analyzer.current_method_or_property_accessor && param != m.this_parameter)
                {
                    // mark all methods between current method and the captured
                    // parameter as closures (to support nested closures)
                    Symbol sym = context.analyzer.current_method_or_property_accessor;
                    while (sym != m)
                    {
                        var method = sym as Method;
                        if (method != null)
                        {
                            method.closure = true;
                        }
                        sym = sym.parent_symbol;
                    }

                    param.captured  = true;
                    m.body.captured = true;

                    if (param.direction != ParameterDirection.IN)
                    {
                        error = true;
                        Report.error(source_reference, "Cannot capture reference or output parameter `%s'".printf(param.get_full_name()));
                    }
                }
                else
                {
                    var acc = param.parent_symbol.parent_symbol as PropertyAccessor;
                    if (acc != null && acc != context.analyzer.current_method_or_property_accessor && param != acc.prop.this_parameter)
                    {
                        // mark all methods between current method and the captured
                        // parameter as closures (to support nested closures)
                        Symbol sym = context.analyzer.current_method_or_property_accessor;
                        while (sym != m)
                        {
                            var method = sym as Method;
                            if (method != null)
                            {
                                method.closure = true;
                            }
                            sym = sym.parent_symbol;
                        }

                        param.captured    = true;
                        acc.body.captured = true;
                    }
                }
            }
            else if (member is Field)
            {
                var f = (Field)member;
                access   = f.access;
                instance = (f.binding == MemberBinding.INSTANCE);
                klass    = (f.binding == MemberBinding.CLASS);

                // do not allow access to fields of generic types
                // if instance type does not specify type arguments
                if (f.variable_type is GenericType)
                {
                    generics = true;
                }
            }
            else if (member is Constant)
            {
                var c = (Constant)member;
                access = c.access;

                var block = c.parent_symbol as Block;
                if (block != null && context.analyzer.find_parent_method_or_property_accessor(block) != context.analyzer.current_method_or_property_accessor)
                {
                    error = true;
                    Report.error(source_reference, "internal error: accessing local constants of outer methods is not supported yet");
                    return(false);
                }
            }
            else if (member is Method)
            {
                var m = (Method)member;
                if (m.is_async_callback)
                {
                    // ensure to use right callback method for virtual/abstract async methods
                    // and also for lambda expressions within async methods
                    var async_method = context.analyzer.current_async_method;

                    bool is_valid_access = false;
                    if (async_method != null)
                    {
                        if (m == async_method.get_callback_method())
                        {
                            is_valid_access = true;
                        }
                        else if (async_method.base_method != null && m == async_method.base_method.get_callback_method())
                        {
                            is_valid_access = true;
                        }
                        else if (async_method.base_interface_method != null && m == async_method.base_interface_method.get_callback_method())
                        {
                            is_valid_access = true;
                        }
                    }
                    if (!is_valid_access)
                    {
                        error = true;
                        Report.error(source_reference, "Access to async callback `%s' not allowed in this context".printf(m.get_full_name()));
                        return(false);
                    }

                    if (async_method != context.analyzer.current_method)
                    {
                        Symbol sym = context.analyzer.current_method;
                        while (sym != async_method)
                        {
                            var method = sym as Method;
                            if (method != null)
                            {
                                method.closure = true;
                            }
                            sym = sym.parent_symbol;
                        }
                        async_method.body.captured = true;
                    }

                    m = async_method.get_callback_method();
                    symbol_reference = m;
                    member           = symbol_reference;
                }
                else if (m.base_method != null)
                {
                    // refer to base method to inherit default arguments
                    m = m.base_method;

                    if (m.signal_reference != null)
                    {
                        // method is class/default handler for a signal
                        // let signal deal with member access
                        symbol_reference = m.signal_reference;
                    }
                    else
                    {
                        symbol_reference = m;
                    }

                    member = symbol_reference;
                }
                else if (m.base_interface_method != null)
                {
                    // refer to base method to inherit default arguments
                    m = m.base_interface_method;

                    if (m.signal_reference != null)
                    {
                        // method is class/default handler for a signal
                        // let signal deal with member access
                        symbol_reference = m.signal_reference;
                    }
                    else
                    {
                        symbol_reference = m;
                    }

                    member = symbol_reference;
                }
                access = m.access;
                if (!(m is CreationMethod))
                {
                    instance = (m.binding == MemberBinding.INSTANCE);
                }
                klass = (m.binding == MemberBinding.CLASS);

                // do not allow access to methods using generic type parameters
                // if instance type does not specify type arguments
                foreach (var param in m.get_parameters())
                {
                    var _generic_type = param.variable_type as GenericType;
                    if (_generic_type != null && _generic_type.type_parameter.parent_symbol is TypeSymbol)
                    {
                        generics = true;
                        break;
                    }
                }
                var generic_type = m.return_type as GenericType;
                if (generic_type != null && generic_type.type_parameter.parent_symbol is TypeSymbol)
                {
                    generics = true;
                }
            }
            else if (member is Property)
            {
                var prop = (Property)member;
                if (!prop.check(context))
                {
                    error = true;
                    return(false);
                }
                if (prop.base_property != null)
                {
                    // refer to base property
                    prop             = prop.base_property;
                    symbol_reference = prop;
                    member           = symbol_reference;
                }
                else if (prop.base_interface_property != null)
                {
                    // refer to base property
                    prop             = prop.base_interface_property;
                    symbol_reference = prop;
                    member           = symbol_reference;
                }
                access = prop.access;
                if (lvalue)
                {
                    if (prop.set_accessor == null)
                    {
                        error = true;
                        Report.error(source_reference, "Property `%s' is read-only".printf(prop.get_full_name()));
                        return(false);
                    }
                    if (prop.access == SymbolAccessibility.PUBLIC)
                    {
                        access = prop.set_accessor.access;
                    }
                    else if (prop.access == SymbolAccessibility.PROTECTED &&
                             prop.set_accessor.access != SymbolAccessibility.PUBLIC)
                    {
                        access = prop.set_accessor.access;
                    }
                }
                else
                {
                    if (prop.get_accessor == null)
                    {
                        error = true;
                        Report.error(source_reference, "Property `%s' is write-only".printf(prop.get_full_name()));
                        return(false);
                    }
                    if (prop.access == SymbolAccessibility.PUBLIC)
                    {
                        access = prop.get_accessor.access;
                    }
                    else if (prop.access == SymbolAccessibility.PROTECTED &&
                             prop.get_accessor.access != SymbolAccessibility.PUBLIC)
                    {
                        access = prop.get_accessor.access;
                    }
                }
                instance = (prop.binding == MemberBinding.INSTANCE);

                // do not allow access to properties of generic types
                // if instance type does not specify type arguments
                if (prop.property_type is GenericType)
                {
                    generics = true;
                }
            }
            else if (member is Signal)
            {
                instance = true;
                access   = member.access;
            }

            member.used = true;
            member.version.check(source_reference);

            if (access == SymbolAccessibility.PROTECTED)
            {
                var target_type = (TypeSymbol)member.parent_symbol;

                bool in_subtype = false;
                for (Symbol this_symbol = context.analyzer.current_symbol; this_symbol != null; this_symbol = this_symbol.parent_symbol)
                {
                    if (this_symbol == target_type)
                    {
                        // required for interfaces with non-abstract methods
                        // accessing protected interface members
                        in_subtype = true;
                        break;
                    }

                    var cl = this_symbol as Class;
                    if (cl != null && cl.is_subtype_of(target_type))
                    {
                        in_subtype = true;
                        break;
                    }
                }

                if (!in_subtype)
                {
                    error = true;
                    Report.error(source_reference, "Access to protected member `%s' denied".printf(member.get_full_name()));
                    return(false);
                }
            }
            else if (access == SymbolAccessibility.PRIVATE)
            {
                var target_type = member.parent_symbol;

                bool in_target_type = false;
                for (Symbol this_symbol = context.analyzer.current_symbol; this_symbol != null; this_symbol = this_symbol.parent_symbol)
                {
                    if (target_type == this_symbol)
                    {
                        in_target_type = true;
                        break;
                    }
                }

                if (!in_target_type)
                {
                    error = true;
                    Report.error(source_reference, "Access to private member `%s' denied".printf(member.get_full_name()));
                    return(false);
                }
            }

            if (generics && inner != null)
            {
                var instance_type = inner.value_type;
                var pointer_type  = inner.value_type as PointerType;
                if (pointer_type != null)
                {
                    instance_type = pointer_type.base_type;
                }

                // instance type might be a subtype of the parent symbol of the member
                // that subtype might not be generic, so do not report an error in that case
                var object_type = instance_type as ObjectType;
                if (object_type != null && object_type.type_symbol.get_type_parameters().Count > 0 &&
                    instance_type.get_type_arguments().Count == 0)
                {
                    error = true;
                    Report.error(inner.source_reference, "missing generic type arguments");
                    return(false);
                }
            }

            if ((instance && !may_access_instance_members) ||
                (klass && !may_access_klass_members))
            {
                prototype_access = true;

                if (symbol_reference is Method)
                {
                    // also set static type for prototype access
                    // required when using instance methods as delegates in constants
                    // TODO replace by MethodPrototype
                    value_type = context.analyzer.get_value_type_for_symbol(symbol_reference, lvalue);
                }
                else if (symbol_reference is Field)
                {
                    value_type = new FieldPrototype((Field)symbol_reference);
                }
                else
                {
                    value_type = new InvalidType();
                }

                if (target_type != null)
                {
                    value_type.value_owned = target_type.value_owned;
                }
            }
            else
            {
                // implicit this access
                if (instance && inner == null)
                {
                    inner                        = new MemberAccess(null, "this", source_reference);
                    inner.value_type             = this_parameter.variable_type.copy();
                    inner.value_type.value_owned = false;
                    inner.symbol_reference       = this_parameter;
                }
                else
                {
                    check_lvalue_access();
                }

                if (!instance && !klass && !(symbol_reference is CreationMethod) && may_access_instance_members && inner != null)
                {
                    if (inner.symbol_reference is Method)
                    {
                        // do not warn when calling .begin or .end on static async method
                    }
                    else
                    {
                        Report.warning(source_reference, "Access to static member `%s' with an instance reference".printf(symbol_reference.get_full_name()));
                    }
                }

                if (context.experimental_non_null && instance && inner.value_type.nullable &&
                    !(inner.value_type is PointerType) && !(inner.value_type is GenericType) &&
                    !(inner.value_type is ArrayType))
                {
                    Report.error(source_reference, "Access to instance member `%s' from nullable reference denied".printf(symbol_reference.get_full_name()));
                }

                var m        = symbol_reference as Method;
                var inner_ma = inner as MemberAccess;
                if (m != null && m.binding == MemberBinding.STATIC && m.parent_symbol is ObjectTypeSymbol &&
                    inner != null && inner.value_type == null && inner_ma.type_argument_list.Count > 0)
                {
                    // support static methods in generic classes
                    inner.value_type = new ObjectType((ObjectTypeSymbol)m.parent_symbol);

                    foreach (var type_argument in inner_ma.type_argument_list)
                    {
                        inner.value_type.add_type_argument(type_argument);
                    }
                }

                formal_value_type = context.analyzer.get_value_type_for_symbol(symbol_reference, lvalue);
                if (inner != null && formal_value_type != null)
                {
                    value_type = formal_value_type.get_actual_type(inner.value_type, null, this);
                }
                else
                {
                    value_type = formal_value_type;
                }

                if (symbol_reference is Method)
                {
                    var method = (Method)symbol_reference;
                    if (target_type != null)
                    {
                        value_type.value_owned = target_type.value_owned;
                    }
                    if (instance && method.parent_symbol is TypeSymbol)
                    {
                        inner.target_type             = SemanticAnalyzer.get_data_type_for_symbol((TypeSymbol)method.parent_symbol);
                        inner.target_type.value_owned = method.this_parameter.variable_type.value_owned;
                    }
                }
                else if (symbol_reference is Property)
                {
                    var prop = (Property)symbol_reference;
                    if (instance && prop.parent_symbol != null)
                    {
                        inner.target_type = SemanticAnalyzer.get_data_type_for_symbol((TypeSymbol)prop.parent_symbol);
                    }
                }
                else if ((symbol_reference is Field ||
                          symbol_reference is Signal) &&
                         instance && symbol_reference.parent_symbol != null)
                {
                    var parent_type = SemanticAnalyzer.get_data_type_for_symbol((TypeSymbol)symbol_reference.parent_symbol);
                    inner.target_type = parent_type.get_actual_type(inner.value_type, null, this);
                }
            }

            return(!error);
        }
 public static Exception Invalid(string memberName, object argumentValue, InvalidType type) => GetException(memberName, argumentValue, GetInvalidMessage(type));
 public static Exception Invalid(string memberName, InvalidType type) => GetException(memberName, GetInvalidMessage(type));
Beispiel #17
0
 public void ShouldThrowWhenTypeIsWrong()
 {
     InvalidType invalidType = new InvalidType();
 }
 public ValidationException(InvalidType type, string message) : base(message)
 {
     invalid = type;
 }
Beispiel #19
0
		///<summary>This is called when any local data becomes outdated.  It's purpose is to tell the other computers to update certain local data.</summary>
		private void DataValid_BecameInvalid(OpenDental.ValidEventArgs e){
			if(e.OnlyLocal){//Currently used after doing a restore from FormBackup so that the local cache is forcefully updated.
				if(!PrefsStartup()){//??
					return;
				}
				RefreshLocalData(InvalidType.AllLocal);//does local computer only
				return;
			}
			if(!e.ITypes.Contains((int)InvalidType.Date) //local refresh for dates is handled within ContrAppt, not here
				&& !e.ITypes.Contains((int)InvalidType.Task)//Tasks are not "cached" data.
				&& !e.ITypes.Contains((int)InvalidType.TaskPopup))
			{
				InvalidType[] itypeArray=new InvalidType[e.ITypes.Count];
				for(int i=0;i<itypeArray.Length;i++){
					itypeArray[i]=(InvalidType)e.ITypes[i];
				}
				RefreshLocalData(itypeArray);//does local computer
			}
			if(e.ITypes.Contains((int)InvalidType.Task) || e.ITypes.Contains((int)InvalidType.TaskPopup)) {
				//One of the two task lists needs to be refreshed on this instance of OD
				if(userControlTasks1.Visible) {
					userControlTasks1.RefreshTasks();
				}
				//See if FormTasks is currently open.
				if(ContrManage2!=null && ContrManage2.FormT!=null && !ContrManage2.FormT.IsDisposed) {
					ContrManage2.FormT.RefreshUserControlTasks();
				}
			}
			string itypeString="";
			for(int i=0;i<e.ITypes.Count;i++){
				if(i>0){
					itypeString+=",";
				}
				itypeString+=e.ITypes[i].ToString();
			}
			Signalod sig=new Signalod();
			sig.ITypes=itypeString;
			if(e.ITypes.Contains((int)InvalidType.Date)){
				sig.DateViewing=e.DateViewing;
			}
			else{
				sig.DateViewing=DateTime.MinValue;
			}
			sig.SigType=SignalType.Invalid;
			if(e.ITypes.Contains((int)InvalidType.Task) || e.ITypes.Contains((int)InvalidType.TaskPopup)){
				sig.TaskNum=e.TaskNum;
			}
			Signalods.Insert(sig);
		}
Beispiel #20
0
        public void CreateStandardLibrary(TypesTable tt)
        {
            lib = tt.Library;
            Namespace ns = lib.RootNamespace;

            // add default template / generic operation
            lib.DefaultLazyOperation = (c) => {
                // oclAsSet is problem on Set type (infinity recursion)
                if (c is CollectionType == false)
                {
                    CollectionType set = lib.CreateCollection(CollectionKind.Set, c, true, tt.defferedCollectionList);
                    AddOperation(c, Library.OclAsSet, set);
                }
            };

            Classifier oclAny = new Classifier(tt, ns, lib.TypeName.Any);

            InsertClassifier(oclAny);
            Classifier real = new Classifier(tt, ns, lib.TypeName.Real, oclAny);

            InsertClassifier(real);
            Classifier integer = new Classifier(tt, ns, lib.TypeName.Integer, real);

            InsertClassifier(integer);
            Classifier unlimited = new Classifier(tt, ns, lib.TypeName.UnlimitedNatural, integer);

            InsertClassifier(unlimited);
            Classifier str = new Classifier(tt, ns, lib.TypeName.String, oclAny);

            InsertClassifier(str);
            Classifier boolean = new Classifier(tt, ns, lib.TypeName.Boolean, oclAny);

            InsertClassifier(boolean);
            Classifier message = new Classifier(tt, ns, lib.TypeName.Message, oclAny);

            InsertClassifier(message);
            Classifier type = new Classifier(tt, ns, lib.TypeName.Type, oclAny);

            InsertClassifier(type);

            Classifier voidT = new VoidType(tt, lib.TypeName.Void);

            InsertClassifier(voidT);
            Classifier invalid = new InvalidType(tt, lib.TypeName.Invalid);

            InsertClassifier(invalid);

            //OCLAny
            AddOperation(oclAny, "=", boolean, oclAny);
            AddOperation(oclAny, "<>", boolean, oclAny);
            AddOperation(oclAny, "oclIsUndefined", boolean);
            AddOperation(oclAny, "oclIsInvalid", boolean);
            //AddOperation(oclAny, "oclAsType", boolean);
            {
                Operation oclAsTypeOp = new Operation(@"oclAsType", true, tt.Library.Any,
                                                      new Parameter[] { new Parameter("type", tt.Library.Type) });
                oclAsTypeOp.ReturnTypeDependsOnArguments = true;
                oclAny.Operations.Add(oclAsTypeOp);
            }
            AddOperation(oclAny, "oclIsNew", boolean);

            //par dalsi operaci chybi

            //Real
            AddOperation(real, "+", real, real);
            AddOperation(real, "-", real, real);
            AddOperation(real, "*", real, real);
            AddOperation(real, "/", real, real);
            AddOperation(real, "-", real);
            AddOperation(real, "abs", real);
            AddOperation(real, "floor", real);
            AddOperation(real, "round", real);
            AddOperation(real, "max", real, real);
            AddOperation(real, "min", real, real);
            AddOperation(real, "<", boolean, real);
            AddOperation(real, ">", boolean, real);
            AddOperation(real, "<=", boolean, real);
            AddOperation(real, ">=", boolean, real);
            AddOperation(real, "toString", str);

            //integer
            AddOperation(integer, "+", integer, integer);
            AddOperation(integer, "-", integer, integer);
            AddOperation(integer, "*", integer, integer);
            AddOperation(integer, "/", integer, real);
            AddOperation(integer, "-", integer);
            AddOperation(integer, "abs", integer);
            AddOperation(integer, "div", integer, integer);
            AddOperation(integer, "mod", integer, integer);
            AddOperation(integer, "min", integer, integer);
            AddOperation(integer, "max", integer, integer);
            AddOperation(integer, "toString", str);

            //string
            AddOperation(str, "+", str, str);
            AddOperation(str, "size", integer);
            AddOperation(str, "concat", str, str);
            AddOperation(str, "substring", str, integer, integer);
            AddOperation(str, "toInteger", integer);
            AddOperation(str, "toReal", real);
            AddOperation(str, "toBoolean", boolean);
            AddOperation(str, "toUpperCase", str);
            AddOperation(str, "toLowerCase", str);
            AddOperation(str, "indexOf", integer, str);
            AddOperation(str, "equalsIgnoreCase", str, boolean);
            AddOperation(str, "at", str, integer);
            AddOperation(str, "<", str, boolean);
            AddOperation(str, ">", str, boolean);
            AddOperation(str, "<=", str, boolean);
            AddOperation(str, ">=", str, boolean);

            // string - non standard (known in XPath)
            AddOperation(str, "substring-before", str, str);
            AddOperation(str, "substring-after", str, str);
            AddOperation(str, "matches", str, str);
            AddOperation(str, "starts-with", str, str);
            AddOperation(str, "ends-with", str, str);


            //boolean
            AddOperation(boolean, "or", boolean, boolean);
            AddOperation(boolean, "xor", boolean, boolean);
            AddOperation(boolean, "and", boolean, boolean);
            AddOperation(boolean, "not", boolean);
            AddOperation(boolean, "implies", boolean, boolean);
            AddOperation(boolean, "toString", str);

            #region lazy operations
            lib.LazyOperation.Add(typeof(Classifier), (c) => {
            });

            lib.LazyOperation.Add(typeof(CollectionType), (c) => {
                CollectionType coll = c as CollectionType;
                Classifier t        = coll.ElementType;

                AddOperation(coll, "=", boolean, coll);
                AddOperation(coll, "<>", boolean, coll);
                AddOperation(coll, "size", integer);
                AddOperation(coll, "includes", boolean, coll.ElementType);
                AddOperation(coll, "excludes", boolean, coll.ElementType);
                AddOperation(coll, "count", integer, coll.ElementType);
                AddOperation(coll, "includesAll", boolean, coll);
                AddOperation(coll, "excludesAll", boolean, coll);
                AddOperation(coll, "isEmpty", boolean);
                AddOperation(coll, "notEmpty", boolean);

                /* TODO: musi splnovat nektere podminky (zatim nekontrolujeme) */
                AddOperation(coll, "sum", t);
                AddOperation(coll, "max", t);
                AddOperation(coll, "min", t);

                //Missing: product, asSet, asOrdredSet,as  sequence,asBag, flatten
            });


            //Added by J.M. 2.3.2012, should not be under CollectionType
            //AddOperation(coll, "at", coll.ElementType, integer);
            //AddOperation(coll, "first", coll.ElementType);
            //AddOperation(coll, "last", coll.ElementType);
            lib.LazyOperation.Add(typeof(SetType), (c) => {
                CollectionType coll = c as CollectionType;
                Classifier t        = coll.ElementType;

                AddOperation(coll, "union", coll, coll);
                //union with bag missing
                AddOperation(coll, "=", boolean, coll);
                AddOperation(coll, "intersection", coll, coll);
                //intersection with bag missing
                AddOperation(coll, "-", coll, coll);
                AddOperation(coll, "including", coll, t);
                AddOperation(coll, "excluding", coll, t);
                AddOperation(coll, "symmetricDifference", coll, coll);
                AddOperation(coll, "count", integer, t);
                //flatten missing
                AddOperation(coll, "asSet", coll);
                //asOrderedSet(),asSequence(),asBag() missing
            });

            lib.LazyOperation.Add(typeof(SequenceType), (c) => {
                CollectionType coll = c as CollectionType;
                Classifier t        = coll.ElementType;

                AddOperation(coll, "count", integer, t);
                AddOperation(coll, "=", boolean, coll);
                SetType set = (SetType)lib.CreateCollection(CollectionKind.Set, t, true, tt.defferedCollectionList);

                AddOperation(coll, "union", coll, coll);
                //flatten missing
                AddOperation(coll, "append", coll, t);
                AddOperation(coll, "prepend", coll, t);
                AddOperation(coll, "insertAt", coll, integer, t);
                AddOperation(coll, "subSequence", coll, integer, integer);
                AddOperation(coll, "at", coll.ElementType, integer);
                AddOperation(coll, "indexOf", integer, t);
                AddOperation(coll, "first", coll.ElementType);
                AddOperation(coll, "last", coll.ElementType);
                AddOperation(coll, "including", coll, t);
                AddOperation(coll, "excluding", coll, t);
                AddOperation(coll, "reverse", coll, t);
                AddOperation(coll, "asSequence", coll, t);
                AddOperation(coll, "asSet", set);
                //asOrderedSet(),asBag(),asSet() missing
            });

            lib.LazyOperation.Add(typeof(BagType), (c) =>
            {
                CollectionType coll = c as CollectionType;
                Classifier t        = coll.ElementType;
                SetType set         = (SetType)lib.CreateCollection(CollectionKind.Set, t, true, tt.defferedCollectionList);
                AddOperation(coll, "asSet", set);
                //asOrderedSet(),asBag(),asSet() missing
            });

            #endregion

            // after lazy operations are defined can we use collection types
            CollectionType strSeq = lib.CreateCollection(CollectionKind.Sequence, str, true, tt.defferedCollectionList);
            tt.RegisterType(strSeq);
            AddOperation(str, "characters", strSeq);
            AddOperation(str, "tokenize", strSeq, str);

            tt.PerformDeferredInitializations();
        }
Beispiel #21
0
 ///<summary>Called every time timerSignals_Tick fires.  Usually about every 5-10 seconds.</summary>
 public void ProcessSignals()
 {
     try {
         List<Signalod> sigList=Signalods.RefreshTimed(signalLastRefreshed);//this also attaches all elements to their sigs
         if(sigList.Count==0) {
             return;
         }
         if(Security.CurUser==null) {
             return;
         }
         //look for shutdown signal
         for(int i=0;i<sigList.Count;i++) {
             if(sigList[i].ITypes==((int)InvalidType.ShutDownNow).ToString()) {
                 timerSignals.Enabled=false;//quit receiving signals.
                 //close the webcam if present so that it can be updated too.
                 if(PrefC.GetBool(PrefName.DockPhonePanelShow)) {
                     Process[] processes=Process.GetProcessesByName("WebCamOD");
                     for(int p=0;p<processes.Length;p++) {
                         processes[p].Kill();
                     }
                 }
                 //start the thread that will kill the application
                 Thread killThread=new Thread(new ThreadStart(KillThread));
                 killThread.Start();
                 string msg="";
                 if(Process.GetCurrentProcess().ProcessName=="OpenDental") {
                     msg+="All copies of Open Dental ";
                 }
                 else {
                     msg+=Process.GetCurrentProcess().ProcessName+" ";
                 }
                 msg+=Lan.g(this,"will shut down in 15 seconds.  Quickly click OK on any open windows with unsaved data.");
                 MsgBoxCopyPaste msgbox=new MsgBoxCopyPaste(msg);
                 msgbox.Size=new Size(300,300);
                 msgbox.TopMost=true;
                 msgbox.ShowDialog();
                 return;
             }
         }
         if(sigList[sigList.Count-1].AckTime.Year>1880) {
             signalLastRefreshed=sigList[sigList.Count-1].AckTime;
         }
         else {
             signalLastRefreshed=sigList[sigList.Count-1].SigDateTime;
         }
         if(ContrAppt2.Visible && Signalods.ApptNeedsRefresh(sigList,AppointmentL.DateSelected.Date)) {
             ContrAppt2.RefreshPeriod();
         }
         bool areAnySignalsTasks=false;
         for(int i=0;i<sigList.Count;i++) {
             if(sigList[i].ITypes==((int)InvalidType.Task).ToString()
                 || sigList[i].ITypes==((int)InvalidType.TaskPopup).ToString()) {
                 areAnySignalsTasks=true;
             }
         }
         List<Task> tasksPopup=Signalods.GetNewTaskPopupsThisUser(sigList,Security.CurUser.UserNum);
         if(tasksPopup.Count>0) {
             for(int i=0;i<tasksPopup.Count;i++) {
                 //Even though this is triggered to popup, if this is my own task, then do not popup.
                 List<TaskNote> notesForThisTask=TaskNotes.GetForTask(tasksPopup[i].TaskNum);
                 if(notesForThisTask.Count==0) {//'sender' is the usernum on the task
                     if(tasksPopup[i].UserNum==Security.CurUser.UserNum) {
                         continue;
                     }
                 }
                 else {//'sender' is the user on the last added note
                     if(notesForThisTask[notesForThisTask.Count-1].UserNum==Security.CurUser.UserNum) {
                         continue;
                     }
                 }
                 if(tasksPopup[i].TaskListNum!=Security.CurUser.TaskListInBox//if not my inbox
                     && userControlTasks1.PopupsAreBlocked)//and popups blocked
                 {
                     continue;//no sound or popup
                     //in other words, popups will always show for my inbox even if popups blocked.
                 }
                 System.Media.SoundPlayer soundplay=new SoundPlayer(Properties.Resources.notify);
                 soundplay.Play();
                 this.BringToFront();//don't know if this is doing anything.
                 FormTaskEdit FormT=new FormTaskEdit(tasksPopup[i],tasksPopup[i].Copy());
                 FormT.IsPopup=true;
                 FormT.Closing+=new CancelEventHandler(TaskGoToEvent);
                 FormT.Show();//non-modal
             }
         }
         if(areAnySignalsTasks || tasksPopup.Count>0) {
             //if user has the Task dialog open, we can't easily tell it to refresh,
             //So that dialog is responsible for auto refreshing every minute on a timer.
             //Improve this.
             if(userControlTasks1.Visible) {
                 userControlTasks1.RefreshTasks();
             }
         }
         List<int> itypes=Signalods.GetInvalidTypes(sigList);
         InvalidType[] itypeArray=new InvalidType[itypes.Count];
         for(int i=0;i<itypeArray.Length;i++) {
             itypeArray[i]=(InvalidType)itypes[i];
         }
         //InvalidTypes invalidTypes=Signalods.GetInvalidTypes(sigList);
         if(itypes.Count>0) {//invalidTypes!=0){
             RefreshLocalData(itypeArray);
         }
         List<Signalod> sigListButs=Signalods.GetButtonSigs(sigList);
         ContrManage2.LogMsgs(sigListButs);
         FillSignalButtons(sigListButs);
         //Need to add a test to this: do not play messages that are over 2 minutes old.
         Thread newThread=new Thread(new ParameterizedThreadStart(PlaySounds));
         newThread.Start(sigListButs);
     }
     catch {
         signalLastRefreshed=DateTime.Now;
     }
 }
Beispiel #22
0
 public void AddItem(Control _control, string _name, string _invalidMessage, InvalidType _invalidType, string _invalidRules)
 {
     AddItem(_control, _name, true, _invalidMessage, _invalidType, _invalidRules, EN_CH.EN, null);
 }
Beispiel #23
0
 public InvalidItem(InvalidType type, string message, object attach)
 {
     this.InvalidType = type;
     Message          = message;
     Attach           = attach;
 }
Beispiel #24
0
 ///<summary>This is called when any local data becomes outdated.  It's purpose is to tell the other computers to update certain local data.</summary>
 private void DataValid_BecameInvalid(OpenDental.ValidEventArgs e)
 {
     if(e.OnlyLocal){
         if(!PrefsStartup()){//??
             return;
         }
         RefreshLocalData(InvalidType.AllLocal);//does local computer only
         return;
     }
     if(!e.ITypes.Contains((int)InvalidType.Date)
         && !e.ITypes.Contains((int)InvalidType.Task)
         && !e.ITypes.Contains((int)InvalidType.TaskPopup)){
         //local refresh for dates is handled within ContrAppt, not here
         InvalidType[] itypeArray=new InvalidType[e.ITypes.Count];
         for(int i=0;i<itypeArray.Length;i++){
             itypeArray[i]=(InvalidType)e.ITypes[i];
         }
         RefreshLocalData(itypeArray);//does local computer
     }
     string itypeString="";
     for(int i=0;i<e.ITypes.Count;i++){
         if(i>0){
             itypeString+=",";
         }
         itypeString+=e.ITypes[i].ToString();
     }
     Signalod sig=new Signalod();
     sig.ITypes=itypeString;
     if(e.ITypes.Contains((int)InvalidType.Date)){
         sig.DateViewing=e.DateViewing;
     }
     else{
         sig.DateViewing=DateTime.MinValue;
     }
     sig.SigType=SignalType.Invalid;
     if(e.ITypes.Contains((int)InvalidType.Task) || e.ITypes.Contains((int)InvalidType.TaskPopup)){
         sig.TaskNum=e.TaskNum;
     }
     Signalods.Insert(sig);
 }
Beispiel #25
0
        public void AddItem(Control _control, string _name, bool _required, string _invalidMessage, InvalidType _invalidType, string _invalidRules, EN_CH _inputMethod, object _defaultValue)
        {
            FormItem item = new FormItem();

            item.controlItem    = _control;
            item.controlName    = _name;
            item.required       = _required;
            item.invalidMessage = _invalidMessage;
            item.invalidType    = _invalidType;
            item.InvalidRules   = _invalidRules;
            item.inputMethod    = _inputMethod;
            item.defaultValue   = _defaultValue;

            _control.Enter += new EventHandler(_control_Enter);
            _control.KeyUp += new KeyEventHandler(_control_KeyUp);
            itemlist.Add(item);
        }