Exemple #1
0
        static void Main(string[] args)
        {
            custom c_1 = new custom();
            custom c_2 = new custom(5);
            custom c_3 = new custom(3, 6);

            Console.WriteLine(
                "c_1 is empty, c_2 atrib_1 = {0}, c_2 atrib_2 = {1}, c_3 atrib_1 = {2}, c_3 atrib_2 = {3}",
                c_2.atrib_1, c_2.atrib_2, c_3.atrib_1, c_3.atrib_2
                );
            Console.WriteLine(
                "c_2 func 1 = {0}, 2 = {1}, 3 = {2}", c_2.func(2),
                c_2.func(1, 2), c_2.func(1, (int)2.3)
                );
            Console.WriteLine(
                "c_3 func 1 = {0}, 2 = {1}, 3 = {2}", c_3.func(2),
                c_3.func(1, 2), c_3.func(1, (int)2.3)
                );
            custom c_sum = new custom();

            c_sum = c_2 + c_3;
            Console.WriteLine("c_sum atrib_1 = {0}, atrib_2 = {1}", c_sum.atrib_1, c_sum.atrib_2);
            c_sum = c_2 - c_3;
            Console.WriteLine("c_diff atrib_1 = {0}, atrib_2 = {1}", c_sum.atrib_1, c_sum.atrib_2);
            bool c_comp = c_sum > c_3;

            Console.WriteLine(c_comp);
            Console.ReadKey();
        }
Exemple #2
0
            public static custom operator -(custom c_1, custom c_2)
            {
                custom c_res = new custom(
                    c_1.atrib_1 - c_2.atrib_1,
                    c_1.atrib_2 - c_2.atrib_2);

                return(c_res);
            }
        /// <summary>
        /// 导入excell中的客户信息到custom表
        /// </summary>
        /// <returns></returns>
        public string UploadExcel()
        {
            try
            {
                string    s  = "导入成功!";
                DataTable dt = new DataTable();
                pbxdatasourceDataContext context = new pbxdatasourceDataContext();
                HttpPostedFileBase       file1   = Request.Files[0];
                string newFile  = DateTime.Now.ToString("yyyyMMddHHmmss");
                string filePath = newFile + file1.FileName;                                         //生成新名字
                file1.SaveAs(Server.MapPath("~/Uploadxls/" + filePath));                            //存到本地
                dt = GetExcellData(Server.MapPath("~/Uploadxls/" + filePath), "Sheet1$").Tables[0]; //把excel转换成datatable
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i][0].ToString() != "")
                    {
                        int check = context.custom.Where(a => a.CustomerId == dt.Rows[i][0].ToString()).Count();//查询是否存在

                        if (check > 0)
                        {
                            s += dt.Rows[i][0] + ":已存在<br />";
                        }
                        else
                        {
                            custom cu = new custom()
                            {
                                CustomerId        = dt.Rows[i][0].ToString(),
                                Shop              = dt.Rows[i][1].ToString(),
                                Contactperson     = dt.Rows[i][2].ToString(),
                                Sex               = dt.Rows[i][3].ToString() == "女" ? 0 : 1,
                                Age               = Convert.ToInt32(dt.Rows[i][4].ToString()),
                                Birthday          = Convert.ToDateTime(dt.Rows[i][5].ToString()).ToString("yyyy-MM-dd"),
                                IDNumber          = dt.Rows[i][6].ToString(),
                                Telephone         = dt.Rows[i][7].ToString(),
                                Phone             = dt.Rows[i][8].ToString(),
                                Weixin            = dt.Rows[i][9].ToString(),
                                QQNo              = dt.Rows[i][10].ToString(),
                                CustomerLevel     = dt.Rows[i][11].ToString(),
                                Remark            = dt.Rows[i][12].ToString(),
                                CustomerServiceId = Convert.ToInt32(dt.Rows[i][13].ToString()),
                            };
                            context.custom.InsertOnSubmit(cu);
                            context.SubmitChanges();
                        }
                    }
                }
                return(s);
            }
            catch (Exception ex)
            {
                return("导入失败!");
            }
        }
Exemple #4
0
        public string Post(getData data)
        {
            custom get    = new custom();
            string result = "";

            if (data == null)
            {
                result = get.getData("");
            }
            else
            {
                result = get.getData(data.code);
            }
            return(result);
        }
 l.textures.ChangeEdge(custom.Text);
Exemple #6
0
        public static Object CUSTOM_IDENTIFIER_SET( custom  c,
						  byte[]  s )
        {
            c.identifier= s;
            return unspecified._unspecified;
        }
Exemple #7
0
 public static byte[] CUSTOM_IDENTIFIER( custom  c )
 {
     return c.identifier;
 }
Exemple #8
0
 public static int CUSTOM_HASH_NUMBER( custom  c )
 {
     return c.hash();
 }
Exemple #9
0
        public static bool CUSTOM_CMP( custom  c1,
				     custom  c2 )
        {
            return c1.equal( c2 );
        }
Exemple #10
0
 public bool Delete(custom c)
 {
     return(_repository.Delete(c));
 }
Exemple #11
0
 public bool UpdateSubFields(custom entity, List <string> fileds)
 {
     return(_repository.UpdateSubFields(entity, fileds));
 }
Exemple #12
0
 public bool Update(custom c)
 {
     return(_repository.Update(c));
 }
Exemple #13
0
 public bool Insert(custom c)
 {
     return(_repository.Insert(c));
 }
Exemple #14
0
        public List <custom> GetCustomList(string keyWord, int page, int perPage, out int UCount)
        {
            List <custom> lc = new List <custom>();

            string sql = "select * from t_user where 1=1 " + keyWord + " order by addOn desc";
            Dictionary <int, user> Dic = new Dictionary <int, user>();

            try
            {
                using (DataTable dt = helper.GetDataTable(sql))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            user u = new user()
                            {
                                addOn    = Convert.ToDateTime(r["addOn"]),
                                area     = r["area"].ToString(),
                                contact  = r["contact"].ToString(),
                                sex      = Convert.ToInt16(r["sex"]),
                                photoUrl = r["photoUrl"].ToString(),
                                nickName = r["nickName"].ToString(),
                                mobile   = r["mobile"].ToString(),
                                openId   = r["openid"].ToString(),
                                id       = Convert.ToInt32(r["id"]),
                                source   = r["source"].ToString()
                            };
                            if (!Dic.ContainsKey(u.id))
                            {
                                Dic.Add(u.id, u);
                            }
                        }
                    }
                }
            }
            catch { }

            int Count = 0;

            try
            {
                Count = Convert.ToInt32(helper.GetOne("select count(distinct userId) as t from t_order where userId in(select id from t_user where 1=1 " + keyWord + ") and isPay = 1 and state < 9"));
            }
            catch
            {
                Count = 0;
            }
            UCount = Count;
            //统计数据
            sql = "select userId,count(*) as t,sum(allPrice) as p from t_order where userId in(select id from t_user where 1=1 " + keyWord + ") and isPay = 1 and state < 9 group by userId order by t desc limit " + (page - 1) * perPage + "," + perPage;
            try
            {
                using (DataTable dt = helper.GetDataTable(sql))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        user u = null;
                        foreach (DataRow r in dt.Rows)
                        {
                            u = null;
                            if (Dic.ContainsKey(Convert.ToInt16(r["userId"])))
                            {
                                u = (user)Dic[Convert.ToInt16(r["userId"])];
                            }
                            if (u != null)
                            {
                                custom c = new custom()
                                {
                                    addOn      = u.addOn,
                                    area       = u.area,
                                    contact    = u.contact,
                                    sex        = u.sex,
                                    photoUrl   = u.photoUrl,
                                    nickName   = u.nickName,
                                    mobile     = u.mobile,
                                    openId     = u.openId,
                                    id         = u.id,
                                    source     = u.source,
                                    sourceName = ""
                                };
                                c.orderNum = Convert.ToInt16(r["t"]);
                                c.orderAll = Convert.ToDouble(r["p"]);
                                try
                                {
                                    if (Convert.ToInt16(c.source) > 0)
                                    {
                                        user us = new _User().GetUser("", "", Convert.ToInt16(c.source));
                                        if (us != null)
                                        {
                                            c.sourceName = us.nickName;
                                        }
                                    }
                                }
                                catch { }
                                lc.Add(c);
                            }
                        }
                    }
                }
            }
            catch { }
            return(lc);
        }
Exemple #15
0
        private DataConnection?GetConnection(string provider, string?providerLocation, string connectionString, string?additionalConnectionString, out DataConnection?secondaryConnection)
        {
            secondaryConnection = null;
            var returnSecondary = false;

            // general rules:
            // - specify specific provider used by tool if linq2db supports multiple providers for database
            // - if multiple dialects (versions) of db supported - make sure version detection enabled
            // other considerations:
            // - generate error for databases with windows-only support (e.g. access, sqlce)
            // - allow user to specify provider discovery hints (e.g. provider path) for unmanaged providers
            switch (provider)
            {
            case ProviderName.SQLite:
                provider = ProviderName.SQLiteClassic;
                break;

            case ProviderName.SqlServer:
                SqlServerTools.AutoDetectProvider = true;
                SqlServerTools.Provider           = SqlServerProvider.MicrosoftDataSqlClient;
                break;

            case ProviderName.Firebird:
                // TODO: don't forget to add versioning here after Firebird versioning feature merged
                break;

            case ProviderName.MySql:
                // TODO: remove provider hint after MySQL.Data support removed
                provider = ProviderName.MySqlConnector;
                break;

            case ProviderName.Oracle:
                OracleTools.AutoDetectProvider = true;
                provider = ProviderName.OracleManaged;
                break;

            case ProviderName.PostgreSQL:
                PostgreSQLTools.AutoDetectProvider = true;
                break;

            case ProviderName.Sybase:
                provider = ProviderName.SybaseManaged;
                break;

            case ProviderName.SqlCe:
            {
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    Console.Error.WriteLine($"SQL Server Compact Edition not supported on non-Windows platforms");
                    return(null);
                }

                var assemblyPath = providerLocation ?? Path.Combine(Environment.GetEnvironmentVariable(IntPtr.Size == 4 ? "ProgramFiles(x86)" : "ProgramFiles") !, @"Microsoft SQL Server Compact Edition\v4.0\Private\System.Data.SqlServerCe.dll");
                if (!File.Exists(assemblyPath))
                {
                    Console.Error.WriteLine(@$ "Cannot locate Server Compact Edition installation.
Probed location: {assemblyPath}.
Possible reasons:
1. SQL Server CE not installed => install SQL CE runtime (e.g. from here https://www.microsoft.com/en-us/download/details.aspx?id=30709)
2. SQL Server CE runtime architecture doesn't match process architecture => add '--architecture x86' or '--architecture x64' scaffold option
3. SQL Server CE runtime has custom location => specify path to System.Data.SqlServerCe.dll using '--provider-location <path_to_assembly>' option");
                    return(null);
                }

                var assembly = Assembly.LoadFrom(assemblyPath);
                DbProviderFactories.RegisterFactory("System.Data.SqlServerCe.4.0", assembly.GetType("System.Data.SqlServerCe.SqlCeProviderFactory") !);
                break;
            }

            case ProviderName.SapHana:
            {
                var isOdbc = connectionString.Contains("HDBODBC", StringComparison.OrdinalIgnoreCase);
                if (!isOdbc && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    Console.Error.WriteLine($"Only ODBC provider for SAP HANA supported on non-Windows platforms. Provided connection string doesn't look like HANA ODBC connection string.");
                    return(null);
                }

                provider = isOdbc ? ProviderName.SapHanaOdbc : ProviderName.SapHanaNative;

                if (!isOdbc)
                {
                    var assemblyPath = providerLocation ?? Path.Combine(Environment.GetEnvironmentVariable(IntPtr.Size == 4 ? "ProgramFiles(x86)" : "ProgramFiles") !, @"sap\hdbclient\dotnetcore\v2.1\Sap.Data.Hana.Core.v2.1.dll");
                    if (!File.Exists(assemblyPath))
                    {
                        Console.Error.WriteLine(@$ "Cannot locate SAP HANA native client installation.
Probed location: {assemblyPath}.
Possible reasons:
1. HDB client not installed => install HDB client for .net core
2. HDB architecture doesn't match process architecture => add '--architecture x86' or '--architecture x64' scaffold option
3. HDB client installed at custom location => specify path to Sap.Data.Hana.Core.v2.1.dll using '--provider-location <path_to_assembly>' option");
                        return(null);
                    }

                    var assembly = Assembly.LoadFrom(assemblyPath);
                    DbProviderFactories.RegisterFactory("Sap.Data.Hana", assembly.GetType("Sap.Data.Hana.HanaFactory") !);
                }
                break;
            }

            case ProviderName.Informix:
            case ProviderName.DB2:
            {
                if (provider == ProviderName.Informix)
                {
                    provider = ProviderName.InformixDB2;
                }
                else
                {
                    DB2Tools.AutoDetectProvider = true;
                }

                if (providerLocation == null || !File.Exists(providerLocation))
                {
                    // we cannot add 90 Megabytes (compressed size) of native provider for single db just because we can
                    // note: we use IBM.Data.DB2.Core because Net.IBM.Data.Db2 and Net5.IBM.Data.Db2 require
                    // net6/net5 runtime and fail to load if .net core 3.1 runtime used to run tool (default runtime for tool)
                    Console.Error.WriteLine(@$ "Cannot locate IBM.Data.DB2.Core.dll provider assembly.
Due to huge size of it, we don't include IBM.Data.DB2 provider into installation.
You need to install it manually and specify provider path using '--provider-location <path_to_assembly>' option.
Provider could be downloaded from:
- for Windows: https://www.nuget.org/packages/Net.IBM.Data.DB2.Core
- for Linux: https://www.nuget.org/packages/Net.IBM.Data.DB2.Core-lnx
- for macOS: https://www.nuget.org/packages/Net.IBM.Data.DB2.Core-osx");
                    return(null);
                }

                var assembly = Assembly.LoadFrom(providerLocation);
                DbProviderFactories.RegisterFactory("IBM.Data.DB2", assembly.GetType($"{assembly.GetName().Name}.DB2Factory") !);
                break;
            }

            case ProviderName.Access:
            {
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    Console.Error.WriteLine($"MS Access not supported on non-Windows platforms");
                    return(null);
                }

                var isOleDb = connectionString.Contains("Microsoft.Jet.OLEDB", StringComparison.OrdinalIgnoreCase) ||
                              connectionString.Contains("Microsoft.ACE.OLEDB", StringComparison.OrdinalIgnoreCase);

                if (!isOleDb)
                {
                    provider = ProviderName.AccessOdbc;
                }

                if (additionalConnectionString == null)
                {
                    Console.Out.WriteLine($"WARNING: it is recommended to use '--additional-connection <secondary_connection>' option with Access for better results");
                }
                else
                {
                    var isSecondaryOleDb = additionalConnectionString.Contains("Microsoft.Jet.OLEDB", StringComparison.OrdinalIgnoreCase) ||
                                           additionalConnectionString.Contains("Microsoft.ACE.OLEDB", StringComparison.OrdinalIgnoreCase);

                    if (isOleDb == isSecondaryOleDb)
                    {
                        Console.Error.WriteLine($"Main and secondary connection strings must use different providers. One should be OLE DB provider and another ODBC provider.");
                        return(null);
                    }

                    var secondaryProvider = isSecondaryOleDb ? ProviderName.Access : ProviderName.AccessOdbc;

                    var secondaryDataProvider = DataConnection.GetDataProvider(secondaryProvider, additionalConnectionString);
                    if (secondaryDataProvider == null)
                    {
                        Console.Error.WriteLine($"Cannot create database provider '{provider}' for secondary connection");
                        return(null);
                    }

                    secondaryConnection = new DataConnection(secondaryDataProvider, additionalConnectionString);
                    // to simplify things for caller (no need to detect connection type)
                    // returned connection should be OLE DB and additional - ODBC
                    returnSecondary = isSecondaryOleDb;
                }

                break;
            }

            default:
                Console.Error.WriteLine($"Unsupported database provider: {provider}");
                return(null);
            }

            var dataProvider = DataConnection.GetDataProvider(provider, connectionString);

            if (dataProvider == null)
            {
                Console.Error.WriteLine($"Cannot create database provider: {provider}");
                secondaryConnection?.Dispose();
                return(null);
            }

            var dc = new DataConnection(dataProvider, connectionString);

            if (secondaryConnection != null && returnSecondary)
            {
                var tmp = secondaryConnection;
                secondaryConnection = dc;
                return(tmp);
            }

            return(dc);
        }