/// <summary> /// Adds subtasks to the Smartsheet project /// </summary> /// <param name="smartsheetClient"></param> /// <param name="columnMap"></param> /// <param name="sheet"></param> /// <param name="taskRow"></param> /// <param name="pmTemplateTaskSSExtRow"></param> /// <param name="subTaskRow"></param> /// <param name="columnID"></param> /// <param name="dependencyStartDateOffset"></param> /// <param name="dependencySibling"></param> /// <returns></returns> public long AddSubTasks(SmartsheetClient smartsheetClient, ProjectEntry projectEntryGraph, Dictionary <string, long> columnMap, Sheet sheet, PMTask taskRow, PMTaskSSExt pmTemplateTaskSSExtRow, PMSubTask subTaskRow, long?columnID, int dependencyStartDateOffset, long dependencySibling, PXResultset <PMSSMapping> templateMappingSSRow) { List <Cell> newCells = new List <Cell>(); Cell currentCell; ProjectEntry copyProjectEntryGraph = projectEntryGraph; ProjectEntryExt graphExtended = copyProjectEntryGraph.GetExtension <ProjectEntryExt>(); if (taskRow != null) { taskRow.TaskCD = subTaskRow.SubTaskCD; taskRow.Description = subTaskRow.Description; if (pmTemplateTaskSSExtRow != null) { if (pmTemplateTaskSSExtRow.UsrEnableSubtaskDependency == true) { taskRow.StartDate = taskRow.EndDate; } } foreach (PMSSMapping row in templateMappingSSRow) { if (!String.IsNullOrEmpty(row.NameAcu)) { if (copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu) is DateTime) { currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], (DateTime)copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } else { if (row.NameAcu == SmartsheetConstants.ColumnMapping.PCT_COMPLETE) { decimal completePercent = Convert.ToDecimal(copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)) / 100; currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], completePercent).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGER_GRAY_BACKGROUND_PERCENTAGE; } else { currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu).ToString()).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } } newCells.Add(currentCell); } } } Row currentRow = new Row.AddRowBuilder(null, true, null, null, null).SetCells(newCells).Build(); currentRow.ParentId = (long)columnID; currentRow.Format = SmartsheetConstants.CellFormat.GRAY_BACKGROUND; List <Row> newSSRows = new List <Row>(); newSSRows.Add(currentRow); IList <Row> ssRows = smartsheetClient.SheetResources.RowResources.AddRows((long)sheet.Id, newSSRows); return((long)ssRows[0].Id); }
/// <summary> /// Inserts Acumatica Tasks in Smartsheet /// </summary> /// <param name="projectEntryGraph"></param> /// <param name="originalColumnMap"></param> /// <param name="modifiedColumnMap"></param> /// <param name="firstSync"></param> /// <returns></returns> public List <Row> InsertAcumaticaTasksInSS(ProjectEntry projectEntryGraph, Dictionary <string, long> originalColumnMap, Dictionary <string, long> modifiedColumnMap, bool firstSync, PXResultset <PMSSMapping> templateMappingSet) { List <Row> newSSRows = new List <Row>(); Row blankRow = new Row(); if (firstSync) { blankRow = new Row.AddRowBuilder(null, true, null, null, null).Build(); newSSRows.Add(blankRow); } foreach (PMTask taskRow in projectEntryGraph.Tasks.Select()) { PMTaskSSExt pmTaskSSExtRow = PXCache <PMTask> .GetExtension <PMTaskSSExt>(taskRow); if (pmTaskSSExtRow != null && pmTaskSSExtRow.UsrSmartsheetTaskID != null) { continue; } List <Cell> newCells = new List <Cell>(); Cell currentCell = new Cell(); foreach (PMSSMapping row in templateMappingSet) { if (!String.IsNullOrEmpty(row.NameAcu)) { if (!String.IsNullOrEmpty(row.NameSS)) { if (row.NameAcu == SmartsheetConstants.ColumnMapping.DURATION) { currentCell = new Cell.AddCellBuilder(originalColumnMap[row.NameSS], projectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu).ToString()).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } else { if (row.NameAcu == SmartsheetConstants.ColumnMapping.PCT_COMPLETE) { decimal completePercent = Convert.ToDecimal(projectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)) / 100; currentCell = new Cell.AddCellBuilder(originalColumnMap[row.NameSS], completePercent).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGER_GRAY_BACKGROUND_PERCENTAGE; } else { if (row.NameAcu == SmartsheetConstants.ColumnMapping.TASKS_CD) { taskRow.TaskCD = taskRow.TaskCD.Trim(); } currentCell = new Cell.AddCellBuilder(originalColumnMap[row.NameSS], projectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } } newCells.Add(currentCell); } } } Row currentRow = new Row.AddRowBuilder(null, true, null, null, null).SetCells(newCells).Build(); currentRow.Format = SmartsheetConstants.CellFormat.GRAY_BACKGROUND; newSSRows.Add(currentRow); blankRow = new Row.AddRowBuilder(null, true, null, null, null).Build(); newSSRows.Add(blankRow); } return(newSSRows); }