/// <summary> /// 用指定类型创建连接 /// </summary> /// <param name="conn">连接字符串</param> /// <param name="cte">连接类型</param> /// <param name="dt">连接超时时间</param> /// <returns>返回创建的连接</returns> private ConnStruct CreateConnection(string conn, ConnTypeEnum cte) { DbConnection db = null; if (cte == ConnTypeEnum.Odbc) { db = new System.Data.Odbc.OdbcConnection(conn);//ODBC数据源连接 } else if (cte == ConnTypeEnum.OleDb) { db = new System.Data.OleDb.OleDbConnection(conn);//OLE DB数据连接,Access数据库 } else if (cte == ConnTypeEnum.SqlClient) { db = new System.Data.SqlClient.SqlConnection(conn);//SqlServer数据库连接 } else if (cte == ConnTypeEnum.MySqlClient) { db = new MySql.Data.MySqlClient.MySqlConnection(conn);//MySqlServer数据库连接 } else if (cte == ConnTypeEnum.OracleClient) { db = new System.Data.OracleClient.OracleConnection(conn);//Oracle数据库连接 } else if (cte == ConnTypeEnum.MsModelClient) { db = new System.Data.EntityClient.EntityConnection(conn);//Microsoft数据库连接 } ConnStruct cs = new ConnStruct(db, cte, DateTime.Now); cs.Open(); return(cs); }
public DBFactory(string dbEntities) { _dbEntities = dbEntities; //mCN = ConfigurationManager.ConnectionStrings[dbEntities] .ToString(); ; System.Data.EntityClient.EntityConnection con = new System.Data.EntityClient.EntityConnection(ConfigurationManager.ConnectionStrings[dbEntities].ToString()); mCN = con.StoreConnection.ConnectionString; }
public virtual void UserInfo(ref string s) { // get user info and return it as formatted html string AddRow(ref s, "Session"); //var fa = System.Web.Security.FormsAuthentication.IsEnabled; //var user = System.Web.Security.Membership.GetUser(); //var roles = System.Web.Security.Roles.GetRolesForUser(); var now = DateTime.Now; var startTime = Process.GetCurrentProcess().StartTime; AddRow(ref s, "Current Time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); AddRow(ref s, "Running Since", startTime.ToString("yyyy-MM-dd HH:mm:ss")); AddRow(ref s, "Running For", (now - startTime).ToString()); var connections = ConfigurationManager.ConnectionStrings; foreach (ConnectionStringSettings item in connections) { string connectionString; if (string.Compare(item.ProviderName, "System.Data.EntityClient", true) == 0) { // Use entity connection. var e = new System.Data.EntityClient.EntityConnection(item.ConnectionString); connectionString = e.StoreConnection.ConnectionString; } else { // Use classic connection. connectionString = item.ConnectionString; } AddConnection(ref s, item.Name, connectionString); } }
private static void VerifyInvalidRequestForAllProviders(string uri, int errorCode, params KeyValuePair <string, string>[] headerValues) { // Very simple test at this level: simply check that we can get an entity by its ID. CombinatorialEngine engine = CombinatorialEngine.FromDimensions( new Dimension("ContentFormat", UnitTestsUtil.ResponseFormats), new Dimension("ContextType", new Type[] { typeof(CustomDataContext), typeof(ocs.CustomObjectContext), typeof(CustomRowBasedContext), typeof(CustomRowBasedOpenTypesContext) })); ocs.PopulateData.EntityConnection = null; using (System.Data.EntityClient.EntityConnection connection = ocs.PopulateData.CreateTableAndPopulateData()) { TestUtil.RunCombinatorialEngineFail(engine, delegate(Hashtable values) { Type contextType = (Type)values["ContextType"]; string contentFormat = (string)values["ContentFormat"]; VerifyInvalidRequest(contextType, contentFormat, uri, errorCode, headerValues); }); } }
public BackupViewModel() { if (!IsInDesignMode) { using (var ctx = new SwizSales.Core.Model.OpenPOSDbEntities()) { var efConn = new System.Data.EntityClient.EntityConnection(ctx.Connection.ConnectionString); this.backupService = new DbBackupService(efConn.StoreConnection.ConnectionString); } this.BackupPath = Properties.Settings.Default.BackupFolderPath; } }
protected void Application_Start() { string ServerPath; string UnityDB; string SubSystemDB; AreaRegistration.RegisterAllAreas(); //WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); #region "To show server name and DB name in footer" System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/"); System.Configuration.ConnectionStringSettings SSconnString; System.Configuration.ConnectionStringSettings UnityconnString; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { SSconnString = rootWebConfig.ConnectionStrings.ConnectionStrings["CRM_Entities"]; UnityconnString = rootWebConfig.ConnectionStrings.ConnectionStrings["Unity_Entities"]; //Response.Write(UnityconnString.ConnectionString.ToString()); System.Data.EntityClient.EntityConnection conn = new System.Data.EntityClient.EntityConnection(); System.Data.EntityClient.EntityConnection connUnity = new System.Data.EntityClient.EntityConnection(); conn.ConnectionString = SSconnString.ConnectionString; connUnity.ConnectionString = UnityconnString.ConnectionString; SubSystemDB = conn.StoreConnection.Database.ToString(); UnityDB = connUnity.StoreConnection.Database.ToString(); ServerPath = conn.DataSource.ToString(); @HttpContext.Current.Application["SubSystemDB"] = SubSystemDB; @HttpContext.Current.Application["ServerPath"] = ServerPath; @HttpContext.Current.Application["UnityDB"] = UnityDB; @HttpContext.Current.Application["version"] = asm.GetName().Version.ToString(); conn.Close(); connUnity.Close(); } #endregion }
internal ImageAnalyseDBEntities GetImageAnalyseEntities() { ImageAnalyseDBEntities entities = new ImageAnalyseDBEntities(connectionString); System.Data.EntityClient.EntityConnection conn = entities.Connection as System.Data.EntityClient.EntityConnection; if (string.IsNullOrEmpty(m_dbConnString)) { string ss = conn.StoreConnection.ConnectionString; m_dbConnString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Path.GetFileName(ss)); MyLog4Net.Container.Instance.Log.DebugFormat("IVXBaseLib Database file location: {0}", m_dbConnString); m_dbConnString = string.Format("data source={0}", m_dbConnString); } conn.StoreConnection.ConnectionString = m_dbConnString; return(entities); }
public Response ValidationSchedule(string bz) { using (DZEntities dzEntities = new DZEntities()) { Response response = new Response(); response.IsSuccess = true; System.Data.EntityClient.EntityConnection entityConnection = (System.Data.EntityClient.EntityConnection)dzEntities.Connection; entityConnection.Open(); System.Data.Common.DbConnection storeConnection = entityConnection.StoreConnection; System.Data.Common.DbCommand cmd = storeConnection.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "P_UN_VALIDATION"; OracleParameter[] sqlpara = new OracleParameter[3]; sqlpara[0] = new OracleParameter("p_bz", bz); sqlpara[1] = new OracleParameter("p_ErrCode", OracleDbType.Varchar2, 30); sqlpara[2] = new OracleParameter("p_ErrMsg", OracleDbType.Varchar2, 1000); sqlpara[0].Direction = ParameterDirection.Input; sqlpara[1].Direction = ParameterDirection.Output; sqlpara[2].Direction = ParameterDirection.Output; cmd.Parameters.Add(sqlpara[0]); cmd.Parameters.Add(sqlpara[1]); cmd.Parameters.Add(sqlpara[2]); cmd.ExecuteNonQuery(); if (cmd.Parameters[1].Value.ToString() == "1") { response.IsSuccess = true; response.MessageText = cmd.Parameters[2].Value.ToString(); } else { response.IsSuccess = false; response.MessageText = cmd.Parameters[2].Value.ToString(); } cmd.Dispose(); return(response); } }
public NewsgroupsEntities CreateConnection(string groupName, bool createDatabaseIfItDoesNotExist = true) { string fn = GetSqlCeDbFileName(groupName, createDatabaseIfItDoesNotExist); if (fn == null) { return(null); } var conStr = CeConnectionString.Replace("###DATABASE###", fn); //var res = new NewsgroupsEntities(conStr); // Give an open connection, so the EF4 will not always open and close the connection for each query... var edmConnection = new System.Data.EntityClient.EntityConnection(conStr); edmConnection.Open(); var res = new NewsgroupsEntities(edmConnection); //res.Connection.StateChange += // (sender, args) => System.Diagnostics.Debug.WriteLine("ConnectionState: {0} - {1}", args.CurrentState, ++ConCnt); return(res); }
public string GetConnectionString(string name) { // Try to find entity connection. var cs = ConfigurationManager.ConnectionStrings[name]; // If configuration section with not found then return. if (cs == null) { return(null); } string connectionString; if (cs.ProviderName == "System.Data.EntityClient") { // Use entity connection. var e = new System.Data.EntityClient.EntityConnection(cs.ConnectionString); connectionString = e.StoreConnection.ConnectionString; } else { // Use classic connection. connectionString = cs.ConnectionString; } var builder = new SqlConnectionStringBuilder(connectionString); if (!builder.ContainsKey("Application Name") || ".Net SqlClient Data Provider".Equals(builder["Application Name"])) { var asm = Assembly.GetEntryAssembly(); if (asm == null) { asm = Assembly.GetExecutingAssembly(); } var appPrefix = asm.GetName().Name.Replace(".", ""); var appName = string.Format("{0}", appPrefix); builder.Add("Application Name", appName); connectionString = builder.ToString(); } return(connectionString); }
public string GetConnectionString(string name) { // Try to find entity connection. var cs = ConfigurationManager.ConnectionStrings[name]; // If configuration section was not found then return. if (cs == null) { return(null); } // If entity connection then... if (cs.ProviderName == "System.Data.EntityClient") { // Use entity connection. var e = new System.Data.EntityClient.EntityConnection(cs.ConnectionString); return(e.StoreConnection.ConnectionString); } else { // Use classic connection. return(cs.ConnectionString); } }
public VehicleBrandDAOService() { //Assembly asm = Assembly.GetExecutingAssembly(); //string configFile = Path.Combine(Directory.GetParent(asm.Location).FullName, "IVXBaseLib.dll.config"); //ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); //configFileMap.ExeConfigFilename = configFile; //Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); //LogService.GetLog("Service").DebugFormat("Configuration path:{0}", config.FilePath); m_Entities = new ImageAnalyseDBEntities(connectionString); System.Data.EntityClient.EntityConnection conn = m_Entities.Connection as System.Data.EntityClient.EntityConnection; if (string.IsNullOrEmpty(m_dbConnString)) { string ss = conn.StoreConnection.ConnectionString; m_dbConnString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Path.GetFileName(ss)); MyLog4Net.Container.Instance.Log.DebugFormat("IVXBaseLib Database file location: {0}", m_dbConnString); m_dbConnString = string.Format("data source={0}", m_dbConnString); } conn.StoreConnection.ConnectionString = m_dbConnString; VehicleBrands = new List <VehicleBrand>(); VehicleBrands.AddRange(this.m_Entities.VehicleBrands); }
public void CallBackTBJ(decimal packageno) { using (Entities en = new Entities()) { // OracleParameter[] para = new OracleParameter[3]; // OracleParameter inpara = new OracleParameter(); //inpara.Direction = ParameterDirection.Input; //inpara.ParameterName = "p_packageNo"; //inpara.Value = packageno; //OracleParameter outpara1 = new OracleParameter(); //outpara1.Direction = ParameterDirection.Input; //outpara1.ParameterName = "p_ErrCode"; //OracleParameter outpara2 = new OracleParameter(); //outpara2.Direction = ParameterDirection.Input; //outpara2.ParameterName = "p_ErrMsg"; //para[0] = inpara; //para[1] = outpara1; //para[2] = outpara2; //en.ExecuteStoreCommand("P_PACKAGE_CALLBACK", para); //获取当前包装机的数据 //en.Configuration.AutoDetectChangesEnabled = false; //en.Configuration.ValidateOnSaveEnabled = false; //获取当前包装机最大条烟流水号 var cALLBACKs = (from item in en.T_PACKAGE_CALLBACK where item.EXPORT == packageno select item).ToList(); decimal maxCigNum = 1; decimal maxSortnum = 0; if (cALLBACKs.Any()) { maxSortnum = cALLBACKs.Max(a => a.SORTNUM);//获取最大的任务号 } //System.Data.EntityClient.EntityConnection entityConnection = (System.Data.EntityClient.EntityConnection)en.Connection; //entityConnection.Open(); //System.Data.Common.DbConnection storeConnection = entityConnection.StoreConnection; //System.Data.Common.DbCommand cmd = storeConnection.CreateCommand(); //cmd.CommandType = System.Data.CommandType.StoredProcedure; //cmd.CommandText = /*String sql=@"select t.billcode, * t.regioncode, * PACKTASKNUM, * normalqty, * t.PACKAGESEQ, * CIGARETTECODE, * CIGARETTENAME, * CIGTYPE, * PACKAGEQTY, * ORDERDATE, * MIANBELT, * ORDERQTY, * ALLPACKAGESEQ, * SORTNUM, * synseq,var_orderPagNum,var_shaednum,var_ordercount,var_NormalTPagNum, * var_UnnormalTPagNum,pCount,var_UnionTPagNum * from t_package_task t left join * ( select a.regioncode,a.PACKAGENO,a.billcode,var_orderPagNum,decode(var_shaednum,null,0,var_shaednum)var_shaednum,var_ordercount, * decode(var_NormalTPagNum,null,0,var_NormalTPagNum)var_NormalTPagNum, * decode(var_UnnormalTPagNum,null,0,var_UnnormalTPagNum)var_UnnormalTPagNum,pCount,decode(var_UnionTPagNum,null,0,var_UnionTPagNum)var_UnionTPagNum from * ( * select regioncode,PACKAGENO,billcode, max(PACKAGESEQ)var_orderPagNum from t_package_task group by regioncode,PACKAGENO,billcode * ) a left join (select regioncode,PACKAGENO,billcode, sum(normalqty)var_shaednum from t_package_task * * where CIGTYPE = '2' group by regioncode,PACKAGENO,billcode)b * * on a.regioncode=b.regioncode and a.PACKAGENO=b.PACKAGENO and a.billcode=b.billcode * left join ( select regioncode,count(distinct billcode)var_ordercount from t_package_task * group by regioncode)c * on c.regioncode=a.regioncode left join (select regioncode,PACKAGENO,billcode, count(distinct PACKTASKNUM ) var_NormalTPagNum from t_package_task * * where CIGTYPE = '1' group by regioncode,PACKAGENO,billcode)e * on a.regioncode=e.regioncode and a.PACKAGENO=e.PACKAGENO and a.billcode=e.billcode * left join (select regioncode,PACKAGENO,billcode, count(distinct PACKTASKNUM ) var_UnnormalTPagNum from t_package_task * * where CIGTYPE = '2' group by regioncode,PACKAGENO,billcode)f * on a.regioncode=f.regioncode and a.PACKAGENO=f.PACKAGENO and a.billcode=f.billcode * left join (select regioncode,PACKAGENO,billcode, count(distinct PACKTASKNUM ) pCount from t_package_task * * group by regioncode,PACKAGENO,billcode)g * on a.regioncode=g.regioncode and a.PACKAGENO=g.PACKAGENO and a.billcode=g.billcode * left join (select regioncode,PACKAGENO,billcode,count(1) var_UnionTPagNum from( * select * from * ( * select distinct regioncode,PACKAGENO,billcode, PACKTASKNUM from t_package_task * * where CIGTYPE = '1' group by regioncode,PACKAGENO,billcode,PACKTASKNUM) * intersect * ( * * select distinct regioncode,PACKAGENO,billcode, PACKTASKNUM from t_package_task * * where CIGTYPE = '2' group by regioncode,PACKAGENO,billcode,PACKTASKNUM * )) group by regioncode,PACKAGENO,billcode) h * on a.regioncode=h.regioncode and a.PACKAGENO=h.PACKAGENO and a.billcode=h.billcode * ) d * on t.regioncode=d.regioncode and t.packageno=d.PACKAGENO and t.billcode=d.billcode * where t.packageNo = "+packageno+@" * and sortnum > "+maxSortnum+@" * order by sortnum, packtasknum, cigtype, cigseq, SYNSEQ";*/ String sql = @"select t.billcode, t.regioncode, PACKTASKNUM, normalqty, t.PACKAGESEQ, CIGARETTECODE, CIGARETTENAME, CIGTYPE, PACKAGEQTY, ORDERDATE, MIANBELT, ORDERQTY, ALLPACKAGESEQ, SORTNUM, synseq,var_orderPagNum,var_shaednum,var_ordercount,var_NormalTPagNum, var_UnnormalTPagNum,pCount,var_UnionTPagNum from t_package_task t left join (select a.regioncode,a.PACKAGENO,a.billcode,var_orderPagNum,decode(var_shaednum,null,0,var_shaednum)var_shaednum,var_ordercount, decode(var_NormalTPagNum,null,0,var_NormalTPagNum)var_NormalTPagNum, decode(var_UnnormalTPagNum,null,0,var_UnnormalTPagNum)var_UnnormalTPagNum,pCount,decode(var_UnionTPagNum,null,0,var_UnionTPagNum)var_UnionTPagNum from (select regioncode,PACKAGENO,billcode, max(PACKAGESEQ)var_orderPagNum from t_package_task group by regioncode,PACKAGENO,billcode) a left join (select regioncode,PACKAGENO,billcode, sum(normalqty)var_shaednum from t_package_task where CIGTYPE = '2' group by regioncode,PACKAGENO,billcode)b on a.regioncode=b.regioncode and a.PACKAGENO=b.PACKAGENO and a.billcode=b.billcode left join ( select regioncode,count(distinct billcode)var_ordercount from t_package_task group by regioncode)c on c.regioncode=a.regioncode left join (select regioncode,PACKAGENO,billcode, (select count(distinct packtasknum) from t_package_task where regioncode=aa.regioncode and packageno = " + packageno + @" ) pCount from t_package_task aa group by regioncode,PACKAGENO,billcode)g on a.regioncode=g.regioncode and a.PACKAGENO=g.PACKAGENO and a.billcode=g.billcode left join (select billcode,max(var_UnionTPagNum) var_UnionTPagNum,max(var_NORMALPACKAGENUM) var_NormalTPagNum ,max(var_UNNORMALPACKAGENUM) var_UnnormalTPagNum from ( (select billcode,count(*) as var_UnionTPagNum,0 as var_NORMALPACKAGENUM, 0 as var_UNNORMALPACKAGENUM from ( select packtasknum,billcode,count(cigtype) countype from ( select packtasknum,cigtype,billcode from t_package_task group by packtasknum,billcode,cigtype ) group by packtasknum,billcode ) where countype = 2 group by billcode) union (select billcode, 0 as var_UnionTPagNum ,count(*) as var_NORMALPACKAGENUM,0 as var_UNNORMALPACKAGENUM from ( select packtasknum,billcode,cigtype from t_package_task where cigtype = '1' and packtasknum not in (select packtasknum from t_package_task where cigtype = '2' group by packtasknum,cigtype) group by packtasknum ,cigtype,billcode) group by billcode) union (select billcode,0 as var_UnionTPagNum,0 as var_NORMALPACKAGENUM,count(*) as var_UNNORMALPACKAGENUM from ( select packtasknum,billcode,cigtype from t_package_task where cigtype = '2' and packtasknum not in (select packtasknum from t_package_task where cigtype = '1' group by packtasknum,cigtype) group by packtasknum ,cigtype,billcode) group by billcode)) group by billcode) y on a.billcode = y.billcode)d on t.regioncode=d.regioncode and t.packageno=d.PACKAGENO and t.billcode=d.billcode where t.packageNo = " + packageno + @" and sortnum > " + maxSortnum + @" order by sortnum, packtasknum, cigtype, cigseq, SYNSEQ"; List <TBJModel> list = en.ExecuteStoreQuery <TBJModel>(sql, null).ToList(); var needInfo = (from item in en.V_PRODUCE_PACKAGEINFO where item.EXPORT == packageno orderby item.TASKNUM select item).ToList(); int mCopunt = 0, cigseq = 0; decimal temppackagenum = 0; V_PRODUCE_PACKAGEINFO firstTask = null; String tempbillcode = ""; // var sql_text = @" insert into T_PACKAGE_CALLBACK(BILLCODE, ROUTEPACKAGENUM, ORDERPACKAGENUM, PACKAGESEQ, CIGARETTEQTY, SHAPEDNUM, CIGARETTECODE, // CIGARETTENAME, CIGARETTETYPE, ROUTECODE, PACKAGEQTY, ORDERDATE, LINECODE, ORDERCOUNT, ORDERSEQ, CIGSEQ, EXPORT, PACKAGENUM, // ORDERQUANTITY, ADDRESS, CUSTOMERNAME, CUSTOMERNO, ORDERURL, ORDERAMOUNT, PAYFLAG, SEQ, NORMALPACKAGENUM, UNNORMALPACKAGENUM, // UNIONTASKPACKAGENUM, SORTNUM, CIGNUM, SYNSEQ)"; StringBuilder sql_text = new StringBuilder(@"insert into T_PACKAGE_CALLBACK(BILLCODE, ROUTEPACKAGENUM, ORDERPACKAGENUM, PACKAGESEQ, CIGARETTEQTY, SHAPEDNUM, CIGARETTECODE, CIGARETTENAME, CIGARETTETYPE, ROUTECODE, PACKAGEQTY, ORDERDATE, LINECODE, ORDERCOUNT, ORDERSEQ, CIGSEQ, EXPORT, PACKAGENUM, ORDERQUANTITY, ADDRESS, CUSTOMERNAME, CUSTOMERNO, ORDERURL, ORDERAMOUNT, PAYFLAG, SEQ, NORMALPACKAGENUM, UNNORMALPACKAGENUM, UNIONTASKPACKAGENUM, SORTNUM, CIGNUM, SYNSEQ)"); System.Data.EntityClient.EntityConnection entityConnection = null; System.Data.Common.DbConnection storeConnection = null; System.Data.Common.DbCommand cmd = null; //DataTable dt = new DataTable(); //dt.Columns.Add("BILLCODE", typeof(string)); //dt.Columns.Add("ROUTEPACKAGENUM", typeof(int)); //dt.Columns.Add("ORDERPACKAGENUM",typeof(int)); //dt.Columns.Add("PACKAGESEQ", typeof(int)); //dt.Columns.Add("CIGARETTEQTY", typeof(int)); //dt.Columns.Add("SHAPEDNUM", typeof(int)); //dt.Columns.Add("CIGARETTECODE", typeof(string)); //dt.Columns.Add("CIGARETTENAME", typeof(string)); //dt.Columns.Add("CIGARETTETYPE", typeof(string)); //dt.Columns.Add("ROUTECODE", typeof(string)); //dt.Columns.Add("PACKAGEQTY", typeof(int)); //dt.Columns.Add("ORDERDATE",typeof(DateTime)); //dt.Columns.Add("LINECODE", typeof(string)); //dt.Columns.Add("ORDERCOUNT", typeof(int)); //dt.Columns.Add("ORDERSEQ", typeof(int)); //dt.Columns.Add("CIGSEQ", typeof(int)); //dt.Columns.Add("EXPORT", typeof(int)); //dt.Columns.Add("PACKAGENUM", typeof(int)); //dt.Columns.Add("ORDERQUANTITY", typeof(int)); //dt.Columns.Add("ADDRESS", typeof(string)); //dt.Columns.Add("CUSTOMERNAME", typeof(string)); //dt.Columns.Add("CUSTOMERNO",typeof(string)); //dt.Columns.Add("ORDERURL", typeof(string)); //dt.Columns.Add("ORDERAMOUNT",typeof(decimal)); //dt.Columns.Add("PAYFLAG", typeof(string)); //dt.Columns.Add("SEQ", typeof(int)); //dt.Columns.Add("NORMALPACKAGENUM", typeof(int)); //dt.Columns.Add("UNNORMALPACKAGENUM", typeof(int)); //dt.Columns.Add("UNIONTASKPACKAGENUM", typeof(int)); //dt.Columns.Add("SORTNUM", typeof(int)); //dt.Columns.Add("CIGNUM", typeof(int)); //dt.Columns.Add("SYNSEQ", typeof(int)); //OracleBulkCopy copy = new OracleBulkCopy("DATA SOURCE=czt-test;PASSWORD=hnzt123;PERSIST SECURITY INFO=True;USER ID=zoomtel", OracleBulkCopyOptions.Default); //copy.BatchSize = 10000; //copy.BulkCopyTimeout = 2000; //copy.DestinationTableName = "t_package_callback"; TBJModel items = null; for (var j = 0; j < list.Count; j++) { items = list[j]; if (tempbillcode == "") { tempbillcode = items.billcode; } else if (tempbillcode != items.billcode) { needInfo = needInfo.Where(x => x.BILLCODE != tempbillcode).ToList(); tempbillcode = items.billcode; } firstTask = needInfo.Where(a => a.BILLCODE == items.billcode).FirstOrDefault(); for (int i = 1; i <= items.normalqty; i++)// { if (temppackagenum == 0 || temppackagenum != items.PACKTASKNUM) { temppackagenum = items.PACKTASKNUM; cigseq = 0; } cigseq++; mCopunt++; //DataRow dr = dt.NewRow(); //dr[0] = items.billcode; //dr[1] = items.pCount; //dr[2] = items.var_orderPagNum; //dr[3] = items.PACKAGESEQ; //dr[4] = 1; //dr[5] = items.var_shaednum; //dr[6] = items.CIGARETTECODE; //dr[7] = items.CIGARETTENAME; //dr[8] = items.CIGTYPE; //dr[9] = items.regioncode; //dr[10] = items.PACKAGEQTY; //dr[11] = items.ORDERDATE; //dr[12] = items.MIANBELT.ToString(); //dr[13] = items.var_ordercount; //dr[14] = firstTask.SORTSEQ; //dr[15] = cigseq; //dr[16] = packageno; //dr[17] = packageno; //dr[18] = items.ORDERQTY; //dr[19] = firstTask.CONTACTADDRESS; //dr[20] = firstTask.CUSTOMERNAME; //dr[21] = firstTask.CUSTOMERCODE; //dr[22] = firstTask.URL; //dr[23] = firstTask.TOTALAMOUNT; //dr[24] = firstTask.CUSTTYPE; //dr[25] = items.ALLPACKAGESEQ; //dr[26] = items.var_UnionTPagNum; //dr[27] = items.var_NormalTPagNum; //dr[28] = items.var_UnnormalTPagNum; //dr[29] = items.SORTNUM; //dr[30] = maxCigNum++; //dr[31] = items.synseq; //dt.Rows.Add(dr); //if (dt.Rows.Count >= 10000) //{ // // entityConnection = (System.Data.EntityClient.EntityConnection)en.Connection; // //entityConnection.Open(); // copy.WriteToServer(dt); // // entityConnection.Close(); // dt.Rows.Clear(); // GC.Collect(); //} //T_PACKAGE_CALLBACK tb = new T_PACKAGE_CALLBACK(); //tb.BILLCODE = item.billcode;//订单 //tb.ROUTEPACKAGENUM = item.pCount;//车组总包数 //tb.ORDERPACKAGENUM = item.var_orderPagNum;//订单总包数 //tb.PACKAGESEQ = item.PACKAGESEQ;//订单内包序 //tb.CIGARETTEQTY = 1;//品牌条烟数 //tb.SHAPEDNUM = item.var_shaednum;//订单异型烟数量 //tb.CIGARETTECODE = item.CIGARETTECODE;//卷烟编码 //tb.CIGARETTENAME = item.CIGARETTENAME;//卷烟名称 //tb.CIGARETTETYPE = item.CIGTYPE;//卷烟类型 //tb.ROUTECODE = item.regioncode;//车组编号 //tb.PACKAGEQTY = item.PACKAGEQTY;//包内条烟数量 //tb.ORDERDATE = item.ORDERDATE;//订单日期 //tb.LINECODE = item.MIANBELT.ToString();//线路编号 //tb.ORDERCOUNT = item.var_ordercount; //车组内订单数 //tb.ORDERSEQ = firstTask.SORTSEQ;//订单户序 firstTask.SORTSEQ ////tb.CIGSEQ = cigseq++;//条烟顺序 //tb.EXPORT = packageno;//出口号(包装机号) //tb.PACKAGENUM = packageno;// 包装机号 //tb.ORDERQUANTITY = item.ORDERQTY;//订单总数 //tb.ADDRESS = firstTask.CONTACTADDRESS;//订单地址 //tb.CUSTOMERNAME = firstTask.CUSTOMERNAME;//客户名称 //tb.CUSTOMERNO = firstTask.CUSTOMERCODE;//客户编码 //tb.ORDERURL = firstTask.URL;//客户URL //tb.ORDERAMOUNT = firstTask.TOTALAMOUNT;//订单总金额; //tb.PAYFLAG = firstTask.CUSTTYPE;//结算状态 //tb.SEQ = item.ALLPACKAGESEQ;//整齐包序 //tb.UNIONTASKPACKAGENUM = item.var_UnionTPagNum;//合包总包数 //tb.NORMALPACKAGENUM = item.var_NormalTPagNum;//常规烟总包数 //tb.UNNORMALPACKAGENUM = item.var_UnnormalTPagNum;//异型烟总包数 //tb.SORTNUM = item.SORTNUM;//流水号 //tb.CIGNUM = maxCigNum++;// 每台包装机从1 增长 //tb.SYNSEQ = item.synseq;//批次号 //en.T_PACKAGE_CALLBACK.AddObject(tb); // sql_text=sql_text +" select '" + item.billcode +"',"+ item.pCount+","+ item.var_orderPagNum+"," +item.PACKAGESEQ+ ","+ // 1+"," + item.var_shaednum+",'" + item.CIGARETTECODE+"','"+ item.CIGARETTENAME+"','"+ item.CIGTYPE+"','"+ item.regioncode+"',"+ // item.PACKAGEQTY + ",to_date('" + item.ORDERDATE.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'),'" + item.MIANBELT.ToString() + "'," + item.var_ordercount + "," + firstTask.SORTSEQ + "," + 1 + "," + packageno + "," // + packageno+","+ item.ORDERQTY+",'"+ //firstTask.CONTACTADDRESS+"','" +firstTask.CUSTOMERNAME+"','"+ firstTask.CUSTOMERCODE+"','" +firstTask.URL+"',"+ firstTask.TOTALAMOUNT+",'"+ firstTask.CUSTTYPE+"'," +item.ALLPACKAGESEQ+"," +item.var_NormalTPagNum+"," //+item.var_UnnormalTPagNum+","+ item.var_UnionTPagNum+","+ // item.SORTNUM+","+ (maxCigNum++)+","+ item.synseq +" from dual union"; sql_text = sql_text.Append(" select '").Append(items.billcode).Append("',").Append(items.pCount) .Append(",").Append(items.var_orderPagNum).Append(",").Append(items.PACKAGESEQ).Append(",") .Append(1).Append(",").Append(items.var_shaednum).Append(",'").Append(items.CIGARETTECODE).Append("','") .Append(items.CIGARETTENAME).Append("','").Append(items.CIGTYPE).Append("','").Append(items.regioncode) .Append("',").Append(items.PACKAGEQTY).Append(",to_date('").Append(items.ORDERDATE.ToString("yyyy-MM-dd")) .Append("','yyyy-mm-dd'),'").Append(items.MIANBELT.ToString()).Append("',").Append(items.var_ordercount) .Append(",").Append(firstTask.SORTSEQ).Append(",") .Append(cigseq) .Append(",").Append(packageno).Append(",").Append(packageno).Append(",").Append(items.ORDERQTY).Append(",'") .Append(firstTask.CONTACTADDRESS).Append("','").Append(firstTask.CUSTOMERNAME).Append("','") .Append(firstTask.CUSTOMERCODE).Append("','").Append(firstTask.URL).Append("',").Append(firstTask.TOTALAMOUNT) .Append(",'").Append(firstTask.CUSTTYPE).Append("',").Append(items.ALLPACKAGESEQ).Append(",") .Append(items.var_NormalTPagNum).Append(",").Append(items.var_UnnormalTPagNum).Append(",") .Append(items.var_UnionTPagNum).Append(",").Append(items.SORTNUM).Append(",").Append(maxCigNum++) .Append(",").Append(items.synseq).Append(" from dual union"); if (mCopunt >= 200) { entityConnection = (System.Data.EntityClient.EntityConnection)en.Connection; entityConnection.Open(); storeConnection = entityConnection.StoreConnection; cmd = storeConnection.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sql_text.ToString().Substring(0, sql_text.Length - 5); cmd.ExecuteNonQuery(); cmd.Dispose(); cmd = null; entityConnection.Close(); entityConnection = null; storeConnection = null; sql_text.Clear(); GC.Collect(); mCopunt = 0; sql_text.Append(@" insert into T_PACKAGE_CALLBACK(BILLCODE, ROUTEPACKAGENUM, ORDERPACKAGENUM, PACKAGESEQ, CIGARETTEQTY, SHAPEDNUM, CIGARETTECODE, CIGARETTENAME, CIGARETTETYPE, ROUTECODE, PACKAGEQTY, ORDERDATE, LINECODE, ORDERCOUNT, ORDERSEQ, CIGSEQ, EXPORT, PACKAGENUM, ORDERQUANTITY, ADDRESS, CUSTOMERNAME, CUSTOMERNO, ORDERURL, ORDERAMOUNT, PAYFLAG, SEQ, NORMALPACKAGENUM, UNNORMALPACKAGENUM, UNIONTASKPACKAGENUM, SORTNUM, CIGNUM, SYNSEQ)"); } } firstTask = null; } if (sql_text.ToString().Contains("union")) { entityConnection = (System.Data.EntityClient.EntityConnection)en.Connection; entityConnection.Open(); storeConnection = entityConnection.StoreConnection; cmd = storeConnection.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sql_text.ToString().Substring(0, sql_text.Length - 5); cmd.ExecuteNonQuery(); cmd.Dispose(); cmd = null; entityConnection.Close(); entityConnection = null; storeConnection = null; } sql_text.Clear(); } }
public EntityDataSource(System.Data.EntityClient.EntityConnection connection) : this() { _connection = connection; }
/// <summary> /// Constructor initializing our EDM connection using the connection /// </summary> /// <param name="connectionStringKey"></param> public AbstractCfEntitiesEf4DA(System.Data.EntityClient.EntityConnection connection) { Ctx = new cfEntitiesData(connection); }
public AstoriaTestObjectContext(System.Data.EntityClient.EntityConnection connection, string defaultContainerName) : base(connection, defaultContainerName) { }
public AstoriaTestObjectContext(System.Data.EntityClient.EntityConnection connection) : base(connection) { }
public void FilterNavigationWithAnyAll() { ocs.PopulateData.EntityConnection = null; using (OpenWebDataServiceHelper.AcceptAnyAllRequests.Restore()) using (System.Data.EntityClient.EntityConnection connection = ocs.PopulateData.CreateTableAndPopulateData()) { OpenWebDataServiceHelper.AcceptAnyAllRequests.Value = true; Type[] types = new Type[] { typeof(ocs.CustomObjectContext), typeof(CustomDataContext), typeof(CustomRowBasedContext) }; var testCases = new[] { new { filters = new string[] { "Orders/any() eq false", "Orders/any() and ID eq 100", "Orders/any(o: o/ID eq 500)", "Orders/any(o: o/ID eq 100 and o/$(Customer)/ID ne 0)", "Orders/any(o: isof(o/$(Customer),'$(CustomerWithBirthDayType)') and o/$(Customer)/ID ne 1)", "Orders/all(o: o/$(Customer)/ID eq 1 and $it/ID ne 1)", "Orders/all(o: o/ID eq 100)", "Orders/all(o: o/ID eq $it/ID)", "Orders/all(o: o/$(Customer)/Orders/any() eq false)", "Orders/all(o: $it/ID eq 1 and o/$(Customer)/Orders/any(o1: o1/ID eq 500))", "Orders/all(o: isof(o/$(Customer),'$(CustomerWithBirthDayType)') and o/$(Customer)/ID ne 1)", }, xpaths = new string[] { "count(//atom:entry)=0" } }, new { filters = new string[] { "Orders/any()", "Orders/any() and ID lt 100", "ID lt 100 and Orders/any()", "Orders/all(o: o/$(Customer)/Orders/any())", }, xpaths = new string[] { "count(//atom:entry)=3" } }, new { filters = new string[] { "Orders/any() and (ID eq 1)", "Orders/any() and isof('$(CustomerWithBirthDayType)')", "Orders/any(o: $it/ID eq 1)", "Orders/any(o: o/$(Customer)/ID eq 1)", "Orders/any(o: isof(o/$(Customer), '$(CustomerWithBirthDayType)'))", "Orders/all(o: $it/ID eq 1)", "Orders/all(o: o/$(Customer)/ID eq 1)", "Orders/all(o: isof(o/$(Customer), '$(CustomerWithBirthDayType)'))", // using the same range variable name in multiple not-nested predicates "Orders/any(o: o/$(Customer)/ID eq 1) and Orders/all(o: o/$(Customer)/ID eq 1)", // nested queries "Orders/any(o: o/$(Customer)/Orders/any(o1: o1/$(Customer)/Orders/all(o2: o2/$(Customer)/ID eq 1)) or $it/ID eq 1)", "Orders/all(o: $it/ID eq 1 and o/$(Customer)/Orders/all(o1: o1/$(Customer)/Orders/any(o2: o2/$(Customer)/ID eq 1)))", // keywords "Orders/any(event: event/$(Customer)/ID eq 1)", "Orders/any(while: while/$(Customer)/ID eq 1)", }, xpaths = new string[] { "count(//atom:entry)=1", "boolean(//atom:entry/atom:category[contains(@term,'CustomerWithBirthday')])" } } }; TestUtil.RunCombinations(types, (type) => { using (TestWebRequest request = TestWebRequest.CreateForInProcess()) { request.DataServiceType = type; request.StartService(); TestUtil.RunCombinations(testCases, (testCase) => { foreach (var str in testCase.filters) { string filter = UnitTestsUtil.ProcessStringVariables(str, (variable) => { if (type == typeof(ocs.CustomObjectContext)) { switch (variable) { case "Customer": return("Customers"); case "CustomerWithBirthDayType": return("AstoriaUnitTests.ObjectContextStubs.Types.CustomerWithBirthday"); } } else if (type == typeof(CustomDataContext)) { switch (variable) { case "CustomerWithBirthDayType": return("AstoriaUnitTests.Stubs.CustomerWithBirthday"); } } else if (type == typeof(CustomRowBasedContext)) { switch (variable) { case "CustomerWithBirthDayType": return("AstoriaUnitTests.Stubs.CustomerWithBirthday"); } } return(variable); }); request.RequestUriString = "/Customers?$format=atom&$filter=" + filter; request.SendRequest(); var response = request.GetResponseStreamAsXDocument(); UnitTestsUtil.VerifyXPaths(response, testCase.xpaths); } }); } }); } }