Ejemplo n.º 1
0
        public ActionResult SearchAdminPopulateIndex()
        {
            try
            {
                //***********PROJECTS **************************
                //first reset all projects to unsynced
                db_EECIP.ResetT_OE_PROJECTS_Unsynced();

                //then send all unsynced projects to Azure
                AzureSearch.PopulateSearchIndexProject(null);


                //***********AGENCIES  **************************
                //reset all agencies to unsynced
                db_Ref.ResetT_OE_ORGANIZATION_Unsynced();

                //then send all unsynced agencies to Azure
                AzureSearch.PopulateSearchIndexOrganization(null);


                //***********ENT SERVICES  **************************
                db_EECIP.ResetT_OE_ORGANIZATION_ENT_SVCS_Unsynced();

                //then send all unsynced agencies to Azure
                AzureSearch.PopulateSearchIndexEntServices(null);


                //***********PEOPLE  **************************
                db_Accounts.ResetT_OE_USERS_Unsynced();

                //then send all unsynced agencies to Azure
                AzureSearch.PopulateSearchIndexUsers(null);


                //***********FORUM TOPICS  **************************
                db_Forum.UpdateTopic_SetAllUnsynced();

                //then send all unsynced agencies to Azure
                AzureSearch.PopulateSearchIndexForumTopic(null);


                TempData["Success"] = "Search index populated.";
            }
            catch (Exception ex)
            {
                TempData["Error"] = ex.ToString().SubStringPlus(0, 100);
            }

            return(RedirectToAction("SearchAdmin", "Admin"));
        }
Ejemplo n.º 2
0
        public ActionResult SearchAdminPopulateIndex()
        {
            string err = "";

            try
            {
                AzureSearch.PopulateSearchIndexProject(null);
                TempData["Success"] = "Search index populated.";
            }
            catch (Exception ex)
            {
                err = ex.ToString();
            }

            TempData["Error"] = err;
            return(RedirectToAction("SearchAdmin", "Admin"));
        }
Ejemplo n.º 3
0
        public ActionResult AddProjectOrg(vmDashboardAddProjectOrg model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            if (model.selAgency != null)
            {
                List <T_OE_ORGANIZATION> projectOrgs = db_EECIP.GetT_OE_PROJECT_ORGS_ByProject(model.project.PROJECT_IDX);
                if (projectOrgs != null && projectOrgs.Count > 0)
                {
                    //CHECK PERMISSIONS
                    if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgList(UserIDX, projectOrgs))
                    {
                        db_EECIP.InsertUpdateT_OE_PROJECT_ORGS(model.project.PROJECT_IDX, model.selAgency.ConvertOrDefault <Guid>(), UserIDX);

                        //now update the Azure search
                        db_EECIP.InsertUpdatetT_OE_PROJECTS(model.project.PROJECT_IDX, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, true, false);
                        AzureSearch.PopulateSearchIndexProject(model.project.PROJECT_IDX);

                        TempData["Success"] = "Update successful.";
                        return(RedirectToAction("ProjectDetails", "Dashboard", new { id = model.project.PROJECT_IDX }));
                    }
                    else
                    {
                        TempData["Error"] = "You do not have rights to edit this project";
                    }
                }
                else
                {
                    TempData["Error"] = "No project found";
                }
            }
            else
            {
                TempData["Error"] = "Please select an agency";
            }

            return(RedirectToAction("AddProjectOrg", "Dashboard", new { id = model.project.PROJECT_IDX }));
        }
        public ActionResult ProjectEdit(vmDashboardProjectDetails model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            //CHECK PERMISSIONS
            if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgIDX(UserIDX, model.project.ORG_IDX.ConvertOrDefault <Guid>()))
            {
                //update project data
                Guid?newProjID = db_EECIP.InsertUpdatetT_OE_PROJECTS(model.project.PROJECT_IDX, model.project.ORG_IDX, model.project.PROJ_NAME ?? "",
                                                                     model.project.PROJ_DESC ?? "", model.project.MEDIA_TAG, model.project.START_YEAR ?? -1, model.project.PROJ_STATUS ?? "",
                                                                     model.project.DATE_LAST_UPDATE ?? -1, model.project.RECORD_SOURCE ?? "", model.project.PROJECT_URL ?? "", model.project.MOBILE_IND,
                                                                     model.project.MOBILE_DESC ?? "", model.project.ADV_MON_IND, model.project.ADV_MON_DESC ?? "", model.project.BP_MODERN_IND,
                                                                     model.project.BP_MODERN_DESC ?? "", model.project.COTS ?? "", model.project.VENDOR ?? "", model.project.PROJECT_CONTACT ?? "", model.project.PROJECT_CONTACT_IDX ?? -1, true, false, UserIDX, null, true);

                if (newProjID != null)
                {
                    Guid newProjID2 = newProjID.ConvertOrDefault <Guid>();
                    //update program area tags
                    db_EECIP.DeleteT_OE_PROJECT_TAGS(newProjID2, "Program Area");
                    foreach (string expertise in model.SelectedProgramAreas ?? new List <string>())
                    {
                        db_EECIP.InsertT_OE_PROJECT_TAGS(newProjID2, "Program Area", expertise);
                    }


                    //update project url
                    db_EECIP.DeleteT_OE_PROJECTS_URL(newProjID2);
                    foreach (T_OE_PROJECT_URLS urls in model.sProjectUrlList ?? new List <T_OE_PROJECT_URLS>())
                    {
                        db_EECIP.InsertT_OE_PROJECTS_URL(newProjID2, urls.PROJECT_URL, urls.PROJ_URL_DESC);
                    }


                    //update feature tags
                    db_EECIP.DeleteT_OE_PROJECT_TAGS(newProjID2, "Project Feature");
                    foreach (string feature in model.SelectedFeatures ?? new List <string>())
                    {
                        db_EECIP.InsertT_OE_PROJECT_TAGS(newProjID2, "Project Feature", feature);
                    }

                    //update files
                    if (model.files != null)
                    {
                        foreach (HttpPostedFileBase file in model.files)
                        {
                            byte[] fileBytes = null;

                            if (file != null)
                            {
                                using (Stream inputStream = file.InputStream)
                                {
                                    MemoryStream memoryStream = inputStream as MemoryStream;
                                    if (memoryStream == null)
                                    {
                                        memoryStream = new MemoryStream();
                                        inputStream.CopyTo(memoryStream);
                                    }
                                    fileBytes = memoryStream.ToArray();

                                    //insert to database
                                    db_EECIP.InsertUpdateT_OE_DOCUMENTS(null, fileBytes, file.FileName, "project", file.ContentType, fileBytes.Length, model.FileDescription, null, newProjID2, null, UserIDX);
                                }


                                //award profile badge
                                if (db_Accounts.UserCanEditOrgIDX(UserIDX, model.project.ORG_IDX.ConvertOrDefault <Guid>()))
                                {
                                    db_Forum.EarnBadgeController(UserIDX, "ProjectDocument");
                                }
                            }
                        }
                    }

                    //award badges for new project
                    if (newProjID2 != model.project.PROJECT_IDX)//new case
                    {
                        db_Forum.EarnBadgeAddProject(UserIDX);
                    }

                    //now update the Azure search
                    AzureSearch.PopulateSearchIndexProject(newProjID2);

                    TempData["Success"] = "Update successful.";
                    return(RedirectToAction("ProjectDetails", "Dashboard", new { id = newProjID2, returnURL = model.ReturnURL }));
                }
                else
                {
                    TempData["Error"] = "Error updating data.";
                }
            }
            else
            {
                TempData["Error"] = "You don't have permissions to edit this project.";
            }

            return(RedirectToAction(model.ReturnURL ?? "Projects", new { selAgency = model.project.ORG_IDX }));
        }
Ejemplo n.º 5
0
        public ActionResult ImportData(vmAdminImportData model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            //set dictionaries used to store stuff in memory
            Dictionary <string, int> colMapping = new Dictionary <string, int>();  //identifies the column number for each field to be imported

            //initialize variables
            bool headInd  = true;
            bool anyError = false;

            //loop through each row
            foreach (string row in model.IMPORT_BLOCK.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
            {
                //split row's columns into string array
                string[] cols = row.Split(new char[] { '\t' }, StringSplitOptions.None);

                if (cols.Length > 0) //skip blank rows
                {
                    if (headInd)
                    {
                        //**********************************************************
                        //HEADER ROW - LOGIC TO DETERMINE WHAT IS IN EACH COLUMN
                        //**********************************************************
                        colMapping = Utils.GetColumnMapping("P", cols);

                        headInd = false;

                        model.projects = new List <ProjectImportType>();
                    }
                    else
                    {
                        //**********************************************************
                        //NOT HEADER ROW - READING IN VALUES
                        //**********************************************************
                        var colList        = cols.Select((value, index) => new { value, index });
                        var colDataIndexed = (from f in colMapping
                                              join c in colList on f.Value equals c.index
                                              select new
                        {
                            _Name = f.Key,
                            _Val = c.value
                        }).ToList();

                        Dictionary <string, string> fieldValuesDict = new Dictionary <string, string>();  //identifies the column number for each field to be imported

                        //loop through all values and insert to list
                        foreach (var c in colDataIndexed)
                        {
                            fieldValuesDict.Add(c._Name, c._Val);
                        }

                        //VALIDATE ROW AND INSERT TO LOCAL OBJECT
                        ProjectImportType p = db_EECIP.InsertOrUpdate_T_OE_PROJECT_local(UserIDX, fieldValuesDict);
                        if (p.VALIDATE_CD == false)
                        {
                            anyError = true;
                        }

                        model.projects.Add(p);
                    }
                }
            } //end each row

            //if no errors, just import. otherwise
            if (!anyError)
            {
                foreach (ProjectImportType ps in model.projects)
                {
                    //import projects
                    T_OE_PROJECTS x          = ps.T_OE_PROJECT;
                    Guid?         ProjectIDX = db_EECIP.InsertUpdatetT_OE_PROJECTS(x.PROJECT_IDX, x.ORG_IDX, x.PROJ_NAME, x.PROJ_DESC, x.MEDIA_TAG, x.START_YEAR, x.PROJ_STATUS,
                                                                                   x.DATE_LAST_UPDATE, x.RECORD_SOURCE, x.PROJECT_URL, x.MOBILE_IND, x.MOBILE_DESC, x.ADV_MON_IND, x.ADV_MON_DESC, x.BP_MODERN_IND,
                                                                                   x.BP_MODERN_DESC, x.COTS, x.VENDOR, x.PROJECT_CONTACT, null, true, false, UserIDX, x.IMPORT_ID, true);

                    //import features
                    if (ps.FEATURES != null)
                    {
                        foreach (string f in ps.FEATURES.Split('|'))
                        {
                            if (f.Length > 0)
                            {
                                db_EECIP.InsertT_OE_PROJECT_TAGS(ProjectIDX.ConvertOrDefault <Guid>(), "Project Feature", f, UserIDX);
                            }
                        }
                    }

                    //import program areas
                    if (ps.PROGRAM_AREAS != null)
                    {
                        foreach (string f in ps.PROGRAM_AREAS.Split('|'))
                        {
                            if (f.Length > 0)
                            {
                                db_EECIP.InsertT_OE_PROJECT_TAGS(ProjectIDX.ConvertOrDefault <Guid>(), "Program Area", f, UserIDX);
                            }
                        }
                    }
                }

                //update azure search
                AzureSearch.PopulateSearchIndexProject(null);

                //clear form
                model.IMPORT_BLOCK  = "";
                model.projects      = null;
                TempData["Success"] = "Data imported successfully";
            }
            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult ProjectEdit(vmDashboardProjectDetails model)
        {
            int UserIDX = db_Accounts.GetUserIDX();


            model.ProjectOrgs = db_EECIP.GetT_OE_PROJECT_ORGS_ByProject(model.project.PROJECT_IDX);

            //for insert case, project orgs will not have org yet
            if (model.ProjectOrgs.Count == 0 && model.NewProjOrgIDX != null)
            {
                model.ProjectOrgs.Add(db_Ref.GetT_OE_ORGANIZATION_ByID(model.NewProjOrgIDX.ConvertOrDefault <Guid>()));
            }

            //CHECK PERMISSIONS
            if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgList(UserIDX, model.ProjectOrgs))
            {
                //plain text version of project description
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(model.ProjectRichDesc);
                string projDescPlain = "";
                foreach (HtmlAgilityPack.HtmlNode node in doc.DocumentNode.SelectNodes("//text()"))
                {
                    projDescPlain += node.InnerText;
                }

                //determine record source
                if (db_Accounts.UserCanEditOrgList(UserIDX, model.ProjectOrgs))
                {
                    model.project.RECORD_SOURCE = "Agency supplied";
                }

                //update project data
                Guid?newProjID = db_EECIP.InsertUpdatetT_OE_PROJECTS(model.project.PROJECT_IDX, null, model.project.PROJ_NAME ?? "",
                                                                     projDescPlain, model.ProjectRichDesc ?? "", model.project.MEDIA_TAG, model.project.START_YEAR ?? -1, model.project.PROJ_STATUS ?? "",
                                                                     model.project.DATE_LAST_UPDATE ?? -1, model.project.RECORD_SOURCE ?? "", model.project.PROJECT_URL ?? "", model.project.MOBILE_IND,
                                                                     model.project.MOBILE_DESC ?? "", model.project.ADV_MON_IND, model.project.ADV_MON_DESC ?? "", model.project.BP_MODERN_IND,
                                                                     model.project.BP_MODERN_DESC ?? "", model.project.COTS ?? "", model.project.VENDOR ?? "", model.project.PROJECT_CONTACT ?? "", model.project.PROJECT_CONTACT_IDX ?? -1, true, false, UserIDX, null, true);

                if (newProjID != null)
                {
                    Guid newProjID2 = newProjID.ConvertOrDefault <Guid>();

                    //update project org
                    if (model.NewProjOrgIDX != null)
                    {
                        db_EECIP.InsertUpdateT_OE_PROJECT_ORGS(newProjID2, model.NewProjOrgIDX.ConvertOrDefault <Guid>(), UserIDX);
                    }


                    //update program area tags
                    db_EECIP.DeleteT_OE_PROJECT_TAGS(newProjID2, "Program Area");
                    foreach (string expertise in model.SelectedProgramAreas ?? new List <string>())
                    {
                        db_EECIP.InsertT_OE_PROJECT_TAGS(newProjID2, "Program Area", expertise);
                    }


                    //update project url
                    db_EECIP.DeleteT_OE_PROJECTS_URL(newProjID2);
                    foreach (T_OE_PROJECT_URLS urls in model.sProjectUrlList ?? new List <T_OE_PROJECT_URLS>())
                    {
                        db_EECIP.InsertT_OE_PROJECTS_URL(newProjID2, urls.PROJECT_URL, urls.PROJ_URL_DESC);
                    }


                    //update feature tags
                    db_EECIP.DeleteT_OE_PROJECT_TAGS(newProjID2, "Tags");
                    foreach (string feature in model.SelectedFeatures ?? new List <string>())
                    {
                        db_EECIP.InsertT_OE_PROJECT_TAGS(newProjID2, "Tags", feature);
                    }

                    foreach (T_OE_DOCUMENTS docs in model.files_existing ?? new List <T_OE_DOCUMENTS>())
                    {
                        db_EECIP.InsertUpdateT_OE_DOCUMENTS(docs.DOC_IDX, null, null, "project", null, null, docs.DOC_COMMENT, null, newProjID2, null, UserIDX);
                    }

                    //update files
                    if (model.files != null)
                    {
                        foreach (HttpPostedFileBase file in model.files)
                        {
                            byte[] fileBytes = null;

                            if (file != null)
                            {
                                using (Stream inputStream = file.InputStream)
                                {
                                    MemoryStream memoryStream = inputStream as MemoryStream;
                                    if (memoryStream == null)
                                    {
                                        memoryStream = new MemoryStream();
                                        inputStream.CopyTo(memoryStream);
                                    }
                                    fileBytes = memoryStream.ToArray();

                                    //insert to database
                                    db_EECIP.InsertUpdateT_OE_DOCUMENTS(null, fileBytes, file.FileName, "project", file.ContentType, fileBytes.Length, model.FileDescription, null, newProjID2, null, UserIDX);
                                }


                                //award profile badge
                                if (db_Accounts.UserCanEditOrgIDX(UserIDX, model.project.ORG_IDX.ConvertOrDefault <Guid>()))
                                {
                                    db_Forum.EarnBadgeController(UserIDX, "ProjectDocument");
                                }
                            }
                        }
                    }

                    //award badges for new project
                    if (newProjID2 != model.project.PROJECT_IDX)//new case
                    {
                        db_Forum.EarnBadgeAddProject(UserIDX);
                    }

                    //now update the Azure search
                    AzureSearch.PopulateSearchIndexProject(newProjID2);

                    TempData["Success"] = "Update successful.";
                    return(RedirectToAction("ProjectDetails", "Dashboard", new { id = newProjID2, returnURL = model.ReturnURL }));
                }
                else
                {
                    TempData["Error"] = "Error updating data.";
                }
            }
            else
            {
                TempData["Error"] = "You don't have permissions to edit this project.";
            }

            return(RedirectToAction(model.ReturnURL ?? "Projects", new { selAgency = model.NewProjOrgIDX }));
        }