Exemplo n.º 1
0
        //数据持久化
        internal static void  SaveToDb(ProjectLevelInfo pProjectLevelInfo, ProjectLevel pProjectLevel, bool pIsNew)
        {
            pProjectLevel.ProjectLevelId   = pProjectLevelInfo.projectLevelId;
            pProjectLevel.ProjectLevelName = pProjectLevelInfo.projectLevelName;
            pProjectLevel.IsNew            = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pProjectLevel.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(ProjectLevelInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pProjectLevelInfo.projectLevelId = pProjectLevel.ProjectLevelId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectLevelInfo)))
            {
                ResetCache();
            }
        }
Exemplo n.º 2
0
        private void CheckItemSelection()
        {
            // Enable / Disable node specific buttons
            button_Rename.Enabled         = treeView.SelectedNodes.Count > 0;
            button_Delete.Enabled         = treeView.SelectedNodes.Count > 0;
            button_MoveUp.Enabled         = treeView.SelectedNodes.Count > 0;
            button_MoveDown.Enabled       = treeView.SelectedNodes.Count > 0;
            button_OpenInExplorer.Enabled = treeView.SelectedNodes.Count > 0;

            // Set the SelectedLevel variable if a node is selected
            // Triggers IDE.SelectedLevelChangedEvent
            if (treeView.SelectedNodes.Count > 0)
            {
                ProjectLevel nodeLevel = (ProjectLevel)treeView.SelectedNodes[0].Tag;

                // Validation check
                if (!nodeLevel.IsValidLevel())
                {
                    treeView.SelectedNodes.Clear();
                    CheckItemSelection();                     // Recursion

                    RefreshLevelList();
                    return;
                }

                _ide.SelectedLevel = nodeLevel;
            }
            else
            {
                _ide.SelectedLevel = null;
            }
        }
Exemplo n.º 3
0
        private void CreateAndAddLevelToProject(string levelName, string levelFolderPath, string dataFileName, string specificFileName)
        {
            // Create the ProjectLevel instance
            ProjectLevel importedLevel = new ProjectLevel
            {
                Name         = levelName,
                FolderPath   = levelFolderPath,
                DataFileName = dataFileName,
                SpecificFile = specificFileName
            };

            UpdateLevelSettings(importedLevel);

            if (checkBox_GenerateSection.Checked)
            {
                int  ambientSoundID = (int)numeric_SoundID.Value;
                bool horizon        = checkBox_EnableHorizon.Checked;

                // // // //
                GeneratedScriptLines = LevelHandling.GenerateScriptLines(importedLevel, ambientSoundID, horizon);
                // // // //
            }

            // // // //
            ImportedLevel = importedLevel;
            // // // //
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <ProjectLevelInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <ProjectLevelInfo> list = new List <ProjectLevelInfo>();

            Query q = ProjectLevel.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            ProjectLevelCollection collection = new  ProjectLevelCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (ProjectLevel projectLevel  in collection)
            {
                ProjectLevelInfo projectLevelInfo = new ProjectLevelInfo();
                LoadFromDAL(projectLevelInfo, projectLevel);
                list.Add(projectLevelInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //专业类别
         ProjectTypes.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(56);
         ProjectTypes.DataTextField  = "ClassName";
         ProjectTypes.DataValueField = "ClassName";
         ProjectTypes.DataBind();
         ProjectTypes.Items.Insert(0, new ListItem("选择类型", ""));
         //级别
         ProjectLevel.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(58);
         ProjectLevel.DataTextField  = "ClassName";
         ProjectLevel.DataValueField = "ClassName";
         ProjectLevel.DataBind();
         ProjectLevel.Items.Insert(0, new ListItem("选择级别", ""));
         //部门
         Depart.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(52);
         Depart.DataTextField  = "ClassName";
         Depart.DataValueField = "ClassName";
         Depart.DataBind();
         Depart.Items.Insert(0, new ListItem("选择部门", ""));
         ProjectManager.Items.Insert(0, new ListItem("选择负责人", ""));
     }
 }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //设置只读权限
                if (Request.QueryString["type"] == "read")
                {
                    btn_submit.Visible = false;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "$(function(){$('input').attr('readonly', 'readonly');$('select').attr('disabled', 'true');$('textarea').attr('readonly', 'readonly');});", true);
                }

                //专业类别
                ProjectTypes.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(56);
                ProjectTypes.DataTextField  = "ClassName";
                ProjectTypes.DataValueField = "ClassName";
                ProjectTypes.DataBind();
                //级别
                ProjectLevel.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(58);
                ProjectLevel.DataTextField  = "ClassName";
                ProjectLevel.DataValueField = "ClassName";
                ProjectLevel.DataBind();
                //部门
                Depart.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(52);
                Depart.DataTextField  = "ClassName";
                Depart.DataValueField = "ClassName";
                Depart.DataBind();
                Depart.Items.Insert(0, new ListItem("选择部门", ""));

                Bind();
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //项目类别
                ProjectTypes.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(56);
                ProjectTypes.DataTextField  = "ClassName";
                ProjectTypes.DataValueField = "ClassName";
                ProjectTypes.DataBind();
                ProjectTypes.Items.Insert(0, new ListItem("选择项目类别", ""));
                //级别
                ProjectLevel.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(58);
                ProjectLevel.DataTextField  = "ClassName";
                ProjectLevel.DataValueField = "ClassName";
                ProjectLevel.DataBind();
                ProjectLevel.Items.Insert(0, new ListItem("选择项目级别", ""));

                //删除
                if (Request.QueryString["limit"] == "del")
                {
                    string ids   = Request.QueryString["id"].ToString();
                    int    count = WebCommon.Public.DataTableDel("tbl_Project", "id in(" + ids + ")");
                    if (count > 0)
                    {
                        WebCommon.Script.Redirect(WebCommon.Public.GetFromUrl());
                    }
                    else
                    {
                        WebCommon.Script.AlertAndGoBack("删除失败!");
                    }
                }
                //绑定列表
                Bind();
            }
        }
Exemplo n.º 8
0
 private void UpdateAllPrj2GameSettings(DirectoryInfo directory, ProjectLevel detectedLevel)
 {
     foreach (FileInfo file in directory.GetFiles("*.prj2", SearchOption.TopDirectoryOnly))
     {
         if (!ProjectLevel.IsBackupFile(file.Name))
         {
             LevelHandling.UpdatePrj2GameSettings(file.FullName, detectedLevel, _ide.Project);
         }
     }
 }
        private void EnableAndFillPrj2FileList()
        {
            treeView_AllPrjFiles.Enabled  = true;
            checkBox_ShowAllFiles.Enabled = true;

            // When the user switched the _ide.SelectedLevel and the current _ide.SelectedLevel 's SpecificFile is a backup file,
            // then check this checkbox, otherwise it will reset the SpecificFile to a non-backup file and we don't want that
            checkBox_ShowAllFiles.Checked = ProjectLevel.IsBackupFile(_ide.SelectedLevel.SpecificFile);

            UpdatePrj2FileList();
        }
Exemplo n.º 10
0
 public static List <string> GenerateScriptLines(ProjectLevel level, int ambientSoundID, bool horizon)
 {
     return(new List <string>
     {
         "\n[Level]",
         "Name= " + level.Name,
         "Level= DATA\\" + level.DataFileName.ToUpper() + ", " + ambientSoundID,
         "LoadCamera= 0, 0, 0, 0, 0, 0, 0",
         "Horizon= " + (horizon? "ENABLED" : "DISABLED")
     });
 }
Exemplo n.º 11
0
 public static ProjectLevelDto ToDto(this ProjectLevel l)
 {
     if (l == null)
     {
         return(null);
     }
     return(new ProjectLevelDto
     {
         Id = l.Id,
         Name = l.Name
     });
 }
Exemplo n.º 12
0
        private bool FolderOnlyContainsBackupFiles(DirectoryInfo directory)
        {
            foreach (FileInfo file in directory.GetFiles("*.prj2", SearchOption.TopDirectoryOnly))
            {
                if (!ProjectLevel.IsBackupFile(file.Name))
                {
                    return(false);                    // We got a non-backup file
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        public static List <string> GetValidPrj2FilesFromDirectory(string directoryPath)
        {
            List <string> validPrj2Files = new List <string>();

            foreach (string file in Directory.GetFiles(directoryPath, "*.prj2", SearchOption.AllDirectories))
            {
                if (!ProjectLevel.IsBackupFile(Path.GetFileName(file)))
                {
                    validPrj2Files.Add(file);
                }
            }

            return(validPrj2Files);
        }
Exemplo n.º 14
0
        private void ScanLevelsDirectory()
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(_ide.Project.LevelsPath);

            // Get all subdirectories of the project's /Levels/ folder
            DirectoryInfo[] levelDirectories = directoryInfo.GetDirectories();

            // Setup the progress bar
            progressBar.Maximum = levelDirectories.Length;

            foreach (DirectoryInfo directory in levelDirectories)
            {
                // Check if the folder we're currently scanning is already known for the project
                if (IsFolderKnownForProject(directory))
                {
                    progressBar.Increment(1);
                    continue;
                }

                // Scan all .prj2 files in the current directory (if there are any)
                if (directory.GetFiles("*.prj2", SearchOption.TopDirectoryOnly).Length > 0)
                {
                    // Check if the folder isn't just made up of backup files
                    if (FolderOnlyContainsBackupFiles(directory))
                    {
                        progressBar.Increment(1);
                        continue;
                    }

                    // Create a new ProjectLevel instance from the folder
                    ProjectLevel detectedLevel = new ProjectLevel
                    {
                        Name       = directory.Name,
                        FolderPath = directory.FullName
                    };

                    // Update the settings of all the .prj2 files in the folder to match the project settings
                    UpdateAllPrj2GameSettings(directory, detectedLevel);

                    _ide.Project.Levels.Add(detectedLevel);
                }

                progressBar.Increment(1);
            }

            CheckForFloatingPrj2Files(directoryInfo);

            DialogResult = DialogResult.OK;
        }
        private void checkBox_ShowAllFiles_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton_LatestFile.Checked)
            {
                return;
            }

            UpdatePrj2FileList();

            // If the user unchecked the checkBox and the SpecificFile was a backup file
            if (!checkBox_ShowAllFiles.Checked && ProjectLevel.IsBackupFile(_ide.SelectedLevel.SpecificFile))
            {
                treeView_AllPrjFiles.SelectNode(treeView_AllPrjFiles.Nodes[0]);                 // Select something else since the item is no longer on the list
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 保存
 /// </summary>
 public override void Save()
 {
     if (!m_Loaded)           //新增
     {
         ProjectLevel projectLevel = new ProjectLevel();
         SaveToDb(this, projectLevel, true);
     }
     else            //修改
     {
         ProjectLevel projectLevel = new ProjectLevel(projectLevelId);
         if (projectLevel.IsNew)
         {
             throw new AppException("该数据已经不存在了");
         }
         SaveToDb(this, projectLevel, false);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns>是否成功</returns>
        public override void Delete()
        {
            if (!m_Loaded)
            {
                throw new AppException("尚未初始化");
            }
            bool result = (ProjectLevel.Delete(ProjectLevelId) == 1);

            //更新缓存
            if (result && CachedEntityCommander.IsTypeRegistered(typeof(ProjectLevelInfo)))
            {
                ResetCache();
            }
            if (!result)
            {
                throw new AppException("删除失败,数据可能被删除");
            }
        }
Exemplo n.º 18
0
        private void UpdateAllPrj2FilesInLevelDirectory(ProjectLevel importedLevel)
        {
            string[] files = Directory.GetFiles(importedLevel.FolderPath, "*.prj2", SearchOption.TopDirectoryOnly);

            progressBar.Visible = true;
            progressBar.BringToFront();
            progressBar.Maximum = files.Length;

            foreach (string file in files)
            {
                if (!ProjectLevel.IsBackupFile(Path.GetFileName(file)))
                {
                    LevelHandling.UpdatePrj2GameSettings(file, importedLevel, _targetProject);
                }

                progressBar.Increment(1);
            }
        }
Exemplo n.º 19
0
        public static void UpdatePrj2GameSettings(string prj2FilePath, ProjectLevel destLevel, Project destProject)
        {
            Level level = Prj2Loader.LoadFromPrj2(prj2FilePath, null);

            string exeFilePath = Path.Combine(destProject.EnginePath, destProject.GetExeFileName());

            string dataFileName = destLevel.DataFileName + destProject.GetLevelFileExtension();
            string dataFilePath = Path.Combine(destProject.EnginePath, "data", dataFileName);

            level.Settings.LevelFilePath = prj2FilePath;

            level.Settings.GameDirectory          = level.Settings.MakeRelative(destProject.EnginePath, VariableType.LevelDirectory);
            level.Settings.GameExecutableFilePath = level.Settings.MakeRelative(exeFilePath, VariableType.LevelDirectory);
            level.Settings.GameLevelFilePath      = level.Settings.MakeRelative(dataFilePath, VariableType.LevelDirectory);
            level.Settings.GameVersion            = destProject.GameVersion;

            Prj2Writer.SaveToPrj2(prj2FilePath, level);
        }
        private void UpdatePrj2FileList()
        {
            treeView_AllPrjFiles.Nodes.Clear();

            foreach (string file in Directory.GetFiles(_ide.SelectedLevel.FolderPath, "*.prj2", SearchOption.TopDirectoryOnly))
            {
                // Don't show backup files if checkBox_ShowAllFiles is unchecked
                if (!checkBox_ShowAllFiles.Checked && ProjectLevel.IsBackupFile(Path.GetFileName(file)))
                {
                    continue;
                }

                // Create the .prj2 file node
                DarkTreeNode node = new DarkTreeNode
                {
                    Text = Path.GetFileName(file),
                    Tag  = file
                };

                // Add the node to the .prj2 file list
                treeView_AllPrjFiles.Nodes.Add(node);
            }

            // Select the SpecificFile node (if the file exists on the list)
            bool nodeFound = false;

            foreach (DarkTreeNode node in treeView_AllPrjFiles.Nodes)
            {
                if (node.Text.ToLower() == _ide.SelectedLevel.SpecificFile.ToLower())
                {
                    treeView_AllPrjFiles.SelectNode(node);
                    nodeFound = true;

                    break;
                }
            }

            if (!nodeFound)
            {
                treeView_AllPrjFiles.SelectNode(treeView_AllPrjFiles.Nodes[0]);                 // Select the first node if no file was found
            }
            treeView_AllPrjFiles.Invalidate();
        }
Exemplo n.º 21
0
 private void LoadFromId(int projectLevelId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectLevelInfo)))
     {
         ProjectLevelInfo projectLevelInfo = Find(GetList(), projectLevelId);
         if (projectLevelInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(projectLevelInfo, this);
     }
     else
     {
         ProjectLevel projectLevel = new ProjectLevel(projectLevelId);
         if (projectLevel.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, projectLevel);
     }
 }
Exemplo n.º 22
0
        private void DeleteLevel()
        {
            ProjectLevel affectedLevel = (ProjectLevel)treeView.SelectedNodes[0].Tag;

            // We can't allow deleting directories of external levels, so we must handle them differently

            // Internal level paths always start with the project's LevelsPath
            bool   isInternalLevel = affectedLevel.FolderPath.StartsWith(_ide.Project.LevelsPath, StringComparison.OrdinalIgnoreCase);
            string message;

            if (isInternalLevel)
            {
                message = "Are you sure you want to delete the \"" + affectedLevel.Name + "\" level?\n" +
                          "This will send the level folder with all its files into the recycle bin.";
            }
            else
            {
                message = "Are you sure you want to delete the \"" + affectedLevel.Name + "\" level from the list?\n" +
                          "Since this is an external level, this process will NOT affect the level folder nor its files.";
            }

            DialogResult result = DarkMessageBox.Show(this, message, "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (isInternalLevel)                 // Move the level folder into the recycle bin in this case
                {
                    FileSystem.DeleteDirectory(affectedLevel.FolderPath, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                }

                // Remove the node and clear selection
                treeView.SelectedNodes[0].Remove();
                treeView.SelectedNodes.Clear();
                CheckItemSelection();

                // Send the new list (without the removed node) into the .trproj file
                ReserializeTRPROJ();
            }
        }
Exemplo n.º 23
0
        private void OnLevelAdded(ProjectLevel addedLevel, List <string> scriptLines)
        {
            AddLevelToList(addedLevel, true);

            // Select the new level node
            foreach (DarkTreeNode node in treeView.Nodes)
            {
                if (((ProjectLevel)node.Tag).Name.ToLower() == addedLevel.Name.ToLower())
                {
                    treeView.SelectNode(node);
                    CheckItemSelection();

                    break;
                }
            }

            if (scriptLines != null && scriptLines.Count > 0)
            {
                _ide.ScriptEditor_AppendScriptLines(scriptLines);
                _ide.ScriptEditor_AddNewLevelString(addedLevel.Name);
            }
        }
Exemplo n.º 24
0
        private void AdjustTextOfAllNodes()
        {
            if (button_ViewFileNames.Checked)
            {
                foreach (DarkTreeNode node in treeView.Nodes)
                {
                    ProjectLevel nodeLevel = (ProjectLevel)node.Tag;

                    if (nodeLevel.SpecificFile == "$(LatestFile)")
                    {
                        node.Text = nodeLevel.Name + " (" + nodeLevel.GetLatestPrj2File() + ")";
                    }
                    else
                    {
                        node.Text = nodeLevel.Name + " (" + nodeLevel.SpecificFile + ")";
                    }

                    // Mark external levels
                    if (!nodeLevel.FolderPath.StartsWith(_ide.Project.LevelsPath, StringComparison.OrdinalIgnoreCase))
                    {
                        node.Text = _ide.IDEConfiguration.ExternalLevelPrefix + node.Text;
                    }
                }
            }
            else
            {
                foreach (DarkTreeNode node in treeView.Nodes)
                {
                    ProjectLevel nodeLevel = (ProjectLevel)node.Tag;
                    node.Text = nodeLevel.Name;

                    // Mark external levels
                    if (!nodeLevel.FolderPath.StartsWith(_ide.Project.LevelsPath, StringComparison.OrdinalIgnoreCase))
                    {
                        node.Text = _ide.IDEConfiguration.ExternalLevelPrefix + node.Text;
                    }
                }
            }
        }
Exemplo n.º 25
0
        private void UpdateLevelSettings(ProjectLevel importedLevel)
        {
            if (radioButton_SpecifiedCopy.Checked)
            {
                string specifiedFileName = Path.GetFileName(textBox_Prj2Path.Tag.ToString());
                string internalFilePath  = Path.Combine(importedLevel.FolderPath, specifiedFileName);

                LevelHandling.UpdatePrj2GameSettings(internalFilePath, importedLevel, _targetProject);
            }
            else if (radioButton_SelectedCopy.Checked)
            {
                UpdateAllPrj2FilesInLevelDirectory(importedLevel);
            }
            else if (radioButton_FolderKeep.Checked)
            {
                DialogResult result = DarkMessageBox.Show(this, "Do you want to update the \"Game\" settings of all the .prj2 files in the\n" +
                                                          "specified folder to match the project settings?", "Update settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    UpdateAllPrj2FilesInLevelDirectory(importedLevel);
                }
            }
        }
Exemplo n.º 26
0
        private void EnableAndFillTreeView()
        {
            treeView.Enabled           = true;
            button_SelectAll.Enabled   = true;
            button_DeselectAll.Enabled = true;

            treeView.Nodes.Clear();

            foreach (string file in Directory.GetFiles(textBox_Prj2Path.Text, "*.prj2", SearchOption.TopDirectoryOnly))
            {
                if (ProjectLevel.IsBackupFile(Path.GetFileName(file)))
                {
                    continue;
                }

                DarkTreeNode node = new DarkTreeNode
                {
                    Text = Path.GetFileName(file),
                    Tag  = file,
                };

                treeView.Nodes.Add(node);
            }
        }
Exemplo n.º 27
0
        private void ImportLevel()
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Title  = "Choose the .prj2 file you want to import";
                dialog.Filter = "Tomb Editor Levels|*.prj2";

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        if (dialog.FileName.StartsWith(_ide.Project.LevelsPath, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException("You cannot import levels which are already inside the project's /Levels/ folder.");
                        }

                        if (ProjectLevel.IsBackupFile(Path.GetFileName(dialog.FileName)))
                        {
                            throw new ArgumentException("You cannot import backup files.");
                        }

                        using (FormImportLevel form = new FormImportLevel(_ide.Project, dialog.FileName))
                        {
                            if (form.ShowDialog(this) == DialogResult.OK)
                            {
                                OnLevelAdded(form.ImportedLevel, form.GeneratedScriptLines);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 28
0
        private void AddLevelToList(ProjectLevel level, bool reserialize = false)
        {
            // Create the node
            DarkTreeNode node = new DarkTreeNode
            {
                Text = level.Name,
                Tag  = level
            };

            // Adjust the node text if button_ViewFileNames is checked
            if (button_ViewFileNames.Checked)
            {
                if (level.SpecificFile == "$(LatestFile)")
                {
                    node.Text = level.Name + " (" + level.GetLatestPrj2File() + ")";
                }
                else
                {
                    node.Text = level.Name + " (" + level.SpecificFile + ")";
                }
            }

            // Mark external levels
            if (!level.FolderPath.StartsWith(_ide.Project.LevelsPath, StringComparison.OrdinalIgnoreCase))
            {
                node.Text = _ide.IDEConfiguration.ExternalLevelPrefix + node.Text;
            }

            // Add the node to the list
            treeView.Nodes.Add(node);

            if (reserialize)
            {
                ReserializeTRPROJ();
            }
        }
Exemplo n.º 29
0
        public static DataTable getProjectLevel()
        {
            Query q = ProjectLevel.Query();

            return(q.ExecuteDataSet().Tables[0]);
        }
Exemplo n.º 30
0
 //数据持久化
 internal static void SaveToDb(ProjectLevelInfo pProjectLevelInfo, ProjectLevel  pProjectLevel,bool pIsNew)
 {
     pProjectLevel.ProjectLevelId = pProjectLevelInfo.projectLevelId;
      		pProjectLevel.ProjectLevelName = pProjectLevelInfo.projectLevelName;
     pProjectLevel.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pProjectLevel.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(ProjectLevelInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pProjectLevelInfo.projectLevelId = pProjectLevel.ProjectLevelId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectLevelInfo)))
     {
         ResetCache();
     }
 }
Exemplo n.º 31
0
 private void LoadFromId(int projectLevelId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectLevelInfo)))
     {
         ProjectLevelInfo projectLevelInfo=Find(GetList(), projectLevelId);
         if(projectLevelInfo==null)
             throw new AppException("未能在缓存中找到相应的键值对象");
         Copy(projectLevelInfo, this);
     }
     else
     {	ProjectLevel projectLevel=new ProjectLevel( projectLevelId);
         if(projectLevel.IsNew)
         throw new AppException("尚未初始化");
        	LoadFromDAL(this, projectLevel);
     }
 }
Exemplo n.º 32
0
 //从后台获取数据
 internal static void LoadFromDAL(ProjectLevelInfo pProjectLevelInfo, ProjectLevel  pProjectLevel)
 {
     pProjectLevelInfo.projectLevelId = pProjectLevel.ProjectLevelId;
      		pProjectLevelInfo.projectLevelName = pProjectLevel.ProjectLevelName;
     pProjectLevelInfo.Loaded=true;
 }
Exemplo n.º 33
0
 public async Task <IActionResult> CreatePrice(ProjectLevel model)
 {
     ViewData["Levels"] = _context.Levels.ToList();
     return(View());
 }
Exemplo n.º 34
0
 /// <summary>
 /// 保存
 /// </summary>
 public override void Save()
 {
     if(!m_Loaded)//新增
     {
         ProjectLevel projectLevel=new ProjectLevel();
         SaveToDb(this, projectLevel,true);
     }
     else//修改
     {
         ProjectLevel projectLevel=new ProjectLevel(projectLevelId);
         if(projectLevel.IsNew)
             throw new AppException("该数据已经不存在了");
         SaveToDb(this, projectLevel,false);
     }
 }