Esempio n. 1
0
        public IHttpActionResult GetContactrecordPrint([FromUri] ViewSearch viewSearch)
        {
            string Token  = Request.Headers.Authorization.Parameter;
            int    id     = JwtAuthUtil.GetId(Token);
            var    result = db.Contactrecords.AsQueryable();

            if (viewSearch.StudentId.HasValue)
            {
                result = result.Where(x => x.StudentId == viewSearch.StudentId);
            }
            if (viewSearch.StartDate.HasValue && viewSearch.EndDate.HasValue)
            {
                viewSearch.EndDate = viewSearch.EndDate.Value.AddDays(1);
                result             = result.Where(x => x.ContactDateTime >= viewSearch.StartDate && x.ContactDateTime <= viewSearch.EndDate);
            }
            var students = db.Students.AsQueryable();
            var data     = result.Select(x => new
            {
                Id              = x.Id,
                Time            = x.ContactDateTime,
                StudentName     = students.FirstOrDefault(y => y.Id == x.StudentId).Name,
                ContactGuardian = x.ContactGuardian,
                Teacher         = x.Teacher.Name,
                Method          = x.Method,
                Reason          = x.Reason,
                Results         = x.Results
            });

            return(Ok(new
            {
                code = 1,
                data = data
            }));
        }
Esempio n. 2
0
        public IHttpActionResult GetStudentsRecords([FromUri] ViewSearch viewSearch)
        {
            int id     = JwtAuthUtil.GetId(Request.Headers.Authorization.Parameter);
            var result = db.Records.Where(x => x.StudentId == id).AsQueryable();

            if (viewSearch.StartDate.HasValue && viewSearch.EndDate.HasValue)
            {
                //因為LessonDate設定為Datetime.today,所以不須再加一天,如下行處理
                //Search.EndDate = viewSearch.EndDate.Value.AddDays(1);
                result = result.Where(x => x.LessonDate >= viewSearch.StartDate && x.LessonDate <= viewSearch.EndDate);
            }
            if (viewSearch.Attendance.HasValue)
            {
                result = result.Where(x => x.Attendance == viewSearch.Attendance);
            }
            var teacher = db.Teachers.AsQueryable();
            var data    = result.Select(x => new
            {
                x.LessonDate,
                x.LessonOrder,
                x.Subject,
                Teacher    = teacher.FirstOrDefault(y => y.Id == x.RollCallTeacherId).Name,
                Attendance = x.Attendance.ToString()
            }).OrderBy(x => x.LessonDate).ToList();

            return(Ok(new
            {
                code = 1,
                data = data
            }));
        }
Esempio n. 3
0
        private static ViewConfiguration EnableSearchForPriceList(ViewConfiguration viewConfig)
        {
            if (viewConfig.EntityName == "gsc_cmn_extendedpricelistitem")
            {
                ViewSearch customSearch = viewConfig.Search;
                customSearch.Enabled = true;

                viewConfig.Search = customSearch;
            }
            return(viewConfig);
        }
        public async Task <IActionResult> Search(ViewSearch search)
        {
            ViewBag.PostsCount = await context.Posts.CountAsync();

            ViewBag.Posts = await(from p in context.Posts.Include(p => p.Category)
                                  where SearchPost(search.Query, p, p.Category)
                                  orderby p.CreatedAt descending
                                  select p)
                            .ToListAsync();

            return(View("Index", search));
        }
        private void SetRecord(DataRow row)
        {
            if (ViewSearch != null)
            {
                ViewSearch.RefreshEditor(true);
                return;
            }


            _txtId.EditValue          = row.Field <Object>(FieldNameId);
            _txtDescription.EditValue = row.Field <Object>(FieldNameDescription);
        }
Esempio n. 6
0
        internal void ViewPosition(RoleInGame role, FastonPosition fpResult, ref List <string> notifyMsg)
        {
            if (role.playerType == RoleInGame.PlayerType.player)
            {
                var        player = (Player)role;
                var        url    = player.FromUrl;
                ViewSearch sn     = new ViewSearch()
                {
                    c           = "ViewSearch",
                    WebSocketID = player.WebSocketID,
                    mctX        = fpResult.MacatuoX,
                    mctY        = fpResult.MacatuoY
                };

                var sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(sn);
                notifyMsg.Add(url);
                notifyMsg.Add(sendMsg);
            }
        }
        public async Task <IActionResult> AllBooks(int count = 0)
        {
            ViewSearch view = new ViewSearch();
            var        book = await _context.Books.Include(b => b.Category).ToListAsync();

            if (book == null)
            {
                return(NotFound());
            }
            view.Books = book.Select(b => new ViewBook
            {
                Id           = b.Id,
                Author       = b.Author,
                Name         = b.Name,
                CategoryName = b.Category.Name,
                Popular      = b.Popular,
                Price        = b.Price,
                Publish      = b.Publish
            }).Skip(count * 10).Take(10);

            return(View(view));
        }
Esempio n. 8
0
        public IHttpActionResult GetAdministrationNotification([FromUri] ViewSearch viewSearch)
        {
            if (viewSearch.StartDate.HasValue && viewSearch.EndDate.HasValue)
            {
                //因為LessonDate設定為Datetime.today,所以不須再加一天,如下行處理
                //Search.End
                //= viewSearch.EndDate.Value.AddDays(1);
                var groups = db.Records.Where(x => x.Attendance == AttendanceType.曠課 && x.LessonDate >= viewSearch.StartDate && x.LessonDate <= viewSearch.EndDate).GroupBy(x => x.StudentId);
                var record = groups.Select(x => new
                {
                    StudentId     = x.Key,
                    Class         = x.FirstOrDefault().Student.Class.ClassName,
                    StudentNumber = x.FirstOrDefault().Student.StudentNumber,
                    Name          = x.FirstOrDefault().Student.Name,
                    Address       = x.FirstOrDefault().Student.Address,
                    Guardian      = x.FirstOrDefault().Student.Guardian,
                    Times         = x.Count(),
                    result        = x.Select(y => new
                    {
                        LessonDate  = y.LessonDate,
                        LessonOrder = y.LessonOrder,
                        Subject     = y.Subject
                    })
                });
                return(Ok(new
                {
                    code = 1,
                    data = record
                }));
            }

            return(Ok(new
            {
                code = 5588,
                message = "請選擇起訖時間"
            }));
        }
Esempio n. 9
0
        public IHttpActionResult GetAdministrationRecordsList([FromUri] ViewSearch viewSearch)
        {
            var result = db.Records.AsQueryable();

            if (viewSearch.ClassId.HasValue)
            {
                result = result.Where(x => x.ClassId == viewSearch.ClassId);
            }
            if (viewSearch.StudentId.HasValue)
            {
                result = result.Where(x => x.StudentId == viewSearch.StudentId);
            }
            if (viewSearch.StartDate.HasValue && viewSearch.EndDate.HasValue)
            {
                //因為LessonDate設定為Datetime.today,所以不須再加一天,如下行處理
                //Search.EndDate = viewSearch.EndDate.Value.AddDays(1);
                result = result.Where(x => x.LessonDate >= viewSearch.StartDate && x.LessonDate <= viewSearch.EndDate);
            }
            if (viewSearch.Attendance.HasValue)
            {
                result = result.Where(x => x.Attendance == viewSearch.Attendance);
            }
            return(Ok(new
            {
                code = 1,
                data = result.Select(x => new
                {
                    Id = x.Id,
                    Class = x.Student.Class.ClassName,
                    Name = x.Student.Name,
                    Date = x.LessonDate,
                    LessonOrder = x.LessonOrder,
                    Attendance = x.Attendance.ToString()
                }).OrderBy(x => x.Date).ThenBy(x => x.LessonOrder).ToList()
            }));
        }
        public IActionResult AllBooks(ViewSearch model)
        {
            IEnumerable <Book> book = _context.Books.Include(b => b.Category)
                                      .Where(b => b.Name == model.Name);

            if (!string.IsNullOrWhiteSpace(model.Author))
            {
                book = book.Where(b => b.Author == model.Author);

                if (model.Popular > 0)
                {
                    book = book.Where(b => b.Popular >= model.Popular);
                    if (model.Publish != null)
                    {
                        book = book.Where(b => b.Publish == model.Publish);
                        if (model.MaxPrice >= model.MaxPrice)
                        {
                            book = book.Where(b => b.Price >= model.MinPrice && b.Price <= model.MaxPrice);
                        }
                    }
                }
            }

            model.Books = book.Select(b => new ViewBook
            {
                Id           = b.Id,
                Author       = b.Author,
                Name         = b.Name,
                CategoryName = b.CategoryName,
                Popular      = b.Popular,
                Price        = b.Price,
                Publish      = b.Publish
            });

            return(View(model));
        }
    public string ShowProductSearch()
    {
        CDynamicViewProduct ViewSearch;
        int currentpage = 0;
        int size        = 20;

        try
        {
            currentpage = int.Parse(Request.QueryString["page"].ToString());
            size        = int.Parse(Request.QueryString["size"].ToString());
            if (size > 40 || size < 10)
            {
                size = 20;
            }
        }
        catch
        {
        }
        try
        {
            text = Request.QueryString["text"].ToString();
            text = text.Replace('"', ' ');
            text = text.Trim();
            if (text.Length > 0)
            {
                if (text.Length > 30)
                {
                    text = text.Substring(0, 30);
                }
            }
        }
        catch
        {
            Response.Redirect("?menu=product");
        }
        if (Session["SSQSProduct"] == null)
        {
            ViewSearch = new CDynamicViewProduct();
            ViewSearch.SetTextSearch(text);
            ViewSearch.SetIdType((int)Application["idtypeproduct"]);
            ViewSearch.BuildWhere();
            ViewSearch.SetNumQuickSearch();
            ViewSearch.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
            Session["SSQSProduct"] = ViewSearch;
        }
        else
        {
            ViewSearch = (CDynamicViewProduct)Session["SSQSProduct"];
            ViewSearch.SetPageSize(size);
            if (!text.Equals(ViewSearch.GetTextSearch()))
            {
                ViewSearch.SetTextSearch(text);
                ViewSearch.BuildWhere();
                ViewSearch.SetNumQuickSearch();
            }
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
        }
        blpro = string.Format(blpro, ViewSearch.GetNumberRecord());
        Product_data product = ViewSearch.ProductQuickSearchFromTo();
        DataTable    table   = product.Tables[Product_data._table];
        int          numPro  = table.Rows.Count;
        Boolean      iseven  = true;

        if (ViewSearch.GetPages() > 1)
        {
            strpage1 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 1);
            strpage2 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 2);
        }
        else if (ViewSearch.GetPages() == 1)
        {
            strpage1 = ButtonCompare(true);
            strpage2 = ButtonCompare(false);
        }
        string strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";

        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        string id       = "";
        string name     = "";
        string url      = "";
        string price    = "";
        string warranty = "";

        for (int i = 0; i < numPro; i++)
        {
            id   = table.Rows[i][Product_data._id].ToString();
            name = table.Rows[i][Product_data._name].ToString();
            url  = table.Rows[i][Product_data._urlImage].ToString();
            if (url.Length > 0)
            {
                url = "image/img_pro/" + url;
            }
            else
            {
                url = "image/common/notimgpro.png";
            }
            price    = table.Rows[i][Product_data._price].ToString();
            warranty = table.Rows[i][Product_data._WarrantyMonth].ToString();
            if (iseven)
            {
                strProMain += "<tr><td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100' height='90' align='center'>";
                if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                {
                    strProMain += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                }
                strProMain += "<a href='?menu=dp&id=" + id + "'><img class='border_img' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td>" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                strProMain += "</td><td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td>";
                iseven      = false;
                if (i + 1 == numPro)
                {
                    strProMain += "<td class='bg_line4' width='11'></td>";
                    strProMain += "<td width='272'>&nbsp;</td>";
                    strProMain += "</tr>";
                }
            }
            else
            {
                strProMain += "<td class='bg_line4' width='11'></td>";
                strProMain += "<td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100' height='90' align='center'>";
                if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                {
                    strProMain += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                }
                strProMain += "<a href='?menu=dp&id=" + id + "'><img class='border_img' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td>" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                strProMain += "</td><td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td></tr>";
                if (i + 1 < numPro)
                {
                    strProMain += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>";
                }
                iseven = true;
            }
        }
        if (numPro == 0)
        {
            strProMain += "<tr><td colspan='3' align='center'>" + tnotpro + "</td></tr>";
        }
        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        strProMain += "</table>";
        return(strProMain);
    }
Esempio n. 12
0
    public string ShowProductSearch()
    {
        CdymanicViewCom ViewSearch;
        int             currentpage = 0;
        int             size        = 20;

        try
        {
            currentpage = int.Parse(Request.QueryString["page"].ToString());
            size        = int.Parse(Request.QueryString["size"].ToString());
            if (size > 40 || size < 10)
            {
                size = 20;
            }
        }
        catch
        {
        }
        if (Session["SSQSComponent"] == null)
        {
            ViewSearch = new CdymanicViewCom();
            ViewSearch.SetTextSearch(text);
            ViewSearch.SetIdType((int)Application["idtypeproduct"]);
            ViewSearch.BuildWhere();
            ViewSearch.SetNumComQuickSearch();
            ViewSearch.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
            Session["SSQSComponent"] = ViewSearch;
        }
        else
        {
            ViewSearch = (CdymanicViewCom)Session["SSQSComponent"];
            ViewSearch.SetPageSize(size);
            if (!text.Equals(ViewSearch.GetTextSearch()))
            {
                ViewSearch.SetTextSearch(text);
                ViewSearch.BuildWhere();
                ViewSearch.SetNumComQuickSearch();
            }
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
        }
        blpro = string.Format(blpro, "<u>" + ViewSearch.GetNumberRecord() + "</u>");
        Component_data product = ViewSearch.ComponentQuickSearchFromTo();
        DataTable      table   = product.Tables[Component_data._table];
        int            numPro  = table.Rows.Count;
        Boolean        iseven  = true;

        if (ViewSearch.GetPages() > 1)
        {
            strpage1 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 1);
            strpage2 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 2);
        }
        else if (ViewSearch.GetPages() == 1)
        {
            strpage1 = ButtonCompare(true);
            strpage2 = ButtonCompare(false);
        }
        string strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";

        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        string id     = "";
        string name   = "";
        string url    = "";
        string price  = "";
        float  rate   = (float)Application["ratepromain"];
        float  price1 = 1;
        string price2 = "";

        string warranty = "";
        string brand    = "";
        string note     = "";

        for (int i = 0; i < numPro; i++)
        {
            id    = table.Rows[i][Component_data._id].ToString();
            name  = table.Rows[i][Component_data._name].ToString();
            url   = table.Rows[i][Component_data._urlImage].ToString();
            brand = table.Rows[i][Component_data._brand].ToString();
            note  = table.Rows[i][Component_data._note].ToString();
            string namepro = name;
            namepro = namepro.Replace("/", "");
            namepro = namepro.Replace("#", "");
            namepro = namepro.Replace(":", "");
            namepro = namepro.Replace("\"", "");
            if (note.Length > 0)
            {
                note = note.Replace("\"", "");
                note = note.Replace('\r', ' ');
                note = note.Replace('\n', ' ');
            }
            else
            {
                note = name;
            }
            if (url.Length > 0)
            {
                url = "image/img_com/" + url;
            }
            else
            {
                url = "image/common/notimgpro.png";
            }

            price2 = table.Rows[i][Component_data._sellingPrice].ToString();
            price1 = float.Parse(table.Rows[i][Component_data._sellingPrice].ToString());
            price1 = price1 * rate;
            price  = price1.ToString("N").Split('.')[0];

            warranty = table.Rows[i][Component_data._warrantyMonth].ToString();
            if (iseven)
            {
                strProMain += "<tr><td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";

                strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />";

                strProMain += tprice + ": <span class='price'>";
                if (price.Equals("0"))
                {
                    strProMain += tupdate + "</span><br />";
                }
                else
                {
                    if (unitPrice.Equals("$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />";
                    }
                    else if (unitPrice.Equals("$$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />";
                    }
                    else
                    {
                        strProMain += price + " " + unitPrice + "</span><br />";
                    }
                    strProMain += "<span class='tvat'>" + strMVAT + "</span><br />";
                }

                strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>";

                strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td>";
                iseven      = false;
                if (i + 1 == numPro)
                {
                    strProMain += "<td class='bg_line4' width='11'></td>";
                    strProMain += "<td width='272'>&nbsp;</td>";
                    strProMain += "</tr>";
                }
            }
            else
            {
                strProMain += "<td class='bg_line4' width='11'></td>";
                strProMain += "<td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";

                strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />";

                strProMain += tprice + ": <span class='price'>";
                if (price.Equals("0"))
                {
                    strProMain += tupdate + "</span><br />";
                }
                else
                {
                    if (unitPrice.Equals("$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />";
                    }
                    else if (unitPrice.Equals("$$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />";
                    }
                    else
                    {
                        strProMain += price + " " + unitPrice + "</span><br />";
                    }
                    strProMain += "<span class='tvat'>" + strMVAT + "</span><br />";
                }



                strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>";

                strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td></tr>";
                if (i + 1 < numPro)
                {
                    strProMain += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>";
                }
                iseven = true;
            }
        }
        if (numPro == 0)
        {
            strProMain += "<tr><td colspan='3' align='center'>" + tnotpro + "</td></tr>";
        }
        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        strProMain += "</table>";
        return(strProMain);
    }
Esempio n. 13
0
        protected MainPageViewModelBase(IWorkbook workbook, ISynchronizationManager synchronizationManager, IStartupManager startupManager, IMessageBoxService messageBoxService, INotificationService notificationService, INavigationService navigationService, IPlatformService platformService, ITileManager tileManager, ITrackingManager trackingManager, ISpeechService speechService)
            : base(workbook, navigationService)
        {
            if (startupManager == null)
            {
                throw new ArgumentNullException(nameof(startupManager));
            }
            if (synchronizationManager == null)
            {
                throw new ArgumentNullException(nameof(synchronizationManager));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (tileManager == null)
            {
                throw new ArgumentNullException(nameof(tileManager));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (speechService == null)
            {
                throw new ArgumentNullException(nameof(speechService));
            }

            this.synchronizationManager = synchronizationManager;
            this.messageBoxService      = messageBoxService;
            this.notificationService    = notificationService;
            this.platformService        = platformService;
            this.tileManager            = tileManager;
            this.trackingManager        = trackingManager;
            this.speechService          = speechService;

            this.synchronizationManager.OperationStarted         += this.OnSyncStarted;
            this.synchronizationManager.OperationProgressChanged += this.OnSyncProgressChanged;
            this.synchronizationManager.OperationCompleted       += this.OnSyncOperationCompleted;
            this.synchronizationManager.OperationFailed          += this.OnSyncOperationFailed;
            this.synchronizationManager.PropertyChanged          += (s, e) =>
            {
                if (e.PropertyName == "ActiveService")
                {
                    this.RaisePropertyChanged("SyncPrioritySupport");
                }
            };

            this.Workbook.Settings.KeyChanged += this.OnSettingsChanged;
            this.Workbook.TaskAdded           += this.OnTaskAddded;

            this.Workbook.FoldersReordered  += this.OnFolderReordered;
            this.Workbook.ContextsReordered += this.OnContextReordered;

            this.addViewCommand      = new RelayCommand(this.AddViewExecute);
            this.addSmartViewCommand = new RelayCommand(this.AddSmartViewExecute);
            this.addFolderCommand    = new RelayCommand(this.AddFolderExecute);
            this.addContextCommand   = new RelayCommand(this.AddContextExecute);
            this.addTaskCommand      = new RelayCommand(this.AddTaskExecute);
            this.syncCommand         = new RelayCommand(this.SyncExecute);
            this.openSettingsCommand = new RelayCommand(this.OpenSettingsExecute);
            this.openDebugCommand    = new RelayCommand(this.OpenDebugExecute);
            this.clearSearchCommand  = new RelayCommand(this.ClearSearchExecute);
            this.speechCommand       = new RelayCommand(this.SpeechExecute);
            this.quickSpeechCommand  = new RelayCommand(this.QuickSpeechExecute);
            this.printCommand        = new RelayCommand(this.PrintExecute);
            this.shareCommand        = new RelayCommand(this.ShareExecute);
            this.editCommand         = new RelayCommand(this.EditExecute);

            this.deleteSelectionCommand      = new RelayCommand(this.DeleteSelectionExecute);
            this.completeSelectionCommand    = new RelayCommand(this.CompleteSelectionExecute);
            this.toggleTaskCompletionCommand = new RelayCommand <ITask>(this.ToggleTaskCompletionExecute);
            this.setPrioritySelectionCommand = new RelayCommand <string>(this.SetPrioritySelectionExecute);

            this.menuItems = new SortableObservableCollection <MenuItemViewModel>();

            bool hasViews      = this.Workbook.Views.Any(v => v.IsEnabled);
            bool hasSmartViews = this.Workbook.SmartViews.Any();
            bool hasFolders    = this.Workbook.Folders.Any();
            bool hasContexts   = this.Workbook.Contexts.Any();

            // create search view
            this.viewSearch       = new ViewSearch(this.Workbook);
            this.searchFolderItem = new FolderItemViewModel(this.Workbook, this.viewSearch);

            // load views
            foreach (var view in this.Workbook.Views.Where(f => f.IsEnabled))
            {
                this.menuItems.Add(new FolderItemViewModel(workbook, view));
            }

            // load smart views
            if (this.Workbook.SmartViews.Any())
            {
                if (hasViews)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorSmartViewId));
                }

                foreach (var smartview in this.Workbook.SmartViews)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, smartview));
                }
            }

            // load folders
            if (this.Workbook.Folders.Count > 0)
            {
                if (hasViews || hasSmartViews)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorFolderId));
                }

                foreach (var folder in this.Workbook.Folders)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, folder));
                }
            }

            // load contexts
            if (this.Workbook.Contexts.Count > 0)
            {
                if (hasViews || hasSmartViews || hasFolders)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorContextId));
                }

                foreach (var context in this.Workbook.Contexts)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, context));
                }
            }

            // load tags
            if (this.Workbook.Tags.Any())
            {
                if (hasViews || hasSmartViews || hasFolders || hasContexts)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorTagId));
                }

                foreach (var tag in this.Workbook.Tags)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, tag));
                }
            }
        }
Esempio n. 14
0
 static FolderItemViewModel()
 {
     searchTaskPredicate = ViewSearch.GetTaskSearchPredicate();
 }