예제 #1
0
        protected override void Execute(CodeActivityContext context)
        {
            // Get the connection string
            DBConnection ext = context.GetExtension <DBConnection>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            // Lookup the Request
            RequestDataContext dc = new RequestDataContext(ext.ConnectionString);
            Request            r  = dc.Requests.SingleOrDefault(x => x.RequestKey == RequestKey.Get(context));

            if (r == null)
            {
                throw new InvalidProgramException("The specified request (" + RequestKey.Get(context) + ") was not found");
            }

            // Update the Request record
            r.ActionTaken = ActionTaken.Get(context);
            r.RouteNext   = RouteNext.Get(context);

            PersistRequest persist = context.GetExtension <PersistRequest>();

            persist.AddRequest(r);

            context.SetValue(Request, r);
        }
예제 #2
0
        private async Task SendActionAsync(ActionTaken action)
        {
            if (string.IsNullOrWhiteSpace(action.Reason))
            {
                action.Reason = "(none)";
            }

            var request = new HttpRequestMessage(HttpMethod.Post, _config["ActionsApiBaseUrl"])
            {
                Content = new StringContent(JsonSerializer.Serialize(action))
            };

            request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            request.Headers.Authorization       = new AuthenticationHeaderValue(_config["FitzyApiKey"]);

            var response = await _httpClient.SendAsync(request);

            Utils.LogToConsole($"Action sent to API: {action.Action} | {action.UserUsername} by {action.ModUsername} | " +
                               $"duration: {action.Duration}");

            if (!response.IsSuccessStatusCode)
            {
                var body = await response.Content.ReadAsStringAsync();

                Utils.LogToConsole($"API error | status: {response.StatusCode} | body: {body}");

                await Utils.SendDiscordErrorWebhookAsync($"{_config["DiscordWebhookUserPing"]} Error sending action to API", _config["DiscordWebhookUrl"]);
            }
        }
예제 #3
0
        public JsonNetResult Add(ActionTakenViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Event e = this.eventTasks.GetEvent(vm.EventId);
                if (e != null)
                {
                    ActionTaken at = new ActionTaken();
                    at.Event = e;
                    if (vm.SubjectPersonId.HasValue)
                    {
                        at.SubjectPerson = this.personTasks.GetPerson(vm.SubjectPersonId.Value);
                    }
                    if (vm.ObjectPersonId.HasValue)
                    {
                        at.ObjectPerson = this.personTasks.GetPerson(vm.ObjectPersonId.Value);
                    }
                    at.ActionTakenType = this.actionTakenTasks.GetActionTakenType(vm.ActionTakenTypeId);
                    Mapper.Map(vm, at);

                    at = this.actionTakenTasks.SaveActionTaken(at);
                    return(JsonNet(string.Empty));
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.NotFound;
                    return(JsonNet("Event does not exist."));
                }
            }
            else
            {
                return(JsonNet(this.GetErrorsForJson()));
            }
        }
예제 #4
0
        private void PerformStep()
        {
            var(obs, reward, isDone) = Observe();
            var action = GetAction(obs);

            ActionTaken?.Invoke(obs, action, reward, isDone);
            ApplyAction(action);
        }
예제 #5
0
        public ActionResult AddAction(int BR_ID, string Message, string Type)
        {
            ActionTaken At = new ActionTaken();

            string custid = Session["Cust_ID"].ToString();

            if (Message != null)
            {
                Session["BirthRegister_ID"] = BR_ID;
                BirthProcessAction Bprocess = new BirthProcessAction();

                #region Show all data of Birth/Death Process
                At.Showall = Bprocess.GetDataofparticularprocess(BR_ID);
                #endregion

                #region Showall comments During verification
                At.ShowAllComments = Bprocess.GetAllCommentsdata(BR_ID);
                #endregion

                #region show all files loaded in Sql
                At.ShowallMessage = Bprocess.FileLoadMessage(Message);
                #endregion

                #region all Recomend/ clarification Comments
                At.Allrecomendedvarification = Bprocess.AddrecomendVerification();
                #endregion

                #region Appeal doc
                At.Appdoc = Bprocess.ShowAppealdate(BR_ID.ToString());


                #endregion

                At.BnDType = Type;
                return(View(At));
            }
            else
            {
                Session["BirthRegister_ID"] = BR_ID;
                BirthProcessAction Bprocess = new BirthProcessAction();
                At.Showall                   = Bprocess.GetDataofparticularprocess(BR_ID);
                At.ShowAllComments           = Bprocess.GetAllCommentsdata(BR_ID);
                At.Allrecomendedvarification = Bprocess.AddrecomendVerification();
                string ProcessNo = Type + "_" + BR_ID;

                At.viewIdentityDocument = Bprocess.ShowIdentityDocumentList(BR_ID.ToString());

                At.viewBnDDocument = Bprocess.ShowBnDDocumentList_1(ProcessNo);

                At.RoleName = Session["RoleDesc"].ToString();
                #region Appeal doc
                At.Appdoc = Bprocess.ShowAppealdate(ProcessNo);


                #endregion
                return(View(At));
            }
        }
예제 #6
0
        public List <Tbl_Document_BnD_List> ShowBnDDocumentList_1(string BR_ID)
        {
            List <Tbl_Document_BnD_List> Tbl_DocumentViewList = new List <Tbl_Document_BnD_List>();
            ActionTaken RoleAccess = new ActionTaken();

            try
            {
                con = Utility.Util.Connection("DBEntities");
                string     result = "";
                SqlCommand cmd    = new SqlCommand("SP_ViewBndDocuments_1", con);
                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@B_ID", BR_ID);

                result = cmd.ExecuteScalar().ToString();
                if (result.Equals(null))
                {
                    return(null);
                }
                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;
                DataSet ds = new DataSet();

                da.Fill(ds);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Tbl_Document_BnD_List DocViewBnDAttachment = new Tbl_Document_BnD_List();
                    DocViewBnDAttachment.ID = Convert.ToInt32(ds.Tables[0].Rows[i]["Id"]);

                    DocViewBnDAttachment.Docname     = ds.Tables[0].Rows[i]["Docname"].ToString();
                    DocViewBnDAttachment.Doctype     = ds.Tables[0].Rows[i]["Doctype"].ToString();
                    DocViewBnDAttachment.DocFilePath = ds.Tables[0].Rows[i]["DocFilePath"].ToString();


                    Tbl_DocumentViewList.Add(DocViewBnDAttachment);
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                con.Close();
            }


            return(Tbl_DocumentViewList);
        }
예제 #7
0
        public ActionResult Edit(int id)
        {
            ActionTaken at = this.actionTakenTasks.GetActionTaken(id);

            if (at != null)
            {
                ActionTakenViewModel vm = new ActionTakenViewModel(at);
                vm.PopulateDropDowns(this.actionTakenTasks.GetActionTakenTypes());
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
예제 #8
0
        public List <Tbl_Document_List> DocumentList(int P_Id)
        {
            List <Tbl_Document_List> Tbl_DocumentTypeList = new List <Tbl_Document_List>();
            ActionTaken RoleAccess = new ActionTaken();

            try
            {
                con = Utility.Util.Connection("DBEntities");
                string     result = "";
                SqlCommand cmd    = new SqlCommand("SP_DocumentType", con);
                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@P_Id", P_Id);
                cmd.Parameters.AddWithValue("@Msg", "");
                result = cmd.ExecuteScalar().ToString();
                if (result.Equals(null))
                {
                    return(null);
                }
                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;
                DataSet ds = new DataSet();

                da.Fill(ds);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Tbl_Document_List DocAttachment = new Tbl_Document_List();
                    DocAttachment.ID = (i + 1);

                    DocAttachment.Docname    = ds.Tables[0].Rows[i]["DocumentTypeName"].ToString();
                    DocAttachment.Doctype    = ds.Tables[0].Rows[i]["DocumentType"].ToString();
                    DocAttachment.DoctypeArr = DocAttachment.Doctype.Split('|');

                    Tbl_DocumentTypeList.Add(DocAttachment);
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                con.Close();
            }


            return(Tbl_DocumentTypeList);
        }
예제 #9
0
        public JsonNetResult Delete(int id)
        {
            ActionTaken at = this.actionTakenTasks.GetActionTaken(id);

            if (at != null)
            {
                this.actionTakenTasks.DeleteActionTaken(at);
                return(JsonNet("Action taken for event successfully removed."));
            }
            Response.StatusCode = (int)HttpStatusCode.NotFound;
            return(JsonNet("Action taken not found."));
        }
예제 #10
0
        /// <summary>All wrapper methods point to this one.</summary>
        private async Task <bool> AddAction(DateTimeOffset time, ulong offenderId, ActionTaken action, ulong staffmemberId,
                                            string reason, long tickDuration = -1)
        {
            LogItem logItem = new LogItem(
                seconds: time.ToUnixTimeSeconds(),
                offenderId: offenderId,
                staffmemberId: staffmemberId,
                action: action,
                duration: tickDuration,
                reason: reason);

            return(await spreadsheetInfo.AppendEntryAsync(logItem));
        }
예제 #11
0
        public List <RoleAction> GetTbl_Action_MasterId(int R_ID, int PId)
        {
            List <RoleAction> Tbl_Action_MasterList = new List <RoleAction>();
            ActionTaken       RoleAccess            = new ActionTaken();

            try
            {
                con = Utility.Util.Connection("DBEntities");
                string     result = "";
                SqlCommand cmd    = new SqlCommand("SP_ChkRoleAction", con);
                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserId", R_ID);
                cmd.Parameters.AddWithValue("@ProcessId", PId);
                result = cmd.ExecuteScalar().ToString();
                if (result.Equals(null))
                {
                    return(null);
                }
                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;
                DataSet ds = new DataSet();

                da.Fill(ds);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    RoleAction RoleAction = new RoleAction();
                    RoleAction.ActionId   = Convert.ToInt32(ds.Tables[0].Rows[i]["ActionId"].ToString());
                    RoleAction.RoleId     = Convert.ToInt32(ds.Tables[0].Rows[i]["RoleId"].ToString());
                    RoleAction.ActionDesc = ds.Tables[0].Rows[i]["ActionDesc"].ToString();
                    roleDesc = ds.Tables[0].Rows[i]["RoleName"].ToString();
                    Tbl_Action_MasterList.Add(RoleAction);
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                con.Close();
            }


            return(Tbl_Action_MasterList);
        }
예제 #12
0
        public ActionResult AjaxPostCall(ActionTaken CommentData)
        {
            int                BR_ID    = Convert.ToInt16(Session["BirthRegister_ID"]);
            string             UserName = Session["U_Name"].ToString();
            int                UserId   = Convert.ToInt16(Session["U_ID"]);
            string             Action   = CommentData.Action;
            string             comments = CommentData.Comments;
            BirthProcessAction Bprocess = new BirthProcessAction();

            //insert all comment data in database
            string Insertresult = Bprocess.AddDataComments(BR_ID, UserName, Action, comments, UserId);

            return(RedirectToAction("Dashboard", "DashBoard"));
        }
예제 #13
0
        public ActionResult DownLoadFile(int id)
        {
            // string FileMsg = null;
            ActionTaken         At       = new ActionTaken();
            List <BirthProcess> ObjFiles = GetFileList(id);

            var FileById = (from FC in ObjFiles

                            select new { FC.DocumentName, FC.FileName }).ToList().FirstOrDefault();

            byte[] data           = Convert.FromBase64String(FileById.FileName);
            string imreBase64Data = Convert.ToBase64String(data);
            string imgDataURL     = string.Format(imreBase64Data);

            //Passing image data in viewbag to view
            ViewBag.ImageData = imgDataURL;
            return(View("ViewDocument", imgDataURL, id));

            #region for save the file in path
            // string strpath = "C:\\Users\\Caritas-Heena\\Desktop\\";
            //if (Directory.Exists(strpath))
            //    {
            //        strpath = strpath + FileById.DocumentName;
            //        using (FileStream Writer = new System.IO.FileStream(strpath, FileMode.Create, FileAccess.Write))
            //        {

            //            Writer.Write(data, 0, data.Length);
            //            FileMsg = "FileDownload";
            //        }
            //    }
            //    else
            //    {
            //        throw new System.Exception("PDF Shared Location not found");
            //    }
            //if (FileMsg.Contains("FileDownload"))
            //{
            //    At.Filemessage = "FileDownload";
            //    return RedirectToAction("AddAction",new { BR_ID=id ,Message=At.Filemessage.ToString()});
            //}
            //else
            //{
            //    At.Filemessage = "Unable to download";
            //    //TempData["shortMessage"] = String.Format("Unable to download");
            //    return RedirectToAction("AddAction", new { BR_ID = id });
            //}
            #endregion
        }
예제 #14
0
        public ActionTaken SaveActionTaken(ActionTaken at)
        {
            at.Event.AddActionTaken(at);

            foreach (Person person in new Person[] { at.ObjectPerson, at.SubjectPerson })
            {
                if (person != null)
                {
                    if (!person.HasValidProfileStatus())
                    {
                        person.ProfileStatus = this.personTasks.GetProfileStatus(ProfileStatus.ROUGH_OUTLINE);
                    }
                    this.personTasks.SavePerson(person);  // also updates lucene
                }
            }

            return(this.actionTakenRepo.SaveOrUpdate(at));
        }
예제 #15
0
        public static bool AddApplicationEvent(int selectedSiteID, ActionTaken actionTaken)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                var apiUrl = ConfigurationManager.AppSettings.Get("WebAPI");
                if (null == AppSession.AccessToken || string.IsNullOrEmpty(AppSession.AccessToken.Token))
                {
                    AppSession.AccessToken = EprodWebApi.GetAuthenticationToken(apiUrl,
                                                                                ConfigurationManager.AppSettings.Get("AppID"),
                                                                                ConfigurationManager.AppSettings.Get("AppPassword"));
                }
                ApplicationEvent appEvent = new ApplicationEvent()
                {
                    UserId       = (int)AppSession.UserID,
                    SiteId       = selectedSiteID,
                    ProgramId    = AppSession.SelectedProgramId,
                    EproductId   = (int)EProductType.Reports,
                    ActionTypeId = (int)actionTaken
                };

                return(EprodWebApi.ApplicationEvent(appEvent, apiUrl, AppSession.AccessToken.Token));
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit")
                {
                    ExceptionLog exceptionLog = new ExceptionLog
                    {
                        ExceptionText = "Reports: " + ex.Message,
                        PageName      = "WebApiMethods.cs",
                        MethodName    = "AddApplicationEvent",
                        UserID        = Convert.ToInt32(AppSession.UserID),
                        SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                        TransSQL      = "",
                        HttpReferrer  = null
                    };
                    ExceptionService _exceptionService = new ExceptionService();
                    _exceptionService.LogException(exceptionLog);
                }
            }
            return(false);
        }
예제 #16
0
 public ActionTakenViewModel(ActionTaken at)
 {
     this.Id = at.Id;
     if (at.SubjectPerson != null)
     {
         this.SubjectPersonId   = at.SubjectPerson.Id;
         this.SubjectPersonName = at.SubjectPerson.Name;
     }
     if (at.ObjectPerson != null)
     {
         this.ObjectPersonId   = at.ObjectPerson.Id;
         this.ObjectPersonName = at.ObjectPerson.Name;
     }
     this.ActionTakenTypeId             = at.ActionTakenType.Id;
     this.ActionTakenTypeName           = at.ActionTakenType.ToString();
     this.ActionTakenTypeIsRemedial     = at.ActionTakenType.IsRemedial;
     this.ActionTakenTypeIsDisciplinary = at.ActionTakenType.IsDisciplinary;
     this.ActionTakenSummary            = at.GetCompleteSummary();
     this.EventId       = at.Event.Id;
     this.EventHeadline = at.Event.Headline;
     Mapper.Map(at, this);
 }
예제 #17
0
        public ActionResult PaymentAddAction(int BR_ID, string Message, string Type)
        {
            ActionTaken At = new ActionTaken();

            if (Message != null)
            {
                Session["BirthRegister_ID"] = BR_ID;
                BirthProcessAction Bprocess = new BirthProcessAction();
                At.Showall         = Bprocess.GetDataofparticularprocess(BR_ID);
                At.ShowAllComments = Bprocess.GetAllCommentsdata(BR_ID);
                At.ShowallMessage  = Bprocess.FileLoadMessage(Message);
                return(View(At));
            }
            else
            {
                Session["BirthRegister_ID"] = BR_ID;
                BirthProcessAction Bprocess = new BirthProcessAction();
                At.Showall         = Bprocess.GetDataofparticularprocess(BR_ID);
                At.ShowAllComments = Bprocess.GetAllCommentsdata(BR_ID);
                At.BnDType         = Type;
                return(View(At));
            }
        }
예제 #18
0
        public void run(View v, MembersRegistry m)
        {
            v.renderMainMenu();
            ActionTaken usersInput = v.getUsersInput();

            while (usersInput != ActionTaken.Quit)
            {
                if (usersInput == ActionTaken.RegisterMember)
                {
                    Member member = v.registerMember();
                    m.addMember(member);
                    db.saveMembersRegistryToDB(m.getMembersList());
                }

                if (usersInput == ActionTaken.EditMember)
                {
                    try
                    {
                        int membersId = v.selectUserById(m.getMembersList());

                        m.getMemberById(membersId).editMemberData(v.editMember(m.getMemberById(membersId).UniqueId));

                        db.saveMembersRegistryToDB(m.getMembersList());
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        v.showInputError(ex.Message);
                        v.renderMainMenu();
                    }
                }

                if (usersInput == ActionTaken.DeleteMember)
                {
                    try
                    {
                        int membersId = v.deleteMember(m.getMembersList());
                        m.deleteMember(membersId);
                        db.saveMembersRegistryToDB(m.getMembersList());
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        v.showInputError(ex.Message);
                        v.renderMainMenu();
                    }
                }

                if (usersInput == ActionTaken.RegisterBoat)
                {
                    try
                    {
                        int usersId = v.selectUserById(m.getMembersList());
                        m.getMemberById(usersId).addBoat(v.registerBoat());
                        db.saveMembersRegistryToDB(m.getMembersList());
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        v.showInputError(ex.Message);
                    }
                }

                if (usersInput == ActionTaken.EditBoat)
                {
                    try
                    {
                        int membersId   = v.selectUserById(m.getMembersList());
                        int indexOfBoat = v.getIndexOfBoat(m.getMemberById(membersId).returnBoatList());

                        m.getMemberById(membersId).updateBoatValues(v.editBoat(), indexOfBoat);
                        db.saveMembersRegistryToDB(m.getMembersList());
                    }
                    catch (Exception ex)
                    {
                        v.showInputError(ex.Message);
                    }
                }

                if (usersInput == ActionTaken.DeleteBoat)
                {
                    try
                    {
                        int membersId   = v.selectUserById(m.getMembersList());
                        int indexOfBoat = v.deleteBoat(m.getMemberById(membersId));

                        m.getMemberById(membersId).removeBoat(indexOfBoat);
                        db.saveMembersRegistryToDB(m.getMembersList());
                    }
                    catch (Exception ex)
                    {
                        v.showInputError(ex.Message);
                    }
                }

                if (usersInput == ActionTaken.ViewSimpleList)
                {
                    IEnumerable <Member> members = m.getMembersList();
                    v.viewSimpleList(members);
                }

                if (usersInput == ActionTaken.ViewDetailedList)
                {
                    v.viewDetailedList(m.getMembersList());
                }

                if (usersInput == ActionTaken.ViewSpecificMember)
                {
                    int membersId = v.selectUserById(m.getMembersList());
                    v.viewSpecificMember(m.getMemberById(membersId));
                }

                v.renderMainMenu();
                usersInput = v.getUsersInput();
            }
        }
 protected void OnActionComplete(string action)
 {
     ActionTaken?.Invoke(this, new EventArgs());
 }
 protected void OnActionComplete(EventArgs e)
 {
     ActionTaken?.Invoke(this, e);
 }
예제 #21
0
파일: Event.cs 프로젝트: ruacol/profiling2
 public virtual void RemoveActionTaken(ActionTaken at)
 {
     this.ActionTakens.Remove(at);
 }
예제 #22
0
파일: Event.cs 프로젝트: ruacol/profiling2
 public virtual void AddActionTaken(ActionTaken at)
 {
     this.ActionTakens.Add(at);
 }
 private void RaiseActionTakenEvent(IAction action)
 {
     ActionTaken?.Invoke(this, new ActionEventArgs(action));
 }
예제 #24
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (CategoryElement != null)
                {
                    result.AddRange(CategoryElement.Validate());
                }
                if (Code != null)
                {
                    result.AddRange(Code.Validate());
                }
                if (StatusElement != null)
                {
                    result.AddRange(StatusElement.Validate());
                }
                if (ProhibitedElement != null)
                {
                    result.AddRange(ProhibitedElement.Validate());
                }
                if (Timing != null)
                {
                    result.AddRange(Timing.Validate());
                }
                if (Location != null)
                {
                    result.AddRange(Location.Validate());
                }
                if (Performer != null)
                {
                    Performer.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Product != null)
                {
                    result.AddRange(Product.Validate());
                }
                if (DailyAmount != null)
                {
                    result.AddRange(DailyAmount.Validate());
                }
                if (Quantity != null)
                {
                    result.AddRange(Quantity.Validate());
                }
                if (DetailsElement != null)
                {
                    result.AddRange(DetailsElement.Validate());
                }
                if (ActionTaken != null)
                {
                    ActionTaken.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (NotesElement != null)
                {
                    result.AddRange(NotesElement.Validate());
                }

                return(result);
            }
예제 #25
0
 public void DeleteActionTaken(ActionTaken at)
 {
     at.Event.RemoveActionTaken(at);
     this.actionTakenRepo.Delete(at);
 }
예제 #26
0
 public static bool AddReportAccessApplicationEvent(int selectedSiteID, ActionTaken reportAccessed)
 {
     return(AddApplicationEvent(selectedSiteID, reportAccessed));
 }
예제 #27
0
    public string Search(int report, int dateGroup, string staffId, int status, string keyword, string listPlayerIdIncidents)
    {
        Keyword = keyword;

        string reportStatus = "";

        switch (status) // set status for writing the select query
        {
        case 2:
            reportStatus = "%Completion%";
            break;

        case 3:
            reportStatus = "%Manager%";
            break;

        case 4:
            reportStatus = "%Further%";
            break;

        case 5:
            reportStatus = "%Completed%";
            break;
        }

        DateTime date1 = DateTime.Now.Date, date2 = DateTime.Now.Date; // used to hold Date Group values

        switch (dateGroup)                                             // set the date being filtered
        {
        case 2:
            date2 = DateTime.Now.Date.AddDays(-1);      // reports from yesterday
            break;

        case 3:
            date2 = DateTime.Now.Date.AddDays(-7);      // reports from last seven days
            break;

        case 4:
            date2 = DateTime.Now.Date.AddDays(-14);      // reports from last 14 days
            break;

        case 5:
            date2 = DateTime.Now.Date.AddDays(-30);      // reports from last month
            break;

        case 6:
            date2 = DateTime.Now.Date.AddDays(-365);      // reports from last year
            break;

        case 7:
            date2 = DateTime.Parse(StartDate);
            date1 = DateTime.Parse(EndDate);
            break;
        }

        string reportType = "";

        switch (report) // set the report type being filtered (take note that any changes from the group will create an error - MRReportsDutyManager)
        {
        case 2:
            reportType = "MR Incident Report";
            break;

        case 3:
            reportType = "MR Duty Managers";
            break;

        case 4:
            reportType = "MR Supervisors";
            break;

        case 5:
            reportType = "MR Function Supervisor";
            break;

        case 6:
            reportType = "MR Reception Supervisor";
            break;

        case 7:
            reportType = "MR Reception";
            break;

        case 8:
            reportType = "CU Duty Managers";
            break;

        case 9:
            reportType = "CU Reception";
            break;

        case 10:
            reportType = "CU Incident Report";
            break;
        }

        // check if user has entered a keyword to be filtered
        bool hasKeyword = true;

        if (keyword.Equals("0") || keyword.Equals("")) // check whether the keyword filter is empty
        {
            hasKeyword = false;                        // keyword filter is empty
        }

        // check if staff has filter
        bool hasStaffFilter = true;

        if (ArchivedStaff)
        {
            if (string.IsNullOrEmpty(staffId))
            {
                staffId = "SELECT StaffId FROM Staff WHERE Active=0";
            }
        }
        else if (string.IsNullOrEmpty(staffId)) // if there is no staff filter selected, populate staff list
        {
            staffId        = "SELECT StaffId FROM Staff";
            hasStaffFilter = false;
        }

        // check if selected staff filter is the user logged in
        bool isAuthor = true;

        if (!staffId.Equals(UserCredentials.StaffId))
        {
            isAuthor = false;
        }

        string selectQuery = "",
               startQuery  = "SELECT [ReportId], [ReportName], [StaffId], [StaffName], [ShiftName], [ShiftDate], [ShiftDOW], [Report_Table], [Report_Version], [ReportStat], [AuditVersion], [RowNum]" +
                             " FROM [View_Reports] WHERE [ReportName] ",
               startQuery1 = "SELECT [ReportId], [ReportName], [StaffId], [StaffName], [ShiftName], [ShiftDate], [ShiftDOW], [Report_Table], [Report_Version], [ReportStat], [AuditVersion], ROW_NUMBER() OVER(ORDER BY ShiftDate DESC, ShiftId DESC) RowNum" +
                             " FROM [View_Reports] WHERE ReportName ",
               reportIdQuery = "", dateQuery = "", statusQuery = "", unreadQuery = "", reportQuery = "", authorQuery = "", cuQuery = "", mrQuery = "",
               endQuery = "ORDER BY ShiftDate DESC, ShiftId DESC, RowNum";

        if (report == 1) // no report type filter
        {
            reportQuery = "IN ('" + UserCredentials.GroupsQuery + "') AND ";
        }
        else // has report type filter
        {
            reportQuery = "= '" + reportType + "' AND ";
        }

        if (string.IsNullOrWhiteSpace(ReportId))
        {
            reportIdQuery = " ";
        }
        else
        {
            reportIdQuery = "ReportId =" + ReportId + " AND ";
        }

        if (dateGroup != 1) // has date filter
        {
            dateQuery = "ShiftDate BETWEEN '" + date2.ToString("yyyy-MM-dd") + "' AND '" + date1.ToString("yyyy-MM-dd") + "' AND ";
        }
        else // no date filter
        {
            dateQuery = " ";
        }

        if (MROnly)
        {
            mrQuery = "[ReportName] LIKE '%MR%' AND ";
        }
        else
        {
            mrQuery = "";
        }

        if (CUOnly)
        {
            cuQuery = "[ReportName] LIKE '%CU%' AND ";
        }
        else
        {
            cuQuery = "";
        }

        if (status != 1) // has status filter
        {
            statusQuery = "[ReportStat] LIKE '" + reportStatus + "' AND ";
        }
        else // no status filter
        {
            statusQuery = " ";
        }

        if (!hasStaffFilter) // if staff filter is empty
        {
            authorQuery = "([ReportStat] = 'Report Completed' OR [ReportStat] = 'Further Action Required' OR [ReportStat] = 'Awaiting Manager Sign-off' OR ([ReportStat] = 'Awaiting Completion' AND [StaffId] = '" + UserCredentials.StaffId + "')) ";
        }
        else // has a staff filter
        {
            if (isAuthor)  // The user selected his ownself
            {
                authorQuery = "([ReportStat] = 'Report Completed' OR [ReportStat] = 'Further Action Required' OR [ReportStat] = 'Awaiting Manager Sign-off' OR ([ReportStat] = 'Awaiting Completion' AND [StaffId] = '" + UserCredentials.StaffId + "')) AND StaffId IN (" + staffId + ") ";
            }
            else //  // staff other than the user
            {
                authorQuery = "([ReportStat] = 'Report Completed' OR [ReportStat] = 'Further Action Required' OR [ReportStat] = 'Awaiting Manager Sign-off') AND StaffId IN (" + staffId + ") ";
            }
        }

        if (UnreadList && string.IsNullOrEmpty(ListPlayerIdIncidents)) // unread tickbox has been checked
        {
            unreadQuery = "AND ([ReadByList] NOT LIKE '%," + UserCredentials.StaffId + ",%' OR [ReadByList] IS NULL) AND ([ManagerSignId] NOT LIKE '%" + UserCredentials.StaffId + ",%' OR [ManagerSignId] IS NULL) ";
        }
        else // no unread list filter
        {
            unreadQuery = " ";
        }


        if (!hasKeyword && (WhatHappened.Equals("0") || string.IsNullOrEmpty(WhatHappened)) && (Location.Equals("0") || string.IsNullOrEmpty(Location)) &&
            (ActionTaken.Equals("0") || string.IsNullOrEmpty(ActionTaken)) && (MemberNo.Equals("0") || string.IsNullOrEmpty(MemberNo)) &&
            (FirstName.Equals("0") || string.IsNullOrEmpty(FirstName)) && (LastName.Equals("0") || string.IsNullOrEmpty(LastName)) &&
            (Alias.Equals("0") || string.IsNullOrEmpty(Alias)))    // if Keyword and advanced filters are empty
        {
            selectQuery = startQuery + reportQuery + reportIdQuery + dateQuery + mrQuery + cuQuery + statusQuery + authorQuery + unreadQuery + endQuery;
        }
        else // keyword filter and advanced filter has been entered
        {
            // run stored procedures
            SqlQuery sqlQuery = new SqlQuery();
            //if (!string.IsNullOrEmpty(listPlayerIdIncidents)) // run all the list of incidents for the selected player id
            //{
            //    sqlQuery.RetrieveData("Proc_ListPriorIncidents", "SearchKeyword");
            //}
            //else // no player id is selected, filter via keyword and report filters
            //{
            //    // set appropriate stored procedure (either Proc_KeywordSearchAllReports - any report other than Incidents ; Proc_KeywordSearchIncidentReports - Incidents ONLY)
            //    if (reportType.Contains("Incident"))
            //    {
            //        sqlQuery.RetrieveData("Proc_KeywordSearchIncidentReports", "SearchKeyword");
            //    }
            //    else
            //    {
            //        sqlQuery.RetrieveData("Proc_KeywordSearchAllReports", "SearchKeyword");
            //    }
            //}

            if (GlobalSearchId.Equals("")) // if no data retrieved, display an error message
            {
                return(selectQuery);
            }

            // take off the extra ', ' in Global Search Ids Variable
            int strLength = GlobalSearchId.Length;
            GlobalSearchId = GlobalSearchId.Remove(strLength - 2, 2);

            string keywordQuery = "AND [ReportId] IN (" + GlobalSearchId + ") ";
            GlobalSearchId        = ""; // to avoid this variable from getting appended
            ListPlayerIdIncidents = ""; // reset this variable to be reused again in searching incident reports related to player id selected

            selectQuery = startQuery1 + reportQuery + reportIdQuery + dateQuery + mrQuery + cuQuery + statusQuery + authorQuery + keywordQuery + unreadQuery + endQuery;
        }
        return(selectQuery);
    }