Ejemplo n.º 1
0
        private bool Copy_SubProject(int pProjectNo, int pProjectNo_Clone)
        {
            oCompServ  = (CompanyService)oCompany.GetCompanyService();
            pmgService = (ProjectManagementService)oCompServ.GetBusinessService(ServiceTypes.ProjectManagementService);
            PM_ProjectDocumentParams projectParam = (PM_ProjectDocumentParams)pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);

            projectParam.AbsEntry = pProjectNo;
            PM_ProjectDocumentData project = pmgService.GetProject(projectParam);

            try
            {
                List <int>            subproject_tmp   = new List <int>();
                List <int>            subproject_clone = new List <int>();
                Dictionary <int, int> mapping_sub      = new Dictionary <int, int>();
                int depth_lv_max = Get_Depth_Level_Subproject(pProjectNo);
                for (int depth_lv = 0; depth_lv <= depth_lv_max; depth_lv++)
                {
                    if (depth_lv == 0)
                    {
                        subproject_tmp = Get_AbsEntry_Subproject_List(pProjectNo);
                        foreach (int i in subproject_tmp)
                        {
                            PM_SubprojectDocumentParams tmp_subprojectpara = (PM_SubprojectDocumentParams)pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_SubprojectDocumentParams);
                            tmp_subprojectpara.AbsEntry = i;
                            PM_SubprojectDocumentData tmp_subproject = pmgService.GetSubproject(tmp_subprojectpara);
                            tmp_subproject.ProjectID = pProjectNo_Clone;
                            pmgService.AddSubproject(tmp_subproject);
                        }
                        subproject_clone = Get_AbsEntry_Subproject_List(pProjectNo_Clone);
                        for (int t = 0; t < subproject_tmp.Count; t++)
                        {
                            mapping_sub.Add(subproject_tmp.ToArray()[t], subproject_clone.ToArray()[t]);
                        }
                    }
                    else if (depth_lv > 0)
                    {
                        subproject_tmp = Get_AbsEntry_Subproject_List(pProjectNo, 0, depth_lv);
                        foreach (int i in subproject_tmp)
                        {
                            PM_SubprojectDocumentParams tmp_subprojectpara = (PM_SubprojectDocumentParams)pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_SubprojectDocumentParams);
                            tmp_subprojectpara.AbsEntry = i;
                            PM_SubprojectDocumentData tmp_subproject = pmgService.GetSubproject(tmp_subprojectpara);
                            tmp_subproject.ProjectID = pProjectNo_Clone;
                            tmp_subproject.ParentID  = mapping_sub[tmp_subproject.ParentID];
                            pmgService.AddSubproject(tmp_subproject);
                        }
                        subproject_clone = Get_AbsEntry_Subproject_List(pProjectNo_Clone, 0, depth_lv);
                        for (int t = 0; t < subproject_tmp.Count; t++)
                        {
                            mapping_sub.Add(subproject_tmp.ToArray()[t], subproject_clone.ToArray()[t]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                oApp.MessageBox(ex.Message);
                return(false);
            }
            return(true);
        }