public virtual IEnumerable SynGanttSmartsheetProject(PXAdapter adapter)
        {
            this.Base.Actions.PressSave();
            PMProject pmProjectRow = this.Base.Project.Current;

            ProjectEntry projectEntryGraph = PXGraph.CreateInstance <ProjectEntry>();

            SmartsheetClient smartsheetClient = CheckTokenSheetSS(projectEntryGraph, pmProjectRow);

            if (smartsheetClient != null)
            {
                PXLongOperation.StartOperation(this.Base,
                                               () =>
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        projectEntryGraph = this.Base;
                        ProjectEntrySmartsheetExt graphExtended = projectEntryGraph.GetExtension <ProjectEntrySmartsheetExt>();
                        CreateEmployeesAcuUserSS(projectEntryGraph, smartsheetClient);
                        graphExtended.CreateUpdateGanttProject(projectEntryGraph, pmProjectRow, smartsheetClient);
                        ts.Complete();
                    }
                });
            }

            return(adapter.Get());
        }
示例#2
0
 public SmartsheetSyncProcess()
 {
     Projects.SetProcessCaption("Sync");
     Projects.SetProcessAllCaption("Sync All");
     Projects.SetProcessDelegate <ProjectEntry>(
         delegate(ProjectEntry graph, PMProject projectRow)
     {
         graph.Clear();
         ProjectEntrySmartsheetExt projectEntryExtGraph = graph.GetExtension <ProjectEntrySmartsheetExt>();
         SmartsheetClient smartsheetClient = projectEntryExtGraph.CheckTokenSheetSS(graph, projectRow, "", true);
         projectEntryExtGraph.CreateEmployeesAcuUserSS(graph, smartsheetClient);
         projectEntryExtGraph.CreateUpdateGanttProject(graph, projectRow, smartsheetClient, true);
     });
 }
        /// <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;
            ProjectEntrySmartsheetExt graphExtended = copyProjectEntryGraph.GetExtension <ProjectEntrySmartsheetExt>();

            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);
        }