示例#1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public BaseController()
 {
     dbEntity = new LiveEntities(ConfigHelper.LiveConnection.Connection);
     oEventBLL = new EventBLL(dbEntity);
     oGeneralBLL = new GeneralBLL(dbEntity);
 }
示例#2
0
 /// <summary>
 /// 构造函数,必须传入数据库连接参数
 /// </summary>
 /// <param name="entity">数据库连接参数</param>
 public DataTransferBLL(LiveEntities entity)
     : base(entity)
 {
     oProductBLL = new ProductBLL(entity);
     oGeneralBLL = new GeneralBLL(entity);
 }
示例#3
0
        public void TestOld()
        {
            LiveEntities dbEntity = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            CultureInfo oCulture1 = new CultureInfo("zh-CN");
            CultureInfo oCulture2 = new CultureInfo("zh-TW");
            CultureInfo oCulture = new CultureInfo("ja-JP");
            decimal dm = 123894.56m;
            string s1 = oCulture.NumberFormat.CurrencySymbol + dm.ToString(oCulture.NumberFormat);
            Debug.WriteLine(s1);

            string symbolRMB = (new CultureInfo("zh-CN")).NumberFormat.CurrencySymbol;
            string symbolUSD = (new CultureInfo("en-US")).NumberFormat.CurrencySymbol;
            string symbolEUR = (new CultureInfo("fr-FR")).NumberFormat.CurrencySymbol;
            Guid? oUnitRMB = (from m in dbEntity.GeneralMeasureUnits
                              where m.Code == symbolRMB
                              select m.Gid).FirstOrDefault();
            Guid? oUnitUSD = (from m in dbEntity.GeneralMeasureUnits
                              where m.Code == symbolUSD
                              select m.Gid).FirstOrDefault();
            Guid? oUnitEUR = (from m in dbEntity.GeneralMeasureUnits
                              where m.Code == symbolEUR
                              select m.Gid).FirstOrDefault();

            GeneralResource oMoney = new GeneralResource
            {
                Rtype = (byte)ModelEnum.ResourceType.MONEY,
                Currency = oUnitRMB,
                Cash = 123.56m,
                ResourceItems = new List<GeneralResItem>
                {
                    new GeneralResItem { Currency = oUnitUSD, Cash = 34.67m },
                    new GeneralResItem { Currency = oUnitEUR, Cash = 31.69m }
                }
            };
            dbEntity.GeneralResources.Add(oMoney);
            dbEntity.SaveChanges();

            GeneralBLL oGeneralBLL = new GeneralBLL(dbEntity);
            string sm = oGeneralBLL.GetMoneyString(oMoney.Gid, oUnitRMB);

            string sMoneyCode1 = oMoney.GetCurrencyUnit(dbEntity).Code;
            string sMoneyCode2 = oMoney.GetCurrencyUnit(dbEntity, oUnitUSD.Value).Code;

            GeneralProgNode oProgNode = new GeneralProgNode
            {
                Program = dbEntity.GeneralPrograms.Where(p => p.Code == "ConfigIndex").FirstOrDefault(),
                Code = "EnableModify",
                Name = new GeneralResource
                {
                    Culture = 1033,
                    Matter = "Modify",
                    ResourceItems = new List<GeneralResItem>
                    {
                        new GeneralResItem { Culture = 2052, Matter = "允许修改" }
                    }
                },
                InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                Optional = new GeneralResource
                {
                    Culture = 1033,
                    Matter = "{0|No},{1|Yes}",
                    ResourceItems = new List<GeneralResItem>
                    {
                        new GeneralResItem { Culture = 2052, Matter = "{0|否},{1|是}" }
                    }
                }
            };
            dbEntity.GeneralProgNodes.Add(oProgNode);
            dbEntity.SaveChanges();

            MemberPrivilege oPrivilege = new MemberPrivilege
            {
                User = dbEntity.MemberUsers.Where(u => u.LoginName == "test").FirstOrDefault(),
                Ptype = (byte)ModelEnum.UserPrivType.PROGRAM_NODE,
                PrivilegeItems = new List<MemberPrivItem>
                {
                     new MemberPrivItem
                     {
                         RefID = oProgNode.Gid,
                         NodeCode = "EnableModify",
                         NodeValue = "1"
                     }
                }
            };
            dbEntity.MemberPrivileges.Add(oPrivilege);
            dbEntity.SaveChanges();

            Dictionary<string, string> oProgramNodes = new Dictionary<string, string>();
            oProgramNodes.Add("Supervisor", "1");
            if (oProgramNodes.ContainsKey("Supervisor") && (oProgramNodes["Supervisor"] == "1"))
            {
                Debug.WriteLine(oProgramNodes["Supervisor"]);
            }
            if (oProgramNodes.ContainsKey("Key") && (oProgramNodes["Key"] == "1"))
            {
                string s = oProgramNodes["Key"];
                Debug.WriteLine(s);
            }

            TimeSpan oTimeSpan = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
            DateTimeOffset oLocalTime1 = new DateTimeOffset(2011, 8, 24, 13, 45, 24, oTimeSpan);

            DateTime oLocalTime2 = DateTime.Now;
            oLocalTime2 = DateTime.SpecifyKind(oLocalTime2, DateTimeKind.Utc);
            DateTimeOffset oLocalTime3 = oLocalTime2;
            DateTimeOffset oLocalTime4 = oLocalTime1;

            GeneralConfig oConfig1 = new GeneralConfig
            {
                Code = "Test11",
                DateValue = oLocalTime1
            };
            GeneralConfig oConfig2 = new GeneralConfig
            {
                Code = "Test21",
                DateValue = oLocalTime3
            };
            GeneralConfig oConfig3 = new GeneralConfig
            {
                Code = "Test31",
                DateValue = oLocalTime4
            };

            dbEntity.GeneralConfigs.Add(oConfig1);
            dbEntity.GeneralConfigs.Add(oConfig2);
            dbEntity.GeneralConfigs.Add(oConfig3);
            dbEntity.SaveChanges();

            GeneralTodoList oTodo2 = (from t in dbEntity.GeneralTodoLists
                                      where t.Gid == new Guid("3429BF77-1ECE-E011-A3A0-60EB69D65AE8")
                                      select t).FirstOrDefault();

            // string strSQL = String.Format("SELECT * FROM dbo.fn_FindTest('{0}')", Guid.Empty);
            // string strSQL = String.Format("EXECUTE sp_FindTest '{0}'", Guid.Empty);

            var fnFindTest = dbEntity.Database.SqlQuery<ShipList>("SELECT * FROM fn_FindTest({0})", Guid.Empty);

            foreach (ShipList fnItem in fnFindTest)
            {
                Debug.WriteLine(fnItem.ShipID);
                Debug.WriteLine(fnItem.ShipWeight);
            }

            Guid og = Guid.Empty;
            Guid? og1 = null;
            Guid? og2 = Guid.NewGuid();
            Guid? og3 = Guid.Empty;
            if (og == Guid.Empty)
                Debug.WriteLine(og);
            if (og1.HasValue)
                Debug.WriteLine(og1.Value);
            if (og2.HasValue)
                Debug.WriteLine(og2.Value);
            if (og3.HasValue)
                Debug.WriteLine(og3.Value);

            var list = from c in dbEntity.WarehouseInformations
                       where c.Deleted == false
                       select c.Parent;
            foreach (var v in list)
            {
                Debug.WriteLine(v.FullName.Matter);

                //Debug.WriteLine(v.Key);
                //foreach (var item in v)
                //{
                //    Debug.WriteLine(item.FullName.Matter);
                //}
                //if (v.FullName == null)
                //    Debug.WriteLine("is null");
                //foreach (var v2 in v.FullName.ResourceItems)
                //    Debug.WriteLine(v2.Matter);
            }

            EventBLL oEventBLL = new EventBLL(dbEntity);
            oEventBLL.WriteEvent("系统启动", ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());

            GeneralConfig oConfig = dbEntity.GeneralConfigs.Where(c => c.Code == "SessionName").FirstOrDefault();

            List<ListItem> oList2 = oConfig.SelectEnumList(typeof(ModelEnum.ActionSource), 2);
            string oListName = oConfig.SelectEnumName(typeof(ModelEnum.ActionSource), 2);
        }