private static long ListColumns(SmartsheetClient smartsheet, long sheetId)
 {
     PaginatedResult<Column> columnsResult = smartsheet.SheetResources.ColumnResources.ListColumns(sheetId, new ColumnInclusion[] { ColumnInclusion.FILTERS }, null);
     Assert.IsTrue(columnsResult.TotalCount == 4);
     Assert.IsTrue(columnsResult.Data.Count == 4);
     return columnsResult.Data[3].Id.Value;
 }
 private static void AddCommentWithoutAttachment(SmartsheetClient smartsheet, long sheetId, long discussionId)
 {
     Comment addedComment = smartsheet.SheetResources.DiscussionResources.CommentResources
     .AddComment(sheetId, discussionId, new Comment.AddCommentBuilder("commented").Build());
     //Assert.IsTrue(addedComment.DiscussionId == discussionId);
     Assert.IsTrue(addedComment.Text == "commented");
 }
 private static void AddGroupMember(SmartsheetClient smartsheet, long groupId)
 {
     GroupMember member = new GroupMember.AddGroupMemberBuilder("*****@*****.**").Build();
     IList<GroupMember> members = smartsheet.GroupResources.AddGroupMembers(groupId, new GroupMember[] { member });
     Assert.IsTrue(members.Count == 1);
     Assert.IsTrue(members[0].Email == "*****@*****.**");
 }
 private static long CreateReport(SmartsheetClient smartsheet)
 {
     PaginatedResult<Report> reportResult = smartsheet.ReportResources.ListReports(null);
     Assert.IsTrue(reportResult.Data.Count > 0);
     long reportId = reportResult.Data[0].Id.Value;
     return reportId;
 }
 private static void GetSheetAsPDF(SmartsheetClient smartsheet, long sheetId)
 {
     BinaryWriter writer = new BinaryWriter(new MemoryStream());
     smartsheet.SheetResources.GetSheetAsPDF(sheetId, writer, PaperSize.A3);
     //smartsheet.SheetResources.GetSheetAsExcel(sheetId, writer);
     //smartsheet.SheetResources.GetSheetAsCSV(sheetId, writer);
 }
 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);
 }
        private static void UpdateGroup(SmartsheetClient smartsheet, long groupId)
        {
            Group group = smartsheet.GroupResources.UpdateGroup(new Group.UpdateGroupBuilder(groupId).SetDescription("updated desc").Build());

            Assert.IsTrue(group.Name == "a group");
            Assert.IsTrue(group.Description == "updated desc");
        }
        private static void UpdateWorkspace(SmartsheetClient smartsheet, long workspaceId)
        {
            Workspace workspace = new Workspace.UpdateWorkspaceBuilder(workspaceId, "updated workspace").Build();

            Workspace updatedWorkspace = smartsheet.WorkspaceResources.UpdateWorkspace(workspace);

            Assert.IsTrue(updatedWorkspace.Name == "updated workspace");
        }
        private static long CreateWorkspace(SmartsheetClient smartsheet)
        {
            Workspace workspace = new Workspace.CreateWorkspaceBuilder("workspace").Build();

            Workspace createdWorkspace = smartsheet.WorkspaceResources.CreateWorkspace(workspace);
            Assert.IsTrue(createdWorkspace.Name == "workspace");
            return createdWorkspace.Id.Value;
        }
示例#10
0
        private static long CreateGroup(SmartsheetClient smartsheet)
        {
            GroupMember member = new GroupMember.AddGroupMemberBuilder("*****@*****.**").Build();
            Group       group  = smartsheet.GroupResources.CreateGroup(
                new Group.CreateGroupBuilder("a group", "this is a group").SetMembers(new GroupMember[] { member }).Build());

            Assert.IsTrue(group.Name == "a group");
            return(group.Id.Value);
        }
示例#11
0
        private static long CreateReport(SmartsheetClient smartsheet)
        {
            PaginatedResult <Report> reportResult = smartsheet.ReportResources.ListReports(null);

            Assert.IsTrue(reportResult.Data.Count > 0);
            long reportId = reportResult.Data[0].Id.Value;

            return(reportId);
        }
        private static long CreateGroup(SmartsheetClient smartsheet)
        {
            GroupMember member = new GroupMember.AddGroupMemberBuilder("*****@*****.**").Build();

            Group group = smartsheet.GroupResources.CreateGroup(new Group.CreateGroupBuilder("a group", "this is a group").SetMembers(new GroupMember[] { member }).Build());

            Assert.IsTrue(group.Name == "a group");
            return group.Id.Value;
        }
        private static void AddValuesToSheet(SmartsheetClient smartsheet, long sheetId, string query)
        {
            Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
            long columnId = sheet.Columns[0].Id.Value;
            Cell cell = new Cell.AddCellBuilder(columnId, query).SetStrict(false).Build();
            Row[] rows = new Row[] { new Row.AddRowBuilder(true, null, null, null, false).SetCells(new Cell[] { cell }).Build() };

            smartsheet.SheetResources.RowResources.AddRows(sheetId, rows);
        }
 private static void SearchEverywhere(SmartsheetClient smartsheet, string query, long sheetId)
 {
     SearchResult result = smartsheet.SearchResources.Search(query);
     Assert.IsTrue(result.Results.Count == 1);
     Assert.IsTrue(result.Results[0].ParentObjectId == sheetId);
     Assert.IsTrue(result.Results[0].ParentObjectType == ObjectType.SHEET);
     Assert.IsTrue(result.Results[0].ObjectType == SearchObjectType.ROW);
     Assert.IsTrue(result.Results[0].Text == query);
 }
示例#15
0
        private static void SearchEverywhere(SmartsheetClient smartsheet, string query, long sheetId)
        {
            SearchResult result = smartsheet.SearchResources.Search(query);

            Assert.IsTrue(result.Results.Count == 1);
            Assert.IsTrue(result.Results[0].ParentObjectId == sheetId);
            Assert.IsTrue(result.Results[0].ParentObjectType == ObjectType.SHEET);
            Assert.IsTrue(result.Results[0].ObjectType == SearchObjectType.ROW);
            Assert.IsTrue(result.Results[0].Text == query);
        }
        private static void AddValuesToSheet(SmartsheetClient smartsheet, long sheetId, string query)
        {
            Sheet sheet    = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
            long  columnId = sheet.Columns[0].Id.Value;
            Cell  cell     = new Cell.AddCellBuilder(columnId, query).SetStrict(false).Build();

            Row[] rows = new Row[] { new Row.AddRowBuilder(true, null, null, null, false).SetCells(new Cell[] { cell }).Build() };

            smartsheet.SheetResources.RowResources.AddRows(sheetId, rows);
        }
示例#17
0
        private static void SendSheet(SmartsheetClient smartsheet, long sheetId)
        {
            SheetEmail sheetEmail = new SheetEmail {
                SendTo = new Recipient[] { new Recipient {
                                               Email = "*****@*****.**"
                                           } }, Subject = "Subject", Format = SheetEmailFormat.PDF
            };

            smartsheet.SheetResources.SendSheet(sheetId, sheetEmail);
        }
示例#18
0
        public void CopySight()
        {
            SmartsheetClient     ss   = HelperFunctions.SetupClient("Copy Sight");
            ContainerDestination dest = new ContainerDestination();

            dest.DestinationType = DestinationType.FOLDER;
            dest.DestinationId   = 424;
            dest.NewName         = "new sight";
            Sight sight = ss.SightResources.CopySight(52, dest);
        }
示例#19
0
        //private static string ShareReport(SmartsheetClient smartsheet, long reportId, Share share)
        //{
        //	IList<Share> shares = smartsheet.ReportResources.ShareResources.ShareTo(reportId, new Share[] { share }, true);
        //	return shares[0].Id;
        //}

        private static void UpdateObjectShares(SmartsheetClient smartsheet, long sheetId, long workspaceId, string sheetShareId, string workspaceShareId)
        {
            Share updatedShare = smartsheet.SheetResources.ShareResources.UpdateShare(sheetId, new Share.UpdateShareBuilder(sheetShareId, AccessLevel.VIEWER).Build());

            Assert.IsTrue(updatedShare.AccessLevel == AccessLevel.VIEWER);
            //updatedShare = smartsheet.ReportResources.ShareResources.UpdateShare(reportId, reportShareId, new Share.UpdateShareBuilder(AccessLevel.VIEWER).Build());
            //Assert.IsTrue(updatedShare.AccessLevel == AccessLevel.VIEWER);
            updatedShare = smartsheet.WorkspaceResources.ShareResources.UpdateShare(workspaceId, new Share.UpdateShareBuilder(workspaceShareId, AccessLevel.VIEWER).Build());
            Assert.IsTrue(updatedShare.AccessLevel == AccessLevel.VIEWER);
        }
        private static void GetFolderInHome(SmartsheetClient smartsheet, long createdFolderInHomeId, long createdFolderInFolderId)
        {
            Folder getFolder = smartsheet.FolderResources.GetFolder(createdFolderInHomeId, null);

            Assert.IsTrue(getFolder.Id == createdFolderInHomeId);
            Assert.IsTrue(getFolder.Name == folderInHomeName);
            Assert.IsTrue(getFolder.Folders.Count == 1);
            Assert.IsTrue(getFolder.Folders[0].Id == createdFolderInFolderId);
            Assert.IsTrue(getFolder.Folders[0].Name == updatedFolderInFolderName);
        }
        public void ListSheets_IncludeOwnerInfo()
        {
            SmartsheetClient ss = HelperFunctions.SetupClient("List Sheets - Include Owner Info");

            PaginatedResult <Sheet> sheets = ss.SheetResources.ListSheets(new List <SheetInclusion> {
                SheetInclusion.OWNER_INFO
            }, null);

            Assert.IsNotNull(sheets.Data.Where(s => s.Owner.Equals("*****@*****.**")).FirstOrDefault());
        }
        private static long CreateDiscussion(SmartsheetClient smartsheet, long sheetId)
        {
            Comment commentToAdd = new Comment.AddCommentBuilder("this is a comment").Build();
            Discussion discussion = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build());

            Discussion discussion2 = smartsheet.SheetResources.DiscussionResources.CreateDiscussionWithAttachment(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build(), path, null);
            Assert.IsTrue(discussion2.Comments[0].Attachments[0].Name == "TestFile.txt");

            long discussionId = discussion.Id.Value;
            return discussionId;
        }
        /// <summary>
        /// Inserts in the Smartsheet project Subtasks defined in the Project Template Task from Acumatica
        /// </summary>
        /// <param name="projectEntryGraph"></param>
        /// <param name="smartsheetClient"></param>
        /// <param name="sheet"></param>
        /// <param name="ssRowSet"></param>
        /// <param name="smartSheetHelperObject"></param>
        /// <param name="columnMap"></param>
        /// <param name="ssTaskIDPosition"></param>
        public void InsertAcumaticaSubTasks(ProjectEntry projectEntryGraph,
                                            SmartsheetClient smartsheetClient,
                                            Sheet sheet,
                                            IList <Row> ssRowSet,
                                            SmartsheetHelper smartSheetHelperObject,
                                            Dictionary <string, long> columnMap,
                                            int ssTaskIDPosition)
        {
            if (projectEntryGraph.Project.Current != null &&
                projectEntryGraph.Project.Current.TemplateID != null)
            {
                PXResultset <PMTask> templateTasksSet = PXSelect <PMTask,
                                                                  Where <PMTask.projectID, Equal <Required <PMTask.projectID> > > >
                                                        .Select(projectEntryGraph, projectEntryGraph.Project.Current.TemplateID);

                foreach (PMTask templateTask in templateTasksSet)
                {
                    PMTask actualTask = PXSelect <PMTask,
                                                  Where <PMTask.projectID, Equal <Required <PMTask.projectID> >,
                                                         And <PMTask.taskCD, Equal <Required <PMTask.taskCD> > > > >
                                        .Select(projectEntryGraph, projectEntryGraph.Project.Current.ContractID, templateTask.TaskCD.Trim());

                    if (actualTask == null)
                    {
                        continue;
                    }

                    PMTaskSSExt pmTemplateTaskSSExtRow = PXCache <PMTask> .GetExtension <PMTaskSSExt>(templateTask);

                    PXResultset <PMSubTask> templateSubTasksSet = PXSelect <PMSubTask,
                                                                            Where <PMSubTask.projectID, Equal <Required <PMSubTask.projectID> >,
                                                                                   And <PMSubTask.taskID, Equal <Required <PMSubTask.taskID> > > >,
                                                                            OrderBy <Asc <PMSubTask.position> > >
                                                                  .Select(projectEntryGraph, templateTask.ProjectID, templateTask.TaskID);

                    int  dependencyStartDateOffset = 0;
                    long dependencySibling         = 0;
                    foreach (Row ssRow in ssRowSet)
                    {
                        if (ssRow.Cells[ssTaskIDPosition].Value != null &&
                            string.Equals(ssRow.Cells[ssTaskIDPosition].Value.ToString().Trim(), templateTask.TaskCD.Trim(), StringComparison.OrdinalIgnoreCase))
                        {
                            foreach (PMSubTask subTaskRow in templateSubTasksSet)
                            {
                                dependencySibling          = smartSheetHelperObject.AddSubTasks(smartsheetClient, columnMap, sheet, actualTask, pmTemplateTaskSSExtRow, subTaskRow, ssRow.Id, dependencyStartDateOffset, dependencySibling);
                                dependencyStartDateOffset += (int)subTaskRow.Duration;
                            }
                        }
                    }
                }
            }

            return;
        }
示例#24
0
        // Constructor gets passed the parent form
        // because I had a problem with the LoginForm process
        // not being closed.
        public ClientForm(SmartsheetClient client, LoginForm parent)
        {
            // Assign private fields
            _client = client;
            _parent = parent;

            // To do : Add a fancy error catch to make sure the Access Token was valid
            _user = _client.UserResources.GetCurrentUser();

            InitializeComponent();
        }
 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);
 }
		private static long CreateSheet(SmartsheetClient smartsheet)
		{
			Column[] columnsToCreate = new Column[] {
			new Column.CreateSheetColumnBuilder("col 1", true, ColumnType.TEXT_NUMBER).Build(),
			new Column.CreateSheetColumnBuilder("col 2", false, ColumnType.DATE).Build(),
			new Column.CreateSheetColumnBuilder("col 3", false, ColumnType.TEXT_NUMBER).Build(),
			};
			Sheet createdSheet = smartsheet.SheetResources.CreateSheet(new Sheet.CreateSheetBuilder("new sheet", columnsToCreate).Build());
			Assert.IsTrue(createdSheet.Columns.Count == 3);
			Assert.IsTrue(createdSheet.Columns[1].Title == "col 2");
			return createdSheet.Id.Value;
		}
        private static void RemoveAndListFavorites(SmartsheetClient smartsheet, long sheetId, long folderId, long workspaceId)
        {
            smartsheet.FavoriteResources.RemoveFavorites(ObjectType.SHEET, new long[] { sheetId });
            smartsheet.FavoriteResources.RemoveFavorites(ObjectType.FOLDER, new long[] { folderId });
            //smartsheet.FavoriteResources.RemoveFavorites(ObjectType.REPORT, new long[] { reportId });
            //smartsheet.FavoriteResources().RemoveFavorites(ObjectType.TEMPLATE, new long[] { templateId });
            smartsheet.FavoriteResources.RemoveFavorites(ObjectType.WORKSPACE, new long[] { workspaceId });

            PaginatedResult <Favorite> favsResult = smartsheet.FavoriteResources.ListFavorites(new PaginationParameters(true, null, null));

            Assert.IsTrue(favsResult.Data.Count == 0);
        }
 private static long CreateSheet(SmartsheetClient smartsheet)
 {
     Column[] columnsToCreate = new Column[] {
     new Column.CreateSheetColumnBuilder("col 1", true, ColumnType.TEXT_NUMBER).Build(),
     new Column.CreateSheetColumnBuilder("col 2", false, ColumnType.DATE).Build(),
     new Column.CreateSheetColumnBuilder("col 3", false, ColumnType.TEXT_NUMBER).Build(),
     };
     Sheet createdSheet = smartsheet.SheetResources.CreateSheet(new Sheet.CreateSheetBuilder("new sheet", columnsToCreate).Build());
     Assert.IsTrue(createdSheet.Columns.Count == 3);
     Assert.IsTrue(createdSheet.Columns[1].Title == "col 2");
     return createdSheet.Id.Value;
 }
        private static void SortSheet(SmartsheetClient smartsheet, long sheetId)
        {
            Sheet         sheet     = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
            SortSpecifier specifier = new SortSpecifier();
            SortCriterion criterion = new SortCriterion();

            criterion.ColumnId     = (long)sheet.Columns[0].Id;
            criterion.Direction    = SortDirection.DESCENDING;
            specifier.SortCriteria = new SortCriterion[] { criterion };
            sheet = smartsheet.SheetResources.SortSheet(sheetId, specifier);
            Assert.AreEqual(sheet.Rows[0].Cells[0].DisplayValue, "C");
        }
示例#30
0
        public virtual void TestBuild()
        {
            SmartsheetClient smartsheet = (new SmartsheetBuilder()).Build();

            Assert.True(smartsheet is SmartsheetImpl);

            SmartsheetClient ss = (SmartsheetImpl)(new SmartsheetBuilder()).SetBaseURI("http://google.com/").SetAccessToken("b").
                                  SetHttpClient(new DefaultHttpClient()).SetJsonSerializer(new JsonNetSerializer()).
                                  SetAssumedUser("user").Build();

            ss.GetType();
        }
示例#31
0
 private static void DeleteGroup(SmartsheetClient smartsheet, long groupId)
 {
     smartsheet.GroupResources.DeleteGroup(groupId);
     try
     {
         smartsheet.GroupResources.GetGroup(groupId);
         Assert.Fail("Cannot get a deleted group");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteRowAndGetRow(SmartsheetClient smartsheet, long sheetId, long rowId)
 {
     smartsheet.SheetResources.RowResources.DeleteRows(sheetId, new long[] { rowId }, false);
     try
     {
         smartsheet.SheetResources.RowResources.GetRow(sheetId, rowId, new RowInclusion[] { RowInclusion.COLUMNS }, null);
         Assert.Fail("Cannot get a deleted row.");
     }
     catch
     {
         //Not found.
     }
 }
示例#33
0
 private static void DeleteAttachment(SmartsheetClient smartsheet, long sheetId, long attachmentId)
 {
     smartsheet.SheetResources.AttachmentResources.DeleteAttachment(sheetId, attachmentId);
     try
     {
         smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachmentId);
         Assert.Fail("Cannot get deleted attachment.");
     }
     catch
     {
         //Not Found.
     }
 }
示例#34
0
 private static void DeleteSheet(SmartsheetClient smartsheet, long sheetId)
 {
     smartsheet.SheetResources.DeleteSheet(sheetId);
     try
     {
         smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
         Assert.Fail("Exception should have been thrown because Sheet should have been deleted.");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteFolders(SmartsheetClient smartsheet, long folder1)
 {
     smartsheet.FolderResources.DeleteFolder(folder1);
     try
     {
         smartsheet.FolderResources.GetFolder(folder1, null);
         Assert.Fail("Exception should have been thrown. Cannot get a deleted folder.");
     }
     catch
     {
         // Should be "Not Found".
     }
 }
 private static void DeleteAndGetColumn(SmartsheetClient smartsheet, long sheetId, long columnId)
 {
     smartsheet.SheetResources.ColumnResources.DeleteColumn(sheetId, columnId);
     try
     {
         smartsheet.SheetResources.ColumnResources.GetColumn(sheetId, columnId, null);
         Assert.Fail("Cannot get a column that is deleted.");
     }
     catch
     {
         //Not found.
     }
 }
示例#37
0
        private long AddCommentWithAttachment(SmartsheetClient smartsheet, long sheetId, long discussionId)
        {
            Comment addedCommentWithAttachment = smartsheet.SheetResources.DiscussionResources.CommentResources
                                                 .AddCommentWithAttachment(sheetId, discussionId, new Comment.AddCommentBuilder("commented2").Build(), path, null);

            //Assert.IsTrue(addedCommentWithAttachment.DiscussionId == discussionId);
            Assert.IsTrue(addedCommentWithAttachment.Text == "commented2");
            Assert.IsTrue(addedCommentWithAttachment.Attachments.Count == 1);
            Assert.IsTrue(addedCommentWithAttachment.Attachments[0].Name == "TestFile.txt");
            long commentId = addedCommentWithAttachment.Id.Value;

            return(commentId);
        }
示例#38
0
 private static void DeleteComment(SmartsheetClient smartsheet, long sheetId, long commentId)
 {
     smartsheet.SheetResources.CommentResources.DeleteComment(sheetId, commentId);
     try
     {
         smartsheet.SheetResources.CommentResources.GetComment(sheetId, commentId);
         Assert.Fail("Cannot get deleted comment");
     }
     catch
     {
         //Not found.
     }
 }
示例#39
0
        private static long CreateDiscussion(SmartsheetClient smartsheet, long sheetId)
        {
            Comment    commentToAdd = new Comment.AddCommentBuilder("this is a comment").Build();
            Discussion discussion   = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build());

            Discussion discussion2 = smartsheet.SheetResources.DiscussionResources.CreateDiscussionWithAttachment(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build(), path, null);

            Assert.IsTrue(discussion2.Comments[0].Attachments[0].Name == "TestFile.txt");

            long discussionId = discussion.Id.Value;

            return(discussionId);
        }
 private static void DeleteComment(SmartsheetClient smartsheet, long sheetId, long commentId)
 {
     smartsheet.SheetResources.CommentResources.DeleteComment(sheetId, commentId);
     try
     {
         smartsheet.SheetResources.CommentResources.GetComment(sheetId, commentId);
         Assert.Fail("Cannot get deleted comment");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteAttachment(SmartsheetClient smartsheet, long sheetId, long attachmentId)
 {
     smartsheet.SheetResources.AttachmentResources.DeleteAttachment(sheetId, attachmentId);
     try
     {
         smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachmentId);
         Assert.Fail("Cannot get deleted attachment.");
     }
     catch
     {
         //Not Found.
     }
 }
 private static void DeleteRowAndGetRow(SmartsheetClient smartsheet, long sheetId, long rowId)
 {
     smartsheet.SheetResources.RowResources.DeleteRows(sheetId, new long[] { rowId }, false);
     try
     {
         smartsheet.SheetResources.RowResources.GetRow(sheetId, rowId, new RowInclusion[] { RowInclusion.COLUMNS }, null);
         Assert.Fail("Cannot get a deleted row.");
     }
     catch
     {
         //Not found.
     }
 }
示例#43
0
 private static void DeleteWorkspace(SmartsheetClient smartsheet, long workspaceId)
 {
     smartsheet.WorkspaceResources.DeleteWorkspace(workspaceId);
     try
     {
         smartsheet.WorkspaceResources.GetWorkspace(workspaceId, null, null);
         Assert.Fail("Cannot get a workspace that was deleted.");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteAndGetColumn(SmartsheetClient smartsheet, long sheetId, long columnId)
 {
     smartsheet.SheetResources.ColumnResources.DeleteColumn(sheetId, columnId);
     try
     {
         smartsheet.SheetResources.ColumnResources.GetColumn(sheetId, columnId, null);
         Assert.Fail("Cannot get a column that is deleted.");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteSheet(SmartsheetClient smartsheet, long sheetId)
 {
     smartsheet.SheetResources.DeleteSheet(sheetId);
     try
     {
         smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
         Assert.Fail("Exception should have been thrown because Sheet should have been deleted.");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteWorkspace(SmartsheetClient smartsheet, long workspaceId)
 {
     smartsheet.WorkspaceResources.DeleteWorkspace(workspaceId);
     try
     {
         smartsheet.WorkspaceResources.GetWorkspace(workspaceId, null, null);
         Assert.Fail("Cannot get a workspace that was deleted.");
     }
     catch
     {
         //Not found.
     }
 }
 private static void DeleteGroup(SmartsheetClient smartsheet, long groupId)
 {
     smartsheet.GroupResources.DeleteGroup(groupId);
     try
     {
         smartsheet.GroupResources.GetGroup(groupId);
         Assert.Fail("Cannot get a deleted group");
     }
     catch
     {
         //Not found.
     }
 }
示例#48
0
 private static void DeleteFolders(SmartsheetClient smartsheet, long folder1)
 {
     smartsheet.FolderResources.DeleteFolder(folder1);
     try
     {
         smartsheet.FolderResources.GetFolder(folder1, null);
         Assert.Fail("Exception should have been thrown. Cannot get a deleted folder.");
     }
     catch
     {
         // Should be "Not Found".
     }
 }
示例#49
0
        private long AttachFileAndUrlToSheet(SmartsheetClient smartsheet, long sheetId)
        {
            Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.smartsheet.com", AttachmentType.LINK).Build();
            Attachment attachment       = smartsheet.SheetResources.AttachmentResources.AttachUrl(sheetId, attachToResource);

            Assert.IsTrue(attachment.Url == "http://www.smartsheet.com");

            attachment = smartsheet.SheetResources.AttachmentResources.AttachFile(sheetId, path, null);
            Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE);
            Assert.IsTrue(attachment.Name == "TestFile.txt");


            return(attachment.Id.Value);
        }
        private static IList<long> AddRows(SmartsheetClient smartsheet, long sheetId, long columnId, Cell[] cellsToAdd)
        {
            Row row1 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();
            Row row2 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();
            Row row3 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();

            IList<Row> rows = smartsheet.SheetResources.RowResources.AddRows(sheetId, new Row[] { row1, row2, row3 });
            IList<long> rowIds = new List<long>();
            foreach (Row row in rows)
            {
                rowIds.Add(row.Id.Value);
            }
            return rowIds;
        }
        public void CreateSheet_NoColumns()
        {
            SmartsheetClient ss = HelperFunctions.SetupClient("Create Sheet - Invalid - No Columns");

            Sheet sheetA = new Sheet
            {
                Name    = "New Sheet",
                Columns = new List <Column>()
            };

            HelperFunctions.AssertRaisesException <SmartsheetException>(() =>
                                                                        ss.SheetResources.CreateSheet(sheetA),
                                                                        "The new sheet requires either a fromId or columns.");
        }
 public SmartsheetSyncProcess()
 {
     Projects.SetProcessCaption("Sync");
     Projects.SetProcessAllCaption("Sync All");
     Projects.SetProcessDelegate <ProjectEntry>(
         delegate(ProjectEntry graph, PMProject projectRow)
     {
         graph.Clear();
         ProjectEntryExt projectEntryExtGraph = graph.GetExtension <ProjectEntryExt>();
         SmartsheetClient smartsheetClient    = projectEntryExtGraph.CheckTokenSheetSS(graph, projectRow, "", true);
         projectEntryExtGraph.CreateEmployeesAcuUserSS(graph, smartsheetClient);
         projectEntryExtGraph.CreateUpdateGanttProject(graph, projectRow, smartsheetClient, true);
     });
 }
示例#53
0
        private static IList <long> AddRows(SmartsheetClient smartsheet, long sheetId, long columnId, Cell[] cellsToAdd)
        {
            Row row1 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();
            Row row2 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();
            Row row3 = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();

            IList <Row>  rows   = smartsheet.SheetResources.RowResources.AddRows(sheetId, new Row[] { row1, row2, row3 });
            IList <long> rowIds = new List <long>();

            foreach (Row row in rows)
            {
                rowIds.Add(row.Id.Value);
            }
            return(rowIds);
        }
 private static void ListWorkspaces(SmartsheetClient smartsheet, long workspaceId)
 {
     PaginatedResult<Workspace> workspaceResult = smartsheet.WorkspaceResources.ListWorkspaces(null);
     Assert.IsTrue(workspaceResult.Data.Count > 0);
     bool contains = false;
     foreach (Workspace ws in workspaceResult.Data)
     {
         if (ws.Id.Value == workspaceId)
         {
             contains = true;
             break;
         }
     }
     Assert.IsTrue(contains);
 }
 private static long AddRows(SmartsheetClient smartsheet, long sheetId, long columnId, Cell[] cellsToAdd)
 {
     Row row = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsToAdd).Build();
     IList<Row> rows = smartsheet.SheetResources.RowResources.AddRows(sheetId, new Row[] { row });
     Assert.IsTrue(rows.Count == 1);
     long rowId = rows[0].Id.Value;
     bool foundValue = false;
     foreach (Cell cell in rows[0].Cells)
     {
         if (cell.ColumnId == columnId)
         {
             Assert.IsTrue(cell.Value.ToString() == "hello");
             foundValue = true;
             break;
         }
     }
     Assert.IsTrue(foundValue);
     return rowId;
 }
        private static void AddFavorites(SmartsheetClient smartsheet, out long sheetId, out long folderId, out long workspaceId)
        {
            sheetId = CreateSheet(smartsheet);
            folderId = CreateFolder(smartsheet);
            //reportId = CreateReport(smartsheet);
            //templateId = CreateTemplate(smartsheet);
            workspaceId = CreateWorkspace(smartsheet);

            Favorite[] favs = new Favorite[] {
            new Favorite.AddFavoriteBuilder(ObjectType.SHEET, sheetId).Build(),
            new Favorite.AddFavoriteBuilder(ObjectType.FOLDER, folderId).Build(),
            //new Favorite.AddFavoriteBuilder(ObjectType.REPORT, reportId).Build(),
            //new Favorite.AddFavoriteBuilder(ObjectType.TEMPLATE, templateId).Build(),
            new Favorite.AddFavoriteBuilder(ObjectType.WORKSPACE, workspaceId).Build()
            };

            IList<Favorite> favsAdded = smartsheet.FavoriteResources.AddFavorites(favs);
            Assert.IsTrue(favsAdded.Count == 3);
        }
 private static void DeleteRows(SmartsheetClient smartsheet, long sheetId, IList<long> rowIds)
 {
     IList<long> rowsDeleted = smartsheet.SheetResources.RowResources.DeleteRows(sheetId, rowIds, false);
     Assert.IsTrue(rowsDeleted.Contains(rowIds[0]));
     Assert.IsTrue(rowsDeleted.Contains(rowIds[1]));
     Assert.IsTrue(rowsDeleted.Contains(rowIds[2]));
 }
 private static void ListRowAttachments(SmartsheetClient smartsheet, long sheetId, long rowId)
 {
     PaginatedResult<Attachment> attachments = smartsheet.SheetResources.RowResources.AttachmentResources.ListAttachments(sheetId, rowId, null);
     Assert.IsTrue(attachments.Data.Count == 2);
 }
 private static long CreateSheetFromTemplate(SmartsheetClient smartsheet, long templateId)
 {
     // Create a new sheet off of that template.
     Sheet newSheet = smartsheet.SheetResources.CreateSheetFromTemplate(new Sheet.CreateSheetFromTemplateBuilder("New Sheet", templateId).Build(), new TemplateInclusion[] { TemplateInclusion.DATA });
     return newSheet.Id.Value;
 }
        private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId)
        {
            Discussion discussionToCreate = new Discussion.CreateDiscussionBuilder("A Disc", new Comment.AddCommentBuilder("A comm").Build()).Build();
            Discussion discussionCreated = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, discussionToCreate);
            long commentId = discussionCreated.Comments[0].Id.Value;
            Attachment attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachFile(sheetId, commentId, path, "text/plain");
            Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE);
            Assert.IsTrue(attachment.Name == "TestFile.txt");

            Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK).Build();
            attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachUrl(sheetId, commentId, attachToResource);
            Assert.IsTrue(attachment.Url == "http://www.google.com");

            return discussionCreated.Id.Value;
        }