Пример #1
0
        public User Login(string LoginName, string Password)
        {
            try
            {
                if(IsLoggedOn == true)
                {
                    //mvarLoggedOnUser = new User();
                    IsLoggedOn = false;
                }

                Functions F = new Functions();
                //Check to see if Login is valid and Fill User
                try
                {
                    mvarLoggedOnUser = new User();

                    mvarLoggedOnUser = F.GetUser(LoginName,Password);

                    if(mvarLoggedOnUser == null)
                    {
                        throw new ApplicationException("Invalid Login Name or Password!");
                    }
                    //myConnection.Close();
                }
                catch(Exception Err)
                {
                    throw new Exception(Err.Message,Err.InnerException);
                }

                //Check if SystemAdmin
                SectionType ST = mvarLoggedOnUser.HighestAuthorityLevel;
                if(ST.mvarPreviousSectionTypeID == -99)
                {
                    //Check to see if SystemAdmin already logged in
                    if(OysterTimer.Enabled == false)
                    {
                        SystemAdminAlreadyLoggedIn = F.IsSystemAdminLoggedIn();
                        if(SystemAdminAlreadyLoggedIn == false)
                        {
                            AcquireSystemLock();
                            OysterTimer.Enabled = true;
                        }
                    }

                }

                IsLoggedOn = true;
                return mvarLoggedOnUser;
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Пример #2
0
 public User GetUserById(int Id)
 {
     Functions F = new Functions();
     User U = F.GetUser(Id);
     F.Dispose();
     return U;
 }
Пример #3
0
        public User Login(string CardNumber)
        {
            try
            {
                User TempUser = null;
                Functions F =new Functions();
                //Check to see if Login is valid and Fill User
                try
                {
                    TempUser = new User();

                    TempUser = F.GetUser(CardNumber);
                    if(TempUser == null)
                        throw new ApplicationException("Card not found in database!");

                    return Login(TempUser.LoginName,TempUser.Password);
                }
                catch(Exception Err)
                {
                    throw new ApplicationException(Err.Message);
                }
            }
            catch(Exception Err)
            {
                throw new ApplicationException(Err.Message);
            }
        }
Пример #4
0
 public User GetUserByCardNumberRaw(string CardNumber)
 {
     string FCardNumber = FormatCardNumber(CardNumber);
     Functions F = new Functions();
     User U = F.GetUser(FCardNumber);
     F.Dispose();
     return U;
 }
Пример #5
0
 public User GetUserByCardNumber(string CardNumber)
 {
     Functions F = new Functions();
     User U = F.GetUser(CardNumber);
     F.Dispose();
     return U;
 }
Пример #6
0
        private void FillTree(int UserId)
        {
            LUser = (User)Session["LUser"];
            Functions F = new Functions();

            User CU = F.GetUser(UserId);
            Sections SS = CU.AllMemberSections;
            Session["Members"] = SS;
            tv.Nodes[0].Text = CU.Description;
            tv.Nodes[0].Type = "User";
            tv.Nodes[0].NodeData = CU.ID.ToString() + ":" + "-999";
            tv.Nodes[0].Expanded = true;
            tv.Nodes[0].Nodes.Clear();
            TreeNode L = new TreeNode();
            L.Text = "Current Sections";
            L.Type = "Label";
            L.Expanded = true;
            tv.Nodes[0].Nodes.Add(L);

            TreeNode U = new TreeNode();
            U.Text = "Unassigned Recordings";
            U.Type = "Label";
            U.DefaultStyle.Add("color","brown");
            U.Expanded = true;

            //Current Sections
            if(CU.ID == LUser.ID)
            {
                foreach(Section CurrentSection in SS)
                {
                    if(CurrentSection.IsDefault == false)
                    {
            //                        Sections AOS = LUser.AllOwnedSections;
            //                        if(AOS == null) goto SkipSections;
                        //Add this Section to the treeview and the users recordings in it.
                        TreeNode N = new TreeNode();
                        N.Text = CurrentSection.Description;
                        N.Type = "Section";
                        N.DefaultStyle.Add("color","DarkGreen");
                        N.NodeData = CurrentSection.ID.ToString();
                        N.ImageUrl = tv.TreeNodeTypes[4].ImageUrl;
                        Recordings CurrentRecordings = F.ALLRecordings(UserId,CurrentSection.ID);
                        int SessionCount = 0;
                        TreeNode[] NSession = new TreeNode[1];
                        ListBox LB = new ListBox();
                        string NData = "";
                        foreach(Recording R in CurrentRecordings)
                        {
                            NData =  R.SessionID + ":" + CU.ID.ToString() +":" + CurrentSection.ID.ToString();

                                if(R.SessionID != "")
                            {
                                bool SkipThis = false;
                                foreach(ListItem LI in LB.Items)
                                {
                                    if(LI.Text == NData)
                                    {
                                        SkipThis = true;
                                    }
                                }
                                if(SkipThis == false)
                                {
                                    SessionCount++;
                                    ListItem LI = new ListItem(NData,R.SessionName);
                                    LB.Items.Add(LI);
                                }
                            }
                        }
                        NSession = new TreeNode[SessionCount];
                        int FillItem = 0;
                        foreach(ListItem LI in LB.Items)
                        {
                            NSession[FillItem] = new TreeNode();
                            NSession[FillItem].Text = LI.Value;
                            NSession[FillItem].NodeData = LI.Text;
                            NSession[FillItem].Type = "RecordingSession";
                            NSession[FillItem].DefaultStyle.Add("color","DarkBlue");
                            NSession[FillItem].ImageUrl = tv.TreeNodeTypes[2].ImageUrl;
                            N.Nodes.Add(NSession[FillItem]);
                            FillItem++;
                        }
                        foreach(Recording R in CurrentRecordings)
                        {
                            TreeNode N2 = new TreeNode();
                            N2.Text = R.DisplayName;
                            N2.Type = "Recording";
                            N2.DefaultStyle.Add("color","Blue");

                            N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();
                            N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                            if(R.SessionID != null)
                            {
                                for(int i = 0; i< SessionCount;i++)
                                {
                                    string[] SID = NSession[i].NodeData.Split(':');
                                    if(R.SessionID == SID[0])
                                    {
                                        NSession[i].Nodes.Add(N2);
                                    }
                                }
                            }
                        }
                        foreach(Recording R in CurrentRecordings)
                        {
                            TreeNode N2 = new TreeNode();
                            N2.Text = R.DisplayName;
                            if(!R.IsReady)
                            {
                                N2.Type = "Label";
                                N2.DefaultStyle.Add("color","Gray");
                            }
                            else
                            {
                                N2.Type = "Recording";
                                N2.DefaultStyle.Add("color","Blue");
                            }
                            N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();
                            N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;

                            if(R.SessionID == "")
                            {
                                N.Nodes.Add(N2);
                            }
                        }
                        L.Nodes.Add(N);
                    }
               // SkipSections:{}
                }
            }
            else
            {
                foreach(Section CurrentSection in SS)
                {
                    if(CurrentSection.IsDefault == false)
                    {
                        Sections AOS = LUser.AllOwnedSections;
                        if(AOS == null) goto SkipSections;
                        foreach(Section LoginUserSection in AOS)
                        {
                            if(LoginUserSection.IsDefault == false)
                            {
                                 bool Addit = F.IsInMyHierarchy(LoginUserSection.ID,CurrentSection.ID);

                                if(Addit == true)
                                {
                                    //Add this Section to the treeview and the users recordings in it.
                                    TreeNode N = new TreeNode();
                                    N.Text = CurrentSection.Description;
                                    N.Type = "Section";
                                    N.DefaultStyle.Add("color","DarkGreen");
                                    N.NodeData = CurrentSection.ID.ToString();
                                    N.ImageUrl = tv.TreeNodeTypes[4].ImageUrl;
                                    Recordings CurrentRecordings = F.ALLRecordings(UserId,CurrentSection.ID);
                                    int SessionCount = 0;
                                    TreeNode[] NSession = new TreeNode[1];
                                    ListBox LB = new ListBox();
                                    string NData = "";
                                    foreach(Recording R in CurrentRecordings)
                                    {
                                        NData =  R.SessionID + ":" + CU.ID.ToString() +":" + LoginUserSection.ID.ToString();

                                        if(R.SessionID != "")
                                        {
                                            bool SkipThis = false;
                                            foreach(ListItem LI in LB.Items)
                                            {
                                                if(LI.Text == NData)
                                                {
                                                    SkipThis = true;
                                                }
                                            }
                                            if(SkipThis == false)
                                            {
                                                SessionCount++;
                                                ListItem LI = new ListItem(NData,R.SessionName);
                                                LB.Items.Add(LI);
                                            }
                                        }
                                    }
                                    NSession = new TreeNode[SessionCount];
                                    int FillItem = 0;
                                    foreach(ListItem LI in LB.Items)
                                    {
                                        NSession[FillItem] = new TreeNode();
                                        NSession[FillItem].Text = LI.Value;
                                        NSession[FillItem].NodeData = LI.Text;
                                        NSession[FillItem].Type = "RecordingSession";
                                        NSession[FillItem].DefaultStyle.Add("color","DarkBlue");
                                        NSession[FillItem].ImageUrl = tv.TreeNodeTypes[2].ImageUrl;
                                        N.Nodes.Add(NSession[FillItem]);
                                        FillItem++;
                                    }
                                    foreach(Recording R in CurrentRecordings)
                                    {
                                        TreeNode N2 = new TreeNode();
                                        N2.Text = R.DisplayName;
                                        N2.Type = "Recording";
                                        N2.DefaultStyle.Add("color","Blue");

                                        N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();
                                        N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                                        if(R.SessionID != null)
                                        {
                                            for(int i = 0; i< SessionCount;i++)
                                            {
                                                string[] SID = NSession[i].NodeData.Split(':');
                                                if(R.SessionID == SID[0])
                                                {
                                                    NSession[i].Nodes.Add(N2);
                                                }
                                            }
                                        }
                                    }
                                    foreach(Recording R in CurrentRecordings)
                                    {
                                        TreeNode N2 = new TreeNode();
                                        N2.Text = R.DisplayName;
                                        if(!R.IsReady)
                                        {
                                            N2.Type = "Label";
                                            N2.DefaultStyle.Add("color","Gray");
                                        }
                                        else
                                        {
                                            N2.Type = "Recording";
                                            N2.DefaultStyle.Add("color","Blue");
                                        }
                                        N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();
                                        N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;

                                        if(R.SessionID == "")
                                        {
                                            N.Nodes.Add(N2);
                                        }
                                    }
                                    L.Nodes.Add(N);
                                }
                            }
                        }
                    }
                SkipSections:{}
                }
            }
            if(L.Nodes.Count == 0)
                L.Text = "No Member Sections";

            // Owned Sections
            foreach(Section CurrentSection in CU.AllOwnedSections)
            {

                if(CurrentSection.IsDefault == true)
                {
                    bool CanView = false;
                    foreach(Permission P in LUser.HighestAuthorityLevel.CanViewUnassignedRecordings)
                    {
                        CanView = true;
                    }
                    if((CanView == true)||(LUser.ID == UserId))
                    {
                        Recordings CurrentRecordings = CurrentSection.CurrentRecordings;
                        int SessionCount = 0;
                        TreeNode[] NSession = new TreeNode[1];
                        ListBox LB = new ListBox();
                        string NData = "";
                        foreach(Recording R in CurrentRecordings)
                        {
                            NData =  R.SessionID + ":" + CU.ID.ToString() +":" + CurrentSection.ID.ToString();
                            if(R.SessionID != "")
                            {
                                bool SkipThis = false;
                                foreach(ListItem LI in LB.Items)
                                {

                                    if(LI.Text == NData)
                                    {
                                        SkipThis = true;
                                    }
                                }
                                if(SkipThis == false)
                                {
                                    SessionCount++;

                                    ListItem LI = new ListItem(NData,R.SessionName);
                                    LB.Items.Add(LI);
                                }
                            }
                        }
                        NSession = new TreeNode[SessionCount];
                        int FillItem = 0;
                        foreach(ListItem LI in LB.Items)
                        {
                            NSession[FillItem] = new TreeNode();
                            NSession[FillItem].Text = LI.Value;
                            NSession[FillItem].NodeData = LI.Text;
                            NSession[FillItem].Type = "RecordingSession";
                            NSession[FillItem].DefaultStyle.Add("color","DarkBlue");
                             NSession[FillItem].ImageUrl = tv.TreeNodeTypes[2].ImageUrl;
                            U.Nodes.Add(NSession[FillItem]);
                            FillItem++;
                        }
                        foreach(Recording R in CurrentRecordings)
                        {
                            TreeNode N2 = new TreeNode();
                            N2.Text = R.DisplayName;
                            N2.Type = "Recording";
                            N2.DefaultStyle.Add("color","Blue");
                            N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();

                             N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                            if(R.SessionID != "")
                            {
                                for(int i = 0; i< SessionCount;i++)
                                {
                                    string[] SID = NSession[i].NodeData.Split(':');
                                    if(R.SessionID == SID[0])
                                    {
                                        NSession[i].Nodes.Add(N2);
                                    }
                                }
                            }
                        }
                        foreach(Recording R in CurrentRecordings)
                        {
                            TreeNode N2 = new TreeNode();
                            N2.Text = R.DisplayName;
                            if(!R.IsReady)
                            {
                                N2.Type = "Label";
                                N2.DefaultStyle.Add("color","Gray");
                            }
                            else
                            {
                                N2.Type = "Recording";
                                N2.DefaultStyle.Add("color","Blue");
                            }
                            N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":" + CurrentSection.ID.ToString();
                             N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                            if(R.SessionID == "")
                            {
                                U.Nodes.Add(N2);
                            }
                        }
                        if(U.Nodes.Count == 0)
                            U.Text = "No Unassigned Recordings";
                        tv.Nodes[0].Nodes.Add(U);
                    }
                }
            }
            //Groups
            OysterClassLibrary.Groups GPS = null;
            if(LUser.HighestAuthorityLevel.ID == OSystem.SectionTypeSysAdmin.ID)
                GPS = OSystem.GetALLGroups(false);
            else
                GPS = LUser.CurrentGroups;
            TreeNode NodeGroups = new TreeNode();
            NodeGroups.Text = "Current Groups";
            NodeGroups.DefaultStyle.Add("color","Green");
            NodeGroups.Type = "labelGroup";
            tv.Nodes[0].Nodes.Add(NodeGroups);

            TreeNode NPublic = new TreeNode();
            TreeNode NPrivate = new TreeNode();

            NPublic.Text = "Public Groups";
            NPrivate.Text = "Private Groups";

            NPublic.Type = "GroupName";
            NPrivate.Type = "GroupName";

            NPublic.DefaultStyle.Add("color","DarkBlue");
            NPrivate.DefaultStyle.Add("color","DarkGreen");

            NodeGroups.Nodes.Add(NPublic);
            NodeGroups.Nodes.Add(NPrivate);

            foreach(OysterClassLibrary.Group G in GPS)
            {
                TreeNode GNode = new TreeNode();
                GNode.Text = G.Description;
                GNode.NodeData = G.ID.ToString();
                if(G.IsPublicAccess)
                {
                    GNode.DefaultStyle.Add("color","Blue");
                    NPublic.Nodes.Add(GNode);

                }
                else
                {
                    GNode.DefaultStyle.Add("color","Green");
                    NPrivate.Nodes.Add(GNode);
                }

                if(G.CurrentRecordings.Count == 0)
                {
                    TreeNode NoRecs = new TreeNode();
                    NoRecs.Text = "No available recordings";
                    NoRecs.DefaultStyle.Add("color","#696969");
                    GNode.Nodes.Add(NoRecs);
                }
                else //if(G.CurrentRecordings.Count > 0)
                {
                    Recordings CurrentRecordings = G.CurrentRecordings;
                    int SessionCount = 0;
                    TreeNode[] NSession = new TreeNode[1];
                    ListBox LB = new ListBox();
                    string NData = "";
                    foreach(Recording R in CurrentRecordings)
                    {
                        NData =  R.SessionID + ":" + CU.ID.ToString() +":0";
                        if(R.SessionID != "")
                        {
                            bool SkipThis = false;
                            foreach(ListItem LI in LB.Items)
                            {

                                if(LI.Text == NData)
                                {
                                    SkipThis = true;
                                }
                            }
                            if(SkipThis == false)
                            {
                                SessionCount++;

                                ListItem LI = new ListItem(NData,R.SessionName);
                                LB.Items.Add(LI);
                            }
                        }
                    }
                    NSession = new TreeNode[SessionCount];
                    int FillItem = 0;
                    foreach(ListItem LI in LB.Items)
                    {
                        NSession[FillItem] = new TreeNode();
                        NSession[FillItem].Text = LI.Value;
                        NSession[FillItem].NodeData = LI.Text;
                        NSession[FillItem].Type = "RecordingSession";
                        NSession[FillItem].DefaultStyle.Add("color","DarkBlue");
                        NSession[FillItem].ImageUrl = tv.TreeNodeTypes[2].ImageUrl;
                        GNode.Nodes.Add(NSession[FillItem]);
                        FillItem++;
                    }
                    foreach(Recording R in CurrentRecordings)
                    {
                        TreeNode N2 = new TreeNode();
                        N2.Text = R.DisplayName;
                        N2.Type = "Recording";
                        N2.DefaultStyle.Add("color","Blue");
                        N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":0";

                        N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                        if(R.SessionID != "")
                        {
                            for(int i = 0; i< SessionCount;i++)
                            {
                                string[] SID = NSession[i].NodeData.Split(':');
                                if(R.SessionID == SID[0])
                                {
                                    NSession[i].Nodes.Add(N2);
                                }
                            }
                        }
                    }
                    foreach(Recording R in CurrentRecordings)
                    {
                        TreeNode N2 = new TreeNode();
                        N2.Text = R.DisplayName;
                        if(!R.IsReady)
                        {
                            N2.Type = "Label";
                            N2.DefaultStyle.Add("color","Gray");
                        }
                        else
                        {
                            N2.Type = "Recording";
                            N2.DefaultStyle.Add("color","Blue");
                        }
                        N2.NodeData = R.ID.ToString()+ ":" + CU.ID.ToString() + ":0";
                        N2.ImageUrl = tv.TreeNodeTypes[1].ImageUrl;
                        if(R.SessionID == "")
                        {
                            GNode.Nodes.Add(N2);
                        }
                    }

                    //NodeGroups.Nodes.Add(GNode);
                }
            }

            if(NPublic.Nodes.Count == 0)
            {
                TreeNode NPNGroups = new TreeNode();
                NPNGroups.Text = "No groups available";
                NPNGroups.DefaultStyle.Add("color","#696969");
                NPublic.Nodes.Add(NPNGroups);
            }

            if(NPrivate.Nodes.Count == 0)
            {
                TreeNode NPriGroups = new TreeNode();
                NPriGroups.Text = "No groups available";
                NPriGroups.DefaultStyle.Add("color","#696969");
                NPrivate.Nodes.Add(NPriGroups);
            }
        }
Пример #7
0
        private void imgButtonRename_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            Transitioning = true;
            LUser = (User)Session["LUser"];
            try
            {
                string[] checkit = imgButtonRename.ImageUrl.Split('/');

                switch(checkit[1])
                {
                    case "Tab_B_RenameRec.jpg":
                        TreeNode XNode = tv.GetNodeFromIndex(tv.SelectedNodeIndex);

                        if(XNode.Type == "Recording")
                        {
                            Functions F = new Functions();
                            string[] sarray = XNode.NodeData.Split(':');
                            int RecordingId = Convert.ToInt32(sarray[0],10);
                            Recording Rec = F.GetRecording(RecordingId);

                            int UserId = Convert.ToInt32(sarray[1],10);
                            User U = F.GetUser(UserId);

                            int SectionId = Convert.ToInt32(sarray[2],10);
                            Section S = F.GetSection(SectionId);

                            int CurrentSectionTypeId = S.CreatedBySectionType.ID;
                            LUser = (User)Session["LUser"];

                            if(LUser.ID == UserId)
                            {
                                Session["Recording"] = Rec;
                                Session["Section"] = S;
                                Session["User"] = U;
                                tbDialogData.Value = Rec.DisplayName;
                                //Response.Redirect("RenameRecording.aspx",false);
                                tbShowDialog.Value = "RenameRecording";
                                return;
                            }
                            else
                            {
                                txtAlert.Value = "Sorry: Only the owner of a recording may change the recording's name.";
                            }
                        }

                        break;

                    case "Tab_B_RenameSes.jpg":
                        TreeNode XNode2 = tv.GetNodeFromIndex(tv.SelectedNodeIndex);
                        if(XNode2.Type == "RecordingSession")
                        {
                            string[] SID = XNode2.NodeData.Split(':');
                            int UserId = Convert.ToInt32(SID[1],10);

                            if(LUser.ID == UserId)
                            {
                                Session["SessionInfo"] = XNode2;
                                //Response.Redirect("RenameSession.aspx",false);
                                tbDialogData.Value = XNode2.Text;
                                tbShowDialog.Value = "RenameSession";
                                return;
                            }
                            else
                            {
                                txtAlert.Value = "Sorry: Only the owner of a Session may change the Session's name.";
                            }
                        }
                        break;
                    case "Tab_B_RecordView.jpg":

                        break;
                    case "Tab_B_RecordSce.jpg":
                        TreeNode NScene = CTV.GetNodeFromIndex(CTV.SelectedNodeIndex);
                        OysterClassLibrary.Room RM = null;

                        OSystem = (Oyster)Session["Oyster"];
                        if(NScene.Type == "Scene")
                        {
                            int RoomId = Convert.ToInt32(NScene.NodeData,10);
                            RM = OSystem.GetRoomById(RoomId);
                        }
                        else
                        {
                            int SEId = Convert.ToInt32(NScene.NodeData,10);
                            OysterClassLibrary.StreamingEncoder SE = OSystem.GetStreamingEncoderById(SEId);
                            RM = SE.CurrentRoom;
                        }

                        tbDialogData.Value = LUser.CardNumber+ "*" + RM.AllCurrentCardReaders.Item(0).ID + "*" + RM.AllCurrentStreamingEncoders.Item(0).CurrentMediaBufferServer.Address + "*" + RM.AllCurrentStreamingEncoders.Item(0).CurrentMediaBufferServer.Port + "*" + RM.Description;
                        Session["RECORDSCENE"] = RM;

                        tbShowDialog.Value =  "RECORDSCENE";

                        break;

                    case "Tab_B_EditNote.jpg":
                        if(dgNotes.SelectedIndex == -1) return;
                        //txtPausePlayers.Value = "Pause";
                        LockAll.Value = "true";
                        DataRow r = DS.Tables[0].Rows[dgNotes.SelectedIndex];
                        //dgNotes.Visible = false;
                        //lblSync.Visible = true;
                        //tbSync.Visible = true;
                        //taNote.Visible = true;
                        //tbSync.Value = r[1].ToString();
                        //taNote.Value = r[2].ToString();

                        //TabStrip1.Enabled = false;
                        //imgButtonView.ImageUrl = "images/btnCancel.jpg";
                        //imgButtonRename.ImageUrl = "images/btnConfirm.jpg";
                        //imgButtonView.Visible=true;
                        //imgButtonRename.Visible=true;
                        //imgButtonMove.Visible=false;
                        //imgButtonMisc.Visible=false;
                        //Session["NoteAction"] = "Update";

                        tbDialogData.Value = r[1].ToString() +"*"+ r[2].ToString();

                        tbShowDialog.Value =  "EditNote";
                        //imgButtonMisc.ImageUrl = "images/Tab_B_UpdateNote.jpg";
                        //imgButtonMisc.Visible = true;
                        //                    Session["DS"] = DS;
                        //                    Session["DA"] = DA;
                        //                    Session["SC"] = SC;
                        break;
                    case "Tab_B_UpdateNote.jpg":
                        //DS.Tables[0].Rows[dgNotes.SelectedIndex].AcceptChanges;
                        DS = (DataSet)Session["DS"];
                        DA = (SqlDataAdapter)Session["DA"];
                        SC = (SqlConnection)Session["SC"];
                        DA.Update(DS);
                        imgButtonMisc.Visible = true;
                        Session["DS"] = DS;
                        Session["DA"] = DA;
                        Session["SC"] = SC;
                        LockAll.Value = "false";

                        break;
                    case "btnConfirm.jpg":
                        string sAction = (string)Session["NoteAction"];
                        LockAll.Value = "false";

                        if(sAction == "New")
                        {
                            string[] NodeData = txtNotes.Value.Split(' ');
                            // Functions F = new Functions();
                            string sNoteValue = taNote.Value;
                            //F.AddNote(Convert.ToInt32(NodeData[0],10),NodeData[2],sNoteValue);
                            string sTimeStamp = txtTimeStamp.Value;
                            DS = (DataSet)Session["DS"];
                            DA = (SqlDataAdapter)Session["DA"];
                            SC = (SqlConnection)Session["SC"];
                            DataRow NewRow = DS.Tables[0].NewRow();
                            NewRow[1] = sTimeStamp;
                            NewRow[2] = sNoteValue;
                            NewRow[3] = Convert.ToInt32(NodeData[0],10);
                            DS.Tables[0].Rows.Add(NewRow);
                            try
                            {
                                DA.Update(DS);
                            }
                            catch(Exception Err)
                            {
                                txtAlert.Value = Err.Message;
                            }
                            SwitchButtons(3);
                            //RefreshGrid();
                            Session["NoteAction"] = "Nutn";
                            TabStrip1.Enabled = true;
                        }
                        else if(sAction == "Update")
                        {

                            DS = (DataSet)Session["DS"];
                            DA = (SqlDataAdapter)Session["DA"];
                            SC = (SqlConnection)Session["SC"];

                            DataRow r2 = DS.Tables[0].Rows[dgNotes.SelectedIndex];
                            r2[2] = taNote.Value;
                            //DS.Tables[0].AcceptChanges();
                            DA.Update(DS);
                            SwitchButtons(3);
                            //RefreshGrid();
                            Session["NoteAction"] = "Nutn";
                            TabStrip1.Enabled = true;
                        }
                        else if(sAction == "Delete")
                        {
                            DS = (DataSet)Session["DS"];
                            DA = (SqlDataAdapter)Session["DA"];
                            SC = (SqlConnection)Session["SC"];
                            DataRow r3 = DS.Tables[0].Rows[dgNotes.SelectedIndex];
                            r3.Delete();
                            //DS.Tables[0].AcceptChanges();
                            DA.Update(DS);
                            SwitchButtons(3);
                            //RefreshGrid();
                            Session["NoteAction"] = "Nutn";
                            TabStrip1.Enabled = true;
                        }
                        break;
                }
            }
            catch(Exception Err)
            {
                txtAlert.Value = Err.Message;
            }
        }
Пример #8
0
        private void imgButtonMove_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            Transitioning = true;
            string[] checkit = imgButtonMove.ImageUrl.Split('/');
            OSystem = (Oyster)Session["Oyster"];
            LUser = (User)Session["LUser"];
            switch(checkit[1])
            {
                case "Tab_B_MoveRec.jpg":
                    TreeNode XNode =tv.GetNodeFromIndex(tv.SelectedNodeIndex);

                    if(XNode.Type == "Recording")
                    {
                        Functions F = new Functions();
                        string[] sarray = XNode.NodeData.Split(':');
                        int RecordingId = Convert.ToInt32(sarray[0],10);
                        Recording Rec = F.GetRecording(RecordingId);

                        int UserId = Convert.ToInt32(sarray[1],10);
                        User U = F.GetUser(UserId);

                        int SectionId = Convert.ToInt32(sarray[2],10);
                        Section S = F.GetSection(SectionId);

                        int CurrentSectionTypeId = S.CreatedBySectionType.ID;
                        LUser = (User)Session["LUser"];

                        if(LUser.ID != UserId)
                        {
                            foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                            {
                                if(P.CanOperateOn == CurrentSectionTypeId)
                                {
                                    Session["Recording"] = Rec;
                                    Session["Section"] = S;
                                    Session["User"] = U;
                                    Sections M1 = LUser.AllMemberSections;
                                    string sDataCol = "";
                                    bool FirstPass = false;
                                    foreach(Section MemberS in M1)
                                    {
                                        if(S.ID != MemberS.ID)
                                        {
                                            //if(S.IsDefault == false)
                                            //{
                                            if(FirstPass == false)
                                            {
                                                FirstPass = true;
                                                sDataCol = MemberS.Description + ":" + MemberS.ID.ToString();
                                            }
                                            else
                                                sDataCol += "~" + MemberS.Description + ":" + MemberS.ID.ToString();
                                            // }
                                        }
                                    }
                                    tbDialogData.Value = sDataCol;
                                    tbShowDialog.Value =  "MoveRecording";
                                    //Response.Redirect("WebForm2.aspx",false);
                                    return;
                                }
                            }
                        }
                        else
                        {

                            if(LUser.HighestAuthorityLevel.PreviousSectionTypeID != -99)
                            {
                                foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                {
                                    if(P.CanOperateOn == CurrentSectionTypeId)
                                    {
                                        Session["Recording"] = Rec;
                                        Session["Section"] = S;
                                        Session["User"] = U;
                                        Sections M2 = LUser.AllMemberSections;
                                        string sDataCol = "";
                                        bool FirstPass = false;
                                        foreach(Section MemberS in M2)
                                        {
                                            if(S.ID != MemberS.ID)
                                            {
                                                //if(S.IsDefault == false)
                                                //{
                                                if(FirstPass == false)
                                                {
                                                    FirstPass = true;
                                                    sDataCol = MemberS.Description + ":" + MemberS.ID.ToString();
                                                }
                                                else
                                                    sDataCol += "~" + MemberS.Description + ":" + MemberS.ID.ToString();
                                                // }
                                            }
                                        }
                                        tbDialogData.Value = sDataCol;
                                        tbShowDialog.Value =  "MoveRecording";
                                        //Response.Redirect("WebForm2.aspx",false);
                                        return;
                                    }
                                }
                            }

                        }
                        txtAlert.Value = "Sorry you do not have sufficient privilege to move this recording";
                            return;
                        //FillTree(UserId);
                    }
                    break;

                case "Tab_B_MoveSes.jpg":
                    TreeNode XNode2 =tv.GetNodeFromIndex(tv.SelectedNodeIndex);

                    if(XNode2.Type == "RecordingSession")
                    {
                        //Functions F = new Functions();
                        string[] sarray = XNode2.NodeData.Split(':');
                        string SessionId = Convert.ToString(sarray[0]);

                        int UserId = Convert.ToInt32(sarray[1],10);
                        User U = OSystem.GetUserById(UserId);

                        int SectionId = Convert.ToInt32(sarray[2],10);
                        Section S = OSystem.GetSectionById(SectionId);

                        int CurrentSectionTypeId = S.CreatedBySectionType.ID;
                        LUser = (User)Session["LUser"];

                        if(LUser.ID != UserId)
                        {
                            foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                            {
                                if(P.CanOperateOn == CurrentSectionTypeId)
                                {
                                    Session["SessionId"] = SessionId;
                                    Session["Section"] = S;
                                    Session["User"] = U;
                                    //Sections M = (Sections)Session["Members"];
                                    Sections M = LUser.AllMemberSections;
                                    string sDataCol = "";
                                    bool FirstPass = false;
                                    foreach(Section MemberS in M)
                                    {
                                        if(S.ID != MemberS.ID)
                                        {
                                            //if(S.IsDefault == false)
                                            //{
                                                if(FirstPass == false)
                                                {
                                                    FirstPass = true;
                                                    sDataCol = MemberS.Description + ":" + MemberS.ID.ToString();
                                                }
                                                else
                                                    sDataCol += "~" + MemberS.Description + ":" + MemberS.ID.ToString();
                                           // }
                                        }
                                    }
                                    tbDialogData.Value = sDataCol;
                                    tbShowDialog.Value =  "MoveSession";
                                    //Response.Redirect("MoveSession.aspx",false);
                                    return;
                                }
                            }
                        }
                        else
                        {

                            if(LUser.HighestAuthorityLevel.PreviousSectionTypeID != -99)
                            {
                                foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                {
                                    if(P.CanOperateOn == CurrentSectionTypeId)
                                    {
                                        Session["SessionId"] = SessionId;
                                        Session["Section"] = S;
                                        Session["User"] = U;
                                        //Sections M = (Sections)Session["Members"];
                                        Sections M = LUser.AllMemberSections;
                                        string sDataCol = "";
                                        bool FirstPass = false;
                                        foreach(Section MemberS in M)
                                        {
                                            if(S.ID != MemberS.ID)
                                            {
                                                //if(S.IsDefault == false)
                                                //{
                                                    if(FirstPass == false)
                                                    {
                                                        FirstPass = true;
                                                        sDataCol = MemberS.Description + ":" + MemberS.ID.ToString();
                                                    }
                                                    else
                                                        sDataCol += "~" + MemberS.Description + ":" + MemberS.ID.ToString();
                                               // }
                                            }
                                        }
                                        tbDialogData.Value = sDataCol;
                                        tbShowDialog.Value =  "MoveSession";

                                        //Response.Redirect("WebForm2.aspx",false);
                                        return;
                                    }
                                }
                            }
                        }
                        FillTree(UserId);
                    }

                    break;

                case "Tab_B_RemoveNote.jpg":
                    LockAll.Value = "true";
                    //Session["NoteAction"] = "Delete";
                    //dgNotes.Visible = false;
                    //lblSync.Visible = false;
                    //tbSync.Visible = false;
                    //taNote.Visible = false;
                    //lblNoNote.Visible = true;
                    //lblNoNote.Text = "Are you sure you wish to permanently remove this note?";
                    //TabStrip1.Enabled = false;
                    //imgButtonView.ImageUrl = "images/btnCancel.jpg";
                    //imgButtonRename.ImageUrl = "images/btnConfirm.jpg";
                    //imgButtonView.Visible=true;
                    //imgButtonRename.Visible=true;
                    //imgButtonMove.Visible=false;
                    //imgButtonMisc.Visible=false;
                    tbDialogData.Value = "Permanently delete note?";
                    tbShowDialog.Value = "DeleteNote";
                    break;

                case "Tab_B_MoveCamera.jpg":
                    TreeNode TN3 = CTV.GetNodeFromIndex(CTV.SelectedNodeIndex);
                    if(TN3 != null)
                    {

                        if(TN3.Type == "Camera")
                        {
                            int SEID = Convert.ToInt32(TN3.NodeData,10);
                            OysterClassLibrary.StreamingEncoder SE = OSystem.GetStreamingEncoderById(SEID);
                            tbDialogData.Value = SE.ControlAddress + "~" + SE.ControlPort;
                            tbShowDialog.Value = "CONTROLCAMERA";
                        }
                    }
                    break;
            }
        }