Example #1
0
        private void Save(int intRequest)
        {
            int intItem    = Int32.Parse(lblItem.Text);
            int intNumber  = Int32.Parse(lblNumber.Text);
            int intService = Int32.Parse(lblService.Text);
            int intProject = oRequest.GetProjectNumber(intRequest);

            //if (intProject == -1)
            //    oServiceRequest.Update(intRequest, txtTitle.Text);
            oServiceEditor.AddRequest(intRequest, intService, intNumber, txtTitle.Text, Int32.Parse(radPriority.SelectedItem.Value), txtStatement.Text, DateTime.Now, DateTime.Now, (radExpediteYes.Checked ? 1 : 0));
            oServiceEditor.SaveForm(Request, intRequest, intService, intNumber, false, intEnvironment, dsn);

            //Reset the Resource Request and Workflow status for returned requests
            if (boolReqReturned == true)
            {
                int intReturned = 0;
                Int32.TryParse(lblReturned.Text, out intReturned);
                ResourceRequest oResourceRequest = new ResourceRequest(0, dsn);
                DataSet         dsRR             = oResourceRequest.GetRequestService(intRequest, intReturned, Int32.Parse(lblNumber.Text));
                if (dsRR.Tables[0].Rows.Count > 0)
                {
                    int intRRId = Int32.Parse(dsRR.Tables[0].Rows[0]["parent"].ToString());
                    oResourceRequest.updateResourceRequestReturnCompleted(Int32.Parse(lblReqReturnedId.Text));
                    DataSet dsRRWF = oResourceRequest.GetWorkflowsParent(intRRId);
                    oResourceRequest.UpdateStatusRequest(intRRId, 2);
                    foreach (DataRow dr in dsRRWF.Tables[0].Rows)
                    {
                        int intRRWFId = Int32.Parse(dr["id"].ToString());
                        oResourceRequest.UpdateWorkflowStatus(intRRWFId, 2, true);
                    }
                }
            }
            //Reset the Resource Request and approval process for denied requests
            if (boolReqDenied == true)
            {
                ResourceRequest oResourceRequest = new ResourceRequest(0, dsn);
                DataSet         dsResource       = oResourceRequest.GetAllService(intRequest, intService, Int32.Parse(lblNumber.Text));
                if (dsResource.Tables[0].Rows.Count > 0)
                {
                    int     intResource = Int32.Parse(dsResource.Tables[0].Rows[0]["rrid"].ToString());
                    DataSet dsRR        = oResourceRequest.Get(intResource);
                    if (dsRR.Tables[0].Rows.Count > 0)
                    {
                        oResourceRequest.UpdateStatusOverall(intResource, 2);
                        oService.UpdateSelectedApprove(intRequest, intService, Int32.Parse(lblNumber.Text), 0, 0, DateTime.Now, "");
                        if (oServiceRequest.NotifyApproval(intResource, intResourceRequestApprove, intEnvironment, "", dsnServiceEditor) == false)
                        {
                            oServiceRequest.NotifyTeamLead(intItem, intResource, intAssignPage, intViewPage, intEnvironment, "", dsnServiceEditor, dsnAsset, dsnIP, 0);
                        }
                    }
                }
            }
        }
Example #2
0
        private void LoadRequest()
        {
            int intRequest  = Int32.Parse(Request.QueryString["rid"]);
            int intProject  = oRequest.GetProjectNumber(intRequest);
            int intPriority = 3;
            int intService  = Int32.Parse(lblService.Text);
            int intItem     = oService.GetItemId(intService);

            string strStatement = "";
            string strExpedite  = "";

            if (oService.Get(intService, "statement") == "1")
            {
                panStatement.Visible = true;
                strStatement        += " && ValidateText('" + txtStatement.ClientID + "','Please enter a statement of work')";
            }
            else
            {
                panStatement.Visible = false;
            }
            panUpload.Visible = (oService.Get(intService, "upload") == "1");
            //if (oService.Get(intService, "expedite") == "1")
            //{
            //    panExpedite.Visible = true;
            //    strExpedite += " && ValidateRadioButtons('" + radExpediteYes.ClientID + "','" + radExpediteNo.ClientID + "','Please select whether or not you want to expedite this request')";
            //}
            //else
            panExpedite.Visible = false;
            if (Request.QueryString["formid"] != null && Request.QueryString["formid"] != "")
            {
                panUpdate.Visible  = true;
                btnCancelR.Visible = boolReqReturned;
                btnCancel.Visible  = (boolReqReturned == false);
                DataSet ds = oServiceEditor.GetRequestData(intRequest, intService, Int32.Parse(lblNumber.Text), 0, dsn);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    txtTitle.Text          = ds.Tables[0].Rows[0]["title"].ToString();
                    txtStatement.Text      = ds.Tables[0].Rows[0]["statement"].ToString();
                    intPriority            = Int32.Parse(ds.Tables[0].Rows[0]["priority"].ToString());
                    radExpediteYes.Checked = (ds.Tables[0].Rows[0]["expedite"].ToString() == "1");
                    radExpediteNo.Checked  = (ds.Tables[0].Rows[0]["expedite"].ToString() == "0");
                }
                strForm = oServiceEditor.LoadForm(intService, false, false, "", intEnvironment, ds, dsn);
            }
            else
            {
                panNavigation.Visible = true;
                strForm = oServiceEditor.LoadForm(intService, false, false, "", intEnvironment, null, dsn);
            }
            // Priority and SLA
            int intApp         = oRequestItem.GetItemApplication(intItem);
            int intWorkingDays = oApplication.GetLead(intApp, intPriority);

            if (intWorkingDays > 0)
            {
                panDeliverable.Visible = true;
                //oApplication.AssignPriority(intApp, radPriority, lblDeliverable.ClientID, txtEnd.ClientID, hdnEnd.ClientID);
                lblDeliverable.Text = intWorkingDays.ToString();
                //if (boolFound == false)
                //    txtEnd.Text = DateTime.Today.AddDays(intWorkingDays).ToShortDateString();
                hdnEnd.Value = DateTime.Today.AddDays(intWorkingDays).ToShortDateString();
            }
            radPriority.SelectedValue = intPriority.ToString();
            string strRequired = oServiceEditor.GetRequired();

            // Load Title if no project
            if (intProject == -1)
            {
                panTitle.Visible = true;
                if (oService.Get(intService, "title_override") == "1")
                {
                    lblTitleName.Text = oService.Get(intService, "title_name");
                }
                btnNext.Attributes.Add("onclick", "return ValidateText('" + txtTitle.ClientID + "','Please enter a title')" +
                                       strStatement +
                                       strRequired +
                                       strExpedite +
                                       " && ProcessButton(this) && LoadWait();");
                btnUpdate.Attributes.Add("onclick", "return ValidateText('" + txtTitle.ClientID + "','Please enter a title')" +
                                         strStatement +
                                         strRequired +
                                         strExpedite +
                                         " && ProcessButton(this) && LoadWait();");
            }
            else
            {
                btnNext.Attributes.Add("onclick", "return true" +
                                       strStatement +
                                       strRequired +
                                       strExpedite +
                                       " && ProcessButton(this) && LoadWait();");
                btnUpdate.Attributes.Add("onclick", "return true" +
                                         strStatement +
                                         strRequired +
                                         strExpedite +
                                         " && ProcessButton(this) && LoadWait();");
            }
            //Check for returned requests
            if (boolReqReturned == true || boolReqDenied == true)
            {
                int intReturned = 0;
                Int32.TryParse(lblReturned.Text, out intReturned);
                ResourceRequest oResourceRequest = new ResourceRequest(0, dsn);
                DataSet         dsResource       = oResourceRequest.GetAllService(intRequest, intReturned, Int32.Parse(lblNumber.Text));
                if (dsResource.Tables[0].Rows.Count > 0)
                {
                    int     intResource = Int32.Parse(dsResource.Tables[0].Rows[0]["rrid"].ToString());
                    DataSet dsRR        = oResourceRequest.Get(intResource);
                    Users   oUser       = new Users(0, dsn);
                    if (dsRR.Tables[0].Rows.Count > 0)
                    {
                        if (dsRR.Tables[0].Rows[0]["status"].ToString() == "-1")
                        {
                            // Request Denied
                            lblReqDenyCommentValue.Text = dsRR.Tables[0].Rows[0]["reason"].ToString();
                            if (lblReqDenyCommentValue.Text == "")
                            {
                                int intApproved = 0;
                                // Try getting from service approval.
                                DataSet dsSelected2 = oService.GetSelected(intRequest, intReturned, Int32.Parse(lblNumber.Text));
                                for (int ii = Int32.Parse(lblNumber.Text); ii > 0 && dsSelected2.Tables[0].Rows.Count == 0; ii--)
                                {
                                    dsSelected2 = oService.GetSelected(intRequest, intReturned, ii - 1);
                                }
                                if (dsSelected2.Tables[0].Rows.Count > 0)
                                {
                                    intApproved = Int32.Parse(dsSelected2.Tables[0].Rows[0]["approved"].ToString());
                                }
                                if (intApproved < 0)
                                {
                                    lblReqDenyCommentValue.Text = dsSelected2.Tables[0].Rows[0]["reason"].ToString();
                                }
                            }
                            pnlReqDenied.Visible = true;
                        }
                        else if (dsRR.Tables[0].Rows[0]["status"].ToString() == "7")
                        {
                            DataSet dsRRReturn = oResourceRequest.getResourceRequestReturn(intResource, intReturned, Int32.Parse(lblNumber.Text), 0, 0);
                            if (dsRRReturn.Tables[0].Rows.Count > 0)
                            {
                                lblReqReturnedId.Text         = dsRRReturn.Tables[0].Rows[0]["Id"].ToString();
                                lblReqReturnCommentValue.Text = oFunction.FormatText(dsRRReturn.Tables[0].Rows[0]["Comments"].ToString());
                                lblReqReturnedByValue.Text    = oUser.GetName(Int32.Parse(dsRRReturn.Tables[0].Rows[0]["ReturnedByUser"].ToString()));
                                lblReqReturnedByValue.Text    = oUser.GetFullName(Int32.Parse(dsRRReturn.Tables[0].Rows[0]["ReturnedByUser"].ToString()));
                                pnlReqReturn.Visible          = true;
                            }
                            DataSet dsRRReturn2 = oResourceRequest.getResourceRequestReturn(intResource, intReturned, Int32.Parse(lblNumber.Text), 1, 0);
                            if (dsRRReturn2.Tables[0].Rows.Count > 0)
                            {
                                lblReqReturnedId2.Text         = dsRRReturn2.Tables[0].Rows[0]["Id"].ToString();
                                lblReqReturnCommentValue2.Text = oFunction.FormatText(dsRRReturn2.Tables[0].Rows[0]["Comments"].ToString());
                                lblReqReturnedByValue2.Text    = oUser.GetName(Int32.Parse(dsRRReturn2.Tables[0].Rows[0]["ReturnedByUser"].ToString()));
                                lblReqReturnedByValue2.Text    = oUser.GetFullName(Int32.Parse(dsRRReturn2.Tables[0].Rows[0]["ReturnedByUser"].ToString()));
                                pnlReqReturn2.Visible          = true;
                            }
                        }
                        else
                        {
                            pnlReqReturn.Visible  = false;
                            pnlReqReturn2.Visible = false;
                        }
                    }
                }
            }
        }
Example #3
0
        public bool NotifyApproval(int _requestid, int intService, int intNumber, int _resourcerequestapprove, int _environment, string _cc, string _dsn_service_editor)
        {
            bool            boolNotify       = false;
            RequestItems    oRequestItem     = new RequestItems(user, dsn);
            ResourceRequest oResourceRequest = new ResourceRequest(user, dsn);
            Applications    oApplication     = new Applications(user, dsn);
            Users           oUser            = new Users(user, dsn);
            Functions       oFunction        = new Functions(user, dsn, _environment);
            Requests        oRequest         = new Requests(user, dsn);
            Pages           oPage            = new Pages(user, dsn);
            Variables       oVariable        = new Variables(_environment);
            Platforms       oPlatform        = new Platforms(user, dsn);
            Services        oService         = new Services(user, dsn);
            Log             oLog             = new Log(user, dsn);
            string          strEMailIdsBCC   = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_REQUEST_STATUS");

            int intPlatform = 0;
            int intManager  = 0;
            int intApp      = 0;
            int intItem     = oService.GetItemId(intService);
            int RRID        = 0;

            DataSet dsResource = oResourceRequest.GetAllService(_requestid, intService, intNumber);

            if (dsResource.Tables[0].Rows.Count > 0)
            {
                Int32.TryParse(dsResource.Tables[0].Rows[0]["RRID"].ToString(), out RRID);
            }

            string strCVT = "CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString();

            if (intItem > 0)
            {
                intApp      = oRequestItem.GetItemApplication(intItem);
                intPlatform = Int32.Parse(oApplication.Get(intApp, "platform_approve"));
            }
            if (intService > 0)
            {
                Int32.TryParse(oService.Get(intService, "manager_approval"), out intManager);
            }

            DataSet dsSelected    = oService.GetSelected(_requestid, intService, intNumber);
            int     intSelectedID = 0;
            int     intApproved   = 0;

            if (dsSelected.Tables[0].Rows.Count > 0)
            {
                Int32.TryParse(dsSelected.Tables[0].Rows[0]["approved"].ToString(), out intApproved);
                Int32.TryParse(dsSelected.Tables[0].Rows[0]["id"].ToString(), out intSelectedID);
            }
            else
            {
                intApproved = 1;    // since not the first one submitted, automatically approve from a service owner perspective.
            }
            // First, check for the requestor's manager Approval
            if (intManager == 1 && Get(_requestid, "manager_approval") == "0")
            {
                // Send to Manager for approval
                intPlatform = 0;
                boolNotify  = true;
                int intUser = oUser.GetManager(oRequest.GetUser(_requestid), true);
                oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to manager for approval - " + oUser.GetFullNameWithLanID(intUser), LoggingType.Debug);
                if (intUser == 0)
                {
                    intPlatform = 1;
                }
                else
                {
                    string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove);
                    if (strDefault == "")
                    {
                        oFunction.SendEmail("Request #CVT" + _requestid.ToString() + " APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false);
                    }
                    else
                    {
                        oFunction.SendEmail("Request #CVT" + _requestid.ToString() + " APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rid=" + _requestid.ToString() + "&approve=true\" target=\"_blank\">Click here to review this request.</a></p>", true, false);
                    }
                }
            }
            else
            {
                // Next, check the service approval
                DataSet dsApprovers = oService.GetUser(intService, -10);
                //int intApproval = ((oService.Get(intService, "approval") == "1" && dsApprovers.Tables[0].Rows.Count > 0) ? 0 : 1);
                int intApproval = ((oService.Get(intService, "approval") == "1" && dsApprovers.Tables[0].Rows.Count > 0) ? 1 : 0);
                if (intApproval == 1 && intApproved == 0)
                {
                    // Send to Approvers for approval
                    boolNotify = true;
                    // Send to Approvers for approval
                    foreach (DataRow drApprover in dsApprovers.Tables[0].Rows)
                    {
                        int intUser = Int32.Parse(drApprover["userid"].ToString());
                        oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to service approver for approval - " + oUser.GetFullNameWithLanID(intUser), LoggingType.Debug);
                        string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove);
                        if (strDefault == "")
                        {
                            oFunction.SendEmail("Service Request APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Service Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false);
                        }
                        else
                        {
                            oFunction.SendEmail("Service Request APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Service Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?srid=" + intSelectedID.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false);
                        }
                    }
                }
                else
                {
                    // Update that the service is approved.
                    if (intSelectedID > 0 && intApproved != 1)
                    {
                        oService.UpdateSelectedApprove(_requestid, intService, intNumber, 1, -999, DateTime.Now, "System Approval");
                    }

                    // Commenting since no current way of knowing if request has been approved by the platform
                    //if (intPlatform == 1)
                    //{
                    //    // Send to Platform for approval
                    //    if (intItem > 0)
                    //    {
                    //        int intUser = oPlatform.GetManager(Int32.Parse(oRequestItem.GetItem(intItem, "platformid")));
                    //        if (intUser > 0)
                    //        {
                    //            string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove);
                    //            if (strDefault == "")
                    //                oFunction.SendEmail("Request APPROVAL", oUser.GetName(intUser), "", strEMailIdsBCC, "Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false);
                    //            else
                    //                oFunction.SendEmail("Request APPROVAL", oUser.GetName(intUser), "", strEMailIdsBCC, "Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rrid=" + _resourcerequestid.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false);
                    //        }
                    //    }
                    //}

                    // Notify 3rd part approvers
                    DataSet       dsAlready        = oResourceRequest.GetApprovals(_requestid, intService, intNumber);
                    ServiceEditor oServiceEditor   = new ServiceEditor(user, _dsn_service_editor);
                    DataSet       dsApprovalFields = oServiceEditor.GetApprovals(intService);
                    DataSet       dsServiceEditor  = oServiceEditor.GetRequestFirstData2(_requestid, intService, intNumber, 0, dsn);

                    foreach (DataRow drApprovalField in dsApprovalFields.Tables[0].Rows)
                    {
                        if (dsServiceEditor.Tables[0].Rows.Count > 0)
                        {
                            int intApprover = 0;
                            if (Int32.TryParse(dsServiceEditor.Tables[0].Rows[0][drApprovalField["dbfield"].ToString()].ToString(), out intApprover) == true && intApprover > 0)
                            {
                                // Check to see if already sent
                                bool boolAlready = false;
                                foreach (DataRow drAlready in dsAlready.Tables[0].Rows)
                                {
                                    if (intApprover == Int32.Parse(drAlready["userid"].ToString()))
                                    {
                                        boolAlready = true;
                                        break;
                                    }
                                }
                                if (boolAlready == false)
                                {
                                    boolNotify = true;
                                    oResourceRequest.AddApproval(_requestid, intService, intNumber, intApprover);
                                    oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to 3rd party approver for approval - " + oUser.GetFullNameWithLanID(intApprover), LoggingType.Debug);
                                    string strDefault = oUser.GetApplicationUrl(intApprover, _resourcerequestapprove);
                                    if (strDefault == "")
                                    {
                                        oFunction.SendEmail("Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", oUser.GetName(intApprover), "", strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false);
                                    }
                                    else
                                    {
                                        oFunction.SendEmail("Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", oUser.GetName(intApprover), "", strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rrid=" + RRID.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false);
                                    }
                                }
                                else
                                {
                                    // No new people to notify, check to see all approvals are finished.
                                    foreach (DataRow drAlready in dsAlready.Tables[0].Rows)
                                    {
                                        if (drAlready["approved"].ToString() == "" && drAlready["denied"].ToString() == "")
                                        {
                                            boolNotify = true;
                                            break;
                                        }
                                    }
                                    oLog.AddEvent(_requestid.ToString(), strCVT, "Notify = " + boolNotify.ToString(), LoggingType.Debug);
                                }
                            }
                        }
                    }
                }
            }

            //if (intApproval)
            return(boolNotify);
        }