Beispiel #1
0
        protected void _submitForm_Click(object sender, EventArgs e)
        {
            int requestID;
            var sendEmail = true;
            try
            {
                List<RequestData> newRequestDataList = RequestFormRequestData(_requestForm);

                if (BrandNewRequest())
                {
                    var xmlInput = RequestData.ToXml(newRequestDataList);

                    ADUserDetail detail = Apollo.AIM.SNAP.CA.DirectoryServices.GetUserByLoginName(_requestorLoginId.Text);

                    using (var db = new SNAPDatabaseDataContext())
                    {
                        requestID = db.usp_insert_request_xml(xmlInput, SnapSession.CurrentUser.LoginId, _requestorLoginId.Text, _requestorId.Text, detail.Title, _managerLoginId.Text, _managerName.Text);
                        if (requestID > 0)
                        {
                            SnapSession.SelectedRequestId = requestID.ToString();
                            SnapSession.UseSelectedRequestId = true;
                        }
                        else
                        {
                            Logger.Fatal("SNAP: Request Form -  Submit failure", "Unknown Error");
                            sendEmail = false;
                        }
                    }
                }
                else
                {
                    requestID = System.Convert.ToInt32(SnapSession.SelectedRequestId);
                    updateRequestUsrInfo(requestID, SnapSession.CurrentUser.LoginId, _requestorLoginId.Text, _requestorId.Text, _managerLoginId.Text, _managerName.Text);
                    RequestData.UpdateRequestData(newRequestDataList, _requestFormData);

                    var accessReq = new AccessRequest(requestID);
                    if (!accessReq.RequestChanged().Success)
                    {
                        sendEmail = false;
                    }
                }

                if (sendEmail)
                {
                    if (SnapSession.CurrentUser.LoginId != _requestorLoginId.Text)
                    {
                        Email.SendTaskEmail(EmailTaskType.ProxyForAffectedEndUser, SnapSession.CurrentUser.LoginId + "@apollogrp.edu", SnapSession.CurrentUser.FullName, requestID, _requestorId.Text);
                    }
                    Email.SendTaskEmail(EmailTaskType.AccessTeamAcknowledge, ConfigurationManager.AppSettings["AIM-DG"], null, requestID, _requestorId.Text);
                    Email.SendTaskEmail(EmailTaskType.UpdateRequester, _requestorLoginId.Text + "@apollogrp.edu", _requestorId.Text, requestID, _requestorId.Text, WorkflowState.Pending_Acknowledgement, null);
                    // TODO: UserLoginId concatenates with @apollogrp, but that may not be the addy.
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal("RequestForm - _submitForm_Click, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace);
            }

            WebUtilities.Redirect(PageNames.USER_VIEW);
        }
Beispiel #2
0
        public void EXEC_usp_open_request_tab()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                var accessReq = new AccessRequest(req.pkId);
                accessReq.Ack();
            }

            using (var db = new SNAPDatabaseDataContext())
            {

                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                Assert.IsTrue(req.statusEnum == (byte)RequestState.Pending);
                var accessReq = new AccessRequest(req.pkId);
                accessReq.RequestToChange("TEST");
            }
            usp_open_request_tabResult t = new usp_open_request_tabResult();
            t.requestId = 0;
            t.userId = "test";
            t.userDisplayName = "test";
            t.userTitle = "test";
            t.submittedBy = "test";
            t.managerUserId = "test";
            t.managerDisplayName = "test";
            t.statusEnum = 0;
            t.isChanged = false;
            t.ticketNumber = "test";
            t.fieldId = 0;
            t.fieldLabel = "test";
            t.fieldText = "ttest";
            t.modifiedDate = DateTime.Now;
            t.createdDate = DateTime.Now;
            using (var db = new SNAPDatabaseDataContext())
            {

                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested);

                var test = db.usp_open_request_tab(req.userId, req.pkId).First();
                Assert.IsTrue(test.requestId > 0);
                Console.WriteLine(test.requestId);
                Console.WriteLine(test.userId);
                Console.WriteLine(test.userDisplayName);
                Console.WriteLine(test.userTitle);
                Console.WriteLine(test.submittedBy);
                Console.WriteLine(test.managerUserId);
                Console.WriteLine(test.managerDisplayName);
                Console.WriteLine(test.statusEnum);
                Console.WriteLine(test.isChanged);
                Console.WriteLine(test.ticketNumber);
                Console.WriteLine(test.fieldId);
                Console.WriteLine(test.fieldLabel);
                Console.WriteLine(test.fieldText);
                Console.WriteLine(test.modifiedDate);
                Console.WriteLine(test.createdDate);
            }
        }
Beispiel #3
0
        public static int AccessTeamCount()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                int result = db.SNAP_Requests
                             .Where(o => o.statusEnum == 0 || o.statusEnum == 1 || o.statusEnum == 2)
                             .Select(s => s.statusEnum)
                             .Count();

                return result;
            }
        }
Beispiel #4
0
        public static WebMethodResponse ApproverActions(int requestId, WorkflowAction action, string comments)
        {
            var currentUsrId = SnapSession.CurrentUser.DistributionGroup != null ? SnapSession.CurrentUser.DistributionGroup : SnapSession.CurrentUser.LoginId;
            int wfId = 0;

            using (var db = new SNAPDatabaseDataContext())
            {
                wfId = db.GetActiveWorkflowId(requestId, currentUsrId);
                if (wfId == 0)
                    return new WebMethodResponse(false, "Approver Action Failed", "Approver has nothing to approve");
            }

            var accessReq = new AccessRequest(requestId);
            comments = comments.FromJSONStringToObj<string>();
            return accessReq.WorkflowAck(wfId, action, comments);
        }
Beispiel #5
0
        public static int ApprovalCount(string[] userIds)
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                int result = (from sr in db.SNAP_Requests
                              join sw in db.SNAP_Workflows on sr.pkId equals sw.requestId
                              join sws in db.SNAP_Workflow_States on sw.pkId equals sws.workflowId
                              join sa in db.SNAP_Actors on sw.actorId equals sa.pkId
                              where userIds.Contains(sa.userId)
                              && sws.workflowStatusEnum == 7
                              && sws.completedDate == null
                              && sr.statusEnum == 2
                              select new { sr.pkId }).GroupBy(p => p.pkId).Count();

                return result;
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Set due date for request to fire the email nag ...");
            Console.WriteLine("What is your intervals(in days):");
            var interval = Convert.ToInt16(Console.ReadLine());
            Console.WriteLine("What is your max over due (in days) to close abandoned  the request:");
            var maxOverDue = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Due on 1 - Tomorrow, 2 - Now (for dev mostly)");
            var dueDateOption = Convert.ToInt16(Console.ReadLine());

            var answer = "Y";
            while (answer.Contains("Y")) {

                Console.WriteLine("Enter your request id which has approver waiting to approve the request");
                var requestId = Console.ReadLine();
                using (var db = new SNAPDatabaseDataContext())
                {
                    var req = db.SNAP_Requests.Single(x => (x.pkId == Convert.ToInt32(requestId) && x.statusEnum != (byte)RequestState.Closed) );
                    Console.WriteLine("req id: " + req.pkId + " - " + req.userDisplayName);
                    foreach(var wf in req.SNAP_Workflows)
                    {
                        var latestState = wf.SNAP_Workflow_States.OrderByDescending(s => s.pkId).First();
                        if (canChangeDueDate(latestState))
                        {
                            Console.WriteLine(wf.SNAP_Actor.displayName + "... " + Enum.GetName(typeof(WorkflowState), latestState.workflowStatusEnum));
                            var newDueDate = askUserToSelectDueDate(interval, dueDateOption, maxOverDue);

                            latestState.dueDate = newDueDate;
                            db.SubmitChanges();
                        }
                    }
                }

                Console.WriteLine("Press 'y' to continue .... any key to quit ...");
                answer = Console.ReadLine().ToUpper();
            }
            Console.WriteLine("Have a good day! Press enter ....");
            Console.ReadKey();
        }
Beispiel #7
0
        public static DataTable GetAllTrackingData(string requestId)
        {
            DataTable table = BuildEmptyTrackingBladeTable();

            using (var db = new SNAPDatabaseDataContext())
            {
                var tracking = from wf in db.SNAP_Workflows
                               where wf.requestId == Convert.ToInt32(requestId)
                               join ws in db.SNAP_Workflow_States on wf.pkId equals ws.workflowId
                               join a in db.SNAP_Actors on wf.actorId equals a.pkId
                               join ag in db.SNAP_Actor_Groups on a.actor_groupId equals ag.pkId
                               orderby ws.workflowId ascending, ws.pkId descending
                               select new
                               {
                                   display_name = a.displayName,
                                   workflow_status = ws.workflowStatusEnum,
                                   workflow_due_date = ws.dueDate,
                                   workflow_completed_date = ws.completedDate,
                                   workflow_pkid = ws.workflowId,
                                   actor_group_type = ag.actorGroupType
                               };

                foreach (var trackingRow in tracking)
                {
                    table.Rows.Add
                        (
                            trackingRow.display_name
                            , trackingRow.workflow_status
                            , trackingRow.workflow_due_date
                            , trackingRow.workflow_completed_date
                            , trackingRow.workflow_pkid
                            , trackingRow.actor_group_type
                        );
                }
            }

            return table;
            // datatable > rows > Non-Public members > list > Results View
        }
Beispiel #8
0
 private bool IsGroupMember()
 {
     try
     {
         using (var db = new SNAPDatabaseDataContext())
         {
             int result = db.SNAP_Actors
                             .Where(w => w.isGroup == true
                                     && w.isActive == true
                                     && MemberOf.Contains(w.userId))
                             .Select(s => s.pkId)
                             .Count();
             if (result > 0) { return true; }
             else { return false; }
         }
     }
     catch (Exception ex)
     {
         Logger.Error("SnapUser - IsGroupMember, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace);
     }
     return false;
 }
Beispiel #9
0
        public void Init()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var actors = db.SNAP_Actors.Where(a => a.SNAP_Actor_Group.actorGroupType == TEAMAPPROVALGROUP).ToList();
                teamApprovalActorId = actors[0].pkId;
                teamApprovalUserId = actors[0].userId;
                //actors = db.SNAP_Actors.Where(a => a.actor_groupId == TECHNICALAPPROVALGROUP).ToList();
                actors = db.SNAP_Actors.Where(a => a.SNAP_Actor_Group.actorGroupType == TECHNICALAPPROVALGROUP).ToList();
                windowsServerActorId = actors[0].pkId;
                WindowsServerUserId = actors[0].userId;
                networkShareActorId = actors[1].pkId;
                networkShareUserId = actors[1].userId;
                databaseActorId = actors[2].pkId;
                databaseUserId = actors[2].userId;
                //actors = db.SNAP_Actors.Where(a => a.actor_groupId == MANAGERGROUP).ToList();
                actors = db.SNAP_Actors.Where(a => a.SNAP_Actor_Group.actorGroupType == MANAGERGROUP).ToList();
                if (actors.Count == 1)
                {
                    db.SNAP_Actors.InsertOnSubmit(new SNAP_Actor() {
                        actor_groupId = actors[0].actor_groupId,
                        userId = "pxlee",
                        displayName = "Pong Lee",
                        emailAddress = "*****@*****.**",
                        isActive = true,
                        isDefault = false
                    });

                    db.SubmitChanges();
                    actors = db.SNAP_Actors.Where(a => a.SNAP_Actor_Group.actorGroupType == MANAGERGROUP).ToList();
                }
                managerActorId = actors[0].pkId;
                managerUserId = actors[0].userId;
                secondManagerActorId = actors[1].pkId;
                secondMagerUserId = actors[1].userId;
            }
        }
Beispiel #10
0
 public void ShouldOk()
 {
     using(var db = new SNAPDatabaseDataContext())
     {
         DateTime current = DateTime.Parse("3/31/2010 1:00:00 PM");
         for (int i = 1; i < 20; i++)
         {
             Console.WriteLine(db.udf_get_next_business_day(current, i));
         }
     }
 }
Beispiel #11
0
 public void ShouldReturnNoRequestData()
 {
     using (var db = new SNAPDatabaseDataContext())
     {
         var maxRequestId = db.SNAP_Requests.Max(x => x.pkId);
         var data = db.RetrieveRequestUserText(++maxRequestId);
         Assert.IsTrue(data.Count() == 0);
     }
 }
Beispiel #12
0
        public void SetUp()
        {
            cleanUp();

            using (var db = new SNAPDatabaseDataContext())
            {

                List<RequestData> requestDataList = new List<RequestData>()
                                                        {
                                                            new RequestData() {FormId = "2", UserText = "Request Access 2"},
                                                            new RequestData() {FormId = "3", UserText = "Request Access 3"},
                                                            new RequestData() {FormId = "4", UserText = "Request Access 4"},
                                                            new RequestData() {FormId = "5", UserText = "Request Access 5"}
                                                        };

                var xmlInput = RequestData.ToXml(requestDataList);

                db.usp_insert_request_xml(xmlInput, "UnitTester", "pxlee", "Pong Lee", "Programmer", "gjbelang", "Greg Belanger");
            }
            using (var db = new SNAPDatabaseDataContext())
            {
                var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester");
                db.SNAP_Request_Comments.InsertOnSubmit(new SNAP_Request_Comment()
                {
                    requestId = req.pkId,
                    commentText = "Test Comment",
                    commentTypeEnum = (byte)CommentsType.Acknowledged,
                    createdDate = DateTime.Now
                });
                db.SubmitChanges();
            }
        }
Beispiel #13
0
 public void ShouldbeAbleToCallUDF()
 {
     using (var db = new SNAPDatabaseDataContext())
     {
        var newDate = db.udf_get_next_business_day(DateTime.Now, 10);
         Assert.IsTrue(newDate != null);
     }
 }
Beispiel #14
0
Datei: UI.cs Projekt: apxlee/SAP
        public static string GetDetails(int requestId)
        {
            Role userRole = SnapSession.CurrentUser.CurrentRole;
            bool includeADManager = false;
            int[] commentFilter;
            switch (userRole)
            {
                case Role.AccessTeam:
                case Role.SuperUser:
                    commentFilter = new int[]{(int)CommentsType.Access_Notes_Requestor,
                        (int)CommentsType.Access_Notes_ApprovingManager,
                        (int)CommentsType.Access_Notes_AccessTeam};
                    includeADManager = true;
                    break;

                case Role.ApprovingManager:
                    commentFilter = new int[]{(int)CommentsType.Access_Notes_Requestor,
                        (int)CommentsType.Access_Notes_ApprovingManager};
                    break;

                case Role.Requestor:
                default:
                    commentFilter = new int[] { (int)CommentsType.Access_Notes_Requestor };
                    break;
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var textIds = from a in db.SNAP_Access_User_Texts
                              where a.requestId == requestId
                              group a by new { a.access_details_formId } into grp
                              select new { ID = grp.Max(s => s.pkId) };

                List<int> currentTextIds = new List<int>();

                foreach (var id in textIds)
                {
                    currentTextIds.Add(id.ID);
                }

                var details = from r in db.SNAP_Requests
                              join ut in db.SNAP_Access_User_Texts on r.pkId equals ut.requestId
                              join adf in db.SNAP_Access_Details_Forms on ut.access_details_formId equals adf.pkId
                              where r.pkId == requestId && adf.isActive == true && currentTextIds.Contains(ut.pkId)
                              orderby adf.pkId ascending
                              select new
                              {
                                  Title = r.userTitle,
                                  Manager = r.managerDisplayName,
                                  ADManager = r.managerUserId,
                                  Requestor = r.submittedBy,
                                  UserId = r.userId,
                                  Label = adf.label,
                                  Text = ut.userText
                              };
                var comments = from r in db.SNAP_Requests
                               join rc in db.SNAP_Request_Comments on r.pkId equals rc.requestId
                               where r.pkId == requestId && commentFilter.Contains(rc.commentTypeEnum)
                               orderby rc.createdDate descending
                               select new
                               {
                                   Audience = MakeFriendlyCommentAudience((CommentsType)rc.commentTypeEnum),
                                   CreatedDate = rc.createdDate,
                                   Text = rc.commentText
                               };

                if (details != null)
                {
                    RequestDetails newDetails = new RequestDetails();
                    List<RequestFormField> newForm = new List<RequestFormField>();
                    string ADManager = String.Empty;
                    foreach (var detail in details)
                    {
                        if (ADManager == String.Empty) { ADManager = (includeADManager ? CompareManagerName(detail.UserId, detail.ADManager) : null); }
                        newDetails.Title = detail.Title;
                        newDetails.Manager = detail.Manager;
                        newDetails.ADManager = ADManager;
                        newDetails.Requestor = detail.Requestor;
                        newDetails.SearchLinkUrl= Model.Utilities.WebRootUrl + Model.PageNames.SEARCH + ".aspx?requestId=" +  requestId.ToString();

                        RequestFormField newField = new RequestFormField();
                        newField.Label = detail.Label;
                        newField.Text = detail.Text;
                        newForm.Add(newField);
                    }
                    newDetails.Details = newForm;

                    if (comments != null)
                    {

                        List<RequestComments> newComments = new List<RequestComments>();

                        foreach (var comment in comments)
                        {
                            RequestComments newComment = new RequestComments();
                            newComment.Audience = comment.Audience;
                            newComment.CreatedDate = comment.CreatedDate.ToString("MMM d, yyyy") + " at " + comment.CreatedDate.ToString("h:mm tt");
                            newComment.Text = comment.Text;
                            newComments.Add(newComment);
                        }
                        newDetails.Comments = newComments;
                    }

                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(newDetails.GetType());
                    using (MemoryStream ms = new MemoryStream())
                    {
                        serializer.WriteObject(ms, newDetails);
                        string retVal = Encoding.Default.GetString(ms.ToArray());
                        return retVal;
                    }
                }
                return string.Empty;
            }
        }
Beispiel #15
0
        public void RUD_SNAP_Workflow_State_Type()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Workflow_State_Types.InsertOnSubmit(new SNAP_Workflow_State_Type()
                {
                    pkId = 20,
                    typeName = "TESTTYPE"
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Workflow_State_Types.Where(t=>t.pkId==20).ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Workflow_State_Types.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Workflow_State_Types.Where(t => t.pkId == 20).ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #16
0
Datei: UI.cs Projekt: apxlee/SAP
        public static List<BuilderActor> GetRequestActors(int requestId)
        {
            List<BuilderActor> actorList = new List<BuilderActor>();
            using (var db = new SNAPDatabaseDataContext())
            {
                var query = from a in db.SNAP_Actors
                            join sw in db.SNAP_Workflows on a.pkId equals sw.actorId
                            join sws in db.SNAP_Workflow_States on sw.pkId equals sws.workflowId
                            where sw.requestId == requestId
                            group sw by new { a.userId, sw.requestId, sw.actorId } into wfGroup
                            select new
                            {
                                ActorId = wfGroup.Key.actorId,
                                UserId = wfGroup.Key.userId,
                                WorkflowId = wfGroup.Max(sw => sw.pkId)
                            };

                foreach (var actor in query)
                {
                    BuilderActor newActor = new BuilderActor();
                    newActor.ActorId = actor.ActorId;
                    newActor.UserId = actor.UserId;
                    newActor.WorkflowState = (WorkflowState)ApprovalWorkflow.GetWorkflowState(actor.WorkflowId);
                    actorList.Add(newActor);
                }
            }
            return actorList;
        }
Beispiel #17
0
 public static void UpdateRequestData(List<RequestData> newRequestList, List<usp_open_request_tabResult> requestData)
 {
     var result = UpdatedRequestDataList(newRequestList, requestData);
     if (result.Count > 0)
     {
         using (var db = new SNAPDatabaseDataContext())
         {
             var reqId = requestData[0].requestId;
             foreach(var data in result)
             {
                 var accessUserText = new SNAP_Access_User_Text()
                                          {
                                              requestId = reqId,
                                              access_details_formId = Convert.ToInt16(data.FormId),
                                              userText = data.UserText,
                                              modifiedDate = DateTime.Now
                                          };
                 db.SNAP_Access_User_Texts.InsertOnSubmit(accessUserText);
             }
             db.SubmitChanges();
         }
     }
 }
Beispiel #18
0
        public void RUD_SNAP_Actor_Group_Type()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
            //        db.SNAP_Actor_Group_Types.InsertOnSubmit(new SNAP_Actor_Group_Type()
            //        {
            //            pkId = 20,
            //            typeName = "TESTTYPE"
            //        });
            //        db.SubmitChanges();

                SNAP_Actor_Group_Type test = new SNAP_Actor_Group_Type();
                test.pkId = 0;
                test.typeName = "Test Type";

                var test1 = db.SNAP_Actor_Group_Types.Where(t => t.pkId == 1).ToList();
                Assert.IsTrue(test1.Count > 0);

            //        foreach (var type in test1)
            //        {
            //            db.SNAP_Actor_Group_Types.DeleteOnSubmit(type);
            //        }
            //        db.SubmitChanges();

            //        var test2 = db.SNAP_Actor_Group_Types.Where(t => t.pkId == 20).ToList();
            //        Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #19
0
        public void ShouldReturnRequestData()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                var maxRequestId = db.SNAP_Requests.Max(x => x.pkId);
                var requestTexts = db.RetrieveRequestUserText(maxRequestId);

                foreach (var text in requestTexts)
                {
                    Console.WriteLine(text.userText);
                }
                Assert.IsTrue(requestTexts.Count() > 0);

            }
        }
Beispiel #20
0
        public void RUD_SNAP_Actor_Group()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Actor_Groups.InsertOnSubmit(new SNAP_Actor_Group()
                {
                    groupName = "Test Group",
                    description = "Test Group Description",
                    actorGroupType = 0,
                    isActive = false,
                    isLargeGroup = false
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Actor_Groups.Where(t => t.groupName == "Test Group").ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Actor_Groups.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Actor_Groups.Where(t => t.groupName == "Test Group").ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #21
0
        public void RUD_SNAP_Actor()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Actors.InsertOnSubmit(new SNAP_Actor()
                {
                    userId = "testuser",
                    displayName = "Test User",
                    emailAddress = "*****@*****.**",
                    isActive = false,
                    isDefault = false,
                    isGroup = false,
                    actor_groupId = 0
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Actors.Where(t => t.userId == "testuser").ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Actors.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Actors.Where(t => t.userId == "testuser").ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #22
0
        public void RUD_SNAP_Access_User_Text()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Access_User_Texts.InsertOnSubmit(new SNAP_Access_User_Text()
                {
                    requestId = 0,
                    access_details_formId = 20,
                    userText = "For unit testing",
                    modifiedDate = DateTime.Now
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Access_User_Texts.Where(t => t.requestId == 0).ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Access_User_Texts.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Access_User_Texts.Where(t => t.requestId == 0).ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #23
0
        public void RUD_SNAP_Access_Details_Form()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Access_Details_Forms.InsertOnSubmit(new SNAP_Access_Details_Form()
                {
                    parentId = 20,
                    label = "Test Field",
                    description = "For Unit Testing",
                    isActive = false,
                    isRequired = false
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Access_Details_Forms.Where(t => t.label == "Test Field").ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Access_Details_Forms.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Access_Details_Forms.Where(t => t.label == "Test Field").ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #24
0
        public void RUD_Request_Comment()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Request_Comments.InsertOnSubmit(new SNAP_Request_Comment()
                {
                    requestId = 0,
                    commentText = "Test Comment",
                    commentTypeEnum = 0,
                    createdDate = DateTime.Now
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Request_Comments.Where(t => t.commentText == "Test Comment").ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Request_Comments.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Request_Comments.Where(t => t.commentText == "Test Comment").ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #25
0
        private void cleanUp()
        {
            using (var db = new SNAPDatabaseDataContext())
            {

                var reqs = db.SNAP_Requests.Where(x => x.submittedBy == "UnitTester").ToList();

                foreach (var r in reqs)
                {
                    var wfs = db.SNAP_Workflows.Where(x => x.requestId == r.pkId).ToList();
                    foreach (SNAP_Workflow wf in wfs)
                    {
                        var states = db.SNAP_Workflow_States.Where(x => x.workflowId == wf.pkId);
                        db.SNAP_Workflow_States.DeleteAllOnSubmit(states);

                        var comments = db.SNAP_Workflow_Comments.Where(c => c.workflowId == wf.pkId);
                        db.SNAP_Workflow_Comments.DeleteAllOnSubmit(comments);
                    }

                    db.SNAP_Workflows.DeleteAllOnSubmit(wfs);

                    var uts = db.SNAP_Access_User_Texts.Where(x => x.requestId == r.pkId);
                    db.SNAP_Access_User_Texts.DeleteAllOnSubmit(uts);
                    db.SNAP_Requests.DeleteOnSubmit(r);

                    var reqComments = db.SNAP_Request_Comments.Where(c => c.requestId == r.pkId);
                    db.SNAP_Request_Comments.DeleteAllOnSubmit(reqComments);
                }

                db.SubmitChanges();
            }
        }
Beispiel #26
0
        public void RUD_SNAP_Weekends_and_Holiday()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                //db.SNAP_Weekends_and_Holidays.InsertOnSubmit(new SNAP_Weekends_and_Holiday()
                //{
                //    dayName = "TESTDAY",
                //    dayOfWeekDate = DateTime.Now
                //});
                //db.SubmitChanges();

                SNAP_Weekends_and_Holiday test = new SNAP_Weekends_and_Holiday();
                test.dayName = "MON";
                test.dayOfWeekDate = DateTime.Now;

                var test1 = db.SNAP_Weekends_and_Holidays.Where(t => t.dayName == test.dayName).ToList();
                Assert.IsTrue(test1.Count > 0);

                //foreach (var row in test1)
                //{
                //    db.SNAP_Weekends_and_Holidays.DeleteOnSubmit(row);
                //}
                //db.SubmitChanges();

                //var test2 = db.SNAP_Weekends_and_Holidays.Where(t => t.dayName == "TESTDAY").ToList();
                //Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #27
0
        /*
        static DataTable GetTable()
        {
            DataTable table = new DataTable();
            table.Columns.Add("pkId", typeof(int));
            table.Columns.Add("parentId", typeof(int));
            table.Columns.Add("label", typeof(string));
            table.Columns.Add("description", typeof(string));
            table.Columns.Add("isActive", typeof(bool));
            table.Columns.Add("isRequired", typeof(bool));

            table.Rows.Add(2, 1, "Windows Servers", "<p>Enter the <strong>exact</strong> servers you need access to...</p>", true, true);
            table.Rows.Add(3, 1, "Linux/Unix Servers", "<p>Enter the exact...</p>", true, true);
            table.Rows.Add(4, 1, "Network Shares", "<p>Enter the exact...</p>", true, true);
            return table;
        }
        */
        private IEnumerable<SNAP_Access_Details_Form> loadDetailRequestFormData()
        {
            var db = new SNAPDatabaseDataContext();
            var formDetails = from form in db.SNAP_Access_Details_Forms
                                  where (form.parentId == 1) && (form.isActive == true)
                                  select form;

            return formDetails;
        }
Beispiel #28
0
        public void RUD_SNAP_Workflow()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Workflows.InsertOnSubmit(new SNAP_Workflow()
                {
                    actorId = 0,
                    requestId = 0
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Workflows.Where(t => t.requestId == 0 && t.actorId == 0).ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Workflows.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Workflows.Where(t => t.requestId == 0 && t.actorId == 0).ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #29
0
        public void RUD_SNAP_Request()
        {
            using (var db = new SNAPDatabaseDataContext())
            {
                db.SNAP_Requests.InsertOnSubmit(new SNAP_Request()
                {
                    userId = "testuser",
                    userTitle = "Unit Tester",
                    userDisplayName = "Test Account",
                    managerUserId = "manager",
                    managerDisplayName = "Test Manager",
                    submittedBy = "submitter",
                    isChanged = false,
                    statusEnum = 0,
                    createdDate = DateTime.Now,
                    lastModifiedDate = DateTime.Now,
                    ticketNumber = "0000"
                });
                db.SubmitChanges();

                var test1 = db.SNAP_Requests.Where(t => t.userId == "testuser").ToList();
                Assert.IsTrue(test1.Count > 0);

                foreach (var row in test1)
                {
                    db.SNAP_Requests.DeleteOnSubmit(row);
                }
                db.SubmitChanges();

                var test2 = db.SNAP_Requests.Where(t => t.userId == "testuser").ToList();
                Assert.IsTrue(test2.Count == 0);
            }
        }
Beispiel #30
0
Datei: UI.cs Projekt: apxlee/SAP
        public static string GetAccessTeamFilter()
        {
            string filter = "";
            List<int> openEnums = new List<int>();
            openEnums.Add((int)RequestState.Open);
            openEnums.Add((int)RequestState.Pending);
            openEnums.Add((int)RequestState.Change_Requested);
            RequestFilter newFilter = new RequestFilter();

            List<Filter> newFilters = new List<Filter>();

            Filter PendingAcknowledgementFilter = new Filter();
            Filter PendingWorkflowFilter = new Filter();
            Filter PendingTicketFilter = new Filter();
            Filter PendingProvisioningFilter = new Filter();
            Filter ChangeRequestedFilter = new Filter();
            Filter InWorkflowFilter = new Filter();

            List<int> PendingAcknowledgementList = new List<int>();
            List<int> PendingWorkflowList = new List<int>();
            List<int> PendingTicketList = new List<int>();
            List<int> PendingProvisioningList = new List<int>();
            List<int> ChangeRequestedList = new List<int>();
            List<int> InWorkflowList = new List<int>();

            using (var db = new SNAPDatabaseDataContext())
            {
                var filterCounts = from r in db.SNAP_Requests
                                 join w in db.SNAP_Workflows on r.pkId equals w.requestId
                                 join ws in db.SNAP_Workflow_States on w.pkId equals ws.workflowId
                                 join a in db.SNAP_Actors on w.actorId equals a.pkId
                                 where a.pkId == AccessTeamActorId
                                 && openEnums.Contains(r.statusEnum)
                                 && ws.completedDate == null
                                 group r by new { r.pkId, r.ticketNumber, ws.workflowStatusEnum } into grp
                                 select new
                                  {
                                      requestId = grp.Key.pkId,
                                      ticketNumber = grp.Key.ticketNumber,
                                      workflowStatusEnum = grp.Key.workflowStatusEnum
                                  };
                if(filterCounts != null)
                {
                    foreach(var row in filterCounts)
                    {
                        switch (row.workflowStatusEnum)
                        {
                            case (int)WorkflowState.Pending_Acknowledgement:
                                PendingAcknowledgementList.Add(row.requestId);
                                break;
                            case (int)WorkflowState.Pending_Workflow:
                                PendingWorkflowList.Add(row.requestId);
                                break;
                            case (int)WorkflowState.Approved:
                            case (int)WorkflowState.Pending_Provisioning:
                                if (row.ticketNumber == null) { PendingTicketList.Add(row.requestId); }
                                else { PendingProvisioningList.Add(row.requestId); }
                                break;
                            case (int)WorkflowState.Workflow_Created:
                                InWorkflowList.Add(row.requestId);
                                break;
                            case (int)WorkflowState.Change_Requested:
                                ChangeRequestedList.Add(row.requestId);
                                break;
                        }
                    }

                    PendingAcknowledgementFilter.FilterName = "Ack";
                    PendingAcknowledgementFilter.RequestIds = PendingAcknowledgementList;
                    PendingWorkflowFilter.FilterName = "WrkFl";
                    PendingWorkflowFilter.RequestIds = PendingWorkflowList;
                    PendingTicketFilter.FilterName = "Tkt";
                    PendingTicketFilter.RequestIds = PendingTicketList;
                    PendingProvisioningFilter.FilterName = "Prov";
                    PendingProvisioningFilter.RequestIds = PendingProvisioningList;
                    ChangeRequestedFilter.FilterName = "Chng Req";
                    ChangeRequestedFilter.RequestIds = ChangeRequestedList;
                    InWorkflowFilter.FilterName = "In WrkFl";
                    InWorkflowFilter.RequestIds = InWorkflowList;
                    newFilters.Add(PendingAcknowledgementFilter);
                    newFilters.Add(PendingWorkflowFilter);
                    newFilters.Add(PendingTicketFilter);
                    newFilters.Add(PendingProvisioningFilter);
                    newFilters.Add(ChangeRequestedFilter);
                    newFilters.Add(InWorkflowFilter);
                    newFilter.Filters = newFilters;

                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(newFilter.GetType());
                    using (MemoryStream ms = new MemoryStream())
                    {
                        serializer.WriteObject(ms, newFilter);
                        string retVal = Encoding.Default.GetString(ms.ToArray());
                        filter = retVal;
                    }
                }
            }

            return filter;
        }