예제 #1
0
        public ActionResult PrivProgram(string result, string open, string Editresult,string Dropresult)
        {
            string[] gid = result.Split(',');
            string[] openstate = open.Split(',');
            Guid priid ;
            Guid priidnode;

            //userID为前台传入值,现在假设已获取
            Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85");
            MemberPrivilege PrivID = (from o in dbEntity.MemberPrivileges
                                      where (o.UserID == userID && o.Deleted == false && o.Ptype == 0)
                                      select o).FirstOrDefault();
            //保存程序授权,Ptype=0
            if (PrivID != null)
            {
                priid = PrivID.Gid;
            }
            else
            {
                //程序授权Ptype=0,主表中添加
                MemberPrivilege m = new MemberPrivilege();
                m.UserID = userID;
                m.Ptype = 0;
                m.Pstatus = 1;

                dbEntity.MemberPrivileges.Add(m);
                dbEntity.SaveChanges();
                priid= m.Gid;
            }
            MemberPrivilege NodePrivID = (from o in dbEntity.MemberPrivileges
                                      where (o.UserID == userID && o.Deleted == false && o.Ptype == 1)
                                      select o).FirstOrDefault();
            if (NodePrivID != null)
            {
                priidnode = NodePrivID.Gid;
            }
            else
            {
                //程序功能点授权,Ptype=1
                    MemberPrivilege m = new MemberPrivilege();
                    m.UserID = userID;
                    m.Ptype = 1;
                    m.Pstatus = 1;

                    dbEntity.MemberPrivileges.Add(m);
                    dbEntity.SaveChanges();
                    priidnode = m.Gid;
            }

            //保存授权的程序或程序节点
            for (int i = 1; i < gid.Length - 1; i++)
            {
                Guid id = new Guid(gid[i]);
                //判断是否是程序的ID
                var IsProgram = (from o in dbEntity.GeneralPrograms
                                 where (o.Gid == id && o.Deleted == false)
                                 select o).FirstOrDefault();
                //gid[i]为程序节点ID
                if (IsProgram == null)
                {
                    var ItemNode = (from o in dbEntity.MemberPrivItems
                                    where (o.RefID == id && o.Deleted == false)
                                    select o).FirstOrDefault();
                    if (ItemNode == null)
                    {
                        GeneralProgNode ProgNode = (from o in dbEntity.GeneralProgNodes.Include("Name").Include("Optional")
                                                    where (o.Gid == id && o.Deleted == false)
                                                    select o).Single();

                        MemberPrivItem mPriItem = new MemberPrivItem();
                        mPriItem.PrivID = priid;
                        mPriItem.RefID = new Guid(gid[i]);
                        mPriItem.NodeCode = ProgNode.Code;
                        if (ProgNode.InputMode == 0)
                            mPriItem.NodeValue = Editresult;
                        else mPriItem.NodeValue = Dropresult;
                        dbEntity.MemberPrivItems.Add(mPriItem);
                        dbEntity.SaveChanges();
                    }

                }
                //gid[i]是程序ID
                else
                {
                    var ItemProg = (from o in dbEntity.MemberPrivItems
                                    where (o.Deleted == false && o.RefID == id)
                                    select o).FirstOrDefault();
                    if (ItemProg == null)
                    {
                        GeneralProgram Program = (from o in dbEntity.GeneralPrograms
                                                  where (o.Gid == id&&o.Deleted==false)
                                                  select o).Single();
                        //程序为叶子节点
                        if (Program.Terminal == true)
                        {
                            if (openstate[i] == "undefined")
                            {
                                //保存自己
                                MemberPrivItem mPriItem = new MemberPrivItem();
                                mPriItem.PrivID = priid;
                                mPriItem.RefID = new Guid(gid[i]);
                                dbEntity.MemberPrivItems.Add(mPriItem);
                                dbEntity.SaveChanges();
                                //保存所有功能节点
                                var ProgNode = from o in dbEntity.GeneralProgNodes
                                               where (o.ProgID == id && o.Deleted == false)
                                               select o;
                                foreach (var Nodeitem in ProgNode)
                                {
                                    mPriItem.PrivID = priid;
                                    mPriItem.RefID = Nodeitem.Gid;
                                    mPriItem.NodeCode = Nodeitem.Code;
                                    if (Nodeitem.InputMode == 0)
                                        mPriItem.NodeValue = Editresult;
                                    else mPriItem.NodeValue = Dropresult;
                                }
                            }
                        }
                        //程序为非叶子节点
                        else
                        {
                            if (openstate[i] == "undefined")
                            {
                                //判断是否已经存在
                                var item = (from o in dbEntity.MemberPrivItems
                                            where (o.RefID == id && o.PrivID == priid)
                                            select o).FirstOrDefault();

                                if (item == null)
                                {
                                    MemberPrivItem mPriItem = new MemberPrivItem();
                                    mPriItem.PrivID = priid;
                                    mPriItem.RefID = new Guid(gid[i]);
                                    dbEntity.MemberPrivItems.Add(mPriItem);
                                    dbEntity.SaveChanges();
                                }
                                //递归保存孩子节点
                                PrivProChild(id, priid);
                            }
                            else
                            {
                                var item = (from o in dbEntity.MemberPrivItems
                                            where (o.RefID == id && o.PrivID == priid)
                                            select o).FirstOrDefault();
                                if (item == null)
                                {
                                    MemberPrivItem mPriItem = new MemberPrivItem();
                                    mPriItem.PrivID = priid;
                                    mPriItem.RefID = new Guid(gid[i]);
                                    dbEntity.MemberPrivItems.Add(mPriItem);
                                    dbEntity.SaveChanges();
                                }
                            }
                        }
                    }

                }
            }

               return RedirectToAction("PrivProgram");
        }
예제 #2
0
        public ActionResult PrivOrganization(MemberPrivilege memberPrivilege, int? optitemCount, string prvID)
        {
            Guid id = new Guid(prvID);
            memberPrivilege = (dbEntity.MemberPrivileges.Where(o => o.Gid == id)).Single();
            if (ModelState.IsValid)
            {
                ICollection<MemberPrivItem> memberPrivItems = new List<MemberPrivItem>();
                for (int i = 0; i < optitemCount; i++)
                {
                    MemberPrivItem memberPrivItem = new MemberPrivItem();
                    memberPrivItem.PrivID = memberPrivilege.Gid;
                    memberPrivItem.RefID = new Guid(Request.Form["privOrg" + i]);
                    memberPrivItems.Add(memberPrivItem);
                }
                memberPrivilege.PrivilegeItems = memberPrivItems;

                dbEntity.SaveChanges();
                return RedirectToAction("Index");
            }
            return View();
        }
예제 #3
0
 /// <summary>
 /// 新建用户组织授权
 /// </summary>
 /// <returns></returns>
 public string PrivOrgDefinition(MemberPrivilege memPriv, Guid? userID)
 {
     memPriv.User = dbEntity.MemberUsers.Where(o => o.Gid == userID).FirstOrDefault();
     memPriv.Ptype = 2;
     memPriv.Pstatus = 1;
     //if(Request.Form["Pstatus"]==null)
     //{
     //    memPriv.Pstatus = 0;
     //}
     //else
     //{
     //    memPriv.Pstatus = 1;
     //}
     if (ModelState.IsValid)
     {
         try
         {
             dbEntity.MemberPrivileges.Add(memPriv);
             dbEntity.SaveChanges();
             return memPriv.Gid.ToString();
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException)//数据库中已存在该条记录
         {
             var id = dbEntity.MemberPrivileges.Where(o => o.UserID==userID&&o.Ptype==2).Select(o=>o.Gid).FirstOrDefault();
             return id.ToString();
         }
     }
     else {
         return null;
     }
 }
예제 #4
0
 public ActionResult PrivilegeDefinition(MemberPrivilege memberPrivilege)
 {
     return View();
 }
예제 #5
0
 /// <summary>
 /// 用户组织授权
 /// </summary>
 /// <returns></returns>
 public ActionResult PrivOrganization(MemberPrivilege memberPrivilege)
 {
     var memberOrganizations = from o in dbEntity.MemberOrganizations.Include("ShortName")
                               where (o.Deleted == false && o.Otype == 0)
                               select new
                               {
                                   Gid = o.Gid,
                                   ShortName = o.ShortName.Matter
                               };
     ViewBag.memOrg = new SelectList(memberOrganizations, "Gid", "ShortName");
     return View();
 }
예제 #6
0
        /// <summary>
        /// 供应商授权
        /// </summary>
        /// <returns></returns>
        public ActionResult PrivSupplier(Guid? id=null)
        {
            if (!base.CheckPrivilege("EnableEdit"))//权限验证
                return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
            if (id == null)
            {
                int nstatus;
                MemberPrivilege PrivID = (from o in dbEntity.MemberPrivileges where (o.Deleted == false && o.UserID == gUserID && o.Ptype == (byte)ModelEnum.UserPrivType.SUPPLIER_CATEGORY) select o).FirstOrDefault();
                if (PrivID != null)
                {
                    nstatus = (int)PrivID.Pstatus;
                }
                else nstatus = -1;
                ViewBag.status = nstatus;
                Guid gUserOrgID = (from o in dbEntity.MemberUsers where (o.Gid == gUserID && o.Deleted == false) select o.OrgID).Single();
                List<SelectListItem> list = new List<SelectListItem>();
                //组织下拉框
                ViewData["Orglist"] = GetGuserSupportOrganizations();
            }
            else
            {
                Guid gPrivID;
                MemberPrivilege PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == gUserID && o.Ptype == (byte)ModelEnum.UserPrivType.SUPPLIER_CATEGORY) select o).FirstOrDefault();
                //主表中存在授权记录
                if (PrivID != null && PrivID.Deleted == false)
                {
                    if (PrivID.Pstatus == 0)
                    {
                        PrivID.Pstatus = 1;
                        dbEntity.SaveChanges();
                    }
                    gPrivID = PrivID.Gid;

                }
                //主表中的授权记录被删除,恢复记录
                else if (PrivID != null && PrivID.Deleted == true)
                {
                    PrivID.Deleted = false;
                    if (PrivID.Pstatus == 0) PrivID.Pstatus = 1;
                    dbEntity.SaveChanges();
                    gPrivID = PrivID.Gid;
                }
                //主表中不存在授权记录
                else
                {
                    MemberPrivilege oMemPriv = new MemberPrivilege();
                    oMemPriv.UserID = gUserID;
                    oMemPriv.Ptype = 6;
                    oMemPriv.Pstatus = 1;
                    dbEntity.MemberPrivileges.Add(oMemPriv);
                    dbEntity.SaveChanges();
                    gPrivID = oMemPriv.Gid;
                }
                if (!id.Equals(Guid.Empty))
                {
                    MemberPrivItem oSupItem = (from o in dbEntity.MemberPrivItems
                                               where (o.PrivID == gPrivID && o.RefID == id)
                                               select o).FirstOrDefault();
                    //从表中存在这条记录,但已经逻辑删除,恢复记录
                    if (oSupItem != null && oSupItem.Deleted == true)
                    {
                        oSupItem.Deleted = false;
                        dbEntity.SaveChanges();
                    }
                    //不存在记录,添加
                    if (oSupItem == null)
                    {
                        MemberPrivItem oSupItem1 = new MemberPrivItem();
                        oSupItem1.PrivID = gPrivID;
                        oSupItem1.RefID = id;
                        dbEntity.MemberPrivItems.Add(oSupItem1);
                        dbEntity.SaveChanges();
                    }
                }
                return RedirectToAction("PrivSupplier");
            }
            return View();
        }
예제 #7
0
 /// <summary>
 /// 用户渠道授权
 /// </summary>
 /// <returns></returns>
 public ActionResult PrivChannel(MemberPrivilege memberPrivilege)
 {
     //选择Otype=1的渠道组织
     var memberChannels = from o in dbEntity.MemberChannels.Include("ShortName")
                               where (o.Deleted == false && o.Otype == 1)
                               select new
                               {
                                   Gid = o.Gid,
                                   ShortName = o.ShortName.Matter
                               };
     ViewBag.memOrg = new SelectList(memberChannels, "Gid", "ShortName");
     return View();
 }
예제 #8
0
        public void MainTest01()
        {
            Console.WriteLine("Start Test");
            InitialiseDatabase.RunOnce();
            //InitialiseDatabase.ImportRegionExcel(@"C:\Temp\SystemRegion.xls");

            LiveEntities dbEntity = new LiveEntities(ConfigHelper.LiveConnection.Connection);

            Guid gUserID = (from u in dbEntity.MemberUsers
                            where u.LoginName == "test"
                            select u.Gid).FirstOrDefault();

            var oPrivilege1 = (from p in dbEntity.MemberPrivileges
                              where p.UserID == gUserID && p.Ptype == (byte)ModelEnum.UserPrivType.PROGRAM
                              select p).FirstOrDefault();
            var oProgram = (from p in dbEntity.GeneralPrograms.Include("ProgramNodes")
                            where p.Code == "ProgramIndex"
                            select p).FirstOrDefault();
            oPrivilege1.PrivilegeItems.Add(
                new MemberPrivItem
                {
                    RefID = oProgram.Gid
                });

            var oPrivilege2 = (from p in dbEntity.MemberPrivileges
                               where p.UserID == gUserID && p.Ptype == (byte)ModelEnum.UserPrivType.PROGRAM_NODE
                               select p).FirstOrDefault();
            if (oPrivilege2 == null)
            {
                oPrivilege2 = new MemberPrivilege
                {
                    Ptype = (byte)ModelEnum.UserPrivType.PROGRAM_NODE,
                    UserID = gUserID,
                    PrivilegeItems = new List<MemberPrivItem>
                    {
                        new MemberPrivItem
                        {
                            RefID = oProgram.FindProgramNode("EnableEdit").Gid,
                            NodeCode = "EnableEdit",
                            NodeValue = "1"
                        }
                    }

                };
                dbEntity.MemberPrivileges.Add(oPrivilege2);
            }

            dbEntity.Entry(oPrivilege1).State = EntityState.Modified;
            dbEntity.SaveChanges();
        }
예제 #9
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);
        }
예제 #10
0
        /// <summary>
        /// 商品分类授权
        /// </summary>
        /// <returns></returns>
        public ActionResult PrivProduct(Guid? id=null)
        {
            if (!base.CheckPrivilege("EnableEdit"))//权限验证
                return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
            if (id == null)
            {
                int nstatus;
                MemberPrivilege oMemberPrivilege = (from o in dbEntity.MemberPrivileges where (o.Deleted == false && o.UserID == gUserID && o.Ptype == (byte)ModelEnum.UserPrivType.PRODUCT_CATEGORY) select o).FirstOrDefault();
                if (oMemberPrivilege != null)
                {
                    //获取状态,1启用,0禁用
                    nstatus = (int)oMemberPrivilege.Pstatus;
                }
                else
                    nstatus = -1;
                ViewBag.status = nstatus;
                //组织下拉框
                ViewData["Orglist"] = GetGuserSupportOrganizations();
            }
            else
            {
                Guid gPrivID = new Guid();
                MemberPrivilege oProPrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == gUserID && o.Ptype == 5) select o).FirstOrDefault();
                //主表中已存在授权记录
                if (oProPrivID != null && oProPrivID.Deleted == false)
                {
                    if (oProPrivID.Pstatus == 0)
                    {
                        oProPrivID.Pstatus = 1;
                        dbEntity.SaveChanges();
                    }
                    gPrivID = oProPrivID.Gid;
                }
                //主表中的授权记录已被逻辑删除,恢复
                if (oProPrivID != null && oProPrivID.Deleted == true)
                {
                    oProPrivID.Deleted = false;
                    oProPrivID.Pstatus = 1;
                    dbEntity.SaveChanges();
                    gPrivID = oProPrivID.Gid;
                }
                //不存在授权记录,添加
                if (oProPrivID == null)
                {
                    MemberPrivilege oMemPriv = new MemberPrivilege();
                    oMemPriv.UserID = gUserID;
                    oMemPriv.Ptype = 5;
                    oMemPriv.Pstatus = 1;
                    dbEntity.MemberPrivileges.Add(oMemPriv);
                    dbEntity.SaveChanges();
                    gPrivID = oMemPriv.Gid;
                }

                MemberPrivItem oProPriItem = (from o in dbEntity.MemberPrivItems where (o.RefID == id && o.PrivID == gPrivID) select o).SingleOrDefault();
                if (oProPriItem != null && oProPriItem.Deleted == true)
                {
                    oProPriItem.Deleted = false;
                    dbEntity.SaveChanges();
                }
                if (oProPriItem == null)
                {
                    MemberPrivItem oProItem = new MemberPrivItem();
                    oProItem.PrivID = gPrivID;
                    oProItem.RefID = id;
                    dbEntity.MemberPrivItems.Add(oProItem);
                    dbEntity.SaveChanges();
                }

                return RedirectToAction("PrivProduct");
            }
            return View();
        }
예제 #11
0
        //=====================================================================
        public void InsertTestData()
        {
            //res 表中添加角色
            GeneralResource resRole = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "General User",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resRole);
            //res 表中添加组织全名
            GeneralResource resOrg = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "筑巢信息科技有限公司",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resOrg);
            //res 表中添加组织简称
            GeneralResource resShort = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "筑巢",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resShort);
            //res 表中添加数据
            GeneralResource resData = new GeneralResource
            {
                Code = GetRandCode(),
                Culture = 2052,
                Matter = "A Test"
            };
            oLiveEntities.GeneralResources.Add(resData);
            GeneralResource resProg0 = new GeneralResource
            {
                Code = GetRandCode(),
                Culture = 2052,
                Matter = "Config"
            };
            oLiveEntities.GeneralResources.Add(resProg0);
            //res 表中添加程序定义
            GeneralResource resProg1 = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "generalProperty",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg1);
            //res 表中添加程序定义
            GeneralResource resProg2 = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "Units",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg2);
            //res 表中添加程序定义
            GeneralResource resProg3 = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "Classification",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg3);
            //res 表中添加程序定义
            GeneralResource resProg4 = new GeneralResource
            {
                Code = GetRandCode(),
                Matter = "Organization",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg4);
            //unit表中添加数据
            GeneralMeasureUnit oUnit = new GeneralMeasureUnit
            {
                Utype = 2,
                Code = GetRandCode(),
                Name = resData
            };
            oLiveEntities.GeneralMeasureUnits.Add(oUnit);
            //unit表中添加数据
            GeneralMeasureUnit oUnit0 = new GeneralMeasureUnit
            {
                Utype = 6,
                Code = GetRandCode(),
                Name = resData
            };
            oLiveEntities.GeneralMeasureUnits.Add(oUnit0);
            //文化表中添加数据
            GeneralCultureUnit culture = new GeneralCultureUnit
            {
                Piece = oUnit,
                Weight = oUnit0,
                Culture = 2052
            };
            oLiveEntities.GeneralCultureUnits.Add(culture);
            //组织表中添加数据
            MemberOrganization org = new MemberOrganization
            {
                Code = GetRandCode(),
                FullName = resOrg,
                ShortName = resShort,
                WorkPhone = "15121040098",
                HomeUrl = "http://www.zhuchao.com"
            };
            oLiveEntities.MemberOrganizations.Add(org);
            MemberOrganization chl = new MemberOrganization
            {
                Code = GetRandCode(),
                FullName = resOrg,
                ShortName = resShort,
                WorkPhone = "15121040098",
                HomeUrl = "http://www.zhuchao.com"
            };
            oLiveEntities.MemberOrganizations.Add(chl);
            //角色表中添加数据
            MemberRole role = new MemberRole
            {
                Name = resRole,
                Code = GetRandCode(),
                Organization = org
            };
            oLiveEntities.MemberRoles.Add(role);

            //新建渠道
            MemberChannel mChl = new MemberChannel
            {
                Code = GetRandCode(),
                CellPhone = "4525254254",
                Email = "*****@*****.**",
            };
            oLiveEntities.MemberChannels.Add(mChl);

            MemberOrgChannel oChl = new MemberOrgChannel
            {
                Organization = org,
                Channel = mChl
            };
            oLiveEntities.MemberOrgChannels.Add(oChl);
            //添加用户
            MemberUser user = new MemberUser
            {
                Organization = org,
                Channel = mChl,
                Role = role,
                LoginName = GetRandCode() + "@qq.com",
                Passcode = GetRandCode()
            };
            oLiveEntities.MemberUsers.Add(user);
            //添加用户
            MemberUser user0 = new MemberUser
            {
                Organization = org,
                Channel = mChl,
                Role = role,
                LoginName = "*****@*****.**",
                Passcode = "123"
            };
            oLiveEntities.MemberUsers.Add(user0);
            //添加程序定义
            GeneralProgram prog = new GeneralProgram
            {
                Name = resProg0,
                Code = GetRandCode()
            };
            oLiveEntities.GeneralPrograms.Add(prog);
            //添加程序定义
            GeneralProgram prog0 = new GeneralProgram
            {
                Name = resProg1,
                Code = GetRandCode()
            };
            oLiveEntities.GeneralPrograms.Add(prog0);
            //添加程序定义
            GeneralProgram prog1 = new GeneralProgram
            {
                Name = resProg2,
                Code = GetRandCode(),
                Parent = prog
            };
            oLiveEntities.GeneralPrograms.Add(prog1);
            //添加程序定义
            GeneralProgram prog2 = new GeneralProgram
            {
                Name = resProg3,
                Code = GetRandCode(),
                Parent = prog
            };
            oLiveEntities.GeneralPrograms.Add(prog2);
            //添加程序定义
            GeneralProgram prog3 = new GeneralProgram
            {
                Name = resProg4,
                Code = GetRandCode(),
                Parent = prog
            };
            oLiveEntities.GeneralPrograms.Add(prog3);
            //添加程序定义
            GeneralProgram prog5 = new GeneralProgram
            {
                Name = resProg4,
                Code = GetRandCode(),
                Parent = prog1
            };
            oLiveEntities.GeneralPrograms.Add(prog5);
            //res 表中添加程序定义
            GeneralResource resnode = new GeneralResource
            {
                Code = "resnode",
                Matter = "功能节点1",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg1);

            GeneralResource resoptional = new GeneralResource
            {
                Code = "resnodeoption",
                Matter = "0|不显示,1|显示",
                Culture = 2052
            };
            oLiveEntities.GeneralResources.Add(resProg1);

            //添加程序功能定义
            GeneralProgNode progNode = new GeneralProgNode
            {
                Program = prog,
                Code = "prognode",
                Name = resnode,
                Optional = resoptional,
                InputMode = 1
            };
            oLiveEntities.GeneralProgNodes.Add(progNode);
            oLiveEntities.SaveChanges();
            //添加权限控制
            MemberPrivilege prol = new MemberPrivilege
            {
                User = user0,
                Ptype = 0
            };
            oLiveEntities.MemberPrivileges.Add(prol);
            //添加权限控制
            MemberPrivilege prol0 = new MemberPrivilege
            {
                User = user0,
                Ptype = 1
            };
            oLiveEntities.MemberPrivileges.Add(prol0);

            MemberPrivItem prinode = new MemberPrivItem
            {
                Privilege = prol0,
                RefID = progNode.Gid,
                NodeValue = "1"
            };
            oLiveEntities.MemberPrivItems.Add(prinode);
            //添加权限控制明细
            MemberPrivItem prolItem = new MemberPrivItem
            {
                Privilege = prol,
                RefID = prog.Gid
            };
            oLiveEntities.MemberPrivItems.Add(prolItem);
            //添加权限控制明细
            MemberPrivItem prolItem0 = new MemberPrivItem
            {
                Privilege = prol,
                RefID = prog0.Gid

            };
            oLiveEntities.MemberPrivItems.Add(prolItem0);
            //添加权限控制明细
            MemberPrivItem prolItem1 = new MemberPrivItem
            {
                Privilege = prol,
                RefID = prog1.Gid

            };
            oLiveEntities.MemberPrivItems.Add(prolItem1);
            //添加权限控制明细
            MemberPrivItem prolItem2 = new MemberPrivItem
            {
                Privilege = prol,
                RefID = prog2.Gid

            };
            oLiveEntities.MemberPrivItems.Add(prolItem2);

            oLiveEntities.SaveChanges();
        }
예제 #12
0
 /// <summary>
 /// 用户组织授权
 /// </summary>
 /// <returns></returns>
 public ActionResult PrivOrganization(string orgSearchString = null, Guid? selectedOrg = null)
 {
     if (!base.CheckPrivilege("EnableEdit"))//权限验证
         return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
     if (selectedOrg == null)
     {
         gSearchStr = orgSearchString;
         //在数据库中查找是否已存在该用户组织授权
         MemberPrivilege memberPrivilege = dbEntity.MemberPrivileges.Where(o => o.UserID == gUserID && o.Deleted == false && o.Ptype == (byte)ModelEnum.UserPrivType.ORGANIZATION).FirstOrDefault();
         if (memberPrivilege != null)
         {
             ViewBag.pStatus = memberPrivilege.Pstatus;
         }
         else
             ViewBag.pStatus = -1;
         ViewBag.orgSearchStr = orgSearchString;
     }
     else//保存
     {
         //在数据库中查找是否已存在该用户组织授权
         MemberPrivilege memberPrivilege = dbEntity.MemberPrivileges.Where(o => o.UserID == gUserID && o.Ptype == (byte)ModelEnum.UserPrivType.ORGANIZATION).FirstOrDefault();
         //如果已存在,则对该用户组织授权项进行更新
         if (memberPrivilege != null)
         {
             //更新组织授权项
             memberPrivilege.Deleted = false;
             memberPrivilege.Pstatus = (byte)ModelEnum.GenericStatus.VALID;
             //在MemberPrivItem中,查找已添加的项
             MemberPrivItem memberPrivItem = dbEntity.MemberPrivItems.Where(o => o.PrivID == memberPrivilege.Gid && o.RefID == selectedOrg).FirstOrDefault();
             if (memberPrivItem != null)
             {
                 memberPrivItem.Deleted = false;
             }
             else  //添加新增的项
             {
                 MemberPrivItem oNewMemberPrivItem = new MemberPrivItem();
                 oNewMemberPrivItem.PrivID = memberPrivilege.Gid;
                 oNewMemberPrivItem.RefID = selectedOrg;
                 dbEntity.MemberPrivItems.Add(oNewMemberPrivItem);
             }
             dbEntity.SaveChanges();
         }
         //如果不存在,则新建组织授权,并添加组织授权项
         else
         {
             //新建组织授权
             memberPrivilege = new MemberPrivilege();
             memberPrivilege.UserID = gUserID;
             memberPrivilege.Ptype = 2;
             memberPrivilege.Pstatus = 1;
             dbEntity.MemberPrivileges.Add(memberPrivilege);
             dbEntity.SaveChanges();
             //添加授权项
             MemberPrivItem memberPrivItem = new MemberPrivItem();
             memberPrivItem.PrivID = memberPrivilege.Gid;
             memberPrivItem.RefID = selectedOrg;
             dbEntity.MemberPrivItems.Add(memberPrivItem);
             dbEntity.SaveChanges();
         }
     }
     return View();
 }
예제 #13
0
 /// <summary>
 /// 启用按钮状态变化时调用
 /// </summary>
 /// <param name="IsCheck">是否启用</param>
 /// <param name="ptype">ptype</param>
 /// <returns></returns>
 public string DelAll(bool IsCheck, byte ptype)
 {
     MemberPrivilege oMemberPrivilege = (from o in dbEntity.MemberPrivileges
                                         where (o.Ptype == ptype && o.UserID == gUserID)
                                         select o).FirstOrDefault();
     if (!IsCheck && oMemberPrivilege != null)
     {
         oMemberPrivilege.Pstatus = (byte)ModelEnum.GenericStatus.NONE;
         dbEntity.SaveChanges();
     }
     else
     {
         if (oMemberPrivilege != null)//如果原来用户在MemberPrivilege中有该Ptype的记录,delete置为false
         {
             oMemberPrivilege.Pstatus = (byte)ModelEnum.GenericStatus.VALID;
             oMemberPrivilege.Deleted = false;
         }
         else//如果原来用户在MemberPrivilege中没有该Ptype的记录,则新建
         {
             MemberPrivilege oNewPriv = new MemberPrivilege {
                 Pstatus = (byte)ModelEnum.GenericStatus.VALID,
                 UserID = gUserID,
                 Ptype = ptype
             };
             dbEntity.MemberPrivileges.Add(oNewPriv);
         }
         dbEntity.SaveChanges();
     }
     return null;
 }
예제 #14
0
 /// <summary>
 /// 用模板对用户授权
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="SelectTemplateCode"></param>
 /// <returns></returns>
 public bool SetPrivilegeByTemplate(Guid UserID, string SelectTemplateCode)
 {
     if (UserID == null || String.IsNullOrEmpty(SelectTemplateCode) || SelectTemplateCode == "null")
         return false;
     List<GeneralPrivTemplate> GeneralPrivTemplateList = dbEntity.GeneralPrivTemplates.Where(g => g.Deleted == false && g.Code == SelectTemplateCode).ToList();
     //查找用户本身的权限 并且都做删除操作
     List<MemberPrivilege> oOldMemberPrivilegeList = dbEntity.MemberPrivileges.Where(m => m.UserID == UserID).ToList();
     if (oOldMemberPrivilegeList.Count > 0)
     {
         foreach (MemberPrivilege memberPriv in oOldMemberPrivilegeList)
         {
             memberPriv.Deleted = true;
             List<MemberPrivItem> oOldMemberPrivItemList = dbEntity.MemberPrivItems.Where(p => p.Deleted == false && p.PrivID == memberPriv.Gid).ToList();
             if (oOldMemberPrivItemList.Count > 0)
             {
                 foreach (MemberPrivItem memberPrivItem in oOldMemberPrivItemList)
                 {
                     memberPrivItem.Deleted = true;
                 }
             }
         }
     }
     dbEntity.SaveChanges();
     //COPY 若原来有该权限 delete恢复 若没有 则添加
     foreach (GeneralPrivTemplate oCopyPrivTemplate in GeneralPrivTemplateList)
     {
         MemberPrivilege oOldMemberPriv = oOldMemberPrivilegeList.Where(m => m.Ptype == oCopyPrivTemplate.Ptype).FirstOrDefault();
         bool bHasBefore = oOldMemberPriv == null ? false : true;
         if (bHasBefore)//之前有权限,则恢复数据
         {
             oOldMemberPriv.Deleted = false;
             oOldMemberPriv.Pstatus = oCopyPrivTemplate.Pstatus;
             oOldMemberPriv.Remark = oCopyPrivTemplate.Remark;
             List<GeneralPrivItem> oCopyGeneralPrivItemList = dbEntity.GeneralPrivItems.Where(g => g.Deleted == false && g.PrivID == oCopyPrivTemplate.Gid).ToList();//待COPY的子表
             foreach (GeneralPrivItem oCopyGeneralPrivItem in oCopyGeneralPrivItemList)
             {
                 MemberPrivItem oOldMemberPrivItem = dbEntity.MemberPrivItems.Where(m => m.PrivID == oOldMemberPriv.Gid && m.RefID == oCopyGeneralPrivItem.RefID).FirstOrDefault();
                 if (oOldMemberPrivItem != null)//子表 之前有 则恢复
                 {
                     oOldMemberPrivItem.Deleted = false;
                     oOldMemberPrivItem.NodeCode = oCopyGeneralPrivItem.NodeCode;
                     oOldMemberPrivItem.NodeValue = oCopyGeneralPrivItem.NodeValue;
                     oOldMemberPrivItem.Remark = oCopyGeneralPrivItem.Remark;
                 }
                 else//子表之前没有 则添加
                 {
                     MemberPrivItem oNewPrivItem = new MemberPrivItem
                     {
                         PrivID = oOldMemberPriv.Gid,
                         RefID = oCopyGeneralPrivItem.RefID,
                         NodeCode = oCopyGeneralPrivItem.NodeCode,
                         NodeValue = oCopyGeneralPrivItem.NodeValue,
                         Remark = oCopyGeneralPrivItem.Remark
                     };
                     dbEntity.MemberPrivItems.Add(oNewPrivItem);
                 }
             }
         }
         else//之前没有,则添加
         {
             MemberPrivilege oNewPriv = new MemberPrivilege
             {
                 UserID = UserID,
                 Ptype = oCopyPrivTemplate.Ptype,
                 Pstatus = oCopyPrivTemplate.Pstatus,
                 Remark = oCopyPrivTemplate.Remark
             };
             dbEntity.MemberPrivileges.Add(oNewPriv);
             dbEntity.SaveChanges();
             List<GeneralPrivItem> oCopyGeneralPrivItemList = dbEntity.GeneralPrivItems.Where(g => g.Deleted == false && g.PrivID == oCopyPrivTemplate.Gid).ToList();
             foreach (GeneralPrivItem oCopyGeneralPrivItem in oCopyGeneralPrivItemList)
             {
                 MemberPrivItem oNewPrivItem = new MemberPrivItem {
                     PrivID = oNewPriv.Gid,
                     RefID = oCopyGeneralPrivItem.RefID,
                     NodeCode = oCopyGeneralPrivItem.NodeCode,
                     NodeValue = oCopyGeneralPrivItem.NodeValue,
                     Remark = oCopyGeneralPrivItem.Remark
                 };
                 dbEntity.MemberPrivItems.Add(oNewPrivItem);
             }
         }
     }
     dbEntity.SaveChanges();
     return true;
 }
예제 #15
0
        public static void RunOnce()
        {
            try
            {
                // 创建数据库事务
                using (var scope = new TransactionScope())
                {
                    // 创建EF实体
                    using (var oLiveEntities = new LiveEntities(ConfigHelper.LiveConnection.Connection))
                    {
                        #region GeneralConfig配置参数
                        GeneralConfig oConfig_System = new GeneralConfig
                        {
                            // 系统配置参数
                            Code = "SYSTEM",
                            StrValue = "System",
                            Remark = "一级菜单(系统配置参数)",
                            ChildItems = new List<GeneralConfig>
                            {
                                // 系统启用日期
                                new GeneralConfig
                                {
                                    Code = "StartDate",
                                    Ctype = (byte)ModelEnum.ConfigParamType.DATETIME,
                                    DateValue = DateTimeOffset.Now,
                                    Remark = "二级菜单(系统启用日期)"
                                },
                                // 国家统计局最新行政区划
                                new GeneralConfig
                                {
                                    Code = "LastRegionDefine",
                                    Ctype = (byte)ModelEnum.ConfigParamType.DATETIME,
                                    DateValue = new DateTimeOffset(2010, 12, 31, 0, 0, 0, TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now)),
                                    Remark = "最新县及县以上行政区划代码(截止2010年12月31日);http://www.stats.gov.cn/tjbz/xzqhdm/t20110726_402742468.htm"
                                },
                                // Session 名称
                                new GeneralConfig
                                {
                                    Code = "SessionName",
                                    StrValue = "ZhuchaoSession",
                                    Remark = "二级菜单(Session名称)"
                                },
                                // Cookie 名称
                                new GeneralConfig
                                {
                                    Code ="CookieName",
                                    StrValue = "ZhuchaoCookie",
                                    Remark = "二级菜单(Cookie名称)"
                                }
                            }
                        };
                        GeneralConfig oConfig_Code = new GeneralConfig
                        {
                            // 代码生成器参数
                            Code = "CODE",
                            StrValue = "Code",
                            Remark = "一级菜单(代码生成器参数)",
                            ChildItems = new List<GeneralConfig>
                            {
                                // 字符代码前缀
                                new GeneralConfig
                                {
                                    Code = "CodePrefix_C",
                                    Ctype = (byte)ModelEnum.ConfigParamType.STRING,
                                    StrValue = "C",
                                    Remark = "二级菜单(字符代码前缀,每个数据库不一样,中国C,美国U,欧洲E)"
                                },
                                // 数字代码前缀
                                new GeneralConfig
                                {
                                    Code = "CodePrefix_N",
                                    Ctype = (byte)ModelEnum.ConfigParamType.STRING,
                                    StrValue = "1",
                                    Remark = "二级菜单(数字代码前缀,每个数据库不一样,中国1,美国2,欧洲3)"
                                },
                                // 错误报告代码 GeneralErrorReport.Code
                                new GeneralConfig
                                {
                                    Code = "ErrorReportCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(错误报告代码)"
                                },
                                // 待办事项代码 GeneralTodoList.Code
                                new GeneralConfig
                                {
                                    Code = "TodoListCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(待办事项代码)"
                                },
                                // 采购单号 PurchaseInformation.Code
                                new GeneralConfig
                                {
                                    Code = "PurchaseCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(采购单号,递增,不可跳号)"
                                },
                                // 质检单号 PurchaseInspection.Code
                                new GeneralConfig
                                {
                                    Code ="InspectionCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(质检单号,递增,不可跳号)"
                                },
                                // 入库单号 WarehouseStockIn.Code
                                new GeneralConfig
                                {
                                    Code ="StockInCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(入库单号,递增,不可跳号)"
                                },
                                // 出库单号 WarehouseStockOut.Code
                                new GeneralConfig
                                {
                                    Code ="StockOutCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(出库单号,递增,不可跳号)"
                                },
                                // 移库单号 WarehouseMoving.Code
                                new GeneralConfig
                                {
                                    Code ="MovingCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(移库单号,递增,不可跳号)"
                                },
                                // 盘点单号 WarehouseInventory.Code
                                new GeneralConfig
                                {
                                    Code ="InventoryCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(盘点单号,递增,不可跳号)"
                                },
                                // 订单号 OrderInformation.Code
                                new GeneralConfig
                                {
                                    Code ="OrderCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(订单号,递增,不可跳号)"
                                },
                                // 应付单号 FinancePayment.Code
                                new GeneralConfig
                                {
                                    Code ="PaymentCode",
                                    Ctype = (byte)ModelEnum.ConfigParamType.INTEGER,
                                    IntValue = 0,
                                    Remark = "二级菜单(应付号,递增,不可跳号)"
                                }
                            }
                        };
                        oLiveEntities.GeneralConfigs.Add(oConfig_System);
                        oLiveEntities.GeneralConfigs.Add(oConfig_Code);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: GeneralConfig 配置参数");
                        #endregion

                        #region GeneralStandardCategory标准分类

                        #region 标准组织类别
                        GeneralStandardCategory oStandardOrganization = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.ORGANIZATION,
                            Code = "Standard",
                            Remark = "标准组织类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "标准组织",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Standard Organization" }
                                }
                            }
                        };
                        #endregion

                        #region 渠道类别
                        GeneralStandardCategory oChannelType01 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "OfficialWeb",
                            Remark = "官网",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "正式官网",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Official Website" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType02 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "Taobao",
                            Remark = "淘宝店,包括淘宝旗舰店和专营店等",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "淘宝店",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Taobao" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType03 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "Paipai",
                            Remark = "拍拍店",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "拍拍店",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Paipai" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType04 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "Sina",
                            Remark = "新浪商城",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "新浪商城",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Sina Mall" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType05 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "tg.com.cn",
                            Remark = "齐家网",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "齐家网",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Qijia" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType06 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "360buy",
                            Remark = "京东商城",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "京东商城",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "360buy" }
                                }
                            }
                        };
                        GeneralStandardCategory oChannelType07 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.CHANNEL,
                            Code = "dangdang",
                            Remark = "当当网",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "当当网",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "dangdang" }
                                }
                            }
                        };
                        #endregion

                        #region 入库类型
                        GeneralStandardCategory oStockInType01 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKIN,
                            Code = "PurchaseIn",
                            Remark = "大货入库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "大货入库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Bulk In" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockInType02 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKIN,
                            Code = "ReturnIn",
                            Remark = "退货入库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "退货入库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Return In" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockInType03 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKIN,
                            Code = "InventoryProfit",
                            Remark = "盘盈入库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "盘盈",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Inventory Profit" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockInType04 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKIN,
                            Code = "AdjustStockIn",
                            Remark = "调整入库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "调整入库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Adjust Stock In" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockInType05 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKIN,
                            Code = "MoveIn",
                            Remark = "移入库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "移入库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Move In" }
                                }
                            }
                        };
                        #endregion

                        #region 出库类型
                        GeneralStandardCategory oStockOutType01 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "Sale",
                            Remark = "销售出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "销售出库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Sale" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType01b = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "Resend",
                            Remark = "销售补发货出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "销售补发/换货",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Resend/Change" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType02 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "ReturnSupplier",
                            Remark = "采购退货出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "采购退货",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Return Supplier" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType03 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "Discard",
                            Remark = "报废出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "报废",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Discard" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType04 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "InventoryLosses",
                            Remark = "盘亏出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "盘亏",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Inventory Losses" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType05 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "Adjust Stock Out",
                            Remark = "调整出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "调整出库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Adjust Stock Out" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType06 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "MoveOut",
                            Remark = "移出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "移出库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Move Out" }
                                }
                            }
                        };
                        GeneralStandardCategory oStockOutType07 = new GeneralStandardCategory
                        {
                            Ctype = (byte)ModelEnum.StandardCategoryType.STOCKOUT,
                            Code = "InternalUse",
                            Remark = "内部领用出库类型",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "内部领用出库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Internal Use" }
                                }
                            }
                        };
                        #endregion

                        oLiveEntities.GeneralStandardCategorys.Add(oStandardOrganization);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType01);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType02);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType03);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType04);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType05);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType06);
                        oLiveEntities.GeneralStandardCategorys.Add(oChannelType07);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockInType01);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockInType02);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockInType03);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockInType04);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockInType05);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType01);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType01b);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType02);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType03);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType04);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType05);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType06);
                        oLiveEntities.GeneralStandardCategorys.Add(oStockOutType07);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: GeneralStandardCategory 标准分类");
                        #endregion

                        #region GeneralMeasureUnit 主要计量单位
                        GeneralMeasureUnit oUnitPiece = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.PIECE,
                            Code = "PCS",
                            Remark = "个/件",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "个",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Piece" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitKG = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.WEIGHT,
                            Code = "KG",
                            Remark = "千克/公斤",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "千克",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "KG" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitG = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.WEIGHT,
                            Code = "G",
                            Remark = "克",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "克",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "G" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitPound = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.WEIGHT,
                            Code = "Pound",
                            Remark = "英磅",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "英磅",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Pound" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitCube = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.VOLUME,
                            Code = "CUBE",
                            Remark = "平方米",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "立方米",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Cube Meter" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitLitre = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.FLUID,
                            Code = "Litre",
                            Remark = "升",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "升",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Litre" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitGallon = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.FLUID,
                            Code = "Gallon",
                            Remark = "加仑",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "加仑",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Gallon" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitSquare = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.AREA,
                            Code = "Square",
                            Remark = "平方米",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "平方米",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Square Meter" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitSF = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.AREA,
                            Code = "SF",
                            Remark = "平方英尺",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "平方英尺",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Square Feet" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitMeter = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.LINEAR,
                            Code = "Meter",
                            Remark = "米",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "米",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Meter" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitFeet = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.LINEAR,
                            Code = "Feet",
                            Remark = "英尺",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "英尺",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Feet" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitRMB = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.CURRENCY,
                            Code = (new CultureInfo("zh-CN")).NumberFormat.CurrencySymbol,
                            Remark = "人民币",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "人民币",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "RMB" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitUSD = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.CURRENCY,
                            Code = (new CultureInfo("en-US")).NumberFormat.CurrencySymbol,
                            Remark = "美元",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "美元",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "USD" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitEUR = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.CURRENCY,
                            Code = (new CultureInfo("fr-FR")).NumberFormat.CurrencySymbol,
                            Remark = "欧元",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "欧元",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "EUR" }
                                }
                            }
                        };
                        GeneralMeasureUnit oUnitGRP = new GeneralMeasureUnit
                        {
                            Utype = (byte)ModelEnum.MeasureUnit.CURRENCY,
                            Code = (new CultureInfo("en-GB")).NumberFormat.CurrencySymbol,
                            Remark = "英镑",
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "英镑",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "GRP" }
                                }
                            }
                        };
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitPiece);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitKG);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitG);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitPound);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitCube);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitLitre);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitGallon);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitSquare);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitSF);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitMeter);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitFeet);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitRMB);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitUSD);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitEUR);
                        oLiveEntities.GeneralMeasureUnits.Add(oUnitGRP);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: GeneralMeasureUnit 主要计量单位");
                        #endregion

                        #region GeneralCultureUnit 默认语言和计量单位
                        GeneralCultureUnit oCultureZHCN = new GeneralCultureUnit
                        {
                            // 中文(中国)
                            Culture = 2052,  // zh-CN
                            Piece = oUnitPiece,
                            Weight = oUnitKG,
                            Volume = oUnitCube,
                            Fluid = oUnitLitre,
                            Area = oUnitSquare,
                            Linear = oUnitMeter,
                            Currency = oUnitRMB
                        };
                        GeneralCultureUnit oCultureENUS = new GeneralCultureUnit
                        {
                            // 英语(美国)
                            Culture = 1033,  // en-US
                            Piece = oUnitPiece,
                            Weight = oUnitPound,
                            Volume = oUnitCube,
                            Fluid = oUnitGallon,
                            Area = oUnitSF,
                            Linear = oUnitFeet,
                            Currency = oUnitUSD
                        };
                        GeneralCultureUnit oCultureENGB = new GeneralCultureUnit
                        {
                            // 英语(英国)
                            Culture = 2057,  // en-GB
                            Piece = oUnitPiece,
                            Weight = oUnitPound,
                            Volume = oUnitCube,
                            Fluid = oUnitGallon,
                            Area = oUnitSF,
                            Linear = oUnitFeet,
                            Currency = oUnitGRP
                        };
                        GeneralCultureUnit oCultureFRFR = new GeneralCultureUnit
                        {
                            // 法文(法国)
                            Culture = 1036,  // fr-FR
                            Piece = oUnitPiece,
                            Weight = oUnitKG,
                            Volume = oUnitCube,
                            Fluid = oUnitLitre,
                            Area = oUnitSquare,
                            Linear = oUnitMeter,
                            Currency = oUnitEUR
                        };
                        GeneralCultureUnit oCultureDEDE = new GeneralCultureUnit
                        {
                            // 德文(德国)
                            Culture = 1031,  // de-DE
                            Piece = oUnitPiece,
                            Weight = oUnitKG,
                            Volume = oUnitCube,
                            Fluid = oUnitLitre,
                            Area = oUnitSquare,
                            Linear = oUnitMeter,
                            Currency = oUnitEUR
                        };
                        oLiveEntities.GeneralCultureUnits.Add(oCultureZHCN);
                        oLiveEntities.GeneralCultureUnits.Add(oCultureENUS);
                        oLiveEntities.GeneralCultureUnits.Add(oCultureENGB);
                        oLiveEntities.GeneralCultureUnits.Add(oCultureFRFR);
                        oLiveEntities.GeneralCultureUnits.Add(oCultureDEDE);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: GeneralCultureUnit 默认语言和计量单位");
                        #endregion

                        #region 预定义第一个组织、两个渠道、第一个仓库、两个角色由触发器生成
                        // 第一个组织
                        MemberOrganization oFirstOrgan = new MemberOrganization
                        {
                            Code = "Zhuchao",
                            Ostatus = (byte)ModelEnum.OrganizationStatus.VALID,
                            ExtendType = oStandardOrganization,  // 标准组织
                            Terminal = true,
                            FullName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "上海筑巢信息科技有限公司",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shanghai Zhuchao Information Technologo Co., Ltd." }
                                }
                            },
                            ShortName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "筑巢",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Zhuchao" }
                                }
                            },
                            FullAddress = "上海市嘉定区马陆镇丰功路958号",
                            PostCode = "201801",
                            Contact = "伯鉴",
                            CellPhone = "13816626660",
                            WorkPhone = "(86)21-60831660",
                            WorkFax = "(86)21-60831657",
                            Email = "*****@*****.**",
                            HomeUrl = "http://www.zhuchao.com"
                        };
                        // 第一个官网渠道
                        MemberChannel oFirstChannel = new MemberChannel
                        {
                            Code = "ZCWEB001",
                            Ostatus = (byte)ModelEnum.OrganizationStatus.VALID,
                            ExtendType = oChannelType01,        // 官网
                            Terminal = true,
                            FullName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "筑巢官网",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Zhuchao Website" }
                                }
                            },
                            ShortName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "筑巢官网",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Zhuchao Website" }
                                }
                            },
                            FullAddress = "上海市嘉定区马陆镇丰功路958号",
                            PostCode = "201801",
                            Contact = "伯鉴",
                            CellPhone = "13816626660",
                            WorkPhone = "(86)21-60831660",
                            WorkFax = "(86)21-60831657",
                            Email = "*****@*****.**",
                            HomeUrl = "http://www.zhuchao.com"
                        };
                        // 第二个淘宝专营店渠道
                        MemberChannel oSecondChannel = new MemberChannel
                        {
                            Code = "ZCTB001",
                            Ostatus = (byte)ModelEnum.OrganizationStatus.VALID,
                            ExtendType = oChannelType02,        // 淘宝网
                            Terminal = true,
                            FullName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "淘宝专营店",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Taobao 专营店" }
                                }
                            },
                            ShortName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "淘宝专营店",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Taobao 专营店" }
                                }
                            },
                            FullAddress = "上海市嘉定区马陆镇丰功路958号",
                            PostCode = "201801",
                            Contact = "伯鉴",
                            CellPhone = "13816626660",
                            WorkPhone = "(86)21-60831660",
                            WorkFax = "(86)21-60831657",
                            Email = "*****@*****.**",
                            HomeUrl = "http://www.zhuchao.com.cn"
                        };
                        // 组织和渠道关联
                        MemberOrgChannel oOrganChannel1 = new MemberOrgChannel
                        {
                            Organization = oFirstOrgan,
                            Channel = oFirstChannel,
                            Cstatus = (byte)ModelEnum.GenericStatus.VALID
                        };
                        MemberOrgChannel oOrganChannel2 = new MemberOrgChannel
                        {
                            Organization = oFirstOrgan,
                            Channel = oSecondChannel,
                            Cstatus = (byte)ModelEnum.GenericStatus.VALID,
                            // RemoteUrl = "http://gw.api.tbsandbox.com/router/rest",         // 沙箱地址
                            RemoteUrl = "http://gw.api.taobao.com/router/rest",               // 正式地址
                            ConfigKey = "12176743",
                            SecretKey = "a9e366dde6816c2866e4f60af62162ca",
                            SessionKey = "23767603b359d0623b84b6963b5507db8f6b3_1"
                        };
                        // 组织支持的默认语言
                        MemberOrgCulture oOrganCulture01 = new MemberOrgCulture
                        {
                            Organization = oFirstOrgan,
                            Ctype = (byte)ModelEnum.CultureType.LANGUAGE,
                            Culture = oCultureZHCN
                        };
                        MemberOrgCulture oOrganCulture02 = new MemberOrgCulture
                        {
                            Organization = oFirstOrgan,
                            Ctype = (byte)ModelEnum.CultureType.LANGUAGE,
                            Culture = oCultureENUS
                        };
                        MemberOrgCulture oOrganCulture03 = new MemberOrgCulture
                        {
                            Organization = oFirstOrgan,
                            Ctype = (byte)ModelEnum.CultureType.CURRENCY,
                            Currency = oUnitRMB
                        };
                        // 第一个仓库及其支持的渠道
                        WarehouseInformation oWarehouse = new WarehouseInformation
                        {
                            Code = "ZCWH001",
                            Ostatus = (byte)ModelEnum.OrganizationStatus.VALID,
                            Parent = oFirstOrgan,
                            Terminal = true,
                            FullName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "上海丰功路仓库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shanghai Fenggong Road" }
                                }
                            },
                            ShortName = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "上海丰功路仓库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shanghai Fenggong Road" }
                                }
                            },
                            FullAddress = "上海市嘉定区马陆镇丰功路958号",
                            PostCode = "201801",
                            Contact = "伯鉴",
                            CellPhone = "13816626660",
                            WorkPhone = "(86)21-60831660",
                            WorkFax = "(86)21-60831657",
                            Email = "*****@*****.**",
                            HomeUrl = "http://www.zhuchao.com",
                            Channels = new List<MemberOrgChannel>
                            {
                                new MemberOrgChannel
                                {
                                    Channel = oFirstChannel,
                                    Cstatus = (byte)ModelEnum.GenericStatus.VALID
                                }
                            }
                        };

                        oLiveEntities.MemberOrgChannels.Add(oOrganChannel1);
                        oLiveEntities.MemberOrgChannels.Add(oOrganChannel2);
                        oLiveEntities.MemberOrgCultures.Add(oOrganCulture01);
                        oLiveEntities.MemberOrgCultures.Add(oOrganCulture02);
                        oLiveEntities.MemberOrgCultures.Add(oOrganCulture03);
                        oLiveEntities.WarehouseInformations.Add(oWarehouse);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: 预定义第一个组织、两个渠道、第一个仓库、角色由触发器生成");
                        #endregion

                        #region 管理员角色,第一个管理员用户,第一个测试用户
                        MemberRole oAdminRole = new MemberRole
                        {
                            Organization = oFirstOrgan,
                            Code = "Supervisor",               // 唯一的一个超级管理员角色,不需要任何权限
                            Parent = oLiveEntities.MemberRoles.Where(r => r.Code == "Internal" && r.OrgID == oFirstOrgan.Gid).FirstOrDefault(),
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "超级管理员",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Supervisor" }
                                }
                            },
                            Remark = "超级管理员"
                        };
                        // 第一个用户
                        MemberUser oAdminUser = new MemberUser
                        {
                            Organization = oFirstOrgan,
                            Role = oAdminRole,
                            Channel = oFirstChannel,
                            LoginName = "admin",
                            Ustatus = (byte)ModelEnum.UserStatus.VALID,
                            NickName = "admin",
                            FirstName = "System",
                            LastName = "Admin",
                            DisplayName = "System Admin",
                            Culture = oCultureENUS,//天佑
                            Passcode = "izhuchao.com"
                        };
                        //测试用户Tester 测试用
                        MemberUser oTester = new MemberUser
                        {
                            Organization = oFirstOrgan,
                            Role = oLiveEntities.MemberRoles.Single(r => (r.OrgID == oFirstOrgan.Gid && r.Code == "Internal")),
                            Channel = oFirstChannel,
                            LoginName = "test",
                            Ustatus = (byte)ModelEnum.UserStatus.VALID,
                            NickName = "test",
                            FirstName = "System",
                            LastName = "Tester",
                            DisplayName = "System Tester",
                            Culture = oCultureZHCN,
                            Passcode = "izhuchao.com"
                        };
                        oLiveEntities.MemberUsers.Add(oAdminUser);
                        oLiveEntities.MemberUsers.Add(oTester);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: 预定义超级管理员角色,第一个管理员和测试用户");
                        #endregion

                        #region GeneralProgram 程序定义

                        #region 首页
                        GeneralProgram oProgramHome = new GeneralProgram
                        {
                            Code = "HomeHomePage",
                            Parent = null,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "首页",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Home" }
                                }
                            },
                            ProgUrl = "/Home/HomePage"
                        };
                        #endregion

                        #region 系统菜单
                        GeneralProgram oProgramSys = new GeneralProgram
                        {
                            Code = "System",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "系统",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "System" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramSys01 = new GeneralProgram
                        {
                            Code = "ConfigIndex",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "配置参数",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Config Parameters" }
                                }
                            },
                            ProgUrl = "/Config/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys02 = new GeneralProgram
                        {
                            Code = "ProgramIndex",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "程序定义",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Program Define" }
                                }
                            },
                            ProgUrl = "/Program/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys03 = new GeneralProgram
                        {
                            Code = "RegionIndex",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "地区维护",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Region Define" }
                                }
                            },
                            ProgUrl = "/Region/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys04 = new GeneralProgram
                        {
                            Code = "CategoryIndex",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "分类管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Category Define" }
                                }
                            },
                            ProgUrl = "/Category/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEditPrivate",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑私有分类",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Private" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableEditStandard",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑标准分类",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Standard" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys05 = new GeneralProgram
                        {
                            Code = "OptionalIndex",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "属性管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Attribute Manage" }
                                }
                            },
                            ProgUrl = "/Optional/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys06 = new GeneralProgram
                        {
                            Code = "ConfigUnit",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "计量单位",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Measure Unit" }
                                }
                            },
                            ProgUrl = "/Config/MeasureUnit",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys07 = new GeneralProgram
                        {
                            Code = "ConfigCulture",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "语言文化",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Culture Manage" }
                                }
                            },
                            ProgUrl = "/Config/Culture",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys08 = new GeneralProgram
                        {
                            Code = "ConfigMessage",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "消息队列",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Message" }
                                }
                            },
                            ProgUrl = "/Config/Message",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableSend",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许发短信",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Send" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramSys11 = new GeneralProgram
                        {
                            Code = "ConfigErrorReport",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "错误报告",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Error Report" }
                                }
                            },
                            ProgUrl = "/Config/ErrorReport"
                        };
                        GeneralProgram oProgramSys12 = new GeneralProgram
                        {
                            Code = "ConfigAction",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "事件日志",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Action Event" }
                                }
                            },
                            ProgUrl = "/Config/Action"
                        };
                        GeneralProgram oProgramSys13 = new GeneralProgram
                        {
                            Code = "ConfigShortcut",
                            Parent = oProgramSys,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "快捷方式",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shortcut" }
                                }
                            },
                            ProgUrl = "/Config/Shortcut"
                        };
                        #endregion

                        #region 会员菜单
                        GeneralProgram oProgramMem = new GeneralProgram
                        {
                            Code = "Member",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "会员",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Member" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramMem01 = new GeneralProgram
                        {
                            Code = "OrganizationIndex",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "组织管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Organization Manage" }
                                }
                            },
                            ProgUrl = "/Organization/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMem02 = new GeneralProgram
                        {
                            Code = "OrganizationChannel",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "渠道管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Channel Manage" }
                                }
                            },
                            ProgUrl = "/Organization/ChannelIndex",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMem03 = new GeneralProgram
                        {
                            Code = "MemberRole",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "角色管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Role Manage" }
                                }
                            },
                            ProgUrl = "/User/MemberRole",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMem04 = new GeneralProgram
                        {
                            Code = "UserIndex",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "用户管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "User Manage" }
                                }
                            },
                            ProgUrl = "/User/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMem05 = new GeneralProgram
                        {
                            Code = "UserPrivilege",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "用户授权",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "User Privilege" }
                                }
                            },
                            ProgUrl = "/Privilege/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMem06 = new GeneralProgram
                        {
                            Code = "UserPoint",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "用户积分",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "User Point" }
                                }
                            },
                            ProgUrl = "/User/Point"
                        };
                        GeneralProgram oProgramMem07 = new GeneralProgram
                        {
                            Code = "UserLevel",
                            Parent = oProgramMem,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "用户级别",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "User Level" }
                                }
                            },
                            ProgUrl = "/User/Level"
                        };
                        #endregion

                        #region 商品菜单
                        GeneralProgram oProgramProd = new GeneralProgram
                        {
                            Code = "Product",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "商品",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramProd01 = new GeneralProgram
                        {
                            Code = "ProductIndex",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "商品列表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product List" }
                                }
                            },
                            ProgUrl = "/Product/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramProd02 = new GeneralProgram
                        {
                            Code = "ProductGallery",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "图片处理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product Gallery" }
                                }
                            },
                            ProgUrl = "/Product/Gallery",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramProd03 = new GeneralProgram
                        {
                            Code = "ProductImport",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "批量导入",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product Import" }
                                }
                            },
                            ProgUrl = "/Product/Import"
                        };
                        GeneralProgram oProgramProd04 = new GeneralProgram
                        {
                            Code = "ProductValidation",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "数据验证",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product Validation" }
                                }
                            },
                            ProgUrl = "/Product/Validation"
                        };
                        GeneralProgram oProgramProd05 = new GeneralProgram
                        {
                            Code = "OnSaleIndex",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "商品上架",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Product On Sale" }
                                }
                            },
                            ProgUrl = "/Product/OnSaleIndex",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认(上架)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm (On Sale)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramProd06 = new GeneralProgram
                        {
                            Code = "OnSaleTemplate",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "上架模板",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "On Sale Template" }
                                }
                            },
                            ProgUrl = "/Product/OnSaleTemplate",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramProd07 = new GeneralProgram
                        {
                            Code = "ProductCodePolicy",
                            Parent = oProgramProd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "代码规则",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Code Policy" }
                                }
                            },
                            ProgUrl = "/Product/CodePolicy",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        #endregion

                        #region 采购菜单
                        GeneralProgram oProgramPur = new GeneralProgram
                        {
                            Code = "Purchase",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "采购",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Purchase" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramPur01 = new GeneralProgram
                        {
                            Code = "PurchaseIndex",
                            Parent = oProgramPur,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "采购单据",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Purchase List" }
                                }
                            },
                            ProgUrl = "/Purchase/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableClose",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许结算",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Close" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramPur02 = new GeneralProgram
                        {
                            Code = "PurchaseQuality",
                            Parent = oProgramPur,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "质量检查",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Quality Control" }
                                }
                            },
                            ProgUrl = "/Purchase/Quality",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramPur03 = new GeneralProgram
                        {
                            Code = "OrganizationSupplier",
                            Parent = oProgramPur,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "供应商",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Supplier" }
                                }
                            },
                            ProgUrl = "/Organization/SupplierIndex",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        #endregion

                        #region 仓库菜单
                        GeneralProgram oProgramWh = new GeneralProgram
                        {
                            Code = "Warehouse",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "仓库",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramWh01 = new GeneralProgram
                        {
                            Code = "OrganizationWarehouse",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "仓库列表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse List" }
                                }
                            },
                            ProgUrl = "/Organization/WarehouseIndex",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh02 = new GeneralProgram
                        {
                            Code = "WarehouseIndex",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "库存总账",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse Ledger" }
                                }
                            },
                            ProgUrl = "/Warehouse/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑(冻结)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit (Lock)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh03 = new GeneralProgram
                        {
                            Code = "WarehouseStockIn",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "入库记录",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Stock In" }
                                }
                            },
                            ProgUrl = "/Warehouse/StockIn",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrint",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许打印",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Print" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh04 = new GeneralProgram
                        {
                            Code = "WarehouseStockOut",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "出库记录",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Stock Out" }
                                }
                            },
                            ProgUrl = "/Warehouse/StockOut",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrint",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许打印",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Print" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认(扫描/发货)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm (Scan/Delivery)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableSignFor",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许签收",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow SignFor" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh05 = new GeneralProgram
                        {
                            Code = "WarehouseMoving",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "移库申请",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Moving" }
                                }
                            },
                            ProgUrl = "/Warehouse/Moving",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh06 = new GeneralProgram
                        {
                            Code = "WarehouseInventory",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "盘点记录",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Inventory" }
                                }
                            },
                            ProgUrl = "/Warehouse/Inventory",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnablePrepare",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许制表(编辑)",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Prepare (Edit)" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableApprove",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableSnapshot",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许仓库快照",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Snapshot" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh07 = new GeneralProgram
                        {
                            Code = "WarehouseShelf",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "货架管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse Shelf" }
                                }
                            },
                            ProgUrl = "/Warehouse/Shelf",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEditShelf",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许定义货架",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Shelf" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableEditLock",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑冻结",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Lock" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            },
                            Remark = "包括WarehouseSkuShelf"
                        };
                        GeneralProgram oProgramWh08 = new GeneralProgram
                        {
                            Code = "WarehouseRegion",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "送达地区",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Support Region" }
                                }
                            },
                            ProgUrl = "/Warehouse/Region",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramWh09 = new GeneralProgram
                        {
                            Code = "WarehouseShipping",
                            Parent = oProgramWh,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "承运商",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Support Shipping" }
                                }
                            },
                            ProgUrl = "/Warehouse/Shipping",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        #endregion

                        #region 订单菜单
                        GeneralProgram oProgramOrd = new GeneralProgram
                        {
                            Code = "Order",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "订单",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Order" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramOrd01 = new GeneralProgram
                        {
                            Code = "OrderIndex",
                            Parent = oProgramOrd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "订单列表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Order List" }
                                }
                            },
                            ProgUrl = "/Order/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableNew",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许新建订单",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow New Order" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableConfig",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许确认订单",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Confirm Order" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableArrange",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许排单",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Arrange" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableClose",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许结算",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Close" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableCancel",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许取消",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Cancel" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnablePayment",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许收/付款",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Payment" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableEditAddress",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑地址",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Address" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                },
                                new GeneralProgNode
                                {
                                    Code = "EnableEditPrice",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑价格",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit Price" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramOrd02 = new GeneralProgram
                        {
                            Code = "OrderConfirm",
                            Parent = oProgramOrd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "订单确认",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Order Confirm" }
                                }
                            },
                            ProgUrl = "/Order/Confirm",
                            Remark = "跳转到/Order/Index?Confirm=待确认,使用OrderIndex的权限"
                        };
                        GeneralProgram oProgramOrd03 = new GeneralProgram
                        {
                            Code = "OrderPolicy",
                            Parent = oProgramOrd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "订单策略",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Order Policy" }
                                }
                            },
                            ProgUrl = "/Order/Policy",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            },
                            Remark = "包括拆单,自动处理等策略"
                        };
                        GeneralProgram oProgramOrd04 = new GeneralProgram
                        {
                            Code = "PromotionIndex",
                            Parent = oProgramOrd,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "促销管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Promotion" }
                                }
                            },
                            ProgUrl = "/Promotion/Index"
                        };
                        #endregion

                        #region 承运菜单
                        GeneralProgram oProgramShip = new GeneralProgram
                        {
                            Code = "Shipping",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "承运",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shipping" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramShip01 = new GeneralProgram
                        {
                            Code = "OrganizationShipper",
                            Parent = oProgramShip,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "承运商列表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shipper List" }
                                }
                            },
                            ProgUrl = "/Organization/ShippingIndex",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramShip02 = new GeneralProgram
                        {
                            Code = "ShippingRegion",
                            Parent = oProgramShip,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "承运商地区",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shipper Region" }
                                }
                            },
                            ProgUrl = "/Shipping/ShipperRegion",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramShip03 = new GeneralProgram
                        {
                            Code = "ShippingIndex",
                            Parent = oProgramShip,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "面单管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Shipper Envelope" }
                                }
                            },
                            ProgUrl = "/Shipping/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        #endregion

                        #region 财务菜单
                        GeneralProgram oProgramFin = new GeneralProgram
                        {
                            Code = "Finance",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "财务",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Finance" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramFin01 = new GeneralProgram
                        {
                            Code = "FinanceIndex",
                            Parent = oProgramFin,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "付款方式",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Payment Type" }
                                }
                            },
                            ProgUrl = "/Finance/Index",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramFin02 = new GeneralProgram
                        {
                            Code = "FinanceInvoice",
                            Parent = oProgramFin,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "发票管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Invoice" }
                                }
                            },
                            ProgUrl = "/Finance/Invoice",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramFin03 = new GeneralProgram
                        {
                            Code = "FinancePayable",
                            Parent = oProgramFin,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "应付款",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Account Payable" }
                                }
                            },
                            ProgUrl = "/Finance/Payable",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        #endregion

                        #region 商城管理
                        GeneralProgram oProgramMall = new GeneralProgram
                        {
                            Code = "Mall",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "商城",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Mall" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramMall01 = new GeneralProgram
                        {
                            Code = "MallIndex",
                            Parent = oProgramMall,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "内容管理",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Mall Content" }
                                }
                            },
                            ProgUrl = "/Mall/Index",
                            Remark = "包括发布",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMall02 = new GeneralProgram
                        {
                            Code = "MallPosition",
                            Parent = oProgramMall,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "位置定义",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Art Position" }
                                }
                            },
                            ProgUrl = "/Mall/Position",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            }
                        };
                        GeneralProgram oProgramMall03 = new GeneralProgram
                        {
                            Code = "MallSetting",
                            Parent = oProgramMall,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "商城配置",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Mall Setting" }
                                }
                            },
                            ProgUrl = "/Mall/Setting",
                            ProgramNodes = new List<GeneralProgNode>
                            {
                                new GeneralProgNode
                                {
                                    Code = "EnableEdit",
                                    Name = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "允许编辑",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "Allow Edit" }
                                        }
                                    },
                                    InputMode = (byte)ModelEnum.OptionalInputMode.COMBOBOX,
                                    Optional = new GeneralResource
                                    {
                                        Culture = 2052, Matter = "0|否,1|是",
                                        ResourceItems = new List<GeneralResItem>
                                        {
                                            new GeneralResItem { Culture = 1033, Matter = "0|No,1|Yes" }
                                        }
                                    }
                                }
                            },
                            Remark = "包括热门关键词,商品收藏,关注,友情链接,敏感词,黑名单等"
                        };
                        GeneralProgram oProgramMall04 = new GeneralProgram
                        {
                            Code = "MallClick",
                            Parent = oProgramMall,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "点击统计",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Click Statistics" }
                                }
                            },
                            ProgUrl = "/Mall/Click"
                        };
                        #endregion

                        #region 知识
                        GeneralProgram oProgramKnow = new GeneralProgram
                        {
                            Code = "Knowledge",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "知识",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Knowledge" }
                                }
                            },
                            ProgUrl = ""
                        };
                        #endregion

                        #region 报表集合
                        GeneralProgram oProgramRpt = new GeneralProgram
                        {
                            Code = "Report",
                            Parent = null,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "报表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Report" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramRpt01 = new GeneralProgram
                        {
                            Code = "ReportSales",
                            Parent = oProgramRpt,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "销售报表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Sales Report" }
                                }
                            },
                            ProgUrl = ""
                        };
                        GeneralProgram oProgramRpt0101 = new GeneralProgram
                        {
                            Code = "ReportSalesDaily",
                            Parent = oProgramRpt01,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "日销售报表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Sales Daily Report" }
                                }
                            },
                            ProgUrl = "/Report/Sales/Daily"
                        };
                        GeneralProgram oProgramRpt02 = new GeneralProgram
                        {
                            Code = "ReportWarehouse",
                            Parent = oProgramRpt,
                            Terminal = false,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "库存报表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse Report" }
                                }
                            },
                            ProgUrl = "/Report/Warehouse/Analysis"
                        };
                        GeneralProgram oProgramRpt0201 = new GeneralProgram
                        {
                            Code = "ReportWarehouseStock",
                            Parent = oProgramRpt02,
                            Terminal = true,
                            Name = new GeneralResource
                            {
                                Culture = 2052,
                                Matter = "库存分析表",
                                ResourceItems = new List<GeneralResItem>
                                {
                                    new GeneralResItem { Culture = 1033, Matter = "Warehouse Stock" }
                                }
                            },
                            ProgUrl = "/Report/Warehouse/Analysis"
                        };
                        #endregion

                        oLiveEntities.GeneralPrograms.Add(oProgramHome);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys01);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys02);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys03);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys04);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys05);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys06);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys07);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys08);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys11);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys12);
                        oLiveEntities.GeneralPrograms.Add(oProgramSys13);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem01);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem02);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem03);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem04);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem05);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem06);
                        oLiveEntities.GeneralPrograms.Add(oProgramMem07);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd01);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd02);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd03);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd04);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd05);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd06);
                        oLiveEntities.GeneralPrograms.Add(oProgramProd07);
                        oLiveEntities.GeneralPrograms.Add(oProgramPur01);
                        oLiveEntities.GeneralPrograms.Add(oProgramPur02);
                        oLiveEntities.GeneralPrograms.Add(oProgramPur03);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh01);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh02);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh03);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh04);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh05);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh06);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh07);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh08);
                        oLiveEntities.GeneralPrograms.Add(oProgramWh09);
                        oLiveEntities.GeneralPrograms.Add(oProgramOrd01);
                        oLiveEntities.GeneralPrograms.Add(oProgramOrd02);
                        oLiveEntities.GeneralPrograms.Add(oProgramOrd03);
                        oLiveEntities.GeneralPrograms.Add(oProgramOrd04);
                        oLiveEntities.GeneralPrograms.Add(oProgramShip01);
                        oLiveEntities.GeneralPrograms.Add(oProgramShip02);
                        oLiveEntities.GeneralPrograms.Add(oProgramShip03);
                        oLiveEntities.GeneralPrograms.Add(oProgramFin01);
                        oLiveEntities.GeneralPrograms.Add(oProgramFin02);
                        oLiveEntities.GeneralPrograms.Add(oProgramFin03);
                        oLiveEntities.GeneralPrograms.Add(oProgramMall01);
                        oLiveEntities.GeneralPrograms.Add(oProgramMall02);
                        oLiveEntities.GeneralPrograms.Add(oProgramMall03);
                        oLiveEntities.GeneralPrograms.Add(oProgramMall04);
                        oLiveEntities.GeneralPrograms.Add(oProgramKnow);
                        oLiveEntities.GeneralPrograms.Add(oProgramRpt0101);
                        oLiveEntities.GeneralPrograms.Add(oProgramRpt0201);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: GeneralProgram 程序定义");
                        #endregion

                        #region MemberPrivilege 权限(测试用)
                        //用户1程序权限
                        MemberPrivilege oMemberPrivilegeProgram = new MemberPrivilege
                        {
                            User = oTester,
                            Ptype = 0,// 0: 程序
                            PrivilegeItems = new List<MemberPrivItem>
                            {
                                new MemberPrivItem { RefID = oProgramHome.Gid },
                                new MemberPrivItem { RefID = oProgramSys01.Gid },
                                new MemberPrivItem { RefID = oProgramSys02.Gid }
                            }
                        };
                        oLiveEntities.MemberPrivileges.Add(oMemberPrivilegeProgram);
                        oLiveEntities.SaveChanges();

                        Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase.RunOnce: MemberPrivilege 权限(测试用)");
                        #endregion
                    }
                    // 提交事务,数据库物理写入
                    scope.Complete();
                }
            }
            catch (TransactionAbortedException ex)
            {
                Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase: TransactionAbortedException Message: {0}", ex.Message);
            }
            catch (ApplicationException ex)
            {
                Debug.WriteLine("LiveAzure.Models.General.InitialiseDatabase: ApplicationException Message: {0}", ex.Message);
            }

            GC.Collect();
        }
예제 #16
0
 /// <summary>
 /// 用户仓库授权
 /// </summary>
 /// <returns></returns>
 public ActionResult PrivWarehouse(MemberPrivilege memberPrivilege)
 {
     //选择Otype=2的仓库组织
     var memberWarehouses = from o in dbEntity.WarehouseInformations.Include("ShortName")
                               where (o.Deleted == false && o.Otype == 2)
                               select new
                               {
                                   Gid = o.Gid,
                                   ShortName = o.ShortName.Matter
                               };
     ViewBag.memOrg = new SelectList(memberWarehouses, "Gid", "ShortName");
     return View();
 }
예제 #17
0
        /// <summary>
        /// 导入用户权限
        /// </summary>
        /// <param name="sExcelFile">Excel文件名</param>
        /// <param name="sSheetName">Sheet名</param>
        public void ImportPrivileges(string sExcelFile, string sSheetName)
        {
            try
            {
                ExcelData oExcel = new ExcelData(sExcelFile, sSheetName);
                DataColumn colLoginName = oExcel.ExcelTable.Columns["登陆名"];
                DataColumn colPrivType = oExcel.ExcelTable.Columns["类型"];
                DataColumn colStatus = oExcel.ExcelTable.Columns["状态"];
                DataColumn colOrgan = oExcel.ExcelTable.Columns["组织"];
                DataColumn colRefCode = oExcel.ExcelTable.Columns["授权代码"];
                DataColumn colNodeCode = oExcel.ExcelTable.Columns["节点代码"];
                DataColumn colNodeValue = oExcel.ExcelTable.Columns["节点值"];
                DataColumn colRemark = oExcel.ExcelTable.Columns["备注"];

                string sLastUser = "";
                Guid gLastGuid = Guid.Empty;
                MemberUser oUser = null;
                foreach (DataRow row in oExcel.ExcelTable.Rows)
                {
                    string sLoginName = row[colLoginName].ToString();
                    byte nType;
                    Byte.TryParse(row[colPrivType].ToString(), out nType);
                    byte nStatus;
                    Byte.TryParse(row[colStatus].ToString(), out nStatus);
                    string sRefCode = row[colRefCode].ToString();
                    string sNodeCode = row[colNodeCode].ToString();
                    string sNodeValue = row[colNodeValue].ToString();
                    string sRemark = row[colRemark].ToString();

                    if (!String.IsNullOrEmpty(sLoginName))
                    {
                        oUser = (from u in dbEntity.MemberUsers
                                     where u.LoginName == sLoginName
                                     select u).FirstOrDefault();
                        sLastUser = sLoginName;
                    }
                    // 授权主表
                    var oPrivilege = (from p in dbEntity.MemberPrivileges
                                      where p.UserID == oUser.Gid && p.Ptype == nType
                                      select p).FirstOrDefault();
                    if (oPrivilege == null)
                    {
                        oPrivilege = new MemberPrivilege { User = oUser, Ptype = nType };
                        dbEntity.MemberPrivileges.Add(oPrivilege);
                    }
                    oPrivilege.Pstatus = nStatus;
                    dbEntity.SaveChanges();
                    // 授权项目表
                    Guid gRefID = Guid.Empty;
                    switch ((ModelEnum.UserPrivType)nType)
                    {
                        case ModelEnum.UserPrivType.PROGRAM:
                            var oProgram = (from p in dbEntity.GeneralPrograms
                                            where p.Code == sRefCode
                                            select p).FirstOrDefault();
                            gLastGuid = oProgram.Gid;
                            gRefID = oProgram.Gid;
                            break;
                        case ModelEnum.UserPrivType.PROGRAM_NODE:
                            var oProgNode = (from n in dbEntity.GeneralProgNodes
                                             where n.ProgID == gLastGuid && n.Code == sNodeCode
                                             select n).FirstOrDefault();
                            gRefID = oProgNode.Gid;
                            break;
                        case ModelEnum.UserPrivType.ORGANIZATION:
                            var oOrgan = (from o in dbEntity.MemberOrganizations
                                          where o.Code == sRefCode && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION
                                          select o).FirstOrDefault();
                            gLastGuid = oOrgan.Gid;
                            gRefID = oOrgan.Gid;
                            break;
                        case ModelEnum.UserPrivType.CHANNEL:
                            var oChannel = (from o in dbEntity.MemberChannels
                                            where o.Code == sRefCode && o.Otype == (byte)ModelEnum.OrganizationType.CHANNEL
                                            select o).FirstOrDefault();
                            gLastGuid = oChannel.Gid;
                            gRefID = oChannel.Gid;
                            break;
                        case ModelEnum.UserPrivType.WAREHOUSE:
                            var oWarehouse = (from o in dbEntity.WarehouseInformations
                                            where o.Code == sRefCode && o.Otype == (byte)ModelEnum.OrganizationType.WAREHOUSE
                                            select o).FirstOrDefault();
                            gLastGuid = oWarehouse.Gid;
                            gRefID = oWarehouse.Gid;
                            break;
                        case ModelEnum.UserPrivType.PRODUCT_CATEGORY:
                            var oCategory1 = (from c in dbEntity.GeneralPrivateCategorys
                                             where c.Organization.Code == sRefCode
                                                   && c.Code == sNodeCode
                                                   && c.Ctype == (byte)ModelEnum.PrivateCategoryType.PRODUCT
                                             select c).FirstOrDefault();
                            gLastGuid = oCategory1.Gid;
                            gRefID = oCategory1.Gid;
                            break;
                        case ModelEnum.UserPrivType.SUPPLIER_CATEGORY:
                            var oCategory2 = (from c in dbEntity.GeneralPrivateCategorys
                                             where c.Organization.Code == sRefCode
                                                   && c.Code == sNodeCode
                                                   && c.Ctype == (byte)ModelEnum.PrivateCategoryType.SUPPLIER
                                             select c).FirstOrDefault();
                            gLastGuid = oCategory2.Gid;
                            gRefID = oCategory2.Gid;
                            break;
                    }
                    MemberPrivItem oPrivItem;
                    if (nType == (byte)ModelEnum.UserPrivType.PROGRAM_NODE)
                    {
                        oPrivItem = (from i in dbEntity.MemberPrivItems
                                     where i.PrivID == oPrivilege.Gid && i.RefID == gRefID && i.NodeCode == sNodeCode
                                     select i).FirstOrDefault();
                        if (oPrivItem == null)
                        {
                            oPrivItem = new MemberPrivItem { Privilege = oPrivilege, RefID = gRefID, NodeCode = sNodeCode };
                            dbEntity.MemberPrivItems.Add(oPrivItem);
                        }
                        oPrivItem.NodeValue = sNodeValue;
                    }
                    else
                    {
                        oPrivItem = (from i in dbEntity.MemberPrivItems
                                     where i.PrivID == oPrivilege.Gid && i.RefID == gRefID
                                     select i).FirstOrDefault();
                        if (oPrivItem == null)
                        {
                            oPrivItem = new MemberPrivItem { Privilege = oPrivilege, RefID = gRefID };
                            dbEntity.MemberPrivItems.Add(oPrivItem);
                        }
                    }
                    oPrivItem.Remark = sRemark;
                    dbEntity.SaveChanges();
                    if (Utility.ConfigHelper.GlobalConst.IsDebug)
                        Debug.WriteLine("{0} {1} {2} {3} {4}", this.ToString(), sLoginName, sRefCode, sNodeCode, sRemark);
                }
                oEventBLL.WriteEvent(String.Format("导入MemberPrivilege成功: {0} {1}", sExcelFile, sSheetName),
                    ModelEnum.ActionLevel.GENERIC, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
            catch (Exception ex)
            {
                oEventBLL.WriteEvent(String.Format("导入MemberPrivilege错误: {0} {1} {2}", sExcelFile, sSheetName, ex.Message),
                    ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
        }
예제 #18
0
        /// <summary>
        /// 程序授权
        /// </summary>
        /// <returns></returns>
        public ActionResult PrivProgram(Guid? id=null)
        {
            if (!base.CheckPrivilege("EnableEdit"))//权限验证
                return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
            if (id == null)
            {
                int nstatus;
                MemberPrivilege oPri = (from o in dbEntity.MemberPrivileges where (o.UserID == gUserID && o.Deleted == false && o.Ptype == (byte)ModelEnum.UserPrivType.PROGRAM) select o).FirstOrDefault();
                if (oPri != null)
                {
                    nstatus = oPri.Pstatus;
                }
                else nstatus = -1;
                ViewBag.status = nstatus;
            }
            else//保存授权程序
            {
                Guid gPrivID = new Guid();
                Guid gid = (Guid)id;
                MemberPrivilege oMemberPrivilege = (from o in dbEntity.MemberPrivileges where (o.Ptype == 0 && o.UserID == gUserID) select o).FirstOrDefault();
                //已存在对程序授权的主记录
                if (oMemberPrivilege != null && oMemberPrivilege.Deleted == false)
                {
                    if (oMemberPrivilege.Pstatus == 0)
                    {
                        oMemberPrivilege.Pstatus = 1;
                        dbEntity.SaveChanges();
                    }
                    gPrivID = oMemberPrivilege.Gid;
                }
                if (oMemberPrivilege != null && oMemberPrivilege.Deleted == true)
                {
                    if (oMemberPrivilege.Pstatus == 0) oMemberPrivilege.Pstatus = 1;
                    oMemberPrivilege.Deleted = false;
                    dbEntity.SaveChanges();
                    gPrivID = oMemberPrivilege.Gid;
                }
                if (oMemberPrivilege == null)
                {
                    MemberPrivilege oMemPriv = new MemberPrivilege();
                    oMemPriv.Ptype = 0;
                    oMemPriv.UserID = gUserID;
                    oMemPriv.Pstatus = 1;
                    dbEntity.MemberPrivileges.Add(oMemPriv);
                    dbEntity.SaveChanges();
                    gPrivID = oMemPriv.Gid;
                }
                //是否存在对该程序的授权记录
                MemberPrivItem oMemberPrivItem = (from o in dbEntity.MemberPrivItems where (o.PrivID == gPrivID && o.RefID == gid) select o).FirstOrDefault();
                if (oMemberPrivItem != null && oMemberPrivItem.Deleted == true)
                {
                    oMemberPrivItem.Deleted = false;
                    dbEntity.SaveChanges();
                }
                if (oMemberPrivItem == null)
                {
                    MemberPrivItem oMemPrivItem = new MemberPrivItem();
                    oMemPrivItem.PrivID = gPrivID;
                    oMemPrivItem.RefID = gid;
                    dbEntity.MemberPrivItems.Add(oMemPrivItem);
                    dbEntity.SaveChanges();
                }

                //如果该程序Terminal=true,保存程序节点授权主记录
                GeneralProgram oGeneralProgram = (from o in dbEntity.GeneralPrograms where (o.Gid == gid && o.Deleted == false) select o).SingleOrDefault();
                if (oGeneralProgram != null)
                {
                    if (oGeneralProgram.Terminal == true)
                    {
                        MemberPrivilege oMemPrivilege = (from o in dbEntity.MemberPrivileges where (o.Ptype == 1 && o.UserID == gUserID) select o).FirstOrDefault();
                        if (oMemPrivilege == null)
                        {
                            MemberPrivilege oNodeMemberPrivilege = new MemberPrivilege();
                            oNodeMemberPrivilege.UserID = gUserID;
                            oNodeMemberPrivilege.Ptype = 1;
                            oNodeMemberPrivilege.Pstatus = 1;
                            dbEntity.MemberPrivileges.Add(oNodeMemberPrivilege);
                            dbEntity.SaveChanges();
                        }
                        if (oMemPrivilege != null && oMemPrivilege.Deleted == true)
                        {
                            if (oMemPrivilege.Pstatus == 0) oMemPrivilege.Pstatus = 1;
                            oMemPrivilege.Deleted = false;
                            dbEntity.SaveChanges();
                        }
                    }
                }
                return RedirectToAction("PrivProgram");
            }
            return View();
        }