Changes for Xylem Nanjing, ver. 3.1.1676
This commit is contained in:
@@ -4,20 +4,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.Output.DB.SensusOracle
|
||||
{
|
||||
public class DatabaseCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
public class DatabaseCfg : ComponentCfgBase, IComponentCfg, IParamsProvider
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DatabaseCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new DatabaseCfgCtrl(); }
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
||||
{
|
||||
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
||||
}
|
||||
|
||||
/// <summary> Serialized parameters </summary>
|
||||
public bool TestMode;
|
||||
public string ProductionDataSource;
|
||||
public string ProductionUserId;
|
||||
public string ProductionPassword;
|
||||
public string QualityDataSource;
|
||||
public string QualityUserId;
|
||||
public string QualityPassword;
|
||||
public string TestDataSource;
|
||||
public string TestUserId;
|
||||
public string TestPassword;
|
||||
public int ProducerId;
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
@@ -37,12 +50,140 @@ namespace TBF.Rig.Output.DB.SensusOracle
|
||||
Name = name;
|
||||
Factory = factory;
|
||||
ParentName = string.Empty;
|
||||
TestMode = false;
|
||||
InitializeAll();
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
public string ComponentName { get { return Name; } }
|
||||
|
||||
public void InitializeAll()
|
||||
{
|
||||
ProductionDataSource = "STARA01.WORLD";
|
||||
ProductionUserId = "deltachef";
|
||||
ProductionPassword = "deltachef";
|
||||
QualityDataSource = "STARA01.WORLD";
|
||||
QualityUserId = "deltaqual";
|
||||
QualityPassword = "test";
|
||||
TestDataSource = "STARA_TEST";
|
||||
TestUserId = "deltachef";
|
||||
TestPassword = "deltachef";
|
||||
ProducerId = 4;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
return string.Format("Name={0} TestMode={1}", Name, TestMode);
|
||||
"Production DB Data Source",
|
||||
"Production DB User ID",
|
||||
"Production DB Password",
|
||||
"Quality DB Data Source",
|
||||
"Quality DB User ID",
|
||||
"Quality DB Password",
|
||||
"Test DB Data Source",
|
||||
"Test DB User ID",
|
||||
"Test DB Password",
|
||||
"Producer ID",
|
||||
};
|
||||
public string ParamName(int i) { return paramNames[i]; }
|
||||
public int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public ICollection<string> ParamValues(int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return ProductionDataSource;
|
||||
case 1: return ProductionUserId;
|
||||
case 2: return ProductionPassword;
|
||||
case 3: return QualityDataSource;
|
||||
case 4: return QualityUserId;
|
||||
case 5: return QualityPassword;
|
||||
case 6: return TestDataSource;
|
||||
case 7: return TestUserId;
|
||||
case 8: return TestPassword;
|
||||
case 9: return ProducerId.ToString();
|
||||
default:
|
||||
return string.Format("{0}: Production={1} Quality={2} Test={3}",
|
||||
Name,
|
||||
string.IsNullOrEmpty(ProductionDataSource) ? string.Empty : ProductionDataSource,
|
||||
string.IsNullOrEmpty(QualityDataSource) ? string.Empty : QualityDataSource,
|
||||
string.IsNullOrEmpty(TestDataSource) ? string.Empty : TestDataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int i, string str)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: ProductionDataSource = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 1: ProductionUserId = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 2: ProductionPassword = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 3: QualityDataSource = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 4: QualityUserId = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 5: QualityPassword = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 6: TestDataSource = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 7: TestUserId = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 8: TestPassword = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 9: ProducerId = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
|
||||
default:
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateParam(int i, string str, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
int idummy;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return true;
|
||||
case 9:
|
||||
if (int.TryParse(str, out idummy) && idummy > 0 && idummy <= 9) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(DatabaseCfg prms)
|
||||
{
|
||||
prms.ProductionDataSource = this.ProductionDataSource;
|
||||
prms.ProductionUserId = this.ProductionUserId;
|
||||
prms.ProductionPassword = this.ProductionPassword;
|
||||
prms.QualityDataSource = this.QualityDataSource;
|
||||
prms.QualityUserId = this.QualityUserId;
|
||||
prms.QualityPassword = this.QualityPassword;
|
||||
prms.TestDataSource = this.TestDataSource;
|
||||
prms.TestUserId = this.TestUserId;
|
||||
prms.TestPassword = this.TestPassword;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
DatabaseCfg pars = new DatabaseCfg();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public bool UpdateEmbeddedDbEntity()
|
||||
{
|
||||
return true; /// =OK, do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user