Ejemplo n.º 1
0
        public void ProductTest()
        {
            LiveEntities oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            oLiveEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 2
0
        public void MemberTest2()
        {
            LiveEntities oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            GeneralResource ResourceB = new GeneralResource
            {
                Rtype = (byte)ModelEnum.ResourceType.STRING,
                Code = "ResourceB",
                Culture = 1033,
                Matter = "ResourceTest2"
            };

            GeneralResItem ResItemA = new GeneralResItem
            {
                Culture = 1033,
                Matter = "this is the resource's son",
                Cash = 3.08m,
                Resource = ResourceB
            };

            oLiveEntities.GeneralResItems.Add(ResItemA);
            oLiveEntities.SaveChanges();

            oLiveEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 3
0
        public void MemberTest()
        {
            LiveEntities oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            GeneralResource ResourceA = new GeneralResource
            {
                Rtype = (byte)ModelEnum.ResourceType.STRING,
                Code = "ResourceA",
                Culture = 1033,
                Matter = "ResourceTest"
            };

            oLiveEntities.GeneralResources.Add(ResourceA);
            oLiveEntities.SaveChanges();

            oLiveEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 4
0
        public void MemberTest()
        {
            LiveEntities oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            MemberOrganization ResourceA = new MemberOrganization
            {

                Code="123456"

            };
            MemberOrganization ResourceB = new MemberOrganization
            {
                Code = "2345",
                CellPhone = "123456"
            };

            oLiveEntities.MemberOrganizations.Add(ResourceA);
            oLiveEntities.MemberOrganizations.Add(ResourceB);
            oLiveEntities.SaveChanges();

            oLiveEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 5
0
 private static void Test04()
 {
     LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);
     MemberUser oUser = new MemberUser
     {
         Passcode = "hello world"
     };
     oGeneralEntities.Dispose();
     GC.Collect();
 }
Ejemplo n.º 6
0
        private static void Test03()
        {
            LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);
            // 指定Child方式
            GeneralLargeItem oItemA1 = new GeneralLargeItem
            {
                Culture = 1033,
                CLOB = "hello, this is a long text (en-US)",
                Source = (byte)ModelEnum.LargeObjectSource.NONE
            };
            GeneralLargeItem oItemA2 = new GeneralLargeItem
            {
                Culture = 1036,
                CLOB = "hello, this is a long text (fr-FR)",
                Source = (byte)ModelEnum.LargeObjectSource.NONE
            };
            GeneralLargeObject oLargeA = new GeneralLargeObject
            {
                CLOB = "hello, there are parents",
                Source = (byte)ModelEnum.LargeObjectSource.DATEBASE,
                LargeItems = new List<GeneralLargeItem> { oItemA1, oItemA2 }
            };
            // 指定Parent方式
            GeneralLargeObject oLargeB = new GeneralLargeObject
            {
                CLOB = "hello, there are parents",
                Source = (byte)ModelEnum.LargeObjectSource.DATEBASE
            };
            GeneralLargeItem oItemB1 = new GeneralLargeItem
            {
                Culture = 1033,
                CLOB = "hello, this is a long text (en-US)",
                Source = (byte)ModelEnum.LargeObjectSource.NONE,
                LargeObject = oLargeB
            };
            GeneralLargeItem oItemB2 = new GeneralLargeItem
            {
                Culture = 1036,
                CLOB = "hello, this is a long text (fr-FR)",
                Source = (byte)ModelEnum.LargeObjectSource.NONE,
                LargeObject = oLargeB
            };

            oGeneralEntities.GeneralLargeObjects.Add(oLargeA);

            oGeneralEntities.GeneralLargeItems.Add(oItemB1);
            oGeneralEntities.GeneralLargeItems.Add(oItemB2);

            oGeneralEntities.SaveChanges();

            var oResources = oGeneralEntities.GeneralLargeObjects.Include("GeneralLargeItems");
            foreach (GeneralLargeObject obj1 in oResources.ToList())
            {
                Console.WriteLine(obj1.CLOB);
                foreach (GeneralLargeItem obj2 in obj1.LargeItems)
                {
                    CultureInfo oCulture = new CultureInfo(obj2.Culture);
                    Console.WriteLine("    " + oCulture.NativeName + " " + obj2.CLOB);
                }
            }
            oGeneralEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 7
0
        private static void Test02(string s)
        {
            LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);
            // 指定Child方式
            GeneralResItem oResItemA1 = new GeneralResItem
            {
                Culture = 1033,
                Matter = "Product Name (En)"
            };
            GeneralResItem oResItemA2 = new GeneralResItem
            {
                Culture = 1036,
                Matter = "Product Name (Fr)"
            };
            GeneralResource oResourceA = new GeneralResource
            {
                Rtype = (byte)ModelEnum.ResourceType.STRING,
                Matter = "产品名称",
                ResourceItems = new List<GeneralResItem> { oResItemA1, oResItemA2 }
            };
            // 指定Parent方式
            GeneralResource oResourceB = new GeneralResource
            {
                Rtype = (byte)ModelEnum.ResourceType.MONEY,
                Matter = "产品名称"
            };
            GeneralResItem oResItemB1 = new GeneralResItem
            {
                Culture = 1033,
                Matter = "Product Name (En)",
                Resource = oResourceB
            };
            GeneralResItem oResItemB2 = new GeneralResItem
            {
                Culture = 1036,
                Matter = "Product Name (Fr)",
                Resource = oResourceB
            };

            oGeneralEntities.GeneralResources.Add(oResourceA);
            oGeneralEntities.GeneralResItems.Add(oResItemB1);
            oGeneralEntities.GeneralResItems.Add(oResItemB2);
            oGeneralEntities.SaveChanges();

            var oResources = oGeneralEntities.GeneralResources.Include("GeneralResItems");
            foreach (GeneralResource obj1 in oResources.ToList())
            {
                Console.WriteLine(obj1.Matter);
                foreach (GeneralResItem obj2 in obj1.ResourceItems)
                {
                    CultureInfo oCulture = new CultureInfo(obj2.Culture);
                    Console.WriteLine("    " + oCulture.NativeName + " " + obj2.Matter);
                }
            }
            oGeneralEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 8
0
        private static void Test01()
        {
            LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);
            GeneralConfig oGeneralA1 = new GeneralConfig
            {
                Code = "F1",
                Culture = 2052,
                Ctype = (byte)ModelEnum.ConfigParamType.DECIMAL,
                IntValue = 0,
                DecValue = 123.3456m
            };
            GeneralConfig oGeneralA2 = new GeneralConfig
            {
                Code = "F2",
                Culture = 2052,
                Ctype = (byte)ModelEnum.ConfigParamType.DATETIME,
                DateValue = DateTimeOffset.Now
            };
            GeneralConfig oGeneralA = new GeneralConfig
            {
                Code = "F",
                Culture = 2052,
                Ctype = (byte)Models.ModelEnum.ConfigParamType.STRING,
                StrValue = "Root_A",
                ChildItems = new List<GeneralConfig> { oGeneralA1, oGeneralA2 }
            };
            GeneralConfig oGeneralA3 = new GeneralConfig
            {
                Code = "F3",
                Culture = 2052,
                Ctype = (byte)Models.ModelEnum.ConfigParamType.STRING,
                StrValue = "Root_A",
                Parent = oGeneralA
            };

            // oGeneralEntities.GeneralConfigs.Add(oGeneralA);
            // oGeneralEntities.GeneralConfigs.Add(oGeneralA1);
            // oGeneralEntities.GeneralConfigs.Add(oGeneralA2);
            oGeneralEntities.GeneralConfigs.Add(oGeneralA3);
            oGeneralEntities.SaveChanges();

            var oConfigs = oGeneralEntities.GeneralConfigs;
            foreach (GeneralConfig obj in oConfigs.ToList())
            {
                Console.WriteLine("GUID: {0}  Code: {1}, Decimal: {2}", obj.Gid.ToString("N"), obj.Code, obj.DecValue);
            }
            oGeneralEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 9
0
        public void MemberTest3()
        {
            LiveEntities oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            GeneralLargeItem LargeItemA = new GeneralLargeItem
            {
                //LargeObject = LargeObjectA,
                Culture = 1024,
                CLOB = "this is a test LargeItem",
                FileType = ".txt",
                Source = (byte)ModelEnum.LargeObjectSource.DATEBASE,
                ObjUrl = "/123/23/3"
            };

            GeneralLargeItem LargeItemB = new GeneralLargeItem
            {
                //LargeObject = LargeObjectB,
                Culture = 2011,
                CLOB = "this is the other test LargeItem",
                FileType = ".php",
                Source = (byte)ModelEnum.LargeObjectSource.NONE,
                ObjUrl = "/1abc"
            };

            GeneralLargeObject LargeObjectA = new GeneralLargeObject
            {
                Code = "LargeObjectA",
                Culture = 1033,
                CLOB = "this is a LargeObject CLOB",
                FileType = ".jpg",
                ObjUrl = "/zhuchao/123",
                LargeItems = new List<GeneralLargeItem> { LargeItemA, LargeItemB},
                Source = (byte)ModelEnum.LargeObjectSource.DATEBASE
            };

            oLiveEntities.GeneralLargeObjects.Add(LargeObjectA);
            oLiveEntities.SaveChanges();

            //Console.WriteLine(LargeItemA.Gid);
            //Console.WriteLine(LargeObjectA.Gid);

            oLiveEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 10
0
        public void MemberTest6()
        {
            LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            GeneralMeasureUnit UnitA = new GeneralMeasureUnit
            {
                Utype = (byte)ModelEnum.MeasureUnit.PIECE,
                Code = "RMB",
                Name = new GeneralResource
                {
                    Matter = "RMB",
                    Culture = 2052,
                    ResourceItems = new List<GeneralResItem>
                    {
                        new GeneralResItem
                        {
                            Culture = 1033,
                            Matter = "USD"
                        },
                        new GeneralResItem
                        {
                            Culture = 1035,
                            Matter = "FR"
                        }
                    }
                }
            };

            oGeneralEntities.GeneralMeasureUnits.Add(UnitA);
            oGeneralEntities.SaveChanges();

            oGeneralEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 11
0
        public void MemberTest5()
        {
            LiveEntities oGeneralEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            GeneralRegion RegionA = new GeneralRegion
            {
                Code = "RegionA",
                FullName = "RegionChinaA",
                ShortName = "A",
                Sorting = 1
            };

            GeneralRegion RegionB = new GeneralRegion
            {
                Code = "RegionB",
                FullName = "RegionChinaB",
                ShortName = "B",
                Sorting = 2,
                Parent = RegionA
            };

            oGeneralEntities.GeneralRegions.Add(RegionB);
            oGeneralEntities.SaveChanges();

            oGeneralEntities.Dispose();
            GC.Collect();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 时间触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimedEvent(object sender, ElapsedEventArgs e)
        {
            if (oSemaphore == LiveSemaphore.RED)           // 红灯冲突,终止执行
                return;
            if (nDelayTime > 0)                            // 延迟一个周期
            {
                nDelayTime--;
                return;
            }

            // 开始执行事件
            oSemaphore = LiveSemaphore.RED;
            LiveEntities dbEntity = new LiveEntities(ConfigHelper.LiveConnection.Connection);
            EventBLL oEventBLL = new EventBLL(dbEntity);
            try
            {
                oEventBLL.WriteEvent("OnTimedEvent 执行事件", this.ToString());

                // 淘宝接口同步
                Section.TaobaoDaemon oTaobao = new Section.TaobaoDaemon(dbEntity, oEventBLL);
                oTaobao.Main();

                // 消息服务
                Section.MessageDaemon oMessage = new Section.MessageDaemon(dbEntity, oEventBLL);
                oMessage.Main();

                // 同步分布式数据库
                Section.SynchroDaemon oSynchro = new Section.SynchroDaemon(dbEntity, oEventBLL);
                oSynchro.Main();

                oEventBLL.WriteEvent("OnTimedEvent 执行结束", this.ToString());
            }
            catch (Exception ex)
            {
                oEventBLL.WriteEvent("OnTimedEvent " + ex.Message,
                    ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
            finally
            {
                try
                {
                    dbEntity.Dispose();
                }
                catch { }
            }
            oSemaphore = LiveSemaphore.GREED;
        }