public CoreSection() { StartPaused = new ConfigItem<bool>(false); WatchDirectories = new ConfigItem<string[]>(new string[] {}); BuildExecutables = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); NUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); MSTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); XUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); MSpecTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); CodeEditor = new ConfigItem<CodeEditor>(new CodeEditor("", "")); DebuggingEnabled = new ConfigItem<bool>(false); MSBuildAdditionalParameters = new ConfigItem<string>(""); MSBuildParallelBuildCount = new ConfigItem<int>(0); GrowlNotify = new ConfigItem<string>(null); NotifyOnRunStarted = new ConfigItem<bool>(true); NotifyOnRunCompleted = new ConfigItem<bool>(true); WatchIgnoreFile = new ConfigItem<string>(""); TestAssembliesToIgnore = new ConfigItem<string[]>(new string[] {}); TestCategoriesToIgnore = new ConfigItem<string[]>(new string[] {}); FileChangeBatchDelay = new ConfigItem<int>(100); CustomOutputPath = new ConfigItem<string>(""); RerunFailedTestsFirst = new ConfigItem<bool>(false); WhenWatchingSolutionBuildSolution = new ConfigItem<bool>(true); UseAutoTestTestRunner = new ConfigItem<bool>(true); UseLowestCommonDenominatorAsWatchPath = new ConfigItem<bool>(true); WatchAllFiles = new ConfigItem<bool>(false); RunAssembliesInParallel = new ConfigItem<bool>(false); TestRunnerCompatibilityMode = new ConfigItem<bool>(false); LogRecycleSize = new ConfigItem<long>(1024000); ProjectsToIgnore = new ConfigItem<string[]>(new string[] {}); Keys = new List<KeyValuePair<string, string>>(); DataGathererServiceUrl = new ConfigItem<string>(""); }
public CoreSection() { StartPaused = new ConfigItem<bool>(false); WatchDirectories = new ConfigItem<string[]>(new string[] {}); BuildExecutables = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); NUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); MSTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); XUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); MSpecTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); CodeEditor = new ConfigItem<CodeEditor>(new CodeEditor("", "")); DebuggingEnabled = new ConfigItem<bool>(false); GrowlNotify = new ConfigItem<string>(null); NotifyOnRunStarted = new ConfigItem<bool>(true); NotifyOnRunCompleted = new ConfigItem<bool>(true); WatchIgnoreFile = new ConfigItem<string>(""); TestAssembliesToIgnore = new ConfigItem<string[]>(new string[] {}); TestCategoriesToIgnore = new ConfigItem<string[]>(new string[] {}); FileChangeBatchDelay = new ConfigItem<int>(100); CustomOutputPath = new ConfigItem<string>(""); RerunFailedTestsFirst = new ConfigItem<bool>(false); WhenWatchingSolutionBuildSolution = new ConfigItem<bool>(true); UseAutoTestTestRunner = new ConfigItem<bool>(true); UseLowestCommonDenominatorAsWatchPath = new ConfigItem<bool>(true); Keys = new List<KeyValuePair<string, string>>(); }
public Grid2DConfig(ConfigNode config) { _config = config; _all2allEn = new ConfigItem<bool>(_config, "All2AllEnable", true); _verticalLinesEn = new ConfigItem<bool>(_config, "VerticalLinesEnable", true); _horizontalLinesEn = new ConfigItem<bool>(_config, "HorizontalLinesEnable", true); _ringsEn = new ConfigItem<bool>(_config, "RingsEnable", true); _littleSquaresEn = new ConfigItem<bool>(_config, "LittleSquaresEnable", true); }
public TrainingConfig(ConfigNode config) { _config = config; _gaussian = new NormalGenerator(0.0, 0.5); _basic = new BasicConfig(config); _autoTrainingEpochs = new ConfigItem<int>(_config, "AutoTrainingEpochs", 400); _autoTrainingAttempts = new ConfigItem<int>(_config, "AutoTrainingAttempts", 1); _autoTrainingPercentSuccessful = new ConfigItem<double>(_config, "AutoTrainingPercentSuccessful", 1.0); _shuffleSwapProbability = new ConfigItem<double>(_config, "ShuffleSwapProbability", 0.05); _shuffleNoiseSigma = new ConfigItem<double>(_config, "ShuffleNoiseSigma", 0.5); _shuffleEn = new ConfigItem<bool>(_config, "ShuffleEnable", false); }
public Configuration() { GraphProvider = new ConfigItem<string>(); MinimizerDebug = new ConfigItem<bool>(); MinimizerAssemblies = new List<ConfigItem<string>>(); MinimizerLevel = new ConfigItem<string>(); ProfilerSetup = new ConfigItem<string>(); ProfilerNamespaces = new List<ConfigItem<string>>(); IgnoreWarmup = new ConfigItem<bool>(); IgnoreThisUpgrade = new ConfigItem<string>(); RealtimeFeedback = new ConfigItem<bool>(); AllDisabled = new ConfigItem<bool>(); AnonFeedback = new ConfigItem<bool>(); BuildErrorsInFeedbackWindow = new ConfigItem<bool>(); BuildWarningsInFeedbackWindow = new ConfigItem<bool>(); FailingTestsInFeedbackWindow = new ConfigItem<bool>(); IgnoredTestsInFeedbackWindow = new ConfigItem<bool>(); StartPaused = new ConfigItem<bool>(); MSBuild = new List<ConfigItem<VersionConfig>>(); BuildSolution = new ConfigItem<bool>(); NUnit = new List<ConfigItem<VersionConfig>>(); MSTest = new List<ConfigItem<VersionConfig>>(); XUnit = new List<ConfigItem<VersionConfig>>(); IgnoreFile = new ConfigItem<IgnoreFile> { Item = new IgnoreFile() }; IgnoredAssemblies = new List<ConfigItem<string>>(); IgnoredCategories = new List<ConfigItem<string>>(); ChangeDelay = new ConfigItem<string>(); BuildOutputPath = new ConfigItem<string>(); GrowlNotifyPath = new ConfigItem<string>(); NotifyOnStartup = new ConfigItem<bool>(); NotifyOnFinish = new ConfigItem<bool>(); Debug = new ConfigItem<bool>(); CatMode = new ConfigItem<bool>(); OverlayNotifications = new ConfigItem<bool>(); RunAssembliesInParallel = new ConfigItem<bool>(); RunTestsInCompatibilityMode = new ConfigItem<bool>(); RiscEnabled = new ConfigItem<bool>(); MSBuildParallelBuildCount = new ConfigItem<int>(); }
private bool InitVariables() { if (_actionType == "edit") { _configItem = ConfigServer.GetConfigItem(_id); if (_configItem == null) return false; } if (!string.IsNullOrEmpty(_parentId)) { _parentConfigItem = ConfigServer.GetConfigItem(_parentId); if (_parentConfigItem == null) return false; } return true; }
public CoreSection() { WatchDirectories = new ConfigItem<string[]>(new string[] {}); BuildExecutables = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); NUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); MSTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); XUnitTestRunner = new ConfigItem<KeyValuePair<string, string>[]>(new KeyValuePair<string, string>[] {}); CodeEditor = new ConfigItem<CodeEditor>(new CodeEditor("", "")); DebuggingEnabled = new ConfigItem<bool>(false); GrowlNotify = new ConfigItem<string>(null); NotifyOnRunStarted = new ConfigItem<bool>(true); NotifyOnRunCompleted = new ConfigItem<bool>(true); WatchIgnoreFile = new ConfigItem<string>(""); TestAssembliesToIgnore = new ConfigItem<string[]>(new string[] {}); TestCategoriesToIgnore = new ConfigItem<string[]>(new string[] {}); FileChangeBatchDelay = new ConfigItem<int>(100); }
public string ReadConfig(ConfigItem Item,out string a,out bool b) { try { HasConfig();//没有配置文件就新建 AMSystemConfig tmpConfig = new AMSystemConfig(); AuthDao.ADSecret ads = new AuthDao.ADSecret(); string FileName = Environment.CurrentDirectory + "\\Config.dat"; Stream fStr = new FileStream(FileName, FileMode.Open); fStr.Position = 0; BinaryFormatter bf = new BinaryFormatter(); tmpConfig = (AMSystemConfig)bf.Deserialize(fStr); fStr.Close(); tmpConfig.ConnectionString = ads.DesDecrypt(tmpConfig.ConnectionString, "JinDi123"); switch (Item) { case ConfigItem.ConnectionString: a = tmpConfig.ConnectionString; b = false; break; case ConfigItem.LoginUserName: a = tmpConfig.LoginUserNames; b = false; break; case ConfigItem.LoginPassword: a = tmpConfig.LoginPassword; b = tmpConfig.LoginSavePass; break; default: a = ""; b = false; break; } return "true"; } catch (Exception x) { a = ""; b = false; return "ReadConfig:" + x.Message; } }
public void Read(string configFile) { if (!tryLoadXml(configFile)) return; WatchDirectories = getValues("configuration/DirectoryToWatch", false); BuildExecutables = getVersionedSetting("configuration/BuildExecutable"); NUnitTestRunner = getVersionedSetting("configuration/NUnitTestRunner"); MSTestRunner = getVersionedSetting("configuration/MSTestRunner"); XUnitTestRunner = getVersionedSetting("configuration/XUnitTestRunner"); CodeEditor = getCodeEditor(); DebuggingEnabled = getBoolItem("configuration/Debugging", false); GrowlNotify = getValueItem("configuration/growlnotify", null); NotifyOnRunStarted = getBoolItem("configuration/notify_on_run_started", true); NotifyOnRunCompleted = getBoolItem("configuration/notify_on_run_completed", true); WatchIgnoreFile = getValueItem("configuration/IgnoreFile", ""); TestAssembliesToIgnore = getValues("configuration/ShouldIgnoreTestAssembly/Assembly", true); TestCategoriesToIgnore = getValues("configuration/ShouldIgnoreTestCategories/Category", true); FileChangeBatchDelay = getIntItem("configuration/changedetectiondelay", 100); }
private void writeIgnoreFileSetting(ConfigItem<IgnoreFile> item) { RemoveNode("IgnoreFile"); if (item.Exists) writeSimpleSetting(item.Item.File, true, item.ShouldExclude, "IgnoreFile"); try { if (item.Item.WriteContent) { if (Directory.Exists(Path.GetDirectoryName(item.Item.File)) && Path.IsPathRooted(item.Item.File)) File.WriteAllText(item.Item.File, item.Item.Content); else if (Directory.Exists(item.Item.ContentPath)) File.WriteAllText(Path.Combine(item.Item.ContentPath, item.Item.File), item.Item.Content); } } catch (Exception ex) { Logging.Logger.Write(ex); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { ConfigServer.RemoveConfigItem(_id); if (string.IsNullOrEmpty(_parentId)) { _backUrl = string.Format("ViewTopLevelConfigItemList.aspx?appName={0}", _appName); } else { ConfigItem parentConfigItem = ConfigServer.GetConfigItem(_parentId); _backUrl = string.Format("ViewConfigItemList.aspx?appName={0}&parentPathItemNames={1}&prevParentId={2}&parentId={3}", _appName, _parentPathItemNames, parentConfigItem.ParentId, _parentId); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "error", "alert('删除失败,请稍后再试!')", true); LocalLoggingService.Error(string.Format("删除配置项失败!异常:{0}", ex)); return; } Response.Redirect(_backUrl); }
private void SaveConfigItem() { try { ConfigServer.SaveConfigItem(_id, _friendlyName, _desc, _value); if (string.IsNullOrEmpty(_parentId)) { _backUrl = string.Format("ViewTopLevelConfigItemList.aspx?appName={0}", _appName); } else { ConfigItem parentConfigItem = ConfigServer.GetConfigItem(_parentId); _backUrl = string.Format("ViewConfigItemList.aspx?appName={0}&parentPathItemNames={1}&prevParentId={2}&parentId={3}", _appName, _parentPathItemNames, parentConfigItem.ParentId, _parentId); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "error", "alert('保存失败,请稍后再试!')", true); LocalLoggingService.Error(string.Format("保存配置项失败!异常:{0}", ex)); return; } Response.Redirect(_backUrl); }
private void SeedConfigItems(MockReleaseRepository repository) { var product_a_specification = new ConfigItem(); product_a_specification.Id = "product_a_specification"; product_a_specification.Name = "《产品A需求说明书V1.0.0》"; product_a_specification.Desc = "..."; repository.ConfigItems.Add(product_a_specification); var product_a_server = new ConfigItem(); product_a_server.Id = "product_a_server"; product_a_server.Name = "产品A服务器"; product_a_server.Desc = "..."; repository.ConfigItems.Add(product_a_server); var log_server = new ConfigItem(); log_server.Id = "log_server"; log_server.Name = "日志服务器"; log_server.Desc = "..."; repository.ConfigItems.Add(log_server); }
private void RemoveCofig(string relaPath) { if (string.IsNullOrEmpty(relaPath)) { return; } if (_configDict == null) { return; } ConfigItem item = null; if (_configDict.TryGetValue(relaPath, out item)) { if (_selectedItem == item) { _selectedItem = null; } } _configDict.Remove(relaPath); }
public static void Backup(ConfigItem p_ConfigItem, string path) { COREBASE.COMMAND.SQL.AccessSQL _sql = new COREBASE.COMMAND.SQL.AccessSQL(p_ConfigItem); try { string[] arrParaName = new string[] { "@Path" }; string[] arrParaValue = new string[] { path }; _sql.Connect(p_ConfigItem); _sql.ExecuteNonQuery("[USP_SYS_BACKUP]", arrParaName, arrParaValue); } catch (Exception ex) { throw ex; } finally { _sql.Disconnect(); } }
public static DataTable GetListRoleByUID(ConfigItem p_ConfigItem, object[] arrValue) { DataTable dt = null; COREBASE.COMMAND.SQL.AccessSQL _sql = new COREBASE.COMMAND.SQL.AccessSQL(p_ConfigItem); try { string[] arrParaName = new string[] { "@UserId" }; _sql.Connect(p_ConfigItem); dt = _sql.GetDataByStoredProcedure("USP_SEL_USER_ROLE_ByUser", arrParaName, arrValue); } catch (Exception ex) { throw ex; } finally { _sql.Disconnect(); } return(dt); }
/************/ public ConfigItem SaveItem(ConfigItem pConfig) { SqlCommand cmd = new SqlCommand(); int vResultado = -1; try { AbrirConexion(); cmd = CrearComando("SGRC_SP_ConfigItem_Save"); cmd.Parameters.AddWithValue("@ConfigItemId", pConfig.ConfigItemID); cmd.Parameters.AddWithValue("@ConfigId", pConfig.ConfigID); cmd.Parameters["@ConfigItemId"].Direction = ParameterDirection.InputOutput; //Se indica que el IdAlmacen sera un parametro de Entrada/Salida. cmd.Parameters.AddWithValue("@Descripcion", pConfig.ConfigItemDescripcion); cmd.Parameters.AddWithValue("@Observacion", pConfig.ConfigItemObservacion); cmd.Parameters.AddWithValue("@Abreviatura", pConfig.ConfigItemAbreviatura); cmd.Parameters.AddWithValue("@Estado", pConfig.Estado); cmd.Parameters.AddWithValue("@saved", 1); Ejecuta_Accion(ref cmd); vResultado = Convert.ToInt32(cmd.Parameters["@saved"].Value); } catch (Exception Ex) { pConfig.Mensaje = Ex.Message.ToString(); throw new Exception("Ocurrio un error al guardar un item: " + Ex.Message, Ex); } pConfig.Accion = vResultado; if (vResultado == 0) { pConfig.Mensaje = "Se genero un error al insertar el item!"; } else { pConfig.Mensaje = "Se ingreso un item correctamente!"; } return(pConfig); }
/// <summary> /// 返回节点 /// </summary> /// <param name="psType"></param> /// <param name="psName"></param> /// <param name="psValue"></param> /// <returns></returns> private void AddExtTreeNode(Node nd, DataTable dt) { Node nd1 = new Node(); string typeS = dt.Rows[0]["PSType2"].ToString(); double PDTotalData = 0; for (int i = 0; i < dt.Rows.Count; i++) { Node ndx = new Node(); ndx.Leaf = true; string PSType2 = dt.Rows[i]["PSType2"].ToString(); string PSName = dt.Rows[i]["PSName"].ToString(); double db1 = Convert.ToDouble(dt.Rows[i]["PDBaseData"]); double db2 = Convert.ToDouble(dt.Rows[i]["PDProjectData"]); double PDData = db1 + db2; PDTotalData += PDData; ConfigItem cf1 = new ConfigItem("PSType2", PSType2, ParameterMode.Value); ConfigItem cf2 = new ConfigItem("PSName", PSName, ParameterMode.Value); ConfigItem cf3 = new ConfigItem("PDData", PDData.ToString("f8").TrimEnd('0'), ParameterMode.Value); ndx.CustomAttributes.Add(cf1); ndx.CustomAttributes.Add(cf2); ndx.CustomAttributes.Add(cf3); nd1.Children.Add(ndx); } ConfigItem cft1 = new ConfigItem("PSType2", typeS, ParameterMode.Value); ConfigItem cft2 = new ConfigItem("PSName", "", ParameterMode.Value); ConfigItem cft3 = new ConfigItem("PDData", PDTotalData.ToString("f8").TrimEnd('0'), ParameterMode.Value); nd1.CustomAttributes.Add(cft1); nd1.CustomAttributes.Add(cft2); nd1.CustomAttributes.Add(cft3); nd.Children.Add(nd1); }
/// <summary> /// 从本地配置获取值 /// </summary> /// <param name="key">键,不区分大小写</param> /// <param name="defaultValue">获取不到返回的默认值</param> /// <param name="exceptionHandler">异常处理</param> /// <returns></returns> public static string GetLocalConfigString(string key, string defaultValue = "", Action <Exception> exceptionHandler = null) { try { var keyList = _localConfigDicts.Keys.ToList(); string actualKey = null;//实际的键 foreach (var item in keyList) { if (StringUtils.EqualsEx(key, item)) { actualKey = item; break; } } if (string.IsNullOrEmpty(actualKey)) { return(defaultValue); } ConfigItem configItem = null; if (_localConfigDicts.TryGetValue(actualKey, out configItem) && configItem != null) { return(StringUtils.TrimEx(configItem.ConfigValue)); } else { return(defaultValue); } } catch (Exception e) { exceptionHandler?.Invoke(e); return(defaultValue); } }
/// <summary> /// Desabilita todos os controles da collection passada como parâmetro (recursivo, todos os níveis de cotnrole) /// </summary> /// <param name="pControles">Coleção de controle</param> public void DesabilitarControlCollection(ControlCollection pControles) { //ConfigItem para acionar a função para travar checkbox e radiobox ConfigItem ci = new ConfigItem(); ci.Name = "onClick"; ci.Value = "function (e) {if ((this.el.dom.checked != this.checked) && !this.readOnly) { this.setValue(this.el.dom.checked); } e.stopEvent(); }"; ci.Mode = ParameterMode.Raw; //Desabilita controles for (int k = 0; k < pControles.Count; k++) { foreach (System.Web.UI.Control ctl in pControles[k].Controls) { /*if (ctl.Controls.Count == 0) * {*/ if (ctl.Parent is Ext.Net.FormPanel || ctl.Parent is Ext.Net.TabPanel || ctl.Parent is Ext.Net.Panel || ctl.Parent is Ext.Net.Container || ctl.Parent is Ext.Net.FormLayout) { DesabilitarControlCollection(ctl.Parent.Controls); } DesabilitarControleTipo(ci, ctl.Parent); /*} * else * { * if (ctl is Ext.Net.FormPanel || ctl is Ext.Net.TabPanel || ctl is Ext.Net.Panel || ctl is Ext.Net.Container || ctl is Ext.Net.FormLayout) * { * DesabilitarControles(ctl.Controls); * } * * DesabilitarControleTipo(ci, ctl); * }*/ } } }
/// <summary> /// Gets items that are missing. /// </summary> /// <param name="find"></param> /// <returns></returns> protected IDictionary GetMissingItems(IDictionary find) { if (find == null) { throw new ArgumentNullException("find"); } // does the table exist? IDictionary results = CollectionsUtil.CreateCaseInsensitiveHashtable(); if (ConfigItem.DoesTableExist()) { // find it... foreach (DictionaryEntry entry in find) { string name = (string)entry.Key; // existing? ConfigItem item = ConfigItem.GetByName(name); if (item == null) { results[name] = entry.Value; } } } else { // copy it... foreach (DictionaryEntry entry in find) { results[entry.Key] = entry.Value; } } // return... return(results); }
public ConfigItem DelItem(string ConfigId, string ConfigItemId) { SqlCommand cmd = new SqlCommand(); ConfigItem vResultado = new ConfigItem(); int vControl = -1; try { cmd = CrearComando("SGRC_SP_ConfigItem_Del"); cmd.Parameters.AddWithValue("@ConfigId", ConfigId); cmd.Parameters.AddWithValue("@ConfigItemId", ConfigItemId); AbrirConexion(); vControl = Ejecuta_Accion(ref cmd); if (vControl > 0) { vResultado.Accion = 1; vResultado.Mensaje = "Se elimino con exito el item!"; vResultado.ConfigItemID = ConfigItemId; } } catch (Exception ex) { vResultado.Accion = 1; vResultado.Mensaje = ex.Message.ToString(); vResultado.ConfigItemID = ConfigItemId; throw new Exception("No se pudo eliminar el registro por el siguiente error: " + ex.Message, ex); } finally { cmd.Dispose(); CerrarConexion(); } return(vResultado); }
public static int Insert(ConfigItem p_configItem, DataRow p_drGroup) { COREBASE.COMMAND.SQL.AccessSQL l_sql = new COREBASE.COMMAND.SQL.AccessSQL(p_configItem); try { string[] l_arrName = new string[] { "@Name", "@Crt_By", "@Remark", "@ID_Cat" }; object[] l_arrValue = new object[] { p_drGroup["Name"], p_configItem.Login_UserName, p_drGroup["Remark"], p_drGroup["Id_Cat"] }; l_sql.Connect(p_configItem); return(l_sql.ExecuteInsert("USP_INS_GROUP", l_arrName, l_arrValue)); } catch (Exception ex) { throw ex; } finally { l_sql.Disconnect(); } }
private void treeStore_ReadData(object sender, NodeLoadEventArgs e) { IList <Xinchen.ExtNetBase.TreePanelEx.Node> nodeItems = this._nodeHelper.GetNodeItems(Convert.ToInt32(e.ExtraParams["parentId"])); foreach (Xinchen.ExtNetBase.TreePanelEx.Node node in nodeItems) { Ext.Net.Node node2 = new Ext.Net.Node { Text = node.Name, NodeID = node.Id.ToString(), Leaf = false, AllowDrag = true, AllowDrop = true }; ConfigItem item = new ConfigItem { Name = "Id", Value = node2.NodeID }; node.CustomAttributes.Add(item); ConfigItem parameters = new ConfigItem { Name = "Name", Value = node2.Text }; ConfigItem item3 = new ConfigItem { Name = "ParentId", Value = node.ParentId.ToString() }; node2.CustomAttributes.Add(parameters); node2.CustomAttributes.Add(item3); node2.CustomAttributes.AddRange(node.CustomAttributes); e.Nodes.Add(node2); } }
public static bool DeleteDetail(ConfigItem p_ConfigItem, DataRow p_drValue) { bool l_rs = false; COREBASE.COMMAND.SQL.AccessSQL _sql = new COREBASE.COMMAND.SQL.AccessSQL(p_ConfigItem); string[] arrParaName = new string[] { "@Id", "@Crt_By" }; object[] arrParaValue = new object[] { p_drValue["Id"], p_ConfigItem.Login_ID }; try { _sql.Connect(p_ConfigItem); _sql.ExecuteNonQuery("USP_DEL_TAKE_OUT_DETAIL", arrParaName, arrParaValue); l_rs = true; } catch (Exception ex) { l_rs = false; throw ex; } finally { _sql.Disconnect(); } return(l_rs); }
public JsonResult CheckOneItem(string idConfig, string id, string descripcion, string abreviatura) { ConfigItem obj = new ConfigItem(); ConfigRepository ConfigRep = new ConfigRepository(); try { if (descripcion != "" || id != "" || abreviatura != "") { obj = ConfigRep.CheckConfigItem(idConfig, id, descripcion, abreviatura); } else { obj.Accion = 0; obj.Mensaje = "El parámetro tiene un valor incorrecto!"; } } catch (Exception ex) { obj.Accion = 0; obj.Mensaje = ex.Message.ToString(); } return(Json(obj, JsonRequestBehavior.AllowGet)); }
private void ShowConfigList() { EditorGUILayout.BeginVertical(); _destSearchTextField.OnGUI(); _scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2, (GUIStyle)"Config List"); foreach (var item in _configList) { string fileName = Path.GetFileName(item.path); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(fileName, GUILayout.Width(250))) { _selectedItem = item; } if (GUILayout.Button("<<", GUILayout.Width(20))) { _removeQueue.Enqueue(item.path); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public List <ConfigItem> GetConfigList(string env, string group) { List <ConfigItem> list = new List <ConfigItem>(); StringBuilder builder = new StringBuilder(); builder.AppendFormat(ConfigSqls.SELECT_CONFIG, env, group); string sql = builder.ToString(); DataTable dt = DatabaseOperationWeb.ExecuteSelectDS(sql, "T").Tables[0]; if (dt != null) { foreach (DataRow dr in dt.Rows) { ConfigItem ConfigItem = new ConfigItem { key = dr["CONFIG_KEY"].ToString(), value = dr["CONFIG_VALUE"].ToString(), }; list.Add(ConfigItem); } } return(list); }
/// <summary> /// 递归产生系统表树形菜单节点 /// </summary> /// <param name="allNodeTable"></param> /// <param name="parentColValue"></param> /// <param name="root"></param> /// <param name="ParentNode"></param> private void Addree(DataTable allNodeTable, string parentColValue, Ext.Net.TreeNode root, Ext.Net.TreeNode ParentNode)//Ext.Net.TreeNode ParentNode { try { DataRow[] myDataRows = allNodeTable.Select("1=1"); foreach (DataRow myDataRow in myDataRows) { Ext.Net.TreeNode node = new Ext.Net.TreeNode(); ConfigItem ci0 = new ConfigItem("col0", myDataRow[0].ToString(), ParameterMode.Value); ConfigItem ci1 = new ConfigItem("col1", myDataRow[1].ToString(), ParameterMode.Value); node.Text = myDataRow[1].ToString() + "(" + GetCount(myDataRow[0].ToString()) + ")"; node.NodeID = myDataRow[0].ToString(); node.Leaf = true; node.Draggable = true; node.Expandable = ThreeStateBool.True; node.Expanded = false; node.Icon = Icon.Car; node.Listeners.Click.Handler = "selectNode('" + myDataRow[0].ToString() + "') ;"; node.CustomAttributes.Add(ci0); node.CustomAttributes.Add(ci1); root.Nodes.Add(node); AddTree(node, myDataRow[0].ToString()); } } catch (Exception ex) { ILog.WriteErrorLog(ex); logManager.InsertLogError("ImportantManager.aspx-Addree", ex.Message + ";" + ex.StackTrace, "Addree has an exception"); } }
public void Add_WhenCalledWhenFileManagerException_ThrowsConfigAddExceptionAndRollsBackAdd() { // Arrange var validItem = new ConfigItem("key4", "value4"); var configItems = new List <IConfigItem>() { new ConfigItem("key1", "value1"), new ConfigItem("key2", "value2"), new ConfigItem("key3", "value3"), }; _memoryCacheService.Contains(validItem.key).Returns(false, true); _fileManager.ReadAllEntriesFromFile().Returns(configItems); _configurationService = new ConfigurationService(_fileManager, _memoryCacheService); _fileManager.When(x => x.AddEntry(validItem)).Throw(new Exception("some error")); // Act Assert.Throws <ConfigAddException>(() => _configurationService.Add(validItem)); // Assert _memoryCacheService.Received(1).Add(validItem); _memoryCacheService.Received(1).Remove(validItem.key); _fileManager.Received(1).AddEntry(validItem); }
public JsonResult deleteItem(ConfigItem Config) { ConfigItem obj = new ConfigItem(); ConfigRepository ConfigRep = new ConfigRepository(); try { if (Config.ConfigID != "") { obj = ConfigRep.DelItem(Config.ConfigID, Config.ConfigItemID); } else { obj.Accion = 0; obj.Mensaje = "El parametro tiene un valor incorrecto!"; } } catch (Exception ex) { obj.Accion = 0; obj.Mensaje = ex.Message.ToString(); } return(Json(obj, JsonRequestBehavior.AllowGet)); }
public void Add_WhenCalledWithNewItem_AddsItemToCacheSucessfully() { // Arrange var newConfigItem = new ConfigItem("key4", "value4"); var configItems = new List <IConfigItem>() { new ConfigItem("key1", "value1"), new ConfigItem("key2", "value2"), new ConfigItem("key3", "value3"), }; _memoryCacheService.Contains(newConfigItem.key).Returns(false); _fileManager.ReadAllEntriesFromFile().Returns(configItems); _configurationService = new ConfigurationService(_fileManager, _memoryCacheService); // Act _configurationService.Add(newConfigItem); // Assert _memoryCacheService.Received(1).Add(newConfigItem); _fileManager.Received(1).AddEntry(newConfigItem); _fileManager.Received(1).ReadAllEntriesFromFile(); }
private string mergeValueItem(ConfigItem<string> settingToMerge, string defaultValue) { if (settingToMerge.ShouldExclude) return defaultValue; return settingToMerge.Value; }
private static void SetOverrideInfo(ConfigItem<VersionConfig> item, string property) { if (property == "exclude") item.ShouldExclude = true; if (property == "merge") item.ShouldMerge = true; }
private static IAsyncResult QueryItemFromServerAsync(string key, ConfigType type, Action<ConfigItem, Exception> callback) { string url = new UrlBuilder() .SetPath("/ActiveConfig/v1/GetKey") .AddParam("appid", _appKey) .AddParam("secretkey", _appSecret) .AddParam("key", key + ":" + (int)type) .GetUrl(); return Http.GetStringAsync(url, (s, e) => { ConfigItem result = null; if (e == null) { result = null; try { var dict = JSON.Parse(s); if (dict != null) { string code = dict["code"].Value; string msg = dict["msg"].Value; string data = dict["data"].Value; if (code != "0") { Debug.WriteLine("Server return error {0}: {1}", code, msg); e = new ActiveConfigException(msg); } else { if (dict["data"].Count == 1) { var item = dict["data"][0]; result = new ConfigItem(); result.Key = item["key"].Value; result.Value = item["value"].Value; result.Type = (ConfigType)Enum.Parse(typeof(ConfigType), item["type"].Value, true); result.ExpireTime = Helper.ConvertTime(item["endtime"].Value); result.MD5 = item["md5"].Value; result.ID = string.Format("{0}:{1}", (int)result.Type, result.Key); if (result.Status == ItemStatus.KeyNotFound) { e = new KeyNotFoundException(key); } } else { e = new KeyNotFoundException(key); } } } else { e = new ActiveConfigException("Parsing json failed"); } } catch (Exception err) { e = new ActiveConfigException("Parsing json failed", err); } } callback(result, e); }); }
public frmNCC(ConfigItem _config) { InitializeComponent(); _ConfigItem = _config; this.Load += new EventHandler(frmNCC_Load); }
public abstract ResourceState Test(ConfigItem data);
/// <summary> /// Compare data with condition in the config file of report /// </summary> /// <param name="i"></param> /// <param name="configItem"></param> /// <returns></returns> private static bool Compare(int i, ConfigItem configItem) { bool check = true; switch (configItem.ColumnName) { case "ID": if (Core.YoutubeFiles[i].ID == configItem.Value) { check = false; } break; case "TITLE": if (Core.YoutubeFiles[i].TITLE == configItem.Value) { check = false; } break; case "ARTIST": if (Core.YoutubeFiles[i].ARTIST == configItem.Value) { check = false; } break; case "ALBUM": if (Core.YoutubeFiles[i].ALBUM == configItem.Value) { check = false; } break; case "LABEL": if (Core.YoutubeFiles[i].LABEL == configItem.Value) { check = false; } break; case "ISRC": if (Core.YoutubeFiles[i].ISRC == configItem.Value) { check = false; } break; case "COMP_ID": if (Core.YoutubeFiles[i].COMP_ID == configItem.Value) { check = false; } break; case "COMP_TITLE": if (Core.YoutubeFiles[i].COMP_TITLE == configItem.Value) { check = false; } break; case "COMP_ISWC": if (Core.YoutubeFiles[i].COMP_ISWC == configItem.Value) { check = false; } break; case "COMP_WRITERS": if (Core.YoutubeFiles[i].COMP_WRITERS == configItem.Value) { check = false; } break; case "COMP_CUSTOM_ID": if (Core.YoutubeFiles[i].COMP_CUSTOM_ID == configItem.Value) { check = false; } break; case "QUANTILE": if (Core.YoutubeFiles[i].QUANTILE == configItem.Value) { check = false; } break; default: break; } return(check); }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="value"></param> protected virtual void RegisterCustomAttribute(string key, string value) { bool isDefaults = key.IndexOf("Default", StringComparison.CurrentCultureIgnoreCase) == 0; bool isOverride = key.IndexOf("X", StringComparison.CurrentCultureIgnoreCase) == 0; if (isDefaults) { key = key.Substring(7); } else if (isOverride) { key = key.Substring(1); } var item = new ConfigItem { Name = key.ToLowerCamelCase(), Mode = ParameterMode.Value }; if (value.StartsWith("<raw>")) { item.Mode = ParameterMode.Raw; value = value.Remove(0, 5); } else if (value.StartsWith("<string>")) { item.Mode = ParameterMode.Value; value = value.Remove(0, value.StartsWith("<string><raw>") ? 13 : 8); } else { bool boolTest; double doubleTest; DateTime dateTest; if (bool.TryParse(value, out boolTest) || double.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out doubleTest)) { item.Mode = ParameterMode.Raw; value = value.ToLowerInvariant(); } else if (DateTime.TryParse(value, CultureInfo.CurrentCulture, DateTimeStyles.None, out dateTest)) { item.Mode = ParameterMode.Raw; value = DateTimeUtils.DateNetToJs(dateTest); } } item.Value = value; if (this is AbstractContainer && isDefaults) { ((AbstractContainer)this).Defaults.Add(new Parameter(item.Name, item.Value, item.Mode)); } else { this.CustomConfig.Add(item); } }
public GroupItemDao(ConfigItem _conf) { this.confItem = _conf; }
public void CreateRandomConfigItem () { var dummyItem = new ConfigItem { Key =$"SomeKey_{currentKey}", Value = $"Config Value {currentKey}" }; this.sqliteNetConn.InsertAsync (dummyItem); Debug.WriteLine ($"Inserted dummy config item using SQLite.Net: {dummyItem}"); currentKey++; }
private ConfigItem<string[]> getValues(string nodeName, bool hasParent) { var item = new ConfigItem<string[]>(new string[] {}); var values = new List<string>(); var nodes = _xml.SelectNodes(nodeName); if (nodes.Count == 0) return item; foreach (XmlNode node in nodes) values.Add(node.InnerText); item.SetValue(values.ToArray()); var mainNode = nodeName; if (hasParent) mainNode = getParentNode(nodeName); if (shouldMerge(mainNode)) item.SetShouldMerge(); if (shouldExcludeFromConfig(mainNode)) item.Exclude(); return item; }
public void Read(string configFile) { if (!tryLoadXml(configFile)) return; StartPaused = getBoolItem("configuration/StartPaused", false); WatchDirectories = getValues("configuration/DirectoryToWatch", false); BuildExecutables = getVersionedSetting("configuration/BuildExecutable"); NUnitTestRunner = getVersionedSetting("configuration/NUnitTestRunner"); MSTestRunner = getVersionedSetting("configuration/MSTestRunner"); XUnitTestRunner = getVersionedSetting("configuration/XUnitTestRunner"); MSpecTestRunner = getVersionedSetting("configuration/MachineSpecificationsTestRunner"); CodeEditor = getCodeEditor(); DebuggingEnabled = getBoolItem("configuration/Debugging", false); MSBuildAdditionalParameters = getValueItem("configuration/MSBuildAdditionalParameters", ""); MSBuildParallelBuildCount = getIntItem("configuration/MSBuildParallelBuildCount", 0); GrowlNotify = getValueItem("configuration/growlnotify", null); NotifyOnRunStarted = getBoolItem("configuration/notify_on_run_started", true); NotifyOnRunCompleted = getBoolItem("configuration/notify_on_run_completed", true); WatchIgnoreFile = getValueItem("configuration/IgnoreFile", ""); TestAssembliesToIgnore = getValues("configuration/ShouldIgnoreTestAssembly/Assembly", true); TestCategoriesToIgnore = getValues("configuration/ShouldIgnoreTestCategories/Category", true); FileChangeBatchDelay = getIntItem("configuration/changedetectiondelay", 200); CustomOutputPath = getValueItem("configuration/CustomOutput", ""); RerunFailedTestsFirst = getBoolItem("configuration/RerunFailedTestsFirst", false); WhenWatchingSolutionBuildSolution = getBoolItem("configuration/WhenWatchingSolutionBuildSolution", true); UseAutoTestTestRunner = getBoolItem("configuration/UseAutoTestTestRunner", true); UseLowestCommonDenominatorAsWatchPath = getBoolItem("configuration/UseLowestCommonDenominatorAsWatchPath", true); WatchAllFiles = getBoolItem("configuration/WatchAllFiles", false); RunAssembliesInParallel = getBoolItem("configuration/RunAssembliesInParallel", false); TestRunnerCompatibilityMode = getBoolItem("configuration/TestRunnerCompatibilityMode", false); LogRecycleSize = getLongItem("configuration/LogRecycleSize", 1024000); ProjectsToIgnore = getValues("configuration/ShouldIgnoreProject/Project", true); Keys = getAllKeys("configuration/*"); DataGathererServiceUrl = getValueItem("configuration/DataGathererServiceUrl", ""); }
private int mergeValueItem(ConfigItem<int> settingToMerge, int defaultValue) { if (settingToMerge.ShouldExclude) return defaultValue; return settingToMerge.Value; }
private static void DownloadImage(ConfigItem hit, Action<BitmapImage> call) { Http.GetBytesAsync(hit.Value, (bytes, err) => { try { if (err == null) { hit.Blob = bytes; lock (_databaseLock) { CacheManger.SubmitChanges(); } Helper.SafeInvoke(() => { BitmapImage image = new BitmapImage(); image = GetImage(bytes); call(image); }); } else { if (err is WebException) { if ((err as WebException).Status == WebExceptionStatus.ConnectFailure) { hit.Status = ItemStatus.InvalidPath; } } } } catch (Exception e) { Debug.WriteLine(e.Message); } }); }
public void GetData(ConfigItem data) { _data = data; }
private ConfigItem<string> getValueItem(string nodeName, string defaultValue) { var item = new ConfigItem<string>(defaultValue); var str = getValue(nodeName, null); if (str == null) return item; item.SetValue(str); if (shouldExcludeFromConfig(nodeName)) item.Exclude(); return item; }
private void mergeVersionedItem(List<KeyValuePair<string, string>> setting, ConfigItem<KeyValuePair<string, string>[]> settingToMerge) { if (!settingToMerge.WasReadFromConfig) return; if (settingToMerge.ShouldExclude) { setting.Clear(); return; } if (settingToMerge.ShouldMerge) { foreach (var mergedItem in settingToMerge.Value) { setting.RemoveAll(x => x.Key.Equals(mergedItem.Key)); setting.Add(mergedItem); } return; } setting.Clear(); setting.AddRange(settingToMerge.Value); }
private string[] mergeValues(string[] setting, ConfigItem<string[]> settingToMerge) { if (settingToMerge.ShouldExclude) return new string[] {}; if (settingToMerge.ShouldMerge) { var list = new List<string>(); list.AddRange(setting); list.AddRange(settingToMerge.Value); return list.ToArray(); } return settingToMerge.Value; }
private void gvSetting_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { m_FocusedItem = gvSetting.GetRow(e.FocusedRowHandle) as ConfigItem; }
private ConfigItem<string> getValue(string xpath, bool isLocal) { var node = _xml.SelectSingleNode(xpath); if (node == null) return new ConfigItem<string>() { Item = "", IsLocal = isLocal, Exists = false }; var item = new ConfigItem<string>() { Item = node.InnerText, IsLocal = isLocal, Exists = true }; var overrideIfno = ""; if (node.Attributes.GetNamedItem("override") != null) overrideIfno = node.Attributes.GetNamedItem("override").InnerText; if (overrideIfno == "exclude") item.ShouldExclude = true; if (overrideIfno == "merge") item.ShouldMerge = true; return item; }
public void GetData(ConfigItem data) { _configItem = data; }
private IEnumerable<ConfigItem<string>> getListOfStrings(string xpath, bool isLocal) { var list = new List<ConfigItem<string>>(); var nodes = _xml.SelectNodes(xpath); foreach (XmlNode node in nodes) { var item = new ConfigItem<string>() { Item = node.InnerText, IsLocal = isLocal, Exists = true }; var overrideIfno = ""; if (node.ParentNode.Attributes.GetNamedItem("override") != null) overrideIfno = node.ParentNode.Attributes.GetNamedItem("override").InnerText; if (overrideIfno == "exclude") item.ShouldExclude = true; if (overrideIfno == "merge") item.ShouldMerge = true; list.Add(item); } return list.ToArray(); }
public abstract ResourceState Apply(ConfigItem data);
private ConfigItem<IgnoreFile> getIgnoreFile(bool isLocal) { var item = new ConfigItem<IgnoreFile>() { Item = new IgnoreFile(), IsLocal = isLocal, Exists = false }; item.Item.ContentPath = _localPath; var node = _xml.SelectSingleNode("configuration/IgnoreFile"); if (node == null) return item; item.Item.File = node.InnerText; item.Exists = true; var overrideIfno = ""; if (node.Attributes.GetNamedItem("override") != null) overrideIfno = node.Attributes.GetNamedItem("override").InnerText; if (overrideIfno == "exclude") item.ShouldExclude = true; if (overrideIfno == "merge") item.ShouldMerge = true; if (item.Item.File.Trim().Length == 0) return item; if (!File.Exists(Path.Combine(_localPath, item.Item.File))) return item; var file = Path.Combine(_localPath, node.InnerText); item.Item.Content = File.ReadAllText(file); return item; }
/// <summary>Generates an item described by a saved object.</summary> /// <param name="save">A saved object descibing an item.</param> /// <param name="tile">The object's intended tile location. Generally necessary for items derived from StardewValley.Object.</param> public static Item CreateItem(SavedObject save, Vector2 tile = default(Vector2)) { switch (save.Type) //check the object's type { case SavedObject.ObjectType.Object: case SavedObject.ObjectType.Item: case SavedObject.ObjectType.Container: case SavedObject.ObjectType.DGA: //these are valid item types break; default: Monitor.Log($"Failed to create an item. Saved object does not appear to be an item.", LogLevel.Debug); Monitor.Log($"Item name: {save.Name}", LogLevel.Debug); return(null); } if (!save.ID.HasValue && save.Type != SavedObject.ObjectType.Container && save.Type != SavedObject.ObjectType.DGA) //if this save doesn't have an ID (and isn't a container or a DGA item) { Monitor.Log("Failed to create an item. Saved object contained no ID.", LogLevel.Debug); Monitor.Log($"Item name: {save.Name}", LogLevel.Debug); return(null); } Item item = null; //the item to be generated ConfigItem configItem = save.ConfigItem; //the ConfigItem class describing the item (null if unavailable) //parse container contents, if applicable List <Item> contents = new List <Item>(); if (save.Type == SavedObject.ObjectType.Container) //if this is a container { string areaID = $"[unknown; parsing chest contents at {save.MapName}]"; //placeholder string; this method has no easy access to the areaID that created a given item List <SavedObject> contentSaves = ParseSavedObjectsFromItemList(configItem.Contents, areaID); //parse the contents into saved objects for validation purposes foreach (SavedObject contentSave in contentSaves) //for each successfully parsed save { Item content = CreateItem(contentSave); //call this method recursively to create this item if (content != null) //if this item was created successfully { contents.Add(content); //add it to the contents list } } } string category = "item"; if (configItem != null && configItem.Category != null) { category = configItem.Category.ToLower(); } switch (category) //based on the category { case "barrel": case "barrels": item = new BreakableContainerFTM(tile, contents, true); //create a mineshaft-style breakable barrel with the given contents break; case "bigcraftable": case "bigcraftables": case "big craftable": case "big craftables": item = new StardewValley.Object(tile, save.ID.Value, false); //create an object as a "big craftable" item break; case "boot": case "boots": item = new Boots(save.ID.Value); break; case "breakable": case "breakables": bool barrel = RNG.Next(0, 2) == 0 ? true : false; //randomly select whether this is a barrel or crate if (configItem != null) { //rewrite the category to save the selection if (barrel) { configItem.Category = "barrel"; } else { configItem.Category = "crate"; } } item = new BreakableContainerFTM(tile, contents, barrel); //create a mineshaft-style breakable container with the given contents break; case "buried": case "burieditem": case "burieditems": case "buried item": case "buried items": item = new BuriedItems(tile, contents); //create an item burial location with the given contents break; case "chest": case "chests": item = new Chest(0, contents, tile, false, 0); //create a mineshaft-style chest with the given contents break; case "cloth": case "clothes": case "clothing": case "clothings": item = new Clothing(save.ID.Value); break; case "crate": case "crates": item = new BreakableContainerFTM(tile, contents, false); //create a mineshaft-style breakable crate with the given contents break; case "dga": try { object rawDGA = DGAItemAPI.SpawnDGAItem(save.Name); //create an item with DGA's API if (rawDGA is Item itemDGA) //if this is a non-null Item { item = itemDGA; //use it } else { Monitor.Log("Failed to create an item. Dynamic Game Assets (DGA) item was null or an unrecognized type.", LogLevel.Debug); Monitor.Log($"Item name: {save.Name}", LogLevel.Debug); return(null); } } catch (Exception ex) { Monitor.LogOnce($"Error spawning a Dynamic Game Assets (DGA) item. The auto-generated error message has been added to the log.", LogLevel.Info); Monitor.Log($"----------", LogLevel.Trace); Monitor.Log($"{ex.ToString()}", LogLevel.Trace); return(null); } break; case "furniture": item = new Furniture(save.ID.Value, tile); break; case "hat": case "hats": item = new Hat(save.ID.Value); break; case "object": //treat objects as items when creating them as Items case "objects": case "item": case "items": item = new StardewValley.Object(tile, save.ID.Value, 1); //create an object with the preferred constructor for "held" or "dropped" items break; case "ring": case "rings": item = new Ring(save.ID.Value); break; case "weapon": case "weapons": item = new MeleeWeapon(save.ID.Value); break; } if (item == null) //if no item could be generated { Monitor.Log("Failed to create an item. Category setting was not recognized.", LogLevel.Debug); Monitor.Log($"Item Category: {category}", LogLevel.Debug); return(null); } if (configItem?.Stack > 1) //if this item has a custom stack setting { item.Stack = configItem.Stack.Value; //apply it } if (save.ID.HasValue) //if this object type uses an ID { item.ParentSheetIndex = save.ID.Value; //manually set this index value, due to it being ignored by some item subclasses } return(item); }
private IEnumerable<ConfigItem<VersionConfig>> GetVersionedSetting(string xpath, bool isLocal) { var list = new List<ConfigItem<VersionConfig>>(); var nodes = _xml.SelectNodes(xpath); foreach (XmlNode node in nodes) { var file = node.InnerText; var framework = ""; var overrideIfno = ""; if (node.Attributes.GetNamedItem("framework") != null) framework = node.Attributes.GetNamedItem("framework").InnerText; if (node.Attributes.GetNamedItem("override") != null) overrideIfno = node.Attributes.GetNamedItem("override").InnerText; var item = new ConfigItem<VersionConfig>() { Item = new VersionConfig() { Path = file, Framework = framework }, IsLocal = isLocal, Exists = true }; SetOverrideInfo(item, overrideIfno); list.Add(item); } return list.ToArray(); }
private void mergeCodeEditor(ConfigItem<CodeEditor> settingToMerge) { if (!settingToMerge.WasReadFromConfig) return; if (settingToMerge.ShouldExclude) { _codeEditor = new CodeEditor("", ""); return; } _codeEditor = settingToMerge.Value; }
private static IAsyncResult QueryAll(ConfigItem[] keys, Action<ConfigItem[], Exception> callback) { string url = new UrlBuilder() .SetPath("/ActiveConfig/v1/CheckUpdate") .AddParam("appid", _appKey) .AddParam("secretkey", _appSecret) .AddParam("key", string.Join(";", keys.Select(x => x.Key + "," + x.MD5 + "," + (int)x.Type))) .GetUrl(); return Http.GetStringAsync(url, (s, e) => { List<ConfigItem> results = null; if (e == null) { results = new List<ConfigItem>(); var dict = JSON.Parse(s); if (dict != null) { string code = dict["code"].Value; string msg = dict["msg"].Value; if (code != "0") { Debug.WriteLine("Server return error {0}: {1}", code, msg); e = new ActiveConfigException(msg); } else { foreach (var item in dict["data"].Childs) { ConfigItem c = new ConfigItem(); c.Key = item["key"].Value; c.Type = (ConfigType)Enum.Parse(typeof(ConfigType), item["type"].Value, true); var serverStatus = item["status"].Value != "" ? (ServerItemStatus)Enum.Parse(typeof(ServerItemStatus), item["status"].Value, true) : ServerItemStatus.Success; if (serverStatus == ServerItemStatus.NoUpdate) { continue; } else if (serverStatus == ServerItemStatus.Invalid) { c.Status = ItemStatus.KeyNotFound; } else { c.Value = item["value"].Value; c.ExpireTime = Helper.ConvertTime(item["endtime"].Value); c.MD5 = item["md5"].Value; c.Status = ItemStatus.OK; } results.Add(c); } } } else { e = new ActiveConfigException("Parsing json failed"); } } callback(results.ToArray(), e); }); }