Пример #1
0
        private void BtnClearWatch_Click(object sender, RoutedEventArgs e)
        {
            ShowHelper.ClearWatched(_currentShows);

            Shows.GetShowService.Save();
            ShowAllEpisodesFromShows();
        }
Пример #2
0
        private void importButton_Click(object sender, EventArgs e)
        {
            var rows = dataGridView.SelectedRows;

            if (rows.Count == 0)
            {
                return;
            }

            var show = rows[0].DataBoundItem as Show;

            if (show == null)
            {
                return;
            }

            using (var context = DbContextFactory.GetDbContext())
            {
                if (!context.Shows.Any(s => s.ApiId == show.ApiId))
                {
                    context.Entry(show).State = System.Data.Entity.EntityState.Added;
                    context.SaveChanges();
                }
                else
                {
                    show = context.Shows.FirstOrDefault(s => s.ApiId == show.ApiId);
                }

                Task.Run(() => ShowHelper.UpdateShows(context, new[] { show }, new TvmazeApi(), CancellationToken.None)).Wait();
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Data.DatabaseConnection.DbContextFactory.SetConnectionProvider(new SqlConnectionProvider());
            Data.Helpers.ImportFileHelper.Import(@"E:\PayEx\shows.csv");

            context = DbContextFactory.GetDbContext();
            ShowHelper.UpdateShows(context, context.Shows.ToArray(), new TvmazeApi(), CancellationToken.None, new ProgressReport());

            Console.ReadLine();

            context.Dispose();
        }
Пример #4
0
        private void SearchSeries_Click(object sender, RoutedEventArgs e)
        {
            names.Clear();
            seasons.Clear();
            string input = SearchInput.Text;

            output = ShowHelper.SearchShowByName(input);
            foreach (KeyValuePair <int, string> item in output)
            {
                names.Add(item.Value);
            }
            ResultsList.Items.Refresh();
        }
Пример #5
0
        private void startSyncButton_Click(object sender, EventArgs e)
        {
            startSyncButton.Enabled = false;

            context = DbContextFactory.GetDbContext();
            var progressReport = new ProgressReport();

            progressReport.ProgressReported += ProgressReport_ProgressReported;

            source = new CancellationTokenSource();

            Task.Run(() => ShowHelper.UpdateShows(context, context.Shows.ToArray(), new TvmazeApi(), source.Token, progressReport));
        }
        public void ShouldSortEpisodesByDate()
        {
            List <ShowControl> shows = new List <ShowControl>();
            ShowControl        show  = CreateBasicShowcontrol("ShowOne");

            shows.Add(show);

            show.Episodes.Add(CreateEpisode("a", new DateTime(2018, 06, 15)));
            show.Episodes.Add(CreateEpisode("b", new DateTime(2019, 07, 15)));

            List <EpisodeControl> orderEpisodes = ShowHelper.GetOrderEpisodes(shows);

            orderEpisodes.Should().HaveCount(2);
            orderEpisodes[0].PublishedDate.Year.Should().Be(2019);
            orderEpisodes[1].PublishedDate.Year.Should().Be(2018);
        }
        public void ShouldSortLocalFilesEpisodesByUrl()
        {
            List <ShowControl> shows = new List <ShowControl>();
            ShowControl        show  = CreateBasicShowcontrol("ShowOne");

            show.ShowOption.ShowStorage = ShowStorageType.LocalStorage;
            shows.Add(show);

            show.Episodes.Add(CreateEpisode("b", new DateTime(2018, 06, 15)));
            show.Episodes.Add(CreateEpisode("a", new DateTime(2019, 07, 15)));

            List <EpisodeControl> orderEpisodes = ShowHelper.GetOrderEpisodes(shows);

            orderEpisodes.Should().HaveCount(2);
            orderEpisodes[0].PodcastURL.Should().Be("a");
            orderEpisodes[0].PublishedDate.Year.Should().Be(2019);
            orderEpisodes[1].PodcastURL.Should().Be("b");
            orderEpisodes[1].PublishedDate.Year.Should().Be(2018);
        }
Пример #8
0
        public static void RemoveTasks()
        {
            string text = $"Index|{"Opis".PadLeft(padsSize[0], ' ')}|" +
                          $"{"Data rozpoczęcia".PadLeft(padsSize[1], ' ')}|" +
                          $"{"Data zakończenia".PadLeft(padsSize[2], ' ')}|";

            Console.WriteLine(text);
            Console.WriteLine("`".PadLeft(padsSize[0] + padsSize[1] + padsSize[2] + 8, '`'));

            int index = 1;

            foreach (Task item in tasksList)
            {
                Console.Write($"{index}".PadLeft(5, ' '));
                ShowHelper.ShowTask(item, padsSize);
                index++;
            }


            index = 1;
            try
            {
                Console.Write("Podaj indeks zdarzenia które chcesz usunąć: ");
                int removeIndex = Convert.ToInt32(Console.ReadLine());

                foreach (Task item in tasksList)
                {
                    if (index == removeIndex)
                    {
                        tasksList.Remove(item);
                        CommentsSuccess("Usunięcie");
                        return;
                    }
                }

                consoleClr.WriteLine("Podany indeks nie istnieje.", ConsoleColor.Red);
            }
            catch (FormatException)
            {
                consoleClr.WriteLine("Niepoprawny format wpisanego indeksu.", ConsoleColor.Red);
            }
        }
Пример #9
0
        private void SeasonList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            episodes.Clear();
            var selectedSeason = SeasonList.SelectedItem as string;

            foreach (KeyValuePair <int, string> item in seasonDic)
            {
                if (item.Value == selectedSeason)
                {
                    idSeason = item.Key;
                }
            }
            List <string> copy = ShowHelper.ShowEpisodes(idSeason);

            foreach (string item in copy)
            {
                episodes.Add(item);
            }
            EpisodeList.Items.Refresh();
        }
Пример #10
0
        private void ResultsList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var selectedShow = ResultsList.SelectedItem as string;

            foreach (KeyValuePair <int, string> item in output)
            {
                if (item.Value == selectedShow)
                {
                    id = item.Key;
                }
            }
            seasonDic = ShowHelper.ShowSeason(id);
            ShowInfo info = new ShowInfo(id);

            foreach (KeyValuePair <int, string> item in seasonDic)
            {
                seasons.Add(item.Value);
            }
            SeriesInfo.Text = info.ToString();
            names.Clear();
            ResultsList.Items.Refresh();
            SeasonList.Items.Refresh();
        }
Пример #11
0
        public void ShouldClearAllWatchShows()
        {
            List <ShowControl> shows = new List <ShowControl>();
            ShowControl        show  = CreateBasicShowcontrol("ShowOne");

            shows.Add(show);
            ShowControl showB = CreateBasicShowcontrol("ShowTwo");

            shows.Add(showB);

            show.Episodes.Add(CreateEpisode("a", new DateTime(2018, 06, 15)));
            showB.Episodes.Add(CreateEpisode("b", new DateTime(2019, 07, 15)));

            ShowHelper.ClearWatched(shows);

            shows[0].Episodes[0].Hidden.Should().BeFalse();
            shows[0].Episodes[0].PlayedLength.Should().Be(0);
            shows[0].Episodes[0].PlayedLengthScaled.Should().Be(0);

            shows[1].Episodes[0].Hidden.Should().BeFalse();
            shows[1].Episodes[0].PlayedLength.Should().Be(0);
            shows[1].Episodes[0].PlayedLengthScaled.Should().Be(0);
        }
Пример #12
0
        public static void ShowTasks()
        {
            Console.WriteLine("Legenda:");
            consoleClr.WriteLine("- nie rozpoczęte zdarzenie", ConsoleColor.DarkCyan)
            .WriteLine("- rozpoczęte zdarzenie", ConsoleColor.DarkYellow)
            .WriteLine("- zakończone zdarzenie", ConsoleColor.DarkGreen)
            .WriteLine("- ważne nie rozpoczęte zdarzenie", ConsoleColor.Cyan)
            .WriteLine("- ważne rozpoczęte zdarzenie", ConsoleColor.Yellow)
            .WriteLine("- ważne zakończone zdarzenie", ConsoleColor.Green);



            string text = $"{"Opis".PadLeft(padsSize[0], ' ')}|" +
                          $"{"Data rozpoczęcia".PadLeft(padsSize[1], ' ')}|" +
                          $"{"Data zakończenia".PadLeft(padsSize[2], ' ')}|";

            Console.WriteLine(text);
            Console.WriteLine("`".PadLeft(padsSize[0] + padsSize[1] + padsSize[2] + 3, '`'));

            foreach (Task item in tasksList)
            {
                ShowHelper.ShowTask(item, padsSize);
            }
        }
Пример #13
0
        /// <summary>
        /// 绑定数据源数据到控件
        /// </summary>
        public override void BindDataToUI(MedDrugGraph control, Dictionary <string, System.Data.DataTable> dataSources)
        {
            if (!dataSources.ContainsKey("AnesthesiaEvent"))
            {
                throw new NotImplementedException(string.Format("在数据源中未找到名为{0}的表AnesInformations.AnesthesiaEventDataTable,请添加此绑定数据源!", "AnesthesiaEvent"));
            }

            bool     isEndAnes = false;
            DateTime dtEndAnes = DateTime.Now;
            List <MED_ANESTHESIA_EVENT> anesEvent = new ModelHandler <MED_ANESTHESIA_EVENT>().FillModel(dataSources["AnesthesiaEvent"]);

            // 针对麻醉系统:持续用药随手术状态自动结束
            if (ApplicationConfiguration.DrugAutoStop && ExtendAppContext.Current.EventNo == "0")
            {
                string          operText   = ApplicationConfiguration.DrugAutoStopOperationStatus;
                OperationStatus operStatus = OperationStatusHelper.OperationStatusFromString(operText);
                if (operStatus != OperationStatus.None)
                {
                    string    timeField = OperationStatusHelper.GetTimeFieldName(operStatus);
                    DataTable dtMaster  = DataContext.GetCurrent().GetData("MED_OPERATION_MASTER");
                    if (dtMaster != null && dtMaster.Rows.Count > 0 && !dtMaster.Rows[0].IsNull(timeField))
                    {
                        int status = 0;
                        if (!dtMaster.Rows[0].IsNull("OPER_STATUS_CODE"))
                        {
                            status = Convert.ToInt32(dtMaster.Rows[0]["OPER_STATUS_CODE"]);
                        }

                        // 出手术室 35
                        // 时如果没有持续用药没有自动结束的话,会按照配置的时间自动结束
                        if (status >= (int)operStatus)
                        {
                            dtEndAnes = (DateTime)dtMaster.Rows[0][timeField];
                            isEndAnes = true;

                            bool changed = false;
                            if (anesEvent != null)
                            {
                                anesEvent.ForEach(row =>
                                {
                                    if (row.DURATIVE_INDICATOR.HasValue && row.DURATIVE_INDICATOR == 1 && !row.END_TIME.HasValue)
                                    {
                                        row.END_TIME = dtEndAnes;
                                        changed      = true;
                                    }
                                });
                            }

                            if (changed)
                            {
                                AnesInfoService.ClientInstance.UpadteAnesthesiaEvent(anesEvent);
                            }
                        }
                    }
                }
            }

            control.Curves.Clear();
            control.ProLongedDrugShowType = (ProLongedDrugUnitShowType)ApplicationConfiguration.ProLonged;
            control.DrugShowType          = (NormalDrugUnitShowType)ApplicationConfiguration.DrugShow;
            control.StartTime             = PagerSetting.PageTimeSpan.StartDateTime;
            control.EndTime          = PagerSetting.PageTimeSpan.EndDateTime;
            control.MinStartDateTime = PagerSetting.PageTimeSpan.OrigiStartDateTime;
            control.MaxEndDateTime   = PagerSetting.PageTimeSpan.OrigiEndDateTime;

            //joysola测试用

            //ApplicationConfiguration.PassedDrugPointFormat = "DOSAGE;DOSAGE_UNITS;(;PERFORM_SPEED;SPEED_UNIT;+;CONCENTRATION;CONCENTRATION_UNIT;\r\n;ADMINISTRATOR;)";//DOSAGE_UNITS,ADMINISTRATOR
            //ApplicationConfiguration.PassedDrugNameFormat = "EVENT_ITEM_NAME;(;DOSAGE_UNITS;);SPEED_UNIT;CONCENTRATION_UNIT;ADMINISTRATOR";//SPEED_UNIT

            //ApplicationConfiguration.DrugPointShowFormat = "DOSAGE;;PERFORM_SPEED;SPEED_UNIT;CONCENTRATION;CONCENTRATION_UNIT;";//DOSAGE_UNITS,ADMINISTRATOR
            //ApplicationConfiguration.DrugNameShowFormat = "EVENT_ITEM_NAME;DOSAGE_UNITS;;CONCENTRATION_UNIT;ADMINISTRATOR";//SPEED_UNIT
            //ApplicationConfiguration.DrugPointMarkFormat = "(;);+;\r\n;";
            //ApplicationConfiguration.DrugNameMarkFormat = "(;)";

            //modified by joysola on 2018-2-26、3-5、4-8 新增获取用药显示、持续用药显示、药名显示
            control.DrugPointShowFormatType     = ShowHelper.GetDrugPointShowFormat(ApplicationConfiguration.PassedDrugPointFormat);
            control.DrugProLongedShowFormatType = ShowHelper.GetDrugPointShowFormat(ApplicationConfiguration.PassedDrugProLongedFormat);
            control.DrugNameShowFormatType      = ShowHelper.GetDrugNameShowFormat(ApplicationConfiguration.PassedDrugNameFormat);

            control.PointMarkFormat     = ShowHelper.GetDrugPointMarkFormat(ApplicationConfiguration.PassedDrugPointFormat);
            control.ProLongedMarkFormat = ShowHelper.GetDrugPointMarkFormat(ApplicationConfiguration.PassedDrugProLongedFormat);
            control.NameMarkFormat      = ShowHelper.GetDrugNameMarkFormat(ApplicationConfiguration.PassedDrugNameFormat);
            //modified end
            string        itemClass = "," + GetAnesClassTypeString(AnesClassType.InOxygen) + ",";
            List <string> titles    = new List <string>();

            if (anesEvent != null)
            {
                anesEvent.ForEach(row =>
                {
                    if (!string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                        !string.IsNullOrEmpty(row.EVENT_ITEM_NAME) &&
                        itemClass.Contains("," + row.EVENT_CLASS_CODE + ",") &&
                        !titles.Contains(row.EVENT_ITEM_NAME))
                    {
                        // 只显示持续用药
                        if (control.IsOnlyLine)
                        {
                            if (row.DURATIVE_INDICATOR.HasValue && row.DURATIVE_INDICATOR == 1)
                            {
                                titles.Add(row.EVENT_ITEM_NAME);
                            }
                        }
                        else
                        {
                            titles.Add(row.EVENT_ITEM_NAME);
                        }
                    }
                });

                itemClass += this.GetAnesClassTypeString(AnesClassType.AnesDrug) + "," + this.GetAnesClassTypeString(AnesClassType.MixLiquid) + ",";
                anesEvent.ForEach(row =>
                {
                    if (!string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                        !string.IsNullOrEmpty(row.EVENT_ITEM_NAME) &&
                        itemClass.Contains("," + row.EVENT_CLASS_CODE + ",") &&
                        !titles.Contains(row.EVENT_ITEM_NAME))
                    {
                        // 只显示持续用药
                        if (control.IsOnlyLine)
                        {
                            if (row.DURATIVE_INDICATOR.HasValue && row.DURATIVE_INDICATOR == 1)
                            {
                                titles.Add(row.EVENT_ITEM_NAME);
                            }
                        }
                        else
                        {
                            titles.Add(row.EVENT_ITEM_NAME);
                        }
                    }
                });

                itemClass += "C,";// 用药
                // 泵注用药部分暂时隐藏,请勿删除
                //anesEvent.ForEach(row =>
                //{
                //    if (!string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                //        !string.IsNullOrEmpty(row.EVENT_ITEM_NAME) &&
                //        row.EVENT_CLASS_CODE.Equals("C") &&
                //        !titles.Contains(row.EVENT_ITEM_NAME)
                //        && !string.IsNullOrEmpty(row.ADMINISTRATOR) && row.ADMINISTRATOR.Equals("泵注"))
                //    {
                //        if (control.IsOnlyLine)
                //        {
                //            if (row.DURATIVE_INDICATOR.HasValue && row.DURATIVE_INDICATOR == 1)
                //            {
                //                titles.Add(row.EVENT_ITEM_NAME);
                //            }
                //        }
                //        else
                //        {
                //            titles.Add(row.EVENT_ITEM_NAME);
                //        }
                //    }
                //});

                anesEvent.ForEach(row =>
                {
                    if (!string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                        !string.IsNullOrEmpty(row.EVENT_ITEM_NAME) &&
                        row.EVENT_CLASS_CODE.Equals("C") &&
                        !titles.Contains(row.EVENT_ITEM_NAME))
                    {
                        if (control.IsOnlyLine)
                        {
                            if (row.DURATIVE_INDICATOR.HasValue && row.DURATIVE_INDICATOR == 1)
                            {
                                titles.Add(row.EVENT_ITEM_NAME);
                            }
                        }
                        else
                        {
                            titles.Add(row.EVENT_ITEM_NAME);
                        }
                    }
                });

                // 只显示持续用药时进行排序
                if (control.IsOnlyLine && titles.Count < control.LineParameters.Count)
                {
                    anesEvent.OrderBy(x => x.START_TIME).ToList().ForEach(row =>
                    {
                        if (!string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                            !string.IsNullOrEmpty(row.EVENT_ITEM_NAME) &&
                            itemClass.Contains("," + row.EVENT_CLASS_CODE + ",") &&
                            !titles.Contains(row.EVENT_ITEM_NAME))
                        {
                            if (row.DURATIVE_INDICATOR == null || row.DURATIVE_INDICATOR != 1)
                            {
                                titles.Add(row.EVENT_ITEM_NAME);
                            }
                        }
                    });
                }
            }

            // 最多只能显示 drugGraph.LineParameters.Count 行,多的显示在明细中
            int index = 0;

            if (titles.Count > 0)
            {
                DateTime sysDatetTime = this.GetSysDateTime();
                foreach (string title in titles)
                {
                    index++;

                    // 目前为 行
                    if (index > control.LineParameters.Count)
                    {
                        break;
                    }

                    MedDrugCurve curve = new MedDrugCurve(title, GetRandomColor());
                    List <MED_ANESTHESIA_EVENT> eventRows = anesEvent.Where(x => !string.IsNullOrEmpty(x.EVENT_ITEM_NAME) &&
                                                                            x.EVENT_ITEM_NAME.Equals(title)).ToList();
                    if (eventRows != null && eventRows.Count > 0)
                    {
                        eventRows.ForEach(row =>
                        {
                            if (row.START_TIME.HasValue &&
                                !string.IsNullOrEmpty(row.EVENT_CLASS_CODE) &&
                                itemClass.Contains("," + row.EVENT_CLASS_CODE + ","))
                            {
                                DateTime dt;
                                bool isArrow        = false;
                                PointType pointType = this.GetDecimalValue(row.DURATIVE_INDICATOR) == 1 ?
                                                      PointType.ProLonged : PointType.SinglePoint;
                                if (row.END_TIME.HasValue)
                                {
                                    dt = row.END_TIME.Value;
                                }
                                else if (pointType == PointType.ProLonged)
                                {
                                    DateTime dtUse = isEndAnes ? dtEndAnes : sysDatetTime;
                                    dt             = (dtUse > PagerSetting.PageTimeSpan.OrigiEndDateTime) ? dtUse : PagerSetting.PageTimeSpan.OrigiEndDateTime;
                                    isArrow        = !isEndAnes;
                                }
                                else
                                {
                                    dt = row.START_TIME.Value;
                                }

                                MedDrugPoint point = curve.AddPoint(row.START_TIME.Value, this.GetDoubleValue(row.DOSAGE),
                                                                    this.GetStringValue(row.DOSAGE_UNITS),
                                                                    this.GetDoubleValue(row.CONCENTRATION),
                                                                    this.GetStringValue(row.CONCENTRATION_UNIT),
                                                                    this.GetStringValue(row.ADMINISTRATOR),
                                                                    dt,
                                                                    this.GetDoubleValue(row.PERFORM_SPEED),
                                                                    this.GetStringValue(row.SPEED_UNIT), pointType);
                                point.IsArrow = isArrow;
                                _drugRows.Add(point, row);
                            }
                        });

                        control.Curves.Add(curve);
                    }
                }
            }
        }
Пример #14
0
 private void ShowAllEpisodesFromShows()
 {
     _podcasts.Clear();
     ShowEpisodes(ShowHelper.GetOrderEpisodes(_currentShows));
 }
Пример #15
0
        private void ShowAllEpisodesForGroup(string groupName)
        {
            _currentShows = ShowHelper.GetAllShowsFromGroup(groupName);

            ShowAllEpisodesFromShows();
        }