예제 #1
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            Sensitivity sensitivity = (Sensitivity)value;

            propertyBag.SetValueWithFixup(InternalSchema.MapiSensitivity, (int)value);
            propertyBag.SetValueWithFixup(InternalSchema.Privacy, sensitivity == Sensitivity.Private);
        }
        public async Task <IActionResult> PutSensitivity(int id, Sensitivity sensitivity)
        {
            if (id != sensitivity.Id)
            {
                return(BadRequest());
            }

            _context.Entry(sensitivity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SensitivityExists(id))
                {
                    return(NotFound());
                }

                return(BadRequest("Internal server error"));
            }

            return(NoContent());
        }
예제 #3
0
 private static string FormatTitle(string subject, Sensitivity sensitivity, EmailAddress organizer)
 {
     if (sensitivity != Sensitivity.Normal)
     { // This is personal or private meeting
         if (organizer != null && !string.IsNullOrEmpty(organizer.Name))
         {
             return(organizer.Name);
         }
         else
         {
             return("Private meeting");
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(subject))
         {
             return(WebUtility.HtmlEncode(subject));
         }
         else
         {
             return("");
         }
     }
 }
예제 #4
0
        void Application_Start(object sender, EventArgs e)
        {
            _containerProvider = new ContainerProvider(ContainerCreationExtentions.CreateNew().LoadDefaultPackage("KindergartenApp"));

            SessionFactoryHelper.CreateSessionFactoryWithDBUpdate();
            using (var session = SessionFactoryHelper.SessionFactory.OpenSession())
            {
                var exist = session.Query <Sensitivity>().Any();

                if (!exist)
                {
                    var s1 = new Sensitivity {
                        Description = "לקטוז"
                    };
                    var s2 = new Sensitivity {
                        Description = "גלוטן"
                    };
                    var s3 = new Sensitivity {
                        Description = "בוטנים"
                    };
                    var s4 = new Sensitivity {
                        Description = "אגוזים"
                    };
                    var s5 = new Sensitivity {
                        Description = "ביצים"
                    };
                    session.Save(s1);
                    session.Save(s2);
                    session.Save(s3);
                    session.Save(s4);
                    session.Save(s5);
                }
            }
        }
예제 #5
0
        private static Sensitivity ReadSensitivityCrossCurrencyBasis(EntryObject o)
        {
            if (!String.IsNullOrEmpty(o.Bucket) || !String.IsNullOrEmpty(o.Label1) || !String.IsNullOrEmpty(o.Label2))
            {
                throw new InvalidDataException("The CRIF file cannot specify Bucket, Label1 and Label2 properties for Risk_XCcyBasis entries.");
            }

            if (!Enum.TryParse(o.ProductClass, out Model.Product product))
            {
                throw new InvalidDataException("The CRIF file contains a Risk_XCcyBasis entry with an invalid ProductClass property.");
            }

            if (product != Model.Product.RatesFx)
            {
                throw new InvalidDataException($"The CRIF file contains a Risk_XCcyBasis entry associated to a product class other than {Model.Product.RatesFx}.");
            }

            if (!Currency.TryParse(o.Qualifier, out Currency currency))
            {
                throw new InvalidDataException("The CRIF file contains a Risk_XCcyBasis entry with an invalid Qualifier property.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            return(Sensitivity.CrossCurrencyBasis(currency, amount, regulationsInfo, tradeInfo));
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the Baseline class.
 /// </summary>
 /// <param name="sensitivity">the sensitivity of the baseline. Possible
 /// values include: 'Low', 'Medium', 'High'</param>
 /// <param name="lowThresholds">The low thresholds of the
 /// baseline.</param>
 /// <param name="highThresholds">The high thresholds of the
 /// baseline.</param>
 public Baseline(Sensitivity sensitivity, IList <double?> lowThresholds, IList <double?> highThresholds)
 {
     Sensitivity    = sensitivity;
     LowThresholds  = lowThresholds;
     HighThresholds = highThresholds;
     CustomInit();
 }
예제 #7
0
 private void AlignActiveValues()
 {
     OptionSetX.AlignActiveValues();
     OptionSetY.AlignActiveValues();
     Sensitivity.AlignActiveValues();
     Rotation.AlignActiveValues();
 }
예제 #8
0
            private static Amount CalculateCorrelatedSumWeights(Currency calculationCurrency, SensitivityRisk risk, List <MarginWeighting> weightingMargins, Dictionary <String, Decimal> thresholdFactors)
            {
                Amount sum = Amount.OfZero(calculationCurrency);

                foreach (MarginWeighting marginWeighting1 in weightingMargins)
                {
                    foreach (MarginWeighting marginWeighting2 in weightingMargins)
                    {
                        Sensitivity sensitivity1 = marginWeighting1.Sensitivity;
                        Sensitivity sensitivity2 = marginWeighting2.Sensitivity;

                        if (sensitivity1 != sensitivity2)
                        {
                            Decimal thresholdFactor1 = thresholdFactors[sensitivity1.Qualifier];
                            Decimal thresholdFactor2 = thresholdFactors[sensitivity2.Qualifier];
                            Decimal concentration    = Math.Min(thresholdFactor1, thresholdFactor2) / Math.Max(thresholdFactor1, thresholdFactor2);

                            Decimal correlationSensitivity = ModelParameters.GetCorrelationSensitivity(risk, sensitivity1, sensitivity2);
                            Decimal correlation            = correlationSensitivity * concentration;

                            sum += marginWeighting1.Value * marginWeighting2.Value * correlation;
                        }
                    }
                }

                return(sum);
            }
예제 #9
0
 public static MarkedAsSensitivityCondition Create(Rule rule, Sensitivity sensitivity)
 {
     Condition.CheckParams(new object[]
     {
         rule
     });
     EnumValidator.ThrowIfInvalid <Sensitivity>(sensitivity, "sensitivity");
     return(new MarkedAsSensitivityCondition(rule, sensitivity));
 }
예제 #10
0
 public static MarkSensitivityAction Create(Sensitivity sensitivity, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule
     });
     EnumValidator.ThrowIfInvalid <Sensitivity>(sensitivity, "sensitivity");
     return(new MarkSensitivityAction(ActionType.MarkSensitivityAction, sensitivity, rule));
 }
예제 #11
0
        private static String CreateSensitivityIdentifier(Sensitivity sensitivity)
        {
            switch (sensitivity.Product)
            {
            case Product.Commodity:
            case Product.Equity:
                return($"{sensitivity.Qualifier}");

            case Product.Credit:
                return($"{sensitivity.Qualifier}{(String.IsNullOrWhiteSpace(sensitivity.Label1) ? String.Empty : $", {sensitivity.Label1}")}{(String.IsNullOrWhiteSpace(sensitivity.Label2) ? String.Empty : $", {sensitivity.Label2}")}");
 public VirtualButtonBehaviour()
 {
     mName = "";
     mPressed = false;
     mSensitivity = DEFAULT_SENSITIVITY;
     mSensitivityDirty = true;
     mHandlers = new List<IVirtualButtonEventHandler>();
     mInitialized = false;
     mHasUpdatedPose = false;
 }
예제 #13
0
 public VirtualButtonBehaviour()
 {
     mName             = "";
     mPressed          = false;
     mSensitivity      = DEFAULT_SENSITIVITY;
     mSensitivityDirty = false;
     mHandlers         = new List <IVirtualButtonEventHandler>();
     mInitialized      = false;
     mHasUpdatedPose   = false;
 }
예제 #14
0
        private static DataValue AdjustedClone(Sensitivity sensitivity, RegulationRole regulationRole)
        {
            DataValue clone = (DataValue)sensitivity.Clone();

            if (regulationRole == RegulationRole.Pledgor)
            {
                clone = clone.ChangeAmount(-clone.Amount);
            }

            return(clone);
        }
예제 #15
0
        private IEnumerable <KeyValuePair <string, object> > GetRequestParams(Sensitivity sensitivity)
        {
            if (Params != null)
            {
                return(Params.Where(param => !Configuration.ExcludeParams && Params != null)
                       .Where(param => param.Value != null && param.Sensitivity == sensitivity)
                       .Select(_ => new KeyValuePair <string, object>(_.Name, _.Value)));
            }

            return(Enumerable.Empty <KeyValuePair <string, object> >());
        }
        private IEnumerable <KeyValuePair <string, string> > GetRequestParams(Sensitivity sensitivity)
        {
            if (!Configuration.ExcludeParams && Params != null)
            {
                foreach (var param in Params.Where(param => param.Value != null && param.Sensitivity == sensitivity))
                {
                    var val = param.Value.Substring(0, Math.Min(param.Value.Length, Configuration.ParamTruncateLength));

                    yield return(new KeyValuePair <string, string>(param.Name, val));
                }
            }
        }
예제 #17
0
 private void MergeSensitivity(ref Sensitivity current, bool detectedValue)
 {
     if (current == Sensitivity.Auto)
     {
         if (detectedValue)
         {
             current = Sensitivity.True;
         }
         else
         {
             current = Sensitivity.False;
         }
     }
 }
        public async Task <ActionResult <Sensitivity> > PostSensitivity(string id, Sensitivity sensitivity)
        {
            var medicalHistory = _context.MedicalHistories.FirstOrDefault(m => m.ApplicationUserId == id);

            if (medicalHistory == null)
            {
                return(BadRequest("There is no medical history for this Patient"));
            }

            sensitivity.MedicalHistoryId = medicalHistory.Id;
            _context.Sensitivities.Add(sensitivity);
            await _context.SaveChangesAsync();

            return(Ok());
        }
예제 #19
0
        internal Baseline(Sensitivity sensitivity, IEnumerable <double> lowThresholds, IEnumerable <double> highThresholds)
        {
            if (lowThresholds == null)
            {
                throw new ArgumentNullException(nameof(lowThresholds));
            }
            if (highThresholds == null)
            {
                throw new ArgumentNullException(nameof(highThresholds));
            }

            Sensitivity    = sensitivity;
            LowThresholds  = lowThresholds.ToList();
            HighThresholds = highThresholds.ToList();
        }
        internal static string ToSerializedValue(this Sensitivity value)
        {
            switch (value)
            {
            case Sensitivity.Low:
                return("Low");

            case Sensitivity.Medium:
                return("Medium");

            case Sensitivity.High:
                return("High");
            }
            return(null);
        }
예제 #21
0
 public override void WriteXml(XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("KnobImage", KnobImage);
     writer.WriteElementString("RotationStep", RotationStep.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("StepValue", StepValue.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture));
     writer.WriteStartElement("ClickType");
     writer.WriteElementString("Type", ClickType.ToString());
     if (ClickType != ClickType.Touch)
     {
         writer.WriteElementString("Sensitivity", Sensitivity.ToString(CultureInfo.InvariantCulture));
     }
     writer.WriteEndElement();
 }
예제 #22
0
        public static Sensitivity Copy(Sensitivity baseSensitivity)
        {
            Sensitivity result = null;

            if (baseSensitivity != null)
            {
                result = new Sensitivity
                {
                    Value         = baseSensitivity.Value,
                    name          = baseSensitivity.name,
                    definitionRef = baseSensitivity.definitionRef
                };
            }
            return(result);
        }
예제 #23
0
        private static Sensitivity ParseSensitivityCreditNonQualifying(EntryObject o)
        {
            if (!Enum.TryParse(o.ProductClass, out Model.Product product))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid ProductClass property.");
            }

            if (product != Model.Product.Credit)
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry associated to a product class other than {Model.Product.Credit}.");
            }

            if (!BucketCreditNonQualifying.TryParse(o.Bucket, out BucketCreditNonQualifying bucket))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid Bucket property.");
            }

            if (!Tenor.TryParse(o.Label1, out Tenor tenor))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid Label1 property.");
            }

            if (!tenor.IsCreditTenor)
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry associated to an improper tenor (accepted tenors are: {String.Join(", ", Tenor.Values.Where(x => x.IsCreditTenor).Select(x => x.Name))}.");
            }

            if (!String.IsNullOrEmpty(o.Label2))
            {
                throw new InvalidDataException($"The CRIF file cannot specify the Label2 property for {o.RiskType} entries.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            if (o.RiskType == "Risk_CreditNonQ")
            {
                if (!DataValidator.IsValidQualifier(o.Qualifier, true))
                {
                    throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid Qualifier property.");
                }

                return(Sensitivity.CreditNonQualifyingDelta(o.Qualifier, bucket, tenor, amount, regulationsInfo, tradeInfo));
            }

            return(Sensitivity.CreditNonQualifyingVega(o.Qualifier, bucket, tenor, amount, regulationsInfo, tradeInfo));
        }
예제 #24
0
        private static Sensitivity ReadSensitivityEquity(EntryObject o)
        {
            if (!Enum.TryParse(o.ProductClass, out Model.Product product))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid ProductClass property.");
            }

            if (product != Model.Product.Equity)
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry associated to a product class other than {Model.Product.Equity}.");
            }

            if (!DataValidator.IsValidQualifier(o.Qualifier, false))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid Qualifier property.");
            }

            if (!BucketEquity.TryParse(o.Bucket, out BucketEquity bucket))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid Bucket property.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            if (o.RiskType == "Risk_Equity")
            {
                if (!String.IsNullOrEmpty(o.Label1) || !String.IsNullOrEmpty(o.Label2))
                {
                    throw new InvalidDataException("The CRIF file cannot specify Label1 and Label2 properties for Risk_Equity entries.");
                }

                return(Sensitivity.EquityDelta(o.Qualifier, bucket, amount, regulationsInfo, tradeInfo));
            }

            if (!Tenor.TryParse(o.Label1, out Tenor tenor))
            {
                throw new InvalidDataException("The CRIF file contains a Risk_EquityVol entry with an invalid Label1 property.");
            }

            if (!String.IsNullOrEmpty(o.Label2))
            {
                throw new InvalidDataException("The CRIF file cannot specify the Label2 property for Risk_EquityVol entries.");
            }

            return(Sensitivity.EquityVega(o.Qualifier, bucket, tenor, amount, regulationsInfo, tradeInfo));
        }
예제 #25
0
        private static Sensitivity ReadSensitivityFx(EntryObject o)
        {
            if (!Enum.TryParse(o.ProductClass, out Model.Product product))
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid ProductClass property.");
            }

            if (product != Model.Product.RatesFx)
            {
                throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry associated to a product class other than {Model.Product.RatesFx}.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            if (o.RiskType == "Risk_FX")
            {
                if (!Currency.TryParse(o.Qualifier, out Currency currency))
                {
                    throw new InvalidDataException("The CRIF file contains a Risk_FX entry with an invalid Qualifier property.");
                }

                if (!String.IsNullOrEmpty(o.Bucket) || !String.IsNullOrEmpty(o.Label1) || !String.IsNullOrEmpty(o.Label2))
                {
                    throw new InvalidDataException("The CRIF file cannot specify Bucket, Label1 and Label2 properties for Risk_FX entries.");
                }

                return(Sensitivity.FxDelta(currency, amount, regulationsInfo, tradeInfo));
            }

            if (!CurrencyPair.TryParse(o.Qualifier, out CurrencyPair pair))
            {
                throw new InvalidDataException("The CRIF file contains a Risk_FXVol entry with an invalid Qualifier property.");
            }

            if (!Tenor.TryParse(o.Label1, out Tenor tenor))
            {
                throw new InvalidDataException("The CRIF file contains a Risk_FXVol entry with an invalid Label1 property.");
            }

            if (!String.IsNullOrEmpty(o.Bucket) || !String.IsNullOrEmpty(o.Label2))
            {
                throw new InvalidDataException("The CRIF file cannot specify the Label2 property for Risk_EquityVol entries.");
            }

            return(Sensitivity.FxVega(pair, tenor, amount, regulationsInfo, tradeInfo));
        }
예제 #26
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("desc1", Description1);
     writer.WriteAttributeString("desc2", Description2);
     writer.WriteAttributeString("partName", PartName);
     writer.WriteAttributeString("featureName", FeatureName);
     writer.WriteAttributeString("toleranceValue", ToleranceValue.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("toleranceEffective",
                                 ToleranceEffective.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("effect", Effect.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("sensitivity", Sensitivity.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("meanShift", MeanShift.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("src", Src);
     writer.WriteAttributeString("weight", Weight.ToString(CultureInfo.InvariantCulture));
 }
예제 #27
0
        public static Amount CalculateCurvatureAmount(Sensitivity sensitivity)
        {
            if (sensitivity == null)
            {
                throw new ArgumentNullException(nameof(sensitivity));
            }

            if (sensitivity.Category != SensitivityCategory.Vega)
            {
                throw new ArgumentException("Invalid sensitivity specified.", nameof(sensitivity));
            }

            Decimal days       = sensitivity.Tenor.Days;
            Decimal scaledDays = ModelParameters.GetCurvatureScaledDays(days);

            return(sensitivity.Amount * scaledDays);
        }
예제 #28
0
    // Start is called before the first frame update
    void Start()
    {
        if (sensitivity == null)
        {
            sensitivity = GameObject.Find("Sensitivity").GetComponent <Sensitivity>();
        }

        /*
         * if(flickDistance == null)
         * {
         *  flickDistance = GameObject.Find("FlickDistance").GetComponent<FlickDistance>();
         * }*/
        if (controllerPosition == null)
        {
            controllerPosition = GameObject.Find("ControllerPosition").GetComponent <ControllerPosition>();
        }
    }
        /// <summary>
        /// Returns the sensitivity to the market data specified by {@code name}.
        /// <para>
        /// This returns a sensitivity instance which stores the sensitivity of the {@code marketDataName} delta to another
        /// market data of {@code name}.
        ///
        /// </para>
        /// </summary>
        /// <param name="name">  the name </param>
        /// <returns> the sensitivity </returns>
        /// <exception cref="IllegalArgumentException"> if the name does not match an entry </exception>
        public CrossGammaParameterSensitivity getSensitivity <T1>(MarketDataName <T1> name)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.tuple.Pair<int, java.util.List<? extends ParameterMetadata>> indexAndMetadata = findStartIndexAndMetadata(name);
            Pair <int, IList <ParameterMetadata> > indexAndMetadata = findStartIndexAndMetadata(name);
            int startIndex = indexAndMetadata.First;
            int rowCt      = ParameterCount;
            int colCt      = indexAndMetadata.Second.Count;

//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] sensi = new double[rowCt][colCt];
            double[][] sensi = RectangularArrays.ReturnRectangularDoubleArray(rowCt, colCt);
            for (int i = 0; i < rowCt; ++i)
            {
                Array.Copy(Sensitivity.rowArray(i), startIndex, sensi[i], 0, colCt);
            }
            return(CrossGammaParameterSensitivity.of(MarketDataName, ParameterMetadata, name, indexAndMetadata.Second, Currency, DoubleMatrix.ofUnsafe(sensi)));
        }
예제 #30
0
 public void SetActiveValues(
     double xSens,
     double ySens,
     double rotation,
     int xMode,
     int yMode,
     AccelArgs xArgs,
     AccelArgs yArgs,
     bool isWhole)
 {
     Sensitivity.SetActiveValues(xSens, ySens);
     Rotation.SetActiveValue(rotation);
     OptionSetX.SetActiveValues(xMode, xArgs);
     WholeVectorMenuItem.Checked       = isWhole;
     ByComponentVectorMenuItem.Checked = !isWhole;
     ByComponentVectorXYLock.Checked   = xArgs.Equals(yArgs);
     OptionSetY.SetActiveValues(yMode, yArgs);
 }
 private static bool containsValue(string[] arr, string value, Sensitivity sens)
 {
     foreach (string s in arr)
     {
         if (sens == Sensitivity.CaseInsensitive)
         {
             if (value.ToLower() == s.ToLower())
             {
                 return(true);
             }
             else if (value == s)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #32
0
파일: SET_SEN.cs 프로젝트: katadam/wockets
 public SET_SEN(Sensitivity sensitivity)
 {
     this._Bytes = new byte[] { (byte)0xa0 | (byte)CommandTypes.SET_SEN, (byte)(((byte)sensitivity)<<3) };
 }
예제 #33
0
파일: Core.cs 프로젝트: katadam/wockets
        /// <summary>
        /// Sends a request to the kernel to set the wockets sensitivity
        /// </summary>
        /// <param name="mac">MAC address of the wocket</param>
        /// <param name="sensitivity">Sensitivity of the wocket</param>
        public static void SET_WOCKET_SENSITIVITY(string mac, Sensitivity sensitivity)
        {
            ThreadPool.QueueUserWorkItem(func =>
            {
                kernelLock.WaitOne();
                try
                {
                    if ((_Registered) && (_Connected))
                    {
                        string commandPath = REGISTRY_REGISTERED_APPLICATIONS_PATH + "\\{" + _IcomingChannel + "}";
                        NamedEvents namedEvent = new NamedEvents();

                        RegistryKey rk = Registry.LocalMachine.OpenSubKey(commandPath, true);
                        rk.SetValue("Message", KernelCommand.SET_WOCKET_SENSITIVITY.ToString(), RegistryValueKind.String);
                        rk.SetValue("Param", mac.ToString() + ":" + sensitivity.ToString(), RegistryValueKind.String);
                        rk.Flush();
                        rk.Close();

                        namedEvent.Send(Core._OutgoingChannel);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Core.cs:SET_WOCKET_SENSITIVITY:" + e.ToString());
                }

                kernelLock.Release();
            });
        }
예제 #34
0
        public Message(uint NID, IPMItem item, PSTFile pst)
        {
            this._IPMItem = item;
            this.Data = BlockBO.GetNodeData(NID, pst);
            this.NID = NID;
            //this.MessagePC = new PropertyContext(this.Data);
            foreach(var subNode in this.Data.SubNodeData)
            {
                var temp = new NID(subNode.Key);
                switch(temp.Type)
                {
                    case NDB.NID.NodeType.ATTACHMENT_TABLE:
                        this.AttachmentTable = new TableContext(subNode.Value);
                        break;
                    case NDB.NID.NodeType.ATTACHMENT_PC:
                        this.AttachmentPC = new PropertyContext(subNode.Value);
                        this.Attachments = new List<Attachment>();
                        foreach(var row in this.AttachmentTable.RowMatrix.Rows)
                        {
                            this.Attachments.Add(new Attachment(row));
                        }
                        break;
                    case NDB.NID.NodeType.RECIPIENT_TABLE:
                        this.RecipientTable = new TableContext(subNode.Value);

                        foreach(var row in this.RecipientTable.RowMatrix.Rows)
                        {
                            var recipient = new Recipient(row);
                            switch(recipient.Type)
                            {
                                case Recipient.RecipientType.TO:
                                    this.To.Add(recipient);
                                    break;
                                case Recipient.RecipientType.FROM:
                                    this.From.Add(recipient);
                                    break;
                                case Recipient.RecipientType.CC:
                                    this.CC.Add(recipient);
                                    break;
                                case Recipient.RecipientType.BCC:
                                    this.BCC.Add(recipient);
                                    break;
                            }
                        }
                        break;
                }
            }
            foreach(var prop in this._IPMItem.PC.Properties)
            {
                if (prop.Value.Data == null)
                    continue;
                switch(prop.Key)
                {
                    case 0x17:
                        this.Imporance = (Importance) BitConverter.ToInt16(prop.Value.Data, 0);
                        break;
                    case 0x36:
                        this.Sensitivity = (Sensitivity) BitConverter.ToInt16(prop.Value.Data, 0);
                        break;
                    case 0x37:
                        this.Subject = Encoding.Unicode.GetString(prop.Value.Data);
                        if (this.Subject.Length > 0)
                        {
                            var chars = this.Subject.ToCharArray();
                            if (chars[0] == 0x001)
                            {
                                var length = (int)chars[1];
                                int i = 0;
                                if (length > 1)
                                    i++;
                                this.SubjectPrefix = this.Subject.Substring(2, length-1);
                                this.Subject = this.Subject.Substring(2 + length-1);
                            }
                        }
                        break;
                    case 0x39:
                        this.ClientSubmitTime = DateTime.FromFileTimeUtc(BitConverter.ToInt64(prop.Value.Data, 0));
                        break;
                    case 0x42:
                        this.SentRepresentingName = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x70:
                        this.ConversationTopic = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x1a:
                        this.MessageClass = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0xc1a:
                        this.SenderName = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0xe06:
                        this.MessageDeliveryTime = DateTime.FromFileTimeUtc(BitConverter.ToInt64(prop.Value.Data, 0));
                        break;
                    case 0xe07:
                        this.MessageFlags = BitConverter.ToUInt32(prop.Value.Data, 0);

                        this.Read = (this.MessageFlags & 0x1) != 0;
                        this.Unsent = (this.MessageFlags & 0x8) != 0;
                        this.Unmodified = (this.MessageFlags & 0x2) != 0;
                        this.HasAttachments = (this.MessageFlags & 0x10) != 0;
                        this.FromMe = (this.MessageFlags & 0x20) != 0;
                        this.IsFAI = (this.MessageFlags & 0x40) != 0;
                        this.NotifyReadRequested = (this.MessageFlags & 0x100) != 0;
                        this.NotifyUnreadRequested = (this.MessageFlags & 0x200) != 0;
                        this.EverRead = (this.MessageFlags & 0x400) != 0;
                        break;
                    case 0xe08:
                        this.MessageSize = BitConverter.ToUInt32(prop.Value.Data, 0);
                        break;
                    case 0xe23:
                        this.InternetArticalNumber = BitConverter.ToUInt32(prop.Value.Data, 0);
                        break;
                    case 0xe27:
                        //unknown
                        break;
                    case 0xe29:
                        //nextSentAccount, ignore this, string
                        break;
                    case 0xe62:
                        //unknown
                        break;
                    case 0xe79:
                        //trusted sender
                        break;
                    case 0x1000:
                        this.BodyPlainText = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x1009:
                        this.BodyCompressedRTF = prop.Value.Data.RangeSubset(4, prop.Value.Data.Length - 4);
                        break;
                    case 0x1035:
                        this.InternetMessageID = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x10F3:
                        this.UrlCompositeName = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x10F4:
                        this.AttributeHidden = prop.Value.Data[0] == 0x01;
                        break;
                    case 0x10F5:
                        //unknown
                        break;
                    case 0x10F6:
                        this.ReadOnly = prop.Value.Data[0] == 0x01;
                        break;
                    case 0x3007:
                        this.CreationTime = DateTime.FromFileTimeUtc(BitConverter.ToInt64(prop.Value.Data, 0));
                        break;
                    case 0x3008:
                        this.LastModificationTime = DateTime.FromFileTimeUtc(BitConverter.ToInt64(prop.Value.Data, 0));
                        break;
                    case 0x300B:
                        //seach key
                        break;
                    case 0x3fDE:
                        this.CodePage = BitConverter.ToUInt32(prop.Value.Data, 0);
                        break;
                    case 0x3ff1:
                        //localeID
                        break;
                    case 0x3ff8:
                        this.CreatorName = Encoding.Unicode.GetString(prop.Value.Data);
                        break;
                    case 0x3ff9:
                        //creator entryid
                        break;
                    case 0x3ffa:
                        //last modifier name
                        break;
                    case 0x3ffb:
                        //last modifier entryid
                        break;
                    case 0x3ffd:
                        this.NonUnicodeCodePage = BitConverter.ToUInt32(prop.Value.Data, 0);
                        break;
                    case 0x4019:
                        //unknown
                        break;
                    case 0x401a:
                        //sentrepresentingflags
                        break;
                    case 0x619:
                        //userentryid
                        break;
                    default:
                        break;
                }
            }
        }
예제 #35
0
 /// <summary>
 /// Sets the sensitivity of the message
 /// </summary>
 /// <param name="nSensitivity">see NetMAPI.cs for Sensitivity enums</param>
 public bool SetSensitivity(Sensitivity nSensitivity)
 {
     return MessageSetSensitivity(pObject, (int)nSensitivity);
 }
예제 #36
0
        private BsonDocument buildSensitivity(Sensitivity tcd)
        {
            Measurement measurement = null;

            // Initialize object that will be stored under 'device' in mongo document
            BsonDocument nestedDevice = null;
            if (tcd.RxTest != null)
            {
                try {
                    measurement = tcd.RxTest.Measurement;
                }  catch (Exception exc) {
                    Program.log("ERROR SENSITIVITY: " + tcd.Id + " - " + exc.Message);
                 } finally {
                    nestedDevice = SyncManager.Instance.getNestedDevice(measurement);
                }
            }
            if (nestedDevice == null)
                return null;

            // Initialize object that will be stored under 'meta' in mongo document
            BsonDocument nestedMeta = SyncManager.Instance.getNestedMeta(measurement);
            if (nestedMeta == null)
                return null;

            // Initialize object that will be stored under 'data' in mongo document
            BsonDocument nestedData = SyncManager.Instance.getNestedData(tcd, excludeDataFields);

            // Custom code to move some set fields to meta object
            nestedMeta.Add("SetTemperature_C", nestedData["SetTemperature"]);
            nestedData.Remove("SetTemperature");
            nestedMeta.Add("Channel", nestedData["Channel"]);
            nestedData.Remove("Channel");
            nestedMeta.Add("SetVoltage", nestedData["SetVoltage"]);
            nestedData.Remove("SetVoltage");

            //System.Diagnostics.Trace.WriteLine("D " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            // Initialize object in root of the document
            BsonDocument rootDoc = new BsonDocument {
                 { "_id",  tcd.Id.ToString()},
                  { "mid", measurement.Id.ToString()  },
                 { "timestamp", tcd.TimeStamp},
                 { "type", domain() },
                 { "subtype",  "sensitivity" },
                 { "result", getResult( nestedData["Result"].ToString()) },
                 { "downstatus", getDownStatus( nestedData["Result"].ToString()) },
                 { "status", getStatus(measurement.Result) }
            };
            nestedData.Remove("Result");

            rootDoc.Add("device", nestedDevice);
            rootDoc.Add("meta", nestedMeta);
            rootDoc.Add("data", nestedData);

            return rootDoc;
        }
 /// <summary>
 /// Sets the sensitivity of the virtual button
 ///
 /// Sensitivity allows deciding between fast and robust button press
 /// measurements. This method must not be called while the corresponding
 /// DataSet is active or it will return false.
 /// </summary>
 public abstract bool SetSensitivity(Sensitivity sensitivity);