当前位置: 首页>>代码示例>>C#>>正文


C# DBManager.Open方法代码示例

本文整理汇总了C#中DBManager.Open方法的典型用法代码示例。如果您正苦于以下问题:C# DBManager.Open方法的具体用法?C# DBManager.Open怎么用?C# DBManager.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager的用法示例。


在下文中一共展示了DBManager.Open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Listar

        public static List<Produto> Listar(Produto filtro)
        {


            DBManager dbManager = new DBManager();
            dbManager.Open();

            StringBuilder stbSelect = new StringBuilder(SQL_SELECT);


            if (filtro.Codigo > 0)
            {
                stbSelect.AppendFormat(" and Codigo = {0}", filtro.Codigo);
            }

            if (!string.IsNullOrEmpty(filtro.Descricao))
            {
                stbSelect.AppendFormat(" and Descricao like '%{0}%'", filtro.Descricao);
            }

            if (filtro.Ativo.HasValue)
            {
                stbSelect.AppendFormat(" and Ativo = {0}", filtro.Ativo.Value ? "True" : "False");
            }

            if (!string.IsNullOrEmpty(filtro.CodigoEntrada))
            {
                stbSelect.AppendFormat(" and CodigoEntrada = '{0}'", filtro.CodigoEntrada);
            }

            if (!string.IsNullOrEmpty(filtro.CodigoSaida))
            {
                stbSelect.AppendFormat(" and CodigoSaida = '{0}'", filtro.CodigoSaida);
            }


            IDataReader dr = dbManager.SelectData(stbSelect.ToString());
            List<Produto> produtos = dbManager.CarregarLista<Produto>(dr, ConvertProduto);

            dbManager.Close();
            return produtos;

        }
开发者ID:rcarubbi,项目名称:MVR.CadCompra,代码行数:43,代码来源:Produto.cs

示例2: Listar

        public static List<Compra> Listar(Compra compraInicio, Compra compraFim, Produto produtoFiltro)
        {
            ValidarFiltro(compraInicio, compraFim, produtoFiltro);

            DBManager dbManager = new DBManager();
            dbManager.Open();

            StringBuilder stbSelect = new StringBuilder(SQL_SELECT);

            if (compraInicio != null)
            {
                if (!string.IsNullOrEmpty(compraInicio.Processo))
                {
                    stbSelect.AppendFormat(" and c.Processo = '{0}'", compraInicio.Processo);
                }

                if (compraInicio.Data.HasValue)
                {
                    stbSelect.AppendFormat(" and c.Data >= #{0} 00:00:00#", compraInicio.Data.Value.ToString("yyyy-MM-dd"));
                }
            }
            if (compraFim != null)
            {
                if (compraFim.Data.HasValue)
                {
                    stbSelect.AppendFormat(" and  c.Data <= #{0} 23:59:59#", compraFim.Data.Value.ToString("yyyy-MM-dd"));
                }
            }

            if (produtoFiltro != null)
            {
                if (!string.IsNullOrEmpty(produtoFiltro.CodigoEntrada))
                {
                    stbSelect.AppendFormat(" and p.CodigoEntrada = '{0}'", produtoFiltro.CodigoEntrada);
                }

                if (!string.IsNullOrEmpty(produtoFiltro.CodigoSaida))
                {
                    stbSelect.AppendFormat(" and p.CodigoSaida = '{0}'", produtoFiltro.CodigoSaida);
                }
            }

            IDataReader dr = dbManager.SelectData(stbSelect.ToString());
            List<Compra> compras = dbManager.CarregarLista<Compra>(dr, ConvertCompra);

            dbManager.Close();
            return compras;
        }
开发者ID:rcarubbi,项目名称:MVR.CadCompra,代码行数:48,代码来源:Compra.cs

示例3: 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;
            }
        }
开发者ID:jedi0605,项目名称:GitTeach,代码行数:82,代码来源:Program.cs

示例4: de_bug

        static void de_bug()
        {
            DBManager dbManager = new DBManager(DataProvider.SqlServer);
            Console.WriteLine("debug Start");
            string AutoProvision_WS_url = Create_VM_Service.Properties.Settings.Default.Create_VM_Service_AutoProvision_WS_AutoProvision_WS;

            string IsDelImg = ConfigurationManager.AppSettings["IsDelImg"].ToString();//是否刪除VM
            string db_server = ConfigurationManager.AppSettings["SSM"].ToString();
            string EmailAccount = ConfigurationManager.AppSettings["EmailAccount"].ToString();
            string EmailPassword = ConfigurationManager.AppSettings["EmailPassword"].ToString();
            string smtphost = ConfigurationManager.AppSettings["smtphost"].ToString();
            dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
            Create_VM_Service.AutoProvision_WS.AutoProvision_WS ws = new Create_VM_Service.AutoProvision_WS.AutoProvision_WS();
            //CPU_Memory_Usage_API.David_API vm_useage = new CPU_Memory_Usage_API.David_API();
            string ftp = ConfigurationManager.AppSettings["FTP_IP"].Replace("ftp://", "").Trim();
            string ftp_user = ConfigurationManager.AppSettings["ftpUsername"].Trim().ToString();
            string ftp_pwd = ConfigurationManager.AppSettings["ftpPassword"].Trim().ToString();
            string ftp_folder = ConfigurationManager.AppSettings["FTP_IP"] + "/" + ConfigurationManager.AppSettings["agentFtpPath"];
            int Max_Create_VM_Num = Convert.ToInt32(ConfigurationManager.AppSettings["Max_Create_VM_Num"].Trim().ToString());
            string vm_account = ConfigurationManager.AppSettings["vm_account"].Trim().ToString();
            string vm_password = ConfigurationManager.AppSettings["vm_password"].Trim().ToString();

            #region //是否有訂單需要刪除
            try//是否有訂單需要刪除
            {
                Create_VM_Service.VMAPI.GCCA_HypervisorAPI vmapi = new GCCA_HypervisorAPI();
                dbManager.Open();
                string sql = "";
                Int32 nCount = 0;
                sql = @"select TOP 1 a.order_audit,a.order_vm_type,a.order_id,order_area,a.company_id,a.temp_id,b.*,c.*
                        from user_vm_order a
                        left outer join config_vm_host b on a.company_id=b.company_id and a.order_vm_type=b.vmtype left outer join order_audit c on a.order_id=c.order_id
                        where c.vm_del='1' and a.order_audit='6'
                        order by a.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)
                {
                    string order_id = ds.Tables[0].Rows[0]["order_id"].ToString();
                    string aa = ws.Change_Order_Status(order_id, "8", false);
                    string vmtype = ds.Tables[0].Rows[0]["order_vm_type"].ToString();
                    if (vmtype == "VMware")
                    {
                        string vcenter_url = ds.Tables[0].Rows[0]["vmware_apiurl"].ToString();
                        string vmware_host_account = ds.Tables[0].Rows[0]["vmware_host_account"].ToString();
                        string vmware_host_pwd = CryptoAES.decrypt(ds.Tables[0].Rows[0]["vmware_host_pwd"].ToString(), "[email protected]");
                        string vmware_datacenter_name = ds.Tables[0].Rows[0]["vmware_datacenter_name"].ToString();
                        string vmware_host_name = ds.Tables[0].Rows[0]["vmware_host_name"].ToString();
                        string vmware_datastore_name = ds.Tables[0].Rows[0]["vmware_datastore_name"].ToString();
                        string[] guidf0 = vmapi.init(vcenter_url, vmware_host_account, vmware_host_pwd, vmware_datacenter_name, true).Split(':');
                        string[] guidf1 = guidf0[2].Split('\'');
                        string guid = guidf1[1];

                        string VMWare_Power_off_f = vmapi.powerOffVM(guid, vmware_datacenter_name, vmware_host_name, order_id).Split(':')[1].Split(',')[0];
                        try
                        {
                            if (IsDelImg == "true" && VMWare_Power_off_f == "true")
                            {
                                vmapi.removeVM(guid, vmware_datacenter_name, vmware_host_name, order_id, vmware_datastore_name, true);
                                ws.Change_Order_Status(order_id, "7", false);
                            }
                            else if (IsDelImg == "true" && VMWare_Power_off_f == "false")
                            {
                                ws.Inset_Log(order_id, "Power Off Error");
                            }
                            else if (IsDelImg == "false" && VMWare_Power_off_f == "false")
                            {
                                ws.Inset_Log(order_id, "Power Off Error");
                            }
                            else if (IsDelImg == "false" && VMWare_Power_off_f == "true")
                            {
                                ws.Change_Order_Status(order_id, "7", false);
                            }
                            System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " delete order is : " + order_id + Environment.NewLine);

                        }
                        catch (Exception ex)
                        {
                            dbManager.Dispose();
                            ws.Dispose();
                            ws.Inset_Log(order_id, ex.Message);
                            System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " delete order tppe is VMware,and fail order_id is : " + order_id + Environment.NewLine);

                        }
                    }
                    else if (vmtype == "KVM")
                    {
                        string kvm_hostname = ds.Tables[0].Rows[0]["kvm_hostname"].ToString();
                        string kvm_dsname = ds.Tables[0].Rows[0]["kvm_dsname"].ToString();
                        string kvm_account = ds.Tables[0].Rows[0]["kvm_account"].ToString();
                        string kvm_pwd = CryptoAES.decrypt(ds.Tables[0].Rows[0]["kvm_pwd"].ToString(), "[email protected]");
                        string[] guidf0 = vmapi.init(kvm_hostname, kvm_dsname, kvm_account, kvm_pwd).Split(':');
                        string[] guidf1 = guidf0[2].Split('\'');
                        string guid = guidf1[1];
                        string VMWare_Power_off_f = vmapi.powerOffVM(guid, "", kvm_hostname, order_id).Split(':')[1].Split(',')[0];
                        try
                        {
                            if (IsDelImg == "true" && VMWare_Power_off_f == "true")
//.........这里部分代码省略.........
开发者ID:jedi0605,项目名称:GitTeach,代码行数:101,代码来源:Program.cs

示例5: 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();
        }
开发者ID:jedi0605,项目名称:GitTeach,代码行数:16,代码来源:Program.cs

示例6: 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;
        }
开发者ID:jedi0605,项目名称:GitTeach,代码行数:36,代码来源:Program.cs


注:本文中的DBManager.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。