private bool GetPeptideProteinMap(SQLiteReader reader, string tableName, out List <RowEntry> pepToProtMapping)
        {
            reader.SQLText = "SELECT * FROM [" + tableName + "]";

            // Make a Mage sink Module (row buffer
            var sink = new SimpleSink();

            // Construct and run mage pipeline to get the peptide and protein info
            ProcessingPipeline.Assemble("Test_Pipeline", reader, sink).RunRoot(null);

            var proteinIdx = sink.ColumnIndex["Protein"];
            var peptideIdx = sink.ColumnIndex["Peptide"];

            pepToProtMapping = new List <RowEntry>();
            foreach (object[] row in sink.Rows)
            {
                var entry = new RowEntry
                {
                    ProteinEntry = (string)row[proteinIdx],
                    PeptideEntry = (string)row[peptideIdx]
                };
                pepToProtMapping.Add(entry);
            }
            if (pepToProtMapping.Count == 0)
            {
                throw new Exception("Error reading data from " + tableName + "; no results found using " + reader.SQLText);
            }

            return(true);
        }
示例#2
0
        private void cmdOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                this.Table.StaticData.Clear();
                var dt = (System.Data.DataTable) this.dataGridView1.DataSource;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    var rowEntry = new RowEntry(this.Table.Root);
                    var index    = 0;
                    foreach (DataColumn dc in dr.Table.Columns)
                    {
                        var cellEntry     = new CellEntry(this.Table.Root);
                        var currentColumn = this.Table.GetColumns().First(x => x.Name == dc.Caption);
                        cellEntry.ColumnRef = currentColumn.CreateRef();
                        cellEntry.Value     = dr[currentColumn.Name].ToString();
                        rowEntry.CellEntries.Add(cellEntry);
                        index++;
                    }
                    this.Table.StaticData.Add(rowEntry);
                }
            }
            catch (Exception ex)
            {
                //Do Nothing
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
示例#3
0
        private void wizard1_Finish(object sender, EventArgs e)
        {
            DatabaseConnectionControl1.PersistSettings();

            _currentTable.StaticData.Clear();
            var dt = (System.Data.DataTable) this.dataGridView1.DataSource;

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                var rowEntry   = new RowEntry(_currentTable.Root);
                var columnList = _currentTable.GetColumns().ToList();
                for (var ii = 0; ii < columnList.Count; ii++)
                {
                    var cellEntry = new CellEntry(_currentTable.Root);
                    cellEntry.ColumnRef = columnList[ii].CreateRef();
                    //if (dr[ii].GetType().ToString() == "System.Byte[]")
                    //{
                    //  cellEntry.Value = System.Text.ASCIIEncoding.ASCII.GetString((byte[])dr[ii]);
                    //}
                    //else
                    //{
                    cellEntry.Value = dr[ii].ToString();
                    //}
                    rowEntry.CellEntries.Add(cellEntry);
                }
                _currentTable.StaticData.Add(rowEntry);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void DrawRow(RowEntry entry, Rect inRect)
        {
            float tW      = inRect.width * 2f;
            float wTxt    = tW * DESC_ROW_T_FRACT;
            float wST     = tW * STORAGE_INFO_FRACT;
            float wButton = BUTTON_FRACT * tW;
            float x0      = inRect.x;
            float x1      = DESC_ROW_T_FRACT * tW + x0;
            float x2      = TEXT_ROW_FRACT * tW + x0;


            var txtRect = new Rect(inRect)
            {
                width = wTxt
            };
            var stInfoRect = new Rect(inRect)
            {
                x = x1, width = wST
            };
            var buttonRect = new Rect(inRect)
            {
                x = x2, width = wButton, height = 10
            };

            Widgets.Label(txtRect, entry.label);
            DrawUsageColumn(entry, stInfoRect);
            DrawButton(buttonRect, entry.def);
        }
        private void DrawUsageColumn(RowEntry entry, Rect inRect)
        {
            float w     = inRect.width / 2f;
            Rect  cRect = new Rect(inRect)
            {
                width = w
            };

            Widgets.Label(cRect, entry.storageSpaceUsed + STORAGE_SUFFIX);

            string usageStr;
            int    totalStorage = Database.TotalStorage;

            if (totalStorage <= 0)
            {
                usageStr = "NaN"; //should be an error message if total storage is 0 ?
            }
            else
            {
                usageStr = ((float)entry.storageSpaceUsed / totalStorage).ToStringPercent();
            }

            cRect.x += w;
            Widgets.Label(cRect, "[" + usageStr + "]");
        }
示例#6
0
        private static RowEntry ConvertToRowEntry(AclTableEntry.ModifyOperation aclModifyOperation)
        {
            switch (aclModifyOperation.Operation)
            {
            case ModifyTableOperationType.Add:
                return(RowEntry.Add(new PropValue[]
                {
                    new PropValue(PropTag.EntryId, aclModifyOperation.Entry.MemberEntryId),
                    new PropValue(PropTag.MemberRights, aclModifyOperation.Entry.MemberRights)
                }));

            case ModifyTableOperationType.Modify:
                return(RowEntry.Modify(new PropValue[]
                {
                    new PropValue(PropTag.MemberId, aclModifyOperation.Entry.MemberId),
                    new PropValue(PropTag.MemberRights, aclModifyOperation.Entry.MemberRights)
                }));

            case ModifyTableOperationType.Remove:
                return(RowEntry.Remove(new PropValue[]
                {
                    new PropValue(PropTag.MemberId, aclModifyOperation.Entry.MemberId)
                }));

            default:
                return(RowEntry.Empty());
            }
        }
示例#7
0
        // send an email to a given employee by row entry
        public void SendEmail(RowEntry row)
        {
            Employee emp = employees[row.ID];

            string name = emp.GivenName;
            string cert = row.Cert;
            string date = row.Expiry;

            string address = emailByID[emp.ID];
            string subject = "Expiring Qualification";
            string cc      = "";
            string bcc     = "";

            // newline character %0D%0A
            string body = String.Format("Hi {0},%0D%0A" +
                                        "Your \'{1}\' is expiring in less than 60 days, on {2}.%0D%0A" +
                                        "Please provide proof of certification when you receive it.%0D%0A%0D%0A" +
                                        "Thanks,%0D%0AJenn", name, cert, date);

            // pop open a new email window
            Process.Start(String.Format("mailto:{0}?subject={1}&cc={2}&bcc={3}&body={4}",
                                        address, subject, cc, bcc, body));

            // update emailed status for employee's certification
            foreach (Certification c in emp.Certifications.Values)
            {
                if (c.Name == cert)
                {
                    c.Emailed     = true;
                    c.EmailedDate = DateTime.Now;
                    break;
                }
            }
        }
示例#8
0
    public void SetRows(List <RowMeta> rows)
    {
        for (int i = 0; i < rowEntries.Length; i++)
        {
            RowEntry rowEntry = rowEntries [i];

            if (i < rows.Count)
            {
                RowMeta meta = rows [i];
                rowEntry.setKeyText(meta.key);
                rowEntry.setValText(meta.value);

                if (meta.sprite != null)
                {
                    rowEntry.setImageEnabled(true);
                    rowEntry.setTexture(meta.sprite);
                }
                else
                {
                    rowEntry.setImageEnabled(false);
                }
            }
            else                //disable unused
            {
                rowEntry.gameObject.SetActive(false);
            }
        }
    }
示例#9
0
 public static RowEntry Remove(long memberId)
 {
     PropValue[] propValues = new PropValue[]
     {
         new PropValue(PropTag.MemberId, memberId)
     };
     return(RowEntry.Remove(propValues));
 }
示例#10
0
 public static RowEntry Add(byte[] memberEntryId, int rights)
 {
     PropValue[] propValues = new PropValue[]
     {
         new PropValue(PropTag.EntryId, memberEntryId),
         new PropValue(PropTag.MemberRights, rights)
     };
     return(RowEntry.Add(propValues));
 }
示例#11
0
 public static RowEntry Update(long memberId, int rights)
 {
     PropValue[] propValues = new PropValue[]
     {
         new PropValue(PropTag.MemberId, memberId),
         new PropValue(PropTag.MemberRights, rights)
     };
     return(RowEntry.Modify(propValues));
 }
示例#12
0
        static string GetDescriptionStringFor(RowEntry rEntry)
        {
            if (_internDict.TryGetValue(rEntry, out string val))
            {
                return(val);
            }

            _internDict[rEntry] = rEntry.label + " : " + rEntry.storageSpaceUsed + STORAGE_SUFFIX; //only calculate this once
            return(_internDict[rEntry]);
        }
示例#13
0
文件: geo.cs 项目: rktangirala/Vision
    public void AddRow(double _lat, double _lon, string _data)
    {
        string   key = FirebaseDatabase.DefaultInstance.GetReference("Rows").Push().Key;
        RowEntry e   = new RowEntry(_lat, _lon, _data);
        Dictionary <string, System.Object> eVal         = e.ToDictionary();
        Dictionary <string, System.Object> childUpdates = new Dictionary <string, System.Object>();

        childUpdates["/Rows/" + key] = eVal;
        FirebaseDatabase.DefaultInstance.GetReference("Rows").UpdateChildrenAsync(childUpdates);
    }
        static string GetDescriptionStringFor(RowEntry rEntry)
        {
            if (_internDict.TryGetValue(rEntry, out string val))
            {
                return val;
                
            }

            _internDict[rEntry] = rEntry.label + " : " + DatabaseUtilities.GetStorageString(rEntry.storageSpaceUsed); //only calculate this once 
            return _internDict[rEntry]; 
        }
        /// <summary>
        /// Called by the model on a new entry.
        /// </summary>
        /// <param name="entry">The entry to be added</param>
        public void Add(RowEntry entry)
        {
            this.averageBuffer.Enqueue(entry);

            //arrayCount reset after the maximum number of steps. Preventing array overflow.
            this.arrayCount = this.entryCount % this.Step;

            // Add values to averageBufferArray
            if (activityValueSupported)
            {
                this.averageBufferArray[this.arrayCount] = entry.Activity;
            }
            else if (vmuValueSupported)
            {
                this.averageBufferArray[this.arrayCount] = entry.Vmu;
            }
            else
            {
                return;
            }

            this.entryCount++;

            if (entryCount < (this.Step))
            {
                return;
            }

            // Keep lookback to max. of the variable Step. This is the place to change if you want
            // less or stronger randoms correction.
            if (this.averageBuffer.Count > this.Step)
            {
                this.averageBuffer.Dequeue();
            }

            // Get minimum of the Buffer
            this.minVeloc = this.averageBufferArray.Min();

            // If all values are bigger then 5.0 and start-date hasn't been set yet,
            // set new start-date
            if (minVeloc >= 5.0 && this.currentDay.StartTime.Equals(this.nullDate))
            {
                this.currentDay.StartTime = this.averageBuffer.First().Date;
            }

            // If all values are bigger then 5.0 and start-date has already been set,
            // assume new end-date, but maybe we'll find a later date later on
            if (minVeloc >= 5.0 && !this.currentDay.StartTime.Equals(this.nullDate))
            {
                this.currentDay.EndTime = entry.Date;
            }
        }
示例#16
0
        /// <summary>
        /// Load data from a tab-delimited text file with columns Protein and Peptide
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="rows">List of protein/peptide pairs (protein name and peptide sequence)</param>
        /// <param name="showProgress">When true, show progress messages at the console</param>
        /// <returns></returns>
        public static bool ReadProteinPeptideTable(string filePath, out List <RowEntry> rows, bool showProgress = true)
        {
            try
            {
                if (showProgress)
                {
                    Console.WriteLine("Loading proteins and peptides from " + filePath);
                }

                rows = new List <RowEntry>();
                var columnsToTrack = new SortedSet <string>(StringComparer.OrdinalIgnoreCase)
                {
                    "Protein", "Peptide"
                };

                var dt = TextFileToDataTableAssignTypeString(filePath, columnsToTrack);

                if (!dt.Columns.Contains("Protein"))
                {
                    throw new Exception("Input file is missing column 'Protein'");
                }

                if (!dt.Columns.Contains("Peptide"))
                {
                    throw new Exception("Input file is missing column 'Peptide'");
                }

                foreach (DataRow item in dt.Rows)
                {
                    var entry = new RowEntry
                    {
                        ProteinEntry = (string)item["Protein"],
                        PeptideEntry = (string)item["Peptide"]
                    };
                    rows.Add(entry);
                }

                if (showProgress)
                {
                    Console.WriteLine("Loaded {0} rows", rows.Count);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Problem loading data from {0}: {1}", filePath, ex.Message));
            }

            return(true);
        }
示例#17
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            /* "Send" button clicked inside a row */
            // acquire actual RowEntry which was clicked
            RowEntry row = (RowEntry)((Button)e.Source).DataContext;

            // initiate an email
            parser.SendEmail(row);

            // update data with 'emailed' status
            // TODO

            // reload/refresh display
            displayGrid.ItemsSource = null;
            displayGrid.ItemsSource = LoadEntries();
        }
示例#18
0
    //To save the review to cloud database
    public void save()
    {
        Debug.Log("Saving to database");
        string content = i.text;

        i.text = "";
        char[]   splitChar = { '\n' };
        string[] list      = mTargetMetadata.Split(splitChar);
        string   tag       = list [0];
        string   key       = FirebaseDatabase.DefaultInstance.GetReference("Rows").Push().Key;
        RowEntry e         = new RowEntry(tag, content);
        Dictionary <string, System.Object> eVal         = e.ToDictionary();
        Dictionary <string, System.Object> childUpdates = new Dictionary <string, System.Object>();

        childUpdates["/Rows/" + key] = eVal;
        FirebaseDatabase.DefaultInstance.GetReference("Rows").UpdateChildrenAsync(childUpdates);
    }
示例#19
0
    public override void Update()
    {
        Dictionary <string, int> count = this.Count;

        lock (count)
        {
            foreach (KeyValuePair <string, int> keyValuePair in this.Count)
            {
                GClass832.< > c__DisplayClass6_0 CS$ < > 8__locals1 = new GClass832.< > c__DisplayClass6_0();
                CS$ < > 8__locals1.string_0 = this.Key + "_" + keyValuePair.Key;
                RowEntry rowEntry = (RowEntry)base.GetOrAdd(CS$ < > 8__locals1.string_0, new Func <IRowEntry>(CS$ < > 8__locals1.method_0));
                (rowEntry.Cells[1] as VariableValue <string>).Value = string.Format("{0:N0}", keyValuePair.Value);
                rowEntry.Order = -keyValuePair.Value;
            }
        }
        base.Update();
    }
示例#20
0
    public override void Update()
    {
        Dictionary <string, GClass884.GStruct0> deathLog = this.DeathLog;

        lock (deathLog)
        {
            foreach (KeyValuePair <string, GClass884.GStruct0> keyValuePair in this.DeathLog)
            {
                GClass884.< > c__DisplayClass8_0 CS$ < > 8__locals1 = new GClass884.< > c__DisplayClass8_0();
                CS$ < > 8__locals1.string_0 = this.Key + "_" + keyValuePair.Key;
                RowEntry rowEntry = (RowEntry)base.GetOrAdd(CS$ < > 8__locals1.string_0, new Func <IRowEntry>(CS$ < > 8__locals1.method_0));
                (rowEntry.Cells[1] as VariableValue <string>).Value = string.Format("{0:N0}", keyValuePair.Value.Count);
                (rowEntry.Cells[2] as VariableValue <string>).Value = string.Format("{0}", keyValuePair.Value.dateTimeOffset_0);
                rowEntry.Order = keyValuePair.Value.Count;
            }
        }
        base.Update();
    }
        /// <summary>
        /// Called by the model on a new entry.
        /// </summary>
        /// <param name="entry">The entry to be added</param>
        public void Add(RowEntry entry)
        {
            // Add activity value to average variable
            if (activityValueSupported)
            {
                this.avgVeloc += entry.Activity;
            }
            else if (vmuValueSupported)
            {
                this.avgVeloc += entry.Vmu;
            }
            else
            {
                return;
            }
            this.averageCount++;

            if (averageCount < this.Steps)
            {
                return;
            }
            else
            {
                avgVeloc /= this.Steps;
            }

            if (this.MinSedantary <= avgVeloc && avgVeloc < this.MinLight)
            {
                this.addCount(ActivityLevels.SEDENTARY);
            }
            else if (this.MinLight <= avgVeloc && avgVeloc < this.MinModerate)
            {
                this.addCount(ActivityLevels.LIGHT);
            }
            else if (this.MinModerate <= avgVeloc && avgVeloc < this.MinHeavy)
            {
                this.addCount(ActivityLevels.MODERATE);
            }
            else if (this.MinHeavy <= avgVeloc && avgVeloc < this.MinVeryheavy)
            {
                this.addCount(ActivityLevels.VIGOROUS);
            }
            else if (this.MinVeryheavy <= avgVeloc)
            {
                this.addCount(ActivityLevels.VERYVIGOROUS);
            }

            this.avgVeloc = 0;
            this.averageCount = 0;
        }
示例#22
0
 public void LotNameEntry_Completed(object sender, EventArgs e)
 {
     RowEntry.Focus();
 }
        private void DrawTable(Rect inRect, RowHeader header)
        {
            inRect.yMin += 10f;
            inRect.yMax += 40f;
            Rect mainView = inRect.ContractedBy(10f);

            var outRect = new Rect(inRect.x, inRect.y, mainView.width, mainView.height - inRect.y - 10f);

            var viewRect = new Rect(mainView.x + mainView.width / 2f + 10f, mainView.y, mainView.width / 2f - 10f - 16f,
                                    mainView.height);
            float viewWidth = viewRect.width / 3 - 10f;

            Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect);
            try
            {
                const float rowHeight = 30;
                const float lineWidth = 5;
                const float buffer    = 5;
                //draw the header row


                var font = Text.Font;
                try
                {
                    Text.Font = GameFont.Small;
                    DrawRow(header, viewRect);
                }
                finally
                {
                    Text.Font = font;
                }


                viewRect.y += (rowHeight + lineWidth + buffer) / 2f;

                Widgets.DrawLine(new Vector2(viewRect.x, viewRect.y), new Vector2(viewRect.x + mainView.width, viewRect.y),
                                 Color.black, lineWidth);

                viewRect.y += (rowHeight + lineWidth) / 2f;
                if (_rowEntries.Count == 0)
                {
                    return;
                }

                for (var index = 0; index < _rowEntries.Count; index++)
                {
                    RowEntry rowEntry = _rowEntries[index];
                    Rect     rect     = viewRect; //TODO fix this
                    rect.y += index * rowHeight;  //go down 1 row?
                    DrawRow(rowEntry, rect);
                }

                //TODO scroll view stuff
                //use _rowEntries to get the needed information
                // Set the scroll view height
            }
            finally
            {
                Widgets.EndScrollView();
            }
        }
示例#24
0
 public DungeonResources([Optional, DefaultParameterValue("Rules/Dungeon-Instances")] string sourcePath)
 {
     string[,] strArray = CsvUtils.Deserialize(ResourceUtil.LoadSafe <TextAsset>(sourcePath, false).text);
     for (int i = 0; i < strArray.GetLength(1); i++)
     {
         if (strArray[0, i] != null)
         {
             int      num4;
             RowEntry entry = new RowEntry();
             int      num2  = 0;
             entry.Id               = strArray[num2++, i];
             entry.Name             = _.L(strArray[num2++, i], null, false);
             entry.LevelRequirement = base.parseInt(strArray[num2++, i]);
             entry.ExploreCost      = base.parseInt(strArray[num2++, i]);
             entry.BaseDifficulty   = base.parseInt(strArray[num2++, i]);
             entry.EnergyCost       = base.parseInt(strArray[num2++, i]);
             entry.FloorCount       = ConfigDungeons.DEFAULT_DUNGEON_ROOM_COUNT;
             num2++;
             entry.PrimaryMinionType   = base.parseEnumType <CharacterType>(strArray[num2++, i]);
             entry.SecondaryMinionType = base.parseEnumType <CharacterType>(strArray[num2++, i]);
             List <KeyValuePair <string, int> > list = base.parseStringIntList(strArray[num2++, i], 0x22c);
             entry.BossPool = new Dictionary <string, int>();
             for (int j = 0; j < list.Count; j++)
             {
                 KeyValuePair <string, int> pair  = list[j];
                 KeyValuePair <string, int> pair2 = list[j];
                 entry.BossPool.Add(pair.Key, pair2.Value);
             }
             entry.BossType   = strArray[num2++, i];
             entry.FtueBoss   = ((list.Count <= 0) || !(entry.BossType != "Elite")) ? null : list[0].Key;
             entry.Theme      = base.parseEnumType <DungeonThemeType>(strArray[num2++, i]);
             entry.Mood       = strArray[num2++, i];
             entry.MapStyle   = strArray[num2++, i];
             entry.LootPool   = base.parseStringList(strArray[num2++, i]);
             entry.LayoutPool = base.parseStringList(strArray[num2++, i]);
             Dungeon dungeon = new Dungeon();
             dungeon.Id                  = entry.Id;
             dungeon.Name                = entry.Name;
             dungeon.LevelRequirement    = entry.LevelRequirement;
             dungeon.ExploreCost         = entry.ExploreCost;
             dungeon.EnergyCost          = entry.EnergyCost;
             dungeon.LootPool            = entry.LootPool;
             dungeon.BaseDifficulty      = entry.BaseDifficulty;
             dungeon.FloorCount          = entry.FloorCount;
             dungeon.LayoutPool          = entry.LayoutPool;
             dungeon.Theme               = entry.Theme;
             dungeon.Mood                = GameLogic.Binder.DungeonMoodResources.getMood(entry.Mood);
             dungeon.MapStyle            = entry.MapStyle;
             dungeon.PrimaryMinionType   = entry.PrimaryMinionType;
             dungeon.SecondaryMinionType = entry.SecondaryMinionType;
             dungeon.FtueBoss            = entry.FtueBoss;
             dungeon.BossPool            = entry.BossPool;
             dungeon.EliteTag            = entry.BossType == "Elite";
             bool flag = int.TryParse(dungeon.Id, out num4);
             if (!flag || (this.m_orderedRegularDungeons.Count < ConfigDungeons.MAX_DUNGEON_COUNT))
             {
                 base.m_resources.Add(dungeon.Id, dungeon);
             }
             if (flag && (this.m_orderedRegularDungeons.Count < ConfigDungeons.MAX_DUNGEON_COUNT))
             {
                 this.m_orderedRegularDungeons.Add(dungeon);
             }
             if (!this.m_dungeonThemeMinionCharacterTypes.ContainsKey(dungeon.Theme))
             {
                 this.m_dungeonThemeMinionCharacterTypes.Add(dungeon.Theme, new List <CharacterType>());
             }
             List <CharacterType> list2 = this.m_dungeonThemeMinionCharacterTypes[dungeon.Theme];
             if (!list2.Contains(entry.PrimaryMinionType))
             {
                 list2.Add(entry.PrimaryMinionType);
             }
             if (!list2.Contains(entry.SecondaryMinionType))
             {
                 list2.Add(entry.SecondaryMinionType);
             }
         }
     }
     this.createDebugDungeon();
 }
 /// <summary>
 /// Called by the model on adding a new entry. Unused.
 /// </summary>
 /// <param name="entry">The entry to be added.</param>
 public void Add(RowEntry entry)
 {
     return;
 }
        private void calculate()
        {
            int count = model.Count;
            this.model.startReading();
            RowEntry tmp;

            for (int i = 0; i < count; i++)
            {
                tmp = new RowEntry();
                this.model.read();

                if (vmuValueSupported)
                    tmp.Vmu = (int) this.model.getValue(SensorData.Vmu);
                if (activityValueSupported)
                    tmp.Activity = (int) this.model.getValue(SensorData.Activity);

                this.Add(tmp);
            }
            this.model.endReading();
        }