本文整理汇总了C#中DBManager.CreateParameters方法的典型用法代码示例。如果您正苦于以下问题:C# DBManager.CreateParameters方法的具体用法?C# DBManager.CreateParameters怎么用?C# DBManager.CreateParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager.CreateParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VM_set_adapter
//暫時 FOR VMWARE creat adapter
static void VM_set_adapter(string[] vlan_id, string[] virNetworkName_m, string guid, string vmware_datacenter_name, string vmware_host_name, string order_id)
{
try
{
Create_VM_Service.AutoProvision_WS.AutoProvision_WS ws = new Create_VM_Service.AutoProvision_WS.AutoProvision_WS();
Create_VM_Service.VMAPI.GCCA_HypervisorAPI vmapi = new GCCA_HypervisorAPI();
#region cleaning adapter and database data
/////cleaning adapter and database data
List<JToken> adapter_detail = new List<JToken>();
string clean = vmapi.getVMNICMacList(guid, vmware_datacenter_name, vmware_host_name, order_id);
JToken token;
token = JToken.Parse(clean.Remove(clean.Length - 1).Remove(0, 1).Replace("\\", "\\\\"));
token.SelectToken("message")[1].SelectToken("Mac").ToString();
for (int i = 1; i < token.SelectToken("message").Count(); i++) // colculate adapter num
{
string temp = vmapi.removeVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, token.SelectToken("message")[i].SelectToken("Nic_Name").ToString(), token.SelectToken("message")[1].SelectToken("Mac").ToString()).ToString();
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " removeVMNIC is : " + temp + + Environment.NewLine);
}
DBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "@order_id", order_id);
string sql = "";
sql = @"DELETE FROM order_nic_mac_list
WHERE order_id = @order_id";
int updateOderId = dbManager.ExecuteNonQuery(CommandType.Text, sql);
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " change DB data number : " + updateOderId + +Environment.NewLine);
clean_IP(order_id);
//////////////
#endregion
List<string> NetworkName = new List<string>();
int j_test = 0;//單純控制下面迴圈
int j_result = 1;//控制下面迴圈
for (int i = 0; i < vlan_id.Length; i++) // 找出VM上符合訂單上VLAN_ID的網卡名稱
{
while (i < vlan_id.Length)
{
j_result = string.Compare(vlan_id[i], virNetworkName_m[j_test]);
if (j_result == 0)
{
NetworkName.Add(virNetworkName_m[j_test - 2]);
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " virNetworkName_m is : " + virNetworkName_m[j_test - 2] + +Environment.NewLine);
break;
}
j_test++;
}
j_test = 0;
j_result = 1;
}
for (int i = 0; i < vlan_id.Length; i++)//如果有多張網卡 建立多張網卡
{
if (i == 0)//if 只有一張網卡,更改網卡名稱
{ vmapi.adjustVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, "Network adapter 1", NetworkName[i]); }//修改網卡內容 只有一張網卡時 修改第一張
//string ggg= vlan_id[];
else
{ vmapi.addVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, NetworkName[i]); }
}
string nic_mac_list = vmapi.getVMNICMacList(guid, vmware_datacenter_name, vmware_host_name, order_id);
//string[] nic_mac_list2 = nic_mac_list.Split(new string[2]{"\"Mac\":\"","\"}"}, StringSplitOptions.RemoveEmptyEntries); //對API回傳的值做切割,
string[] nic_mac_list2 = nic_mac_list.Split(new string[4] { "Nic_Name\":\"", "\",", "\"Mac\":\"", "\"}" }, StringSplitOptions.RemoveEmptyEntries); //字串分割 Nic_Name":" ", Mac":" "}
int j_i = 0;
for (int i = 0; i < vlan_id.Length; i++)//將網卡MAC等資料 塞回DB
{
j_i = 3 * i; //只要陣列中的 i*3+(1or2)的值
ws.save_nic_mac(order_id, nic_mac_list2[j_i + 1], nic_mac_list2[j_i + 2], vlan_id[i], vmware_host_name); //將creat VM的資料(order_id,macID,nic_id,groupID,order_area,vlan_id,host_name) 塞回DB
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " save_nic_mac: " + order_id + " " + nic_mac_list2[j_i + 1] + " " + nic_mac_list2[j_i + 2] + " " + vlan_id[i] + " " + vmware_host_name + " " + +Environment.NewLine);
}
dbManager.Dispose();
}
catch (Exception)
{
return;
}
}
示例2: clean_IP
private static void clean_IP(string vmname)
{
string sql;
DBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "@order_id", vmname);
sql = @"update c_ip_list
set ip_address=(select substring(ip_address,0,case charindex(':',ip_address) when '' then Len(ip_address)+1 else charindex(':',ip_address) end) from c_ip_list a where c_ip_list.row_id=a.row_id),order_id=NULL,used=NULL,upd_userid='Service',used_mac=NULL,upd_datetime=GETDATE()
where order_id [email protected]_id";
int updateOderId = dbManager.ExecuteNonQuery(CommandType.Text, sql);
dbManager.Dispose();
}
示例3: de_bug
//.........这里部分代码省略.........
finally
{
dbManager.Dispose();
}
#endregion
#region 是否有訂單完成 vm create ready
try//是否有訂單完成 vm create ready
{
dbManager.Open();
string sql = "";
Int32 nCount = 0;
//
sql = @"select TOP 1 e.os_type as os,a.order_audit,a.FQDN+'@'+f.domain_name as FQDN,a.order_vm_type,order_id,order_area,a.order_cpu,a.order_ram,a.temp_id,order_vm_type,c.vpath,a.company_id,a.temp_id,a.group_id
from user_vm_order a
left outer join vm_temp b on a.temp_id=b.temp_id
left outer join vm_temp_virus_r c on a.temp_id=c.temp_id and a.order_virus=c.virus
left outer join Param e on b.os=e.para_id
left outer join c_domain f on a.company_id=f.company_id and a.order_area=f.area_id
where a.order_audit='5'
order by order_id";
DataSet ds = dbManager.ExecuteDataSet(CommandType.Text, sql);
nCount = ds.Tables[0].Rows.Count;
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", "訂單完成數 : " + nCount + Environment.NewLine);
if (nCount > 0)
{
System.Threading.Thread.Sleep(18000);
string order_id = ds.Tables[0].Rows[0]["order_id"].ToString();
string FQDN = ds.Tables[0].Rows[0]["FQDN"].ToString();
ws.Send_mail(order_id, FQDN);
ws.Inset_Percent(order_id, "100", "");
ws.Change_Order_Status(order_id, "1", true);
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "order_id", order_id);
string sql2 = @"update user_vm_order
set finish_time=getdate()
where [email protected]_id";
DataSet ds2 = dbManager.ExecuteDataSet(CommandType.Text, sql2);
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", "send mail, change order status ok. " + Environment.NewLine);
}
}
catch (Exception ex)
{
dbManager.Dispose();
ws.Dispose();
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", "訂單完成產生錯誤 : " + ex.Message + Environment.NewLine);
}
finally
{
dbManager.Dispose();
}
#endregion
try//是否有訂單需建立 need create
{
dbManager.Open();
string check_order = @"select order_audit
from user_vm_order
where order_audit = '3' ";
DataSet ds0 = dbManager.ExecuteDataSet(CommandType.Text, check_order);
Int32 n1 = ds0.Tables[0].Rows.Count;
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", "craeting VM number is : " + n1 + Environment.NewLine);
if (n1 <= Max_Create_VM_Num) //一次只能建立?筆訂單
{
try
示例4: a
//test area
static void a()
{
DBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
dbManager.Open();
dbManager.CreateParameters(4);
dbManager.AddParameters(0, "@order_area", "TP");
dbManager.AddParameters(1, "@company_id", "GCCA");
dbManager.AddParameters(2, "@vmtype", "VMware");
dbManager.AddParameters(3, "@temp_id", "Temp_20130606_001");
string sql = @"SELECT vmware_apiurl,vmware_datacenter_name,vmware_datastore_name,vmware_host_account,vmware_host_name,vmware_host_pwd,b.hostname as create_on_hostname,resource_pool_name,b.datacenter_name as create_on_datacentername,b.temp_id
FROM config_vm_host a left outer join vm_temp b on a.vmtype=b.vm_type
WHERE [email protected]_area and [email protected]_id and [email protected] and [email protected]_id";
DataSet ds = dbManager.ExecuteDataSet(CommandType.Text, sql);
int nCount = ds.Tables[0].Rows.Count;
string vmware_apiurl = ds.Tables[0].Rows[0]["vmware_apiurl"].ToString();
string vmware_vcenter_ip = vmware_apiurl.Split('/')[2];
//vmware_datacenter_name = ds.Tables[0].Rows[0]["vmware_datacenter_name"].ToString();
//vmware_datastore_name = ds.Tables[0].Rows[0]["vmware_datastore_name"].ToString();
//vmware_host_account = ds.Tables[0].Rows[0]["vmware_host_account"].ToString();
//vmware_host_name = ds.Tables[0].Rows[0]["vmware_host_name"].ToString();
//vmware_host_pwd = CryptoAES.decrypt(ds.Tables[0].Rows[0]["vmware_host_pwd"].ToString(), "[email protected]");
//vmware_host_encryp_pwd = ds.Tables[0].Rows[0]["vmware_host_pwd"].ToString();
//create_on_hostname = ds.Tables[0].Rows[0]["create_on_hostname"].ToString();
//create_on_datacentername = ds.Tables[0].Rows[0]["create_on_datacentername"].ToString();
//resource_pool_name = Convert.ToString(ds.Tables[0].Rows[0]["resource_pool_name"]);
dbManager.Dispose();
Create_VM_Service.VMAPI.GCCA_HypervisorAPI vmapi = new GCCA_HypervisorAPI();
//string[] guidf0 = vmapi.init(vmware_apiurl, "administrator", "Passw0rd", "GCCA_8F_Lab", true).Split(':'); //連線至VMWARE HOST
//string[] guidf1 = guidf0[2].Split('\'');
//string guid = guidf1[1];//取得GUID
string vm_network_name = vmapi.getVMNICNetworkList("f048f491-05c1-44aa-9aff-55e4129b4c1d", "GCCA_8F_Lab", "172.16.10.45", "20130606_006");
return;
}