示例#1
0
        /**
         * Connects to the specified {@link SpreadsheetsService} and uses a batch
         * request to retrieve a {@link CellEntry} for each cell enumerated in {@code
         * cellAddrs}. Each cell entry is placed into a map keyed by its RnCn
         * identifier.
         *
         * @param service the spreadsheet service to use.
         * @param cellFeed the cell feed to use.
         * @param cellAddrs list of cell addresses to be retrieved.
         * @return a dictionary consisting of one {@link CellEntry} for each address in {@code
         *         cellAddrs}
         */
        private static Dictionary <String, CellEntry> GetCellEntryMap(
            SpreadsheetsService service, CellFeed cellFeed, List <CellAddress> cellAddrs)
        {
            CellFeed batchRequest = new CellFeed(new Uri(cellFeed.Self), service);

            foreach (CellAddress cellId in cellAddrs)
            {
                CellEntry batchEntry = new CellEntry((uint)cellId.Row, (uint)cellId.Col, cellId.InputValue);
                batchEntry.Id        = new AtomId(string.Format("{0}/{1}", cellFeed.Self, cellId.IdString));
                batchEntry.BatchData = new GDataBatchEntryData(cellId.IdString, GDataBatchOperationType.query);
                batchRequest.Entries.Add(batchEntry);
            }

            CellFeed queryBatchResponse = (CellFeed)service.Batch(batchRequest, new Uri(cellFeed.Batch));

            Dictionary <String, CellEntry> cellEntryMap = new Dictionary <String, CellEntry>();

            foreach (CellEntry entry in queryBatchResponse.Entries)
            {
                cellEntryMap.Add(entry.BatchData.Id, entry);
                Console.WriteLine("batch {0} (CellEntry: id={1} editLink={2} inputValue={3})",
                                  entry.BatchData.Id, entry.Id, entry.EditUri,
                                  entry.InputValue);
            }

            return(cellEntryMap);
        }
        ///// <summary>
        ///// Get Data from a collection of cells
        ///// </summary>
        ///// <param name="worksheet"></param>
        ///// <param name="columStart"></param>
        ///// <param name="columEnd"></param>
        ///// <param name="rowStart"></param>
        ///// <param name="rowEnd"></param>
        ///// <returns></returns>
        //public static List<CellEntry> GetCellDataCollection(this GS2U_Worksheet worksheet, string columStart, string columEnd, int rowStart, int rowEnd)
        //{
        //    CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
        //    cellQuery.MinimumRow = (uint)rowStart;
        //    cellQuery.MaximumRow = (uint)rowEnd;
        //    cellQuery.MinimumColumn = (uint)Util.GetIndexInAlphabet(columStart);
        //    cellQuery.MaximumColumn = (uint)Util.GetIndexInAlphabet(columEnd);

        //    CellFeed cellFeed = SpreadSheetManager.service.Query(cellQuery) as CellFeed;
        //    List<CellEntry> entries = new List<CellEntry>();

        //    for (int i = 0; i < cellFeed.Entries.Count; i++)
        //    {
        //        entries.Add((CellEntry)cellFeed.Entries[i]);
        //    }

        //    return entries;
        //}

        //public static void ModifyCellData(this CellEntry cell, string newData)
        //{
        //    cell.InputValue = newData;
        //    cell.Update();
        //}

        public static void ModifyCellData(this GS2U_Worksheet worksheet, string colum, int row, string newData)
        {
            CellEntry cell = worksheet.GetCellEntry(colum, row);

            cell.InputValue = newData;
            cell.Update();
        }
示例#3
0
        private string ToGoogleTable()
        {
            WorksheetFeed  wsFeed    = TargetTable.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed  listFeed  = service.Query(listQuery);

            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            CellFeed  cellFeed  = service.Query(cellQuery);

            CellEntry cellEntry = new CellEntry(1, 1, "oid");

            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 2, "value");
            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 3, "type");
            cellFeed.Insert(cellEntry);
            ProgressBarSetStartParams(progressBar1, ListData[ListData.Count - 1].Count);
            tabControlShow(progressBar1);
            tabControlShow(label3);
            for (int i = 0; i < ListData[ListData.Count - 1].Count; i++)
            {
                IncrementProgressbar(progressBar1);
                IncrementGeneralLabel(string.Format("Выполнено {0}/{1}", i + 1, ListData[ListData.Count - 1].Count));
                service.Insert(listFeed, ListData[ListData.Count - 1].GetCustom(i));
            }
            tabControlShow(progressBar1, false);
            tabControlShow(label3, false);
            return("Данные записаны");
        }
示例#4
0
    private IEnumerator DoMove()
    {
        yield return(new WaitForSeconds(t.wait));

        Board next = Current.FindNextMove(t.depth, t.isSmart[t.curPlayer]);

        for (int i = 0; i < t.n; i++)
        {
            for (int j = 0; j < t.n; j++)
            {
                CellEntry v = next.m_Values[i + j * t.n], u = Current.m_Values[i + j * t.n];
                if (u != v)
                {
                    if ((t.curPlayer == 1 && t.isX1) || (t.curPlayer == 2 && !t.isX1))  //当前游戏者是player1,下"X" 或 当前游戏者是player2,下"X"
                    {
                        t.img[j, i] = t.imgCellX;
                    }
                    else if ((t.curPlayer == 1 && !t.isX1) || (t.curPlayer == 2 && t.isX1))     //当前游戏者是player1,下"O" 或 当前游戏者是player2,下"O"
                    {
                        t.img[j, i] = t.imgCellO;
                    }
                }
            }
        }
        if (next != null)
        {
            Current = next;
        }
        NextPlayer();
    }
示例#5
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();
        }
示例#6
0
        /// <summary>
        /// カラム数が変わっていたら表を拡張してカラム名を更新
        /// </summary>
        /// <param name="wsEntry"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        protected WorksheetEntry CheckColumns(WorksheetEntry wsEntry, string[] columns)
        {
            if (columns.Length > wsEntry.Cols)
            {
                wsEntry.Cols = (uint)columns.Length;

                WorksheetEntry newEntry = (WorksheetEntry)wsEntry.Update();

                /*
                 * http://stackoverflow.com/questions/22719170/updating-cell-in-google-spreadsheets-returns-error-missing-resource-version-id
                 * http://stackoverflow.com/questions/20841411/google-spreadsheets-api-c-sharp-missing-resource-version-id-on-batch-update/23438381
                 *
                 * ETag:*をするとか、そもそもBatchよりPublishの方が分かりやすい、とか。
                 */
                CellFeed cellFeed = wsEntry.QueryCellFeed();

                uint col = 1;
                foreach (var it in columns)
                {
                    CellEntry batchEntry = cellFeed[1, col++];
                    batchEntry.InputValue = it;
                    batchEntry.Etag       = "*";
                }
                cellFeed.Publish();

                return(newEntry);
            }
            return(wsEntry);
        }
示例#7
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();
        }
        public void EnviarMovimiento(SpreadsheetsService servicio, CellEntry celdaMovimiento, double cantidad, double precio, string puntoVenta, string comentario,
                                     CellEntry[] producto, string[] nombresColumnas, string[] listaColumnasInventario, string url)
        {
            var movimiento = AgregarHistorico(celdaMovimiento, cantidad, precio, puntoVenta, producto, nombresColumnas, listaColumnasInventario, comentario);

            EnviarFilas(movimiento, servicio, url);
        }
示例#9
0
        public CellEntry BatchUpdateEntry(CellEntry cellEntry)
        {
            SetValue(cellEntry, Value);
            cellEntry.BatchData = new GDataBatchEntryData(IdString, GDataBatchOperationType.update);

            return(cellEntry);
        }
        /// <summary>
        /// Updates a single cell in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet to update</param>
        private static void UpdateCell(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink  cellFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
            CellQuery query        = new CellQuery(cellFeedLink.HRef.ToString());

            Console.WriteLine();

            Console.Write("Row of cell to update? ");
            string row = Console.ReadLine();

            Console.Write("Column of cell to update? ");
            string column = Console.ReadLine();

            query.MinimumRow    = query.MaximumRow = uint.Parse(row);
            query.MinimumColumn = query.MaximumColumn = uint.Parse(column);

            CellFeed  feed = service.Query(query);
            CellEntry cell = feed.Entries[0] as CellEntry;

            Console.WriteLine();
            Console.WriteLine("Current cell value: {0}", cell.Cell.Value);
            Console.Write("Enter a new value: ");
            string newValue = Console.ReadLine();

            cell.Cell.InputValue = newValue;
            AtomEntry updatedCell = cell.Update();

            Console.WriteLine("Successfully updated cell: {0}", updatedCell.Content.Content);
        }
        private void DoCellDelete(string index)
        {
            CellEntry entry = (CellEntry)this.editUriTable[index];

            // If the data is empty, then delete the cell
            service.Delete(entry);
        }
    private void AddSelectTableData(AtomEntryCollection colectCollection, MenuItemType sheet)
    {
        int counter = 0;

        for (int i = 4; i < colectCollection.Count; i++)
        {
            CellEntry cell = colectCollection[i] as CellEntry;
            switch (counter)
            {
            case 0:
                _runtimeDbSelect[sheet].Add(new BaseDataForSelectWindow()
                {
                    Id = int.Parse(cell.Value)
                }); break;

            case 1: _runtimeDbSelect[sheet].Last().Name = cell.Value; break;

            case 2: _runtimeDbSelect[sheet].Last().Price = cell.Value; break;

            case 3:
                _runtimeDbSelect[sheet].Last().AvatarSprite = cell.Value;
                counter = -1; break;
            }
            counter++;
        }
    }
        private void DoCellUpdate(string index)
        {
            CellEntry entry = (CellEntry)this.editUriTable[index];

            entry.Cell.Value        = null;
            entry.Cell.NumericValue = null;
            entry.Cell.InputValue   = this.cellUpdateDataTextBox.Text;

            service.Update(entry);
        }
        /// <summary>
        /// Sets the list view on the Cells tab
        /// </summary>
        /// <param name="feed">The feed providing the data</param>
        void SetCellListView(CellFeed feed)
        {
            // Clear out all the old information
            this.cellsListView.Items.Clear();
            this.cellsListView.Columns.Clear();
            this.editUriTable.Clear();

            AtomEntryCollection entries = feed.Entries;

            // Add in the column headers, as many as the column count asks
            // The number of rows, we only care to go as far as the data goes
            this.cellsListView.Columns.Add("", 20, HorizontalAlignment.Left);
            for (int i = 1; i < feed.ColCount.Count; i++)
            {
                this.cellsListView.Columns.Add(i.ToString(), 80, HorizontalAlignment.Center);
            }

            int currentRow = 1;
            int currentCol = 1;

            ListViewItem item = new ListViewItem();

            item.Text = 1.ToString();

            for (int i = 0; i < entries.Count; i++)
            {
                CellEntry entry = entries[i] as CellEntry;
                if (entry != null)
                {
                    // Add the current row, since we are starting
                    // a new row in data from the feed
                    while (entry.Cell.Row > currentRow)
                    {
                        this.cellsListView.Items.Add(item);
                        item      = new ListViewItem();
                        item.Text = (currentRow + 1).ToString();
                        currentRow++;
                        currentCol = 1;
                    }

                    // Add blank entries where there is no data for the column
                    while (entry.Cell.Column > currentCol)
                    {
                        item.SubItems.Add("");
                        currentCol++;
                    }

                    // Add the current data entry
                    item.SubItems.Add(entry.Cell.Value);
                    this.editUriTable.Add("R" + currentRow + "C" + currentCol,
                                          entry);
                    currentCol++;
                }
            }
        }
示例#15
0
 public static string GetValue(CellEntry cellEntry)
 {
     if (EscapedStrings.ContainsKey(cellEntry.InputValue))
     {
         return(EscapedStrings[cellEntry.InputValue]);
     }
     else
     {
         return(cellEntry.InputValue);
     }
 }
示例#16
0
        public Google2uCell(CellEntry in_entry)
        {
            if (in_entry == null)
            {
                return;
            }

            _MyCell = in_entry;
            RowNum  = (int)_MyCell.Row;
            ColNum  = (int)_MyCell.Column;
        }
        private async void IrAlProducto(string codigoProductoSeleccionado)
        {
            var fila = -1;

            GrupoEncabezado.IsVisible = false;
            if (CuentaUsuario.ObtenerAccesoDatos() == "G")
            {
                var productoSeleccionado = new CellEntry[_celdas.ColCount.Count];

                // Obtener el arreglo del producto para enviar
                foreach (CellEntry celda in _celdas.Entries)
                {
                    if (celda.Column == 1 && celda.Value == codigoProductoSeleccionado)
                    {
                        fila = (int)celda.Row;
                    }
                    if (celda.Row == fila)
                    {
                        productoSeleccionado.SetValue(celda, (int)celda.Column - 1);
                    }

                    // Si encontró producto (fila > -1) y ya pasó al próximo producto (celda.Row > fila) o es el último producto (celda.Column == _celdas.ColCount.Count)
                    if (fila > -1 && (celda.Row > fila || celda.Column == _celdas.ColCount.Count))
                    {
                        var titulo = _nombresColumnas != null && _nombresColumnas.Length > 1 ? _nombresColumnas[1] : "PRODUCTO";
                        await Navigation.PushAsync(new Producto(productoSeleccionado, _nombresColumnas, _servicio, titulo), true);

                        break;
                    }
                }
            }
            else
            {
                foreach (var producto in _productos)
                {
                    if (producto[0] != codigoProductoSeleccionado)
                    {
                        continue;
                    }
                    fila = 0;
                    await Navigation.PushAsync(new Producto(producto, _nombresColumnas), true);

                    break;
                }
            }
            GrupoEncabezado.IsVisible = true;
            // Si fila = -1 no se ha encuentrado el código
            if (fila == -1)
            {
                await DisplayAlert("Código", "No se ha encontrado un producto para el código escaneado.", "Listo");
            }
        }
示例#18
0
        public void AddNewHeader(string header)
        {
            WorksheetEntry.Cols += 1;
            WorksheetEntry.Update();
            CellQuery cellQuery = new CellQuery(WorksheetEntry.CellFeedLink);

            cellQuery.MaximumRow = 1;
            //cellQuery.Range = "A543:L543";
            CellFeed  cellFeed  = service.Query(cellQuery);
            CellEntry cellEntry = new CellEntry(1, (uint)cellFeed.Entries.Count + 1, header);

            cellFeed.Insert(cellEntry);
        }
示例#19
0
        /// <summary>
        /// Get cells in the given <paramref name="worksheet" />.
        /// </summary>
        /// <param name="query">The <typeparamref name="Google.GData.Spreadsheets.CellQuery" /> which should be executed.</param>
        /// <returns>Returns a <typeparamref name="Google.GData.Spreadsheets.CellEntry" /> array.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="query"/> is null.</exception>
        public virtual CellEntry[] GetCells(CellQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            this.cellFeed = this.service.Query(query);
            var result = new CellEntry[this.cellFeed.Entries.Count];

            this.cellFeed.Entries.CopyTo(result, 0);
            return(result);
        }
        /// <summary>
        /// Gets the data from an exact cell reference
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="column"></param>
        /// <param name="row"></param>
        /// <returns></returns>
        public static CellData GetCellData(this GS2U_Worksheet worksheet, string column, int row)
        {
            int colInt = GoogleSheetsToUnityUtilities.GetIndexInAlphabet(column);

            CellEntry entry = worksheet.GetCellEntry(colInt, row);

            List <string> rows = worksheet.GetRowTitles();
            List <string> cols = worksheet.GetColumnTitles();

            CellData cellData = new CellData(entry.InputValue, rows[row - 1], cols[colInt - 1]);

            return(cellData);
        }
        private void DoCellInsert()
        {
            // If there is data to insert then do so
            CellEntry entry = new CellEntry();

            CellEntry.CellElement cell = new CellEntry.CellElement();
            cell.InputValue = this.cellUpdateDataTextBox.Text;
            cell.Row        = UInt32.Parse(this.cellUpdateRowTextBox.Text);
            cell.Column     = UInt32.Parse(this.cellUpdateColumnTextBox.Text);
            entry.Cell      = cell;

            service.Insert(new Uri(this.worksheetListView.SelectedItems[0].SubItems[1].Text),
                           entry);
        }
示例#22
0
        /// <summary>
        /// Updates a single <paramref name="cell"/> with <paramref name="content"/>
        /// </summary>
        /// <param name="cell">The <typeparamref name="Google.GData.Spreadsheets.CellEntry" /> which should be updated.</param>
        /// <param name="content">The updated value. (empty string for deleting the cell's content)</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="cell"/> is null.</exception>
        public virtual void UpdateCell(CellEntry cell, string content)
        {
            if (cell == null)
            {
                throw new ArgumentNullException("cell");
            }
            if (content == null)
            {
                content = String.Empty;
            }

            cell.InputValue = content;
            cell.Update();
        }
示例#23
0
    void ComputeScore()                                 //对叶子节点的评估函数
    {
        int ret = 0;

        for (int i = lines.GetLowerBound(0); i <= lines.GetUpperBound(0); i++)
        {
            CellEntry[] temp = new CellEntry[m_n];
            for (int j = 0; j < m_n; j++)
            {
                temp[j] = m_Values[lines[i, j]];
            }
            ret += GetScoreForOneLine(temp);
        }
        m_Score = ret;
    }
示例#24
0
        private static void DoBulkUpdate(SpreadsheetsService service, WorksheetEntry worksheet)
        {
            Console.WriteLine("Attempting batch update...");

            var cellQuery = new CellQuery(worksheet.CellFeedLink);             //new CellQuery(result.Id, "od6", "private", "full");
            var cellFeed  = service.Query(cellQuery);

            // Work out those we wish to update
            var cellIdentifiers = new List <CellIdentifier>();

            for (uint row = 3; row <= 5; row++)
            {
                for (uint col = 1; col <= 3; col++)
                {
                    cellIdentifiers.Add(new CellIdentifier(row, col));
                }
            }

            // Query Google's API for these cells...
            CellFeed cellsToUpdate = BatchQuery(service, cellFeed, cellIdentifiers);

            // Update query...
            CellFeed batchRequest = new CellFeed(cellQuery.Uri, service);

            foreach (CellEntry cell in cellsToUpdate.Entries)
            {
                CellEntry batchEntry = cell;
                batchEntry.InputValue = string.Format("hello {0}", cell.BatchData.Id);
                batchEntry.BatchData  = new GDataBatchEntryData(cell.BatchData.Id, GDataBatchOperationType.update);
                batchRequest.Entries.Add(batchEntry);
            }

            var batchResponse = (CellFeed)service.Batch(batchRequest, new Uri(cellFeed.Batch));

            // Check all is well
            foreach (CellEntry entry in batchResponse.Entries)
            {
                var currentCellId = entry.BatchData.Id;
                if (entry.BatchData.Status.Code == 200)
                {
                    Console.WriteLine(string.Format("Cell {0} succeeded", currentCellId));
                }
                else
                {
                    Console.WriteLine(string.Format("Cell {0} failed: (status {1}) {2}", currentCellId, entry.BatchData.Status.Code, entry.BatchData.Status.Reason));
                }
            }
        }
示例#25
0
        private static bool UpdateHeaders(WorksheetEntry wsEntry)
        {
            bool updated = false;

            try
            {
                googleHeaders = new string[headers.Length];

                CellQuery cellQuery = new CellQuery(wsEntry.CellFeedLink);
                cellQuery.MaximumRow    = 1;
                cellQuery.MinimumRow    = 1;
                cellQuery.MinimumColumn = 1;
                cellQuery.MaximumColumn = (uint)headers.Length;

                CellFeed cellFeed = sheetsService.Query(cellQuery);
                if (cellFeed.Entries.Count > 0)
                {
                    for (int i = 0; i < cellFeed.Entries.Count; i++)
                    {
                        CellEntry cell = (CellEntry)cellFeed.Entries[i];
                        googleHeaders[i] = cell.InputValue;
                    }

                    if (!googleHeaders.Contains("SourceModelId"))
                    {
                        string    headerText = "SourceModelId"; // new column
                        CellEntry cell       = new CellEntry(1, (uint)headers.Length, headerText);
                        cellFeed.Insert(cell);
                        googleHeaders[headers.Length - 1] = headerText;
                    }
                }
                else
                {
                    for (int i = 0; i < headers.Length; i++)
                    {
                        string    headerText = headers[i];
                        CellEntry cell       = new CellEntry(1, Convert.ToUInt16(i + 1), headerText);
                        cellFeed.Insert(cell);
                    }
                    updated = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to update headers in Google Worksheet.\n" + ex.Message, "Update Headers", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(updated);
        }
示例#26
0
        private static CellFeed BatchQuery(SpreadsheetsService service, CellFeed cellFeed, IEnumerable <CellIdentifier> cellIdentifiers)
        {
            CellFeed batchRequest = new CellFeed(new Uri(cellFeed.Self), service);

            foreach (var cellId in cellIdentifiers)
            {
                CellEntry batchEntry = new CellEntry(cellId.Row, cellId.Col, cellId.Id);
                batchEntry.Id        = new AtomId(string.Format("{0}/{1}", cellFeed.Self, cellId.Id));
                batchEntry.BatchData = new GDataBatchEntryData(cellId.Id, GDataBatchOperationType.query);
                batchRequest.Entries.Add(batchEntry);
            }

            CellFeed queryBatchResponse = (CellFeed)service.Batch(batchRequest, new Uri(cellFeed.Batch));

            return(queryBatchResponse);
        }
        public string ObtenerHistorico(CellEntry celdaMovimiento, double cantidad, double precio, string lugar, CellEntry[] producto,
                                       string[] nombresColumnas, string[] listaColumnasInventario, string comentario)
        {
            // Abre la fila
            var fila = "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:gsx=\"http://schemas.google.com/spreadsheets/2006/extended\">";

            // Agrega la fecha
            fila += "<gsx:fecha>" + DateTime.Now.ToString("dd-MM-yyyy") + "</gsx:fecha>";
            // Agrega los valores del producto
            for (var i = 0; i < nombresColumnas.Length; i++)
            {
                var valor = producto[i].Value;                 //Si la columna no es de stock o es la que recibió el movimiento se inserta su valor en el histórico
                if (listaColumnasInventario[i] == "1" && i + 1 != celdaMovimiento.Column)
                {
                    valor = "-";                     //Si la columna es de stock pero no la que recibió el movimiento el valor para el histórico es "-"
                }
                var columna = Regex.Replace(nombresColumnas[i].ToLower(), @"\s+", "");
                fila += "<gsx:" + columna + ">" + WebUtility.HtmlEncode(valor) + "</gsx:" + columna + ">";
            }

            // Agrega el Movimiento
            fila += "<gsx:cantidad>" + cantidad.ToString().Replace('.', ',') + "</gsx:cantidad>";
            // Agrega el Precio total
            fila += "<gsx:preciototal>" + Math.Abs(precio) + "</gsx:preciototal>";
            // Agrega el Lugar (proveedor o punto de venta)
            fila += "<gsx:lugar>" + WebUtility.HtmlEncode(lugar) + "</gsx:lugar>";
            // Agrega Comentario
            comentario = string.IsNullOrEmpty(comentario) ? "-" : WebUtility.HtmlEncode(comentario.Trim());
            fila      += "<gsx:comentario>" + comentario + "</gsx:comentario>";
            // Agrega el Usuario
            var usuario = CuentaUsuario.ObtenerNombreUsuarioGoogle() ?? "-";

            fila += "<gsx:usuario>" + WebUtility.HtmlEncode(usuario) + "</gsx:usuario>";
            // Agrega Eliminado
            fila += "<gsx:eliminado>-</gsx:eliminado>";
            // Agrega Eliminado por
            fila += "<gsx:eliminadopor>-</gsx:eliminadopor>";

            //fila += "<batch:id>item" + u + "</batch:id>";
            //fila += "<batch:operation type=\"insert\"/>";
            //fila += "<g:item_type>recipes</g:item_type>";

            // Cierra la fila
            fila += "</entry>";

            return(fila);
        }
        private List <string> GetNodeMatches(CellFeed cellFeed, string lookupText)
        {
            List <string> listNodes = new List <string>();

            for (int i = 0; i < cellFeed.Entries.Count; i = i + 2)
            {
                CellEntry curCell = (CellEntry)cellFeed.Entries[i];
                string    urlText = curCell.Value;
                if (!string.IsNullOrWhiteSpace(urlText) && urlText.Contains(lookupText))
                {
                    CellEntry nextCell = (CellEntry)cellFeed.Entries[i + 1];
                    listNodes.Add(nextCell.Value);
                    break;
                }
            }
            return(listNodes);
        }
示例#29
0
        /// <summary>
        /// Get cells in the given <paramref name="worksheet" />.
        /// </summary>
        /// <param name="worksheet">The <typeparamref name="Google.GData.Spreadsheets.WorksheetEntry" /> from which the wcells should be returned.</param>
        /// <returns>Returns a <typeparamref name="Google.GData.Spreadsheets.CellEntry" /> array.</returns>
        public virtual CellEntry[] GetCells(WorksheetEntry worksheet)
        {
            if (worksheet == null)
            {
                worksheet = GetWorksheets(null)[0];
            }

            var query = new CellQuery(worksheet.CellFeedLink);

            query.ReturnEmpty = ReturnEmptyCells.yes;

            this.cellFeed = this.service.Query(query);
            var result = new CellEntry[this.cellFeed.Entries.Count];

            this.cellFeed.Entries.CopyTo(result, 0);
            return(result);
        }
示例#30
0
        private void SetColumnHeaders(string cellsFeedURI, params string[] headers)
        {
            CellFeed feed = service.Query(new CellQuery(cellsFeedURI));

            for (int i = 0; i < headers.Length; ++i)
            {
                CellEntry entry = new CellEntry
                {
                    Cell = new CellEntry.CellElement
                    {
                        InputValue = headers[i],
                        Row        = 1,
                        Column     = (uint)i + 1
                    }
                };
                service.Insert(new Uri(cellsFeedURI), entry);
            }
        }
示例#31
0
 public void Init()
 {
     entry = new CellEntry();
     cell = new CellEntry.CellElement();
     rng = new Random();
 }