Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="initial"></param>
    /// <param name="modifier"></param>
    /// <param name="modificationType"></param>
    /// <returns></returns>
    public int modifyValue(int initial, int modifier,
                           ModificationType modificationType)
    {
        switch (modificationType)
        {
        case ModificationType.ADD:
            return(initial + modifier);

        case ModificationType.SUBTRACT:
            return(initial - modifier);

        case ModificationType.MULTIPLY:
            return(initial * modifier);

        case ModificationType.DIVIDE:
            return(initial / modifier);

        case ModificationType.REPLACE:
            return(modifier);

        case ModificationType.ADD_DIVISION:
            int strengthAddition = initial / modifier;
            return(initial + strengthAddition);

        default:
            Debug.LogError("Error! Unrecognized ModificationType enum given"
                           + "in modifyValue function: "
                           + modificationType.ToString());
            return(0);
        }
    }
Ejemplo n.º 2
0
        public static byte[] ToRecurrenceBlob(Properties easCalendarItem, ExDateTime start, ExDateTime end, ExTimeZone targetTimeZone)
        {
            Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Recurrence recurrence = easCalendarItem.Recurrence;
            RecurrencePattern  pattern            = SyncCalendarUtils.CreateRecurrencePattern(recurrence);
            RecurrenceRange    range              = SyncCalendarUtils.CreateRecurrenceRange(start, recurrence);
            ExDateTime         dt                 = targetTimeZone.ConvertDateTime(start);
            ExDateTime         dt2                = targetTimeZone.ConvertDateTime(end);
            TimeSpan           startOffset        = dt - dt.Date;
            TimeSpan           endOffset          = dt2 - dt2.Date;
            InternalRecurrence internalRecurrence = new InternalRecurrence(pattern, range, null, targetTimeZone, ExTimeZone.UtcTimeZone, startOffset, endOffset);

            if (easCalendarItem.Exceptions != null)
            {
                foreach (Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Exception ex in easCalendarItem.Exceptions)
                {
                    ExDateTime originalStartTime = SyncCalendarUtils.ToUtcExDateTime(ex.ExceptionStartTime);
                    ExDateTime date = originalStartTime.Date;
                    if (ex.Deleted)
                    {
                        internalRecurrence.TryDeleteOccurrence(date);
                    }
                    else
                    {
                        ModificationType  modificationType  = (ModificationType)0;
                        MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();
                        memoryPropertyBag.SetAllPropertiesLoaded();
                        if (ex.Subject != easCalendarItem.CalendarSubject)
                        {
                            modificationType |= ModificationType.Subject;
                            memoryPropertyBag[ItemSchema.Subject] = ex.Subject;
                        }
                        if (ex.Reminder != easCalendarItem.Reminder)
                        {
                            modificationType |= ModificationType.ReminderDelta;
                            memoryPropertyBag[ItemSchema.ReminderMinutesBeforeStartInternal] = ex.Reminder;
                        }
                        if (ex.Location != easCalendarItem.Location)
                        {
                            modificationType |= ModificationType.Location;
                            memoryPropertyBag[CalendarItemBaseSchema.Location] = ex.Location;
                        }
                        if (ex.BusyStatus != easCalendarItem.BusyStatus)
                        {
                            modificationType |= ModificationType.BusyStatus;
                            memoryPropertyBag[CalendarItemBaseSchema.FreeBusyStatus] = ex.BusyStatus;
                        }
                        if (ex.AllDayEvent != easCalendarItem.AllDayEvent)
                        {
                            modificationType |= ModificationType.SubType;
                            memoryPropertyBag[CalendarItemBaseSchema.MapiIsAllDayEvent] = ex.AllDayEvent;
                        }
                        ExDateTime    startTime     = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.StartTime));
                        ExDateTime    endTime       = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.EndTime));
                        ExceptionInfo exceptionInfo = new ExceptionInfo(null, date, originalStartTime, startTime, endTime, modificationType, memoryPropertyBag);
                        internalRecurrence.ModifyOccurrence(exceptionInfo);
                    }
                }
            }
            return(internalRecurrence.ToByteArray());
        }
Ejemplo n.º 3
0
        private void AddKeybinding(FloatFilterParameterModel model, string value, ModificationType modType, Key key)
        {
            var val     = GetFloatValue(value);
            var binding = new FloatFilterParameterModel.FloatParameterAction(val, modType);

            model.Keybindings[key] = binding;
        }
Ejemplo n.º 4
0
        private void AddParameterAction(IntFilterParameterModel model, string value, ModificationType modType, ActionType actionType)
        {
            var val    = GetIntValue(value);
            var action = new IntFilterParameterModel.IntParameterAction(val, modType);

            model.Actions[actionType] = action;
        }
Ejemplo n.º 5
0
        protected override void PositionChanged(IPosition position, ModificationType type)
        {
            // Event occurs on every change of the positions
            // Event occurs on every change of the positions
            if ((int)type == (int)ModificationType.Closed)
            {
                XXPrint("Position {0} was closed at price {1} with profit {2}",
                        position.Number, position.ClosePrice, position.Profit);

                if ((int)position.Type == (int)ExecutionRule.Buy)
                {
                    if ((position.ClosePrice - position.OpenPrice) < -(2 * Instrument.Spread /*+Instrument.Comission*/))
                    {
                        setMarketBuyOrder();
                    }
                    else
                    {
                        setMarketSellOrder();
                    }
                }
                if ((int)position.Type == (int)ExecutionRule.Sell)
                {
                    if ((position.ClosePrice - position.OpenPrice) < -(Instrument.Spread /*+Instrument.Comission*/))
                    {
                        setMarketSellOrder();
                    }
                    else
                    {
                        setMarketBuyOrder();
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void ReadModificationsFromXmlFile(string modsXmlFilepath, bool userModifications)
        {
            XmlDocument mods_xml = new XmlDocument();

            mods_xml.Load(modsXmlFilepath);

            XmlNamespaceManager mods_xml_ns = new XmlNamespaceManager(mods_xml.NameTable);

            mods_xml_ns.AddNamespace("omssa", mods_xml.ChildNodes[1].Attributes["xmlns"].Value);

            foreach (XmlNode mod_node in mods_xml.SelectNodes("/omssa:MSModSpecSet/omssa:MSModSpec", mods_xml_ns))
            {
                string           mod_name     = mod_node.SelectSingleNode("./omssa:MSModSpec_name", mods_xml_ns).FirstChild.Value;
                ModificationType mod_type     = (ModificationType)int.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_type", mods_xml_ns).FirstChild.FirstChild.Value);
                double           mod_monomass = double.Parse(mod_node.SelectSingleNode("./omssa:MSModSpec_monomass", mods_xml_ns).FirstChild.Value);

                XmlNodeList amino_acid_residues     = mod_node.SelectNodes("./omssa:MSModSpec_residues/omssa:MSModSpec_residues_E", mods_xml_ns);
                List <char> mod_amino_acid_residues = amino_acid_residues.Count > 0 ? new List <char>(amino_acid_residues.Count) : null;
                foreach (XmlNode amino_acid_residue in amino_acid_residues)
                {
                    mod_amino_acid_residues.Add(amino_acid_residue.FirstChild.Value[0]);
                }

                Modification mod = new Modification(mod_name, mod_monomass, mod_type, mod_amino_acid_residues, userModifications);

                if (!ContainsKey(mod_name))
                {
                    Add(mod);
                }
                else
                {
                    this[mod_name] = mod;
                }
            }
        }
Ejemplo n.º 7
0
 public Modification2(string modName)
 {
     if (Tables.Modifications.ContainsKey(modName))
     {
         Modification m = Tables.Modifications[modName];
         Fill(m);
     }
     else if (modName.StartsWith("Mass:"))
     {
         int ind = modName.LastIndexOf(':');
         DeltaMass = Parser.Double(modName.Substring(7, ind - 7));
         int modInd = Parser.Int(modName.Substring(ind + 1));
         Index             = (ushort)(ushort.MaxValue - modInd - 1);
         Position          = ModificationPosition.anywhere;
         IsProteinTerminal = false;
         IsInternal        = true;
         IsNterminal       = false;
         IsCterminal       = false;
         IsIsotopicLabel   = true;
         IsIsotopicMod     = true;
         HasNeutralLoss    = false;
         ModificationType  = ModificationType.Label;
         aas  = new[] { modName[5] };
         Name = modName;
     }
     else
     {
         throw new Exception("Illegal modification name: " + modName);
     }
 }
Ejemplo n.º 8
0
        private void AddKeybinding(BoolFilterParameterModel model, string value, ModificationType modType, Key key)
        {
            var val     = GetBoolValue(value);
            var binding = new BoolFilterParameterModel.BoolParameterAction(val, modType);

            model.Keybindings[key] = binding;
        }
Ejemplo n.º 9
0
 public Modification(string name, double monoisotopicMassShift,
                     ModificationType modificationType, IEnumerable <char> aminoAcidResidues)
 {
     this.name = name;
     this.monoisotopicMassShift = monoisotopicMassShift;
     this.modificationType      = modificationType;
     this.aminoAcidResidues     = aminoAcidResidues;
 }
Ejemplo n.º 10
0
 protected override void PositionChanged(IPosition position, ModificationType type)
 {
     // Событие происходит при каждом изменении позиций
     if (type == ModificationType.Closed)
     {
         Print("Position {0} was closed at price {1}", position.Number, position.ClosePrice);
     }
 }
Ejemplo n.º 11
0
 public Modification(string name, double monoisotopicMassShift,
     ModificationType modificationType, IEnumerable<char> aminoAcidResidues)
 {
     this.name = name;
     this.monoisotopicMassShift = monoisotopicMassShift;
     this.modificationType = modificationType;
     this.aminoAcidResidues = aminoAcidResidues;
 }
 public AccountModification(Guid accountid, ModificationType modificationType, double amount, DateTime modificationDateTime)
 {
     Id = Guid.NewGuid();
     AccountId = accountid;
     ModificationType = modificationType;
     Amount = amount;
     ModificationDateTime = modificationDateTime;
 }
Ejemplo n.º 13
0
 public Modifier(Modifier <E> modifier)
 {
     propertyType     = modifier.propertyType;
     modificationType = modifier.modificationType;
     value_1          = modifier.value_1;
     value_2          = modifier.value_2;
     value_3          = modifier.value_3;
 }
Ejemplo n.º 14
0
 protected override void PositionChanged(IPosition position, ModificationType type)
 {
     if ((type.Equals(ModificationType.Closed)) && (position.Id == _positionGuid))
     {
         _positionGuid            = Guid.Empty;
         _positionOpendSignalType = SignalType.None;
     }
 }
Ejemplo n.º 15
0
  } // NewBar
		
//============================================================================================================	

        protected override void PositionChanged(IPosition position, ModificationType type)
        {
            if (type==ModificationType.Closed)
            {
               if (posGuidBuy==position.Id)  posGuidBuy=Guid.Empty;  
		       if (posGuidSell==position.Id) posGuidSell=Guid.Empty;
            }
        }			
Ejemplo n.º 16
0
 protected override void PositionChanged(IPosition position, ModificationType type)
 {
     // Event occurs on every change of the positions
     if (type == ModificationType.Closed)
     {
         Print("Position {0} was closed at price {1}", position.Number, position.ClosePrice);
     }
 }
Ejemplo n.º 17
0
 protected override void PositionChanged(IPosition position, ModificationType type)
 {
     // Event occurs on every change of the positions
     if ((int)type == (int)ModificationType.Closed)
     {
         XXPrint("Position {0} was closed at price {1} with profit {2}",
                 position.Number, position.ClosePrice, position.Profit);
     }
 }
Ejemplo n.º 18
0
 public Modification(ModificationType modificationType, object oldValue, object newValue,
                     object target, PropertySpecifier property)
 {
     ModificationType = modificationType;
     OldValue         = oldValue;
     NewValue         = newValue;
     Target           = target;
     Property         = property;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates the event arguments object.
 /// </summary>
 /// <param name="type">The type of modification that occurred.</param>
 /// <param name="text">The text inserted or deleted.</param>
 /// <param name="location">The location of the modification.</param>
 /// <param name="userAction">A flag indicating if this action was caused by the user.</param>
 /// <param name="undo">A flag indicating if this action is part of an undo process.</param>
 /// <param name="redo">A flag indicating if this action is part of a redo process.</param>
 /// <param name="linesAdded">The number of lines added by this modification.</param>
 public ModifiedEventArgs(ModificationType type, TextPtr text, TextLocation location, bool userAction, bool undo, bool redo, int linesAdded)
 {
     ModificationType = type;
     Text             = text;
     Location         = location;
     UserAction       = userAction;
     Undo             = undo;
     Redo             = redo;
     LinesAdded       = linesAdded;
 }
        /// <summary>
        /// Serializes the object into ADSML xml.
        /// </summary>
        /// <returns><see cref="XElement"/></returns>
        public XElement ToAdsml()
        {
            this.Validate();

            var xml = new XElement("ModificationItem",
                                   new XAttribute("operation", ModificationType.GetStringValue()),
                                   new XElement("AttributeDetails", AttributeToModify.ToAdsml()));

            return(xml);
        }
Ejemplo n.º 21
0
 public Modification(string description, ModificationType type, char aminoAcid, double monoisotopicMassShift,
     double averageMassShift, bool defaultFixed, bool defaultVariable)
 {
     Description = description;
     Type = type;
     AminoAcid = aminoAcid;
     MonoisotopicMassShift = monoisotopicMassShift;
     AverageMassShift = averageMassShift;
     DefaultFixed = defaultFixed;
     DefaultVariable = defaultVariable;
 }
Ejemplo n.º 22
0
 public Modification(string description, ModificationType type, char aminoAcid, double monoisotopicMassShift,
                     double probability, bool defaultFixedModification, bool defaultVariableModification, bool automatic)
 {
     Description                 = description;
     Type                        = type;
     AminoAcid                   = aminoAcid;
     MonoisotopicMassShift       = monoisotopicMassShift;
     Probability                 = probability;
     DefaultFixedModification    = defaultFixedModification;
     DefaultVariableModification = defaultVariableModification;
     this.Automatic              = automatic;
 }
Ejemplo n.º 23
0
 public ModifiedEventArgs(NativeScintillaEventArgs nsea, Encoding enc)
 {
     _ModificationType = (ScintillaCsharp.Base.ModificationType)nsea.SCNotification.modificationType;
     _Position = nsea.SCNotification.position;
     _Length = nsea.SCNotification.length;
     _LinesAdded = nsea.SCNotification.linesAdded;
     // _Text = Utilities.ObtenerTextoMemoriaDll(nsea.SCNotification.text, enc);
     _Text = Utilities.IntPtrToString(enc, nsea.SCNotification.text, _Length);
     _Line = nsea.SCNotification.line;
     _FoldLevelNow = nsea.SCNotification.foldLevelNow;
     _FoldLevelPrev = nsea.SCNotification.foldLevelPrev;
 }
        public void InitForActionChange(ushort id, ushort aid, ModificationType modificationtype)
        {
            if (!IsInitialized)
            {
                Id               = id;
                TargetId         = aid;
                TargetItemType   = TargetItemType.Action;
                ModificationType = modificationtype;

                IsInitialized = true;
            }
        }
Ejemplo n.º 25
0
 public static bool IsStandardVarMod(ModificationType type)
 {
     switch (type)
     {
     case ModificationType.Standard:
     case ModificationType.AaSubstitution:
     case ModificationType.Glycan:
     case ModificationType.CleavedCrosslink:
         return(true);
     }
     return(false);
 }
Ejemplo n.º 26
0
        /**
         * {position}{Parameter}-{Type:accession}|{neutral loss}
         */
        public Modification(Section section, ModificationType type, string accession)
        {
            if (! section.isData()){
                throw new ArgumentException("Section should use Protein, Peptide, PSM or SmallMolecule.");
            }
            _section = section;
            _type = type;

            if (accession == null){
                throw new NullReferenceException("Modification accession can not null!");
            }
            _accession = accession;
        }
Ejemplo n.º 27
0
        public void LogChange(User user, ModificationType modificationType)
        {
            if (ThesisLogs == null)
            {
                ThesisLogs = new List <ThesisLog>();
            }

            ThesisLogs.Add(new ThesisLog
            {
                User             = user,
                ModificationType = modificationType
            });
        }
        public void InitForIntegerPropertyChange(ushort id, ushort pid, ModelPropertyType modelpropertytype, ModificationType modificationtype, int value)
        {
            if (!IsInitialized)
            {
                Id               = id;
                TargetId         = pid;
                TargetItemType   = TargetItemType.Property;
                ModificationType = modificationtype;

                ModificationDetails = (IModificationDetails)propertyFactory.Create(pid, value);

                IsInitialized = true;
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// This method is used to set the entries at a specific index in the
 /// DoubleModificationTimestamps, DoubleModificationTypes, and the
 /// DoubleOperatorNames arrays.
 /// </summary>
 /// <param name="idx">The index of the entries to be updated.</param>
 /// <param name="modificationTimestamp">The modificationTimestamp to be set for the entry.</param>
 /// <param name="modificationType">The modificationType to be set for the entry.</param>
 /// <param name="operatorName">The operatorName to be set for the entry.</param>
 /// <param name="statusCode">The statusCode to be set for the entry.</param>
 /// <param name="timestamp">The timestamp to be set for the entry.</param>
 /// <param name="value">The double value to be set for the entry.</param>
 public void SetDouble(int idx, DateTime modificationTimestamp, ModificationType modificationType,
                       string operatorName, uint statusCode, DateTime timestamp, double value)
 {
     if (DoubleModificationTimestamps is null ||
         DoubleModificationTypes is null ||
         DoubleOperatorNames is null)
     {
         throw new InvalidOperationException();
     }
     DoubleModificationTimestamps[idx] = modificationTimestamp;
     DoubleModificationTypes[idx]      = modificationType;
     DoubleOperatorNames[idx]          = operatorName;
     base.SetDouble(idx, statusCode, timestamp, value);
 }
        public void InitForRelationChange(ushort id, ushort rid, ushort relatedid, ModificationType modificationtype)
        {
            if (!IsInitialized)
            {
                Id               = id;
                TargetId         = rid;
                TargetItemType   = TargetItemType.Relation;
                ModificationType = modificationtype;

                ModificationDetails = new ModelRelation(rid, relatedid);

                IsInitialized = true;
            }
        }
Ejemplo n.º 31
0
 /// <summary>
 /// This method is used to set the entries at a specific index in the
 /// LongModificationTimestamps, LongModificationTypes, and the
 /// LonOperatorNames arrays
 /// </summary>
 /// <param name="idx">The index of the entries to be updated.</param>
 /// <param name="modificationTimestamp">The modificationTimestamp to be set for the entry.</param>
 /// <param name="modificationType">The modificationType to be set for the entry.</param>
 /// <param name="operatorName">The operatorName to be set for the entry.</param>
 /// <param name="statusCode">The statusCode to be set for the entry.</param>
 /// <param name="timestamp">The timestamp to be set for the entry.</param>
 /// <param name="value">The long value to be set for the entry.</param>
 public void SetUint(int idx, DateTime modificationTimestamp, ModificationType modificationType,
                     string operatorName, uint statusCode, DateTime timestamp, uint value)
 {
     if (LongModificationTimestamps is null ||
         LongModificationTypes is null ||
         LongOperatorNames is null)
     {
         throw new InvalidOperationException();
     }
     LongModificationTimestamps[idx] = modificationTimestamp;
     LongModificationTypes[idx]      = modificationType;
     LongOperatorNames[idx]          = operatorName;
     base.SetUint(idx, statusCode, timestamp, value);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// This method is used to set the entries at a specific index in the
 /// ObjectModificationTimestamps, ObjectModificationTypes, and the
 /// ObjectOperatorNames arrays.
 /// </summary>
 /// <param name="idx">The index of the entries to be updated.</param>
 /// <param name="modificationTimestamp">The modificationTimestamp to be set for the entry.</param>
 /// <param name="modificationType">The modificationType to be set for the entry.</param>
 /// <param name="operatorName">The operatorName to be set for the entry.</param>
 /// <param name="statusCode">The statusCode to be set for the entry.</param>
 /// <param name="timestamp">The timestamp to be set for the entry.</param>
 /// <param name="value">The object value to be set for the entry.</param>
 public void SetObject(int idx, DateTime modificationTimestamp, ModificationType modificationType,
                       string operatorName, uint statusCode, DateTime timestamp, object value)
 {
     if (ObjectModificationTimestamps is null ||
         ObjectModificationTypes is null ||
         ObjectOperatorNames is null)
     {
         throw new InvalidOperationException();
     }
     ObjectModificationTimestamps[idx] = modificationTimestamp;
     ObjectModificationTypes[idx]      = modificationType;
     ObjectOperatorNames[idx]          = operatorName;
     base.SetObject(idx, statusCode, timestamp, value);
 }
Ejemplo n.º 33
0
        protected override void PositionChanged(IPosition position, ModificationType type)
        {
            if (type == ModificationType.Closed || type == ModificationType.Canceled)
            {
                if (listOfBuyStop.Contains(position.Id))
                {
                    listOfBuyStop.Remove(position.Id);
                }

                if (listOfSellStop.Contains(position.Id))
                {
                    listOfSellStop.Remove(position.Id);
                }
            }
        }
Ejemplo n.º 34
0
 public Modification(string description, ModificationType type, char aminoAcid, double monoisotopicMassShift,
     double averageMassShift, double monoisotopicNeutralLossMass, double averageNeutralLossMass, bool defaultFixed, bool defaultVariable, string database, int databaseAccessionNumber, string databaseName, bool known)
 {
     Description = description;
     Type = type;
     AminoAcid = aminoAcid;
     MonoisotopicMassShift = monoisotopicMassShift;
     AverageMassShift = averageMassShift;
     MonoisotopicNeutralLossMass = monoisotopicNeutralLossMass;
     AverageNeutralLossMass = averageNeutralLossMass;
     DefaultFixed = defaultFixed;
     DefaultVariable = defaultVariable;
     Database = database;
     DatabaseAccessionNumber = databaseAccessionNumber;
     DatabaseName = databaseName;
     Known = known;
 }
Ejemplo n.º 35
0
        /// <summary>
        ///     Create an object using the contents of the corresponding MzIdentML object
        /// </summary>
        /// <param name="m"></param>
        /// <param name="idata"></param>
        public ModificationObj(ModificationType m, IdentDataObj idata)
            : base(m, idata)
        {
            _location                      = m.location;
            LocationSpecified              = m.locationSpecified;
            _avgMassDelta                  = m.avgMassDelta;
            AvgMassDeltaSpecified          = m.avgMassDeltaSpecified;
            _monoisotopicMassDelta         = m.monoisotopicMassDelta;
            MonoisotopicMassDeltaSpecified = m.monoisotopicMassDeltaSpecified;

            Residues = null;

            if (m.residues != null)
            {
                Residues = new List <string>(m.residues);
            }
        }
Ejemplo n.º 36
0
 public Modification(string description, ModificationType type, char aminoAcid, double monoisotopicMassShift,
                     double averageMassShift, double monoisotopicNeutralLossMass, double averageNeutralLossMass, bool defaultFixed, bool defaultVariable, string database, int databaseAccessionNumber, string databaseName, bool known)
 {
     Description                 = description;
     Type                        = type;
     AminoAcid                   = aminoAcid;
     MonoisotopicMassShift       = monoisotopicMassShift;
     AverageMassShift            = averageMassShift;
     MonoisotopicNeutralLossMass = monoisotopicNeutralLossMass;
     AverageNeutralLossMass      = averageNeutralLossMass;
     DefaultFixed                = defaultFixed;
     DefaultVariable             = defaultVariable;
     Database                    = database;
     DatabaseAccessionNumber     = databaseAccessionNumber;
     DatabaseName                = databaseName;
     Known                       = known;
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Enteres a modification history entry based on the submitted customer and the modification type.
        /// </summary>
        /// <param name="context">The context in which the modification entry will be performed.</param>
        /// <param name="customer">The customer object that has been modified. Original details are saved in the history table.</param>
        /// <param name="modificationType">The modofication type: Add, Remove, Update, Other</param>
        /// <returns></returns>
        private async Task EnterModificationHistory(CustomersContext context, Customer customer, ModificationType modificationType)
        {
            CustomerDbHistory customerHistory = new CustomerDbHistory()
            {
                // log modification type
                ModificationType = modificationType,
                // and customer details so it's easier to reproduce changes
                Id = customer.Id,
                AddressLineOne = customer.AddressLineOne,
                Category = customer.Category,
                Country = customer.Country,
                DateOfBirth = customer.DateOfBirth,
                Gender = customer.Gender,
                HouseNumber = customer.HouseNumber,
                Name = customer.Name,
                State = customer.State,
                ChangedOn = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")
            };

            try
            {
                context.CustomerDbHistories.Add(customerHistory);
                await context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                DbLog.LogException(e, "DataProxy.cs");
            }
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Creates the event arguments object.
 /// </summary>
 /// <param name="type">The type of modification that occurred.</param>
 /// <param name="text">The text inserted or deleted.</param>
 /// <param name="location">The location of the modification.</param>
 /// <param name="userAction">A flag indicating if this action was caused by the user.</param>
 /// <param name="undo">A flag indicating if this action is part of an undo process.</param>
 /// <param name="redo">A flag indicating if this action is part of a redo process.</param>
 /// <param name="linesAdded">The number of lines added by this modification.</param>
 public ModifiedEventArgs(ModificationType type, TextPtr text, TextLocation location, bool userAction, bool undo, bool redo, int linesAdded)
 {
     ModificationType = type;
     Text = text;
     Location = location;
     UserAction = userAction;
     Undo = undo;
     Redo = redo;
     LinesAdded = linesAdded;
 }
Ejemplo n.º 39
0
 private void CheckAuthorInfo(IEnumerable<AuthorInfoNode> authors)
 {
     foreach (AuthorInfoNode author in authors)
     {
         if (author.FirstName == null && author.LastName != null)
         {
             author.FirstName = String.Empty;
             this.modificationType |= ModificationType.Description;
         }
         else if (author.FirstName != null && author.LastName == null)
         {
             author.LastName = String.Empty;
             this.modificationType |= ModificationType.Description;
         }
         else if ((String.IsNullOrEmpty(author.FirstName) && String.IsNullOrEmpty(author.LastName)) && String.IsNullOrEmpty(author.NickName))
         {
             author.NickName = "FB2Fix";
             this.modificationType |= ModificationType.Description;
         }
     }
 }
Ejemplo n.º 40
0
 public ModificationModifiedEventArgs(ModificationType type, IStat sender)
 {
     this.type = type;
     this.sender = sender;
 }
Ejemplo n.º 41
0
        public FictionBook(XmlDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            this.document = document;

            this.documentStatus = Fb2FixStatus.None;

            XmlNode statusInfoNode = document.SelectSingleNode("//FictionBook/description/custom-info[@info-type='fb2fix-status']");
            if (statusInfoNode != null && statusInfoNode.NodeType == XmlNodeType.Element)
            {
                if (String.IsNullOrEmpty(statusInfoNode.InnerText))
                {
                    try
                    {
                        this.documentStatus = (Fb2FixStatus)Enum.Parse(typeof(Fb2FixStatus), statusInfoNode.InnerText, true);
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }

            this.documentInfoNode = document.SelectSingleNode("//FictionBook/description/document-info");
            if (this.documentInfoNode != null && this.documentInfoNode.NodeType == XmlNodeType.Element)
            {
                documentInfo = new DocumentInfoNode();
                documentInfo.Load(this.documentInfoNode as XmlElement);
            }

            this.titleInfoNode = document.SelectSingleNode("//FictionBook/description/title-info");
            if (this.titleInfoNode != null && this.titleInfoNode.NodeType == XmlNodeType.Element)
            {
                titleInfo = new TitleInfoNode();
                titleInfo.Load(this.titleInfoNode as XmlElement);
            }

            if (titleInfo == null)
            {
                throw new Exception("InvalidFictionBookFormatException");
            }

            this.srcTitleInfoNode = document.SelectSingleNode("//FictionBook/description/src-title-info");
            if (this.srcTitleInfoNode != null && this.srcTitleInfoNode.NodeType == XmlNodeType.Element)
            {
                srcTitleInfo = new TitleInfoNode();
                srcTitleInfo.Load(this.srcTitleInfoNode as XmlElement);
            }

            this.publishInfoNode = document.SelectSingleNode("//FictionBook/description/publish-info");
            if (this.publishInfoNode != null && this.publishInfoNode.NodeType == XmlNodeType.Element)
            {
                publishInfo = new PublishInfoNode();
                publishInfo.Load(this.publishInfoNode as XmlElement);
            }

            this.descriptionNode = document.SelectSingleNode("//FictionBook/description");

            if (this.descriptionNode == null)
            {
                throw new Exception("InvalidFictionBookFormatException");
            }

            XmlNodeList nodes = document.SelectNodes("//FictionBook/description/custom-info");

            customInfos = new List<CustomInfoNode>(nodes.Count);

            foreach (XmlNode node in nodes)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    CustomInfoNode item = new CustomInfoNode();
                    item.Load((XmlElement)node);

                    if (!String.IsNullOrEmpty(item.InfoType))
                    {
                        switch (item.InfoType)
                        {
                            case "fb2fix-status":
                            case "librusec-id":
                            case "previous-id":
                                continue;
                        }
                    }

                    item.XmlNode = node;
                    customInfos.Add(item);
                }
            }

            this.modificationType = ModificationType.None;
            this.containerDateTime = DateTime.Now;
        }
Ejemplo n.º 42
0
 public Modification(Section section, ModificationType type, int accession)
     : this(section, type, accession.ToString(CultureInfo.InvariantCulture))
 {
 }
 public ModificationEventArgs(string path, ModificationType type)
 {
     Path = path;
     Type = type;
 }
Ejemplo n.º 44
0
 public StatModifiedEventArgs(ModificationType type, IStatModification modification)
 {
     this.type = type;
     this.modification = modification;
 }
Ejemplo n.º 45
0
        public void CheckDocumentHeader()
        {
            foreach (TitleInfoNode infoNode in new TitleInfoNode[] { titleInfo, srcTitleInfo })
            {
                if (infoNode == null)
                {
                    continue;
                }

                if (infoNode.Genres.Count == 0)
                {
                    infoNode.Genres.Add(new GenreInfoNode("nonfiction"));
                    this.modificationType |= ModificationType.Description;
                }

                CheckAuthorInfo(infoNode.Authors);

                if (infoNode.BookTitle == null)
                {
                    if (publishInfo != null && !String.IsNullOrEmpty(publishInfo.BookName))
                    {
                        infoNode.BookTitle = publishInfo.BookName;
                        this.modificationType |= ModificationType.Description;
                    }
                    else if (titleInfo != null && !String.IsNullOrEmpty(titleInfo.BookTitle))
                    {
                        infoNode.BookTitle = titleInfo.BookTitle;
                        this.modificationType |= ModificationType.Description;
                    }
                    else
                    {
                        throw new Exception("InvalidFictionBookFormatException");
                    }
                }

                if (infoNode.Lang == null)
                {
                    infoNode.Lang = "ru";
                    this.modificationType |= ModificationType.Description;
                }

                CheckAuthorInfo(infoNode.Translators);
            }

            if (documentInfo == null)
            {
                documentInfo = new DocumentInfoNode();

                AuthorInfoNode documentAuthor = new AuthorInfoNode();
                documentAuthor.NickName = "FB2Fix";

                documentInfo.Authors.Add(documentAuthor);
                documentInfo.Id = ComputeDocumentId(document.DocumentElement.InnerText);
                documentInfo.Date = DateTime.Now;
                documentInfo.ProgramUsed = "FB2Fix";
                documentInfo.Version = 0.0f;

                this.modificationType |= ModificationType.DocumentInfo;
            }
            else
            {
                CheckAuthorInfo(documentInfo.Authors);

                if (documentInfo.Date == null)
                {
                    documentInfo.Date = DateTime.Now;
                    this.modificationType |= ModificationType.Description;
                }

                if (documentInfo.Version == null)
                {
                    documentInfo.Version = 0.0f;
                    this.modificationType |= ModificationType.DocumentInfo;
                }

                    if (String.IsNullOrEmpty(documentInfo.Id))
                    {
                        XmlElement xmlPreviousId = this.document.SelectSingleNode("//FictionBook/description/custom-info[@info-type='previous-id']") as XmlElement;

                        if (xmlPreviousId == null)
                        {
                            xmlPreviousId = document.CreateElement("custom-info");

                            XmlAttribute attr = document.CreateAttribute("info-type");
                            attr.Value = "previous-id";

                            xmlPreviousId.Attributes.Append(attr);
                            this.descriptionNode.AppendChild(xmlPreviousId);
                        }

                        xmlPreviousId.InnerText = documentInfo.Id;
                    }

                    documentInfo.Id = ComputeDocumentId(document.DocumentElement.InnerText);
                    this.modificationType |= ModificationType.Description;

                if (String.IsNullOrEmpty(documentInfo.Id))
                {
                    documentInfo.Id = ComputeDocumentId(document.DocumentElement.InnerText);
                    this.modificationType |= ModificationType.Description;
                }

                CheckAuthorInfo(documentInfo.Publishers);
            }

            XmlElement xmlNewTitleInfo = document.CreateElement("title-info");
            xmlNewTitleInfo = titleInfo.Store(document, xmlNewTitleInfo);
            this.descriptionNode.ReplaceChild(xmlNewTitleInfo, titleInfoNode);
            titleInfoNode = xmlNewTitleInfo;

            if (srcTitleInfo != null)
            {
                XmlElement xmlNewSrcTitleInfo = document.CreateElement("src-title-info");
                xmlNewSrcTitleInfo = srcTitleInfo.Store(document, xmlNewSrcTitleInfo);
                this.descriptionNode.ReplaceChild(xmlNewSrcTitleInfo, srcTitleInfoNode);
                srcTitleInfoNode = xmlNewSrcTitleInfo;
            }

            XmlElement xmlNewDocumentInfo = document.CreateElement("document-info");
            xmlNewDocumentInfo = documentInfo.Store(document, xmlNewDocumentInfo);
            if (documentInfoNode == null)
            {
                if (srcTitleInfoNode == null)
                {
                    this.descriptionNode.InsertAfter(xmlNewDocumentInfo, titleInfoNode);
                }
                else
                {
                    this.descriptionNode.InsertAfter(xmlNewDocumentInfo, srcTitleInfoNode);
                }
            }
            else
            {
                this.descriptionNode.ReplaceChild(xmlNewDocumentInfo, documentInfoNode);
            }

            if (publishInfo != null)
            {
                XmlElement xmlNewPublishInfo = document.CreateElement("publish-info");
                xmlNewPublishInfo = publishInfo.Store(document, xmlNewPublishInfo);

                if (xmlNewPublishInfo != null)
                {
                    this.descriptionNode.ReplaceChild(xmlNewPublishInfo, publishInfoNode);
                }
                else
                {
                    this.descriptionNode.RemoveChild(publishInfoNode);
                }
            }

            foreach (CustomInfoNode customInfoNode in customInfos)
            {
                XmlElement element = document.CreateElement("custom-info");
                element = customInfoNode.Store(document, element);

                if (element != null)
                {
                    this.descriptionNode.ReplaceChild(customInfoNode.XmlNode, element);
                }
                else
                {
                    this.descriptionNode.RemoveChild(customInfoNode.XmlNode);
                }
            }
        }
Ejemplo n.º 46
0
        private int GetModificationTypeCount(Token t, ModificationType modType )
        {
            int c = 0;
            foreach (var m in t.modifications)
            {
                if (m.modType == modType)
                {
                    ++c;
                }
            }

            return c;
        }