Example #1
0
        public ActionResult Update(TimeLineModel model)
        {
            ApiResult <TimeLineModel> result = new ApiResult <TimeLineModel>();

            using (var db = new TimeLineDb())
            {
                var dbmodel = db.timeLineModels.Where(p => p.Id == model.Id).First();
                if (dbmodel != null)
                {
                    dbmodel.Copy       = model.Copy;
                    dbmodel.Images     = model.Images;
                    dbmodel.TitleYear  = model.TitleYear;
                    dbmodel.TitleMonth = model.TitleMonth;
                    dbmodel.TitleDay   = model.TitleDay;
                    dbmodel.UpdateTime = DateTime.Now;
                }
                db.Entry(dbmodel).State = System.Data.Entity.EntityState.Modified;
                var ret = db.SaveChanges();
                if (ret > 0)
                {
                    result.Code      = 200;
                    result.Data      = dbmodel;
                    result.IsSuccess = true;
                }
                return(Json(result));
            }
        }
Example #2
0
        public ActionResult Create(TimeLineModel model)
        {
            ApiResult <bool> result = new ApiResult <bool>();

            //编写创建model逻辑
            using (var dbContext = new TimeLineDb())
            {
                TimeLineModel newModel = model;
                try
                {
                    newModel.CreateTime = DateTime.Now;
                    newModel.UpdateTime = DateTime.Now;
                    newModel.IsDeleted  = false;
                    dbContext.timeLineModels.Add(newModel);
                    int ret = dbContext.SaveChanges();
                    if (ret > 0)
                    {
                        result.Code      = 10000;
                        result.Data      = true;
                        result.IsSuccess = true;
                    }
                    else
                    {
                        result.Code      = 20000;
                        result.Data      = false;
                        result.IsSuccess = false;
                    }
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <param name="cited"></param>
        /// <returns></returns>
        public static List <TimeLineModel> GetModels()
        {
            List <TimeLineModel> lines = new List <TimeLineModel>();

            using (SqlConnection conn = SQL.GetConnection())
            {
                SqlCommand    cmd    = new SqlCommand(string.Format(RunSql.SQL_CITEDLIST, "select * from dbo.Table_History"), conn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    TimeLineModel model = new TimeLineModel();
                    model.Id         = Convert.ToInt32(reader[0]);
                    model.TitleYear  = reader[1].ToString();
                    model.TitleMonth = reader[2].ToString();
                    model.TitleDay   = reader[3].ToString();
                    model.Copy       = reader[4].ToString();
                    model.Images     = reader[5].ToString();
                    model.CreateTime = Convert.ToDateTime(reader[6]);
                    model.UpdateTime = Convert.ToDateTime(reader[7]);
                    model.IsDeleted  = Convert.ToBoolean(reader[8]);
                    lines.Add(model);
                }
            }
            return(lines);
        }
Example #4
0
 /// <summary>
 ///		Cambia el tamaño de un control
 /// </summary>
 private void ExecuteResize(TimeLineModel timeLine, FrameworkElement control, ResizeActionModel action)
 {
     if (CheckMustAnimate(action))
     {
         if (action.Width != null)
         {
             CreateDoubleAnimation(control, null, action.Width ?? 100,
                                   new PropertyPath(ComicPageView.PageWidthProperty), action);
         }
         if (action.Height != null)
         {
             CreateDoubleAnimation(control, null, action.Height ?? 100,
                                   new PropertyPath(ComicPageView.PageHeightProperty), action);
         }
     }
     else
     {
         if (action.Width != null)
         {
             ComicPageView.SetPageWidth(control, action.Width ?? 100);
         }
         if (action.Height != null)
         {
             ComicPageView.SetPageHeight(control, action.Height ?? 100);
         }
     }
 }
Example #5
0
        public async Task <ActionResult> TimeLine(int programId)
        {
            var result = new TimeLineModel().GetTerms(_dbContext, programId);
            var json   = await JsonUtil.JsonResultAsync(result);

            return(Content(json, "application/json"));
        }
Example #6
0
        /// <summary>
        ///		Obtiene la siguiente acción
        /// </summary>
        public TimeLineModel MoveNextAction()
        {
            TimeLineModel timeLine = null;

            // Obtiene la siguiente acción
            if (IndexActualAction < ActualPage.TimeLines.Count)
            {
                timeLine = ActualPage.TimeLines[IndexActualAction++];
            }
            // Devuelve la acción
            return(timeLine);
        }
Example #7
0
        /// <summary>
        ///		Pasa a la siguiente acción
        /// </summary>
        private void NextAction()
        {
            TimeLineModel timeLine = Manager.MoveNextAction();

            // Ejecuta la acción
            if (timeLine != null)
            {
                udtComic.Execute(timeLine);
            }
            else
            {
                NextPage();
            }
        }
Example #8
0
        public ActionResult Edit(int id)
        {
            TimeLineModel model = new TimeLineModel();

            using (var db = new TimeLineDb())
            {
                var findModel = db.timeLineModels.Where(p => p.Id == id).First();
                if (findModel != null)
                {
                    model = findModel;
                }
            }
            return(View(model));
        }
Example #9
0
        //// GET: TimeLine
        //public ActionResult OldIndex()
        //{
        //    var highchartSample = new List<TimeLineModel>
        //    {
        //        new TimeLineModel() {Parameters = "Event", GoodScore = 23.45D, AverageScore = 15.32D,BadScore = 9.4D,ActualScore=78.33D},
        //        new TimeLineModel() {Parameters = "Weather",GoodScore=45.67D,AverageScore = 33.24D,BadScore = 12.23D,ActualScore = 56.22D},
        //        new TimeLineModel() {Parameters = "User Review",GoodScore=67.23D,AverageScore = 31.23D,BadScore = 10.11D,ActualScore = 29.44D},
        //        new TimeLineModel() {Parameters = "Tweets",GoodScore = 89.67D,AverageScore = 12.33D,BadScore = 3.43D,ActualScore = 88.11D},
        //        new TimeLineModel() {Parameters = "Persona",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 35.08D},
        //        new TimeLineModel() {Parameters = "Crime",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 24.87D}
        //    };

        //    var xDataParameters = highchartSample.Select(i => i.Parameters).ToArray();
        //    var actualScore = highchartSample.Select(i => i.ActualScore);

        //    var chart = new Highcharts("chart");
        //    chart.InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar });
        //    chart.SetTitle(new Title { Text = "Risk Score Profiling" });
        //    chart.SetSubtitle(new Subtitle { Text = "Risk predicting using social media" });
        //    chart.SetXAxis(new XAxis { Categories = xDataParameters });
        //    chart.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Scores" }, Max = 100 });
        //    chart.SetLegend(new Legend { Enabled = false, });
        //    chart.SetTooltip(new Tooltip
        //    {
        //        Enabled = true,
        //        Formatter = @"function(){return '<b>' + this.series.name +'</b><br/>' + this.x+':' + this.y;}"
        //    });
        //    chart.SetPlotOptions(new PlotOptions
        //    {
        //        //Series = new PlotOptionsSeries() { Stacking = Stackings.Normal },
        //        Bar = new PlotOptionsBar
        //        {
        //            DataLabels = new PlotOptionsBarDataLabels { Enabled = true, Color = Color.Maroon, Shadow = true },
        //            //PointWidth = 10,
        //            //GroupPadding = 1,
        //            //PointPadding = 0,
        //            Shadow = true,
        //            BorderWidth = 1,
        //            BorderColor = Color.FloralWhite,
        //        }
        //    });
        //    Data data = new Data(
        //        actualScore.Select(y => new Point { Color = GetBarColor(y), Y = y }).ToArray()
        //    );

        //    chart.SetSeries(new Series { Name = "Actual Score", Data = data });

        //    return View(chart);
        //}

        //public ActionResult Index1()
        //{

        //    apiController = new RequestAPIController();

        //    GetEventScore(57);

        //    var highchartSample = new List<TimeLineModel>
        //    {
        //        new TimeLineModel() {Parameters = "Event", GoodScore = 23.45D, AverageScore = 15.32D,BadScore = 9.4D,ActualScore=78.33D},
        //        new TimeLineModel() {Parameters = "Weather",GoodScore=45.67D,AverageScore = 33.24D,BadScore = 12.23D,ActualScore = 56.22D},
        //        new TimeLineModel() {Parameters = "User Review",GoodScore=67.23D,AverageScore = 31.23D,BadScore = 10.11D,ActualScore = 29.44D},
        //        new TimeLineModel() {Parameters = "Tweets",GoodScore = 89.67D,AverageScore = 12.33D,BadScore = 3.43D,ActualScore = 88.11D},
        //        new TimeLineModel() {Parameters = "Persona",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 35.08D},
        //        new TimeLineModel() {Parameters = "Crime",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 24.87D}
        //    };

        //    var xDataParameters = highchartSample.Select(i => i.Parameters).ToArray();
        //    var actualScore = highchartSample.Select(i => i.ActualScore);

        //    Highcharts chart = new Highcharts("chart")
        //        .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
        //        .SetTitle(new Title { Text = "Risk Score Profiling" })
        //        .SetSubtitle(new Subtitle { Text = "Risk predicting using social media" })
        //        .SetXAxis(new XAxis { Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } })
        //        .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Scores" }, Max = 100 })
        //        .SetLegend(new Legend
        //        {
        //            Layout = Layouts.Vertical,
        //            Align = HorizontalAligns.Left,
        //            VerticalAlign = VerticalAligns.Top,
        //            X = 100,
        //            Y = 70,
        //            Floating = true,
        //            BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")),
        //            Shadow = true
        //        })
        //        .SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y +' mm'; }" })
        //        .SetPlotOptions(new PlotOptions
        //        {
        //            Column = new PlotOptionsColumn
        //            {
        //                PointPadding = 0.2,
        //                //BorderWidth = 0,
        //                Shadow = true,
        //                BorderWidth = 1,
        //                BorderColor = Color.FloralWhite
        //            }
        //        })

        //        .SetSeries(new[]
        //        {
        //            new Series { Name = "Event", Data = new Data(new object[] { 49.9, 21.5, 46.4, 49.2, 44.0, 76.0, 35.6, 48.5, 16.4, 44.1, 55.6, 54.4 }) },
        //            new Series { Name = "Weather", Data = new Data(new object[] { 8.9, 8.8, 9.3, 21.4, 27.0, 28.3, 29.0, 29.6, 22.4, 25.2, 29.3, 31.2 }) },
        //            new Series { Name = "User Review", Data = new Data(new object[] { 33.6, 48.8, 98.5, 93.4, 36.0, 84.5, 35.0, 34.3, 31.2, 83.5, 16.6, 92.3 }) },
        //            new Series { Name = "Persona", Data = new Data(new object[] { 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1 }) },
        //            new Series { Name = "Crime", Data = new Data(new object[] { 22.4, 23.2, 44.5, 59.7, 72.6, 45.5, 37.4, 20.4, 47.6, 19.1, 26.8, 31.1 }) }
        //        });

        //    return View(chart);
        //}

        public ActionResult Index(int id)
        {
            ViewBag.RequestId = id;

            apiController = new RequestAPIController();

            Highcharts chart12 = new Highcharts("chart")
                                 .InitChart(new Chart
            {
                Type      = ChartTypes.Column,
                Margin    = new[] { 75 },
                Options3d = new ChartOptions3d
                {
                    Enabled      = true,
                    Alpha        = 0,
                    Beta         = 0,
                    Depth        = 50,
                    ViewDistance = 25
                }
            })
                                 .SetXAxis(new XAxis {
                Categories = GetMonthList()
            })
                                 .SetTitle(new Title {
                Text = "Event Timeline"
            })
                                 .SetPlotOptions(new PlotOptions {
                Column = new PlotOptionsColumn {
                    Depth = 25, Color = Color.LightSlateGray, BorderColor = Color.AntiqueWhite, BorderWidth = 1
                }
            })
                                 .SetLegend(new Legend {
                Enabled = false
            })

                                 .SetSeries(new Series {
                Data = new Data(GetEventScore(id))
            });

            TimeLineModel model = new TimeLineModel {
                chart = chart12, TweetScore = GetTweetScore(id), UserScore = GetUserFeedbackScore(id), WeatherScore = 60, CrimeScore = 20, LocationAura = Math.Round((GetTweetScore(id) + 60 + 20) / 3, 2)
            };

            return(View(model));
        }
Example #10
0
        private void Duplicate(DateTime weekStart, string clientID = null)
        {
            //Add the start/End days
            Tuple <DateTime, DateTime> dates = Utilities.GetWeekStartEndDates(_EndDay, weekStart);
            DateTime choosenWeekStart        = dates.Item1;
            DateTime choosenWeekEnd          = dates.Item2;

            Tuple <DateTime, DateTime> currentDate = Utilities.GetWeekStartEndDates(_EndDay);
            DateTime thisWeekStart = currentDate.Item1;

            int weeksDifference = (thisWeekStart - weekStart).Days;


            string userID = User.Identity.Name;

            using (TimeLineDB db = new TimeLineDB())
            {
                foreach (TimeLineModel line in db.TimeLines.Where(x => (x.LineDate >= choosenWeekStart && x.LineDate <= choosenWeekEnd && x.UserID == userID)))
                {
                    if (clientID == null || clientID != line.ClientID)
                    {
                        continue;
                    }

                    TimeLineModel temp = new TimeLineModel();

                    temp.ActivityCode = line.ActivityCode;
                    temp.ClientID     = line.ClientID;

                    temp.LineDate = line.LineDate.AddDays(weeksDifference);

                    temp.Pieces    = line.Pieces;
                    temp.StartTime = line.StartTime;
                    temp.EndTime   = line.EndTime;
                    temp.Hours     = line.Hours;
                    temp.UserID    = line.UserID;
                    temp.Comments  = line.Comments;

                    db.Entry(temp).State = System.Data.EntityState.Added;
                }

                db.SaveChanges();
            }
        }
Example #11
0
        private TimeLineModel AddTimeLine(DateTime?requestTime, string dateTime)
        {
            var item = new TimeLineModel();

            item.Time = DateTime.Parse(dateTime);
            int index = 0;

            if (Items.Count > 0)
            {
                index = item.Time > Items[0].Time ? 0 : Items.Count;
            }
            DateTime big   = new DateTime();
            DateTime small = new DateTime();

            if (requestTime.HasValue)
            {
                big   = requestTime.Value > item.Time ? requestTime.Value : item.Time;
                small = requestTime.Value < item.Time ? requestTime.Value : item.Time;
            }
            if (Items.Count >= 1)
            {
                big   = index == 0 ? DateTime.Parse(item.GroupTime) : DateTime.Parse(Items[index - 1].GroupTime);
                small = index == 0 ? DateTime.Parse(Items[0].GroupTime) : DateTime.Parse(item.GroupTime);
            }

            int gap = (big.Year - small.Year) * 12 + (big.Month - small.Month) - 1;

            if (gap > 0)
            {
                for (int i = gap; i > 0; i--)
                {
                    big = big.AddMonths(-1);
                    var blank = new TimeLineModel();
                    blank.Time  = big;
                    blank.Blank = true;
                    Items.Insert(index, blank);
                    index++;
                }
            }

            Items.Insert(index, item);
            return(item);
        }
Example #12
0
        public void AddItem(DateTime?requestTime, ContentModel model)
        {
            string        time = model.Time.ToString("yyyy-MM-dd");
            TimeLineModel item = null;

            item = Items.FirstOrDefault(n => n.TimeString == time);
            if (item == null)
            {
                item = AddTimeLine(requestTime, time);
            }
            var temp = item.Childs.FirstOrDefault(n => n.ID == model.ID);

            if (temp == null)
            {
                int index = 0;
                if (item.Childs.Count > 0)
                {
                    index = model.Time > item.Childs[0].Time ? 0 : item.Childs.Count;
                }
                item.Childs.Insert(index, model);
            }
        }
Example #13
0
 /// <summary>
 ///		Ejecuta las acciones de una línea de tiempo
 /// </summary>
 internal void Execute(TimeLineModel timeLine)
 {
     // Si no existía ninguna animación se crea
     if (_animationProcessor == null)
     {
         // Crea el objeto
         _animationProcessor = new TimeLineProcessor(this, UseAnimation);
         // Asigna los manejadores de eventos
         _animationProcessor.AnimationStart += (sender, evntArgs) =>
         {
             StartAnimation?.Invoke(this, EventArgs.Empty);
             IsPlayingAnimation = true;
         };
         _animationProcessor.AnimationEnd += (sender, evntArgs) =>
         {
             EndAnimation?.Invoke(this, EventArgs.Empty);
             IsPlayingAnimation = false;
         };
     }
     // Ejecuta la animación
     _animationProcessor.Execute(timeLine);
 }
Example #14
0
 /// <summary>
 /// 创建记录
 /// </summary>
 /// <param name="stroredCited"></param>
 public static void AddCitedModel(TimeLineModel timeLineModel)
 {
     using (SqlConnection conn = SQL.GetConnection())
     {
         SqlCommand     cmd   = new SqlCommand(RunSql.SQL_INSERT_HISTORY, conn);
         SqlParameter[] _para =
         {
             new SqlParameter("@TitleYear",  timeLineModel.TitleYear),
             new SqlParameter("@TitleMonth", timeLineModel.TitleMonth),
             new SqlParameter("@TitleDay",   timeLineModel.TitleDay),
             new SqlParameter("@Copy",       timeLineModel.Copy),
             new SqlParameter("@Images",     timeLineModel.Images),
             new SqlParameter("@CreateTime", timeLineModel.CreateTime),
             new SqlParameter("@UpdateTime", timeLineModel.UpdateTime),
             new SqlParameter("@IsDeleted",  timeLineModel.IsDeleted),
         };
         if (null != _para)
         {
             cmd.Parameters.AddRange(_para);
         }
         cmd.ExecuteNonQuery();
     }
 }
        public ActionResult Edit(CardModel model)
        {
            using (TimeLineDB db = new TimeLineDB())
            {
                model.EditLine.UserID = User.Identity.Name;
                TimeLineModel temp = db.TimeLines.FirstOrDefault(x => x.Id == model.EditLine.Id);

                temp.ActivityCode = model.EditLine.ActivityCode;
                temp.ClientID     = model.EditLine.ClientID;
                temp.LineDate     = model.EditLine.LineDate;
                temp.Pieces       = model.EditLine.Pieces;
                temp.StartTime    = model.EditLine.StartTime;
                temp.EndTime      = model.EditLine.EndTime;
                temp.UserID       = model.EditLine.UserID;

                db.Entry(temp).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            model = SetupModel();

            return(View("Index", model));
        }
Example #16
0
        public async Task <int> AddTimeLineRecord(TimeLineModel data)
        {
            var Ack = await _database.InsertAsync(data);

            return(Ack);
        }
Example #17
0
        /// <summary>
        ///		Ejecuta una serie de acciones
        /// </summary>
        internal void Execute(TimeLineModel timeLine)
        {
            // Crea el storyboard de las animaciones
            if (sbStoryBoard == null)
            {
                // Crea el storyBoard
                sbStoryBoard = new Storyboard();
                // Asigna el evento de fin de animación
                sbStoryBoard.Completed += (sender, evntArgs) => AnimationEnd?.Invoke(this, EventArgs.Empty);
            }
            // Limpia el storyBoard
            sbStoryBoard.Children.Clear();
            // Asigna las propiedades de duración
            sbStoryBoard.BeginTime = TimeSpan.FromSeconds(timeLine.Parameters.Start);
            sbStoryBoard.Duration  = new Duration(TimeSpan.FromSeconds(timeLine.Parameters.Duration));
            // Recorre las acciones añadiéndolas al storyboard
            foreach (ActionBaseModel action in timeLine.Actions)
            {
                if (action != null)
                {
                    FrameworkElement control = PageView.GetPageControl(action.TargetKey);

                    // Ejecuta la acción
                    if (control != null)                             // && control.RenderTransform is TransformGroup)
                    {
                        if (action is SetVisibilityActionModel)
                        {
                            ExecuteVisibility(control, action as SetVisibilityActionModel);
                        }
                        else if (action is ResizeActionModel)
                        {
                            ExecuteResize(timeLine, control, action as ResizeActionModel);
                        }
                        else if (action is RotateActionModel)
                        {
                            ExecuteRotation(control, action as RotateActionModel);
                        }
                        else if (action is ZoomActionModel)
                        {
                            ExecuteZoom(control, action as ZoomActionModel);
                        }
                        else if (action is TranslateActionModel)
                        {
                            ExecuteTranslate(control, action as TranslateActionModel);
                        }
                        else if (action is PathActionModel)
                        {
                            ExecutePathAnimation(control, action as PathActionModel);
                        }
                        else if (action is SetZIndexModel)
                        {
                            ExecuteZIndexAnimation(control, action as SetZIndexModel);
                        }
                        else if (action is BrushViewBoxActionModel)
                        {
                            ExecuteViewBoxAnimation(control, action as BrushViewBoxActionModel);
                        }
                        else if (action is BrushRadialActionModel)
                        {
                            ExecuteBrushRadial(control, action as BrushRadialActionModel);
                        }
                        else if (action is BrushLinearActionModel)
                        {
                            ExecuteBrushLinear(control, action as BrushLinearActionModel);
                        }
                    }
                }
            }
            // Inicia la animación
            if (sbStoryBoard.Children.Count > 0)
            {
                // Lanza el evento de inicio de animación
                AnimationStart?.Invoke(this, EventArgs.Empty);
                // Arranca la animación
                sbStoryBoard.Begin();
            }
        }
Example #18
0
        private async void LaodTimeline()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                string url = "";
                switch (cb_OrderBy.SelectedIndex)
                {
                case 0:
                    url = string.Format("https://bangumi.bilibili.com/api/timeline_v4?access_key={0}&appkey={1}&area_id=1%2C2%2C-1&build=411005&date_after=6&date_before=6&mobi_app=android&platform=wp&see_mine=0&ts={2}000", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpan);
                    break;

                case 1:
                    url = string.Format("https://bangumi.bilibili.com/api/timeline_v4?access_key={0}&appkey={1}&area_id=1%2C2%2C-1&build=411005&date_after=6&date_before=6&mobi_app=android&platform=wp&see_mine=1&ts={2}000", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpan);
                    break;

                case 2:
                    url = string.Format("https://bangumi.bilibili.com/api/timeline_v4?access_key={0}&appkey={1}&area_id=2%2C-1&build=411005&date_after=6&date_before=6&mobi_app=android&platform=wp&see_mine=0&ts={2}000", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpan);
                    break;

                case 3:
                    url = string.Format("https://bangumi.bilibili.com/api/timeline_v4?access_key={0}&appkey={1}&area_id=1%2C-1&build=411005&date_after=6&date_before=6&mobi_app=android&platform=wp&see_mine=0&ts={2}000", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpan);
                    break;

                default:
                    break;
                }
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await WebClientClass.GetResults(new Uri(url));

                TimeLineModel m = JsonConvert.DeserializeObject <TimeLineModel>(results);
                if (m.code == 0)
                {
                    AllTimeLineModel model = new AllTimeLineModel();
                    var t0 = GetWeek(DateTime.Now);
                    model.today = new AllTimeLineModel()
                    {
                        Week = t0[0], WeekStr = t0[1], Date = t0[2], ls = new List <TimeLineModel>()
                    };
                    var n0 = GetWeek(DateTime.Now.AddDays(1));
                    model.next1 = new AllTimeLineModel()
                    {
                        Week = n0[0], WeekStr = n0[1], Date = n0[2], ls = new List <TimeLineModel>()
                    };
                    var n1 = GetWeek(DateTime.Now.AddDays(2));
                    model.next2 = new AllTimeLineModel()
                    {
                        Week = n1[0], WeekStr = n1[1], Date = n1[2], ls = new List <TimeLineModel>()
                    };
                    var n2 = GetWeek(DateTime.Now.AddDays(3));
                    model.next3 = new AllTimeLineModel()
                    {
                        Week = n2[0], WeekStr = n2[1], Date = n2[2], ls = new List <TimeLineModel>()
                    };
                    var n3 = GetWeek(DateTime.Now.AddDays(4));
                    model.next4 = new AllTimeLineModel()
                    {
                        Week = n3[0], WeekStr = n3[1], Date = n3[2], ls = new List <TimeLineModel>()
                    };
                    var n4 = GetWeek(DateTime.Now.AddDays(5));
                    model.next5 = new AllTimeLineModel()
                    {
                        Week = n4[0], WeekStr = n4[1], Date = n4[2], ls = new List <TimeLineModel>()
                    };
                    var n5 = GetWeek(DateTime.Now.AddDays(6));
                    model.next6 = new AllTimeLineModel()
                    {
                        Week = n5[0], WeekStr = n5[1], Date = n5[2], ls = new List <TimeLineModel>()
                    };
                    var p0 = GetWeek(DateTime.Now.AddDays(-6));
                    model.per1 = new AllTimeLineModel()
                    {
                        Week = p0[0], WeekStr = p0[1], Date = p0[2], ls = new List <TimeLineModel>()
                    };
                    var p1 = GetWeek(DateTime.Now.AddDays(-5));
                    model.per2 = new AllTimeLineModel()
                    {
                        Week = p1[0], WeekStr = p1[1], Date = p1[2], ls = new List <TimeLineModel>()
                    };
                    var p2 = GetWeek(DateTime.Now.AddDays(-4));
                    model.per3 = new AllTimeLineModel()
                    {
                        Week = p2[0], WeekStr = p2[1], Date = p2[2], ls = new List <TimeLineModel>()
                    };
                    var p3 = GetWeek(DateTime.Now.AddDays(-3));
                    model.per4 = new AllTimeLineModel()
                    {
                        Week = p3[0], WeekStr = p3[1], Date = p3[2], ls = new List <TimeLineModel>()
                    };
                    var p4 = GetWeek(DateTime.Now.AddDays(-2));
                    model.per5 = new AllTimeLineModel()
                    {
                        Week = p4[0], WeekStr = p4[1], Date = p4[2], ls = new List <TimeLineModel>()
                    };
                    var p5 = GetWeek(DateTime.Now.AddDays(-1));
                    model.per6 = new AllTimeLineModel()
                    {
                        Week = p5[0], WeekStr = p5[1], Date = p5[2], ls = new List <TimeLineModel>()
                    };
                    foreach (var item in m.result)
                    {
                        DateTime dt = DateTime.Parse(item.pub_date).Date;
                        if (dt == DateTime.Now.Date)
                        {
                            model.today.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-6).Date)
                        {
                            model.per1.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-5).Date)
                        {
                            model.per2.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-4).Date)
                        {
                            model.per3.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-3).Date)
                        {
                            model.per4.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-2).Date)
                        {
                            model.per5.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(-1).Date)
                        {
                            model.per6.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(1).Date)
                        {
                            model.next1.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(2).Date)
                        {
                            model.next2.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(3).Date)
                        {
                            model.next3.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(4).Date)
                        {
                            model.next4.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(5).Date)
                        {
                            model.next5.ls.Add(item);
                        }
                        if (dt == DateTime.Now.AddDays(6).Date)
                        {
                            model.next6.ls.Add(item);
                        }
                    }


                    this.DataContext = model;
                }
                else
                {
                    messShow.Show(m.message, 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867 || ex.HResult == -2147012889)
                {
                    messShow.Show("无法连接服务器,请检查你的网络连接", 3000);
                }
                else
                {
                    messShow.Show("读取放送表失败了", 3000);
                }
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
                await Task.Delay(1000);

                GeneralTransform generalTransform = st.TransformToVisual(gv_today);
                Point            point            = generalTransform.TransformPoint(new Point(0, 0));

                sv.ChangeView(null, Math.Abs(point.Y), null);
            }
        }
Example #19
0
        public ActionResult ClientEntry(LineModel model, string viewName = null)
        {
            if (System.Configuration.ConfigurationManager.AppSettings["UseHours"] != "1")
            {
                if (model.EditLine.EndTime <= model.EditLine.StartTime)
                {
                    ModelState.AddModelError("EditLine.EndTime", "End Time must be after start time");
                }
            }
            //Check Pieces
            if (ETSData.Helpers.CheckIfPiecesNeeded(ConfigurationManager.ConnectionStrings["ETSConnection"].ConnectionString, model.EditLine.ActivityCode) && model.EditLine.Pieces <= 0)
            {
                ModelState.AddModelError("EditLine.Pieces", "This Activity Code requires Pieces");
            }


            //Check Date
            if (!(model.EditLine.LineDate.Date >= model.WeekStart.Date && model.EditLine.LineDate.Date <= model.WeekStart.Date.AddDays(7)))
            {
                ModelState.AddModelError("EditLine.LineDate", "This Date must be within the week");
            }

            //Check total hours for this client
            double oldHours = ETSData.Helpers.GetHoursThisWeekForClient
                                  (ConfigurationManager.ConnectionStrings["ETSConnection"].ConnectionString,
                                  model.Client.Name_Key, model.EditLine.LineDate);
            double newHours = (model.EditLine.EndTime - model.EditLine.StartTime).TotalHours;

            if (oldHours + newHours > int.Parse(ConfigurationManager.AppSettings["HoursError"]))
            {
                ModelState.AddModelError("EditLine.EndTime", "Total hours can not exceed " + ConfigurationManager.AppSettings["HoursError"] + " hours for the day.");
            }

            if (ModelState.IsValid)
            {
                //Save the edited line
                using (TimeLineDB db = new TimeLineDB())
                {
                    System.Data.EntityState state = System.Data.EntityState.Modified;

                    model.EditLine.UserID = User.Identity.Name;
                    TimeLineModel temp = db.TimeLines.FirstOrDefault(x => x.Id == model.EditLine.Id);

                    if (temp == null)
                    {
                        temp  = new TimeLineModel();
                        state = System.Data.EntityState.Added;
                    }

                    temp.ActivityCode = model.EditLine.ActivityCode;
                    temp.ClientID     = model.Client.Name_Key;
                    temp.LineDate     = model.EditLine.LineDate;
                    temp.Pieces       = model.EditLine.Pieces;
                    temp.StartTime    = model.EditLine.StartTime;
                    temp.EndTime      = model.EditLine.EndTime;

                    if (System.Configuration.ConfigurationManager.AppSettings["UseHours"] == "1")
                    {
                        temp.Hours = model.EditLine.Hours;
                    }
                    else
                    {
                        temp.Hours = (decimal)(model.EditLine.EndTime - model.EditLine.StartTime).TotalHours;
                    }
                    temp.UserID   = model.EditLine.UserID;
                    temp.Comments = model.EditLine.Comments;

                    db.Entry(temp).State = state;
                    db.SaveChanges();
                }
            }

            model = SetupLineModel(model.Client.Name_Key, model.WeekStart.Date);

            GetWeekHourSummary(model, model.Client.Name_Key);
            return(viewName == null?View(model) : View(viewName, model));
        }
Example #20
0
        private async void RunTask()
        {
            var ble = CrossBluetoothLE.Current;

            var adapter = CrossBluetoothLE.Current.Adapter;

            List <IDevice> deviceList = new List <IDevice>();

            adapter.DeviceDiscovered += (s, a) =>
            {
                deviceList.Add(a.Device);
            };
            while (true)
            {
                await adapter.StartScanningForDevicesAsync();

                foreach (var device in deviceList.ToList())
                {
                    if (device.AdvertisementRecords.Count > 0)
                    {
                        try
                        {
                            Thread.Sleep(100);
                            await adapter.ConnectToDeviceAsync(device);
                        }
                        catch (DeviceConnectionException e)
                        {
                            continue;
                        }
                        var service = await device.GetServiceAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5"));

                        if (service != null)
                        {
                            string data = "";

                            var characteristic3 = await service.GetCharacteristicAsync(Guid.Parse("d8de624e-140f-4a22-8594-e2216b84a5f2"));

                            var bytes3 = await characteristic3.ReadAsync();

                            if (bytes3 == null)
                            {
                                continue;
                            }
                            data = System.Text.Encoding.UTF8.GetString(bytes3);

                            var person = await firebaseHelper.GetPersonByID(data);

                            if (data != "")
                            {
                                TimeLineModel TimeLine = new TimeLineModel();
                                TimeLine.Email          = person.Email;
                                TimeLine.Name           = person.Name;
                                TimeLine.Picture        = person.Picture;
                                TimeLine.TransportColor = "#76c2af";
                                TimeLine.Distance       = getDistance(device.Rssi, -69).ToString("0.00") + " M";
                                TimeLine.TransportType  = "Walking";
                                TimeLine.DateTime       = DateTime.UtcNow;
                                TimeLine.Time           = DateTime.UtcNow.ToLocalTime().ToString("h:mm tt");
                                await App.Database.AddTimeLineRecord(TimeLine);
                            }
                        }
                        await adapter.DisconnectDeviceAsync(device);
                    }
                }
                deviceList.Clear();
                Thread.Sleep(10000);
            }
        }
        /// <summary>
        ///		Carga los datos de un timeline
        /// </summary>
        internal TimeLineModel LoadTimeLine(PageModel page, MLNode nodeML)
        {
            TimeLineModel timeLine = new TimeLineModel(page, nodeML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));

            // Asigna los atributos
            AssignAttributesAction(nodeML, timeLine.Parameters, 0, 3);
            // Carga el contenido del timeLine
            foreach (MLNode childML in nodeML.Nodes)
            {
                ActionBaseModel action = null;

                // Obtiene la acción
                switch (childML.Name)
                {
                case ComicRepositoryConstants.TagActionShowImage:
                    action = new SetVisibilityActionModel(timeLine,
                                                          childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                          childML.Attributes[ComicRepositoryConstants.TagVisible].Value.GetBool(true),
                                                          childML.Attributes[ComicRepositoryConstants.TagOpacity].Value.GetDouble(),
                                                          childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionResize:
                    action = new ResizeActionModel(timeLine,
                                                   childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                   childML.Attributes[ComicRepositoryConstants.TagWidth].Value.GetDouble(),
                                                   childML.Attributes[ComicRepositoryConstants.TagHeight].Value.GetDouble(),
                                                   childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionRotate:
                    action = new RotateActionModel(timeLine,
                                                   childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                   childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5),
                                                   childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5),
                                                   childML.Attributes[ComicRepositoryConstants.TagAngle].Value.GetDouble(0),
                                                   childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionZoom:
                    action = new ZoomActionModel(timeLine,
                                                 childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                 childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5),
                                                 childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5),
                                                 childML.Attributes[ComicRepositoryConstants.TagScaleX].Value.GetDouble(1),
                                                 childML.Attributes[ComicRepositoryConstants.TagScaleY].Value.GetDouble(1),
                                                 childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionTranslate:
                    action = new TranslateActionModel(timeLine,
                                                      childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                      childML.Attributes[ComicRepositoryConstants.TagTop].Value.GetDouble(),
                                                      childML.Attributes[ComicRepositoryConstants.TagLeft].Value.GetDouble(),
                                                      childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionSetZIndex:
                    action = new SetZIndexModel(timeLine,
                                                childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true),
                                                childML.Attributes[ComicRepositoryConstants.TagZIndex].Value.GetInt(1));
                    break;

                case ComicRepositoryConstants.TagActionPath:
                    action = new PathActionModel(timeLine,
                                                 childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                 Mediator.CommonRepository.Normalize(childML.Value),
                                                 childML.Attributes[ComicRepositoryConstants.TagRotateWithTangent].Value.GetBool(true),
                                                 childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionViewBox:
                    action = new BrushViewBoxActionModel(timeLine,
                                                         childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                         Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewBox].Value),
                                                         Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewPort].Value),
                                                         Mediator.CommonRepository.ConvertTile(childML.Attributes[ComicRepositoryConstants.TagTileMode].Value),
                                                         childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionRadialBrush:
                    action = new BrushRadialActionModel(timeLine,
                                                        childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagCenter].Value),
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagOrigin].Value),
                                                        childML.Attributes[ComicRepositoryConstants.TagRadiusX].Value.GetDouble(),
                                                        childML.Attributes[ComicRepositoryConstants.TagRadiusY].Value.GetDouble(),
                                                        childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionLinearBrush:
                    action = new BrushLinearActionModel(timeLine,
                                                        childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagStart].Value),
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagEnd].Value),
                                                        Mediator.CommonRepository.GetSpreadMethod(childML.Attributes[ComicRepositoryConstants.TagSpread].Value),
                                                        childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;
                }
                // Si realmente se ha leído alguna acción
                if (action != null)
                {
                    // Asigna los atributos
                    AssignAttributesAction(childML, action.Parameters, timeLine.Parameters.Start, timeLine.Parameters.Duration);
                    // Asigna las funciones
                    LoadEases(action, childML);
                    // Añade la acción al timeline
                    timeLine.Actions.Add(action);
                }
            }
            // Devuelve el timeline
            return(timeLine);
        }
Example #22
0
 public async Task<ActionResult> TimeLine(int programId)
 {
     var result = new TimeLineModel().GetTerms(_dbContext, programId);
     var json = await JsonUtil.JsonResultAsync(result);
     return Content(json, "application/json");
 }