Beispiel #1
0
        public virtual IEnumerable <DbQueryCommandTree> CreateDiscoveryQueryTrees()
        {
            DbConnection connection = (DbConnection)null;

            try
            {
                connection = this.CreateConnection();
                foreach (string schema in this._schemas)
                {
                    using (HistoryContext context = this.CreateContext(connection, schema))
                    {
                        IOrderedQueryable <string> query   = context.History.Where <HistoryRow>((Expression <Func <HistoryRow, bool> >)(h => h.ContextKey == this._contextKey)).Select <HistoryRow, string>((Expression <Func <HistoryRow, string> >)(s => s.MigrationId)).OrderByDescending <string, string>((Expression <Func <string, string> >)(s => s));
                        DbQuery <string>           dbQuery = query as DbQuery <string>;
                        if (dbQuery != null)
                        {
                            dbQuery.InternalQuery.ObjectQuery.EnablePlanCaching = false;
                        }
                        using (CommandTracer commandTracer = new CommandTracer((DbContext)context))
                        {
                            query.First <string>();
                            DbQueryCommandTree queryTree = commandTracer.CommandTrees.OfType <DbQueryCommandTree>().Single <DbQueryCommandTree>((Func <DbQueryCommandTree, bool>)(t => t.DataSpace == DataSpace.SSpace));
                            yield return(new DbQueryCommandTree(queryTree.MetadataWorkspace, queryTree.DataSpace, queryTree.Query.Accept <DbExpression>((DbExpressionVisitor <DbExpression>) new HistoryRepository.ParameterInliner(commandTracer.DbCommands.Single <DbCommand>().Parameters))));
                        }
                    }
                }
            }
            finally
            {
                this.DisposeConnection(connection);
            }
        }
Beispiel #2
0
 private void timer_Elapsed2(object sender, ElapsedEventArgs e)
 {
     if ((this.beginTime.TimeOfDay.Hours == 11 && this.beginTime.TimeOfDay.Minutes == 0) || (this.beginTime.TimeOfDay.Hours == 17 && this.beginTime.TimeOfDay.Minutes == 0) || (this.beginTime.TimeOfDay.Hours == 22 && this.beginTime.TimeOfDay.Minutes == 0))
     {
         this.notifyIcon1.ShowBalloonTip(10000, "", "请及时签出!", ToolTipIcon.Info);
     }
     if ((this.beginTime.TimeOfDay.Hours == 12 && this.beginTime.TimeOfDay.Minutes == 30) || (this.beginTime.TimeOfDay.Hours == 18 && this.beginTime.TimeOfDay.Minutes == 30) || (this.beginTime.TimeOfDay.Hours == 23 && this.beginTime.TimeOfDay.Minutes == 30))
     {
         IOrderedQueryable <signrecord> source = from item in this.entity.signrecord
                                                 where item.userId == this.uid
                                                 orderby item.signTimestamp descending
                                                 select item;
         if (source.Count <signrecord>() > 0)
         {
             if (source.First <signrecord>().in_out)
             {
                 this.contextMenuStrip1.Items[1].Text = "签出 " + this.beginTime;
             }
             else
             {
                 this.contextMenuStrip1.Items[1].Text = "签入 " + this.beginTime;
             }
         }
     }
 }
        /// <summary>
        /// Add Program Package Version To the Database via Entityframework.
        /// The Program package version is allways linked to a Program package.
        /// </summary>
        /// <param name="queryProgram"></param>
        /// <param name="db"></param>
        /// <param name="val"></param>
        private static void AddProgramPackageVersionToDatabase(IOrderedQueryable <EF_Program> queryProgram, ProgramContext db, XMLClasses.feedEntry val)
        {
            var program = queryProgram.First();

            db.ProgramVersions.Add(new EF_ProgramVersion {
                Program = program, Version = val.properties.Version
            });
        }
        public async Task <DifferentialChangeset> ExtractDifferentialChangeset(T1 id, IOrderedQueryable <HistoricalEvent> events)
        {
            var differentialChangeset = new DifferentialChangeset();

            differentialChangeset.EntityId       = id.ToString();
            differentialChangeset.EntityTypeName = events.First().EntityName;
            differentialChangeset.Changesets     = events.AggregateCombine(ExtractOneDifferentialChangeset <T2>);
            return(differentialChangeset);
        }
        private static AnalyticsPrice CalculateAnalyticsPrice(IOrderedQueryable <HourlyShareRate> ratesOrderedByTimestamp)
        {
            if (!ratesOrderedByTimestamp.Any())
            {
                return(null);
            }

            return(new AnalyticsPrice
            {
                High = ratesOrderedByTimestamp.Max(r => r.Rate),
                Low = ratesOrderedByTimestamp.Min(r => r.Rate),
                Open = ratesOrderedByTimestamp.First().Rate,
                Close = ratesOrderedByTimestamp.Last().Rate,
            });
        }
        public void LinqOrderByCanBeUsedToControlResultsBug()
        {
            CreateThreeFoos();

            // If look at the "LinqOrderByCanBeUsedToControlResults", you will see this query
            // works fine is the static type of "foos" is "IEnumerable<Foo>"...
            IOrderedQueryable <FooRecord> foos =
                from f in _fooRepos.Table
                where f.Name == "two" || f.Name == "three"
                orderby f.Name, f.Id ascending
            select f;

            Assert.That(foos.Count(), Is.EqualTo(2));
            Assert.That(foos.First().Name, Is.EqualTo("three"));

            // Looks like a bug in NHib implementation of IOrderedQueryable<T>
            Assert.Throws <AssertionException>(() => Assert.That(foos.Skip(1).First().Name, Is.EqualTo("two")));
        }
        public Level GetNextNonCompleteLevel(int playerId)
        {
            Level        nextLevel;
            LevelAttempt highestCompletedLevelAttempt = GetHighestCompletedLevelAttemptForPlayer(playerId);

            IOrderedQueryable <Level> orderedLevels = GetOrderedLevels();

            if (highestCompletedLevelAttempt == null)
            {
                //the player has not completed any levels, so just get the first
                nextLevel = orderedLevels.First(l => l.Active);
            }
            else
            {
                //check to see if there is another level in the current world
                nextLevel =
                    orderedLevels
                    .SingleOrDefault(
                        l =>
                        l.World == highestCompletedLevelAttempt.Level.World &&
                        l.SequenceInWorld == highestCompletedLevelAttempt.Level.SequenceInWorld + 1);

                if (nextLevel == null)
                {
                    //check to see if there is a next world
                    nextLevel =
                        orderedLevels
                        .SingleOrDefault(
                            l =>
                            l.World == highestCompletedLevelAttempt.Level.World + 1 &&
                            l.SequenceInWorld == 1);
                }

                if (nextLevel == null)
                {
                    //the player has completed all levels, so just return the last level
                    nextLevel =
                        orderedLevels.OrderByDescending(o => o.World).ThenByDescending(o => o.SequenceInWorld)
                        .First();
                }
            }

            return(nextLevel);
        }
Beispiel #8
0
            public IntelligenceQueue(Guid queueGuid, Guid currentUser, NoteContext db) : base(queueGuid, currentUser, db)
            {
#warning 此处不应该硬编码,未来修改时拆分至其他项目
                Guid          questionnaireGuid = Guid.Parse("b546b709-2b2b-4f6e-9f1f-64f281de8d5b");
                Questionnaire qn = (from questionnaire in db.Questionnaire
                                    where questionnaire.Version != Guid.Empty
                                    where questionnaire.QuestionnaireGuid == questionnaireGuid
                                    orderby questionnaire.Ctime
                                    select questionnaire).First();

                UserInformationRecord user         = db.UserInformation.First(x => x.UserGuid == currentUser);
                List <Guid>           questionList = JsonConvert.DeserializeObject <List <Guid> >(qn.Question);
                if (user.UserGender == UserInformationRecord.Gender.Man)
                {
                    //如果为男性,移除白带异常问题
                    questionList.Remove(Guid.Parse("23E317C9-D691-402E-8249-C0E4D3ED78D0"));
                }
                else
                {
                    //如果为女性,移除阴囊潮湿问题
                    questionList.Remove(Guid.Parse("A6C1DBC2-233D-4FA8-927B-8BAED0F709B3"));
                }

                DateTime today = DateTime.Now;//兼容多次测试
                //查找出用户已经答过的问题
                IQueryable <Guid> answeredQuestions = from answer in db.Answer
                                                      where answer.Userid == currentUser
                                                      where answer.Ctime.Date == today.Date//兼容多次测试
                                                      where answer.Mtime != DateTime.MinValue
                                                      where questionList.Contains(answer.QuestionGuid)
                                                      select answer.QuestionGuid;
                if (answeredQuestions.Any())
                {
                    //移除
                    foreach (Guid answeredQuestion in answeredQuestions)
                    {
                        questionList.Remove(answeredQuestion);
                        //Console.WriteLine("移除了一个记录:" + answeredQuestion);
                    }
                }
                //Console.WriteLine($"该用户还有{questionList.Count}道题没有完成");
                IOrderedQueryable <Question> questionRecords = from s in db.Question
                                                               where s.Version != Guid.Empty
                                                               orderby s.Ctime descending
                                                               select s;
                foreach (Guid a in questionList)
                {
                    QuestionQueue queues = new QuestionQueue
                    {
                        QueueGuid       = guid,
                        QuestionVersion = questionRecords.First(x => x.QuestionGuid == a).Version,
                        QueueUser       = base.user,
                        Ctime           = DateTime.Now
                    };
                    db.QuestionQueue.Add(queues);
                }

                db.QuestionQueue.Add(new QuestionQueue
                {
                    QueueGuid       = guid,
                    QuestionVersion = Guid.Parse("CB849EFF-6C6F-433B-BB46-535570D6158B"),
                    Ctime           = DateTime.Now,
                    QueueUser       = base.user,
                    DynamicContent  = JsonConvert.SerializeObject(new Conclusion
                    {
                        Link    = $"Result/{base.user.ToString()}",
                        Title   = "您的体质似乎是这样的……",
                        Options = new Dictionary <string, BooleanOption.Option>
                        {
                            { "Left", new BooleanOption.Option {
                                  Text = "哦?"
                              } },
                            { "Right", new BooleanOption.Option {
                                  Text = "我想知道"
                              } },
                        }
                    })
                });

                db.SaveChanges();
            }
Beispiel #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Process[] processesByName = Process.GetProcessesByName("CISLClient");
            if (processesByName.Length > 1)
            {
                MessageBox.Show("程序已运行!");
                Application.Exit();
            }
            Control.CheckForIllegalCrossThreadCalls = false;
            this.beginTime = this.entity.Database.SqlQuery <DateTime>("select now()", new object[0]).FirstOrDefault <DateTime>();
            this.notifyIcon1.ShowBalloonTip(5000, "", "CISL签到客户端", ToolTipIcon.Info);
            StreamReader streamReader = new StreamReader(Application.StartupPath + "\\config.txt", false);
            string       text         = streamReader.ReadLine();

            if (text != null && text != "")
            {
                this.array = text.Split(new char[]
                {
                    ' '
                });
                this.uname = array[0];
                this.pwd   = array[1];
                if (this.array.Length > 2)
                {
                    this.autosignin  = array[2];
                    this.autosignout = array[3];

                    int inteval = int.Parse(array[4]);
                    this.timer1.Interval = inteval;
                    MessageBox.Show("签入:" + this.autosignin + ",签出:" + this.autosignout + ",间隔时间:" + inteval, "配置信息");
                }


                streamReader.Close();
                IQueryable <user> source = from item in this.entity.user
                                           where item.username == this.uname && item.password == this.pwd
                                           select item;
                if (source.Count <user>() == 0)
                {
                    MessageBox.Show("用户名或密码错误,请到配置文件修改!");
                }
                else
                {
                    this.contextMenuStrip1.Items[0].Text = "当前用户:" + this.uname;
                    this.uid     = source.First <user>().id;
                    this.zh_name = source.First <user>().zh_name;
                    IOrderedQueryable <signrecord> source2 = from r in this.entity.signrecord
                                                             where r.userId == this.uid
                                                             orderby r.signTimestamp descending
                                                             select r;
                    if (source2.Count <signrecord>() == 0)
                    {
                        this.flag = false;
                        this.contextMenuStrip1.Items[1].Text = "签入 " + this.beginTime;
                    }
                    else if (source2.First <signrecord>().in_out)
                    {
                        this.flag = true;
                        this.contextMenuStrip1.Items[1].Text = "签出 " + this.beginTime;
                    }
                    else
                    {
                        this.flag = false;
                        this.contextMenuStrip1.Items[1].Text = "签入 " + this.beginTime;
                    }
                }
            }
            else
            {
                MessageBox.Show("请先配置用户名及密码!");
            }
        }
 /// <summary>
 /// Add Program Package Version To the Database via Entityframework. 
 /// The Program package version is allways linked to a Program package.
 /// </summary>
 /// <param name="queryProgram"></param>
 /// <param name="db"></param>
 /// <param name="val"></param>
 private static void AddProgramPackageVersionToDatabase(IOrderedQueryable<EF_Program> queryProgram, ProgramContext db, XMLClasses.feedEntry val)
 {
     var program = queryProgram.First();
     db.ProgramVersions.Add(new EF_ProgramVersion {Program = program, Version = val.properties.Version});
 }