public SearchResultsAdapter(Context context, ActivityNavigator activityNavigator, SearchActivityBinding binding) : base(context)
 {
     this.activityNavigator  = activityNavigator;
     this.binding            = binding;
     this.filteredList       = new ArrayList();
     this.textAppearanceSpan = new TextAppearanceSpan(context, Resource.Style.SearchResultAppearance);
 }
 private object?PlatformCreate(object?value, ServerTimestampBehavior?serverTimestampBehavior)
 {
     return(value switch
     {
         JavaList list => PlatformCreate(list),
         AbstractList list => PlatformCreate(list),
         null => default,
        public static StringColumn FindColumn(AbstractList list, string columnName, out int index)
        {
            StringColumn foundColumn = list.Columns.First(column => column.Name.Contains(TranslateUtils.Translate(columnName)));

            index = list.Columns.ToList().IndexOf(foundColumn);
            return(foundColumn);
        }
示例#4
0
 /// <summary>
 /// Gets all products
 /// </summary>
 /// <returns></returns>
 public IHttpActionResult Get()
 {
     try
     {
         AbstractList <Product> productsList = new AbstractList <Product>();
         productsList.entitis = productsManager.retrieve();
         productsList.entitis.ForEach(o => o.Links.Add(new Link()
         {
             Rel    = "Self",
             Method = "Get",
             Href   = "/produts/" + o.Id
         }));
         productsList.links.Add(new Link()
         {
             Rel    = "Self",
             Method = "Get",
             Href   = "/produts/"
         });
         return(Ok(productsList));
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }
 public object?Create(object?value, ServerTimestampBehavior?serverTimestampBehavior)
 {
     return(value switch
     {
         JavaList list => Create(list),
         AbstractList list => Create(list),
         null => default,
        public static void WriteList(AbstractList list, string path, IXLSXWriteDataStrategy writeDataStrategy, IXLSXWriteHeaderStrategy headerStrategy, ListType listType)
        {
            CellStyleFactory.ResetStyles();

            _sheet = SheetFactory.CreateSheet(path);
            _list  = list;

            headerStrategy.FormatHeader(_list, _sheet, listType);

            WriteColumnsNames();

            if (listType == ListType.BoltsDelivery)
            {
                CellRangeAddress blankRegion =
                    new CellRangeAddress(_sheet.LastRowNum, _sheet.LastRowNum, _list.Columns.Count - 1, _list.Columns.Count + 1);

                IRow columnsRow = _sheet.GetRow(_sheet.LastRowNum);
                columnsRow.CreateCell(_list.Columns.Count);
                columnsRow.CreateCell(_list.Columns.Count + 1);
                columnsRow.GetCell(_list.Columns.Count + 1).CellStyle = CellStyleFactory.CreateCenterAlignmentStyle(_sheet.Workbook);
                _sheet.AddMergedRegion(blankRegion);
            }

            writeDataStrategy.WriteData(list, _sheet);

            AutosizeAllColumns();
            WriteWorkbook(path);
            OpenWorkbook(path);
        }
示例#7
0
        public static StructuralList ConvertToStructuralList(this AbstractList list)
        {
            _list = (StructuralList)list;

            TidyColumns();

            return(_list);
        }
        public static TeklaList ConvertToDeliveryList(this AbstractList list)
        {
            _list = (TeklaList)list;

            CalculateTotalWeight();

            PutAreaOnEnd();
            return(_list);
        }
示例#9
0
        private void ValidateModel(AbstractList model)
        {
            foreach (var item in model.Items.Select((value, i) => (value, i)))
            {
                var value = item.value;
                var index = item.i;

                Assert.Equal(index, value.Id);
            }
        }
        public void TestGetNearbyPointOfInterests()
        {
            Location location = new Location("ACPPlacesTestApp.Xamarin");

            location.Latitude  = 37.3309;
            location.Longitude = 121.8939;
            ACPPlaces.GetNearbyPointsOfInterest(location, 0, new AdobeCallback());
            AbstractList pois = (AbstractList)taskCompletionSource.Task.ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.That(pois.Size, Is.EqualTo(0));
        }
示例#11
0
        public static BoltsDeliveryList ConvertToBoltsDeliveryList(this AbstractList list)
        {
            _list = (BoltsDeliveryList)list;

            FillRemainingColumns();
            FixEmptyEntries();
            DivideDataIntoChunks();
            ReplaceTextInSize();
            SetColumnsInOrder();

            return(_list);
        }
示例#12
0
            public override void InsertAtInternal(int index, T[] items, out AbstractList one, out AbstractList[] many)
            {
                int subIndex;
                int slot     = this.GetSlot(index, out subIndex);
                var subArray = this.arrays[slot];

                AbstractList subOne;

                AbstractList[] subMany;
                subArray.InsertAtInternal(subIndex, items, out subOne, out subMany);

                this.ReplaceSubArray(slot, subOne, subMany, out one, out many);
            }
        public static List <StringColumn> GetClonedColumns(AbstractList list)
        {
            List <StringColumn> clonedColumns = new List <StringColumn>();
            List <StringColumn> oldColumns    = list.Columns;

            foreach (StringColumn oldColumn in oldColumns)
            {
                StringColumn newColumn = new StringColumn(oldColumn.Name);
                newColumn.Data = new List <DataChunk>();
                clonedColumns.Add(newColumn);
            }

            return(clonedColumns);
        }
示例#14
0
        private AbstractList CreateModel()
        {
            var model = new AbstractList();

            for (int i = 0; i < 10; i++)
            {
                model.Items.Add(new ItemImplementation
                {
                    Id = i,
                });
            }

            return(model);
        }
        public void FormatHeader(AbstractList list, ISheet sheet, ListType listType)
        {
            for (int rowNum = sheet.FirstRowNum; rowNum < sheet.LastRowNum; rowNum++)
            {
                IRow row = sheet.GetRow(rowNum);
                for (int cellNum = row.FirstCellNum; cellNum < row.LastCellNum; cellNum++)
                {
                    ICell  cell            = row.GetCell(cellNum);
                    string originalContent = cell.StringCellValue;

                    string newContent = originalContent.Replace("<rodzaj listy>", GetListTypeString(listType))
                                        .Replace("<data>", list.Header.Date)
                                        .Replace("<nr projektu>", list.Header.No);

                    cell.SetCellValue(newContent);
                }

                sheet.Workbook.SetSheetName(0, GetListTypeString(listType));
            }
        }
        public static void WriteList(ListType type, AbstractList list, string path)
        {
            switch (type)
            {
            case ListType.Material:
                XLSXWriter.WriteList(list, path, new MaterialDeliveryStrategy(), new HeaderStrategy(), type);
                break;

            case ListType.Delivery:
                XLSXWriter.WriteList(list.ConvertToDeliveryList(), path, new MaterialDeliveryStrategy(), new HeaderStrategy(), type);
                break;

            case ListType.Structural:
                XLSXWriter.WriteList(list.ConvertToStructuralList(), path, new StructuralStrategy(), new HeaderStrategy(), type);
                break;

            case ListType.BoltsDelivery:
                XLSXWriter.WriteList(list.ConvertToBoltsDeliveryList(), path, new BoltsDeliveryStrategy(), new HeaderStrategy(), type);
                break;
            }
        }
示例#17
0
        public IHttpActionResult Get()
        {
            try
            {
                AbstractList <Order> ordersList = new AbstractList <Order>();

                ordersList.entitis = orderManager.retrieve(userId);
                ordersList.entitis.ForEach(o => o.Links.Add(new Link()
                {
                    Rel    = "Get Order Details",
                    Method = "Get",
                    Href   = "/Orders/" + o.Id
                }));
                ordersList.entitis.ForEach(o => o.Links.Add(new Link()
                {
                    Rel    = "Delete Order",
                    Method = "Delete",
                    Href   = "/Orders/" + o.Id
                }));
                ordersList.links.Add(new Link()
                {
                    Rel    = "Self",
                    Method = "Get",
                    Href   = "/Orders/"
                });
                ordersList.links.Add(new Link()
                {
                    Rel    = "Create New Order",
                    Method = "Post",
                    Href   = "/Orders/"
                });
                return(Ok(ordersList));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
示例#18
0
            public override void InsertAtInternal(int index, T[] items, out AbstractList one, out AbstractList[] many)
            {
                if (this.items.Length + items.Length <= IdealElementCount)
                {
                    one  = new ElementList(this.items.InsertAt(index, items));
                    many = null;
                }
                else if (index == 0)
                {
                    one  = null;
                    many = new AbstractList[] { new ElementList(items), this };
                }
                else if (index == this.items.Length)
                {
                    one  = null;
                    many = new AbstractList[] { this, new ElementList(items) };
                }
                else
                {
                    var before = this.items.RemoveAt(index, this.items.Length - index);
                    var after  = this.items.RemoveAt(0, index);

                    one = null;
                    if (before.Length + items.Length <= IdealElementCount)
                    {
                        many = new AbstractList[] { new ElementList(before.Append(items)), new ElementList(after) };
                    }
                    else if (after.Length + items.Length <= IdealElementCount)
                    {
                        many = new AbstractList[] { new ElementList(before), new ElementList(items.Append(after)) };
                    }
                    else
                    {
                        many = new AbstractList[] { new ElementList(before), new ElementList(items), new ElementList(after) };
                    }
                }
            }
        public void CreateList(string listName)
        {
            switch (listName)
            {
            case Constants.ListTitle.Employees:
                _model = new EmployeesList(_context);
                _model.Create();
                break;

            case Constants.ListTitle.Projects:
                _model = new ProjectsList(_context);
                _model.Create();
                break;

            case Constants.ListTitle.ProjDoc:
                _model = new ProjDocsList(_context);
                _model.Create();
                break;

            default:
                throw new Exception("Chương trình không hỗ trợ List này");
            }
            _model.Dispose();
        }
示例#20
0
        public void WriteData(AbstractList list, ISheet sheet)
        {
            ICollection <StringColumn> columns = list.Columns;
            int numDataChunks = columns.First().Data.Count;
            int numColumns    = columns.Count;

            _lastDataColumn = numColumns - 1;

            for (int chunkIndex = 0; chunkIndex < numDataChunks; chunkIndex++)
            {
                int numEntries = columns.First().Data.ElementAt(chunkIndex).Entries.Count;
                for (int entryIndex = 0; entryIndex < numEntries; entryIndex++)
                {
                    IRow row = SheetUtils.CreateRow(sheet);
                    if (chunkIndex == 0 && entryIndex == 0)
                    {
                        _firstDataRow = row.RowNum;
                    }

                    string assemblyEntry = columns.First().Data.ElementAt(chunkIndex).Entries.ElementAt(entryIndex);
                    bool   isFirstRow    = !string.IsNullOrEmpty(assemblyEntry);

                    for (int columnIndex = 0; columnIndex < numColumns; columnIndex++)
                    {
                        ICell cell = row.CreateCell(columnIndex);
                        cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle(sheet.Workbook);
                        string entry = columns.ElementAt(columnIndex).Data.ElementAt(chunkIndex).Entries
                                       .ElementAt(entryIndex);

                        bool isNumber = double.TryParse(entry, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                        out double result);

                        if (isNumber)
                        {
                            int decimalPts = columns.ElementAt(columnIndex).GetNumDecimalPlaces();
                            switch (decimalPts)
                            {
                            case -1:
                                cell.SetCellValue(entry);
                                break;

                            case 0:
                                cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle0DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            case 1:
                                cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle1DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            default:
                                cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle2DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;
                            }
                        }
                        else
                        {
                            cell.SetCellValue(entry.Trim());
                        }

                        if (isFirstRow)
                        {
                            if (isNumber)
                            {
                                int decimalPts = columns.ElementAt(columnIndex).GetNumDecimalPlaces();

                                switch (decimalPts)
                                {
                                case -1:
                                    cell.SetCellValue(entry);
                                    cell.CellStyle = CellStyleFactory.CreateSummaryStyle(sheet.Workbook);
                                    break;

                                case 0:
                                    cell.CellStyle = CellStyleFactory.CreateSummaryStyle0DecimalPts(sheet.Workbook);
                                    cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                    break;

                                case 1:
                                    cell.CellStyle = CellStyleFactory.CreateSummaryStyle1DecimalPts(sheet.Workbook);
                                    cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                    break;

                                default:
                                    cell.CellStyle = CellStyleFactory.CreateSummaryStyle2DecimalPts(sheet.Workbook);
                                    cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                    break;
                                }
                            }
                            else
                            {
                                cell.CellStyle = CellStyleFactory.CreateSummaryStyle(sheet.Workbook);
                            }
                        }
                    }
                }
            }

            IRow   summaryRow        = SheetUtils.CreateRow(sheet);
            int    emptySummaryCount = 0;
            string weightColumnName  = TranslateUtils.Translate("Weight");

            for (int columnIndex = 0; columnIndex < columns.Count; columnIndex++)
            {
                ICell cell = summaryRow.CreateCell(columnIndex);
                cell.CellStyle = CellStyleFactory.CreateFinalSummaryStyle(sheet.Workbook);

                if (columns.ElementAt(columnIndex).Name.Contains(weightColumnName))
                {
                    int decimalPts = columns.ElementAt(columnIndex).GetNumDecimalPlaces();
                    switch (decimalPts)
                    {
                    case -1:
                        cell.SetCellValue(((StructuralList)list).WeightSummary);
                        break;

                    case 0:
                        cell.CellStyle =
                            CellStyleFactory.CreateFinalSummaryStyle0DecimalPts(sheet.Workbook);
                        cell.SetCellValue(double.Parse(((StructuralList)list).WeightSummary, NumberStyles.Any, CultureInfo.InvariantCulture));
                        break;

                    case 1:
                        cell.CellStyle =
                            CellStyleFactory.CreateFinalSummaryStyle1DecimalPts(sheet.Workbook);
                        cell.SetCellValue(double.Parse(((StructuralList)list).WeightSummary, NumberStyles.Any, CultureInfo.InvariantCulture));
                        break;

                    default:
                        cell.CellStyle =
                            CellStyleFactory.CreateFinalSummaryStyle2DecimalPts(sheet.Workbook);
                        cell.SetCellValue(double.Parse(((StructuralList)list).WeightSummary, NumberStyles.Any, CultureInfo.InvariantCulture));
                        break;
                    }
                    // cell.SetCellValue(SheetUtils.SeparateThousands(((StructuralList) list).WeightSummary, false));
                }
                else
                {
                    cell.SetCellValue("Suma całkowita");
                    emptySummaryCount++;
                }
            }

            CellRangeAddress region =
                new CellRangeAddress(sheet.LastRowNum, sheet.LastRowNum, 0, emptySummaryCount - 1);

            sheet.AddMergedRegion(region);

            _lastDataRow = sheet.LastRowNum;

            BorderDrawer.drawBorders(sheet, _firstDataRow, _lastDataRow, _lastDataColumn);
        }
示例#21
0
 public AbstractListIterator(AbstractList list)
 {
     this.list = list;
     this.n    = 0;
 }
示例#22
0
 public abstract void InsertAtInternal(int index, T[] items, out AbstractList one, out AbstractList[] many);
        public void WriteData(AbstractList list, ISheet sheet)
        {
            ICollection <StringColumn> columns = list.Columns;
            int numDataChunks = columns.First().Data.Count;
            int numColumns    = columns.Count;

            _lastDataColumn = numColumns - 1;

            for (int i = 0; i < numDataChunks - 1; i++)
            {
                int rowCount = columns.First().Data.ElementAt(i).Entries.Count;
                for (int r = 0; r < rowCount; r++)
                {
                    IRow row = SheetUtils.CreateRow(sheet);
                    if (i == 0 && r == 0)
                    {
                        _firstDataRow = row.RowNum;
                    }
                    for (int c = 0; c < numColumns; c++)
                    {
                        ICell cell = row.CreateCell(c);
                        cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle(sheet.Workbook);

                        string entry    = columns.ElementAt(c).Data.ElementAt(i).Entries.ElementAt(r);
                        bool   isNumber = double.TryParse(entry, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                          out double result);

                        if (isNumber)
                        {
                            int decimalPts = columns.ElementAt(c).GetNumDecimalPlaces();
                            switch (decimalPts)
                            {
                            case -1:
                                cell.SetCellValue(entry);
                                break;

                            case 0:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle0DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            case 1:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle1DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            default:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle2DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;
                            }
                        }
                        else
                        {
                            cell.SetCellValue(entry);
                        }
                    }
                }

                IRow       summaryRow        = SheetUtils.CreateRow(sheet);
                int        emptySummaryCount = 0;
                bool       isFinal           = i == numDataChunks - 2;
                ICellStyle summaryStyle      = isFinal
                    ? CellStyleFactory.CreateFinalSummaryStyle(sheet.Workbook)
                    : CellStyleFactory.CreateSummaryStyle(sheet.Workbook);
                string sumLabel = isFinal ? "Suma całkowita" : "Suma";

                for (int c = 0; c < numColumns; c++)
                {
                    string summary = columns.ElementAt(c).Data.ElementAt(i).Summary;

                    ICell cell = summaryRow.CreateCell(c, CellType.Numeric);
                    cell.CellStyle = summaryStyle;

                    if (string.IsNullOrEmpty(summary) || summary.Contains("Tota") || summary.Contains("for"))
                    {
                        emptySummaryCount++;
                        cell.SetCellValue(sumLabel);
                    }
                    else
                    {
                        string columnName = columns.ElementAt(c).Name;

                        bool isNumber = double.TryParse(summary, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                        out double result);
                        if (isNumber)
                        {
                            int decimalPts = columns.ElementAt(c).GetNumDecimalPlaces();
                            switch (decimalPts)
                            {
                            case -1:
                                cell.SetCellValue(summary);
                                break;

                            case 0:
                                cell.CellStyle = isFinal
                                        ? CellStyleFactory.CreateFinalSummaryStyle0DecimalPts(sheet.Workbook)
                                        : CellStyleFactory.CreateSummaryStyle0DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(summary, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            case 1:
                                cell.CellStyle = isFinal
                                        ? CellStyleFactory.CreateFinalSummaryStyle1DecimalPts(sheet.Workbook)
                                        : CellStyleFactory.CreateSummaryStyle1DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(summary, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            default:
                                cell.CellStyle = isFinal
                                        ? CellStyleFactory.CreateFinalSummaryStyle2DecimalPts(sheet.Workbook)
                                        : CellStyleFactory.CreateSummaryStyle2DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(summary, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;
                            }

                            // cell.SetCellValue(SheetUtils.SeparateThousands(summary,
                            //     !intColumns.Any(column => columnName.Contains(TranslateUtils.Translate(column)))));
                        }
                        else
                        {
                            emptySummaryCount++;
                        }
                    }

                    if (!string.IsNullOrEmpty(summary) && summary.Contains("for") && summary.Length == 3)
                    {
                        emptySummaryCount++;
                    }
                }


                CellRangeAddress region =
                    new CellRangeAddress(sheet.LastRowNum, sheet.LastRowNum, 0, emptySummaryCount - 1);
                sheet.AddMergedRegion(region);
            }

            _lastDataRow = sheet.LastRowNum;

            BorderDrawer.drawBorders(sheet, _firstDataRow, _lastDataRow, _lastDataColumn);
        }
示例#24
0
            private void Check()
            {
                IEnumerator <KeyValuePair <DatanodeDescriptor, AbstractList <BlockInfoContiguous> > >
                it = new CyclicIteration <DatanodeDescriptor, AbstractList <BlockInfoContiguous> >(
                    this._enclosing.decomNodeBlocks, this.iterkey).GetEnumerator();
                List <DatanodeDescriptor> toRemove = new List <DatanodeDescriptor>();

                while (it.HasNext() && !this.ExceededNumBlocksPerCheck() && !this.ExceededNumNodesPerCheck
                           ())
                {
                    this.numNodesChecked++;
                    KeyValuePair <DatanodeDescriptor, AbstractList <BlockInfoContiguous> > entry = it.Next
                                                                                                       ();
                    DatanodeDescriptor dn = entry.Key;
                    AbstractList <BlockInfoContiguous> blocks = entry.Value;
                    bool fullScan = false;
                    if (blocks == null)
                    {
                        // This is a newly added datanode, run through its list to schedule
                        // under-replicated blocks for replication and collect the blocks
                        // that are insufficiently replicated for further tracking
                        DecommissionManager.Log.Debug("Newly-added node {}, doing full scan to find " + "insufficiently-replicated blocks."
                                                      , dn);
                        blocks = this.HandleInsufficientlyReplicated(dn);
                        this._enclosing.decomNodeBlocks[dn] = blocks;
                        fullScan = true;
                    }
                    else
                    {
                        // This is a known datanode, check if its # of insufficiently
                        // replicated blocks has dropped to zero and if it can be decommed
                        DecommissionManager.Log.Debug("Processing decommission-in-progress node {}", dn);
                        this.PruneSufficientlyReplicated(dn, blocks);
                    }
                    if (blocks.Count == 0)
                    {
                        if (!fullScan)
                        {
                            // If we didn't just do a full scan, need to re-check with the
                            // full block map.
                            //
                            // We've replicated all the known insufficiently replicated
                            // blocks. Re-check with the full block map before finally
                            // marking the datanode as decommissioned
                            DecommissionManager.Log.Debug("Node {} has finished replicating current set of "
                                                          + "blocks, checking with the full block map.", dn);
                            blocks = this.HandleInsufficientlyReplicated(dn);
                            this._enclosing.decomNodeBlocks[dn] = blocks;
                        }
                        // If the full scan is clean AND the node liveness is okay,
                        // we can finally mark as decommissioned.
                        bool isHealthy = this._enclosing.blockManager.IsNodeHealthyForDecommission(dn);
                        if (blocks.Count == 0 && isHealthy)
                        {
                            this._enclosing.SetDecommissioned(dn);
                            toRemove.AddItem(dn);
                            DecommissionManager.Log.Debug("Node {} is sufficiently replicated and healthy, "
                                                          + "marked as decommissioned.", dn);
                        }
                        else
                        {
                            if (DecommissionManager.Log.IsDebugEnabled())
                            {
                                StringBuilder b = new StringBuilder("Node {} ");
                                if (isHealthy)
                                {
                                    b.Append("is ");
                                }
                                else
                                {
                                    b.Append("isn't ");
                                }
                                b.Append("healthy and still needs to replicate {} more blocks," + " decommissioning is still in progress."
                                         );
                                DecommissionManager.Log.Debug(b.ToString(), dn, blocks.Count);
                            }
                        }
                    }
                    else
                    {
                        DecommissionManager.Log.Debug("Node {} still has {} blocks to replicate " + "before it is a candidate to finish decommissioning."
                                                      , dn, blocks.Count);
                    }
                    this.iterkey = dn;
                }
                // Remove the datanodes that are decommissioned
                foreach (DatanodeDescriptor dn_1 in toRemove)
                {
                    Preconditions.CheckState(dn_1.IsDecommissioned(), "Removing a node that is not yet decommissioned!"
                                             );
                    Sharpen.Collections.Remove(this._enclosing.decomNodeBlocks, dn_1);
                }
            }
示例#25
0
 /// <summary>
 /// Removes sufficiently replicated blocks from the block list of a
 /// datanode.
 /// </summary>
 private void PruneSufficientlyReplicated(DatanodeDescriptor datanode, AbstractList
                                          <BlockInfoContiguous> blocks)
 {
     this.ProcessBlocksForDecomInternal(datanode, blocks.GetEnumerator(), null, true);
 }
        public void WriteData(AbstractList list, ISheet sheet)
        {
            ICollection <StringColumn> columns = list.Columns;
            int numDataChunks = columns.First().Data.Count;
            int numColumns    = columns.Count;

            _lastDataColumn = numColumns + 1;

            for (int i = 0; i < numDataChunks; i++)
            {
                int rowCount = columns.First().Data.ElementAt(i).Entries.Count;
                for (int r = 0; r < rowCount; r++)
                {
                    IRow row = SheetUtils.CreateRow(sheet);
                    if (i == 0 && r == 0)
                    {
                        _firstDataRow = row.RowNum;
                    }
                    for (int c = 0; c < numColumns; c++)
                    {
                        ICell cell = row.CreateCell(c);
                        cell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle(sheet.Workbook);

                        string entry    = columns.ElementAt(c).Data.ElementAt(i).Entries.ElementAt(r);
                        bool   isNumber = double.TryParse(entry, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                          out double result);

                        if (isNumber)
                        {
                            int decimalPts = columns.ElementAt(c).GetNumDecimalPlaces();
                            switch (decimalPts)
                            {
                            case -1:
                                cell.SetCellValue(entry);
                                break;

                            case 0:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle0DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            case 1:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle1DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;

                            default:
                                cell.CellStyle =
                                    CellStyleFactory.CreateCenterAlignmentStyle2DecimalPts(sheet.Workbook);
                                cell.SetCellValue(double.Parse(entry, NumberStyles.Any, CultureInfo.InvariantCulture));
                                break;
                            }
                        }
                        else
                        {
                            cell.SetCellValue(entry);
                        }
                    }

                    for (int notesIndex = 0; notesIndex < 2; notesIndex++)
                    {
                        ICell notesCell = row.CreateCell(numColumns + notesIndex);
                        // if ()
                        notesCell.CellStyle = CellStyleFactory.CreateCenterAlignmentStyle(sheet.Workbook);
                    }

                    CellRangeAddress region =
                        new CellRangeAddress(sheet.LastRowNum, sheet.LastRowNum, numColumns - 1, numColumns + 1);
                    sheet.AddMergedRegion(region);
                }

                if (i == numDataChunks - 1)
                {
                    continue;
                }

                IRow blankRow = SheetUtils.CreateRow(sheet);

                for (int c = 0; c < numColumns + 2; c++)
                {
                    ICell cell = blankRow.CreateCell(c);
                    cell.CellStyle = CellStyleFactory.CreateFinalSummaryStyle(sheet.Workbook);
                }

                CellRangeAddress blankRegion =
                    new CellRangeAddress(sheet.LastRowNum, sheet.LastRowNum, numColumns - 1, numColumns + 1);
                sheet.AddMergedRegion(blankRegion);
            }

            _lastDataRow = sheet.LastRowNum;

            BorderDrawer.drawBorders(sheet, _firstDataRow, _lastDataRow, _lastDataColumn);
        }
示例#27
0
            private void ReplaceSubArray(int slot, AbstractList subOne, AbstractList[] subMany, out AbstractList one, out AbstractList[] many)
            {
                if (subOne != null)
                {
                    one  = new CompoundList(this.arrays.ReplaceAt(slot, subOne));
                    many = null;
                }
                else if (subMany == null || subMany.Length == 0)
                {
                    // no subOne or subMany? Item in slot is gone
                    if (this.arrays.Length == 1)
                    {
                        // nothing left
                        one = Empty;
                    }
                    else
                    {
                        one = new CompoundList(this.arrays.RemoveAt(slot));
                    }

                    many = null;
                }
                else if (this.arrays.Length - 1 + subMany.Length <= IdealSlotCount)
                {
                    one  = new CompoundList(this.arrays.ReplaceAt(slot, 1, subMany));
                    many = null;
                }
                else if (slot == 0)
                {
                    one  = null;
                    many = new AbstractList[]
                    {
                        new CompoundList(subMany),
                        new CompoundList(this.arrays.RemoveAt(0, 1))
                    };
                }
                else if (slot == this.arrays.Length - 1)
                {
                    one  = null;
                    many = new AbstractList[]
                    {
                        new CompoundList(this.arrays.RemoveAt(slot, this.arrays.Length - slot)),
                        new CompoundList(subMany)
                    };
                }
                else
                {
                    var before = this.arrays.RemoveAt(slot, this.arrays.Length - slot);
                    var after  = this.arrays.RemoveAt(0, slot + 1);

                    one = null;

                    if (before.Length + subMany.Length <= IdealElementCount)
                    {
                        many = new AbstractList[] { new CompoundList(before.Append(subMany)), new CompoundList(after) };
                    }
                    else if (after.Length + subMany.Length <= IdealElementCount)
                    {
                        many = new AbstractList[] { new CompoundList(before), new CompoundList(subMany.Append(after)) };
                    }
                    else
                    {
                        many = new AbstractList[] { new CompoundList(before), new CompoundList(subMany), new CompoundList(after) };
                    }
                }
            }