Exemple #1
0
        public void souldReturnFacsetSecuritiesWhenAddProject()
        {
            _projects = new ProjectCollection();

            var newProject = new ProjectTest.Builder()
                             .WithName("Facset")
                             .WithCode("ggn-001")
                             .Build();

            var expectedProject = new ProjectTest.Builder()
                                  .WithName("Facset-Securities")
                                  .WithCode("ggn-001")
                                  .Build();

            _projects.Add(newProject);

            Project firsElement;

            using (var e = _projects.GetEnumerator())
            {
                e.MoveNext();
                firsElement = e.Current;
            }

            Assert.True(firsElement.Name.Equals(expectedProject.Name));
        }
Exemple #2
0
        public ProjectCollection GetProjectsByUser(string userName)
        {
            ProjectCollection projects = new ProjectCollection();

            if (Directory.Exists(this.savedProjectsPath))
            {
                string[] files = Directory.GetFiles(this.savedProjectsPath, "*.xml");

                foreach (string filePath in files)
                {
                    string projectXml;

                    using (StreamReader reader = new StreamReader(filePath))
                    {
                        projectXml = reader.ReadToEnd();
                    }

                    try
                    {
                        Project project = this.Deserialize <Project>(projectXml);

                        projects.Add(project);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                    }
                }
            }

            return(projects);
        }
        /// <summary>
        /// Converts the <see cref="List{SqlProject}"/> to <see cref="ProjectCollection"/>.
        /// </summary>
        /// <param name="projects">The projects.</param>
        /// <returns>The <see cref="ProjectCollection"/>.</returns>
        public static ProjectCollection ConvertToProjects(List <SqlProject> projects, IMetadataLocator metadataLocator)
        {
            ProjectCollection projectCollection = new ProjectCollection();

            foreach (SqlProject sqlProject in projects)
            {
                projectCollection.Add(ConvertToProject(sqlProject, metadataLocator));
            }

            return(projectCollection);
        }
        /// <summary>
        /// Converts the <see cref="List{SqlProject}"/> to <see cref="ProjectCollection"/>.
        /// </summary>
        /// <param name="projects">The projects.</param>
        /// <returns>The <see cref="ProjectCollection"/>.</returns>
        public static ProjectCollection ConvertToProjects(List <SqlProject> projects)
        {
            ProjectCollection projectCollection = new ProjectCollection();

            foreach (SqlProject sqlProject in projects)
            {
                projectCollection.Add(ConvertToProject(sqlProject));
            }

            return(projectCollection);
        }
Exemple #5
0
        public void souldAddNewItemToCollection()
        {
            var newProject = new ProjectTest.Builder()
                             .WithName("Facset")
                             .WithCode("ggn-001")
                             .Build();

            _projects.Add(newProject);

            var expectedProjectsNumber = 1;

            Assert.Equal(expectedProjectsNumber, _projects.Count);
        }
        protected CollectionBase  GenerateProjectCollectionFromReader(IDataReader returnData)
        {
            ProjectCollection prjCollection = new ProjectCollection();

            while (returnData.Read())
            {
                Project prj = new Project((int)returnData["ProjectId"], (string)returnData["ProjectName"], (string)returnData["ProjectDescription"],
                                          (string)returnData["ProjectManagerDisplayName"], (string)returnData["ProjectCreatorDisplayName"], (DateTime)returnData["ProjectCreationDate"]);

                prjCollection.Add(prj);
            }
            return(prjCollection);
        }
        public ProjectCollection GetProjects()
        {
            DataTable         projectTable;
            ProjectCollection projectList;

            projectTable = MyDataServer.GetProjects();

            projectList = new ProjectCollection();
            for (int i = 0; i < projectTable.Rows.Count; i++)
            {
                projectList.Add(new Project((int)projectTable.Rows[i]["id"],
                                            projectTable.Rows[i]["identifier"].ToString()));
            }

            return(projectList);
        }
Exemple #8
0
        // 打包, 即复制到文件
        private void button_CopyToFile_Click(object sender, System.EventArgs e)
        {
            int nRet;
            // 当前已选择的node
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show(this, "尚未选择方案或者目录");
                return;
            }

            TreeNode node = treeView1.SelectedNode;
            if (node.ImageIndex == 0) // 目录
            {

            }
            else
            {
                string strProjectNamePath = node.FullPath;

                string strLocate = "";

                // 获得方案参数
                // strProjectNamePath	方案名,或者路径
                // return:
                //		-1	error
                //		0	not found project
                //		1	found
                nRet = scriptManager.GetProjectData(
                    strProjectNamePath,
                    out strLocate);
                if (nRet != 1)
                {
                    MessageBox.Show(this, "方案 " + strProjectNamePath + " 在ScriptManager中没有找到");
                    return;
                }

                string strPath;
                string strName;

                // 从完整的方案"名字路径"中,析出路径和名
                ScriptManager.SplitProjectPathName(strProjectNamePath,
                    out strPath,
                    out strName);

                Project project = null;

                try
                {
                    project = Project.MakeProject(
                         strProjectNamePath,
                         strLocate);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "MakeProject error : " + ex.Message);
                    return;
                }

                // 目前还允许host参数为空,这样软件不会加以检查
                string strHostName = project.GetHostName();
                if (string.IsNullOrEmpty(strHostName) == false
                    && strHostName != this.HostName)
                {
                    string strError = "拟导出的方案其(在metadata.xml定义的)宿主名为 '" + GetHostNameCaption(strHostName) + "', 不符合当前窗口的宿主名 '" + GetHostNameCaption(this.HostName) + "'。拒绝导出";
                    MessageBox.Show(this, strError);
                    return;
                }

                // 询问包文件全路径
                SaveFileDialog dlg = new SaveFileDialog();

                dlg.Title = "导出方案 -- 请指定要保存的文件名";
                dlg.CreatePrompt = true;
                dlg.FileName = strName + ".projpack";
                dlg.InitialDirectory = strRecentPackageFilePath == "" ?
                    Environment.GetFolderPath(Environment.SpecialFolder.Personal)
                    : strRecentPackageFilePath; //Environment.CurrentDirectory;
                dlg.Filter = "方案打包文件 (*.projpack)|*.projpack|All files (*.*)|*.*";
                dlg.RestoreDirectory = true;

                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                strRecentPackageFilePath = dlg.FileName;

                // Clipboard.SetDataObject(project);
                ProjectCollection array = new ProjectCollection();

                array.Add(project);

                ///
                //Opens a file and serializes the object into it in binary format.
                using (Stream stream = File.Open(dlg.FileName, FileMode.Create))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    formatter.Serialize(stream, array);
                }
            }
        }
Exemple #9
0
        public CategoryCollection GetCategories()
        {
            if (this._categories != null && this._categories.Count > 0)
            {
                return(this._categories);
            }

            Logger.Info("Loading all categories available in the configured templates");
            IList <TemplateModelCollection> collections = null;

            if (_templateFilesCollection == null || _templateFilesCollection.Count == 0)
            {
                collections = GetTemplateCollections();
            }

            Logger.Debug(String.Format("Number of collections to parse => {0}", collections.Count));


            this._categories    = new CategoryCollection();
            this._languageTypes = new LanguageTypeCollection();

            foreach (TemplateModelCollection collection in collections)
            {
                Logger.Debug("\n-----------------------------------START TEMPLATE COLLECTION-----------------------------------");

                Logger.Debug(String.Format("Current collection in the iterator has {0} templates", collection.Count));

                foreach (ITemplate template in collection)
                {
                    Logger.Debug("\n_______________________________START TEMPLATE______________________________________________");
                    Logger.Debug(String.Format("Processing template '{0}' to get unique Categories & LanguageTypes", template.Name));

                    ProjectCollection projects = new ProjectCollection();

                    Logger.Debug(String.Format("Current template in the iterator has {0} projects", template.Projects.Count));
                    foreach (IType projectType in template.Projects)
                    {
                        IProject project = new Project();
                        project.Name = projectType.DisplayName;
                        project.Icon = projectType.IconPath;

                        Logger.Debug(String.Format("Project's ('{0}') absolute Icon path provided [{1}]", project.Name,
                                                   this.TemplatePath + projectType.IconPath));

                        Logger.Debug("Project Icon has been loaded successfully");

                        projects.Add(project);

                        Logger.Debug(String.Format("Project '{0}' has been added to project collection", project.Name));
                    }

                    if (this._categories.Count == 0)
                    {
                        Logger.Info("Categories collection is empty, adding new categories now");

                        ILanguageType langType = new LanguageType();
                        langType.Name     = template.LanguageType;
                        langType.Projects = projects;
                        Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                        ICategory category = new Category();
                        category.Name = template.Category;
                        category.LanguageTypes.Add(langType);
                        Logger.Debug(String.Format("Found new Category '{0}'", category.Name));

                        this._categories.Add(category);

                        Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                        Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                    }
                    else
                    {
                        bool isCategoryAlreadyExist = this._categories.Contains(template.Category);

                        if (isCategoryAlreadyExist)
                        {
                            ICategory category = this._categories.find(template.Category);
                            bool      isLangTypeAlreadyExist = category.LanguageTypes.Contains(template.LanguageType);

                            if (isLangTypeAlreadyExist)
                            {
                                ILanguageType langType = category.LanguageTypes.find(template.LanguageType);
                                langType.Projects.AddRange(projects);
                                Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                            }
                            else
                            {
                                ILanguageType langType = new LanguageType();
                                langType.Name     = template.LanguageType;
                                langType.Projects = projects;

                                Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                                category.LanguageTypes.Add(langType);

                                Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                                Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                            }
                        }
                        else
                        {
                            ILanguageType langType = new LanguageType();
                            langType.Name     = template.LanguageType;
                            langType.Projects = projects;

                            Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                            ICategory category = new Category();
                            category.Name = template.Category;

                            Logger.Debug(String.Format("Found new Category '{0}'", category.Name));

                            category.LanguageTypes.Add(langType);

                            this._categories.Add(category);
                            Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                            Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                        }
                    }
                    Logger.Debug("_______________________________END TEMPLATE______________________________________________\n");
                }
                Logger.Debug("-----------------------------------END TEMPLATE COLLECTION-----------------------------------\n");
            }
            return(this._categories);
        }
 public HttpResponseMessage RetrieveTicketProjectList(string clientIds = null, int? includeId = null, bool? inactiveOnly = null, bool? nonProjectOnly = null, int? userId = null)
 {
     var ticketProjectsList = new ProjectCollection();
     var ticketProjectList = this.lookupService.RetrieveTicketProjectListItem(clientIds, includeId, inactiveOnly, nonProjectOnly, Convert.ToInt32(userId, CultureInfo.CurrentCulture));
     ticketProjectList.Where(a => !a.IsDoNotList).ToList().ForEach(ticketProject => ticketProjectsList.Add(MapToTicketProject(ticketProject)));
     return Request.CreateResponse(HttpStatusCode.OK, ticketProjectsList);
 }