Exemple #1
0
        ///////////////////////////////////////////////////////////////////////

        #region List Methods
        public static Result MaybeCombine(
            Result result1,
            Result result2
            )
        {
            if ((result1 == null) && (result2 == null))
            {
                return(null);
            }

            if (result1 == null)
            {
                return(result2);
            }

            if (result2 == null)
            {
                return(result1);
            }

            ResultList results = new ResultList();

            results.Add(result1);
            results.Add(result2);

            return(results);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpFeatureCall"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">Details of the feature call.</param>
        public CSharpFeatureCall(ICSharpContext context, IFeatureCall source)
        {
            foreach (IParameter Item in source.ParameterList)
            {
                ICSharpClass     Owner        = context.GetClass(Item.ResolvedParameter.Location.EmbeddingClass);
                ICSharpParameter NewParameter = CSharpParameter.Create(context, Item, Owner);
                ParameterList.Add(NewParameter);
            }

            foreach (IParameter Item in source.ResultList)
            {
                ICSharpClass     Owner        = context.GetClass(Item.ResolvedParameter.Location.EmbeddingClass);
                ICSharpParameter NewParameter = CSharpParameter.Create(context, Item, Owner);
                ResultList.Add(NewParameter);
            }

            foreach (IArgument Item in source.ArgumentList)
            {
                ICSharpArgument NewArgument = CSharpArgument.Create(context, Item);
                ArgumentList.Add(NewArgument);
            }

            Debug.Assert(ParameterList.Count >= ArgumentList.Count);
            Count = ParameterList.Count;

            ArgumentStyle = source.TypeArgumentStyle;
        }
        public async void init()
        {
            try
            {
                MainPage.Current.ActiveProgressRing();
                CategoryList.Clear();
                InitCategory();
                ResultList.Clear();
                string jsonResult = await LinqHelper.GetSearchData(SearchModel, "BlockQuery");

                var result = JsonConvert.DeserializeObject <JsonSearchResultTemplate <BlockEntry> >(jsonResult);
                if (result.ResultCode == (int)ResultCodeType.操作成功)
                {
                    SearchModel.TotalCount = result.Data.TotalSize;
                    SearchModel.PageIndex  = result.Data.PageIndex;
                    SearchModel.PageSize   = result.Data.PageSize;
                    result.Data.Data.ToList().ForEach(item => { ResultList.Add(item); });
                    var length = ResultList.Count > 0 ? ResultList.Max(x => x.Keywords.Length) : 0;
                    BlockEntryControl.KeywordMinWidth = length * BlockEntryControl.FontSize;
                }
                else
                {
                    await MainPage.ShowMessage(result.ResultCode);
                }
            }
            catch (Exception ex)
            {
                await MainPage.ShowErrorMessage(ex.Message);
            }
            finally
            {
                MainPage.Current.InActiveProgressRing();
            }
        }
        /// <summary>
        /// Makes prior analysis through normalizers and calculates ratings based on average vote
        /// and vote count.
        /// </summary>
        /// <param name="rawDataContainer">Entities to appraise with additional parameters.</param>
        /// <param name="outputResults">Flag to define need to output.</param>
        /// <returns>Collection of result object (data object with rating).</returns>
        /// <remarks>
        /// Entities collection must be unique because rating calculation errors can occur in such
        /// situations.
        /// </remarks>
        public virtual ResultList GetRatings(RawDataContainer rawDataContainer, bool outputResults)
        {
            CheckRatingId();

            var ratings = new ResultList();
            IReadOnlyList <BasicInfo> rawData = rawDataContainer.GetData();

            if (rawData.IsNullOrEmpty())
            {
                return(ratings);
            }

            MinMaxDenominator voteCountMMD   = rawDataContainer.GetParameter("VoteCount");
            MinMaxDenominator voteAverageMMD = rawDataContainer.GetParameter("VoteAverage");

            foreach (BasicInfo entityInfo in rawData)
            {
                double ratingValue = CalculateRating(entityInfo, voteCountMMD, voteAverageMMD);

                var resultInfo = new ResultInfo(entityInfo.ThingId, ratingValue, RatingId);
                ratings.Add(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage(resultInfo.ToString());
                }
            }

            ratings.Sort((x, y) => y.RatingValue.CompareTo(x.RatingValue));
            return(ratings);
        }
Exemple #5
0
        void RefreshResult()
        {
            ResultList.Clear();
            foreach (var condition in ConditionList)
            {
                var l = condition.GetResult(null, AnalyseEndTime);
                foreach (var r in l)
                {
                    var inst = InstrumentList.FirstOrDefault(v => v.Ticker == r.Ticker);
                    if (inst != null)
                    {
                        if (!ResultList.Any(v => v.Ticker == inst.Ticker))
                        {
                            ResultList.Add(inst);
                        }
                    }
                }
            }

            var rl = new List <IInstrument>();

            foreach (var preicate in PredicateList)
            {
                rl.Clear();
                var l = preicate.GetResult(null, AnalyseEndTime);
                foreach (var r in l)
                {
                    var inst = InstrumentList.FirstOrDefault(v => v.Ticker == r.Ticker);
                    rl.Add(inst);
                }
                ResultList.RemoveAll(v => !rl.Any(r => r.Ticker == v.Ticker));
            }
        }
 private void RemoveBinFromListThenAddRoResultList()
 {
     PairIndexValueList.Remove(CurrentPair1);
     PairIndexValueList.Remove(CurrentPair2);
     ResultList.Add(CurrentBin);
     ResultListCoordinates.Add(new Point(CursorX, CursorY));
 }
        protected override void OnAdded(int index, TSource value)
        {
            int currentAdjustment = 0;

            for (int elementIndex = 0; elementIndex < _indexes.Count; ++elementIndex)
            {
                var item        = _indexes[elementIndex];
                var sourceIndex = SourceLists[0][elementIndex];

                if (sourceIndex == SourceList.Count - 1)
                {
                    item = new Item(true, item.Index + currentAdjustment++);
                    _indexes[elementIndex] = item;
                    ResultList.Add(item.Index, SourceList[sourceIndex]);
                }
                else
                {
                    if (currentAdjustment > 0)
                    {
                        item = new Item(item.InList, item.Index + currentAdjustment);
                        _indexes[elementIndex] = item;
                    }
                    if (item.InList)
                    {
                        ResultList.Replace(item.Index, SourceList[sourceIndex]);
                    }
                }
            }
        }
        private bool customPanel1_PanelGetDataInfo(CE_FlowOperationType flowOperationType)
        {
            try
            {
                if (!CheckSubmitInfo())
                {
                    return(false);
                }

                m_lnqBillInfo.BillNo   = txtBillNo.Text;
                m_lnqBillInfo.FileCode = txtFileCode.Text;
                m_lnqBillInfo.FileInfo = m_byteData;
                m_lnqBillInfo.Reason   = txtReason.Text;

                List <View_Business_Base_BomChange_PartsLibrary> listLibrary =
                    (dataGridViewLibrary.DataSource as BindingCollection <View_Business_Base_BomChange_PartsLibrary>).ToList();

                ResultInfo        = m_lnqBillInfo;
                FlowInfo_BillNo   = m_lnqBillInfo.BillNo;
                FlowOperationType = flowOperationType;

                this.ResultList = new List <object>();

                ResultList.Add(m_listStruct);
                ResultList.Add(listLibrary);
                KeyWords = "【技术变更单号】:" + m_lnqBillInfo.FileCode;

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }
        private bool 生产BOM变更单明细_PanelGetDataInfo(CE_FlowOperationType flowOperationType)
        {
            try
            {
                GetInfo();

                if (lbBillStatus.Text == CE_CommonBillStatus.新建单据.ToString() &&
                    flowOperationType == CE_FlowOperationType.提交)
                {
                    CheckInfo();
                }

                FlowOperationType = flowOperationType;
                ResultInfo        = _lnqPBOMBill;

                this.ResultList = new List <object>();
                ResultList.Add(_listDetail);

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }
        public ComplexModelObject()
        {
            this.Name    = BIGString;
            this.Address = "8755 Lakeview Terrace";

            this.Items = (new List <int>()
            {
                1, 3, 5, 6, 7, 88
            }).ToArray();

            ResultList.Add(new Result());
            ResultList.Add(new Result());
            Collect.Add(1);
            Collect.Add("Test");
            OldAges.Add("test", "data");
            ChildrenAges.Add("bill", 13);
            //DT.Columns.Add("Column1", typeof(string));
            //DT.Columns.Add("Column2", typeof(int));

            //for (var i = 0; i < 10; i++)
            //{
            //    var r = DT.NewRow();
            //    r[0] = "Test_" + i.ToString();
            //    r[1] = i;
            //    DT.Rows.Add(r);
            //}

            MixObjects.Add("Test");
            MixObjects.Add(1);
            MixObjects.Add(true);
        }
Exemple #11
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     ResultList.Clear();
     if (lbData.SelectedIndex >= 0)
     {
         ResultList.Add(lbData.Items[lbData.SelectedIndex].ToString());
     }
     this.Close();
 }
        protected override void OnAdded(int collectionIndex, int index, TResult value)
        {
            var info          = _listInfo[collectionIndex];
            var adjustedIndex = info.Offset + index;

            ResultList.Add(adjustedIndex, value);
            AdjustIndices(collectionIndex + 1, 1);
            _listInfo[collectionIndex] = new ListInfo(info.Offset, info.Count + 1);
        }
Exemple #13
0
        public void CalculateScore()
        {
            try
            {
                _jumpLength        = double.Parse(jumpLength.Text);
                _criticalPoint     = double.Parse(criticalPoint.Text);
                _levelCompensation = double.Parse(levelCompensation.Text);
                _platformChange    = double.Parse(levelChange.Text);
                _windChance1       = double.Parse(windCheck1.Text);
                _windChance2       = double.Parse(windCheck2.Text);
                _windChance3       = double.Parse(windCheck3.Text);
                _windChance4       = double.Parse(windCheck4.Text);
                _windChance5       = double.Parse(windCheck5.Text);
                _stylePoints1      = double.Parse(stylePoints1.Text);
                _stylePoints2      = double.Parse(stylePoints2.Text);
                _stylePoints3      = double.Parse(stylePoints3.Text);
                _stylePoints4      = double.Parse(stylePoints4.Text);
                _stylePoints5      = double.Parse(stylePoints5.Text);

                if (nameComboBox.SelectedIndex == -1 || _jumpLength == 0 || _criticalPoint == 0 || _levelCompensation == 0)
                {
                    MessageBox.Show("Please, fill in all jump specs!");
                }
                else
                {
                    _windCompensation = countWindEffect(_criticalPoint, _windChance1, _windChance2, _windChance3,
                                                        _windChance4, _windChance5);
                    _jumpScore   = countLengthScore(_jumpLength, _criticalPoint, _windCompensation);
                    _stylePoints = countStylePoints(_stylePoints1, _stylePoints2, _stylePoints3, _stylePoints4,
                                                    _stylePoints5);
                    _platformCompensation = countPlatformCompensation(_criticalPoint, _platformChange, _levelCompensation);
                    _score = _windCompensation + _jumpScore + _stylePoints + _platformCompensation;

                    if (_error != true)
                    {
                        var thisJumper = JumperList.FirstOrDefault(x => x.Number == _number);

                        var scoreExist = ResultList.FirstOrDefault(x => x.Number == _number);
                        if (scoreExist != null)
                        {
                            double total = scoreExist.Score;
                            scoreExist.Score = _score + total;
                            JumperList.Remove(thisJumper);
                        }
                        else
                        {
                            ResultList.Add(new Result(_number, thisJumper.Name, thisJumper.Country, _score));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
 protected override void OnAdded(int index, TSource value)
 {
     if (_predicate.Invoke(value))
     {
         ResultList.Add(AddIndex(index, false), value);
     }
     else
     {
         _indexList.Add(index, -1);
     }
 }
Exemple #15
0
        private void dgvDetailList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Decimal qty = Decimal.Zero, uamt = Decimal.Zero, amt = Decimal.Zero;

            try
            {
                qty  = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[5].Value.ToString()); // Qty
                uamt = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[7].Value.ToString()); // Unit Amount

                amt = (decimal)qty * uamt;
            }
            catch { }

            dgvDetailList.Rows[e.RowIndex].Cells[8].Value = amt; // Amount

            if (qty > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[5].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[6].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            if (uamt > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[7].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[8].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            if (DAL.Common.Utility.IsGUID(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString()))
            {
                Guid productId = new Guid(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString());

                DetailData detail = ResultList.Find(d => d.ProductId == productId);

                if (detail == null)
                {
                    detail            = new DetailData();
                    detail.ProductId  = productId;
                    detail.Qty        = qty;
                    detail.UnitAmount = uamt;
                }
                else
                {
                    ResultList.Remove(detail);

                    detail.Qty        = qty;
                    detail.UnitAmount = uamt;
                }

                ResultList.Add(detail);
            }

            CalcSubTotalQty();
        }
Exemple #16
0
    public List <int> FindTheIntersection(Dictionary <int, int> inputDictionary)
    {
        foreach (KeyValuePair <int, int> pair in inputDictionary)
        {
            if (pair.Key != pair.Value)
            {
                ResultList.Add(pair.Key);
            }
        }

        return(ResultList);
    }
Exemple #17
0
 internal void AddResult(DuplPairViewModel result)
 {
     ResultList.Add(result);
     if (!FileList.Contains(result.FirstFile))
     {
         FileList.Add(result.FirstFile);
     }
     if (!FileList.Contains(result.SecondFile))
     {
         FileList.Add(result.SecondFile);
     }
 }
 public void read_result(IDbCommand _dbcmd)
 {
     _reader = _dbcmd.ExecuteReader();
     while (_reader.Read())
     {
         int   _id       = _reader.GetInt32(0);
         float _score    = _reader.GetFloat(1);
         float _time     = _reader.GetFloat(2);
         float _sens     = _reader.GetFloat(3);
         float _accuracy = _reader.GetFloat(4);
         newResult.Add(_id, _score, _time, _sens, _accuracy);
     }
 }
Exemple #19
0
        private void dgvDetailList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            decimal qty  = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[5].Value.ToString()); // Qty
            decimal uamt = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[7].Value.ToString()); // Unit Amount

            decimal amt = (decimal)qty * uamt;

            dgvDetailList.Rows[e.RowIndex].Cells[8].Value = amt; // Amount

            if (qty > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[5].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[6].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            if (uamt > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[7].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[8].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            Guid productId = Guid.Empty;

            if (Guid.TryParse(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString(), out productId))
            {
                //Guid productId = new Guid(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString());

                DetailData detail = ResultList.Find(d => d.ProductId == productId);

                decimal price = GetPrice(productId);

                if (detail == null)
                {
                    detail            = new DetailData();
                    detail.ProductId  = productId;
                    detail.Qty        = qty;
                    detail.UnitAmount = price > 0 ? price : uamt;
                }
                else
                {
                    ResultList.Remove(detail);

                    detail.Qty        = qty;
                    detail.UnitAmount = price > 0 ? price : uamt;
                }

                ResultList.Add(detail);
            }

            CalcSubTotalQty();
        }
 protected override void OnAdded(int collectionIndex, int index, int value)
 {
     if (value >= 0 && value < SourceList.Count)
     {
         var item = GetItem(index, true);
         _indexes.Add(index, item);
         RecalculateIndexes(index + 1, _indexes.Count - 1);
         ResultList.Add(item.Index, SourceList[value]);
     }
     else
     {
         _indexes.Add(index, GetItem(index, false));
     }
 }
Exemple #21
0
        private void AddToGroup(ItemData item, bool isResetting = false)
        {
            bool addToResultList = !isResetting;

            if (!_resultSet.TryGetValue(item.Key, out var group))
            {
                if (!_emptyGroups.TryGetValue(item.Key, out group))
                {
                    group = new GroupData(item.Key);
                }
                else
                {
                    _emptyGroups.Remove(item.Key);
                }

                _resultSet.Add(item.Key, group);
            }
            else
            {
                addToResultList = false;
            }

            item.TargetIndex = FindTargetIndex(group.Items, item.SourceIndex);
            group.Items.Add(item.TargetIndex, item);

            for (int i = item.TargetIndex + 1; i < group.Items.Count; ++i)
            {
                group.Items[i].TargetIndex = i;
            }

            if (addToResultList)
            {
                group.TargetIndex = FindTargetIndexForGroup(group.SourceIndex, -1);

                if (!isResetting)
                {
                    for (int i = group.TargetIndex; i < ResultList.Count; ++i)
                    {
                        ResultList[i].TargetIndex = i + 1;
                    }

                    ResultList.Add(group.TargetIndex, group);
                }
            }
            else if (item.TargetIndex == 0 && !isResetting)
            {
                UpdateGroupIndex(group);
            }
        }
Exemple #22
0
        public bool Start(int times)
        {
            Stopwatch sw = new Stopwatch();

            if (haveResult)
            {
                for (int i = 0; i < times; i++)
                {
                    try
                    {
                        sw.Start();
                        ResultList.Add(function());
                        sw.Stop();
                        RunTimeList.Add(sw.Elapsed);
                        sw.Reset();
                    }
                    catch (Exception ex)
                    {
                        CausedException = ex;
                        sw.Stop();
                        RunTime = sw.Elapsed;
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                for (int i = 0; i < times; i++)
                {
                    try
                    {
                        sw.Start();
                        action();
                        sw.Stop();
                        RunTimeList.Add(sw.Elapsed);
                        sw.Reset();
                    }
                    catch (Exception ex)
                    {
                        CausedException = ex;
                        sw.Stop();
                        RunTime = sw.Elapsed;
                        return(false);
                    }
                }
                return(true);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpQueryOverloadType"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly node from which the C# node is created.</param>
        /// <param name="owner">The class where the overload is declared.</param>
        protected CSharpQueryOverloadType(ICSharpContext context, IQueryOverloadType source, ICSharpClass owner)
            : base(source)
        {
            foreach (IParameter Parameter in source.ParameterTable)
            {
                ICSharpParameter NewParameter = CSharpParameter.Create(context, Parameter, owner);
                ParameterList.Add(NewParameter);
            }

            foreach (IParameter Result in source.ResultTable)
            {
                ICSharpParameter NewResult = CSharpParameter.Create(context, Result, owner);
                ResultList.Add(NewResult);
            }
        }
Exemple #24
0
        /// <summary>
        /// 将分页结果添加到ResultList
        /// </summary>
        /// <param name="_ResultList">未分页总数据集</param>
        private void Split_ResultList(IList <T> _ResultList)
        {
            int startIndex = (CurrentPageIndex - 1) * PageSize;
            int endIndex   = startIndex + PageSize - 1;

            if (_ResultList.Count - 1 < endIndex)
            {
                endIndex = _ResultList.Count - 1;
            }
            //分页完成后 排序数据

            for (int i = startIndex; i <= endIndex; i++)
            {
                ResultList.Add(_ResultList[i]);
            }
        }
        protected override void OnAdded(int index, TSource value)
        {
            var key         = _keySelector.Invoke(value);
            var targetIndex = FindByKey(key, index);
            var itemSet     = new ItemSet(key, value)
            {
                SourceIndex = index,
                TargetIndex = targetIndex
            };

            _sourceList.Add(index, itemSet);
            ResultList.Add(targetIndex, itemSet);

            UpdateSourceIndexes(index + 1);
            UpdateTargetIndexes(targetIndex + 1);
        }
        private async void BroadcastTx()
        {
            IsSending = true;
            Errors    = string.Empty;
            Status    = "Broadcasting Transaction...";

            Response <ResultWrapper> resp = await SelectedApi.PushTx(RawTx);

            ResultList.Add(resp.Result);

            if (resp.Errors.Any())
            {
                Errors = resp.Errors.GetErrors();
            }
            Status    = resp.Result.ResultString;
            IsSending = false;
        }
        protected override void ItemModified(int index, TSource value)
        {
            var targetIndex = _indexList[index];

            if (_predicate.Invoke(value))
            {
                if (targetIndex < 0)
                {
                    ResultList.Add(AddIndex(index, true), value);
                }
            }
            else if (targetIndex >= 0)
            {
                RemoveIndex(index, true);
                ResultList.Remove(targetIndex);
            }
        }
Exemple #28
0
 /// <summary>
 /// add book for the booklist and with the important entities to the resultList
 /// </summary>
 /// <param name="result">the api calls result object</param>
 private void AddItemToList(BookList result)
 {
     foreach (var d in result.Docs)
     {
         ImageSource img  = _searchService.GetImg(d.Cover_edition_key, "M");
         var         temp = new BookEntity
         {
             Title = d.Title_suggest,
             Img   = img,
             Isbn  = d.Isbn,
             Oclc  = d.Oclc,
             Lccn  = d.Lccn
         };
         ResultList.Add(temp);
         BookList.Add(d);
     }
 }
Exemple #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpQueryOverload"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly node from which the C# node is created.</param>
        /// <param name="parentFeature">The parent feature.</param>
        /// <param name="owner">The class where the overload is declared.</param>
        protected CSharpQueryOverload(ICSharpContext context, IQueryOverload source, ICSharpFeature parentFeature, ICSharpClass owner)
            : base(source)
        {
            ParentFeature = parentFeature;

            foreach (IParameter Parameter in source.ParameterTable)
            {
                ICSharpParameter NewParameter = CSharpParameter.Create(context, Parameter, owner);
                ParameterList.Add(NewParameter);
            }

            foreach (IParameter Result in source.ResultTable)
            {
                ICSharpParameter NewResult = CSharpParameter.Create(context, Result, owner);
                ResultList.Add(NewResult);
            }

            Body = CSharpBody.Create(context, parentFeature, source.ResolvedBody.Item);
        }
        /// <inheritdoc />
        /// <remarks>
        /// Considers popularity value in addition to average vote and vote count.
        /// </remarks>
        /// <exception cref="ArgumentException">
        /// <paramref name="rawDataContainer" /> contains instances of invalid type for this
        /// appraiser.
        /// </exception>
        public override ResultList GetRatings(RawDataContainer rawDataContainer, bool outputResults)
        {
            CheckRatingId();

            var ratings = new ResultList();
            IReadOnlyList <BasicInfo> rawData = rawDataContainer.GetData();

            if (rawData.IsNullOrEmpty())
            {
                return(ratings);
            }

            // Check if list have proper type.
            if (!rawData.All(e => e is TmdbMovieInfo))
            {
                throw new ArgumentException(
                          $"Element type is invalid for appraiser with type {TypeId.FullName}"
                          );
            }

            MinMaxDenominator voteCountMMD   = rawDataContainer.GetParameter("VoteCount");
            MinMaxDenominator voteAverageMMD = rawDataContainer.GetParameter("VoteAverage");
            MinMaxDenominator popularityMMD  = rawDataContainer.GetParameter("Popularity");

            var converted = rawData.Select(e => (TmdbMovieInfo)e);

            foreach (TmdbMovieInfo entityInfo in converted)
            {
                double ratingValue = CalculateRating(entityInfo, voteCountMMD, voteAverageMMD,
                                                     popularityMMD);

                var resultInfo = new ResultInfo(entityInfo.ThingId, ratingValue, RatingId);
                ratings.Add(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage($"Appraised {resultInfo} by {Tag}");
                }
            }

            ratings.Sort((x, y) => y.RatingValue.CompareTo(x.RatingValue));
            return(ratings);
        }
Exemple #31
0
        public ResultList GSsearchCitationUrl(String url)
        {
            ResultList resultList = new ResultList();
            GSParser parser = new GSParser();

            url = "http://scholar.google.co.in" + url;
            var citationUrl = new Uri(url);
            int i;
            for (i = 0; i < 10; i += 10)
            {
                Result result = new Result();

                String newURL;
                newURL = citationUrl + "&start=" + i.ToString();
                var newUrl = new Uri(newURL);
                Console.WriteLine(newUrl);
                resultList.Add(parser.GSConnect(newUrl));

            }
            return resultList;

        }
Exemple #32
0
        public ResultList MSASConnectFetch(Uri URL)
        {

            WebClient wc = new WebClient();
            wc.Proxy = WebProxy.GetDefaultProxy();

            ResultList resList = new ResultList();


            var data = " ";
            try
            {
                data = wc.DownloadString(URL);
                //Console.WriteLine(data);
            }
            catch (Exception e)
            {
                //TabPage.displayError("MS Also blocking Dude !!! YY !!!!");
                return null;
            }
            JObject obj = JObject.Parse(data);

            int paperCount = 0;

            if (obj["d"]["Publication"]["Result"].Count() == 0)
            {

                //TabPage.displayError("No Results");
                return null;
            }
            int total = (int)obj["d"]["Publication"]["TotalItem"];
            Console.WriteLine("sdfsd" + total);
            resList.setCount(total);
            while (paperCount < obj["d"]["Publication"]["Result"].Count())
            {

                Result result = new Result();
                Paper p = new Paper();



                String title = (String)obj["d"]["Publication"]["Result"][paperCount]["Title"];
                p.settitle(title);

                String content = (String)obj["d"]["Publication"]["Result"][paperCount]["Abstract"];
                p.setdescription(content);
                int authorCount = 0;

                String authors = "";

                while (authorCount < obj["d"]["Publication"]["Result"][paperCount]["Author"].Count() && authorCount < 5)
                {

                    authors += (String)obj["d"]["Publication"]["Result"][paperCount]["Author"][authorCount]["FirstName"] + " ";

                    if ((String)obj["d"]["Publication"]["Result"][paperCount]["Author"][authorCount]["MiddleName"] != "")

                        authors += (String)obj["d"]["Publication"]["Result"][paperCount]["Author"][authorCount]["MiddleName"] + " " + (String)obj["d"]["Publication"]["Result"][paperCount]["Author"][authorCount]["LastName"] + " , ";
                    else
                        authors += (String)obj["d"]["Publication"]["Result"][paperCount]["Author"][authorCount]["LastName"] + " , ";

                    authorCount++;
                }

                p.setYear((int)obj["d"]["Publication"]["Result"][paperCount]["Year"]);
                p.setauthors(authors);

                //if (obj["d"]["Publication"]["Result"][paperCount]["Conference"] != null)
                //  p.setConferenceUrl(((String)(obj["d"]["Publication"]["Result"][paperCount]["Conference"][0])));


                int citations = Convert.ToInt32((String)obj["d"]["Publication"]["Result"][paperCount]["CitationCount"]);
                p.setnumCitations(citations);

                String url = "";

                if (obj["d"]["Publication"]["Result"][paperCount]["FullVersionURL"].Count() > 0)
                {
                    url = (String)obj["d"]["Publication"]["Result"][paperCount]["FullVersionURL"][0];
                }


                if (url != "")
                {
                    Uri titleURL = new Uri(url);
                    p.seturl(titleURL);
                }
                else
                {
                    p.seturl(null);
                }
                int id = (int)obj["d"]["Publication"]["Result"][paperCount]["ID"];
                p.setid(id);
                paperCount++;

                result.addPaper(p);
                resList.Add(result);
            }
            return resList;

        }