public ActionResult ProjectEventPaymentGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Payment Request";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;
                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("Запрос на Оплату");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Reppers", new { id = BudgetID }));
        }
        private bool DeleteMyFile(int FileID, int EventID)
        {
            bool result             = true;
            ProjectEventService pes = new ProjectEventService();
            string dir     = ConfigurationManager.AppSettings["PhysicalPath"];
            string virpath = pes.GetProjectEventDocument(FileID).PhysicalVirtualPath;

            System.IO.File.Delete(dir + virpath);
            pes.DeleteDocument(FileID, EventID);
            return(result);
        }
Exemplo n.º 3
0
        public void ProjectEventService_GetAsync_ReturnsProjectEvents()
        {
            //Arrange
            var mockDbContextScopeFac = new Mock<IDbContextScopeFactory>();
            var mockDbContextScope = new Mock<IDbContextReadOnlyScope>();
            var mockEfDbContext = new Mock<EFDbContext>();
            mockDbContextScopeFac.Setup(x => x.CreateReadOnly(DbContextScopeOption.JoinExisting)).Returns(mockDbContextScope.Object);
            mockDbContextScope.Setup(x => x.DbContexts.Get<EFDbContext>()).Returns(mockEfDbContext.Object);

            var projectPerson1 = new Person { Id = "dummyUserId1", FirstName = "Firs1", LastName = "Last1" };

            var project1 = new Project { Id = "dummyId1", ProjectName = "Project1", ProjectAltName = "ProjectAlt1", IsActive_bl = true, ProjectCode = "CODE1", 
                ProjectPersons = new List<Person> { projectPerson1 } };

            var dbEntry1 = new ProjectEvent { Id = "dummyEntryId1", EventName = "Event1", EventAltName = "EventAlt1", IsActive_bl = false, Comments = "DummyComments1",
                 AssignedToProject = project1 };
            var dbEntry2 = new ProjectEvent { Id = "dummyEntryId2", EventName = "Event2", EventAltName = "EventAlt2", IsActive_bl = true, Comments = "DummyComments2",
                 AssignedToProject = project1 };
            var dbEntries = (new List<ProjectEvent> { dbEntry1, dbEntry2 }).AsQueryable();

            var mockDbSet = new Mock<DbSet<ProjectEvent>>();
            mockDbSet.As<IDbAsyncEnumerable<ProjectEvent>>().Setup(m => m.GetAsyncEnumerator()).Returns(new MockDbAsyncEnumerator<ProjectEvent>(dbEntries.GetEnumerator())); 
            mockDbSet.As<IQueryable<ProjectEvent>>().Setup(m => m.Provider).Returns(new MockDbAsyncQueryProvider<ProjectEvent>(dbEntries.Provider));
            mockDbSet.As<IQueryable<ProjectEvent>>().Setup(m => m.Expression).Returns(dbEntries.Expression);
            mockDbSet.As<IQueryable<ProjectEvent>>().Setup(m => m.ElementType).Returns(dbEntries.ElementType);
            mockDbSet.As<IQueryable<ProjectEvent>>().Setup(m => m.GetEnumerator()).Returns(dbEntries.GetEnumerator());
            mockDbSet.Setup(x => x.Include(It.IsAny<string>())).Returns(mockDbSet.Object);
            
            mockEfDbContext.Setup(x => x.ProjectEvents).Returns(mockDbSet.Object);

            var eventService = new ProjectEventService(mockDbContextScopeFac.Object, projectPerson1.Id);

            //Act
            var resultProjectEvents = eventService.GetAsync().Result;
            
            //Assert
            Assert.IsTrue(resultProjectEvents.Count == 1);
            Assert.IsTrue(resultProjectEvents[0].EventAltName.Contains("EventAlt2"));
        }
        public string WordAutoSave(int FileID, int EventID)
        {
            //depending on .ext it is either doc or excel.
            bool result             = true;
            ProjectEventService pes = new ProjectEventService();
            string dir     = ConfigurationManager.AppSettings["PhysicalPath"];
            string virpath = dir + pes.GetProjectEventDocument(FileID).PhysicalVirtualPath;

            try
            {
                object           filename    = virpath; //@"\\192.168.33.17\Download\IT\TEST.docx";
                Word.Application application = new Word.Application();
                application.Visible = true;
                //  int hello = application.Documents.Count();
                Word.Document document = application.Documents.Open(filename);
            }
            catch (Exception e)
            {
                return("Exception caught. " + e);
            }


            return(virpath);
        }
        public ActionResult ProjectEventAcceptanceMemoGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                //Create Event.
                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Letter to Grantee";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;

                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                //Generate Document.
                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("письмо о принятии отчета");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Index", "Events", null));

            // return RedirectToAction("Reppers", new { id = BudgetID });
        }
        public bool CreateFromTemplate(int TemplateDocsID, int ProjectID, int EventID, int?ReportPeriodID)
        {
            bool result = true;

            try
            {
                TemplateService ts      = new TemplateService();
                string          dir     = ConfigurationManager.AppSettings["PhysicalPath"];
                string          WordDoc = ts.GenerateDocumentFromTemplateName(TemplateDocsID, EventID, ProjectID, dir, ReportPeriodID);

                TemplateFile tfile = ts.GetTemplateDocument(TemplateDocsID).TemplateFile;

                string virtdir = "files/" + ProjectID.ToString() + "/"; // "files/A" + DateTime.Now.Year.ToString().Substring(2) + ProjectID.ToString() + "/";
                dir += virtdir.Replace("/", "\\");

                if (!(Directory.Exists(dir)))
                {
                    Directory.CreateDirectory(dir);
                }
                string fileformat = EventID.ToString() + "_" + ProjectID.ToString() + "_";
                int    i;
                for (i = 1; System.IO.File.Exists(dir + fileformat + i.ToString() + "." + tfile.fileextension); i++)
                {
                }
                System.IO.File.WriteAllText(dir + fileformat + i.ToString() + "." + tfile.fileextension, WordDoc);
                ProjectEventDocument docItem = new ProjectEventDocument();
                docItem.Author               = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;;
                docItem.CreatedDate          = DateTime.Now;
                docItem.fileextension        = tfile.fileextension;
                docItem.FileName             = fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.PhysicalAbsolutePath = dir + fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.PhysicalVirtualPath  = "\\" + virtdir.Replace("/", "\\") + fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.UpdatedDate          = docItem.CreatedDate;
                docItem.WebVirtualPath       = "/" + virtdir + fileformat + i.ToString() + "." + tfile.fileextension;
                //docItem.
                ProjectEventService pes = new ProjectEventService();
                pes.InsertDocument(docItem, EventID);

                TemplateDocument tdoc = ts.GetTemplateDocument(TemplateDocsID);
                if (tdoc != null)
                {
                    ProjectService projservice = new ProjectService();

                    //acknowledgement letter - completed project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("acknowledgement"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Completed");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //award letter - Active project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("award"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Active");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //close out letter - Closed project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("close") && tdoc.TemplateDocName.ToLower().Contains("out"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Closed");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            //  projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //suspended letter - Active project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("suspended"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Suspended");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //reject letter - Rejected project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("reject"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Rejected");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 7
0
        // GET: /ProposalInfo/View/1
        public ActionResult View(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            Project _project = projservice.GetProposalInfo(id.Value); //This will happen In MenuITEM Controller orgservice.GetOrganizationGeneralOfCurrentProposal(id.Value);

            if (_project.ProjectInfo == null)                         //no ProjectInfo.
            {
                _project.ProjectInfo = new ProjectInfo();             //give some instance.
            }


            FinanceResults finres = new FinanceResults(id.Value);

            // ViewData["moneyLeft"] = finres.Project_TotalAmountLeftFromAwardAmount();
            ViewData["CashOnHand"]      = finres.Project_TotalCashOnHand();
            ViewData["MoneyTransfered"] = finres.Project_TotalMoneyTransferedFromAwardAmount();


            //    ViewData["StaffRoleList"] = new SelectList(projservice.GetOrgStaffRoles(), "RoleID", "RoleTitle");


            //   ViewData["ProgramAreaList"] = new SelectList(projservice.GetProgramAreaList(), "ProgramAreaCodeID", "ProgramAreaText");


            ViewData["ProposalID"] = id.Value;



            //Get Events with Type: Site Visit
            //Get All Events with Type: Narrative Reports

            ProjectEventService        evnts     = new ProjectEventService();
            IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value);
            int sitevisits        = 0;
            int narrativereport   = 0;
            int narrativeaccepted = 0;
            int narrativerejected = 0;

            //   Project Info=> Accepted Narrative Reports Rename to Current Grant Evaluation
            //Count Evaluation not Narrative Report.
            foreach (ProjectEvent projevnt in projevnts)
            {
                if (projevnt.EventType.EventTypeName == "Site Visit" || projevnt.EventType.EventTypeName == "Site visit")
                {
                    sitevisits++;
                }

                //if (projevnt.EventDescription != null)
                //{
                //    if (projevnt.EventDescription.Contains("Site Visit") || projevnt.EventDescription.Contains("Site visit"))
                //    {
                //        sitevisits++;
                //    }
                //}



                if (projevnt.EventType.EventTypeName == "Evaluation Report" || projevnt.EventType.EventTypeName == "Evaluation report")
                //|| projevnt.EventDescription.Contains("Narrative Report") || projevnt.EventDescription.Contains("Narrative report"))
                {
                    narrativereport++;

                    if (projevnt.ReportStatus.HasValue)
                    {
                        if (projevnt.ReportStatus.Value == 1)
                        {
                            narrativeaccepted++;
                        }
                        if (projevnt.ReportStatus.Value == 0)
                        {
                            narrativerejected++;
                        }
                    }
                }
            }

            ViewData["NumberOfSiteVisits"]        = sitevisits;
            ViewData["NumberOfAcceptedNarrative"] = narrativeaccepted;
            ViewData["NumberOfRejectedNarrative"] = narrativerejected;

            // EventType evType = new EventType();
            //  evType.EventTypeName
            //  evntTypeSer.GetEventTypeList();



            return(View(_project));
        }
/*
 *      private bool DeleteMyFile(int FileID, int EventID)
 *      {
 *          bool result = true;
 *          ProjectEventService pes = new ProjectEventService();
 *          string dir = ConfigurationManager.AppSettings["PhysicalPath"];
 *          string virpath = pes.GetProjectEventDocument(FileID).PhysicalVirtualPath;
 *          System.IO.File.Delete(dir + virpath);
 *          pes.DeleteDocument(FileID, EventID);
 *          return result;
 *      }
 *
 */
        //
        // GET: /Event/

        public ActionResult Index(int?id)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            EventTypeService    et  = new EventTypeService();
            ProjectEventService pes = new ProjectEventService();
            SSPStaffService     sss = new SSPStaffService();

            ViewData["ddlEventType"] = new SelectList(et.GetEventTypeList(), "EventTypeID", "EventTypeName", 31);
            //Session["ProposalID"] = "1";
            int ProposalID = Session["ProposalID"] != null?int.Parse(Session["ProposalID"].ToString()) : 0;

            ViewData["ProjectID"] = ProposalID;
            IEnumerable <ProjectEvent> pe = pes.GetProjectEventList(ProposalID);

            IEnumerable <SSPStaff> slist = sss.GetSSPStaffListForProject(ProposalID);



            List <SelectListItem> selects = new List <SelectListItem>();

            if (slist != null)
            {
                //this gets users who is in keyassosiactions.
                foreach (var item in slist)
                {
                    selects.Add(new SelectListItem()
                    {
                        Value = item.SSPStaffID.ToString(), Text = item.FirstName + " " + item.LastName + " " + item.MiddleName
                    });
                }

                //-----------------This chunk added in order not
                // =========to lose previous eventHolder.
                //next step we must add users who is participating in this project if they don't exist,
                //this will cover users who was deleted from keyassociations, but did particular event.
                //How to do that? we go through all Events, get event Holders and compare HolderID agains slist. if does not exist we add.
                foreach (ProjectEvent e in pe)
                { //check if staff in event inside DropDown.
                    SelectListItem sitem = (from x in selects
                                            where x.Value.ToString() == e.EventHolderID.ToString()
                                            select x).FirstOrDefault();

                    if (sitem == null) //no staff.
                    {
                        SSPStaff staff = null;

                        //get that user from repository
                        if (e.EventHolderID.HasValue)
                        {
                            staff = sss.GetAccountByID(e.EventHolderID.Value);
                        }

                        //insert.
                        if (staff != null)
                        {
                            selects.Add(new SelectListItem()
                            {
                                Value = staff.SSPStaffID.ToString(), Text = staff.FirstName + " " + staff.LastName + " " + staff.MiddleName
                            });
                        }
                    }
                }
                //----------------------
            }
            ViewData["SSPStaffList"] = selects;
            ProjectService projservice = new ProjectService();;
            Project        _project;

            _project = projservice.GetProposalInfo(ProposalID);
            List <SelectListItem> reportperiods = new List <SelectListItem>();

            try
            {
                foreach (var item in _project.Budget.ReportPeriodListRs)
                {
                    reportperiods.Add(new SelectListItem()
                    {
                        Value = item.ReportPeriodID.ToString(),
                        Text  = (item.PeriodStart.HasValue ? item.PeriodStart.Value.ToShortDateString() : "") + " - " +
                                (item.PeriodEnd.HasValue ? item.PeriodEnd.Value.ToShortDateString() : "")
                    });
                }
            } catch (Exception ex) {}
            ViewData["ReportPeriodList"] = reportperiods;
            if (id.HasValue == true)
            {
                ViewData["selectedID"] = id;
            }
            return(View(pe));
        }
        public ActionResult UserAction(string useraction, ProjectEvent o, string SSPOrGrantee)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            ProjectEventService pes = new ProjectEventService();

            switch (useraction.ToLower())
            {
            case "generate file from template":
                if (o.EventID > 0)
                {
                    pes.Update(o);
                }
                return(RedirectToAction("SelectTemplate", new { ProjectID = o.ProjectID, EventID = o.EventID, EventTypeID = o.EventTypeID, ReportPeriodID = o.ReportPeriodID }));

            case "insert":
                // if (o.EventID > 0)
                pes.Insert(o);
                break;
                return(RedirectToAction("SelectTemplate", new { ProjectID = o.ProjectID, EventID = o.EventID, o.ReportPeriodID }));

            case "update":
                if (o.EventID > 0)       //there must be eventID and user must be logged in.
                {
                    pes.Update(o);
                    if (Request.Files.Count != 0)
                    {
                        for (int i = 0; i < Request.Files.Count; i++)
                        {
                            if (!String.IsNullOrEmpty(Request.Files[i].FileName))
                            {
                                string FileKey;
                                FileKey = Request.Files.GetKey(i);
                                string FileID;
                                FileID = FileKey.Replace("files_", "");

                                string dir = ConfigurationManager.AppSettings["PhysicalPath"];

                                //string MyString="";
                                //int FileLen;
                                //System.IO.Stream MyStream;

                                //FileLen = Request.Files[i].ContentLength;
                                //byte[] input = new byte[FileLen];

                                //// Initialize the stream.
                                //MyStream = Request.Files[i].InputStream;

                                //// Read the file into the byte array.
                                //MyStream.Read(input, 0, FileLen);

                                //// Copy the byte array into a string.
                                //for (int Loop1 = 0; Loop1 < FileLen; Loop1++)
                                //    MyString = MyString + input[Loop1].ToString();
                                string fileOriginalName = Request.Files[i].FileName;
                                string ExtenSion        = Path.GetExtension(fileOriginalName);

                                if (FileID == "0")
                                {
                                    #region InsertNewDocument


                                    ProjectEventDocument myDoc = new ProjectEventDocument();
                                    string virtdir             = "files/" + o.ProjectID.ToString() + "/";//"files/A" + DateTime.Now.Year.ToString().Substring(2) + o.ProjectID.ToString() + "/";
                                    dir += virtdir.Replace("/", "\\");
                                    if (!(Directory.Exists(dir)))
                                    {
                                        Directory.CreateDirectory(dir);
                                    }
                                    string fileformat = o.EventID.ToString() + "_" + o.ProjectID.ToString() + "_";
                                    int    fi;
                                    //checking other file names to come up with new file number.
                                    for (fi = 1; System.IO.File.Exists(dir + fileformat + fi.ToString() + ExtenSion); fi++)
                                    {
                                    }



                                    Request.Files[i].SaveAs(dir + fileformat + fi.ToString() + ExtenSion);

                                    myDoc.Author               = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;
                                    myDoc.CreatedDate          = DateTime.Now;
                                    myDoc.fileextension        = ExtenSion.Replace(".", ""); //needs "doc"
                                    myDoc.FileName             = fileformat + fi.ToString() + ExtenSion;
                                    myDoc.PhysicalAbsolutePath = dir + fileformat + fi.ToString() + ExtenSion;
                                    myDoc.PhysicalVirtualPath  = "\\" + virtdir.Replace("/", "\\") + fileformat + fi.ToString() + ExtenSion;
                                    myDoc.UpdatedDate          = myDoc.CreatedDate;
                                    myDoc.WebVirtualPath       = "/" + virtdir + fileformat + fi.ToString() + ExtenSion;
                                    pes.InsertDocument(myDoc, o.EventID);
                                    #endregion
                                }
                                else
                                {
                                    #region Update Document      //with different file extension it won't work.
                                    //get object by fileid
                                    //update object

                                    ProjectEventDocument myDoc = pes.GetProjectEventDocument(int.Parse(FileID));
                                    //System.IO.File.WriteAllText(dir + myDoc.PhysicalVirtualPath, MyString);

                                    if (myDoc.fileextension == ExtenSion.Replace(".", ""))      //if extensions are the same then Update allowed.
                                    {
                                        Request.Files[i].SaveAs(dir + myDoc.PhysicalVirtualPath);
                                        myDoc.Author      = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;;
                                        myDoc.UpdatedDate = DateTime.Now;
                                        pes.UpdateProjectEventDocument(myDoc);
                                    }
                                    //get object by fileid
                                    //update object
                                    #endregion
                                }
                            }
                        }
                    }
                }
                break;

            case "delete":
                string mydir = Request.MapPath("~");
                foreach (var item in o.ProjectEventDocs)
                {
                    try
                    {
                        System.IO.File.Delete(mydir + item.ProjectEventDocument.PhysicalVirtualPath);
                    }
                    catch (Exception ex) { }
                    DeleteMyFile(item.ProjectEventDocumentID, o.EventID);
                }
                pes.Delete(o.EventID);
                break;
            }

            return(RedirectToAction("Index", new { id = o.EventID }));
        }
Exemplo n.º 10
0
 //Constructors---------------------------------------------------------------------------------------------------------//
 public ProjectEventSrvController(ProjectEventService projectEventService)
 {
     this.projectEventService = projectEventService;
 }
        public ActionResult test()
        {
            // var View = new Dictionary<ProgramAreaID, Dictionary<RegionID, numberOfItems>>();
            var                 MView       = new Dictionary <FirstVs, Dictionary <int, numberOfItems> >();
            ProjectService      prj         = new ProjectService();
            ProjectEventService evnts       = new ProjectEventService();
            AppDropDownsService appDropDown = new AppDropDownsService();

            int?id = 1;
            IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value);

            int sitevisits = 0;
            IEnumerable <Project> projects = prj.getAllProjects().Where(p => p.CompetitionCode != null && p.ProgramArea != null);
            //int sitevisits = projevnts.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2);
            //  if (projevnt.EventType.EventTypeName == "Site Visit" || projevnt.EventType.EventTypeName == "Site visit")
            // projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2
            var projSiteVisits = new Dictionary <Project, int>();
            var MView2         = new Dictionary <int, List <VsContainer> >();

            //==========1===========
            if (projects != null)
            {
                var query = projects
                            .GroupBy(g => new    //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested.
                {
                    g.CompetitionCode.CompetCodeID,
                    g.ProgramArea.ProgramAreaCodeID
                })
                            .Select(group => new VsContainer() //Select all Grouped into VersusContainer.
                {
                    ProjId      = group.Select(i => i.ProjectID).ToList(),
                    Field1      = group.Key.CompetCodeID.Value,
                    Field2      = group.Key.ProgramAreaCodeID.Value,
                    iAmount     = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)),
                    dAmount     = group.Select(i => i.ProjectID).Count(),
                    Field1Title = group.Select(i => i.CompetitionCode.CompetitionCodeList.CodeText).FirstOrDefault(),
                    Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault()
                });

                List <VsContainer> vsc = query.ToList();   //test.

                MView2.Add(1, vsc);
            }
            // var View = new Dictionary<ProgramAreaID, Dictionary<CompCodeID, numberOfItems>>();
            //======var MView = new Dictionary<FirstVs, Dictionary<int, numberOfItems>>();=========================



            //==========2===========
            IEnumerable <Project> projects2 = prj.getAllProjects().Where(p => p.Organization.Addresses.FirstOrDefault().Region != null && p.ProgramArea != null);

            if (projects != null)
            {
                var query = projects2
                            .GroupBy(g => new    //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested.
                {
                    g.Organization.Addresses.FirstOrDefault().DDIDRegion,
                    g.ProgramArea.ProgramAreaCodeID
                })
                            .Select(group => new VsContainer() //Select all Grouped into VersusContainer.
                {
                    ProjId      = group.Select(i => i.ProjectID).ToList(),
                    Field1      = group.Key.DDIDRegion.Value,
                    Field2      = group.Key.ProgramAreaCodeID.Value,
                    iAmount     = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)),
                    dAmount     = group.Select(i => i.ProjectID).Count(),
                    Field1Title = group.Select(i => i.Organization.Addresses.FirstOrDefault().RegionList.DDNAME).FirstOrDefault(),
                    Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault()
                });

                List <VsContainer> vsc = query.ToList();   //test.

                MView2.Add(2, vsc);
            }
            //===============================


            //foreach (var p in projects)
            //{
            //    sitevisits += p.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2);
            //    projSiteVisits.Add(p, sitevisits);
            //    sitevisits = 0;
            //}


            //IEnumerable<RegionList> regions = appDropDown.GetRegionList();

            //foreach (RegionList reg in regions)
            //{

            //}

            //foreach (var v in View)
            //{
            //    foreach(var vl in v.Value)
            //    {
            //       int hello = vl.Value.numOfgrant;
            //    }
            //}

            //AppDropDownsService ServiceDDL = new AppDropDownsService();
            //var SubView = new Dictionary<int, numberOfItems>();
            //var SubView2 = new Dictionary<int, numberOfItems>();
            //// ==============
            //var number1 = new numberOfItems();
            //number1.numOfgrant = 35;
            //number1.numOfvisits = 40;
            //SubView.Add(1, number1);

            //var number2 = new numberOfItems();
            //number2.numOfgrant = 15;
            //number2.numOfvisits = 10;

            //SubView.Add(4, number2);

            //var number3 = new numberOfItems();
            //number3.numOfgrant = 25;
            //number3.numOfvisits = 60;

            //SubView.Add(8, number3);


            //var number4 = new numberOfItems();
            //number4.numOfgrant = 125;
            //number4.numOfvisits = 60;

            //var number5 = new numberOfItems();
            //number5.numOfgrant = 125;
            //number5.numOfvisits = 60;

            //SubView2.Add(3, number4);
            //SubView2.Add(2, number5);

            //FirstVs fv = new FirstVs();
            //fv.id = 1;
            //fv.title = "ECD";
            //MView.Add(fv, SubView);

            //FirstVs fv2 = new FirstVs();
            //fv2.id = 2;
            //fv2.title = "Youth";
            //MView.Add(fv2, SubView2);

            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["MView"]          = MView;
            ViewData["MView2"]         = MView2;
            ViewData["Region"]         = ServiceDDL.GetRegionList();
            ViewData["CompletionCode"] = ServiceDDL.GetCompetitionCodeList();
            ViewData["ProgramArea"]    = ServiceDDL.GetProgramAreaList();

            return(View());
        }
        public Dictionary <int, List <VsContainer> > SiteVisitReports(IEnumerable <Project> prj)
        {
            // var View = new Dictionary<ProgramAreaID, Dictionary<RegionID, numberOfItems>>();
            var MView = new Dictionary <FirstVs, Dictionary <int, numberOfItems> >();
            // ProjectService prj = new ProjectService();
            ProjectEventService evnts       = new ProjectEventService();
            AppDropDownsService appDropDown = new AppDropDownsService();

            int?id = 1;
            IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value);

            int sitevisits = 0;
            //Filter OUT NULL STUFF!
            IEnumerable <Project> projects = prj.Where(p => p.CompetitionCode != null && p.ProgramArea != null);

            var projSiteVisits = new Dictionary <Project, int>();
            var MView2         = new Dictionary <int, List <VsContainer> >();

            //==========1===========
            if (projects != null)
            {
                var query = projects
                            .GroupBy(g => new    //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested.
                {
                    g.CompetitionCode.CompetCodeID,
                    g.ProgramArea.ProgramAreaCodeID
                })
                            .Select(group => new VsContainer() //Select all Grouped into VersusContainer.
                {
                    ProjId      = group.Select(i => i.ProjectID).ToList(),
                    Field1      = group.Key.CompetCodeID.Value,
                    Field2      = group.Key.ProgramAreaCodeID.Value,
                    iAmount     = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)),
                    dAmount     = group.Select(i => i.ProjectID).Count(),
                    Field1Title = group.Select(i => i.CompetitionCode.CompetitionCodeList.CodeText).FirstOrDefault(),
                    Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault()
                });

                List <VsContainer> vsc = query.ToList();   //test.

                MView2.Add(1, vsc);
            }
            // var View = new Dictionary<ProgramAreaID, Dictionary<CompCodeID, numberOfItems>>();
            //======var MView = new Dictionary<FirstVs, Dictionary<int, numberOfItems>>();=========================


            //==========2===========
            //Filter OUT NULL STUFF!
            IEnumerable <Project> projects2 = prj.Where(p => p.Organization != null && p.Organization.Addresses != null && p.Organization.Addresses.FirstOrDefault().Region != null && p.ProgramArea != null);

            if (projects != null)
            {
                var query = projects2
                            .GroupBy(g => new    //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested.
                {
                    g.Organization.Addresses.FirstOrDefault().DDIDRegion,
                    g.ProgramArea.ProgramAreaCodeID
                })
                            .Select(group => new VsContainer() //Select all Grouped into VersusContainer.
                {
                    ProjId      = group.Select(i => i.ProjectID).ToList(),
                    Field1      = group.Key.DDIDRegion.Value,
                    Field2      = group.Key.ProgramAreaCodeID.Value,
                    iAmount     = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)),
                    dAmount     = group.Select(i => i.ProjectID).Count(),
                    Field1Title = group.Select(i => i.Organization.Addresses.FirstOrDefault().RegionList.DDNAME).FirstOrDefault(),
                    Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault()
                });

                List <VsContainer> vsc = query.ToList();   //test.

                MView2.Add(2, vsc);
            }
            //===============================

            return(MView2);
        }
Exemplo n.º 13
0
 public ReservationController()
 {
     service  = new ReservationService();
     service1 = new ProjectEventService();
     service2 = new UserService();
 }
Exemplo n.º 14
0
 public EventProjectController()
 {
     service = new ProjectEventService();
 }
        //
        // GET: /Tasks/

        public ActionResult Index(int?filter, int?alltasks)
        {
            /*if (Session["ProposalID"] == null)
             * {
             *  return RedirectToAction("Search", "ProposalInfo");
             * }*/

            ProjectEventService pes = new ProjectEventService();
            //int ProjectID = Session["ProposalID"] != null ? int.Parse(Session["ProposalID"].ToString()) : 0;
            IEnumerable <ProjectEvent> pe;

            // List<ProjectEvent> pelist;
            if (alltasks.HasValue)
            {
                if (alltasks.Value == 0)
                {
                    pe = pes.GetProjectEventListScheduledMy(session.CurrentUser.SSPStaffID);
                }
                else
                {
                    pe = pes.GetProjectEventListScheduled();
                    //  pelist = pes.GetProjectEventListScheduled().ToList();
                }
            }
            else
            {
                pe = pes.GetProjectEventListScheduledMy(session.CurrentUser.SSPStaffID);
            }


            SSPStaffService        sss   = new SSPStaffService();
            IEnumerable <SSPStaff> slist = sss.GetSSPStaffList();

            ViewData["staff"] = slist;

            IEnumerable <ProjectEvent> OverdueEvents = from p in pe
                                                       where p.ScheduledDate < DateTime.Now
                                                       select p;
            IEnumerable <ProjectEvent> OverdueGrantEvents = from p in OverdueEvents
                                                            where p.SSPOrGrantee == true
                                                            select p;
            IEnumerable <ProjectEvent> OverdueNonGrantEvents = from p in OverdueEvents
                                                               where p.SSPOrGrantee == false
                                                               select p;

            ViewData["OverdueGrantEvents"]    = OverdueGrantEvents;
            ViewData["OverdueNonGrantEvents"] = OverdueNonGrantEvents;
            List <SelectListItem> ff = new List <SelectListItem>();

            ff.Add(new SelectListItem()
            {
                Value = "-1", Text = "ALL"
            });
            ff.Add(new SelectListItem()
            {
                Value = "1", Text = "OVERDUE SCHEDULED GRANT EVENTS"
            });
            ff.Add(new SelectListItem()
            {
                Value = "2", Text = "OVERDUE SCHEDULED NON-GRANT EVENTS"
            });
            ViewData["FilterItems"] = ff.AsEnumerable();

            List <SelectListItem> ev = new List <SelectListItem>();

            ev.Add(new SelectListItem()
            {
                Value = "0", Text = "My Tasks"
            });
            ev.Add(new SelectListItem()
            {
                Value = "1", Text = "All Tasks"
            });

            ViewData["iftasks"] = ev.AsEnumerable();

            if (alltasks.HasValue)
            {
                ViewData["task"] = alltasks.Value;
            }
            else
            {
                ViewData["task"] = 0;
            }

            if (filter.HasValue)
            {
                ViewData["filter"] = filter.Value;
            }
            else
            {
                ViewData["filter"] = -1;
            }
            return(View());
        }