Inheritance: GameManagerObject
Example #1
0
    // nared se death zone;
    // Use this for initialization
    void Start()
    {
        config = (CustomConfig) GameManager.Instance.gameManagerObject;

        PlayerConfig[] playersConfig = config.playersConfig;
        if (playersConfig == null) { // for debug purposes, so this scene can be started standalone
            playersConfig = debugPlayersConfig;
        }

        for (int i = 0; i < playersConfig.Length; i++) {
            if (playersConfig[i] != null) {
                Vector3 spawnPoint = players[i].transform.position + new Vector3(0, 10, 0); // avto je ze na svojmu startu
                Vector3 respawnPoint = customRespawnPoints ? respawnPositions[i] : spawnPoint;
                int lives = playersConfig[i].lives;
                int id = playersConfig[i].id;

                PlayerSelfManager pd = players[i].GetComponent<PlayerSelfManager>();
                pd.name = playersConfig[i].name;
                pd.id = id;
                pd.leftLives = lives;
                pd.spawnPoint = spawnPoint;
                pd.respawnPoint = respawnPoint;
                pd.isPlaying = true;
                pd.spawnFacing = players[i].transform.rotation;
                playerSelfManagers[i] = pd;
                EditorUtility.SetDirty(pd);
            } else {
                playersHUD[i].SetActive(false);
                players[i].SetActive(false);
                players[i].transform.position = inactivePosition;
            }

        }
    }
Example #2
0
        public void DropOneToOneRightTable() {
            var configTo = new CustomConfig();
            var configFrom = new CustomConfig();

            // remove onetooneleft from the config
            var mappedTypes =
                (IDictionary<Type, IMap>)
                typeof(ConfigurationBase).GetField("mappedTypes", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(configTo);
            mappedTypes.Remove(typeof(OneToOneRight));
            configTo.GetMap<OneToOneLeft>().Columns.Remove("Right");

            var dialect = new SqlServer2012Dialect();
            var migrator = new Migrator(
                dialect,
                new CreateTableWriter(dialect),
                new AlterTableWriter(dialect),
                new DropTableWriter(dialect),
                GetMockStatisticsProvider(configFrom));
            IEnumerable<string> warnings;
            IEnumerable<string> errors;
            var script = migrator.GenerateSqlDiff(
                configFrom.Maps,
                configTo.Maps,
                null,
                new Mock<ILogger>().Object,
                new string[0],
                out warnings,
                out errors);

            var dropColIdx = script.IndexOf("alter table [OneToOneLefts] drop column [RightId];", StringComparison.Ordinal);
            var dropTableIdx = script.IndexOf("drop table [OneToOneRights];", StringComparison.Ordinal);
            Assert.True(dropColIdx > -1);
            Assert.True(dropTableIdx > -1);
            Assert.True(dropColIdx < dropTableIdx);
        }
Example #3
0
 private static Delegate GenerateSingleMapper() {
     var config = new CustomConfig();
     var selectQuery = new SelectQuery<Post>(new Mock<ISelectQueryExecutor>().Object).Fetch(p => p.Blog) as SelectQuery<Post>;
     var writer = new SelectWriter(new SqlServer2012Dialect(), config);
     var result = writer.GenerateSql(selectQuery);
     var mapper = new NonCollectionMapperGenerator(config);
     var func = mapper.GenerateNonCollectionMapper<Post>(result.FetchTree);
     return func.Item1;
 }
Example #4
0
        private DatabaseSchema MakeSchema(CustomConfig config) {
            var result = new DatabaseSchema(string.Empty, SqlType.SqlServer);
            foreach (var map in config.Maps) {
                var table = new DatabaseTable();
                table.Name = map.Table;
                foreach (var column in map.Columns.Where(c => c.Value.Relationship == RelationshipType.ManyToOne)) {
                    table.Columns.Add(new DatabaseColumn { ForeignKeyTableName = config.GetMap(column.Value.Type).Table, Name = column.Value.DbName });
                }

                result.Tables.Add(table);
            }

            return result;
        }
Example #5
0
 public UserControl GetConfig(CustomConfig config)
 {
     return(null);
 }
Example #6
0
 public void ParentColumnAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("public Blog Blog { get; set; }", results["Post"]);
 }
Example #7
0
 public void NamespaceAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("namespace " + TestNamespace, results.First().Value);
 }
Example #8
0
 public SerialPortShutterReleaseConfig()
 {
     InitializeComponent();
     CustomConfig = new CustomConfig();
 }
        protected override void InitPageTemplate(HttpContext context)
        {
            //一些设置项
            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
            this.Document.SetValue("IsRegStudent", config["IsRegStudent"].Value.Boolean ?? true);   //是否允许注册

            #region 此段代码用于取token与openid
            string code = WeiSha.Common.Request.QueryString["code"].String;
            if (Request.ServerVariables["REQUEST_METHOD"] == "GET" && !string.IsNullOrWhiteSpace(code))
            {
                string orgid        = WeiSha.Common.Request.QueryString["state"].String; //状码码是机构id
                string openid       = string.Empty;
                string access_token = getToken(out openid);
                //微信登录的回调域,(用途:如果回调域不是根域,则不再取当前机构二级域名)
                string returl = Business.Do <ISystemPara>()["WeixinpubReturl"].Value ?? WeiSha.Common.Server.MainName;
                if (!string.IsNullOrWhiteSpace(returl))
                {
                    if (returl.StartsWith("http://"))
                    {
                        returl = returl.Substring(7);
                    }
                    if (returl.StartsWith("https://"))
                    {
                        returl = returl.Substring(8);
                    }
                }
                //如果回调域与根域相同,则转到当前机构的二级域名
                if (returl.Equals(WeiSha.Common.Server.MainName, StringComparison.CurrentCultureIgnoreCase))
                {
                    Song.Entities.Organization org = getOrgan(-1);
                    returl = org.Org_TwoDomain + "." + WeiSha.Common.Server.MainName;
                }
                string uri = "{0}/mobile/{1}?token={2}&openid={3}&orgid={4}";
                uri = string.Format(uri, returl, WeiSha.Common.Request.Page.FileName, access_token, openid, orgid);
                this.Document.Variables.SetValue("gourl", uri); //传到客户端,进行跳转
                return;
            }
            #endregion

            #region 具体操作代码
            string token = WeiSha.Common.Request.QueryString["token"].String;
            if (Request.ServerVariables["REQUEST_METHOD"] == "GET" && !string.IsNullOrWhiteSpace(token))
            {
                _StateForGET();
            }
            #endregion

            //此页面的ajax提交,全部采用了POST方式
            if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                string action = WeiSha.Common.Request.Form["action"].String;
                switch (action)
                {
                case "Direct": _directLogin();       //直接登录
                    break;

                case "getRegSms": sendSmsVcode();      //验证手机注册时,获取短信时的验证码
                    break;

                case "register1": register1();     //直接注册,无需验证手机号
                    break;

                case "register2": register2();     //用手机注册,需短信验证手机号
                    break;

                case "bind1": bind1();      //绑定已经存在账户,不验证手机
                    break;

                case "bind2": bind2();      //绑定已经存在账户,验证手机号
                    break;

                default:
                    //acclogin_verify();  //验证账号登录时的密码
                    break;
                }
                Response.End();
            }
        }
 public bool Focus(CustomConfig config)
 {
     throw new NotImplementedException();
 }
 // Use this for initialization
 void Start()
 {
     config = (CustomConfig) GameManager.Instance.gameManagerObject;
     winnerNameDisplayField.text = config.playersConfig [config.winnerId].name;
 }
Example #12
0
 /// <summary>
 /// 构造函数中调用,读取客户自定义配置内容
 /// </summary>
 private void ReadCustomConfig()
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream stream = new FileStream(CustomCfgBinaryFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
         _customCfg = (CustomConfig)formatter.Deserialize(stream);
         stream.Close();
     }
     catch (Exception ex)
     {
         //log
     }
     if (null == _customCfg)
     {
         _customCfg = new CustomConfig();
     }
 }
Example #13
0
        private static Delegate GenerateSingleAwkwardMapper() {
            var config = new CustomConfig();
            var selectQuery =
                new SelectQuery<PostWithoutCollectionInitializerInConstructor>(new Mock<ISelectQueryExecutor>().Object).Fetch(p => p.Comments) as
                SelectQuery<PostWithoutCollectionInitializerInConstructor>;
            var writer = new SelectWriter(new SqlServer2012Dialect(), config);
            var result = writer.GenerateSql(selectQuery);

            var mapper = new SingleCollectionMapperGenerator(config);
            var func = mapper.GenerateCollectionMapper<PostWithoutCollectionInitializerInConstructor>(result.FetchTree);
            return func.Item1;
        }
Example #14
0
        public void NestedMultipleOneToManyFetchingWorksTrackingEnabledLast() {
            // setup the factory
            var config = new CustomConfig();
            var selectQuery =
                new SelectQuery<Blog>(new Mock<ISelectQueryExecutor>().Object).FetchMany(b => b.Posts)
                                                                              .ThenFetchMany(p => p.Tags)
                                                                              .ThenFetch(t => t.ElTag)
                                                                              .FetchMany(b => b.Posts)
                                                                              .ThenFetchMany(p => p.DeletedTags)
                                                                              .ThenFetch(t => t.ElTag)
                                                                              .FetchMany(p => p.Posts)
                                                                              .ThenFetch(p => p.Author) as SelectQuery<Blog>;
            var writer = new SelectWriter(new SqlServer2012Dialect(), config);
            var result = writer.GenerateSql(selectQuery);
            var mapper = new MultiCollectionMapperGenerator(config);
            var funcFac = mapper.GenerateMultiCollectionMapper<Blog>(result.FetchTree).Item1;

            // setup the scenario
            var blog1 = new Blog { BlogId = 1 };
            var blog2 = new Blog { BlogId = 2 };
            var post1 = new Post { PostId = 1 };
            var post2 = new Post { PostId = 2 };
            var post3 = new Post { PostId = 3 };
            var posttag1 = new PostTag { PostTagId = 1 };
            var posttag2 = new PostTag { PostTagId = 2 };
            var posttag3 = new PostTag { PostTagId = 3 };
            var tag1 = new Tag { TagId = 1 };
            var tag2 = new Tag { TagId = 2 };
            var tag3 = new Tag { TagId = 3 };
            var tag4 = new Tag { TagId = 4 };
            var delPostTag1 = new PostTag { PostTagId = 3 };
            var delPostTag2 = new PostTag { PostTagId = 4 };
            var delPostTag3 = new PostTag { PostTagId = 5 };
            var author1 = new User { UserId = 1 };
            var author2 = new User { UserId = 2 };

            // act
            Blog currentRoot = null;
            IList<Blog> results = new List<Blog>();
            var dict0 = new Dictionary<int, Post>();
            var hashsetPair0 = new HashSet<Tuple<int, int>>();
            var dict1 = new Dictionary<int, PostTag>();
            var hashsetPair1 = new HashSet<Tuple<int, int>>();
            var dict2 = new Dictionary<int, PostTag>();
            var hashsetPair2 = new HashSet<Tuple<int, int>>();

            var func =
                (Func<object[], Blog>)funcFac.DynamicInvoke(currentRoot, results, dict0, hashsetPair0, dict1, hashsetPair1, dict2, hashsetPair2);
            func(new object[] { blog1, post1, author1, null, null, posttag1, tag1 });
            func(new object[] { blog1, post1, author1, null, null, posttag2, tag2 });
            func(new object[] { blog1, post2, author2, delPostTag1, tag3, null, null });
            func(new object[] { blog1, post2, author2, delPostTag2, tag4, null, null });
            func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag1, tag1 });
            func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag1, tag1 });
            func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag1, tag1 });
            func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag2, tag2 });
            func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag2, tag2 });
            func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag2, tag2 });
            func(new object[] { blog2, post3, author1, delPostTag1, tag3, posttag3, tag3 });
            func(new object[] { blog2, post3, author1, delPostTag2, tag4, posttag3, tag3 });
            func(new object[] { blog2, post3, author1, delPostTag3, tag4, posttag3, tag3 });

            Assert.False(((ITrackedEntity)results[0]).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Posts[0]).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Posts[0].Author).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Posts[0].Tags[0]).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Posts[0].Tags[0].ElTag).GetDirtyProperties().Any());
        }
Example #15
0
        public void MultipleManyToManyFetchingWorks() {
            // setup the factory
            var config = new CustomConfig();
            var selectQuery =
                new SelectQuery<Post>(new Mock<ISelectQueryExecutor>().Object).FetchMany(p => p.Tags)
                                                                              .ThenFetch(p => p.ElTag)
                                                                              .FetchMany(p => p.DeletedTags)
                                                                              .ThenFetch(t => t.ElTag) as SelectQuery<Post>;
            var writer = new SelectWriter(new SqlServer2012Dialect(), config);
            var result = writer.GenerateSql(selectQuery);
            var mapper = new MultiCollectionMapperGenerator(config);
            var funcFac = mapper.GenerateMultiCollectionMapper<Post>(result.FetchTree).Item1;

            // setup the scenario
            var post1 = new Post { PostId = 1 };
            var tag1 = new Tag { TagId = 1 };
            var tag2 = new Tag { TagId = 2 };
            var tag3 = new Tag { TagId = 3 };
            var postTag1 = new PostTag { PostTagId = 1 };
            var postTag2 = new PostTag { PostTagId = 2 };
            var postTag3 = new PostTag { PostTagId = 3 };

            // act
            Post currentRoot = null;
            IList<Post> results = new List<Post>();
            var dict0 = new Dictionary<int, PostTag>();
            var hashsetPair0 = new HashSet<Tuple<int, int>>();
            var dict1 = new Dictionary<int, PostTag>();
            var hashsetPair1 = new HashSet<Tuple<int, int>>();

            var func = (Func<object[], Post>)funcFac.DynamicInvoke(currentRoot, results, dict0, hashsetPair0, dict1, hashsetPair1);
            func(new object[] { post1, postTag2, tag2, postTag1, tag1 });
            func(new object[] { post1, postTag3, tag3, postTag1, tag1 });

            Assert.Equal(1, results.Count);
            Assert.Equal(1, results[0].Tags.Count);
            Assert.Equal(1, results[0].Tags[0].PostTagId);
            Assert.Equal(2, results[0].DeletedTags.Count);
            Assert.Equal(2, results[0].DeletedTags[0].PostTagId);
            Assert.Equal(3, results[0].DeletedTags[1].PostTagId);
        }
 public UserControl GetConfig(CustomConfig config)
 {
     return(new SerialPortShutterReleaseConfig(config));
 }
Example #17
0
 public CustomConfig GetCustomConfig()
 {
     return(CustomConfig.GetInstance());
 }
 public HomeController(IOptions <CustomConfig> options)
 {
     _options = options.Value;
 }
Example #19
0
        /// <summary>
        /// 是否是手机端
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        protected bool isMobilePage(out string path)
        {
            bool   ismobi = false;
            string prefix = "/mobile";

            path = this.Request.Url.AbsolutePath;
            if (path.Length >= prefix.Length)
            {
                string pre = path.Substring(0, prefix.Length);
                if (pre.ToLower() == prefix.ToLower())
                {
                    ismobi = true;
                }
            }
            //如果是手机端页面,则去除/mobile/路径
            if (ismobi)
            {
                path = path.Substring(prefix.Length);
            }
            if (path.IndexOf(".") > -1)
            {
                path = path.Substring(path.IndexOf("/") + 1, path.LastIndexOf(".") - 1);
            }
            else
            {
                path = path.Substring(path.IndexOf("/") + 1);
            }
            path = path.Replace("/", "\\");
            //自定义配置项
            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
            bool isNoaccess = false;    //是否禁止访问

            //如果是手机端
            if (ismobi)
            {
                //如果禁止微信中使用,且又处于微信中时
                if ((config["DisenableWeixin"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixin)
                {
                    isNoaccess = true;
                }
                if ((config["DisenableMini"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixinApp)
                {
                    isNoaccess = true;
                }
                if ((config["DisenableMweb"].Value.Boolean ?? false) && (!WeiSha.Common.Browser.IsAPICloud && !WeiSha.Common.Browser.IsWeixin))
                {
                    isNoaccess = true;
                }
                if ((config["DisenableAPP"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsAPICloud)
                {
                    isNoaccess = true;
                }
            }
            else
            {
                if ((config["WebForDeskapp"].Value.Boolean ?? false) && !WeiSha.Common.Browser.IsDestopApp)
                {
                    isNoaccess = true;
                }
            }
            //如果被限制访问
            if (isNoaccess)
            {
                path = "Noaccess";
            }
            return(ismobi);
        }
 public ArduinoShutterReleaseConfig()
 {
     CustomConfig = new CustomConfig();
     InitializeComponent();
 }
        protected override void InitPageTemplate(HttpContext context)
        {
            //if (!Extend.LoginState.Accounts.IsLogin || this.Account==null)
            //    context.Response.Redirect(WeiSha.Common.Login.Get["Accounts"].NoLoginPath.String);
            //自定义配置项
            Song.Entities.Organization org    = Business.Do <IOrganization>().OrganCurrent();
            WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
            //
            //取当前章节
            ol = id < 1 ? Business.Do <IOutline>().OutlineFirst(couid, true)
                       : ol = Business.Do <IOutline>().OutlineSingle(id);
            //当前课程
            Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(ol == null ? couid : ol.Cou_ID);
            if (course == null)
            {
                return;
            }
            #region 创建与学员的关联
            if (this.Account != null)
            {
                int  accid  = this.Account.Ac_ID;
                bool istudy = Business.Do <ICourse>().Study(course.Cou_ID, accid);
            }
            #endregion

            #region 章节输出

            //是否免费,或是限时免费
            if (course.Cou_IsLimitFree)
            {
                DateTime freeEnd = course.Cou_FreeEnd.AddDays(1).Date;
                if (!(course.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now))
                {
                    course.Cou_IsLimitFree = false;
                }
            }
            this.Document.Variables.SetValue("course", course);
            Extend.LoginState.Accounts.Course(course);
            if (ol == null)
            {
                return;
            }
            //
            couid = ol.Cou_ID;
            id    = ol.Ol_ID;
            //入写章节id的cookie,当播放视频时会判断此处
            Response.Cookies.Add(new HttpCookie("olid", id.ToString()));
            outlines = Business.Do <IOutline>().OutlineAll(ol.Cou_ID, true);
            //是否学习当前课程
            if (course == null || this.Account == null)
            {
                isStudy = false;
            }
            else
            {
                isStudy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, course.Cou_ID);
            }
            this.Document.Variables.SetValue("isStudy", isStudy);
            //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
            bool canStudy = isStudy || course.Cou_IsFree || course.Cou_IsLimitFree ? true : (course.Cou_IsTry && ol.Ol_IsFree);
            canStudy = canStudy && ol.Ol_IsUse && ol.Ol_IsFinish && this.Account != null;
            this.Document.Variables.SetValue("canStudy", canStudy);
            //课程章节列表
            this.Document.Variables.SetValue("outlines", outlines);
            //树形章节输出
            if (outlines.Length > 0)
            {
                this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outlines));
            }
            this.Document.Variables.SetValue("outline", ol);
            #endregion
            //视频
            List <Song.Entities.Accessory> videos = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "CourseVideo");
            if (videos.Count > 0)
            {
                if (videos[0].As_IsOuter)
                {
                    //如果是外部链接
                    this.Document.Variables.SetValue("video", videos[0]);
                }
                else
                {
                    //如果是内部链接
                    videos[0].As_FileName = Upload.Get[videos[0].As_Type].Virtual + videos[0].As_FileName;
                    try
                    {
                        string fileHy = Server.MapPath(videos[0].As_FileName);
                        if (!System.IO.File.Exists(fileHy))
                        {
                            string ext = System.IO.Path.GetExtension(fileHy).ToLower();
                            if (ext == ".mp4")
                            {
                                videos[0].As_FileName = Path.ChangeExtension(videos[0].As_FileName, ".flv");
                            }
                            if (ext == ".flv")
                            {
                                videos[0].As_FileName = Path.ChangeExtension(videos[0].As_FileName, ".mp4");
                            }
                        }
                        this.Document.Variables.SetValue("video", videos[0]);
                        if (Extend.LoginState.Accounts.IsLogin)
                        {
                            Song.Entities.LogForStudentStudy studyLog = Business.Do <IStudent>().LogForStudySingle(this.Account.Ac_ID, ol.Ol_ID);
                            if (studyLog != null)
                            {
                                this.Document.Variables.SetValue("studyLog", studyLog);
                                double historyPlay = (double)studyLog.Lss_PlayTime / 1000;
                                this.Document.Variables.SetValue("historyPlay", historyPlay);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                this.Document.Variables.SetValue("IsVideoNoload", config["IsVideoNoload"].Value.Boolean ?? false);
                state = state < 1 ? 1 : state;
            }
            //内容
            if (!string.IsNullOrWhiteSpace(ol.Ol_Intro))
            {
                state = state < 1 ? 2 : state;
            }
            //上级章节
            if (ol != null)
            {
                Song.Entities.Outline pat = Business.Do <IOutline>().OutlineSingle(ol.Ol_PID);
                this.Document.Variables.SetValue("pat", pat);
            }
            //附件
            List <Song.Entities.Accessory> access = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "Course");
            if (access.Count > 0)
            {
                foreach (Accessory ac in access)
                {
                    ac.As_FileName = Upload.Get["Course"].Virtual + ac.As_FileName;
                }
                this.Document.Variables.SetValue("access", access);
                state = state < 1 ? 3 : state;
            }
            //当前章节是否有试题
            if (canStudy)
            {
                bool isQues = Business.Do <IOutline>().OutlineIsQues(ol.Ol_ID, true);
                this.Document.Variables.SetValue("isQues", isQues);
                if (isQues)
                {
                    state = state < 1 ? 4 : state;
                }
            }
            else
            {
                state = 0;
            }

            //章节事件
            OutlineEvent[] events = Business.Do <IOutline>().EventAll(-1, ol.Ol_ID, -1, true);
            this.Document.Variables.SetValue("events", events);
            this.Document.RegisterGlobalFunction(this.getEventQues);
            this.Document.RegisterGlobalFunction(this.getEventFeedback);
            this.Document.RegisterGlobalFunction(this.GetOrder);
            //状态
            this.Document.Variables.SetValue("state", state);
            this.Document.Variables.SetValue("olid", id);
        }
Example #22
0
        public void DropSelfReferencedWorks() {
            var configTo = new CustomConfig();
            var configFrom = new CustomConfig();

            // remove onetooneleft from the config
            var mappedTypes =
                (IDictionary<Type, IMap>)
                typeof(ConfigurationBase).GetField("mappedTypes", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(configTo);
            mappedTypes.Remove(typeof(Pair));

            var dialect = new SqlServer2012Dialect();
            var migrator = new Migrator(
                dialect,
                new CreateTableWriter(dialect),
                new AlterTableWriter(dialect),
                new DropTableWriter(dialect),
                GetMockStatisticsProvider(configFrom));
            IEnumerable<string> warnings;
            IEnumerable<string> errors;
            var script = migrator.GenerateSqlDiff(
                configFrom.Maps,
                configTo.Maps,
                null,
                new Mock<ILogger>().Object,
                new string[0],
                new string[0],
                out warnings,
                out errors);

            Assert.Equal(@"drop table [Pairs];", script.Trim());
        }
Example #23
0
        public void FetchManyNonRootTrackingEnabledLast() {
            var config = new CustomConfig();
            var selectQuery =
                new SelectQuery<PostTag>(new Mock<ISelectQueryExecutor>().Object).FetchMany(p => p.Post.Comments).ThenFetch(c => c.User) as
                SelectQuery<PostTag>;
            var writer = new SelectWriter(new SqlServer2012Dialect(), config);
            var result = writer.GenerateSql(selectQuery);
            var mapper = new SingleCollectionMapperGenerator(config);
            var funcFac = mapper.GenerateCollectionMapper<PostTag>(result.FetchTree).Item1;

            // setup the scenario
            var tag1 = new PostTag { PostTagId = 1 };
            var tag2 = new PostTag { PostTagId = 2 };
            var tag3 = new PostTag { PostTagId = 3 };
            var post1 = new Post { PostId = 1, Title = "Foo" };
            var anotherPost1 = new Post { PostId = 1, Title = "Foo" };
            var post2 = new Post { PostId = 2, Title = "Foo" };
            var post3 = new Post { PostId = 3, Title = "Foo" };
            var post4 = new Post { PostId = 4, Title = "Foo" };
            var comment1 = new Comment { CommentId = 1 };
            var comment2 = new Comment { CommentId = 2 };
            var comment3 = new Comment { CommentId = 3 };
            var comment4 = new Comment { CommentId = 4 };
            var comment5 = new Comment { CommentId = 5 };
            var comment6 = new Comment { CommentId = 6 };
            var user1 = new User { UserId = 1 };
            var user2 = new User { UserId = 2 };
            var user3 = new User { UserId = 3 };
            var user4 = new User { UserId = 4 };
            var user5 = new User { UserId = 5 };

            PostTag currentRoot = null;
            IList<PostTag> results = new List<PostTag>();
            var func = (Func<object[], PostTag>)funcFac.DynamicInvoke(currentRoot, results);
            func(new object[] { tag1, post1, comment1, user1 });
            func(new object[] { tag1, post1, comment2, user1 });
            func(new object[] { tag1, post1, comment3, user2 });
            func(new object[] { tag2, anotherPost1, comment1, user1 });
            func(new object[] { tag2, anotherPost1, comment2, user1 });
            func(new object[] { tag2, anotherPost1, comment3, user2 });
            func(new object[] { tag3, post2, comment4, user3 });
            func(new object[] { tag3, post2, comment5, user4 });
            func(new object[] { tag3, post2, comment6, user5 });

            Assert.False(((ITrackedEntity)results[0]).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Post).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Post.Comments[0]).GetDirtyProperties().Any());
            Assert.False(((ITrackedEntity)results[0].Post.Comments[0].User).GetDirtyProperties().Any());
        }
 public DCCUSBShutterReleaseConfig()
 {
     InitializeComponent();
     CustomConfig = new CustomConfig();
 }
Example #25
0
 public void PrimaryKeyAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("public System.Int32 PostId { get; set; }", results["Post"]);
 }
 // Use this for initialization
 void Start()
 {
     config = (CustomConfig)GameManager.Instance.gameManagerObject;
     winnerNameDisplayField.text = config.playersConfig [config.winnerId].name;
 }
Example #27
0
 public void CollectionColumnInitStatementAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("this.Comments = new List<Comment>();", results["Post"]);
 }
        protected override void InitPageTemplate(HttpContext context)
        {
            #region 具体操作代码
            string access_token = WeiSha.Common.Request.QueryString["token"].String;
            string openid       = WeiSha.Common.Request.QueryString["openid"].String;
            if (Request.ServerVariables["REQUEST_METHOD"] == "GET" && !string.IsNullOrWhiteSpace(access_token))
            {
                this.Document.Variables.SetValue("token", access_token);
                this.Document.Variables.SetValue("openid", openid);
                //设置主域,用于js跨根域
                if (!WeiSha.Common.Server.IsLocalIP)
                {
                    this.Document.Variables.SetValue("domain", WeiSha.Common.Request.Domain.MainName);
                }
                //QQ回调域
                string qqreturl = Business.Do <ISystemPara>()["QQReturl"].Value;
                if (string.IsNullOrWhiteSpace(qqreturl))
                {
                    qqreturl = WeiSha.Common.Request.Domain.MainName;
                }
                this.Document.SetValue("QQReturl", qqreturl + "/qqlogin.ashx");
                //当前机构
                Song.Entities.Organization org = getOrgan();
                this.Document.SetValue("domain2", getOrganDomain(org));
                //获取帐户,如果已经注册,则直接实现登录
                Song.Entities.Accounts acc = _ExistAcc(openid);
                if (acc == null)
                {
                    //账户不存在,以下用于注册
                    WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
                    this.Document.SetValue("forpw", config["IsLoginForPw"].Value.Boolean ?? true);                   //启用账号密码登录
                    this.Document.SetValue("forsms", config["IsLoginForSms"].Value.Boolean ?? true);                 //启用手机短信验证登录
                    this.Document.SetValue("IsQQDirect", Business.Do <ISystemPara>()["QQDirectIs"].Boolean ?? true); //是否允许qq直接注册登录
                    //获取qq登录账户的信息
                    acc = getUserInfo(access_token, openid);
                    this.Document.Variables.SetValue("name", acc.Ac_Name);    //QQ昵称
                    this.Document.Variables.SetValue("photo2", acc.Ac_Photo); //100*100头像
                    this.Document.Variables.SetValue("gender", acc.Ac_Sex);   //性别
                }
            }
            #endregion

            #region ajax请求
            //此页面的ajax提交,全部采用了POST方式
            if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                string action = WeiSha.Common.Request.Form["action"].String;
                switch (action)
                {
                case "Direct": _DirectLogin();       //直接登录
                    break;

                case "getRegSms": sendSmsVcode();      //验证手机注册时,获取短信时的验证码
                    break;

                case "register1": register1();     //直接注册,无需验证手机号
                    break;

                case "register2": register2();     //用手机注册,需短信验证手机号
                    break;

                case "bind1": bind1();      //绑定已经存在账户,不验证手机
                    break;

                case "bind2": bind2();      //绑定已经存在账户,验证手机号
                    break;

                default:
                    //acclogin_verify();  //验证账号登录时的密码
                    break;
                }
                Response.End();
            }
            #endregion
        }
Example #29
0
 public bool Focus(CustomConfig config)
 {
     return(true);
 }
Example #30
0
 public bool OpenShutter(CustomConfig config)
 {
     Capture(config);
     return(true);
 }
 public bool CanExecute(CustomConfig config)
 {
     return(true);
 }
Example #32
0
 public bool CloseShutter(CustomConfig config)
 {
     return(true);
 }
Example #33
0
        /// <summary>
        /// 手机注册的验证
        /// </summary>
        private void mobiregister_verify()
        {
            string vname    = WeiSha.Common.Request.Form["vname"].String;
            string imgCode  = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码
            string userCode = WeiSha.Common.Request.Form["vcode"].MD5;        //取输入的验证码
            string phone    = WeiSha.Common.Request.Form["phone"].String;     //输入的手机号
            string sms      = WeiSha.Common.Request.Form["sms"].MD5;          //输入的短信验证码
            string pw       = WeiSha.Common.Request.Form["pw"].MD5;           //密码
            string name     = WeiSha.Common.Request.Form["name"].String;      //姓名
            string email    = WeiSha.Common.Request.Form["email"].String;     //邮箱
            string rec      = WeiSha.Common.Request.Form["rec"].String;       //推荐人的电话
            int    recid    = WeiSha.Common.Request.Form["recid"].Int32 ?? 0; //推荐人的账户id

            //验证图片验证码
            if (imgCode != userCode)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"1\"}");   //图片验证码不正确
                return;
            }
            //验证手机号是否存在
            Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, phone, 1);
            if (acc != null)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"2\"}");   //手机号已经存在
                return;
            }
            //验证短信验证码
            bool isSmsCode = true;      //是否短信验证;

            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
            isSmsCode = config["IsRegSms"].Value.Boolean ?? true;
            string smsCode = WeiSha.Common.Request.Cookies["reg_mobi_" + vname].ParaValue;

            if (isSmsCode && sms != smsCode)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"3\"}");  //短信验证失败
                return;
            }
            else
            {
                //创建新账户
                Song.Entities.Accounts tmp = new Entities.Accounts();
                tmp.Ac_AccName  = phone;
                tmp.Ac_Pw       = pw;
                tmp.Ac_Name     = name;
                tmp.Ac_MobiTel1 = phone;
                tmp.Ac_Email    = email;
                //获取推荐人
                Song.Entities.Accounts accRec = null;
                if (!string.IsNullOrWhiteSpace(rec))
                {
                    accRec = Business.Do <IAccounts>().AccountsSingle(rec, true, true);
                }
                if (accRec == null && recid > 0)
                {
                    accRec = Business.Do <IAccounts>().AccountsSingle(recid);
                }
                if (accRec != null && accRec.Ac_ID != tmp.Ac_ID)
                {
                    tmp.Ac_PID = accRec.Ac_ID;                           //设置推荐人,即:当前注册账号为推荐人的下线
                    Business.Do <IAccounts>().PointAdd4Register(accRec); //增加推荐人积分
                }
                //如果需要审核通过
                tmp.Ac_IsPass = !(bool)(config["IsVerifyStudent"].Value.Boolean ?? true);
                tmp.Ac_IsUse  = tmp.Ac_IsPass;
                int id = Business.Do <IAccounts>().AccountsAdd(tmp);
                //以下为判断是否审核通过
                if (tmp.Ac_IsPass)
                {
                    LoginState.Accounts.Write(tmp);
                    Response.Write("{\"success\":\"1\",\"name\":\"" + tmp.Ac_Name + "\",\"state\":\"1\"}");
                }
                else
                {
                    //注册成功,但待审核
                    Response.Write("{\"success\":\"1\",\"name\":\"" + tmp.Ac_Name + "\",\"state\":\"0\"}");
                }
            }
        }
Example #34
0
 public bool DeassertFocus(CustomConfig config)
 {
     return(true);
 }
Example #35
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //如果没有登录则跳转
            if (this.Account == null)
            {
                if (WeiSha.Common.Browser.IsMobile)
                {
                    context.Response.Redirect("/Mobile/Login.ashx");
                }
                else
                {
                    context.Response.Redirect("/student/index.ashx");
                }
                return;
            }
            //当前章节
            Song.Entities.Outline ol = null;
            ol = id < 1 ? Business.Do <IOutline>().OutlineFirst(couid, true)
                       : ol = Business.Do <IOutline>().OutlineSingle(id);
            this.Document.Variables.SetValue("outline", ol);
            if (ol == null)
            {
                return;
            }
            //入写章节id的cookie,当播放视频时会判断此处
            Response.Cookies.Add(new HttpCookie("olid", ol.Ol_ID.ToString()));
            //自定义配置项
            Song.Entities.Organization org    = Business.Do <IOrganization>().OrganCurrent();
            WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
            //视频
            List <Song.Entities.Accessory> videos = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "CourseVideo");

            if (videos.Count > 0)
            {
                if (videos[0].As_IsOuter)
                {
                    //如果是外部链接
                    this.Document.Variables.SetValue("video", videos[0]);
                }
                else
                {
                    //如果是内部链接
                    videos[0].As_FileName = Upload.Get[videos[0].As_Type].Virtual + videos[0].As_FileName;
                    this.Document.Variables.SetValue("video", videos[0]);
                }
                this.Document.Variables.SetValue("vpath", Upload.Get["CourseVideo"].Virtual);
                this.Document.Variables.SetValue("IsVideoNoload", config["IsVideoNoload"].Value.Boolean ?? false);
            }
            //附件
            List <Song.Entities.Accessory> access = Business.Do <IAccessory>().GetAll(ol.Ol_UID, "Course");

            if (access.Count > 0)
            {
                foreach (Accessory ac in access)
                {
                    ac.As_FileName = Upload.Get["Course"].Virtual + ac.As_FileName;
                }
                this.Document.Variables.SetValue("access", access);
            }
            //章节事件
            OutlineEvent[] events = Business.Do <IOutline>().EventAll(-1, ol.Ol_ID, -1, true);
            this.Document.Variables.SetValue("events", events);
            this.Document.RegisterGlobalFunction(this.getEventQues);
            this.Document.RegisterGlobalFunction(this.getEventFeedback);
            this.Document.RegisterGlobalFunction(this.GetOrder);
        }
Example #36
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     CustomConfig.GetSystemParameters();
     LogInterface.Listen(CustomConfig.LogDirectoryName.ToString());
     Console.Write(sizeof(int));
 }
 public bool CanExecute(CustomConfig config)
 {
     throw new NotImplementedException();
 }
 public static void CheckRequiredFieldsNotNull(this CustomConfig config)
 {
Example #39
0
        public new void ProcessRequest(HttpContext context)
        {
            string gourl = WeiSha.Common.Skip.GetUrl();   //跳转

            if (!string.IsNullOrWhiteSpace(gourl))
            {
                context.Response.Redirect(gourl);
                return;
            }
            ////计算树形的运算时间
            //DateTime beforDT = System.DateTime.Now;

            this.InitContext(context);  //初始化页面参数
            //输出数据
            this.LoadCurrentTemplate(); //装载当前页面的模板文档
            try
            {
                //一些公共对象
                this.Document.SetValue("org", this.Organ);
                this.Document.SetValue("orgpath", Upload.Get["Org"].Virtual);
                //学生、教师、管理员是否登录
                if (Extend.LoginState.Accounts.IsLogin)
                {
                    this.Document.SetValue("Account", this.Account);
                    this.Document.SetValue("stuid", Extend.LoginState.Accounts.UID);
                }
                if (Extend.LoginState.Accounts.IsLogin)
                {
                    this.Document.SetValue("Teacher", this.Teacher);
                }
                if (Extend.LoginState.Admin.IsLogin)
                {
                    this.Document.SetValue("Admin", this.Admin);
                }
                //各种路径
                this.Document.SetValue("stpath", Upload.Get["Accounts"].Virtual);
                this.Document.SetValue("thpath", Upload.Get["Teacher"].Virtual);
                this.Document.SetValue("adminpath", Upload.Get["Employee"].Virtual);
                //当前模板的路径
                this.Document.SetValue("TempPath", this.TmBank.Path.Virtual);
                //自定义配置项
                WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
                //手机端隐藏关于“充值收费”等资费相关信息
                bool IsMobileRemoveMoney = config["IsMobileRemoveMoney"].Value.Boolean ?? false;
                this.Document.SetValue("mremove", IsMobileRemoveMoney);
                //电脑端隐藏资费
                bool IsWebRemoveMoney = config["IsWebRemoveMoney"].Value.Boolean ?? false;
                this.Document.SetValue("wremove", IsWebRemoveMoney);
            }
            catch { }
            //时间
            string WeekStr = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));

            this.Document.SetValue("week", WeekStr);
            this.Document.SetValue("tick", DateTime.Now.Ticks);
            //系统版本号
            this.Document.SetValue("version", version);
            //导航菜单
            this.Document.RegisterGlobalFunction(this.Navi);
            this.Document.RegisterGlobalFunction(this.NaviDrop);
            //版权信息
            this.Document.SetValue("copyright", WeiSha.Common.Request.Copyright);
            //用本地模板引擎处理标签
            Song.Template.Handler.Start(this.Document);
            //
            //开始输出
            this.InitPageTemplate(context);
            this.Document.Render(this.Response.Output);

            //DateTime afterDT = System.DateTime.Now;
            //TimeSpan ts = afterDT.Subtract(beforDT);
            //if (ts.TotalMilliseconds >= 100)
            //{
            //    WeiSha.Common.Log.Debug(this.GetType().FullName, string.Format("页面输出,耗时:{0}ms", ts.TotalMilliseconds));
            //}
        }
        /// <summary>
        /// get请求时
        /// </summary>
        protected void _StateForGET()
        {
            string token  = WeiSha.Common.Request.QueryString["token"].String;
            string openid = WeiSha.Common.Request.QueryString["openid"].String;

            this.Document.Variables.SetValue("openid", openid);
            this.Document.Variables.SetValue("token", token);
            //设置主域,用于js跨根域
            if (!WeiSha.Common.Server.IsLocalIP)
            {
                this.Document.Variables.SetValue("domain", WeiSha.Common.Request.Domain.MainName);
            }
            //当前机构
            Song.Entities.Organization org = getOrgan();
            this.Document.Variables.SetValue("org", org);
            if (!WeiSha.Common.Server.IsLocalIP)
            {
                this.Document.Variables.SetValue("domain", WeiSha.Common.Request.Domain.MainName);
            }
            this.Document.SetValue("domain2", getOrganDomain(org));
            //获取帐户,如果已经注册,则直接实现登录
            Song.Entities.Accounts acc = Business.Do <IAccounts>().Account4Weixin(openid);
            if (acc != null)
            {
                this.Document.Variables.SetValue("acc", acc);
                //直接实现登录
                if (acc.Ac_IsPass && acc.Ac_IsUse)
                {
                    LoginState.Accounts.Write(acc);
                    Business.Do <IAccounts>().PointAdd4Login(acc, "电脑网页", "微信登录", ""); //增加登录积分
                    Business.Do <IStudent>().LogForLoginAdd(acc);
                    this.Document.Variables.SetValue("success", "1");                  //登录成功
                }
                else
                {
                    this.Document.Variables.SetValue("success", "-1");   //账户禁用中
                }
            }
            else
            {
                //账户不存在,以下用于注册
                //相关参数
                WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
                //登录方式
                bool IsLoginForPw  = config["IsLoginForPw"].Value.Boolean ?? true;   //启用账号密码登录
                bool IsLoginForSms = config["IsLoginForSms"].Value.Boolean ?? true;  //启用手机短信验证登录
                this.Document.SetValue("forpw", IsLoginForPw);
                this.Document.SetValue("forsms", IsLoginForSms);
                this.Document.SetValue("IsWeixinDirect", Business.Do <ISystemPara>()["WeixinDirectIs"].Boolean ?? true); //是否允许微信直接注册登录
                //获取微信登录账户的信息
                Song.Entities.Accounts acctm = null;
                try
                {
                    acctm = getUserInfo(token, openid);
                }
                catch (Exception ex)
                {
                    this.Document.Variables.SetValue("acctmex", ex.Message);
                }
                if (acctm != null)
                {
                    this.Document.Variables.SetValue("name", acctm.Ac_Name);    //QQ昵称
                    this.Document.Variables.SetValue("photo", acctm.Ac_Photo);  //头像
                    this.Document.Variables.SetValue("gender", acctm.Ac_Sex);   //性别
                }
                this.Document.Variables.SetValue("acctm", acctm);
            }
        }
        /// <summary>
        /// get请求时
        /// </summary>
        protected void _StateForGET()
        {
            string token  = WeiSha.Common.Request.QueryString["token"].String;
            string openid = WeiSha.Common.Request.QueryString["openid"].String;

            this.Document.Variables.SetValue("openid", openid);
            this.Document.Variables.SetValue("token", token);
            //WeiSha.Common.Log.Write(string.Format("再次登录时,取token:{0},openid:{1}", token, openid));
            //设置主域,用于js跨根域
            int multi = Business.Do <ISystemPara>()["MultiOrgan"].Int32 ?? 0;

            if (multi == 0 && !WeiSha.Common.Server.IsLocalIP)
            {
                this.Document.Variables.SetValue("domain", WeiSha.Common.Server.MainName);
            }
            //当前机构
            Song.Entities.Organization org = getOrgan(-1);
            this.Document.Variables.SetValue("org", org);
            //WeiSha.Common.Log.Write(string.Format("再次登录时,机构{0}",org.Org_Name));
            //设置主域,用于js跨根域
            if (multi == 0 && !WeiSha.Common.Server.IsLocalIP)
            {
                this.Document.Variables.SetValue("domain", WeiSha.Common.Server.MainName);
            }
            this.Document.SetValue("domain2", org.Org_TwoDomain + "." + WeiSha.Common.Server.MainName);
            //获取帐户,如果已经注册,则直接实现登录
            string unionid = string.Empty;

            Song.Entities.Accounts acctm = getUserInfo(token, openid, out unionid);
            Song.Entities.Accounts acc   = null;
            if (acctm != null && !string.IsNullOrWhiteSpace(unionid))
            {
                acc = Business.Do <IAccounts>().Account4Weixin(unionid);
            }
            if (acc != null)
            {
                this.Document.Variables.SetValue("acc", acc);
                //直接实现登录
                if (acc.Ac_IsPass && acc.Ac_IsUse)
                {
                    LoginState.Accounts.Write(acc);
                    Business.Do <IAccounts>().PointAdd4Login(acc, "手机网页", "微信登录", ""); //增加登录积分
                    Business.Do <IStudent>().LogForLoginAdd(acc);
                    this.Document.Variables.SetValue("success", "1");                  //登录成功
                }
                else
                {
                    this.Document.Variables.SetValue("success", "-1");   //账户禁用中
                }
            }
            else
            {
                //账户不存在,以下用于注册
                //相关参数
                WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);
                //登录方式
                bool IsLoginForPw  = config["IsLoginForPw"].Value.Boolean ?? true;   //启用账号密码登录
                bool IsLoginForSms = config["IsLoginForSms"].Value.Boolean ?? true;  //启用手机短信验证登录
                this.Document.SetValue("forpw", IsLoginForPw);
                this.Document.SetValue("forsms", IsLoginForSms);
                this.Document.SetValue("IsWeixinDirect", Business.Do <ISystemPara>()["WeixinDirectIs"].Boolean ?? true); //是否允许微信直接注册登录
                //获取qq登录账户的信息
                if (acctm != null)
                {
                    this.Document.Variables.SetValue("name", acctm.Ac_Name);    //QQ昵称
                    this.Document.Variables.SetValue("photo", acctm.Ac_Photo);  //40*40头像
                    this.Document.Variables.SetValue("gender", acctm.Ac_Sex);   //性别
                }
                this.Document.Variables.SetValue("acctm", acctm);
            }
        }
Example #42
0
        public void TestReconfiguredProcessorId()
        {
            var jsonFileName = Path.GetTempFileName();

            try
            {
                var customConfig = new CustomConfig()
                {
                    ProcessorSelectorOptions = new SelectingProcessorAccessorOptions()
                    {
                        ProcessorId = "SQLite",
                    },
                    ConnectionStrings = new Dictionary <string, string>()
                    {
                        ["SQLite"]        = "Data Source=:memory:",
                        ["SQLAnywhere16"] = "Data Source=test.db",
                    }
                };

                SaveConfigFile(jsonFileName, customConfig);

                var config = new ConfigurationBuilder()
                             .AddJsonFile(
                    source =>
                {
                    source.Path           = jsonFileName;
                    source.ReloadOnChange = true;
                    source.ReloadDelay    = 50;
                    source.ResolveFileProvider();
                })
                             .Build();

                using (var serviceProvider = ServiceCollectionExtensions
                                             .CreateServices(false)
                                             .Configure <ProcessorOptions>(config.GetSection("ProcessorOptions"))
                                             .Configure <SelectingProcessorAccessorOptions>(config.GetSection("ProcessorSelectorOptions"))
                                             .AddSingleton <IConfiguration>(config)
                                             .BuildServiceProvider(true))
                {
                    using (var scope = serviceProvider.CreateScope())
                    {
                        var accessor = scope.ServiceProvider.GetRequiredService <IConnectionStringAccessor>();
                        Assert.AreEqual("Data Source=:memory:", accessor.ConnectionString);
                    }

                    EnsureReloadedConfiguration(config,
                                                () =>
                    {
                        customConfig.ProcessorSelectorOptions.ProcessorId = "SqlAnywhere16";
                        SaveConfigFile(jsonFileName, customConfig);
                    });

                    using (var scope = serviceProvider.CreateScope())
                    {
                        var accessor = scope.ServiceProvider.GetRequiredService <IConnectionStringAccessor>();
                        Assert.AreEqual("Data Source=test.db", accessor.ConnectionString);
                    }
                }
            }
            finally
            {
                File.Delete(jsonFileName);
            }
        }
Example #43
0
        protected override void InitPageTemplate(HttpContext context)
        {
            //相关参数
            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
            //登录方式
            bool IsLoginForPw  = config["IsLoginForPw"].Value.Boolean ?? true;   //启用账号密码登录
            bool IsLoginForSms = config["IsLoginForSms"].Value.Boolean ?? true;  //启用手机短信验证登录

            this.Document.SetValue("forpw", IsLoginForPw);
            this.Document.SetValue("forsms", IsLoginForSms);
            this.Document.SetValue("islogin", !IsLoginForPw && !IsLoginForSms);
            //界面状态
            if (!IsLoginForPw && IsLoginForSms)
            {
                loyout = "mobile";
            }
            this.Document.SetValue("loyout", loyout);
            //来源页
            string from = WeiSha.Common.Request.QueryString["from"].String;

            if (string.IsNullOrWhiteSpace(from))
            {
                from = context.Request.UrlReferrer != null ? context.Request.UrlReferrer.PathAndQuery : "";
            }
            this.Document.SetValue("from", from);
            //此页面的ajax提交,全部采用了POST方式
            if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                string action = WeiSha.Common.Request.Form["action"].String;
                switch (action)
                {
                case "accloginvcode":
                    accloginvcode_verify();     //验证账号登录时的验证码
                    break;

                case "acclogin":
                    acclogin_verify();      //验证账号登录时的密码
                    break;

                case "getSms":
                    mobivcode_verify();      //验证手机登录时,获取短信时的验证码
                    break;

                case "mobilogin":
                    mobiLogin_verify();
                    break;
                }
                Response.End();
            }
            //如果localStorage存有用户id,会提交到这里
            if (accid > 0)
            {
                ajaxLogin(context);
                return;
            }
            //QQ登录
            this.Document.SetValue("QQLoginIsUse", Business.Do <ISystemPara>()["QQLoginIsUse"].Boolean ?? true);
            this.Document.SetValue("QQAPPID", Business.Do <ISystemPara>()["QQAPPID"].String);
            this.Document.SetValue("QQReturl", Business.Do <ISystemPara>()["QQReturl"].Value ?? "http://" + WeiSha.Common.Request.Domain.MainName);
            //微信登录
            this.Document.SetValue("WeixinLoginIsUse", Business.Do <ISystemPara>()["WeixinLoginIsUse"].Boolean ?? false);
            this.Document.SetValue("WeixinAPPID", Business.Do <ISystemPara>()["WeixinAPPID"].String);
            this.Document.SetValue("WeixinReturl", Business.Do <ISystemPara>()["WeixinReturl"].Value ?? "http://" + WeiSha.Common.Request.Domain.MainName);
            //记录当前机构到本地,用于QQ或微信注册时的账户机构归属问题
            System.Web.HttpCookie cookie = new System.Web.HttpCookie("ORGID");
            cookie.Value = this.Organ.Org_ID.ToString();
            if (!WeiSha.Common.Server.IsLocalIP)
            {
                cookie.Domain = WeiSha.Common.Request.Domain.MainName;
            }
            this.Response.Cookies.Add(cookie);
            //推荐人id
            string sharekeyid = WeiSha.Common.Request.QueryString["sharekeyid"].String;

            System.Web.HttpCookie cookieShare = new System.Web.HttpCookie("sharekeyid");
            cookieShare.Value = sharekeyid;
            if (!WeiSha.Common.Server.IsLocalIP)
            {
                cookie.Domain = WeiSha.Common.Request.Domain.MainName;
            }
            this.Response.Cookies.Add(cookieShare);
        }
Example #44
0
 protected override void InitPageTemplate(HttpContext context)
 {
     //登录且学员必须通过审核
     if (!(Extend.LoginState.Accounts.IsLogin && Extend.LoginState.Accounts.CurrentUser.Ac_IsPass))
     {
         return;
     }
     #region 基本信息布局
     //题型
     this.Document.SetValue("quesType", WeiSha.Common.App.Get["QuesType"].Split(','));
     //难度
     Tag diffTag = this.Document.GetChildTagById("diff");
     if (diffTag != null)
     {
         string tm = diffTag.Attributes.GetValue("level", "");
         this.Document.SetValue("diff", tm.Split(','));
     }
     //每页的题量***********
     //总题数
     int sumCount = 0;
     Song.Entities.Outline outline = Business.Do <IOutline>().OutlineSingle(olid);
     if (outline != null)
     {
         bool isBuy = Business.Do <ICourse>().IsBuy(outline.Cou_ID, Extend.LoginState.Accounts.CurrentUserId, 1);
         if (isBuy)
         {
             sumCount = Business.Do <IQuestions>().QuesOfCount(Organ.Org_ID, 0, 0, olid, type, diff, true);
         }
         else
         {
             //是否在试用中
             bool istry = Business.Do <ICourse>().IsTryout(outline.Cou_ID, this.Account.Ac_ID);
             Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(outline.Cou_ID);
             if (course.Cou_IsTry)
             {
                 sumCount = Business.Do <IQuestions>().QuesOfCount(Organ.Org_ID, 0, 0, olid, type, diff, true);
                 sumCount = sumCount > course.Cou_TryNum ? course.Cou_TryNum : sumCount;
             }
             this.Document.Variables.SetValue("isTry", istry);
         }
     }
     //计算分页,200个记录不分页,每页默认100条,最多10页
     QuestionPagerItem qpi = new QuestionPagerItem(200, 100, 10);
     //sumCount = WeiSha.Common.Request.QueryString["sum"].Int32 ?? 0;   //仅供测试
     List <QuestionPagerItem> pager = qpi.Builder(sumCount);
     this.Document.SetValue("pager", pager);
     this.Document.SetValue("sumCount", sumCount);
     //与当前索引页码与取值长度
     if (!string.IsNullOrWhiteSpace(indexPara))
     {
         if (indexPara.IndexOf("-") > -1)
         {
             int.TryParse(indexPara.Substring(0, indexPara.IndexOf("-")), out index);
             int.TryParse(indexPara.Substring(indexPara.IndexOf("-") + 1), out size);
         }
     }
     else
     {
         index = pager.First <QuestionPagerItem>().Index;
         size  = pager.First <QuestionPagerItem>().Size;
     }
     this.Document.SetValue("index", index);
     #endregion
     //
     //自定义配置项
     WeiSha.Common.CustomConfig config = CustomConfig.Load(Organ.Org_Config);
     //如果需要学员登录后才能学习
     bool isTraningLogin = config["IsTraningLogin"].Value.Boolean ?? false;
     this.Document.SetValue("isTraningLogin", isTraningLogin);
     //试题
     Song.Entities.Questions[] ques = null;
     if (isTraningLogin)
     {
         //登录且学员必须通过审核
         if (Extend.LoginState.Accounts.IsLogin && Extend.LoginState.Accounts.CurrentUser.Ac_IsPass)
         {
             ques = Business.Do <IQuestions>().QuesCount(Organ.Org_ID, 0, 0, olid, type, diff, true, index - 1, size);
             //ques = Business.Do<IQuestions>().QuesRandom(Organ.Org_ID, -1, -1, olid, type, diff, diff, true, count);
         }
     }
     else
     {
         ques = Business.Do <IQuestions>().QuesCount(Organ.Org_ID, 0, 0, olid, type, diff, true, index - 1, size);
         //ques = Business.Do<IQuestions>().QuesRandom(Organ.Org_ID, -1, -1, olid, type, diff, diff, true, count);
     }
     if (ques != null)
     {
         for (int i = 0; i < ques.Length; i++)
         {
             ques[i]           = Extend.Questions.TranText(ques[i]);
             ques[i].Qus_Title = ques[i].Qus_Title.Replace("&lt;", "<");
             ques[i].Qus_Title = ques[i].Qus_Title.Replace("&gt;", ">");
             ques[i].Qus_Title = Extend.Html.ClearHTML(ques[i].Qus_Title, "p", "div", "font", "pre");
             ques[i].Qus_Title = ques[i].Qus_Title.Replace("\n", "<br/>");
         }
     }
     this.Document.SetValue("ques", ques);
     this.Document.RegisterGlobalFunction(this.GetTypeName);
     this.Document.RegisterGlobalFunction(this.AnswerItems);
     this.Document.RegisterGlobalFunction(this.GetAnswer);
     this.Document.RegisterGlobalFunction(this.GetOrder);
     this.Document.RegisterGlobalFunction(this.IsCollect);
 }
 public bool Capture(CustomConfig config)
 {
     return(true);
 }
Example #46
0
        public void FetchManyNonRootWorks() {
            var config = new CustomConfig();
            var selectQuery =
                new SelectQuery<PostTag>(new Mock<ISelectQueryExecutor>().Object).FetchMany(p => p.Post.Comments).ThenFetch(c => c.User) as
                SelectQuery<PostTag>;
            var writer = new SelectWriter(new SqlServer2012Dialect(), config);
            var result = writer.GenerateSql(selectQuery);
            var mapper = new SingleCollectionMapperGenerator(config);
            var funcFac = mapper.GenerateCollectionMapper<PostTag>(result.FetchTree).Item1;

            // setup the scenario
            var tag1 = new PostTag { PostTagId = 1 };
            var tag2 = new PostTag { PostTagId = 2 };
            var tag3 = new PostTag { PostTagId = 3 };
            var post1 = new Post { PostId = 1, Title = "Foo" };
            var anotherPost1 = new Post { PostId = 1, Title = "Foo" };
            var post2 = new Post { PostId = 2, Title = "Foo" };
            var post3 = new Post { PostId = 3, Title = "Foo" };
            var post4 = new Post { PostId = 4, Title = "Foo" };
            var comment1 = new Comment { CommentId = 1 };
            var comment2 = new Comment { CommentId = 2 };
            var comment3 = new Comment { CommentId = 3 };
            var comment4 = new Comment { CommentId = 4 };
            var comment5 = new Comment { CommentId = 5 };
            var comment6 = new Comment { CommentId = 6 };
            var user1 = new User { UserId = 1 };
            var user2 = new User { UserId = 2 };
            var user3 = new User { UserId = 3 };
            var user4 = new User { UserId = 4 };
            var user5 = new User { UserId = 5 };

            PostTag currentRoot = null;
            IList<PostTag> results = new List<PostTag>();
            var func = (Func<object[], PostTag>)funcFac.DynamicInvoke(currentRoot, results);
            func(new object[] { tag1, post1, comment1, user1 });
            func(new object[] { tag1, post1, comment2, user1 });
            func(new object[] { tag1, post1, comment3, user2 });
            func(new object[] { tag2, anotherPost1, comment1, user1 });
            func(new object[] { tag2, anotherPost1, comment2, user1 });
            func(new object[] { tag2, anotherPost1, comment3, user2 });
            func(new object[] { tag3, post2, comment4, user3 });
            func(new object[] { tag3, post2, comment5, user4 });
            func(new object[] { tag3, post2, comment6, user5 });

            Assert.Equal(3, results.Count);
            Assert.Equal(3, results.First().Post.Comments.Count);
            Assert.Equal(1, results.First().Post.PostId);
            Assert.Equal(1, results.First().Post.Comments.First().User.UserId);
            Assert.Equal(1, results.First().Post.Comments.ElementAt(1).User.UserId);
            Assert.Equal(2, results.First().Post.Comments.ElementAt(2).User.UserId);
            Assert.Equal(3, results.ElementAt(1).Post.Comments.Count);
            Assert.Equal(1, results.ElementAt(1).Post.PostId);
            Assert.Equal(1, results.ElementAt(1).Post.Comments.First().User.UserId);
            Assert.Equal(1, results.ElementAt(1).Post.Comments.ElementAt(1).User.UserId);
            Assert.Equal(2, results.ElementAt(1).Post.Comments.ElementAt(2).User.UserId);
            Assert.Equal(3, results.ElementAt(2).Post.Comments.Count);
            Assert.Equal(2, results.ElementAt(2).Post.PostId);
            Assert.Equal(4, results.ElementAt(2).Post.Comments.First().CommentId);
            Assert.Equal(5, results.ElementAt(2).Post.Comments.ElementAt(1).CommentId);
            Assert.Equal(6, results.ElementAt(2).Post.Comments.ElementAt(2).CommentId);
        }