public bool Equals(JniValueMarshalerState other)
 {
     return(JniArgumentValue.Equals(other.JniArgumentValue) &&
            ReferenceValue.Equals(other.ReferenceValue) &&
            object.ReferenceEquals(PeerableValue, other.PeerableValue) &&
            object.ReferenceEquals(Extra, other.Extra));
 }
Beispiel #2
0
        /// <summary>
        /// Overriden. Returns a hash code for the current Object.
        /// </summary>
        /// <returns>A hash code for the current Object.</returns>
        public override int GetHashCode()
        {
            switch (ValueType)
            {
            case ValueTypeDefinitionData.Reference:
                return(ReferenceValue.GetHashCode());

            case ValueTypeDefinitionData.DateTime:
                return(DateTimeValue.GetHashCode());

            case ValueTypeDefinitionData.Bool:
                return(BoolValue.GetHashCode());

            case ValueTypeDefinitionData.Float:
                return(FloatValue.GetHashCode());

            case ValueTypeDefinitionData.Int:
                return(IntValue.GetHashCode());

            case ValueTypeDefinitionData.StringNonUnicode:
                return(StringNonUnicodeValue.GetHashCode());

            default:
                return(base.GetHashCode());
            }
        }
        public async Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.ReferenceValues.Any())
            {
                if (dbContext.ReferenceValues.Any(x => x.Units == null))
                {
                    await AddMeasuringUnits(dbContext);

                    return;
                }

                return;
            }

            var referenceValueNames = new List <string> {
                "Albumin", "Globulin", "ALT", "AST", "g-GT", "Urea", "Creatinine", "Glucose",
            };

            var dogMaxReferenceValues = new List <decimal> {
                44, 52, 118, 48.5m, 7, 8.9m, 124, 7.95m
            };

            var dogMinReferenceValues = new List <decimal> {
                25, 23, 10, 8.9m, 0, 2.5m, 27, 3.89m
            };

            var catMaxReferenceValues = new List <decimal> {
                45, 57, 100, 43m, 2, 10.7m, 141, 8.3m
            };

            var catMinReferenceValues = new List <decimal> {
                27, 15, 20, 12, 0, 3.6m, 27, 3.9m
            };

            for (int i = 0; i < referenceValueNames.Count; i++)
            {
                var referenceValue = new ReferenceValue
                {
                    Name       = referenceValueNames[i],
                    AnimalType = dbContext.AnimalTypes.FirstOrDefault(at => at.Name == "Dog"),
                    MaxValue   = dogMaxReferenceValues[i],
                    MinValue   = dogMinReferenceValues[i],
                };

                await dbContext.AddAsync(referenceValue);
            }

            for (int i = 0; i < referenceValueNames.Count; i++)
            {
                var referenceValue = new ReferenceValue
                {
                    Name       = referenceValueNames[i],
                    AnimalType = dbContext.AnimalTypes.FirstOrDefault(at => at.Name == "Cat"),
                    MaxValue   = catMaxReferenceValues[i],
                    MinValue   = catMinReferenceValues[i],
                };

                await dbContext.AddAsync(referenceValue);
            }
        }
Beispiel #4
0
 public bool Equals(JniValueMarshalerState value)
 {
     return(JniArgumentValue.Equals(value.JniArgumentValue) &&
            ReferenceValue.Equals(value.ReferenceValue) &&
            object.ReferenceEquals(PeerableValue, value.PeerableValue) &&
            object.ReferenceEquals(Extra, value.Extra));
 }
Beispiel #5
0
        public void Provision(MVEntry mventry)
        {
            string          maName = "ADMA";
            ManagementAgent ma     = mventry.ConnectedMAs[maName];

            //begin  changes
            if (mventry.ConnectedMAs[maName].Connectors.Count == 0)
            {
                //provision new AD object
                if (mventry["uid"].IsPresent && mventry["accountName"].IsPresent && mventry["ou"].IsPresent)
                {
                    string         cn        = string.Format("CN={0}", mventry["uid"].StringValue);
                    ReferenceValue dn        = mventry.ConnectedMAs[maName].EscapeDNComponent(cn).Concat(mventry["ou"].StringValue);
                    CSEntry        adCSentry = mventry.ConnectedMAs[maName].Connectors.StartNewConnector("user");
                    adCSentry.DN = dn;
                    string pwd = GenerateRandomString(32);
                    adCSentry["unicodePwd"].Value = pwd;
                    //Log.Debug(pwd);
                    adCSentry["SamAccountName"].StringValue = mventry["AccountName"].StringValue;
                    adCSentry.CommitNewConnector();
                }
            }
            else
            {
                //rename existing AD object
                CSEntry        adCSentry = mventry.ConnectedMAs[maName].Connectors.ByIndex[0];
                ReferenceValue newDn     = mventry.ConnectedMAs[maName].EscapeDNComponent(string.Format("Cn={0}", mventry["uid"].StringValue)).Concat(mventry["ou"].StringValue);
                adCSentry.DN = newDn;
            }
        }
        public ProgramState execute(ProgramState state)
        {
            if (state.GetSymTable().ContainsKey(id))
            {
                throw new Exception("Variable already declared!\n");
            }
            Value.Value val = null;
            if (type.HasSameType(new IntType()))
            {
                val = new IntValue(0);
            }
            else if (type.HasSameType(new BoolType()))
            {
                val = new BoolValue(false);
            }
            else if (type.HasSameType(new StringType()))
            {
                val = new StringValue("");
            }
            else
            {
                val = new ReferenceValue(0, ((ReferenceType)type).getInner());
            }
            state.GetSymTable()[id] = val;

            return(null);
        }
Beispiel #7
0
 public override string ToString()
 {
     return(string.Format("JniValueMarshalerState({0}, ReferenceValue={1}, PeerableValue=0x{2}, Extra={3})",
                          JniArgumentValue.ToString(),
                          ReferenceValue.ToString(),
                          RuntimeHelpers.GetHashCode(PeerableValue).ToString("x"),
                          Extra));
 }
Beispiel #8
0
 public Option(ReferenceValue <bool> boolReference, string optionName)
 {
     type = typeof(bool);
     name = optionName;
     this.boolReference  = boolReference;
     this.floatReference = new ReferenceValue <float>(() => 0f, v => { });
     minValue            = 0f;
     maxValue            = 0f;
 }
Beispiel #9
0
 public Variable GetVariableFromReference(ReferenceValue reference)
 {
     Variable result;
     if(!TryGetVariableFromReference(reference, out result))
     {
         throw new KeyNotFoundException(string.Format("No variable from reference '{0}'.", reference));
     }
     return result;
 }
Beispiel #10
0
 public Option(ReferenceValue <float> floatReference, string optionName, float min = 0f, float max = 1f)
 {
     type = typeof(float);
     name = optionName;
     this.boolReference  = new ReferenceValue <bool>(() => false, v => { });
     this.floatReference = floatReference;
     minValue            = min;
     maxValue            = max;
 }
        /// <summary>
        /// Constructor used internal
        /// </summary>
        /// <param name="referenceValue">referencevalue</param>
        internal ComplexType(ReferenceValue referenceValue)
        {
            if (referenceValue == null)
            {
                throw new ArgumentNullException();
            }

            this.referenceValue = referenceValue;
        }
Beispiel #12
0
 private bool AreDNsEqual(ReferenceValue dn1, ReferenceValue dn2, ManagementAgent ma, bool strictCompare)
 {
     if (strictCompare)
     {
         Tracer.TraceInformation("performing-strict-DN-comparison");
         return(dn1.ToString() == dn2.ToString());
     }
     else
     {
         Tracer.TraceInformation("performing-RFC-compliant-DN-comparison");
         return(dn1.Equals(dn2));
     }
 }
Beispiel #13
0
 public override BloodPressureQuery AddValueFilter(string parameterName, ReferenceValue value)
 {
     if (parameterName == "subject")
     {
         var patIdValue = value.Reference.StripFromStart("Patient/");
         if (!int.TryParse(patIdValue, out var patId))
         {
             throw new ArgumentException("Patient Id must be an integer value");
         }
         return(PredicateQuery(bp => bp.PatientId == patId));
     }
     return(base.AddValueFilter(parameterName, value));
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (valueTypeCase_ == ValueTypeOneofCase.NullValue)
            {
                hash ^= NullValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.BooleanValue)
            {
                hash ^= BooleanValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.IntegerValue)
            {
                hash ^= IntegerValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.DoubleValue)
            {
                hash ^= DoubleValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.TimestampValue)
            {
                hash ^= TimestampValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.StringValue)
            {
                hash ^= StringValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.BytesValue)
            {
                hash ^= BytesValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.ReferenceValue)
            {
                hash ^= ReferenceValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.GeoPointValue)
            {
                hash ^= GeoPointValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.ArrayValue)
            {
                hash ^= ArrayValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.MapValue)
            {
                hash ^= MapValue.GetHashCode();
            }
            hash ^= (int)valueTypeCase_;
            return(hash);
        }
        internal static bool Compare(MVEntry mventry, CSEntry csentry, string csattributeName, string mvattributeName)
        {
            ReferenceValue csval = null;
            ReferenceValue mvval = null;

            Attrib mvAttrib = mventry[mvattributeName];

            if (csattributeName == "[DN]")
            {
                csval = csentry.DN;
            }
            else
            {
                Attrib csAttrib = csentry[csattributeName];

                if (!csAttrib.IsPresent && !mvAttrib.IsPresent)
                {
                    return(true);
                }

                if (csAttrib.IsPresent ^ mvAttrib.IsPresent)
                {
                    return(false);
                }

                switch (csAttrib.DataType)
                {
                case AttributeType.Reference:
                    csval = csAttrib.ReferenceValue;
                    break;

                case AttributeType.String:
                    csval = csentry.MA.CreateDN(csAttrib.StringValue);
                    break;

                default:
                    Tracer.TraceError("Can only compare string values as DNs");
                    return(false);
                }
            }

            if (mvAttrib.DataType != AttributeType.String)
            {
                Tracer.TraceError("Can only compare string values as DNs");
            }

            mvval = csentry.MA.CreateDN(mvAttrib.StringValue);

            return(mvval.Equals(csval));
        }
Beispiel #16
0
        private void ConditionalRenameConnector(ConnectedMA ma, CSEntry csentry, MVEntry mventry, Rule connectorRule)
        {
            Tracer.TraceInformation("enter-conditionalrenameconnector");
            try
            {
                if (connectorRule.ConditionalRename == null)
                {
                    return;
                }

                string escapedCN     = null;
                string replacedValue = null;
                if (string.IsNullOrEmpty(connectorRule.ConditionalRename.EscapedCN))
                {
                    Tracer.TraceInformation("no-cn-to-escape");
                    replacedValue = connectorRule.ConditionalRename.NewDNValue.ReplaceWithMVValueOrBlank(mventry);
                }
                else
                {
                    escapedCN = ma.EscapeDNComponent(connectorRule.ConditionalRename.EscapedCN.ReplaceWithMVValueOrBlank(mventry, "")).ToString();
                    Tracer.TraceInformation("escaped-cn {0}", escapedCN);
                    replacedValue = connectorRule.ConditionalRename.NewDNValue.ReplaceWithMVValueOrBlank(mventry, escapedCN);
                }

                ReferenceValue newdn = ma.CreateDN(replacedValue);
                ReferenceValue olddn = ma.CreateDN(csentry.DN.ToString());
                Tracer.TraceInformation("old-dn '{0}'", olddn.ToString());
                Tracer.TraceInformation("new-dn '{0}'", newdn.ToString());

                if (this.AreDNsEqual(olddn, newdn, ma, connectorRule.ConditionalRename.StrictDNCompare))
                {
                    Tracer.TraceInformation("no-renaming-necessary");
                }
                else
                {
                    Tracer.TraceInformation("dn-rename-required");
                    csentry.DN = newdn;
                }
            }
            catch (Exception ex)
            {
                Tracer.TraceError("error {0}", ex.GetBaseException());
                throw;
            }
            finally
            {
                Tracer.TraceInformation("exit-conditionalrenameconnector");
            }
        }
        public void HandleReferenceParam()
        {
            var p1 = new ReferenceValue("2");

            Assert.AreEqual("2", p1.Value);

            var p2 = new ReferenceValue("http://server.org/fhir/Patient/1");

            Assert.AreEqual("http://server.org/fhir/Patient/1", p2.Value);

            var crit = Criterium.Parse(@"paramX=http://server.org/\$4/fhir/Patient/1");
            var p3   = ((UntypedValue)crit.Operand).AsReferenceValue();

            Assert.AreEqual("http://server.org/$4/fhir/Patient/1", p3.Value);
        }
Beispiel #18
0
        public override bool IsLessThan(ReferenceValue obj)
        {
            bool result;

            if (obj is PointerToElementValue)
            {
                PointerToElementValue ptr = obj as PointerToElementValue;
                result = arr == ptr.arr && index < ptr.index;
            }
            else
            {
                result = false;
            }

            return(result);
        }
Beispiel #19
0
        /// <summary>
        /// Determines whether the specified PropertyInstanceValueData is equal to the current PropertyInstanceValueData.
        /// </summary>
        /// <param name="that">The PropertyInstanceValueData to compare with the current object.</param>
        /// <returns>Returns true if the specified object has the same value type and same vale as the current PropertyInstanceValueData; otherwise false.</returns>
        public virtual bool Equals(PropertyInstanceValueData that)
        {
            // if that is null - not equal
            if (ReferenceEquals(that, null))
            {
                return(false);
            }

            // if that is has same reference to me - equal
            if (ReferenceEquals(this, that))
            {
                return(true);
            }

            // if that has a different value type than me - not equal
            if (ValueType != that.ValueType)
            {
                return(false);
            }

            // finally - if that has the same actual value as me - equal (otherwise, not equal)
            switch (ValueType)
            {
            case ValueTypeDefinitionData.Reference:
                return(ReferenceValue.Equals(that.ReferenceValue));

            case ValueTypeDefinitionData.DateTime:
                return(DateTimeValue.Equals(that.DateTimeValue));

            case ValueTypeDefinitionData.Bool:
                return(BoolValue == that.BoolValue);

            case ValueTypeDefinitionData.Float:
                return(FloatValue == that.FloatValue);

            case ValueTypeDefinitionData.Int:
                return(IntValue == that.IntValue);

            case ValueTypeDefinitionData.StringNonUnicode:
                return(StringNonUnicodeValue.Equals(that.StringNonUnicodeValue));

            default:
                return(false);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Recupera o valor de referência.
        /// </summary>
        /// <param name="referenceValue">Dados da referência do valor.</param>
        /// <returns></returns>
        public double GetValue(ReferenceValue referenceValue)
        {
            if (string.IsNullOrEmpty(referenceValue.Path))
            {
                return(0.0);
            }

            // Quebra o caminho da referencias em partes
            var parts = referenceValue.Path.Split('/');

            if (parts.Length < 3)
            {
                return(0);
            }

            AsseguraInicializacao();

            var fabricante    = parts[0];
            var ferragem      = parts[1];
            var nomeConstante = parts[2];

            Constante constante = null;

            lock (_itens)
            {
                var item = _itens.FirstOrDefault(f =>
                                                 StringComparer.InvariantCultureIgnoreCase.Equals(f.Fabricante, fabricante) &&
                                                 StringComparer.InvariantCultureIgnoreCase.Equals(f.Nome, ferragem));

                if (item != null)
                {
                    constante = item.Constantes.FirstOrDefault(f => StringComparer.InvariantCultureIgnoreCase.Equals(f.Nome, nomeConstante));
                }
            }

            if (constante != null)
            {
                return(constante.Valor);
            }

            return(referenceValue.DefaultValue);
        }
Beispiel #21
0
        internal void Create(string referencePath, IHDDFileReaderWriter readerWriter)
        {
            // ttr sample1:
            ReferenceValue refVal1 = new ReferenceValue("Thickness Average", Units.um, 200);
            ReferenceValue refVal2 = new ReferenceValue("Thickness Std", Units.um, 2);
            ReferenceValue refVal3 = new ReferenceValue("Resistivity Average", Units.Ohmcm, 1.5);

            List <IReferenceValue> referenceValues1 = new List <IReferenceValue> {
                refVal1, refVal2, refVal3
            };
            ReferenceSample referenceSample1 = new ReferenceSample("TTR Reference 01", referenceValues1);

            readerWriter.WriteToFile(referenceSample1, Path.Combine(referencePath, $"TTR_Ref_01{_fileExtension}"));


            // ttr sample2:
            ReferenceValue refVal11 = new ReferenceValue("Thickness Average", Units.um, 190);
            ReferenceValue refVal12 = new ReferenceValue("Thickness Std", Units.um, 2);
            ReferenceValue refVal13 = new ReferenceValue("Resistivity Average", Units.Ohmcm, 1.4);

            List <IReferenceValue> referenceValues11 = new List <IReferenceValue> {
                refVal11, refVal12, refVal13
            };
            ReferenceSample referenceSample11 = new ReferenceSample("TTR Reference 02", referenceValues11);

            readerWriter.WriteToFile(referenceSample11, Path.Combine(referencePath, $"TTR_Ref_02{_fileExtension}"));


            // ttr sample2:
            ReferenceValue refVal21 = new ReferenceValue("Thickness Average", Units.um, 210);
            ReferenceValue refVal22 = new ReferenceValue("Thickness Std", Units.um, 2);
            ReferenceValue refVal23 = new ReferenceValue("Resistivity Average", Units.Ohmcm, 1.6);

            List <IReferenceValue> referenceValues21 = new List <IReferenceValue> {
                refVal21, refVal22, refVal23
            };

            ReferenceSample referenceSample21 = new ReferenceSample("TTR Reference 03", referenceValues21);

            readerWriter.WriteToFile(referenceSample21, Path.Combine(referencePath, $"TTR_Ref_03{_fileExtension}"));
        }
        public override string ToString()
        {
            string valueString = "";

            if (ReferenceValue == null)
            {
                valueString = "null";
            }
            else if (ReferenceValue.ToString().Contains("BH.oM") && !(ReferenceValue is Type))
            {
                valueString = ReferenceValue.GetType().GetProperty("Name").GetValue(ReferenceValue) as string;
            }

            valueString = string.IsNullOrWhiteSpace(valueString) ? ReferenceValue.ToString() : valueString;

            // Make the text in the ValueComparisons more readable (remove camelCase and add spaces)
            string comparisonText = Comparison.ToString();
            var    builder        = new System.Text.StringBuilder();

            foreach (char c in comparisonText)
            {
                if (Char.IsUpper(c) && builder.Length > 0)
                {
                    builder.Append(' ');
                }
                builder.Append(Char.ToLower(c));
            }
            comparisonText = builder.ToString();

            if (string.IsNullOrWhiteSpace(PropertyName) && ReferenceValue is System.Type)
            {
                return($"must be of type `{(ReferenceValue as Type).Name}`");
            }

            return($"{PropertyName} {comparisonText} {valueString}");
        }
Beispiel #23
0
 public virtual bool IsLessThan(ReferenceValue obj)
 {
     return false;
 }
Beispiel #24
0
 public virtual bool IsGreaterThan(ReferenceValue obj)
 {
     return obj is NullValue;
 }
        void IMVSynchronization.Provision(MVEntry mventry)
        {
            //get our provisioning ma from the db
            string provisioningMAName = FIMConfiguration.GetProvisioningMA()["ma_name"].ToString();

            XmlDocument xmldoc     = FIMConfiguration.GetConfigXML(provisioningMAName, "private_configuration_xml");
            XmlNodeList attributes = xmldoc.SelectNodes("//MAConfig/parameter-values/parameter");

            //loop through each MA/object type selected
            foreach (XmlNode attrib in attributes)
            {
                string param      = attrib.Attributes["name"].Value;
                string maName     = param.Substring(0, param.LastIndexOf(" - "));
                string objectType = param.Substring(param.LastIndexOf(" - ") + 3);

                //if enabled, provision it
                if (attrib.InnerText.Equals("1"))
                {
                    //our ma has been enabled for provisioning, create a new csentry and add initial flows
                    ConnectedMA ma = mventry.ConnectedMAs[maName];

                    if (ma.Connectors.Count == 0)
                    {
                        CSEntry csentry = ma.Connectors.StartNewConnector(objectType);

                        //go and get the real anchor info, our provisioning ma
                        //uses a generic anchor to ensure tha flows can be
                        //defined for the actual anchor
                        XmlDocument maSchemaConfig = FIMConfiguration.GetConfigXML(maName, "dn_construction_xml");
                        XmlNode     maSchemaRoot   = maSchemaConfig.FirstChild;

                        //get dn for the object
                        List <string> anchors = new List <string>();
                        if (maSchemaRoot.FirstChild.Name.Equals("attribute", StringComparison.InvariantCultureIgnoreCase))
                        {
                            XmlNodeList anchorList = maSchemaConfig.SelectNodes("//dn-construction/attribute");

                            foreach (XmlNode anchor in anchorList)
                            {
                                anchors.Add(anchor.InnerText);
                            }
                        }
                        else
                        {
                            XmlNodeList anchorList = maSchemaConfig.SelectNodes("//dn-construction/dn[@object-type='" + objectType + "']/attribute");

                            foreach (XmlNode anchor in anchorList)
                            {
                                anchors.Add(anchor.InnerText);
                            }
                        }

                        //our export schema defines the initial attributes to flow
                        XmlDocument xmlFlows = FIMConfiguration.GetConfigXML(provisioningMAName, "export_attribute_flow_xml");
                        XmlNodeList flows    = xmlFlows.SelectNodes("//export-attribute-flow/export-flow-set[@cd-object-type='" + maName + "']/export-flow");

                        foreach (XmlNode flow in flows)
                        {
                            //get the mapping for each flow defined and provision an initial flow
                            string csAttribName = flow.Attributes["cd-attribute"].Value;
                            csAttribName = csAttribName.Substring(csAttribName.LastIndexOf(" - ") + 3);

                            XmlNode         mappingNode = flow.FirstChild;
                            string          mappingType = mappingNode.Name;
                            string          flowValue   = null;
                            ValueCollection flowValues  = null;

                            switch (mappingType)
                            {
                            case "direct-mapping":

                                string mvAttribName = mappingNode.FirstChild.InnerText;

                                if (mventry[mvAttribName].IsPresent)
                                {
                                    if (mventry[mvAttribName].IsMultivalued)
                                    {
                                        flowValues = mventry[mvAttribName].Values;
                                    }
                                    else
                                    {
                                        //TODO: convert this to its proper type if necessary (i.e. int, boolean, etc)
                                        flowValue = mventry[mvAttribName].Value;
                                    }
                                }
                                break;

                            case "constant-mapping":
                                flowValue = mappingNode.FirstChild.InnerText;
                                break;

                            case "scripted-mapping":
                                break;

                            default:
                                throw new Exception("Unexpected mapping type encountered. Only Direct, Constant and Advanced/Scripted flows are allowed. Check flow rules and try again.");
                            }

                            if (flowValue != null || flowValues != null)
                            {
                                //calc dn if necessary
                                if (csAttribName.Equals("dn", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    //are we safe to assume that if we are calculating dn, we must
                                    //be using flowValue and not flowValues?
                                    string         rdn = flowValue.ToString();
                                    ReferenceValue dn  = ma.EscapeDNComponent(rdn);
                                    csentry.DN = dn;
                                }
                                else
                                {
                                    try
                                    {
                                        if (flowValue != null)
                                        {
                                            csentry[csAttribName].Values.Add(flowValue);
                                        }
                                        else if (flowValues != null)
                                        {
                                            csentry[csAttribName].Values.Add(flowValues);
                                        }
                                    }
                                    catch (InvalidOperationException ex)
                                    {
                                        if (!ex.Message.Equals("attribute " + csAttribName + " is read-only", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            throw;
                                        }
                                        else
                                        {
                                            //our anchor attribute is read only, set a temporary dn
                                            if (anchors.Contains(csAttribName))
                                            {
                                                ReferenceValue dn = ma.EscapeDNComponent(Guid.NewGuid().ToString());
                                                csentry.DN = dn;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        //do we want to throw an error now if any writeable anchor attributes have not been set??
                        //otherwise they will get one on export, we will leave it that way for now

                        csentry.CommitNewConnector();
                    }
                }
            }
        }
Beispiel #26
0
        void IMVSynchronization.Provision(MVEntry mventry)
        {
            switch (mventry.ObjectType.ToLower())
            {
                //Person - MV Object type to scope provision of contoso users to the GALSync domain, as contact objects, under the "ExternalContacts" OU
                #region case "person":
                case "person":
                    {

                        bool bContactsConnected = false; // reset our boolean 
                        bool bProv = false;
                        if (mventry["mail"].IsPresent) bProv = true;
                        maContacts = mventry.ConnectedMAs["GALSync"]; //Declares MA to Provisions

                        int iNumConnectorsContacts = maContacts.Connectors.Count; // count our connectors to this MA 

                        if (bProv)
                        {
                            if (iNumConnectorsContacts > 0) bContactsConnected = true;
                            RDN = "CN=" + mventry["cn"].Value + ",OU=ExternalContacts" + ",DC=GALSync,DC=com";
                            targetDN = maContacts.CreateDN(RDN); //Created the CS DN
                            if (!(bContactsConnected)) //If not found while iNumConnectorsContacts
                            {
                                CSEntry = maContacts.Connectors.StartNewConnector("contact"); //Starts a new connector
                                CSEntry.DN = targetDN; //Sets the CS DN from targetDN
                                CSEntry["targetAddress"].Value = mventry["mail"].Value; //flows mail attribute MV > CS
                                CSEntry.CommitNewConnector(); //commits the connector to cs db
                            }
                        }
                        break;
                    }
                #endregion case "person"

                //GALSyncPerson - MV Obkect type to scope provision of external contacts from the GALSync.com domain to AD in Contoso under the "ExternalContacts" OU
                #region case "GalSyncPerson":
                case galsyncperson":
                    {

                        bool bContactsConnected = false; // reset our boolean 
                        bool bProv = false;
                        if (mventry["mail"].IsPresent) bProv = true;
                        maContacts = mventry.ConnectedMAs["AD MA"]; //Declares MA to Provisions

                        int iNumConnectorsContacts = maContacts.Connectors.Count; // count our connectors to this MA 

                        if (bProv)
                        {
                            if (iNumConnectorsContacts > 0) bContactsConnected = true;
                            RDN = "CN=" + mventry["cn"].Value + ",OU=ExternalContacts" + ",DC=Contoso,DC=com";
                            targetDN = maContacts.CreateDN(RDN); //Created the CS DN
                            if (!(bContactsConnected)) //If not found while iNumConnectorsContacts
                            {
                                CSEntry = maContacts.Connectors.StartNewConnector("contact"); //Starts a new connector
                                CSEntry.DN = targetDN; //Sets the CS DN from targetDN
                                CSEntry["targetAddress"].Value = mventry["mail"].Value; //flows mail attribute MV > CS
                                CSEntry.CommitNewConnector(); //commits the connector to cs db
                            }
                        }
                        break;
                    }
                    #endregion case "GalSyncPerson"
            }
        }
Beispiel #27
0
 protected sealed override void OnRestoreChanges(ReferenceValue changes)
 {
     this.RestoreChanges((TChanges)changes);
 }
Beispiel #28
0
        public void HandleReferenceParam()
        {
            var p1 = new ReferenceValue("2");
            Assert.AreEqual("2", p1.Value);

            var p2 = new ReferenceValue("http://server.org/fhir/Patient/1");
            Assert.AreEqual("http://server.org/fhir/Patient/1", p2.Value);

            var crit = Criterium.Parse(@"paramX=http://server.org/\$4/fhir/Patient/1");
            var p3 = ((UntypedValue)crit.Operand).AsReferenceValue();
            Assert.AreEqual("http://server.org/$4/fhir/Patient/1", p3.Value);
        }
Beispiel #29
0
 protected abstract void OnRestoreChanges(ReferenceValue changes);
Beispiel #30
0
        public override bool IsLessThan(ReferenceValue obj)
        {
            bool result;
            if (obj is PointerToElementValue)
            {
                PointerToElementValue ptr = obj as PointerToElementValue;
                result = arr == ptr.arr && index < ptr.index;
            }
            else
                result = false;

            return result;
        }
 public Notification(string key, Type type, ReferenceValue value)
 {
     this.key   = key;
     this.type  = type;
     this.value = value;
 }
Beispiel #32
0
        private void AddOrRenameConnector(ref ConnectedMA MA, ref GALMA MAConfig, MVEntry mventry, CSEntry csentry = null)
        {
            //
            // All objects are provisioned as contacts
            //
            string cn                = null;
            int    numberToAppend    = 1;
            bool   successful        = false;
            bool   extendedNameTried = false;
            string extendedName      = null;
            string adminGroup        = null;
            bool   provisioningAdd   = false;
            int    cnLengthMax       = 0;
            string validatedName     = null;

            //
            // Add or Rename if only SynchronizationOU is defined
            //
            if ((MAConfig.SynchronizationOU == null) || MAConfig.SynchronizationOU.Equals(""))
            {
                return;
            }

            if (!mventry[COMMON_NAME].IsPresent || !mventry[MAIL_NICK_NAME].IsPresent || !mventry[TARGET_ADDRESS].IsPresent)
            {
                LogAndThrowUnexpectedDataException("Provisioning without cn, mailNickName or targetAddress");
            }

            if (null == csentry)
            {
                provisioningAdd = true;
            }

            cn = mventry[COMMON_NAME].Value.ToString();

            //
            // Active Directory does not distinguish CNs that differ only in use of diacritical marks (accents) etc.
            // whereas the sync service does. So force uniqueness by appending mailnickname to all CNs with extended
            // chars if doing so does not exceed CN max length.
            //
            IEnumerator cnEnum = cn.GetEnumerator();

            while (cnEnum.MoveNext())
            {
                if (Strings.AscW(cnEnum.Current.ToString()) > 127 && cn.Length + mventry[MAIL_NICK_NAME].Value.ToString().Length + 2 + RDN_TYPE.Length < AD_RDN_MAX_SIZE)
                {
                    cn = cn + "(" + mventry[MAIL_NICK_NAME].Value.ToString() + ")";
                    break;                     // TODO: might not be correct. Was : Exit While
                }
            }

            do
            {
                try {
                    //
                    // Create a DN for the new object, need UPPER case "CN=..."
                    //
                    string         rdn = RDN_TYPE + cn;
                    ReferenceValue dn  = MA.EscapeDNComponent(rdn).Concat(MAConfig.SynchronizationOU);

                    if (rdn.Length > AD_RDN_MAX_SIZE + RDN_TYPE.Length)
                    {
                        LogAndThrowUnexpectedDataException("RDN too long: " + rdn);
                    }

                    if (csentry == null)
                    {
                        //
                        // Try to add the object
                        //
                        //LoggingCs.Log("Adding " + dn.ToString());

                        csentry = ExchangeUtils.CreateMailEnabledContact(MA, dn, mventry[MAIL_NICK_NAME].Value.ToString(), mventry[TARGET_ADDRESS].Value.ToString());

                        adminGroup = GetAdminGroup(csentry);
                        if ((adminGroup != null))
                        {
                            //
                            // LegacyExhangeDN = adminGroup/cn=mailnickname-guid
                            //
                            validatedName = ValidateLegacyExhangeDN(mventry[MAIL_NICK_NAME].Value.ToCharArray());

                            if ((validatedName == null))
                            {
                                csentry[LEGACY_EXCHANGE_DN].Value = adminGroup + "/cn=" + System.Guid.NewGuid().ToString();
                            }
                            else
                            {
                                csentry[LEGACY_EXCHANGE_DN].Value = adminGroup + "/cn=" + validatedName + "-" + System.Guid.NewGuid().ToString();
                            }
                        }
                    }
                    else
                    {
                        //
                        // Try to rename the object
                        //
                        if (!csentry.DN.Equals(dn))
                        {
                            //LoggingCs.Log("Renaming " + dn.ToString());
                            csentry.DN = dn;
                        }
                    }
                    successful = true;
                } catch (MissingParentObjectException ex) {
                    //
                    // Typically the admin has to perform a full/delta import
                    // on the target CD, or disable provisioning until all
                    // forests are imported.
                    //
                    //LoggingCs.Log("Target MA " + MA.Name + " is not imported yet. " + "Please disable provisioning until all forests " + "are imported.");
                    throw ex;
                } catch (ObjectAlreadyExistsException ex) {
                    //
                    // If adding connector, throw away the instance to start over
                    //
                    if (provisioningAdd)
                    {
                        csentry = null;
                    }

                    //
                    // There is a duplicate object in the target AD,
                    // change the cn accordingly to avoid conflict.
                    //
                    if (!extendedNameTried)
                    {
                        extendedNameTried = true;
                        try {
                            if (mventry[DEPARTMENT].IsPresent)
                            {
                                extendedName = mventry[DEPARTMENT].Value;
                            }
                        } catch (NoSuchAttributeInObjectTypeException ex2) {
                        }
                    }

                    cn = null;
                    if (extendedName != null)
                    {
                        cn           = mventry[COMMON_NAME].Value + " (" + extendedName + ")";
                        extendedName = null;

                        if (cn.Length > AD_RDN_MAX_SIZE)
                        {
                            //
                            // If too long, we'll try without it
                            //
                            cn = null;
                        }
                    }


                    if (null == cn)
                    {
                        cn = mventry[COMMON_NAME].Value;

                        //
                        // To make sure that the number appended
                        // will not be truncated.
                        // The 2 spaces reserved is for "()"
                        //
                        cnLengthMax = AD_RDN_MAX_SIZE - (numberToAppend.ToString().Length + 2);
                        //
                        // If it's too long, we are going to truncate the
                        // name and preserve the number appended.
                        //
                        if (cn.Length > cnLengthMax)
                        {
                            cn = cn.Substring(0, cnLengthMax);
                        }

                        cn             = cn + "(" + numberToAppend.ToString() + ")";
                        numberToAppend = numberToAppend + 1;

                        if (numberToAppend > RETRY_NUM_LIMIT)
                        {
                            LogAndThrowUnexpectedDataException("Retry for " + mventry[COMMON_NAME].Value + " exceeds limit " + numberToAppend.ToString());
                        }
                    }
                }
            } while (!successful);
        }
Beispiel #33
0
 public void RestoreChanges(ReferenceValue changes)
 {
     this.OnRestoreChanges(changes);
 }
Beispiel #34
0
 public bool TryGetVariableFromReference(ReferenceValue reference, out Variable variable)
 {
     return globalVariables.TryGetValue(reference.Value, out variable) || 
                           localVariables.TryGetValue(Tuple.Create(reference.Scope, reference.Value), out variable);
 }