Exemplo n.º 1
0
        /// <summary>
        /// This method takes a record and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(BaseRecord rec, BaseColumn col)
		{
			ForeignKey fkColumn = PhotoClubsTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);
			if (fkColumn == null)
				return null;
			String _DFKA = fkColumn.PrimaryKeyDisplayColumns;
			if (_DFKA.Trim().StartsWith("="))
            {
                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation 
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return rec.Format(c);
                    }
                }
                            
				String tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
				return EvaluateFormula(_DFKA, rec, null, tableName);
			}
			else
				return null;
		}
Exemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jsonRecord = JObject.Load(reader);

            if (jsonRecord.ContainsKey("tx")) // 1P4 for MS-Windows
            {
                this.convertWinToMac(jsonRecord);
            }

            string     recordType = (string)jsonRecord.GetValue("typeName");
            BaseRecord record     = null;

            if (!string.IsNullOrEmpty(recordType) && classTypesByItemType.ContainsKey(recordType))
            {
                record = Activator.CreateInstance(classTypesByItemType[recordType]) as BaseRecord;
            }
            else
            {
                record = new UnknownRecord();
            }

            serializer.Populate(jsonRecord.CreateReader(), record);

            return(record);
        }
Exemplo n.º 3
0
            public static BaseArrayTable CreateFrom(BinaryReader reader, long beginAt, ushort classCount)
            {
                reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
                //---
                var    baseArrTable = new BaseArrayTable();
                ushort baseCount    = reader.ReadUInt16();

                baseArrTable._records = new BaseRecord[baseCount];
                // Read all baseAnchorOffsets in one go
                ushort[] baseAnchorOffsets = Utils.ReadUInt16Array(reader, classCount * baseCount);
                for (int i = 0; i < baseCount; ++i)
                {
                    AnchorPoint[] anchors = new AnchorPoint[classCount];
                    BaseRecord    baseRec = new BaseRecord(anchors);

                    //each base has anchor point for mark glyph'class
                    for (int n = 0; n < classCount; ++n)
                    {
                        ushort offset = baseAnchorOffsets[i * classCount + n];
                        if (offset <= 0)
                        {
                            //TODO: review here
                            //bug?
                            continue;
                        }
                        anchors[n] = AnchorPoint.CreateFrom(reader, beginAt + offset);
                    }

                    baseArrTable._records[i] = baseRec;
                }
                return(baseArrTable);
            }
Exemplo n.º 4
0
        /// <summary>
        /// This method takes a keyValue and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(String keyValue, BaseColumn col, String formatPattern)
        {
            if (keyValue == null)
            {
                return(null);
            }
            ForeignKey fkColumn = AreasTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);

            if (fkColumn == null)
            {
                return(null);
            }
            String _DFKA = fkColumn.PrimaryKeyDisplayColumns;

            if (_DFKA.Trim().StartsWith("="))
            {
                String          tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                PrimaryKeyTable t         = (PrimaryKeyTable)DatabaseObjects.GetTableObject(tableName);
                BaseRecord      rec       = null;

                if (t != null)
                {
                    try
                    {
                        rec = (BaseRecord)t.GetRecordData(keyValue, false);
                    }
                    catch
                    {
                        rec = null;
                    }
                }
                if (rec == null)
                {
                    return("");
                }

                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column        = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return(rec.Format(c));
                    }
                }
                return(EvaluateFormula(_DFKA, rec, null, tableName));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 private Plugin GetPluginFromNode(BaseRecord node)
 {
     BaseRecord tn = node;
     var pluginFromNode = tn as Plugin;
     if (pluginFromNode != null) return pluginFromNode;
     while (!(tn is Plugin) && tn != null) tn = tn.Parent;
     if (tn != null) return tn as Plugin;
     return null;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initalize this class with a record with recommended values for a BaseRecord
        /// </summary>
        /// <param name="record"></param>
        internal ResultPrimarySecondary(BaseRecord record)
        {
            //Short-circut some values
            Conclusion = record.Conclusion;
            string description = string.IsNullOrWhiteSpace(record.Description) ? string.Empty : record.Description;

            switch (Conclusion)
            {
                //The primary result for these conclusion is always our pre-set value and (if available) the description from the script as secondary
                case ConclusionEnum.Success:
                case ConclusionEnum.DoesNotApply:
                case ConclusionEnum.Fatal:

                    //Set Primary to a descriptive text, e.g. Conclusiong==Success -> "OK (Success)"
                    Primary = ConclusionEnumConverter.ConclusionHumanized(Conclusion);

                    if (record is AssetRecord)
                    {
                        //For an asset that returned SUCCESS, the VALUE the asset has retrieved is the interessting part, hence change primary to the value
                        if (Conclusion == ConclusionEnum.Success)
                        {
                            Primary = (record as AssetRecord).Data;
                        }

                        //Assign to secondary either the default conclusion description or the one from the script
                        Secondary = string.IsNullOrWhiteSpace(description) ? ConclusionEnumConverter.AssetRecordConclusionDescription(Conclusion) : description;
                    }
                    else
                    {
                        Secondary = string.IsNullOrWhiteSpace(description) ? ConclusionEnumConverter.TestRecordConclusionDescription(Conclusion) : description;
                    }

                    break;

                //For these conclusions, the text will be promoted to be Primary, and our internal description for the conclusion is secondary.
                //The exception for this rule is if we have text, then the value from the script will be used
                case ConclusionEnum.Inconclusive:
                case ConclusionEnum.Major:
                case ConclusionEnum.Minor:
                    if (record is AssetRecord)
                    {
                        Primary = string.IsNullOrEmpty(description) ? ConclusionEnumConverter.ConclusionHumanized(Conclusion) : description;
                        Secondary = ConclusionEnumConverter.AssetRecordConclusionDescription(Conclusion);
                    }
                    else
                    {
                        Primary = string.IsNullOrEmpty(description) ? ConclusionEnumConverter.ConclusionHumanized(Conclusion) : description;
                        Secondary = ConclusionEnumConverter.TestRecordConclusionDescription(Conclusion);

                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", Conclusion.ToString()));
            }
        }
Exemplo n.º 7
0
        private bool IsNonConformingRecord(BaseRecord tn)
        {
            if (tn is Record)
            {
                var r = tn as Record;
                return(r != null && !r.MatchRecordStructureToRecord());
            }

            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Updates an instance obtained through copy constructor into database.
        /// </summary>
        ///
        public MovieExemplar Update()
        {
            VerifyUpdate();

            BaseRecord.SetFieldsFrom(this);

            Movie.MovieExemplars.OnUpdated(BaseRecord);

            return(BaseRecord);
        }
Exemplo n.º 9
0
 public void Read(TTFReader r, int markClassCount)
 {
     r.ReadInt(out this.baseCount);
     this.baseRecord = new List <BaseRecord>();
     for (int i = 0; i < this.baseCount; ++i)
     {
         BaseRecord br = new BaseRecord();
         br.Read(r, markClassCount);
         baseRecord.Add(br);
     }
 }
Exemplo n.º 10
0
 public static void GetFormattedHeader(this BaseRecord rec, RTFBuilder rb)
 {
     if (rec is Record)
     {
         ((Record)rec).GetFormattedHeader(rb);
     }
     else if (rec is SubRecord)
     {
         ((SubRecord)rec).GetFormattedHeader(rb);
     }
 }
Exemplo n.º 11
0
        private void PasteSubRecord()
        {
            if (!this.ValidateMakeChange())
            {
                return;
            }

            if (!MainView.HasClipboardData <SubRecord[]>())
            {
                return;
            }

            try
            {
                BaseRecord br = this.Selection.Record;

                int insertIdx = this.listSubrecord.SelectedIndices.Count == 0 ? -1 : this.listSubrecord.GetFocusedItem();
                var nodes     = MainView.GetClipboardData <SubRecord[]>();
                foreach (var clipSr in insertIdx < 0 ? nodes : nodes.Reverse())
                {
                    // insert in revers
                    var sr = clipSr.Clone() as SubRecord;
                    if (sr == null)
                    {
                        return;
                    }

                    if (br is Record)
                    {
                        try
                        {
                            if (insertIdx >= 0 && insertIdx < this.listSubrecord.Items.Count)
                            {
                                br.InsertRecord(insertIdx, sr);
                            }
                            else
                            {
                                br.AddRecord(sr);
                            }
                        }
                        catch (TESParserException ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }

                this.RebuildSelection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 12
0
        internal bool findNonConformingRecordIncremental(BaseRecord tn, bool forward, bool wrapAround)
        {
            var node = this.IncrementalSearch(tn, false, forward, wrapAround, this.IsNonConformingRecord);

            if (node != null)
            {
                this.PluginTree.SelectedRecord = node;
            }

            return(node != null);
        }
 public override DoStuff(BaseRecord record)
 {
     if (record is DerivedRecordOne)
     {
         // Do DerivedRecordOne stuff here
     }
     else
     {
         // do base stuff
         base.DoStuff(record);
     }
 }
Exemplo n.º 14
0
 public SearchSettings()
 {
     this.type       = SearchType.EditorID;
     this.startNode  = null;
     this.text       = null;
     this.first      = true;
     this.partial    = true;
     this.forward    = true;
     this.wrapAround = true;
     this.updateFunc = null;
     this.rectype    = null;
 }
Exemplo n.º 15
0
 public static void GetFormattedData(this BaseRecord rec, StringBuilder sb)
 {
     //if (rec is Record)
     //    ((Record)rec).GetFormattedData(sb);
     if (rec is SubRecord)
     {
         ((SubRecord)rec).GetFormattedData(sb);
     }
     else
     {
         sb.Append(rec.GetDesc());
     }
 }
Exemplo n.º 16
0
 public static void giveBaseRecordNewFormID(BaseRecord rec, bool updateReference, ref uint formCount, ref uint refCount)
 {
     if (rec is Record)
     {
         giveRecordNewFormID((Record)rec, updateReference, ref formCount, ref refCount);
     }
     else if (rec is GroupRecord)
     {
         foreach (BaseRecord rec2 in ((GroupRecord)rec).Records)
         {
             giveBaseRecordNewFormID(rec2, updateReference, ref formCount, ref refCount);
         }
     }
 }
Exemplo n.º 17
0
    public override DoStuff(BaseRecord record)
    {
        DerivedRecordOne derivedRecordOne = record as DerivedRecordOne;

        if (null != derivedRecordOne)
        {
            // Do DerivedRecordOne stuff here using local variable derivedRecordOne
        }
        else
        {
            // do base stuff
            base.DoStuff(record);
        }
    }
Exemplo n.º 18
0
        private void AddMaintenanceItems(BaseRecord record)
        {
            if (!_fileItems.ContainsKey(record.RecovererCode))
            {
                _fileItems.Add(record.RecovererCode, new Dictionary <int, List <BaseRecord> >());
            }

            if (!_fileItems[record.RecovererCode].ContainsKey(record.AccountId))
            {
                _fileItems[record.RecovererCode].Add(record.AccountId, new List <BaseRecord>());
            }

            _fileItems[record.RecovererCode][record.AccountId].Add(record);
        }
Exemplo n.º 19
0
        public override void Fill(params object[] references)
        {
            if (references.Length < 1)
            {
                return;
            }
            Guid reference = (Guid)references[0];

            if (reference.Equals(Guid.Empty))
            {
                return;
            }
            using (new WaitingCursor())
                using (IDbCommand cmd = BDDatabase.Database.GetCommand())
                {
                    cmd.CommandText = "SELECT ID_PERSONNE, NOMPERSONNE, SITEWEB, BIOGRAPHIE FROM PERSONNES WHERE ID_PERSONNE = ?";
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(BDDatabase.Database.GetParameter("@ID_personne", StringUtils.GuidToString(reference)));
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader <AuteurComplet> dataReader = new BaseDataReader <AuteurComplet>(result))
                            if (result != null && result.Read())
                            {
                                dataReader.LoadData(this);
                            }

                    // UpperTitreSerie en premier pour forcer l'union à trier sur le titre
                    cmd.CommandText  = "SELECT UPPERTITRESERIE, s.ID_SERIE";
                    cmd.CommandText += " FROM ALBUMS al";
                    cmd.CommandText += "  INNER JOIN AUTEURS au ON al.ID_album = au.ID_album AND au.ID_personne = ?";
                    cmd.CommandText += "  INNER JOIN SERIES s ON s.ID_serie = al.ID_serie";
                    cmd.CommandText += " union ";
                    cmd.CommandText += "SELECT UPPERTITRESERIE, s.ID_SERIE";
                    cmd.CommandText += " FROM auteurs_series au";
                    cmd.CommandText += "  INNER JOIN SERIES s ON s.ID_serie = au.ID_serie AND au.ID_personne = ?";
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(BDDatabase.Database.GetParameter("@ID_personne1", StringUtils.GuidToString(reference)));
                    cmd.Parameters.Add(BDDatabase.Database.GetParameter("@ID_personne2", StringUtils.GuidToString(reference)));
                    this.Séries.Clear();
                    using (IDataReader result = cmd.ExecuteReader())
                        using (BaseDataReader <object> dataReader = new BaseDataReader <object>(result))
                            if (result != null)
                            {
                                while (result.Read())
                                {
                                    this.Séries.Add(BaseRecord.Create <SérieComplet>(dataReader.GetGuid(1), this.ID_Auteur));
                                }
                            }
                }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Updates an instance obtained through copy constructor into database.
        /// </summary>
        ///
        public Movie Update()
        {
            VerifyUpdate();

            BaseRecord.SetFieldsFrom(this);

            Database.Movies.OnUpdated(BaseRecord);

            foreach (MovieExemplar exemplar in MovieExemplars)
            {
                MovieExemplars.OnUpdated(exemplar, "Updated Movie");
            }

            return(BaseRecord);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Populates trading support records for the securities of each working order in a set.
        /// </summary>
        /// <param name="orders">The working orders to populate records for.</param>
        /// <returns>The populated records.</returns>
        protected virtual BaseRecord[] PopulateSecurityRecords(List <IMovableObject> orders)
        {
            BaseRecord[] records = new BaseRecord[orders.Count];

            for (Int32 index = 0; index < orders.Count; ++index)
            {
                WorkingOrder order = orders[index] as WorkingOrder;

                records[index] = new BaseRecord {
                    RowId = order.WorkingOrderId, RowVersion = order.RowVersion
                };
            }

            return(records);
        }
Exemplo n.º 22
0
 public static void GetFormattedData(this BaseRecord rec, RTFBuilder rb)
 {
     if (rec is Record)
     {
         ((Record)rec).GetFormattedData(rb);
     }
     else if (rec is SubRecord)
     {
         ((SubRecord)rec).GetFormattedData(rb);
     }
     else
     {
         rb.Append(rec.GetDesc());
     }
 }
Exemplo n.º 23
0
        public T OverwriteRecord <T>(Guid guid, BaseRecord newRecord) where T : BaseRecord
        {
            if (!typeof(BaseRecord).IsAssignableFrom(typeof(T)))
            {
                throw new BlobDatabaseRecordTypeException("The type given for T does not inherit BaseRecord");
            }

            var record = RecordExists(guid) ? CreateRecord <T>() : GetRecord <T>(guid);

            record.Load(newRecord.CopyBlob());

            NeedsStore();
            Save();

            return(record);
        }
Exemplo n.º 24
0
        public void UpdateRecord(BaseRecord sc)
        {
            if (sc == null)
            {
                UpdateText("");
                return;
            }
            FontLangInfo defLang;
            if (!Encoding.TryGetFontInfo(Properties.Settings.Default.LocalizationName, out defLang))
                defLang = new FontLangInfo(1252, 1033, 0);

            var rb = new RTFBuilder(RTFFont.Arial, 16, defLang.lcid, defLang.charset);
            sc.GetFormattedHeader(rb);
            sc.GetFormattedData(rb);
            this.rtfInfo.Rtf = rb.ToString();            
        }
Exemplo n.º 25
0
        public virtual string EvaluateFormula(string formula, BaseRecord dataSourceForEvaluate, string format)
        {
            Data.BaseFormulaEvaluator e = new Data.BaseFormulaEvaluator();

            // All variables referred to in the formula are expected to be
            // properties of the DataSource.  For example, referring to
            // UnitPrice as a variable will refer to DataSource.UnitPrice
            e.DataSource = dataSourceForEvaluate;

            Object resultObj = e.Evaluate(formula);

            if (resultObj == null)
            {
                return("");
            }
            return(resultObj.ToString());
        }
Exemplo n.º 26
0
        internal void PasteFromClipboard(bool recordOnly)
        {
            if (!MainView.HasClipboardData())
            {
                MainView.PostStatusWarning(Resources.TheClipboardIsEmpty);
                return;
            }
            var clipboardObject = MainView.Clipboard;

            bool isRec     = clipboardObject is Record || clipboardObject is GroupRecord;
            bool isRecList = clipboardObject is BaseRecord[];


            if (recordOnly && !(isRec || isRecList))
            {
                return;
            }
            if (isRec)
            {
                BaseRecord node = PluginTree.SelectedRecord;
                try
                {
                    var dstNode = PluginTree.SelectedRecord;
                    var br      = ((BaseRecord)clipboardObject).Clone();
                    node.AddRecord(br);
                    RebuildSelection();
                }
                catch (TESParserException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (isRecList)
            {
                var gr = PluginTree.SelectedRecord as IGroupRecord;
                if (gr != null)
                {
                    foreach (var rec in (BaseRecord[])clipboardObject)
                    {
                        gr.AddRecord(rec);
                    }
                    RefreshObject(gr as BaseRecord);
                }
            }
        }
Exemplo n.º 27
0
        public void UpdateRecord(BaseRecord record)
        {
            if (record == null)
            {
                this.UpdateText(string.Empty);
                return;
            }

            try
            {
                string html = TESVSnip.UI.Rendering.HtmlRenderer.GetDescription(record);
                UpdateText(html);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.WarningText);
            }
        }
Exemplo n.º 28
0
        private Plugin GetPluginFromNode(BaseRecord node)
        {
            BaseRecord tn = node;

            if (tn is Plugin)
            {
                return((Plugin)tn);
            }
            while (!(tn is Plugin) && tn != null)
            {
                tn = tn.Parent;
            }
            if (tn != null)
            {
                return(tn as Plugin);
            }
            return(null);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Updates an instance obtained through copy constructor into database.
        /// </summary>
        ///
        public Customer Update()
        {
            VerifyUpdate();

            Customer customerWithPID = Database.Customers.FindByPersID(PersonID);

            if (customerWithPID != null && customerWithPID != BaseRecord)
            {
                throw new ArgumentException("Customer #" + customerWithPID.ID
                                            + " (" + customerWithPID.FullName + ") already has PID " + PersonID);
            }

            BaseRecord.SetFieldsFrom(this);

            Database.Customers.OnUpdated(BaseRecord);

            return(BaseRecord);
        }
Exemplo n.º 30
0
        protected override void ProcessNonEmptyData(BaseRecord record, Hashtable table, string dataKeyValue)
        {
            //The basic values are all set by :base() and it was also validated that the hashtable contains a key ".Data". 
            TestRecord testRecord = new TestRecord(record);

            //Data is not NULL and not "", hence we need to check which conclusion the author wanted to report
            ConclusionEnum conclusion = ConclusionEnumConverter.ParseConclusion(dataKeyValue);

            if (conclusion == ConclusionEnum.Fatal)
            {
                //We were not able to parse the value inside .Data
                testRecord.AddLineToProcessMessages(string.Format("Unable to parse result {0}", dataKeyValue));

            }
            testRecord.Conclusion = conclusion;

            _results.Add(testRecord);

        }
Exemplo n.º 31
0
        private Plugin GetPluginFromNode(BaseRecord node)
        {
            var tn             = node;
            var pluginFromNode = tn as Plugin;

            if (pluginFromNode != null)
            {
                return(pluginFromNode);
            }
            while (!(tn is Plugin) && tn != null)
            {
                tn = tn.Parent;
            }
            if (tn != null)
            {
                return(tn as Plugin);
            }
            return(null);
        }
Exemplo n.º 32
0
        public void UpdateRecord(BaseRecord sc)
        {
            if (sc == null)
            {
                UpdateText("");
                return;
            }
            FontLangInfo defLang;

            if (!Encoding.TryGetFontInfo(Properties.Settings.Default.LocalizationName, out defLang))
            {
                defLang = new FontLangInfo(1252, 1033, 0);
            }

            var rb = new RTFBuilder(RTFFont.Arial, 16, defLang.lcid, defLang.charset);

            sc.GetFormattedHeader(rb);
            sc.GetFormattedData(rb);
            this.rtfInfo.Rtf = rb.ToString();
        }
Exemplo n.º 33
0
        internal BaseRecord IncrementalSearch(BaseRecord tn, bool first, bool forward, bool wrapAround, Predicate <BaseRecord> searchFunc)
        {
            using (var itr = new RecursiveRecordIterator(tn, forward))
            {
                BaseRecord startNode = null;
                Debug.Assert(tn.Equals(itr.Current));
                bool keep = first;
                do
                {
                    do
                    {
                        tn = itr.Current;
                        if (keep && searchFunc(tn))
                        {
                            return(tn);
                        }

                        keep = true;
                        if (startNode == null)
                        {
                            startNode = tn;
                        }
                        else if (startNode.Equals(tn))
                        {
                            return(null);
                        }
                    }while (itr.MoveNext());

                    if (!wrapAround)
                    {
                        break;
                    }

                    itr.Push(PluginList.All.Records[0] as BaseRecord);
                    itr.Reset();
                    wrapAround = false; // multipass protection
                }while (itr.MoveNext());
            }

            return(null);
        }
Exemplo n.º 34
0
        protected override void ProcessNonEmptyData(BaseRecord record, Hashtable table, string dataKeyValue)
        {
            AssetRecord assetRecord = new AssetRecord(record);

            //Data is set = Conclusion.Success
            assetRecord.Conclusion = ConclusionEnum.Success;
            assetRecord.Data = dataKeyValue;

            //Check the object that was returned and copy it to .DataNative (if we support the type)
            object dataObjectFromHashtable = GetObjectFromHashtable(table, Xteq5EngineConstant.ReturnedHashtableKeyData);

            if (dataObjectFromHashtable is string)
            {
                //String is the default of .Data. Therefore no action is required
            }
            else
            {
                if (dataObjectFromHashtable is bool)
                {
                    assetRecord.DataNative = (Boolean)dataObjectFromHashtable;
                }
                else
                {
                    if (dataObjectFromHashtable is int)
                    {
                        assetRecord.DataNative = (int)dataObjectFromHashtable;
                    }

                    else
                    {
                        if (dataObjectFromHashtable is System.Version)
                        {
                            assetRecord.DataNative = dataObjectFromHashtable as System.Version;
                        }
                    }
                }
            }


            _results.Add(assetRecord);
        }
Exemplo n.º 35
0
 public static string GetDescription(BaseRecord rec)
 {
     if (rendererImpl == null)
     {
         var sb = new StringBuilder();
         Extensions.StringRenderer.GetFormattedData(rec, sb);
         return(sb.ToString());
     }
     try
     {
         var kwargs = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase);
         kwargs["title"] = "Record";
         kwargs["css"]   = new string[] { Path.ChangeExtension(RendererPyPath, ".css") };
         return(rendererImpl.Render(rec, kwargs));
     }
     catch (Exception ex)
     {
         return(ex.ToString());
         //return Extensions.StringRenderer.GetDesc(rec);
     }
 }
Exemplo n.º 36
0
 private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ValidateMakeChange())
         return;
     if (Clipboard == null)
     {
         MessageBox.Show("The clipboard is empty", "Error");
         return;
     }
     BaseRecord node = (BaseRecord)PluginTree.SelectedNode.Tag;
     if (Clipboard is Plugin)
     {
         MessageBox.Show("Plugin merging has been disabled");
         return;
     }
     try
     {
         node.AddRecord(Clipboard);
         Clipboard = Clipboard.Clone();
         if (ClipboardNode != null)
         {
             PluginTree.SelectedNode.Nodes.Add(ClipboardNode);
             ClipboardNode = (TreeNode)ClipboardNode.Clone();
             ClipboardNode.Tag = Clipboard;
         }
         else
         {
             PluginTree_AfterSelect(null, null);
         }
     }
     catch (TESParserException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 37
0
 private void TESsnip_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (searchForm != null) searchForm.Close();
     PluginTree.Nodes.Clear();
     Clipboard = null;
     ClipboardNode = null;
     parentRecord = null;
     CloseStringEditor();
     Settings.SetWindowPosition("TESsnip", this);
 }
Exemplo n.º 38
0
        private void toolStripCopySubrecord_Click(object sender, EventArgs e)
        {
            var sr = GetSelectedSubrecord();
            if (sr == null) return;

            Clipboard = (SubRecord)sr.Clone();
            ClipboardNode = null;
        }
Exemplo n.º 39
0
 protected override void ProcessTest(StringBuilder sbTests, TestRecord test, BaseRecord baseRec, ResultPrimarySecondary resultPrimSecond)
 {
     sbTests.AppendLine(CreateTableRow(baseRec, resultPrimSecond));
 }
Exemplo n.º 40
0
 //Called by this class for each test that exists. Imlementation must add the content to the given stringbuilder.
 protected abstract void ProcessTest(StringBuilder sbTests, TestRecord test, BaseRecord baseRec, ResultPrimarySecondary resultPrimSecond);
        public virtual string EvaluateFormula(string formula, BaseRecord  dataSourceForEvaluate, string format)
        {
            Data.BaseFormulaEvaluator e = new Data.BaseFormulaEvaluator();

            // All variables referred to in the formula are expected to be
            // properties of the DataSource.  For example, referring to
            // UnitPrice as a variable will refer to DataSource.UnitPrice
            e.DataSource = dataSourceForEvaluate;

            Object resultObj = e.Evaluate(formula);
            if(resultObj == null)
            return "";
            return resultObj.ToString();
        }
Exemplo n.º 42
0
 protected override void ProcessEmptyData(BaseRecord record, Hashtable table)
 {
     //Conclusion is already set to .DoesNotApply
     TestRecord rec = new TestRecord(record);
     _results.Add(rec);
 }
Exemplo n.º 43
0
 protected override void ProcessFailure(BaseRecord record)
 {
     //All basic values were set by BaseRunner already, so we simply add it to our list
     TestRecord rec = new TestRecord(record);
     _results.Add(rec);
 }
Exemplo n.º 44
0
        public string GetDataForExport(BaseColumn col, BaseRecord rec)
        {
            String val = "";

            if (col.TableDefinition.IsExpandableNonCompositeForeignKey(col))
            {
                //  Foreign Key column, so we will use DFKA and String type.
                val = rec.Format(col);
            }
            else
            {
                switch (col.ColumnType)
                {
                    case BaseColumn.ColumnTypes.Binary:
                    case BaseColumn.ColumnTypes.Image:
                        break;
                    case BaseColumn.ColumnTypes.Currency:
                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                        val = rec.Format(col);
                        break;
                    default:
                        val = rec.Format(col);
                        break;
                }
            }
            return val;
        }
Exemplo n.º 45
0
                public BaseRecord GetBaseRecord(uint i)
                {
                    BaseRecord br = null;

                    if (i < BaseCount)
                    {
                        ushort sizeofBaseRecord = (ushort)(2 * m_ClassCount);
                        uint offset = m_offsetBaseArrayTable + (uint)FieldOffsets.BaseRecordArray + i*sizeofBaseRecord;
                        br = new BaseRecord(offset, m_bufTable, m_offsetBaseArrayTable, m_ClassCount);
                    }

                    return br;
                }
Exemplo n.º 46
0
        protected internal string GetValueForExcelExport(ExcelColumn col, BaseRecord rec)
        {
            String val = "";
            bool isNull = false;
            decimal deciNumber;

            if (col == null)
                return null;
            //DFKA value is evaluated in the <tablename>ExportExcelButton_Click method in the <tablename>.controls file
            //if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
            //{
            //    //  Foreign Key column, so we will use DFKA and String type.
            //    val = rec.Format(col.DisplayColumn);
            //}
            //else
            //{
                switch (col.DisplayColumn.ColumnType)
                {

                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                    case BaseColumn.ColumnTypes.Currency:
                        ColumnValue numVal = rec.GetValue(col.DisplayColumn);
                        //If the value of the column to be exported is nothing, add an empty cell to the Excel file
                        if (numVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {
                            deciNumber = numVal.ToDecimal();
                            val = deciNumber.ToString(System.Globalization.CultureInfo.InvariantCulture);

                            if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Currency)
                            {
                                val = rec.Format(col.DisplayColumn, "c");
                            }
                            else if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Percentage)
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            } else if (col.DisplayFormat == "Standard")
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            }
                        }
                        break;
                    case BaseColumn.ColumnTypes.Date:
                        ColumnValue dateVal = rec.GetValue(col.DisplayColumn);
                        if (dateVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {  // Specify the default Excel format for the date field
                            // val = rec.Format(col.DisplayColumn, "s");
                            // val += ".000";
                            val = rec.Format(col.DisplayColumn, "d");
                        }
                        break;
                    case BaseColumn.ColumnTypes.Very_Large_String:
                        val = rec.GetValue(col.DisplayColumn).ToString();
                        break;

                    case BaseColumn.ColumnTypes.Boolean:
                        val = rec.Format(col.DisplayColumn);
                        break;

                    default:
                        val = rec.Format(col.DisplayColumn);
                        break;
                }
            //}
            if (isNull)
                return null;
            else
                return val;
        }
Exemplo n.º 47
0
 internal AssetRecord(BaseRecord baseRecord)
     : base(baseRecord)
 {
     Data = string.Empty;
     DataNative = null;
 }
Exemplo n.º 48
0
 private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ValidateMakeChange())
         return;
     if (MessageBox.Show("This will close all open plugins, and you will lose any unsaved changes.\n" +
         "Are you sure you wish to continue", "Warning", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
     PluginTree.Nodes.Clear();
     Clipboard = null;
     ClipboardNode = null;
     CloseStringEditor();
     GC.Collect();
 }
Exemplo n.º 49
0
        //Bootstrap helper function
        string CreateTableRow(BaseRecord record, ResultPrimarySecondary primarySecondary)
        {
            WeakHTMLTag tr = new WeakHTMLTag("tr");

            //If the conclusion is MAJOR or FATAL, add a class to the TR so the entire row is colored
            if ((record.Conclusion == ConclusionEnum.Major) || (record.Conclusion == ConclusionEnum.Fatal))
            {
                tr.CSSClass = ConclusionToCSSModifier(record.Conclusion);
            }

            //Add parameter for script details modal
            tr.Attributes["data-toggle"] = "modal";
            tr.Attributes["data-target"] = "#modalDetails";
            tr.Attributes["data-modal-title"] = WeakHTMLTag.HTMLEncode(record.ScriptFilename);
            tr.Attributes["data-modal-content"] = ConvertProcessMessagesToHTML(record.ProcessMessages);

            //Create <td> for Status
            string tdStatus = CreateHTMLElement_TdGlyphSpan(record.Conclusion);

            //Create <td> for Name and Script file
            string tdName = CreateHTMLElement_TdTextSmallText(record.Name, record.ScriptFilename);

            string tdValue = CreateHTMLElement_TdTextSmallText(primarySecondary.Primary, primarySecondary.Secondary);
            tr.HTML = tdStatus + tdName + tdValue;

            return tr.ToString() + "\r\n";
        }
Exemplo n.º 50
0
        /// <summary>
        /// This method takes a record and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(BaseRecord rec, BaseColumn col)
        {
            ForeignKey fkColumn = UsersTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);
            if (fkColumn == null)
                return null;
            String _DFKA = fkColumn.PrimaryKeyDisplayColumns;
            if (_DFKA.Trim().StartsWith("="))
            {
                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return rec.Format(c);
                    }
                }

                String tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                return EvaluateFormula(_DFKA, rec, null, tableName);
            }
            else
                return null;
        }
Exemplo n.º 51
0
 protected override void ProcessAsset(StringBuilder sbAssets, AssetRecord asset, BaseRecord baseRec, ResultPrimarySecondary resultPrimSecond)
 {
     sbAssets.AppendLine(CreateTableRow(baseRec, resultPrimSecond));
 }
Exemplo n.º 52
0
 protected override void ProcessEmptyData(BaseRecord record, Hashtable table)
 {
     //All basic values were set by BaseRunner already, so we simply add it to our list
     AssetRecord rec = new AssetRecord(record);
     _results.Add(rec);
 }
Exemplo n.º 53
0
 //Called by this class for each asset that exists. Imlementation must add the content to the given stringbuilder.
 protected abstract void ProcessAsset(StringBuilder sbAssets, AssetRecord asset, BaseRecord baseRec, ResultPrimarySecondary resultPrimSecond);
Exemplo n.º 54
0
 public void RefreshObject(BaseRecord record)
 {
     PluginTree.RefreshObject(record);
 }
Exemplo n.º 55
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedSubrecord)
            {
                if (listSubrecord.SelectedIndices.Count != 1) return;
                int idx = listSubrecord.SelectedIndices[0];

                SubRecord sr = (SubRecord)listSubrecord.DataSource[idx];
                Clipboard = (SubRecord)sr.Clone();
                ClipboardNode = null;
            }
            else if (PluginTree.SelectedNode.Tag is Plugin)
            {
                MessageBox.Show("Cannot copy a plugin", "Error");
            }
            else
            {
                BaseRecord node = ((BaseRecord)PluginTree.SelectedNode.Tag).Clone();
                Clipboard = node;
                ClipboardNode = (TreeNode)PluginTree.SelectedNode.Clone();
                ClipboardNode.Tag = node;
                if (ClipboardNode.Nodes.Count > 0)
                {
                    ClipboardNode.Nodes.Clear();
                    foreach (Rec r in ((GroupRecord)node).Records) WalkPluginTree(r, ClipboardNode);
                }

            }
        }