public static void AddRemoveConf(string ConfName, string ConfDate, bool OpenForm, bool Remove)
        {
            IDbCommand command;
            try
            {
                string confName = ConfName;
                string confDate = ConfDate;
                if (OpenForm)
                {
                    var confForm = new ConfForm();
                    confForm.CName = confName;
                    confForm.CDate = confDate;
                    confForm.ShowDialog();

                    confName = confForm.CName;
                    confDate = confForm.CDate;
                }

                if (confName == null || confDate == null)
                    return;

                DbDataAdapter Adapter = DbProvider.GetDataAdapter("SELECT Conf_Name, Conf_Date FROM Conf", ORM.DB_University.connection);

                DataTable Table = new DataTable();
                Adapter.Fill(Table);

                var queriedItems = (from DataRow r in Table.AsEnumerable()
                                  select r[0].ToString().Trim() + ", " + r[1].ToString().Trim()).ToList();

                if (queriedItems.Exists(delegate(string d) { return d == confName + ", " + confDate; }))
                {
                    if (Remove)
                    {
                        command = DbProvider.GetCommand("DELETE FROM Conf WHERE (Conf_Name='" + confName + "' AND Conf_Date='" + confDate + "')", connection);
                        command.ExecuteNonQuery();
                        return;
                    }
                    MessageBox.Show("Entered conference is already exists", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (Remove)
                    return;
                command = DbProvider.GetCommand("INSERT INTO Conf VALUES('" + confName + "', '" + confDate + "')", connection);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
		/// <summary>
		/// 此接口是客户的接口,非常 重要,目前没有权限的控制
		/// </summary>
		/// <param name="confForm"> </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public com.baidu.disconf.web.web.config.dto.ConfigFullModel verifyConfForm(com.baidu.disconf.web.service.config.form.ConfForm confForm) throws Exception
		public virtual ConfigFullModel verifyConfForm(ConfForm confForm)
		{

			//
			// app
			//
			if (StringUtils.isEmpty(confForm.App))
			{
				throw new Exception("app is empty");
			}

			App app = appMgr.getByName(confForm.App);
			if (app == null)
			{
				throw new Exception("app " + confForm.App + " doesn't exist in db.");
			}

			//
			// env
			//
			if (StringUtils.isEmpty(confForm.Env))
			{
				throw new Exception("app is empty");
			}

			Env env = envMgr.getByName(confForm.Env);
			if (env == null)
			{
				throw new Exception("env " + confForm.Env + " doesn't exist in db.");
			}

			//
			// key
			//
			if (StringUtils.isEmpty(confForm.Key))
			{
				throw new Exception("key is empty");
			}

			//
			// version
			//
			if (StringUtils.isEmpty(confForm.Version))
			{
				throw new Exception("version is empty");
			}

			return new ConfigFullModel(app, env, confForm.Version, confForm.Key);
		}
Example #3
0
		/// <summary>
		/// 获取配置项 Item
		/// </summary>
		/// <param name="confForm">
		/// 
		/// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @NoAuth @RequestMapping(value = "/item", method = org.springframework.web.bind.annotation.RequestMethod.GET) @ResponseBody public com.baidu.disconf.core.common.json.ValueVo getItem(com.baidu.disconf.web.service.config.form.ConfForm confForm)
		public virtual ValueVo getItem(ConfForm confForm)
		{

			LOG.info(confForm.ToString());

			//
			// 校验
			//
			ConfigFullModel configModel = null;
			try
			{
				configModel = configValidator4Fetch.verifyConfForm(confForm);
			}
			catch (Exception e)
			{
				LOG.warn(e.ToString());
				return ConfigUtils.getErrorVo(e.Message);
			}

			return configFetchMgr.getConfItemByParameter(configModel.App.Id, configModel.Env.Id, configModel.Version, configModel.Key);
		}
Example #4
0
		/// <summary>
		/// 获取配置文件
		/// 
		/// @return
		/// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @NoAuth @RequestMapping(value = "/file", method = org.springframework.web.bind.annotation.RequestMethod.GET) @ResponseBody public org.springframework.http.HttpEntity<byte[]> getFile(com.baidu.disconf.web.service.config.form.ConfForm confForm)
		public virtual HttpEntity<sbyte[]> getFile(ConfForm confForm)
		{

			bool hasError = false;

			//
			// 校验
			//
			ConfigFullModel configModel = null;
			try
			{
				configModel = configValidator4Fetch.verifyConfForm(confForm);
			}
			catch (Exception e)
			{
				LOG.error(e.ToString());
				hasError = true;
			}

			if (hasError == false)
			{
				try
				{
					//
					Config config = configFetchMgr.getConfByParameter(configModel.App.Id, configModel.Env.Id, configModel.Version, configModel.Key, DisConfigTypeEnum.FILE);
					if (config == null)
					{
						hasError = true;
						throw new DocumentNotFoundException(configModel.Key);
					}

					return downloadDspBill(configModel.Key, config.Value);

				}
				catch (Exception e)
				{
					LOG.error(e.ToString());
				}
			}

			if (!string.ReferenceEquals(confForm.Key, null))
			{
				throw new DocumentNotFoundException(confForm.Key);
			}
			else
			{
				throw new DocumentNotFoundException("");
			}
		}