Example #1
0
        private string getResourceName(Guid resGuid, ProjectDataSet projectDataSet)
        {
            var drRes = rDs.Resources.Select($"RES_UID=\'{resGuid}\'");

            if (drRes.Length > 0)
            {
                var dataRow = drRes[0];

                if (dataRow[ResourceIsWindowsUser].ToString() == bool.TrueString)
                {
                    var username = dataRow[WresAccount].ToString();

                    try
                    {
                        return mySiteToPublish.AllUsers[username].Name;
                    }
                    catch (Exception exception)
                    {
                        Trace.WriteLine(exception);
                        return string.Empty;
                    }
                }

                return Convert.ToString(dataRow[ResourceName]);
            }

            var dataRows = projectDataSet.ProjectResource.Select($"RES_UID=\'{resGuid}\'");

            return dataRows.Length > 0
                ? dataRows[0][ResourceName].ToString()
                : string.Empty;
        }
        protected override async Task<IConstraintSolverResult> Run(ProjectDataSet dataSet, IConstraints constraints, IDictionary<Guid, TimeFrame> overrideActivityTargetDurations)
        {
            if (constraints == null)
                throw new ArgumentNullException("The constraint object cannot be null.");

            var bestSolutionResult = new ConstraintSolverResult(constraints);

            try
            {
                var dataManager = new SolverDataManager(dataSet, bestSolutionResult);

                await dataManager.InitializeDataAsync();

                var solver = new Solver(dataManager);
                await solver.ComputeSolutionAsync();

                bestSolutionResult.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                bestSolutionResult.Errors.Add(new ConstraintSolverError(null, "Error running GreedySolver solver", ex.LastExceptionMessage()));
            }

            return bestSolutionResult;
        }
 private void processTask(
     ProjectDataSet.TaskRow taskRow,
     ProjectDataSet projectDataSet,
     ArrayList fieldsToPublish,
     SPListItem listItem,
     Hashtable hshFields,
     string taskUid,
     int pubType)
 {
     try
     {
         ProcessFieldsToPublish(taskRow, projectDataSet, fieldsToPublish, listItem);
         UpdateTaskUidAndTimeSheetId(taskRow, projectDataSet, listItem, taskUid, pubType);
         listItem.Update();
     }
     catch (SPException spException)
     {
         myLog.WriteEntry(
             $"SPException: Error processing Task ({taskRow.TASK_NAME}): {spException.Message}{spException.StackTrace}",
             EventLogEntryType.Error,
             331);
     }
     catch (Exception exception)
     {
         myLog.WriteEntry(
             $"Error processing Task ({taskRow.TASK_NAME}): {exception.Message}{exception.StackTrace}",
             EventLogEntryType.Error,
             330);
     }
 }
Example #4
0
        protected override async Task <IConstraintSolverResult> Run(ProjectDataSet dataSet, IConstraints constraints, IDictionary <Guid, TimeFrame> overrideActivityTargetDurations)
        {
            if (constraints == null)
            {
                throw new ArgumentNullException("The constraint object cannot be null.");
            }

            var bestSolutionResult = new ConstraintSolverResult(constraints);

            try
            {
                var dataManager = new SolverDataManager(dataSet, bestSolutionResult);

                await dataManager.InitializeDataAsync();

                var solver = new Solver(dataManager);
                await solver.ComputeSolutionAsync();

                bestSolutionResult.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                bestSolutionResult.Errors.Add(new ConstraintSolverError(null, "Error running GreedySolver solver", ex.LastExceptionMessage()));
            }

            return(bestSolutionResult);
        }
        private void publishTasks(int projectId, int pubType, Guid newTransUid, Guid lastTransUid)
        {
            try
            {
                ProjectDataSet projectDataSet = null;
                SPSecurity.RunWithElevatedPrivileges(() => projectDataSet = pService.ReadProject(projectGuid, DataStoreEnum.PublishedStore));

                double taskDoneCount = 0;
                double taskCount     = projectDataSet.Task.Count;
                var    taskCenter    = mySiteToPublish.Lists[TaskCenter];

                taskCount = PublishTasksPubTypeOne(projectId, pubType, taskCount, projectDataSet, taskCenter, ref taskDoneCount);
                ProcessProjectDataSetTask(projectId, pubType, newTransUid, lastTransUid, projectDataSet, taskCenter, taskDoneCount, taskCount);

                foreach (DictionaryEntry dictionaryEntry in hshCurTasks)
                {
                    var itemByUniqueId = taskCenter.GetItemByUniqueId(new Guid(dictionaryEntry.Value.ToString()));
                    itemByUniqueId.Delete();
                }

                foreach (Guid guid in arrDelNewTasks)
                {
                    var listItem = taskCenter.GetItemByUniqueId(guid);
                    listItem.Delete();
                }
            }
            catch (Exception exception)
            {
                myLog.WriteEntry(
                    $"Error in publishTasks(): {exception.Message}{exception.StackTrace}{exception.InnerException}",
                    EventLogEntryType.Error,
                    315);
            }
        }
Example #6
0
        public void MakeChangesInProjectServer(Guid projectId,
                                               ProjectDataSet projectDataSetToAdd,
                                               ProjectDataSet projectDataSetToUpdate)
        {
            var taskChanges             = projectDataSetToUpdate.Task.GetChanges(DataRowState.Modified);
            var taskCustomFieldsChanges = projectDataSetToUpdate.TaskCustomFields.GetChanges(DataRowState.Modified);
            var dependencies            = projectDataSetToUpdate.Dependency.GetChanges(DataRowState.Added | DataRowState.Modified);

            if ((taskChanges != null && taskChanges.Rows.Count != 0) ||
                (taskCustomFieldsChanges != null && taskCustomFieldsChanges.Rows.Count != 0) ||
                (dependencies != null && dependencies.Rows.Count != 0))
            {
                while (!TryUpdateProject(projectId, projectDataSetToUpdate))
                {
                    _errorsContainer.Append("Retrying updating...");
                }
            }

            if (projectDataSetToAdd.Task.Any() || projectDataSetToAdd.Dependency.Any())
            {
                while (!TryAddToProject(projectId, projectDataSetToAdd))
                {
                    _errorsContainer.Append("Retrying adding...");
                }
            }
        }
        public void GetProject_ByGuid_ShouldReturnNewDataSetWithUpdatedProjectName()
        {
            var projectDataSet = _projectService.Invoke(p => p.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore));

            var result = new Dictionary <string, object>();

            _mapper.Map(
                projectDataSet.Project,
                result,
                new NopPropsMatcher(),
                new BasicProjectMappingProjNameToTestValueConverter());

            Assert.IsTrue(result["PROJ_NAME"].Equals("Test"));
            Assert.IsTrue(((Guid)result["PROJ_UID"]).Equals(Settings.DefaultProjectGuid));

            var newProjectDataSet = new ProjectDataSet();

            _mapper.Map(
                result,
                newProjectDataSet.Project,
                new NopPropsMatcher(),
                new BasicProjectMappingIfProjNameTestSetUpdatedValueConverter());

            Assert.IsTrue(newProjectDataSet.Project[0]["PROJ_NAME"].Equals("Updated"));
            Assert.IsTrue(((Guid)newProjectDataSet.Project[0]["PROJ_UID"]).Equals(Settings.DefaultProjectGuid));
        }
        public override global::System.Data.DataSet Clone()
        {
            ProjectDataSet cln = ((ProjectDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Example #9
0
 public override void Execute(Guid targetInstanceId)
 {
     MyUtilities.ErrorLog("The Process Started at " + DateTime.Now.ToString(), EventLogEntryType.SuccessAudit);
     try
     {
         foreach (SPSite Site in WebApplication.Sites)
         {
             foreach (SPFeature Feature in Site.Features)
             {
                 try
                 {
                     if (Feature.Definition.DisplayName == MyUtilities.SPFeatureName)
                     {
                         if (Feature.Definition.ActivateOnDefault)
                         {
                             SPList configurationList = MyUtilities.GetConfigurationList(Site);
                             if (configurationList != null)
                             {
                                 // define project server web service
                                 var Project_Svc = new Project
                                 {
                                     Url = Site.Url + "/_vti_bin/psi/project.asmx",
                                     UseDefaultCredentials = true,
                                     AllowAutoRedirect     = true
                                 };
                                 ProjectDataSet ProjectList = Project_Svc.ReadProjectList();
                                 foreach (ProjectDataSet.ProjectRow PRow in ProjectList.Project.Rows)
                                 {
                                     MyUtilities.CheckandAddEntry(configurationList, PRow.PROJ_UID, Project_Svc);
                                 }
                             }
                             break;
                         }
                     }
                 }
                 catch (Exception) { }
             }
         }
     }
     catch (Exception ex)
     {
         MyUtilities.ErrorLog("Error at timer job while synchronizing configuration list due to " + ex.Message, EventLogEntryType.Error);
     }
     try
     {
         var weeklySchedule = new SPWeeklySchedule()
         {
             BeginHour = 0, BeginDayOfWeek = DayOfWeek.Sunday
         };
         Schedule = weeklySchedule;
         Update();
         base.Execute(targetInstanceId);
     }
     catch (Exception ex)
     {
         MyUtilities.ErrorLog("Error at timer job while updating its schedule due to " + ex.Message, EventLogEntryType.Error);
     }
 }
        private static void ProcessTaskPredecessors(
            ProjectDataSet.TaskRow taskRow,
            ProjectDataSet projectDataSet,
            SPListItem listItem,
            string wssFieldName)
        {
            Guard.ArgumentIsNotNull(wssFieldName, nameof(wssFieldName));
            Guard.ArgumentIsNotNull(listItem, nameof(listItem));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));
            Guard.ArgumentIsNotNull(taskRow, nameof(taskRow));

            const string LinkTypeZero  = "0";
            const string LinkTypeTwo   = "2";
            const string LinkTypeThree = "3";

            var predecessorDataSetBuilder = new StringBuilder();
            var dataRows = projectDataSet.Dependency.Select($"LINK_SUCC_UID=\'{taskRow.TASK_UID}\'");

            foreach (var dataRow in dataRows)
            {
                var drTask = (ProjectDataSet.TaskRow[])projectDataSet.Task.Select($"TASK_UID=\'{dataRow["LINK_PRED_UID"]}\'");

                if (drTask.Length > 0)
                {
                    predecessorDataSetBuilder.Append($",{drTask[0].TASK_ID}");

                    var linkType = dataRow[LinkType].ToString();

                    switch (linkType)
                    {
                    case LinkTypeZero:
                        predecessorDataSetBuilder.Append("FF");
                        break;

                    case LinkTypeTwo:
                        predecessorDataSetBuilder.Append("SF");
                        break;

                    case LinkTypeThree:
                        predecessorDataSetBuilder.Append("SS");
                        break;

                    default:
                        Trace.WriteLine($"Unexpected value : {linkType}");
                        break;
                    }
                }
            }

            var predecessorDataSet = predecessorDataSetBuilder.ToString();

            if (predecessorDataSet.Length > 1)
            {
                predecessorDataSet = predecessorDataSet.Substring(1);
            }

            listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = predecessorDataSet;
        }
        private void PopulateListItem(
            int pubType,
            Guid newTransUid,
            Guid lastTransUid,
            ProjectDataSet projectDataSet,
            SPList taskCenter,
            SPListItem listItem,
            ProjectDataSet.TaskRow taskRow)
        {
            Guard.ArgumentIsNotNull(taskRow, nameof(taskRow));
            Guard.ArgumentIsNotNull(listItem, nameof(listItem));
            Guard.ArgumentIsNotNull(taskCenter, nameof(taskCenter));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));

            var canProcess = true;

            try
            {
                if (pubType == PubTypeTwo || pubType == PubTypeThree && lastTransUid != new Guid())
                {
                    if (listItem[TransUid].ToString() != lastTransUid.ToString())
                    {
                        canProcess = false;
                    }
                }
            }
            catch (Exception exception)
            {
                Trace.WriteLine(exception);
            }

            if (canProcess)
            {
                listItem[listItem.Fields.GetFieldByInternalName(TaskHierarchy).Id] = getHierarchy(projectDataSet, taskRow.TASK_PARENT_UID);
                const string AssignmentId = "0";
                listItem[listItem.Fields.GetFieldByInternalName(IsAssignment).Id] = AssignmentId;
                listItem[TransUid] = newTransUid.ToString();
                listItem[taskCenter.Fields.GetFieldByInternalName(Title).Id] = taskRow.TASK_NAME;

                if (!taskRow.IsTASK_WBSNull())
                {
                    listItem[taskCenter.Fields.GetFieldByInternalName(Wbs).Id] = taskRow.TASK_WBS;
                }

                listItem[taskCenter.Fields.GetFieldByInternalName(TaskUid).Id]   = taskRow.TASK_UID;
                listItem[taskCenter.Fields.GetFieldByInternalName(TaskOrder).Id] = taskRow.TASK_ID;
                listItem[Summary] = taskRow.TASK_IS_SUMMARY.ToString();

                if (!taskRow.IsTASK_NOTESNull())
                {
                    listItem[taskCenter.Fields.GetFieldByInternalName(Notes).Id] = taskRow.TASK_NOTES;
                }

                listItem[taskCenter.Fields.GetFieldByInternalName(LastPublished).Id] = DateTime.Now;
                processTask(taskRow, projectDataSet, arrFieldsToPublish, listItem, hshTaskCenterFields, taskRow.TASK_UID.ToString(), pubType);
            }
        }
        private void ProcessFilterCategoryOne(
            DataRow assignmentRow,
            ProjectDataSet projectDataSet,
            SPListItem listItem,
            ProjectDataSet.TaskRow taskRow,
            string fieldName,
            string wssFieldName,
            string assnFieldName,
            string fieldType,
            string multiplier)
        {
            Guard.ArgumentIsNotNull(multiplier, nameof(multiplier));
            Guard.ArgumentIsNotNull(fieldType, nameof(fieldType));
            Guard.ArgumentIsNotNull(assnFieldName, nameof(assnFieldName));
            Guard.ArgumentIsNotNull(wssFieldName, nameof(wssFieldName));
            Guard.ArgumentIsNotNull(fieldName, nameof(fieldName));
            Guard.ArgumentIsNotNull(taskRow, nameof(taskRow));
            Guard.ArgumentIsNotNull(listItem, nameof(listItem));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));
            Guard.ArgumentIsNotNull(assignmentRow, nameof(assignmentRow));

            if (fieldName == TaskPredecessors)
            {
                ProcessTaskPredecessors(taskRow, projectDataSet, listItem, wssFieldName);
            }
            else
            {
                string fieldData;

                try
                {
                    fieldData = assignmentRow[assnFieldName].ToString();
                }
                catch (Exception exception)
                {
                    Trace.WriteLine(exception);
                    fieldData = taskRow[fieldName].ToString();
                }

                if (fieldType == DateTimeText)
                {
                    if (!string.IsNullOrWhiteSpace(fieldData.Trim()))
                    {
                        listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = fieldData;
                    }
                }
                else
                {
                    if (multiplier != "1")
                    {
                        fieldData = multiplyField(fieldData, multiplier);
                    }

                    listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = fieldData;
                }
            }
        }
Example #13
0
        public static ProjectDataSet BuildProjectDataSetForCreate(DataTable table, out ProjectDataSet projectDataSet, out ProjectDataSet.ProjectRow projectRow,out bool iscreate,out bool hasPlan)
        {
            var inputProjectRow = table.Rows[0];
            Console.WriteLine("Starting import of project for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
            projectDataSet = new ProjectDataSet();

            iscreate = false;

            projectRow = projectDataSet.Project.NewProjectRow();
            Guid projectGuid = Guid.NewGuid();

            projectRow.PROJ_UID = projectGuid;
            projectRow.PROJ_NAME = inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString();
            hasPlan = false;
            Guid PlanUID = Repository.GetUIDFromEPTUID(new Guid(inputProjectRow[_mapping.ProjectMap["ENTERPRISE_PROJECT_TYPE_UID"]].ToString()));
            if (PlanUID  == Guid.Empty)
            {
                projectRow.ENTERPRISE_PROJECT_TYPE_UID = new Guid(inputProjectRow[_mapping.ProjectMap["ENTERPRISE_PROJECT_TYPE_UID"]].ToString());
            }
            else
            {
                projectRow.ENTERPRISE_PROJECT_TYPE_UID = new Guid(inputProjectRow[_mapping.ProjectMap["ENTERPRISE_PROJECT_TYPE_UID"]].ToString()); ;
                hasPlan = true;
            }
            //projectRow.ENTERPRISE_PROJECT_TYPE_NAME = inputProjectRow[_mapping.ProjectMap["ENTERPRISE_PROJECT_TYPE_NAME"]].ToString();
            // set the project start date to min of start dates for all tasks provided mapping exists for task start with key = TASK_START_DATE
            if (_mapping.TaskMap.ContainsKey("TASK_START_DATE"))
            {
                DateTime minDate = table.AsEnumerable().Min(t => t.Field<DateTime>(_mapping.TaskMap["TASK_START_DATE"]));
                projectRow.PROJ_INFO_START_DATE = minDate;
            }
            projectDataSet.Project.AddProjectRow(projectRow);

            if (!Repository.CheckIfProjectExists(inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString()))
            {
                Console.WriteLine("Starting create project for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());

                    BuildProjectCustomFields(projectDataSet, inputProjectRow, projectGuid);
                projectGuid =  new Repository().CreateProject(projectDataSet,hasPlan,PlanUID);  //create with minimal initiation data including EPT Type
                iscreate = true;
            }
            else
            {
                Console.WriteLine("Project already exists for {0}, Starting an update", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
                projectGuid = Repository.GetProjectList().Project
                    .First(t => t.PROJ_NAME.Trim().ToUpper() == inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString().Trim().ToUpper()).PROJ_UID;
            }

            projectDataSet = Repository.ReadProject(projectGuid);
            projectRow = projectDataSet.Project.Rows[0] as SvcProject.ProjectDataSet.ProjectRow;
            BuildResources(table, projectDataSet, projectGuid); // build team
            new Repository().UpdateProjectTeam(projectDataSet);
            projectDataSet = Repository.ReadProject(projectGuid);
            projectRow = projectDataSet.Project.Rows[0] as SvcProject.ProjectDataSet.ProjectRow;
            return projectDataSet;
        }
Example #14
0
        /// <summary>
        /// This method used to insert the data into EPMLive PFE.
        /// </summary>
        /// <param name="projectId">project id</param>
        private void ProcessPFEWork(int projectId)
        {
            try
            {
                ProjectDataSet projectDataSet = null;
                var            lstName        = ProjectCenter;

                SPSecurity.RunWithElevatedPrivileges(() => projectDataSet = pService.ReadProject(projectGuid, DataStoreEnum.PublishedStore));

                var stringBuilder = new StringBuilder(
                    $"<UpdateScheduledWork><Params Worktype=\"1\"/><Data><Project ID=\'{projectId}\' List=\'{lstName}\'>");

                foreach (ProjectDataSet.AssignmentRow assignmentRow in projectDataSet.Assignment)
                {
                    var resourceId = getResourceResId(assignmentRow.RES_UID_OWNER);

                    if (resourceId > 0)
                    {
                        stringBuilder.Append($"<Resource Id=\"{resourceId}\">");

                        var assnStartDate  = assignmentRow.ASSN_START_DATE;
                        var assnFinishDate = assignmentRow.ASSN_FINISH_DATE;
                        var interval       = (assnFinishDate - assnStartDate).Days;
                        var hour           = assignmentRow.ASSN_WORK;
                        var loopStDate     = assnStartDate;

                        while (loopStDate <= assnFinishDate)
                        {
                            var individualHour = hour / (interval + 1) / assignmentRow.ASSN_UNITS / 6;
                            stringBuilder.Append($"<Work Date=\"{DateTime.Parse(loopStDate.ToString()):s}\" Hours=\"{individualHour}\"/>");
                            loopStDate = loopStDate.AddDays(1);
                        }

                        stringBuilder.Append("</Resource>");
                    }
                }

                stringBuilder.Append("</Project></Data></UpdateScheduledWork>");

                SPSecurity.RunWithElevatedPrivileges(
                    delegate
                {
                    var portfolioEngineApi = new PortfolioEngineAPI
                    {
                        Url = $"{mySiteToPublish.Url}/_vti_bin/portfolioengine.asmx",
                        UseDefaultCredentials = true
                    };
                    portfolioEngineApi.Execute("UpdateScheduledWork", stringBuilder.ToString());
                });
            }
            catch (Exception exception)
            {
                myLog.WriteEntry($"Error in ProcessPFEWork {exception.Message}{exception.StackTrace}", EventLogEntryType.Error, 305);
            }
        }
        private double PublishTasksPubTypeOne(
            int projectId,
            int pubType,
            double taskCount,
            ProjectDataSet projectDataSet,
            SPList taskCenter,
            ref double taskDoneCount)
        {
            Guard.ArgumentIsNotNull(taskCenter, nameof(taskCenter));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));

            const string AssignmentId = "1";

            if (pubType == PubTypeOne)
            {
                taskCount += projectDataSet.Assignment.Count;

                foreach (ProjectDataSet.AssignmentRow assignmentRow in projectDataSet.Assignment)
                {
                    var currentTaskKey = $"{assignmentRow.TASK_UID.ToString().ToUpper()}.{assignmentRow.ASSN_UID.ToString().ToUpper()}";

                    if (!IsAssignedTaskSaved(assignmentRow.ASSN_UID))
                    {
                        SPListItem listItem;

                        if (hshCurTasks.Contains(currentTaskKey))
                        {
                            var hshCurTask = (Guid)hshCurTasks[currentTaskKey];
                            listItem = taskCenter.GetItemByUniqueId(hshCurTask);

                            hshCurTasks.Remove(currentTaskKey);
                        }
                        else
                        {
                            listItem = taskCenter.Items.Add();
                        }

                        listItem[listItem.Fields.GetFieldByInternalName(IsAssignment).Id] = AssignmentId;
                        listItem[ProjectText] = projectId;

                        processAssignment(assignmentRow, projectDataSet, listItem);
                    }
                    else
                    {
                        hshCurTasks.Remove(currentTaskKey);
                    }

                    taskDoneCount++;
                    setPubPercent(taskCount, taskDoneCount);
                }
            }

            return(taskCount);
        }
        private string ProcessFieldCategoryOne(
            ProjectDataSet.TaskRow taskRow,
            ProjectDataSet projectDataSet,
            SPListItem listItem,
            string fieldName,
            string wssFieldName,
            string fieldType,
            string multiplier)
        {
            Guard.ArgumentIsNotNull(multiplier, nameof(multiplier));
            Guard.ArgumentIsNotNull(fieldType, nameof(fieldType));
            Guard.ArgumentIsNotNull(wssFieldName, nameof(wssFieldName));
            Guard.ArgumentIsNotNull(fieldName, nameof(fieldName));
            Guard.ArgumentIsNotNull(listItem, nameof(listItem));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));
            Guard.ArgumentIsNotNull(taskRow, nameof(taskRow));

            string fieldData = null;

            if (fieldName == TaskPredecessors)
            {
                ProcessTaskPredecessors(taskRow, projectDataSet, listItem, wssFieldName);
            }
            else if (fieldName != TaskResnames)
            {
                try
                {
                    fieldData = taskRow[fieldName].ToString();
                }
                catch (Exception exception)
                {
                    Trace.WriteLine(exception);
                }

                if (fieldType == DateTimeText)
                {
                    listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = !string.IsNullOrWhiteSpace(fieldData.Trim())
                        ? (object)DateTime.Parse(fieldData)
                        : null;
                }
                else
                {
                    if (multiplier != "1")
                    {
                        fieldData = multiplyField(fieldData, multiplier);
                    }

                    listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = fieldData;
                }
            }

            return(fieldData);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            ProjectDataSet ds = new ProjectDataSet();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
        private void ProcessProjectDataSetTask(
            int projectId,
            int pubType,
            Guid newTransUid,
            Guid lastTransUid,
            ProjectDataSet projectDataSet,
            SPList taskCenter,
            double taskDoneCount,
            double taskCount)
        {
            Guard.ArgumentIsNotNull(taskCenter, nameof(taskCenter));
            Guard.ArgumentIsNotNull(projectDataSet, nameof(projectDataSet));

            foreach (ProjectDataSet.TaskRow taskRow in projectDataSet.Task)
            {
                if (taskRow.TASK_ID != 0 && !taskRow.IsTASK_NAMENull() && !taskRow.TASK_IS_SUBPROJ)
                {
                    try
                    {
                        SPListItem listItem;

                        if (hshCurTasks.Contains(taskRow.TASK_UID.ToString().ToUpper()))
                        {
                            var hshCurTask = (Guid)hshCurTasks[taskRow.TASK_UID.ToString().ToUpper()];
                            listItem = taskCenter.GetItemByUniqueId(hshCurTask);

                            hshCurTasks.Remove(taskRow.TASK_UID.ToString().ToUpper());
                        }
                        else
                        {
                            listItem = taskCenter.Items.Add();
                        }

                        listItem[ProjectText] = projectId;

                        PopulateResources(pubType, projectDataSet, listItem, taskRow);
                        PopulateListItem(pubType, newTransUid, lastTransUid, projectDataSet, taskCenter, listItem, taskRow);
                    }
                    catch (Exception exception)
                    {
                        myLog.WriteEntry(
                            $"Error in publishTasks({taskRow.TASK_NAME}) updating list item: {exception.Message}{exception.StackTrace}{exception.InnerException}",
                            EventLogEntryType.Error,
                            315);
                    }
                }

                taskDoneCount++;
                setPubPercent(taskCount, taskDoneCount);
            }
        }
        private void processAssignment(ProjectDataSet.AssignmentRow assignmentRow, ProjectDataSet projectDataSet, SPListItem listItem)
        {
            var taskRow = (ProjectDataSet.TaskRow)projectDataSet.Task.Select($"TASK_UID=\'{assignmentRow.TASK_UID}\'")[0];

            try
            {
                listItem[listItem.Fields.GetFieldByInternalName(TaskHierarchy).Id] = getHierarchy(projectDataSet, taskRow.TASK_PARENT_UID);
                listItem[listItem.Fields.GetFieldByInternalName(IsAssignment).Id]  = "1";
                listItem[listItem.Fields.GetFieldByInternalName(Title).Id]         = taskRow.TASK_NAME;
                listItem[listItem.Fields.GetFieldByInternalName(Wbs).Id]           = taskRow.TASK_WBS;
                listItem[listItem.Fields.GetFieldByInternalName(TaskUid).Id]       = $"{taskRow.TASK_UID}.{assignmentRow.ASSN_UID}";
                listItem[listItem.Fields.GetFieldByInternalName(TaskOrder).Id]     = taskRow.TASK_ID;

                if (!assignmentRow.IsASSN_NOTESNull())
                {
                    listItem[listItem.Fields.GetFieldByInternalName(Notes).Id] = assignmentRow.ASSN_NOTES;
                }

                listItem[listItem.Fields.GetFieldByInternalName(LastPublished).Id] = DateTime.Now;
                var resourceWssId = getResourceWssId(assignmentRow.RES_UID_OWNER);

                if (resourceWssId != 0)
                {
                    listItem[listItem.Fields.GetFieldByInternalName(AssignedTo).Id] = resourceWssId;
                }

                listItem[Summary] = taskRow.TASK_IS_SUMMARY.ToString();

                ProcessFieldToPublish(assignmentRow, projectDataSet, listItem, taskRow);

                if (!string.IsNullOrWhiteSpace(strTimesheetField))
                {
                    if (listItem.Fields.ContainsField(TimeSheetId))
                    {
                        var dataRows = projectDataSet.TaskCustomFields.Select(
                            $"TASK_UID=\'{taskRow.TASK_UID}\' AND MD_PROP_UID=\'{strTimesheetField}\'");

                        listItem[TimeSheetId] = dataRows.Length > 0
                            ? (object)dataRows[0][FlagValue].ToString()
                            : 0;
                    }
                }

                listItem.Update();
            }
            catch (Exception ex)
            {
                myLog.WriteEntry($"Error processing Assignment ({taskRow.TASK_NAME}): {ex.Message}{ex.StackTrace}", EventLogEntryType.Error, 330);
            }
        }
Example #20
0
        public ConstraintSolverResult ScheduleDataSet(ProjectDataSet dataSet, IConstraints constraints, GreedyActivityStrategy strategy)
        {
            var result = new ConstraintSolverResult(constraints);

            try
            {
                var cp = new CriticalPathHelper();
                cp.OrderActivitySchedule(dataSet, result);
                foreach (var a in result.Schedule)
                {
                    _scheduledJobs.GetOrAdd(a.ScheduledItem.UID, a);
                }

                SetupJobsAndResources(dataSet, constraints);
                var dataManager = new SolverDataManager(dataSet, result);
                var solver      = new Solver(dataManager);

                //var results = solver.Solve(
                //    _shifts.Values.ToList(),
                //    _workers.Values.ToList(),
                //    _tools.Values.ToList(),
                //    _zones.Values,
                //    _jobs.Values,
                //    strategy, _shiftManager);

                //foreach (var job in results)
                //{
                //    var activity = _activitiesMap[job.Job.ID];
                //    var scheduledActivity = _scheduledJobs[activity.UID];

                //    var start = TimeFrame.FromMinutes(job.Start);
                //    var end = TimeFrame.FromMinutes(job.End);

                //    scheduledActivity.ScheduledStart = start;
                //    scheduledActivity.ScheduledFinish = end;

                //    //result.ActivitySchedule.AddOrUpdateItemSchedule(job.Start, scheduledActivity);
                //    //result.State = SolverResultState.OptimalSolutionFound;
                //}
                //result.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                throw new Exception("Yikes! Error in solver!", ex);
            }

            return(result);
        }
Example #21
0
        public void MapDictionaryToTaskRow_ShouldMapDictionaryToNativeTaskFields()
        {
            var projectDs = new ProjectDataSet();
            var row       = projectDs.Task.NewTaskRow();

            var fields = new Dictionary <string, object>
            {
                { projectDs.Task.TASK_IDColumn.ColumnName, 100 },
                { projectDs.Task.TASK_NAMEColumn.ColumnName, "NewTask" }
            };

            _mapper.Map(fields, row, new NopPropsMatcher());

            Assert.IsTrue(row["TASK_NAME"].Equals("NewTask"));
            Assert.IsTrue(row["TASK_ID"].Equals(DBNull.Value));
        }
Example #22
0
        protected override List <IDataSetValidationResult> PerformSpecificValidation(ProjectDataSet dataSet, IConstraints constraints)
        {
            List <IDataSetValidationResult> validationResults = new List <IDataSetValidationResult>();

            if (constraints.ConstrainOnLaborPool)
            {
                validationResults.Add(ValidationService.ValidateActivityLaborRequirement(dataSet, ValidationOutcome.Invalid));
                //validationResults.Add(ValidationService.ValidateActivityShiftLengthForRequiredLabor(dataSet, ValidationOutcome.Warning));
            }

            if (constraints.ConstrainOnTools)
            {
                validationResults.Add(ValidationService.ValidateActivityToolRequirement(dataSet, ValidationOutcome.Invalid));
                //validationResults.Add(ValidationService.ValidateActivityShiftLengthForRequiredTools(dataSet, ValidationOutcome.Warning));
            }

            return(validationResults);
        }
        protected override List<IDataSetValidationResult> PerformSpecificValidation(ProjectDataSet dataSet, IConstraints constraints)
        {
            List<IDataSetValidationResult> validationResults = new List<IDataSetValidationResult>();
            
            if (constraints.ConstrainOnLaborPool)
            {
                validationResults.Add(ValidationService.ValidateActivityLaborRequirement(dataSet, ValidationOutcome.Invalid));
                //validationResults.Add(ValidationService.ValidateActivityShiftLengthForRequiredLabor(dataSet, ValidationOutcome.Warning));
            }

            if (constraints.ConstrainOnTools)
            {
                validationResults.Add(ValidationService.ValidateActivityToolRequirement(dataSet, ValidationOutcome.Invalid));
                //validationResults.Add(ValidationService.ValidateActivityShiftLengthForRequiredTools(dataSet, ValidationOutcome.Warning));
            }

            return validationResults;
        }
        public static void AddNewTask(this ProjectDataSet projectDataSet,
                                      Guid projectId,
                                      Guid jiraProjectIdCustomFieldUid,
                                      Guid jiraProjectNameCustomFieldUid,
                                      Guid jiraTaskIdCustomFieldUid,
                                      JiraTaskDto taskDto)
        {
            var task = projectDataSet.Task.NewTaskRow();

            task.TASK_UID = Guid.NewGuid();

            var jiraProjectIdCustomFieldRow = projectDataSet.TaskCustomFields.NewTaskCustomFieldsRow();

            jiraProjectIdCustomFieldRow.CUSTOM_FIELD_UID = Guid.NewGuid();
            jiraProjectIdCustomFieldRow.PROJ_UID         = projectId;
            jiraProjectIdCustomFieldRow.TASK_UID         = task.TASK_UID;
            jiraProjectIdCustomFieldRow.MD_PROP_UID      = jiraProjectIdCustomFieldUid;

            var jiraProjectNameCustomFieldRow = projectDataSet.TaskCustomFields.NewTaskCustomFieldsRow();

            jiraProjectNameCustomFieldRow.CUSTOM_FIELD_UID = Guid.NewGuid();
            jiraProjectNameCustomFieldRow.PROJ_UID         = projectId;
            jiraProjectNameCustomFieldRow.TASK_UID         = task.TASK_UID;
            jiraProjectNameCustomFieldRow.MD_PROP_UID      = jiraProjectNameCustomFieldUid;

            var jiraTaskIdCustomFieldRow = projectDataSet.TaskCustomFields.NewTaskCustomFieldsRow();

            jiraTaskIdCustomFieldRow.CUSTOM_FIELD_UID = Guid.NewGuid();
            jiraTaskIdCustomFieldRow.PROJ_UID         = projectId;
            jiraTaskIdCustomFieldRow.TASK_UID         = task.TASK_UID;
            jiraTaskIdCustomFieldRow.MD_PROP_UID      = jiraTaskIdCustomFieldUid;

            MapTaskFields(projectId,
                          taskDto,
                          task,
                          jiraProjectIdCustomFieldRow,
                          jiraProjectNameCustomFieldRow,
                          jiraTaskIdCustomFieldRow);

            projectDataSet.Task.AddTaskRow(task);
            projectDataSet.TaskCustomFields.AddTaskCustomFieldsRow(jiraProjectIdCustomFieldRow);
            projectDataSet.TaskCustomFields.AddTaskCustomFieldsRow(jiraProjectNameCustomFieldRow);
            projectDataSet.TaskCustomFields.AddTaskCustomFieldsRow(jiraTaskIdCustomFieldRow);
        }
Example #25
0
        private void SetupJobsAndResources(ProjectDataSet dataSet, IConstraints constraints)
        {
            //foreach (var shift in dataSet.Shifts)
            //{
            //    var cshift = CreateShiftFromShift(shift);
            //    _shiftManager.AddShift(cshift);
            //    _shifts.GetOrAdd(shift.Name, cshift);

            //    if (constraints.ConstrainOnLaborPool)
            //    {
            //        foreach (var laborLink in shift.LaborLinks)
            //        {
            //            foreach (var w in CreateWorkerFromLaborLink(laborLink))
            //            {
            //                _workers.GetOrAdd(w.ID, w);
            //                _shifts[shift.Name].Workers.Add(w);
            //            }
            //        }
            //    }

            //    if (constraints.ConstrainOnTools)
            //    {
            //        foreach (var toolLink in shift.ToolLinks)
            //        {
            //            foreach (var t in CreateToolFromToolLink(toolLink))
            //            {
            //                _tools.GetOrAdd(t.ID, t);
            //                _shifts[shift.Name].Tools.Add(t);
            //            }
            //        }
            //    }
            //}

            if (constraints.ConstrainOnZones)
            {
                foreach (var zone in dataSet.GetZoneResources())
                {
                    var z = CreateZoneFromZone(zone);
                    _zones.GetOrAdd(z.ID, z);
                    _zonesMap.GetOrAdd(z.ID, zone);
                }
            }
        }
Example #26
0
        public bool TryGetProjectDataSet(out ProjectDataSet projectDataSet)
        {
            projectDataSet = GetProject(ProjectName);
            if (projectDataSet == null)
            {
                _errorsContainer.AppendFormat("Project {0} cannot be found", ProjectName);
                return(false);
            }

            var project = projectDataSet.Project.SingleOrDefault();

            if (project == null)
            {
                _errorsContainer.AppendFormat("Project {0} cannot be found within project data set", ProjectName);
                return(false);
            }

            return(true);
        }
Example #27
0
        private static void AddOrUpdateTasks(TaskImportManager taskImportManager,
                                             IEnumerable <JiraTaskDto> jiraTaskDtos,
                                             CustomFieldDataSet.CustomFieldsRow jiraTaskIdCustomField,
                                             CustomFieldDataSet.CustomFieldsRow jiraProjectIdCustomField,
                                             CustomFieldDataSet.CustomFieldsRow jiraProjectNameCustomField)
        {
            var projectDataSetToAdd = new ProjectDataSet();

            ProjectDataSet projectDataSetToUpdate;

            if (!taskImportManager.TryGetProjectDataSet(out projectDataSetToUpdate))
            {
                Console.WriteLine(taskImportManager.GetAllErrors());
            }

            Guid projectId;
            var  projectTasks = projectDataSetToUpdate.GetExistingTasksByJiraKeys(jiraTaskIdCustomField, out projectId);

            foreach (var taskDto in jiraTaskDtos)
            {
                ProjectDataSet.TaskRow taskRow;
                if (!projectTasks.TryGetValue(taskDto.Id, out taskRow))
                {
                    projectDataSetToAdd.AddNewTask(projectId,
                                                   jiraProjectIdCustomField.MD_PROP_UID,
                                                   jiraProjectNameCustomField.MD_PROP_UID,
                                                   jiraTaskIdCustomField.MD_PROP_UID,
                                                   taskDto);
                }
                else
                {
                    projectDataSetToUpdate.UpdateTask(projectId,
                                                      taskRow.TASK_UID,
                                                      jiraProjectIdCustomField.MD_PROP_UID,
                                                      jiraProjectNameCustomField.MD_PROP_UID,
                                                      jiraTaskIdCustomField.MD_PROP_UID,
                                                      taskDto);
                }
            }

            taskImportManager.MakeChangesInProjectServer(projectId, projectDataSetToAdd, projectDataSetToUpdate);
        }
Example #28
0
        private string getHierarchy(ProjectDataSet projectDataSet, Guid taskuid)
        {
            if (hshTaskHierarchy.Contains(taskuid))
            {
                return hshTaskHierarchy[taskuid].ToString();
            }

            var taskRow = (ProjectDataSet.TaskRow)projectDataSet.Task.Select($"TASK_UID=\'{taskuid}\'")[0];

            var hierarchy = $"{getHierarchy(projectDataSet, taskRow.TASK_PARENT_UID)} > {taskRow.TASK_NAME}";

            if (hierarchy.Length > 3 && hierarchy[1] == '>')
            {
                hierarchy = hierarchy.Substring(3);
            }

            hshTaskHierarchy.Add(taskRow.TASK_UID, hierarchy);

            return hierarchy;
        }
Example #29
0
        private void processProjectCenterFields(ProjectDataSet projectDataSet, IEnumerable arrFToPublish, ref SPListItem listItem)
        {
            try
            {
                foreach (string field in arrFToPublish)
                {
                    var fieldSplit = field.Split(FieldSplitChar);

                    if (fieldSplit.Length < 6)
                    {
                        throw new InvalidOperationException("Invalid fieldSplit length");
                    }

                    var fieldName     = fieldSplit[0];
                    var wssFieldName  = fieldSplit[1];
                    var fieldCategory = fieldSplit[3];
                    var fieldType     = fieldSplit[4];
                    var multiplier    = fieldSplit[5];

                    if (fieldCategory == "4")
                    {
                        var drAssn = projectDataSet.ProjectCustomFields.Select($"MD_PROP_ID=\'{fieldName}\'");

                        if (drAssn.Length >= 1)
                        {
                            var fieldData = GetFieldData(fieldType, drAssn, fieldName, true);
                            listItem[listItem.Fields.GetFieldByInternalName(wssFieldName).Id] = fieldData;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                myLog.WriteEntry(
                    $"Error processing Project Center Enterprise Fields: {exception.Message}{exception.StackTrace}",
                    EventLogEntryType.Error,
                    330);
            }

            listItem.Update();
        }
Example #30
0
        public static DataSet GetProjectDataSetFromList()
        {
            ProjectDataSet projectDataSet = new ProjectDataSet();
            DataSet outputDataSet = projectDataSet.Copy();
            //add new table DrivingPath
            outputDataSet.Tables.Add("DrivingPath");
            outputDataSet.Tables["DrivingPath"].Columns.Add("PROJ_UID", typeof(String));
            outputDataSet.Tables["DrivingPath"].Columns.Add("TASK_DRIVINGPATH_ID", typeof(String));
            outputDataSet.Tables["DrivingPath"].Columns.Add("DrivingPathName", typeof(String));

            // Add new columns for output DataSet
            outputDataSet.Tables["Task"].Columns.Add("TASK_PREDECESSORS", typeof(String));
            outputDataSet.Tables["Task"].Columns.Add("TASK_DRIVINGPATH_ID", typeof(String));
            outputDataSet.Tables["Task"].Columns.Add("TASK_MODIFIED_ON", typeof(DateTime));

            //Add new Columns for Custom Fields
            outputDataSet.Tables["Task"].Columns.Add("CUSTOMFIELD_TEXT", typeof(String));
            outputDataSet.Tables["Task"].Columns.Add("CUSTOMFIELD_DESC", typeof(String));
            SPWeb web;
            if (SPContext.Current != null)
                web = SPContext.Current.Web;
            else
                web = new SPSite("http://finweb.contoso.com/sites/PMM").OpenWeb();

            var list = web.Lists.TryGetList(Constants.LIST_NAME_PROJECT_TASKS);
            var dPathsField = list.Fields[Constants.FieldId_DrivingPath] as SPFieldMultiChoice;
            var dShownField = list.Fields[Constants.FieldId_ShowOn] as SPFieldMultiChoice;
            Guid guid = Guid.NewGuid();
            if (list != null)
            {
                for (int i = 0; i < list.ItemCount; i++)
                {
                    DataRow row = outputDataSet.Tables["Task"].NewRow();
                    BuildTaskRowFromListItem(row, list.Items[i], guid);
                    outputDataSet.Tables["Task"].Rows.Add(row);
                }
            }
            return outputDataSet;
        }
        public ProjectDataSet UpdateRelations(ProjectDataSet projectDataSetToUpdate, IDictionary <int, IEnumerable <int> > jiraTaskRelations, out Guid projectId)
        {
            var projectDataSetToAdd = new ProjectDataSet();

            var tasksByJiraKeys = projectDataSetToUpdate.GetExistingTasksByJiraKeys(_jiraTaskIdCustomField, out projectId);

            foreach (var jiraTaskRelation in jiraTaskRelations)
            {
                ProjectDataSet.TaskRow mainTask;
                if (!tasksByJiraKeys.TryGetValue(jiraTaskRelation.Key, out mainTask))
                {
                    continue;
                }

                foreach (var relatedTaskId in jiraTaskRelation.Value)
                {
                    ProjectDataSet.TaskRow relatedTask;

                    if (tasksByJiraKeys.TryGetValue(relatedTaskId, out relatedTask))
                    {
                        var dependency = projectDataSetToUpdate.Dependency.SingleOrDefault(x => x.LINK_PRED_UID == relatedTask.TASK_UID &&
                                                                                           x.LINK_SUCC_UID == mainTask.TASK_UID);
                        if (dependency == null)
                        {
                            dependency               = projectDataSetToAdd.Dependency.NewDependencyRow();
                            dependency.LINK_UID      = Guid.NewGuid();
                            dependency.PROJ_UID      = projectId;
                            dependency.LINK_PRED_UID = relatedTask.TASK_UID;
                            dependency.LINK_SUCC_UID = mainTask.TASK_UID;
                            dependency.LINK_TYPE     = 2; // StartFinish, http://msdn.microsoft.com/en-us/library/websvcproject.projectdataset.dependencyrow.link_type(v=office.12).aspx

                            projectDataSetToAdd.Dependency.AddDependencyRow(dependency);
                        }
                    }
                }
            }

            return(projectDataSetToAdd);
        }
Example #32
0
        public int getResourceIdForTask(Guid taskuid, ProjectDataSet pDs)
        {
            var id = 0;

            using (var sqlCommand = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='AssignedToField'", cn))
                using (var sqlDataReader = sqlCommand.ExecuteReader())
                {
                    try
                    {
                        if (sqlDataReader.Read())
                        {
                            var field = sqlDataReader.GetString(0);
                            if (field.Trim() != string.Empty)
                            {
                                var fieldsRows = (ProjectDataSet.TaskCustomFieldsRow[])pDs.TaskCustomFields.Select(
                                    string.Format("TASK_UID='{0}' AND MD_PROP_UID='{1}'", taskuid, field));

                                if (fieldsRows.Length > 0)
                                {
                                    if (fieldsRows[0].IsCODE_VALUENull())
                                    {
                                        id = getResourceIdByEmail(fieldsRows[0].TEXT_VALUE);
                                    }
                                    else
                                    {
                                        var email = getLookupDescription(field, fieldsRows[0].CODE_VALUE.ToString());
                                        id = getResourceIdByEmail(email);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Exception Suppressed {0}", ex);
                    }
                }
            return(id);
        }
Example #33
0
        public void CreateProject <T>(T project)
        {
            var customFieldsDataSet = _customFieldsPsiService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Project.GetAttr <GuidAttribute>().Guid));

            var ds = new ProjectDataSet();

            _mapper.Map(project, ds.Project);
            _mapper.Map(project, ds.ProjectCustomFields, externalData: new Dictionary <string, object>
            {
                { customFieldsDataSet.DataSetName, customFieldsDataSet },
                { "PROJ_UID", ds.Project[0].PROJ_UID }
            });

            var createProjectJobUid = Guid.NewGuid();

            _projectPsiService.Invoke(p => p.QueueCreateProject(createProjectJobUid, ds, false));
            Wait(createProjectJobUid);

            var publishProjectJobUid = Guid.NewGuid();

            _projectPsiService.Invoke(p => p.QueuePublish(publishProjectJobUid, ds.Project[0].PROJ_UID, true, string.Empty));
            Wait(publishProjectJobUid);
        }
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model = model;
            _solverResult = data;

            var jobFactory = new JobFactory();
            var skillFactory = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory = new ToolFactory();
            var zoneFactory = new ZoneFactory();
            var shiftFactory = new ShiftFactory();
            
            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager = new JobManager(jobConverter);
            _zoneManager = new ZoneManager(zoneConverter);
        }
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model        = model;
            _solverResult = data;

            var jobFactory    = new JobFactory();
            var skillFactory  = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory   = new ToolFactory();
            var zoneFactory   = new ZoneFactory();
            var shiftFactory  = new ShiftFactory();

            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter  = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter  = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter   = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager   = new JobManager(jobConverter);
            _zoneManager  = new ZoneManager(zoneConverter);
        }
Example #36
0
 public DateTime? GetProjectCurrentDate(ProjectDataSet projectDataSet,Guid projectGuid)
 {
     return DataRepository.GetProjectCurrentDate(projectDataSet, projectGuid);
 }
Example #37
0
        private static void BuildTask(DataRow inputTaskRow, ProjectDataSet.TaskRow taskRow, Guid projectGuid)
        {
            Console.WriteLine("build task started for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());
            foreach (var taskField in _mapping.Task.Fields)
            {
                var sourcecolumn = taskField.Source;
                var targetColumn = taskField.Target;
                if (!inputTaskRow.Table.HasColumn(sourcecolumn))
                    continue;

                Guid guidValue;
                var inputValue = inputTaskRow[sourcecolumn];

                if (!(inputValue == System.DBNull.Value || inputValue == null || string.IsNullOrEmpty(inputValue.ToString())))
                {
                    if (taskField.MapStringToGuid == true)
                    {
                        guidValue = Repository.GetResources().Resources.First(t => t.RES_NAME.Trim().ToUpper() == inputValue.ToString().Trim().ToUpper()).RES_UID;
                        taskRow[targetColumn] = guidValue;
                    }
                    else
                    {
                        if (taskRow.Table.Columns[targetColumn].DataType == typeof(bool))
                        {
                            taskRow[targetColumn] = inputValue.ToString().Trim().ToUpper() == "YES";
                        }
                        else
                        {
                            taskRow[targetColumn] = inputValue;
                        }
                    }

                    taskRow.PROJ_UID = projectGuid;
                    taskRow.TASK_UID = Guid.NewGuid();
                }
            }
            Console.WriteLine("build task done successfully for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());
        }
Example #38
0
 private static void BuildTasks(DataTable table, ProjectDataSet projectDataSet, Guid projectGuid)
 {
     Console.WriteLine("Starting build tasks");
     for (int i = 1; i < table.Rows.Count; i++)
     {
         //Build Tasks
         var inputTaskRow = table.Rows[i];
         var taskRow = projectDataSet.Task.NewTaskRow();
         BuildTask(inputTaskRow, taskRow, projectGuid);
         projectDataSet.Task.Rows.Add(taskRow);
         BuildAssignments(inputTaskRow, projectDataSet, projectGuid);
         BuildTaskCustomFields(projectDataSet, inputTaskRow, projectGuid);
     }
     Console.WriteLine("build tasks done successfully");
 }
Example #39
0
        public void UpdateProject(ProjectDataSet projectDs)
        {
            Guid projUid = projectDs.Project[0].PROJ_UID;
            Guid sessionId = Guid.NewGuid();
            string projectName = projectDs.Project[0].PROJ_NAME;
            Console.WriteLine("update project team started for {0}", projectName);
            ProjectDataSet deltaDataSet = new ProjectDataSet();
            if (projectDs.GetChanges() != null)
            {

                if (projectDs.GetChanges(DataRowState.Added) != null)
                {
                    deltaDataSet.Merge(projectDs.GetChanges(DataRowState.Added));
                    projectClient.CheckOutProject(projUid, sessionId, "");
                    Guid jobGuid = Guid.NewGuid();
                    projectClient.QueueAddToProject(jobGuid, sessionId, deltaDataSet, false);
                    // Wait for the Project Server Queuing System to create the project.
                    if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectUpdate))
                    {
                        jobGuid = Guid.NewGuid();
                        projectClient.QueueCheckInProject(jobGuid, projUid, true, Guid.NewGuid(), "");
                        if (WaitForQueueJobCompletion(jobGuid, projUid, (int)SvcQueueSystem.QueueMsgType.ProjectCheckIn))
                        {
                            projectClient.QueuePublish(Guid.NewGuid(), projUid, false, pwaUrl);
                            if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectPublish))
                            {
                                Console.WriteLine("update project done successfully for {0}", projectName);
                            }
                            else
                            {
                                Console.WriteLine(
                                           "update project done queue error for {0}", projectName);
                            }
                        }
                        else
                        {
                            Console.WriteLine(
                                            "update project  done queue error for {0}", projectName);
                        }

                    }
                    else
                    {
                        Console.WriteLine(
                                           "update project done queue error for {0}", projectName);
                    }
                }
                else
                {
                    Console.WriteLine("update project done successfully for {0}", projectName);
                }

                 if (projectDs.GetChanges(DataRowState.Modified) != null)
                {
                    deltaDataSet = new ProjectDataSet();
                    deltaDataSet.Merge(projectDs.GetChanges(DataRowState.Modified));
                    projectClient.CheckOutProject(projUid, sessionId, "");
                    Guid jobGuid = Guid.NewGuid();
                    projectClient.QueueUpdateProject(jobGuid, sessionId, deltaDataSet, false);
                    // Wait for the Project Server Queuing System to create the project.
                    if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectUpdate))
                    {
                        jobGuid = Guid.NewGuid();
                        projectClient.QueueCheckInProject(jobGuid, projUid, true, Guid.NewGuid(), "");
                        if (WaitForQueueJobCompletion(jobGuid, projUid, (int)SvcQueueSystem.QueueMsgType.ProjectCheckIn))
                        {

                            projectClient.QueuePublish(Guid.NewGuid(), projUid, false, pwaUrl);
                            if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectPublish))
                            {
                                Console.WriteLine("update project done successfully for {0}", projectName);
                            }
                            else
                            {
                                Console.WriteLine(
                                           "update project done queue error for {0}", projectName);
                            }
                        }
                        else
                        {
                            Console.WriteLine(
                                            "update project  done queue error for {0}", projectName);
                        }

                    }
                    else
                    {
                        Console.WriteLine(
                                           "update project done queue error for {0}", projectName);
                    }
                }
                else
                {
                    Console.WriteLine("update project done successfully for {0}", projectName);
                }

            }
        }
Example #40
0
        private static List<GraphDataGroup> GetBEIData(Guid projectUID, ProjectDataSet projectDataSet)
        {
            List<GraphDataGroup> group = new List<GraphDataGroup>();
            DateTime? projectStatusDate = GetProjectCurrentDate(projectUID, projectDataSet);
            List<FiscalUnit> projectStatusPeriods = GetProjectStatusWeekPeriods(projectStatusDate);
            IEnumerable<ProjectDataSet.TaskRow> tasks = projectDataSet.Task.Where(t => t.TASK_IS_SUMMARY == false && !t.IsTASK_DURNull() && t.TASK_DUR > 0);

            //Get BEIStart Data
            List<GraphData> graphDataBES = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {

                int totalStart = tasks.Count(t => !t.IsTASK_ACT_STARTNull() && t.TASK_ACT_START >= unit.From && t.TASK_ACT_START <= unit.To);
                int totalTBStart = tasks.Count(t => !t.IsTB_STARTNull() && t.TB_START >= unit.From && t.TB_START <= unit.To);
                if (totalTBStart != 0)
                {
                    graphDataBES.Add(new GraphData() { Count = totalStart / totalTBStart, Title = unit.GetTitle() });
                }
                else
                {
                    graphDataBES.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
                }
            }
            group.Add(new GraphDataGroup() { Type = "BES", Data = graphDataBES });

            //Get BEIFinish Data
            List<GraphData> graphDataBEF = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {

                int totalFinish = tasks.Count(t => !t.IsTASK_ACT_FINISHNull() && t.TASK_ACT_FINISH >= unit.From && t.TASK_ACT_FINISH <= unit.To);
                int totalTBFinish = tasks.Count(t => !t.IsTB_FINISHNull() && t.TB_FINISH >= unit.From && t.TB_FINISH <= unit.To);
                if (totalTBFinish != 0)
                {
                    graphDataBEF.Add(new GraphData() { Count = totalFinish / totalTBFinish, Title = unit.GetTitle() });
                }
                else
                {
                    graphDataBEF.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
                }
            }
            group.Add(new GraphDataGroup() { Type = "BEF", Data = graphDataBEF });

            //Get BEI Forecast Start Data
            List<GraphData> graphDataBEFS = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int totalStart = tasks.Count(t => !t.IsTASK_START_DATENull() && !t.IsTASK_PCT_COMPNull() && t.TASK_START_DATE >= unit.From && t.TASK_START_DATE <= unit.To && t.TASK_PCT_COMP == 0);
                int totalTBStart = tasks.Count(t => !t.IsTB_STARTNull() && t.TB_START >= unit.From && t.TB_START <= unit.To);
                if (totalTBStart != 0)
                {
                    graphDataBEFS.Add(new GraphData() { Count = totalStart / totalTBStart, Title = unit.GetTitle() });
                }
                else
                {
                    graphDataBEFS.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
                }
            }
            group.Add(new GraphDataGroup() { Type = "BEFS", Data = graphDataBEFS });

            //Get BEI Forecast Finish Data
            List<GraphData> graphDataBEFF = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {

                int totalFinish = tasks.Count(t => !t.IsTASK_FINISH_DATENull() && !t.IsTASK_PCT_COMPNull() && t.TASK_FINISH_DATE >= unit.From && t.TASK_FINISH_DATE <= unit.To);
                int totalTBFinish = tasks.Count(t => !t.IsTB_FINISHNull() && t.TB_FINISH >= unit.From && t.TB_FINISH <= unit.To);
                if (totalTBFinish != 0)
                {
                    graphDataBEFF.Add(new GraphData() { Count = totalFinish / totalTBFinish, Title = unit.GetTitle() });
                }
                else
                {
                    graphDataBEFF.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
                }
            }
            group.Add(new GraphDataGroup() { Type = "BEFF", Data = graphDataBEFF });

            return group;
        }
Example #41
0
        private static List<GraphDataGroup> GetSPDLSTartToBLData(Guid projectUID, ProjectDataSet projectDataSet)
        {
            List<GraphDataGroup> group = new List<GraphDataGroup>();
            DateTime? projectStatusDate = GetProjectCurrentDate(projectUID, projectDataSet);
            if (!projectStatusDate.HasValue)
                return new List<GraphDataGroup>();
            List<FiscalUnit> projectStatusPeriods = GetProjectStatusPeriods(projectStatusDate.Value);
            IEnumerable<ProjectDataSet.TaskRow> tasks = projectDataSet.Task.Where(t => t.TASK_IS_SUMMARY == false && !t.IsTASK_DURNull() && t.TASK_DUR > 0);

            //Get CS Data
            List<GraphData> graphDataCS = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTASK_ACT_STARTNull() && t.TASK_ACT_START >= unit.From && t.TASK_ACT_START <= unit.To);
                graphDataCS.Add(new GraphData() { Count = count, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "CS", Data = graphDataCS });

            //Get FCS Data
            List<GraphData> graphDataFCS = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTASK_START_DATENull() && t.TASK_START_DATE >= unit.From && t.TASK_START_DATE <= unit.To && t.IsTASK_ACT_STARTNull() && t.TASK_PCT_COMP == 0);
                graphDataFCS.Add(new GraphData() { Count = count, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "FCS", Data = graphDataFCS });

            //Get DQ Data
            List<GraphData> graphDataDQ = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTASK_START_DATENull() && !t.IsTB_STARTNull() && t.TB_START >= unit.From && t.TB_START <= unit.To && t.TASK_START_DATE > t.TB_START);
                graphDataDQ.Add(new GraphData() { Count = count, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "DQ", Data = graphDataDQ });

            //Get FDQ Data
            List<GraphData> graphDataFDQ = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTASK_START_DATENull() && !t.IsTB_STARTNull() && t.TB_START >= unit.From && t.TB_START <= unit.To && t.TASK_START_DATE > t.TB_START && t.TASK_PCT_COMP == 0);
                graphDataFDQ.Add(new GraphData() { Count = count, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "FDQ", Data = graphDataFDQ });

            //Get CDQ Data
            List<GraphData> graphDataCDQ = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTB_STARTNull() && t.TB_START <= projectStatusDate && t.TB_START >= unit.From && t.TB_START <= unit.To && t.IsTASK_ACT_STARTNull());
                graphDataCDQ.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "CDQ", Data = graphDataCDQ });

            //Get FCDQ Data
            List<GraphData> graphDataFCDQ = new List<GraphData>();
            foreach (FiscalUnit unit in projectStatusPeriods)
            {
                int count = tasks.Count(t => !t.IsTASK_START_DATENull() && !t.IsTB_STARTNull() && t.TASK_START_DATE > projectStatusDate && t.TASK_START_DATE >= unit.From && t.TASK_START_DATE <= unit.To && t.TASK_START_DATE > t.TB_START);
                graphDataFCDQ.Add(new GraphData() { Count = 0, Title = unit.GetTitle() });
            }
            group.Add(new GraphDataGroup() { Type = "FCDQ", Data = graphDataFCDQ });

            return group;
        }
        public ConstraintSolverResult ScheduleDataSet(ProjectDataSet dataSet, IConstraints constraints, GreedyActivityStrategy strategy)
        {
            var result = new ConstraintSolverResult(constraints);

            try
            {
                var cp = new CriticalPathHelper();
                cp.OrderActivitySchedule(dataSet, result);
                foreach (var a in result.Schedule)
                {
                    _scheduledJobs.GetOrAdd(a.ScheduledItem.UID, a);
                }

                SetupJobsAndResources(dataSet, constraints);
                var dataManager = new SolverDataManager(dataSet, result);
                var solver = new Solver(dataManager);

                //var results = solver.Solve(
                //    _shifts.Values.ToList(),
                //    _workers.Values.ToList(),
                //    _tools.Values.ToList(),
                //    _zones.Values,
                //    _jobs.Values,
                //    strategy, _shiftManager);

                //foreach (var job in results)
                //{
                //    var activity = _activitiesMap[job.Job.ID];
                //    var scheduledActivity = _scheduledJobs[activity.UID];

                //    var start = TimeFrame.FromMinutes(job.Start);
                //    var end = TimeFrame.FromMinutes(job.End);

                //    scheduledActivity.ScheduledStart = start;
                //    scheduledActivity.ScheduledFinish = end;

                //    //result.ActivitySchedule.AddOrUpdateItemSchedule(job.Start, scheduledActivity);
                //    //result.State = SolverResultState.OptimalSolutionFound;
                //}
                //result.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                throw new Exception("Yikes! Error in solver!", ex);
            }

            return result;
        }
Example #43
0
        private static void BuildResource(DataTable table, ProjectDataSet resources, DataRow inputProjectRow, Guid projectGuid, ResourceMode mode)
        {
            _resourcesList = new List<string>();
            IEnumerable<Field> data;

            if (mode == ResourceMode.Project)
            {
                data = _mapping.Project.Fields.Where(t => t.IsResourceColumn);
                if (_mapping.Project.Fields.Any(t => t.IsResourceColumn))
                {
                    foreach (var projectField in data)
                    {
                        var sourcecolumn = projectField.Source;
                        var targetColumn = projectField.Target;
                        if (!inputProjectRow.Table.HasColumn(sourcecolumn))
                        {
                            continue;
                        }
                        var inputValue = inputProjectRow[sourcecolumn];

                        if (inputValue == null || inputValue == System.DBNull.Value || inputValue.ToString() == string.Empty)
                        {
                            continue;
                        }
                        if (!_resourcesList.Contains(inputValue))
                        {
                            _resourcesList.Add(inputValue.ToString());
                        }
                    }
                }
            }
            else
            {

                for (int i = 1; i < table.Rows.Count; i++)
                {
                    if (_mapping.Task.Fields.Any(t => t.IsResourceColumn))
                    {
                        data = _mapping.Task.Fields.Where(t => t.IsResourceColumn);
                        foreach (var taskField in data)
                        {
                            var sourcecolumn = taskField.Source;
                            var targetColumn = taskField.Target;
                            var inputValue = table.Rows[i][sourcecolumn];
                            if (!_resourcesList.Contains(inputValue))
                            {
                                _resourcesList.Add(inputValue.ToString());
                            }
                        }
                    }

                    if (_mapping.Assignment.Fields.Any(t => t.IsResourceColumn))
                    {
                        data = _mapping.Assignment.Fields.Where(t => t.IsResourceColumn);
                        foreach (var assnField in data)
                        {
                            var sourcecolumn = assnField.Source;
                            var targetColumn = assnField.Target;
                            var inputValue = table.Rows[i][sourcecolumn];
                            if (!_resourcesList.Contains(inputValue))
                            {
                                _resourcesList.Add(inputValue.ToString());
                            }
                        }
                    }
                }
            }

            /// at this point the _resourcesList contains every distinct resource identified in the input file
            foreach (var newResource in _resourcesList)
            {
                if (!Repository.GetResources().Resources.Any(t => t.RES_NAME.ToUpper() == newResource.ToUpper()))
                {
                    var newRow = resources.ProjectResource.NewProjectResourceRow();
                    newRow.RES_UID = Guid.NewGuid();//Repository.GetResourceUidFromNtAccount(newResource, out isWindowsUser);
                    newRow.RES_NAME = newResource;
                    newRow.PROJ_UID = projectGuid;
                    resources.ProjectResource.Rows.Add(newRow);
                }
                else
                {
                    if (!resources.ProjectResource.Any(t => t.RES_NAME.Trim().ToUpper() == newResource.Trim().ToUpper()))
                    {
                        var newRow = resources.ProjectResource.NewProjectResourceRow();
                        if (!Repository.GetResources()
                                .Resources.Any(t => t.RES_NAME.Trim().ToUpper() == newResource.Trim().ToUpper()))
                            throw new ArgumentException("Resource not found for" + newResource);
                        newRow.RES_UID =
                            Repository.GetResources()
                                .Resources.First(t => t.RES_NAME.Trim().ToUpper() == newResource.Trim().ToUpper())
                                .RES_UID;
                        newRow.RES_NAME = newResource;
                        newRow.PROJ_UID = projectGuid;

                        resources.ProjectResource.Rows.Add(newRow);
                        newRow.AcceptChanges();
                    }
                }
            }
        }
Example #44
0
        private static void BuildProjectCustomFields(ProjectDataSet projectDataSet,
          DataRow inputProjectRow, Guid projectGuid)
        {
            Console.WriteLine("build project custom fields started for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
            foreach (var customField in _mapping.Project.CustomFields)
            {
                var sourcecolumn = customField.Source;
                if (!inputProjectRow.Table.HasColumn(sourcecolumn))
                    continue;
                bool customFieldExists = false; ;
                if (inputProjectRow[sourcecolumn] == System.DBNull.Value || inputProjectRow[sourcecolumn] == null || string.IsNullOrEmpty(inputProjectRow[sourcecolumn].ToString()))
                {
                    continue;
                }

                var targetColumn = customField.Target;
                var csField =
                    customDataSet.CustomFields.First(t => t.MD_PROP_NAME == targetColumn);
                SvcProject.ProjectDataSet.ProjectCustomFieldsRow customfieldRow;
                if (projectDataSet.ProjectCustomFields.Any(t => t.MD_PROP_UID == csField.MD_PROP_UID && t.PROJ_UID == projectGuid))
                {
                    customfieldRow = projectDataSet.ProjectCustomFields.First(t => t.MD_PROP_UID == csField.MD_PROP_UID && t.PROJ_UID == projectGuid);
                    customFieldExists = true;
                }
                else
                {
                    customfieldRow = projectDataSet.ProjectCustomFields.NewProjectCustomFieldsRow();
                    customfieldRow.MD_PROP_ID = csField.MD_PROP_ID;
                    customfieldRow.CUSTOM_FIELD_UID = Guid.NewGuid();
                    customfieldRow.FIELD_TYPE_ENUM = (byte)csField.MD_PROP_TYPE_ENUM;
                    customfieldRow.MD_PROP_ID = csField.MD_PROP_ID;
                    customfieldRow.MD_PROP_UID = csField.MD_PROP_UID;

                    customfieldRow.PROJ_UID = projectGuid;
                }

                //First(t => t.MD_PROP_UID == csField.MD_PROP_UID);
                if (!csField.IsMD_LOOKUP_TABLE_UIDNull())
                {
                    var lookup = Repository.lookupTableClient.ReadLookupTablesByUids(
                        new Guid[] { csField.MD_LOOKUP_TABLE_UID }, false, CultureInfo.CurrentCulture.LCID);
                    customfieldRow.CODE_VALUE =
                        lookup.LookupTableTrees.First(t => t.LT_VALUE_FULL == inputProjectRow[sourcecolumn].ToString())
                            .LT_STRUCT_UID;  //to do add a friendly message
                }
                else
                {

                    switch (customfieldRow.FIELD_TYPE_ENUM)
                    {
                        case 4:
                            customfieldRow.DATE_VALUE = Convert.ToDateTime(inputProjectRow[sourcecolumn]);
                            break;
                        case 9:
                            customfieldRow.NUM_VALUE = Convert.ToDecimal(inputProjectRow[sourcecolumn]);
                            break;
                        case 6:
                            customfieldRow.DUR_VALUE = Convert.ToInt16(inputProjectRow[sourcecolumn]);
                            break;
                        case 27:
                            customfieldRow.DATE_VALUE = Convert.ToDateTime(inputProjectRow[sourcecolumn]);
                            break;
                        case 17:
                            customfieldRow.FLAG_VALUE = Convert.ToBoolean(inputProjectRow[sourcecolumn]);
                            break;
                        case 15:
                            customfieldRow.NUM_VALUE = Convert.ToDecimal(inputProjectRow[sourcecolumn]);
                            break;
                        case 21:
                            customfieldRow.TEXT_VALUE = Convert.ToString(inputProjectRow[sourcecolumn]);
                            break;
                    }
                }
                if (!customFieldExists)
                {
                    projectDataSet.ProjectCustomFields.Rows.Add(customfieldRow);
                }
            }
            Console.WriteLine("build project custom fields done successfully for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
        }
Example #45
0
        private static void BuildProject(DataRow inputProjectRow, ProjectDataSet.ProjectRow projectRow,
            ProjectDataSet projectDataSet, Guid projectGuid,bool updateCustomFieldsnotreqd)
        {
            Console.WriteLine("build project started for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
            foreach (var projectField in _mapping.Project.Fields)
            {
                var sourcecolumn = projectField.Source;

                if (!inputProjectRow.Table.HasColumn(sourcecolumn))
                    continue;
                var inputValue = inputProjectRow[sourcecolumn];
                var targetColumn = projectField.Target;

                if (targetColumn == "ENTERPRISE_PROJECT_TYPE_UID" || targetColumn == "ENTERPRISE_PROJECT_TYPE_NAME" || targetColumn == "PROJ_TYPE" || inputValue == System.DBNull.Value ||
                   inputValue == null || inputValue.ToString() == string.Empty
                    )
                {
                    continue;
                }
                Guid guidValue;
                 //row["Input column name in the exel file"]
                if (projectField.MapStringToGuid == true)
                {
                    guidValue = Repository.GetResources().Resources.First(t => t.RES_NAME.Trim().ToUpper() == inputValue.ToString().Trim().ToUpper()).RES_UID;
                    projectRow[targetColumn] = guidValue;
                }
                else
                {
                    projectRow[targetColumn] = inputValue; // projectROW["PROJ_UID"]
                }

            }
            if (!updateCustomFieldsnotreqd)
            {

                BuildProjectCustomFields(projectDataSet, inputProjectRow, projectGuid);
            }
            Console.WriteLine("build project done successfully for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
        }
Example #46
0
        private static void BuildAssignments(DataRow inputTaskRow,
            ProjectDataSet projectDataSet, Guid projectGuid)
        {
            Console.WriteLine("Starting build assignment");
            if (inputTaskRow.Table.Columns.Contains(_mapping.AssignmentMap["RES_NAME"]))
            {
                foreach (var assnField in _mapping.Assignment.Fields)
                {
                    var sourcecolumn = assnField.Source;
                    var targetColumn = assnField.Target;

                    if (!inputTaskRow.Table.HasColumn(sourcecolumn))
                        continue;
                    var assignmentRow = projectDataSet.Assignment.NewAssignmentRow();
                    var inputValue = inputTaskRow[sourcecolumn];
                    assignmentRow.ASSN_UID = Guid.NewGuid();
                    assignmentRow.PROJ_UID = projectGuid;
                    assignmentRow.TASK_UID =
                        projectDataSet.Task.First(t => t.TASK_NAME == inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString())
                            .TASK_UID;
                    if (resUids.ContainsKey(inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString()))
                    {
                        assignmentRow.RES_UID = resUids[inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString()];
                    }
                    else
                    {

                        if (
                            Repository.GetResources()
                                .Resources.Any(
                                    t =>
                                        t.RES_NAME.ToUpper() ==
                                        inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString().ToUpper()))
                        {
                            assignmentRow.RES_UID = Repository.GetResources()
                                .Resources.First(
                                    t =>
                                        t.RES_NAME.ToUpper() ==
                                        inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString().ToUpper()).RES_UID;
                        }
                        else
                        {
                            assignmentRow.RES_UID = projectDataSet.ProjectResource.First(t => t.RES_NAME == inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString()).RES_UID;
                        }

                        resUids.Add(inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString(), assignmentRow.RES_UID);
                    }
                    assignmentRow.RES_NAME = inputTaskRow[_mapping.AssignmentMap["RES_NAME"]].ToString();
                    assignmentRow[targetColumn] = inputValue;
                    projectDataSet.Assignment.Rows.Add(assignmentRow);
                }
            }
            Console.WriteLine("build assignment done successfully");
        }
Example #47
0
 public static void BuildResources(DataTable table, ProjectDataSet resources, Guid projectGuid)
 {
     Console.WriteLine("Starting build project resources");
     DataRow inputProjectRow = table.Rows[0];
     BuildResource(table, resources, inputProjectRow, projectGuid, ResourceMode.Project);
     Console.WriteLine("Build project resources done successfully");
     for (int i = 1; i < table.Rows.Count; i++)
     {
         Console.WriteLine("Starting build task resource");
         BuildResource(table, resources, table.Rows[i], projectGuid, ResourceMode.Task);
         Console.WriteLine("Build task resource done successfully");
     }
 }
        private void SetupJobsAndResources(ProjectDataSet dataSet, IConstraints constraints)
        {

            //foreach (var shift in dataSet.Shifts)
            //{
            //    var cshift = CreateShiftFromShift(shift);
            //    _shiftManager.AddShift(cshift);
            //    _shifts.GetOrAdd(shift.Name, cshift);

            //    if (constraints.ConstrainOnLaborPool)
            //    {
            //        foreach (var laborLink in shift.LaborLinks)
            //        {
            //            foreach (var w in CreateWorkerFromLaborLink(laborLink))
            //            {
            //                _workers.GetOrAdd(w.ID, w);
            //                _shifts[shift.Name].Workers.Add(w);
            //            }
            //        }
            //    }

            //    if (constraints.ConstrainOnTools)
            //    {
            //        foreach (var toolLink in shift.ToolLinks)
            //        {
            //            foreach (var t in CreateToolFromToolLink(toolLink))
            //            {
            //                _tools.GetOrAdd(t.ID, t);
            //                _shifts[shift.Name].Tools.Add(t);
            //            }
            //        }
            //    }
            //}

            if (constraints.ConstrainOnZones)
            {
                foreach (var zone in dataSet.GetZoneResources())
                {
                    var z = CreateZoneFromZone(zone);
                    _zones.GetOrAdd(z.ID, z);
                    _zonesMap.GetOrAdd(z.ID, zone);
                }
            }

            
        }
Example #49
0
        private static void BuildTask(ProjectDataSet projectDataSet, DataRow inputTaskRow, ProjectDataSet.TaskRow taskRow, Guid projectGuid, bool isCreate)
        {
            Console.WriteLine("build task started for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());

            foreach (var taskField in _mapping.Task.Fields)
            {
                var sourcecolumn = taskField.Source;
                var targetColumn = taskField.Target;
                if (!inputTaskRow.Table.HasColumn(sourcecolumn))
                    continue;

                Guid guidValue;
                var inputValue = inputTaskRow[sourcecolumn];

                if (_mapping.TaskMap.ContainsKey("TASK_ID") && sourcecolumn == _mapping.TaskMap["TASK_ID"].ToString())
                {
                    continue;
                }

                if (_mapping.TaskMap.ContainsKey("TASK_ID") && sourcecolumn == _mapping.TaskMap["TASK_OUTLINE_LEVEL"].ToString())
                {
                    if (isCreate)
                    {

                            //taskRow.AddAfterTaskUID = parentGuid;
                            taskRow.AddPosition = (int)Microsoft.Office.Project.Server.Library.Task.AddPositionType.Last;

                    }
                }

                if (!(inputValue == System.DBNull.Value || inputValue == null || string.IsNullOrEmpty(inputValue.ToString())))
                {
                    if (taskField.MapStringToGuid == true)
                    {
                        guidValue = Repository.GetResources().Resources.First(t => t.RES_NAME.Trim().ToUpper() == inputValue.ToString().Trim().ToUpper()).RES_UID;
                        taskRow[targetColumn] = guidValue;
                    }
                    else
                    {
                        if (taskRow.Table.Columns[targetColumn].DataType == typeof(bool))
                        {
                            taskRow[targetColumn] = inputValue.ToString().Trim().ToUpper() == "YES";
                        }
                        else
                        {
                            taskRow[targetColumn] = inputValue;
                        }
                    }

                    taskRow.PROJ_UID = projectGuid;
                    if (isCreate)
                    {
                        taskRow.TASK_UID = Guid.NewGuid();
                    }
                }

            }

            Console.WriteLine("build task done successfully for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());
        }
Example #50
0
 internal static DateTime? GetProjectCurrentDate(ProjectDataSet projectDataSet, Guid projUID)
 {
     try
     {
         DateTime date = projectDataSet.Project.First(t => t.PROJ_UID == projUID).PROJ_INFO_STATUS_DATE;
         return date;
     }
     catch
     {
         return DateTime.Now;
     }
 }
Example #51
0
        private static void BuildTaskCustomFields(ProjectDataSet projectDataSet,
            DataRow inputTaskRow, Guid projectGuid)
        {
            Console.WriteLine("build task custom fields started for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());
            foreach (var customField in _mapping.Task.CustomFields)
            {
                var sourcecolumn = customField.Source;
                if (!inputTaskRow.Table.HasColumn(sourcecolumn))
                    continue;
                if (inputTaskRow[sourcecolumn] == System.DBNull.Value || inputTaskRow[sourcecolumn] == null || string.IsNullOrEmpty(inputTaskRow[sourcecolumn].ToString()))
                {
                    continue;
                }

                var targetColumn = customField.Target;
                var csField =
                    customDataSet.CustomFields.First(t => t.MD_PROP_NAME == targetColumn);
                var customfieldRow = projectDataSet.TaskCustomFields.NewTaskCustomFieldsRow();
                customfieldRow.MD_PROP_ID = csField.MD_PROP_ID;
                customfieldRow.CUSTOM_FIELD_UID = Guid.NewGuid();
                customfieldRow.FIELD_TYPE_ENUM = (byte)csField.MD_PROP_TYPE_ENUM;
                customfieldRow.MD_PROP_ID = csField.MD_PROP_ID;
                customfieldRow.MD_PROP_UID = csField.MD_PROP_UID;

                customfieldRow.PROJ_UID = projectGuid;
                customfieldRow.TASK_UID =
                    projectDataSet.Task.First(t => t.TASK_NAME == inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString()).TASK_UID;
                //If it is a lookup table custom field
                if (!csField.IsMD_LOOKUP_TABLE_UIDNull())
                {
                    var lookup = Repository.lookupTableClient.ReadLookupTablesByUids(
                        new Guid[] { csField.MD_LOOKUP_TABLE_UID }, false, CultureInfo.CurrentCulture.LCID);
                    customfieldRow.CODE_VALUE =
                        lookup.LookupTableTrees.First(t => t.LT_VALUE_FULL == inputTaskRow[sourcecolumn].ToString())
                            .LT_STRUCT_UID;
                }
                else
                {
                    switch (customfieldRow.FIELD_TYPE_ENUM)
                    {
                        case 4:
                            customfieldRow.DATE_VALUE = Convert.ToDateTime(inputTaskRow[sourcecolumn]);
                            break;
                        case 9:
                            customfieldRow.NUM_VALUE = Convert.ToDecimal(inputTaskRow[sourcecolumn]);
                            break;
                        case 6:
                            customfieldRow.DUR_VALUE = Convert.ToInt16(inputTaskRow[sourcecolumn]);
                            break;
                        case 27:
                            customfieldRow.DATE_VALUE = Convert.ToDateTime(inputTaskRow[sourcecolumn]);
                            break;
                        case 17:
                            customfieldRow.FLAG_VALUE = inputTaskRow[sourcecolumn].ToString().Trim().ToUpper() == "YES";
                            break;
                        case 15:
                            customfieldRow.NUM_VALUE = Convert.ToDecimal(inputTaskRow[sourcecolumn]);
                            break;
                        case 21:
                            customfieldRow.TEXT_VALUE = Convert.ToString(inputTaskRow[sourcecolumn]);
                            break;
                    }
                }
                projectDataSet.TaskCustomFields.Rows.Add(customfieldRow);
            }
            Console.WriteLine("build task custom fields done successfully for {0}", inputTaskRow[_mapping.TaskMap["TASK_NAME"]].ToString());
        }
 public async Task<ConstraintSolverResult> ScheduleDataSetAsync(ProjectDataSet dataSet, IConstraints constraints, GreedyActivityStrategy strategy)
 {
     return await Task.Run(() => ScheduleDataSet(dataSet, constraints, strategy));
 }
Example #53
0
        private static void BuildTasks(DataTable table, ProjectDataSet projectDataSet, Guid projectGuid)
        {
            Console.WriteLine("Starting build tasks");
            if (ProjectHasTasks(table))
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    //Build Tasks
                    var inputTaskRow = table.Rows[i];
                    SvcProject.ProjectDataSet.TaskRow taskRow; bool isCreate = false;
                    if (_mapping.TaskMap.ContainsKey("TASK_ID") && inputTaskRow.Table.HasColumn(_mapping.TaskMap["TASK_ID"].ToString()) &&
                        inputTaskRow[_mapping.TaskMap["TASK_ID"].ToString()].ToString() != null &&
                        !string.IsNullOrEmpty(inputTaskRow[_mapping.TaskMap["TASK_ID"]].ToString()))
                    {
                        if (projectDataSet.Task.Any(t => (!t.IsTASK_IDNull() && t.TASK_ID == Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_ID"].ToString()].ToString())) && t.PROJ_UID == projectGuid))
                        {
                            taskRow = projectDataSet.Task.First(t => (t.TASK_ID == Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_ID"].ToString()].ToString())) && t.PROJ_UID == projectGuid);
                        }
                        else
                        {
                            taskRow = projectDataSet.Task.NewTaskRow();
                            isCreate = true;
                        }

                    }
                    else
                    {
                        taskRow = projectDataSet.Task.NewTaskRow();
                        isCreate = true;
                    }

                    BuildTask(projectDataSet, inputTaskRow, taskRow, projectGuid, isCreate);
                    if (isCreate)
                    {
                        projectDataSet.Task.Rows.Add(taskRow);
                    }
                    //BuildAssignments(inputTaskRow, projectDataSet, projectGuid);
                    BuildTaskCustomFields(projectDataSet, inputTaskRow, projectGuid);
                }
            }
            Console.WriteLine("build tasks done successfully");
        }
Example #54
0
 private static DateTime? GetProjectCurrentDate(Guid projectUID, ProjectDataSet projectDataSet)
 {
     DataAccess da = new DataAccess(projectUID);
     return da.GetProjectCurrentDate(projectDataSet, projectUID);
 }
Example #55
0
 private static Guid GetParentUIDForTask(DataRow inputTaskRow, ProjectDataSet.TaskRow taskRow,ProjectDataSet projectDataSet)
 {
     if(Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_OUTLINE_LEVEL"]].ToString()) == taskRow.TASK_OUTLINE_LEVEL)
     {
         return Guid.Empty;
     }
     if (Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_OUTLINE_LEVEL"]].ToString()) == 1)
     {
         return projectDataSet.Task.First(t => t.TASK_ID == 0).TASK_UID;
     }
     if (Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_OUTLINE_LEVEL"]].ToString()) < taskRow.TASK_OUTLINE_LEVEL)
     {
         return projectDataSet.Task.First(t => t.TASK_OUTLINE_LEVEL == (Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_OUTLINE_LEVEL"]].ToString()) - 1)).TASK_UID;
     }
     else
     {
         return projectDataSet.Task.First(t => t.TASK_OUTLINE_LEVEL == Convert.ToInt32(inputTaskRow[_mapping.TaskMap["TASK_OUTLINE_LEVEL"]].ToString())).TASK_UID;
     }
 }
Example #56
0
        public Guid CreateProject(ProjectDataSet projectDs,bool hasPlan,Guid planUID)
        {
            string projectName = projectDs.Project[0].PROJ_NAME;

            Console.WriteLine("Create project started for {0}", projectName);
            Guid jobGuid = Guid.NewGuid();
            //if (hasPlan)
            //{
            //    var projID = projectClient.CreateProjectFromTemplate(planUID, projectName);
            //    projectClient.QueuePublish(jobGuid, projID, true, string.Empty);
            //    if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectPublish
            //  ))
            //    {
            //        Console.WriteLine("Create project done successfully for {0}", projectName);
            //        projectDs = projectClient.ReadProject(projID,DataStoreEnum.PublishedStore);
            //    }
            //    else
            //    {
            //        Console.WriteLine("The project was not created due to queue error for : {0}", projectName);
            //    }
            //    return projID;
            //}
            //else
            //{
                projectClient.QueueCreateProject(jobGuid, projectDs, false);
                // Wait for the Project Server Queuing System to create the project.
                if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectCreate
                    ))
                {

                    jobGuid = Guid.NewGuid();

                }
                else
                {
                    Console.WriteLine("The project was not created due to queue error for : {0}", projectName);
                }
                return projectDs.Project[0].PROJ_UID;
            //}
        }
Example #57
0
        public static ProjectDataSet BuildProjectDataSetForUpdate(DataTable table, ProjectDataSet projectDataSet, 
            ProjectDataSet.ProjectRow projectRow, bool updateCustomFieldsnotrequired)
        {
            Console.WriteLine("Starting build project entities");
            Guid projectGuid = projectDataSet.Project[0].PROJ_UID;

            var inputProjectRow = table.Rows[0];

                BuildProject(inputProjectRow, projectRow, projectDataSet, projectGuid,updateCustomFieldsnotrequired);
            BuildTasks(table, projectDataSet, projectGuid);
            new Repository().UpdateProject(projectDataSet);
            Console.WriteLine("Build project entities done successfully");
            Console.WriteLine("Import of project done successfully for {0}", inputProjectRow[_mapping.ProjectMap["PROJ_NAME"]].ToString());
            return projectDataSet;
        }
Example #58
0
        public void UpdateProjectTeam(ProjectDataSet projectDs)
        {
            Guid projUid = projectDs.Project[0].PROJ_UID;
            string projectName = projectDs.Project[0].PROJ_NAME;
            Guid sessionId = Guid.NewGuid();
            Console.WriteLine("update project team started for {0}", projectName);
            //Read from the server the team that is present on the server for the project
            var projectTeam = projectClient.ReadProjectTeam(projUid);
            //For every resource read from the input file add to thye team if not already existing within the team
            foreach (var resource in projectDs.ProjectResource)
            {
                if (!projectTeam.ProjectTeam.Any(t => t.RES_NAME == resource.RES_NAME))
                {
                    var projectTeamRow = projectTeam.ProjectTeam.NewProjectTeamRow();
                    projectTeamRow.RES_UID = resource.RES_UID;
                    projectTeamRow.RES_NAME = resource.RES_NAME;
                    projectTeamRow.PROJ_UID = projUid;
                    projectTeamRow.NEW_RES_UID = resource.RES_UID;
                    projectTeam.ProjectTeam.Rows.Add(projectTeamRow);
                }
            }
            ProjectTeamDataSet teamDelta = new ProjectTeamDataSet();
            if (projectTeam.GetChanges(DataRowState.Added) != null)
            {
                projectClient.CheckOutProject(projUid, sessionId, "");
                teamDelta.Merge(projectTeam.GetChanges(DataRowState.Added));
                Guid jobGuid = Guid.NewGuid();
                projectClient.QueueUpdateProjectTeam(jobGuid, sessionId, projUid, teamDelta);
                if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectUpdateTeam))
                {
                    jobGuid = Guid.NewGuid();
                    projectClient.QueueCheckInProject(jobGuid, projUid, true, Guid.NewGuid(), "");
                    if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectCheckIn))
                    {
                        Console.WriteLine("update project team done successfully for {0}", projectName);
                    }
                    else
                    {
                        Console.WriteLine(
                                       "update project team done queue error for {0}", projectName);
                    }

                }
                else
                {
                    jobGuid = Guid.NewGuid();
                    projectClient.QueueCheckInProject(jobGuid, projUid, true, Guid.NewGuid(), "");
                    if (WaitForQueueJobCompletion(jobGuid, Guid.NewGuid(), (int)SvcQueueSystem.QueueMsgType.ProjectCheckIn))
                    {
                        Console.WriteLine("update project team done successfully for {0}", projectName);
                    }
                    else
                    {
                        Console.WriteLine(
                                       "update project team done queue error for {0}", projectName);
                    }
                    Console.WriteLine(
                                        "update project team done queue error for {0}", projectName);
                }
            }
            else
            {
                Console.WriteLine("update project team done successfully for {0}", projectName);
            }
        }
 public void ProcessModel(ProjectDataSet model, IConstraints constraints)
 {
     ProcessShifts(model.Shifts, constraints);
 }