コード例 #1
0
ファイル: OperateXML.cs プロジェクト: zjk537/ModelCollect
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CommendService commendService = new CommendService();
            commendService.Guid = txtGuid.Text.Trim();
            commendService.Name = txtName.Text.Trim();
            commendService.Enable = chkEnable.Checked;
            commendService.Description = txtDescription.Text.Trim();
            commendService.LogoUrl = txtLogoUrl.Text.Trim();
            BusinessType businessType = new BusinessType();
            businessType.Name = cboBusinessTypeName.Text.Trim();
            businessType.CommentService.Add(commendService);

            ResultInfo resultInfo = XMLManager.InserRecordIntoXml(path, businessType);
            if (!resultInfo.IsSuccessed)
            {
                MessageBox.Show(resultInfo.ReturnMessage, resultInfo.ReturnCode);
            }
        }
コード例 #2
0
ファイル: XMLManager.cs プロジェクト: zjk537/ModelCollect
 /// <summary>
 /// 创建服务节点
 /// </summary>
 /// <param name="xElementParent">该服务在父节点</param>
 /// <param name="commendService">服务实体</param>
 private static ResultInfo CreateCommendServiceNode(XElement xElementParent, CommendService commendService)
 {
     ResultInfo resultInfo = null;
     try
     {
         XElement newElement = new XElement("CommendService",
                                                   new XAttribute("Guid", commendService.Guid),
                                                   new XAttribute("Name", commendService.Name),
                                                   new XAttribute("Enable", commendService.Enable.ToString()),
                                                   new XAttribute("Description", commendService.Description),
                                                   new XAttribute("LogoUrl", commendService.LogoUrl)
                                                   );
         xElementParent.Element("CommendServices").Add(newElement);
         resultInfo = ResultInfoFactory<ResultInfo>.Create(true, "ServiceSuccessed", "服务节点 {0} 创建成功", commendService.Name);
     }
     catch (Exception ex)
     {
         resultInfo = ResultInfoFactory<ResultInfo>.Create(false, "ServiceException", "服务节点 {0} 创建时异常:\r\t{1}", commendService.Name, ex.Message);
     }
     return resultInfo;
 }