private static void CopyRowToCreatedSheet(SmartsheetClient smartsheet, long sheetId, long rowId)
 {
     long tempSheetId = smartsheet.SheetResources.CreateSheet(new Sheet.CreateSheetBuilder("tempSheet", new Column[] { new Column.CreateSheetColumnBuilder("col1", true, ColumnType.TEXT_NUMBER).Build() }).Build()).Id.Value;
     CopyOrMoveRowDestination destination = new CopyOrMoveRowDestination {
         SheetId = tempSheetId
     };
     CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective {
         RowIds = new long[] { rowId }, To = destination
     };
     CopyOrMoveRowResult result = smartsheet.SheetResources.RowResources.CopyRowsToAnotherSheet(sheetId, directive, new CopyRowInclusion[] { CopyRowInclusion.CHILDREN }, false);
 }
        /// <summary>
        /// <para>Moves Row(s) from the Sheet specified in the URL to (the bottom of) another sheet.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: POST /sheets/{sheetId}/rows/copy</para>
        /// <remarks><para>Up to 5,000 row IDs can be specified in the request,
        /// but if the total number of rows in the destination sheet after the copy exceeds the Smartsheet row limit,
        /// an error response will be returned.</para>
        /// <para>Any child rows of the rows specified in the request will also be moved.
        /// Parent-child relationships amongst rows will be preserved within the destination sheet.</para></remarks>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="ignoreRowsNotFound"> ignoreRowsNotFound </param>
        /// <param name="directive"> directive </param>
        /// <param name="include">the elements to include.</param>
        /// <returns> CopyOrMoveRowResult object </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception>
        /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception>
        /// <exception cref="AuthorizationException"> if there is any problem with  the REST API authorization (access token) </exception>
        /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception>
        /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due to rate limiting) </exception>
        /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception>
        public virtual CopyOrMoveRowResult MoveRowsToAnotherSheet(long sheetId, CopyOrMoveRowDirective directive, IEnumerable <MoveRowInclusion> include, bool?ignoreRowsNotFound)
        {
            Utility.Utility.ThrowIfNull(directive);
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (ignoreRowsNotFound.HasValue)
            {
                parameters.Add("ignoreRowsNotFound", ignoreRowsNotFound.ToString().ToLower());
            }
            return(this.CreateResource <CopyOrMoveRowResult, CopyOrMoveRowDirective>(QueryUtil.GenerateUrl("sheets/" + sheetId + "/rows/move", parameters), directive));
        }
Exemplo n.º 3
0
        public virtual void TestMoveRowsToAnotherSheet()
        {
            server.setResponseBody("../../../TestSDK/resources/copyOrMoveRowResult.json");

            CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective()
            {
                RowIds = new List <long> {
                    147258369, 963852741
                }, To = new CopyOrMoveRowDestination()
                {
                    SheetId = 123
                }
            };
            CopyOrMoveRowResult row = sheetRowResource.MoveRowsToAnotherSheet(123, directive, null, true);

            Assert.NotNull(row);
            Assert.AreEqual(row.RowMappings[1].To, 2256565987239812);
        }
Exemplo n.º 4
0
        public async Task <CopyOrMoveRowResult> CopyRowsToSheet(long?sourceSheetId, long?destinationSheetId, IList <long?> rowIds)
        {
            if (sourceSheetId == null || destinationSheetId == null)
            {
                throw new Exception("Source or Destination Sheet ID cannot be null");
            }

            var copyOrMoveRowDirective = new CopyOrMoveRowDirective()
            {
                To = new CopyOrMoveRowDestination()
                {
                    SheetId = destinationSheetId
                },
                RowIds = rowIds
            };

            var response = await this.ExecuteRequest <CopyOrMoveRowResult, CopyOrMoveRowDirective>(HttpVerb.POST, string.Format("sheets/{0}/rows/copy?include=all", sourceSheetId), copyOrMoveRowDirective);

            return(response);
        }