コード例 #1
0
ファイル: Class1.cs プロジェクト: CarverLab/Oyster
        private static void Main(string[] args)
        {
            Console.WriteLine("Make Schedule File");

            string SourceDirectoryPath;
            string ManagementServerAddress;
            int ManagementServerPort;
            string encryptedPassword;
            bool isIdEncrypted;
            string settingKey = "SourceDirectory";
            int fileCountToMake = 1;

            if (args.Length > 0)
            {
                fileCountToMake = Convert.ToInt32(args[0]);
            }

            SourceDirectoryPath = GetApplicationSetting(settingKey);
            ManagementServerAddress = GetApplicationSetting("ManagementServerAddress");
            ManagementServerPort = int.Parse(GetApplicationSetting("ManagementServerPort"));
            encryptedPassword = GetApplicationSetting("ManagementServerId");
            isIdEncrypted = bool.Parse(GetApplicationSetting("IsIdEncrypted"));

            if (!Directory.Exists(SourceDirectoryPath))
            {
                Console.WriteLine("{0} does not exist. Attempting to create.", SourceDirectoryPath);
                try
                {
                    Directory.CreateDirectory(SourceDirectoryPath);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Could not create directory: {0}", e.Message);
                    return;
                }
            }
            //string password = Crypto.DecryptFromBase64String("cYEtk1PeJ81QJiOIew4C4w==");// GENESIS SQL Server password
            string password;
            if (isIdEncrypted)
            {
                password = Crypto.DecryptFromBase64String(encryptedPassword);
            }
            else
            {
                password = encryptedPassword;
            }
            var oyster = new OysterClassLibrary.Oyster(ManagementServerAddress, password);
            MakeScheduleFiles(SourceDirectoryPath, fileCountToMake, oyster, ManagementServerAddress, ManagementServerPort);
        }
コード例 #2
0
        private void Button2_Click(object sender, System.EventArgs e)
        {
            lbStatus.Visible = false;
            Oyster O = null;
            try
            {
                O = new Oyster();
            }
            catch(Exception Err)
            {

                lbStatus.Text = Err.Message;
                lbStatus.Visible = true;
                return;
            }
            try
            {

                User LUser = O.Login(TextBox1.Text,TextBox2.Value);
                if(LUser != null)
                {
                    Session["LUser"] = LUser;
                    Session["Oyster"] = O;
                    //txtHidden.Value = "Confirmed";
                    TextBox1.Text = "";
                    TextBox2.Value = "";
                    Response.Write("<script> window.open('OysterPlayer.aspx','','fullscreen= yes,menubar=no,resizeable=no,scrollbars=no,sizeable= yes,titlebar=no,toolbar=no,status=yes',false);</script>");
                    Session["Started"] = true;
                }
                else
                {
                    lbStatus.Text = "Invalid User Id or Password";
                    lbStatus.Visible = true;
                }
            }
            catch(Exception Err)
            {
                lbStatus.Text = Err.Message;
                lbStatus.Visible = true;
            }
        }
コード例 #3
0
ファイル: Service1.cs プロジェクト: CarverLab/Oyster
        /// <summary>
        /// Set things in motion so your service can do its work.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            ServiceThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.ThreadMain));
            ServiceThread.Start();
            bool bFound = false;

            try
            {
                OysterClassLibrary.Oyster o = new OysterClassLibrary.Oyster();
                foreach (OysterClassLibrary.ForwardingServer fs in o.FORWARDINGSERVERS)
                {
                    if (fs.Address != "Not Assigned")
                    {
                        foreach (OysterClassLibrary.MediaBufferServer mbs in fs.CurrentMediaBufferServers)
                        {
                            if (mbs.Address != "Not Assigned")
                            {
                                sXMLSourceDirectory = mbs.StorageDirectory;
                                bFound = true;
                                // get OysterRootDirectory from the system
                                OysterRootDirectory = (string)
                                    o.GetVideoStorageServerById(fs.CurrentVideoStorageServer.ID).CurrentVideoStorageServerType["OysterRootDirectory"];
                                // get OysterSourceDirectory from the system
                                OysterSourceDirectory = (string)
                                    o.GetVideoStorageServerById(fs.CurrentVideoStorageServer.ID).CurrentVideoStorageServerType["OysterSourceDirectory"];
                                // get OysterProfileName from the system
                                OysterProfileName = (string)
                                    o.GetVideoStorageServerById(fs.CurrentVideoStorageServer.ID).CurrentVideoStorageServerType["OysterProfile"];
                                break;
                            }
                        }
                    }
                }
                if (!bFound)
                {
                    log.WriteLog("Could not find a source directory in the configuration. There is nothing to do. Aborting.");
                    return;
                }
            }
            catch (System.Exception oex)
            {
                log.WriteLog("When attempting to open the OysterClassLibrary and exception occured: " + oex.Message);
                return;
            }
            if (false == System.IO.Directory.Exists(sXMLSourceDirectory))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(sXMLSourceDirectory);
                }
                catch (System.Exception dex)
                {
                    log.WriteLog("Unable to create the directory " + sXMLSourceDirectory + ": " + dex.Message + ". Aborting.");
                    return;
                }
            }
            if (OysterRootDirectory[OysterRootDirectory.Length - 1] != '\\')
                OysterRootDirectory += "\\";
            if (OysterSourceDirectory[OysterSourceDirectory.Length - 1] != '\\')
                OysterSourceDirectory += "\\";

            /*
            ENCODE_PATH = OysterSourceDirectory + "encode.bat";
            while (!IsDone)
            {
                DirectoryInfo di = new System.IO.DirectoryInfo(sXMLSourceDirectory);
                FileInfo[] fiFileInfoList = di.GetFiles("*.xml");
                SortedList slFileInfoList =
                    new SortedList(new FileInfoDateComparer(FileInfoDateComparer.DateCompareType.CreationTime));

                foreach (System.IO.FileInfo fi in fiFileInfoList)
                {
                    slFileInfoList.Add(fi,fi);
                }
                foreach (System.Collections.DictionaryEntry entry in slFileInfoList)
                {
                    System.IO.FileInfo fi = entry.Value as System.IO.FileInfo;
                    Encode(fi.Name.Substring(fi.Name.Length - 4));
                }
            }
            */
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: CarverLab/Oyster
        private void Form1_Load(object sender, System.EventArgs e)
        {
            string myPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string myConfig = myPath + @"\myConfig.xml";

            Config cfg = new Config();
            Config.ConfigurationRow row;

            if (File.Exists(myConfig))
            {
                cfg.ReadXml(myConfig);
                row = cfg.Configuration[0];
            }
            else
            {
                frmServerInfo frm = new frmServerInfo();
            //				frm.ShowDialog(this);
            //				if (frm.ServerAddress.Length < 1)
            //				{
            //					Application.Exit();
            //				}
                string serverAddress = "10.1.0.100";
                string password;
                password = Convert.ToBase64String(Encrypt("oyster1"));
                row = cfg.Configuration.AddConfigurationRow(serverAddress,0,password);
                cfg.WriteXml(myConfig);
            }

            try
            {
                _oyster = new Oyster(row.ServerAddress,Decrypt(Convert.FromBase64String(row.Password)));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Could not connect...");
                Application.Exit();
            }
            //_oyster.Login("sa","");
            foreach (StreamingEncoder encoder in _oyster.STREAMINGENCODERS)
            {
                if (encoder.CurrentStreamingEncoderType.ID == 1)
                {
                    Room room = _oyster.GetRoomById(encoder.RoomID);
                    if (room.ID != 7)
                    {
                        ListViewItem lvi = new ListViewItem(room.Description);
                        lvi.SubItems.Add(encoder.ControlAddress.ToString());
                        lvi.SubItems.Add("No");
                        lvi.SubItems.Add(string.Empty);
                        lvi.Tag = encoder;
                        listView1.Items.Add(lvi);
                    }
                }
            }
            _updateThread = new Thread(new ThreadStart(UpdateEncoderListThreadProc));
            //_updateThread.Start(); // TODO: possibly move this to a checkbox that disables the update button and starts continuous updates
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: CarverLab/Oyster
        private void Form1_Load(object sender, EventArgs e)
        {
            string serverAddress = Settings.Default.ServerAddress,
                   serverPassword = Settings.Default.ServerPassword;

            if (string.IsNullOrEmpty(serverAddress))
            {
                serverAddress = "10.1.0.100";
                Settings.Default["ServerAddress"] = serverAddress;
                Settings.Default.Save();
            }
            if (string.IsNullOrEmpty(serverPassword))
            {
                serverPassword = Crypto.EncryptToBase64String("oyster1");
                Settings.Default["ServerPassword"] = serverPassword;
                Settings.Default.Save();
            }
            _oyster = new Oyster(serverAddress, Crypto.DecryptFromBase64String(serverPassword));
            foreach (StreamingEncoder encoder in _oyster.STREAMINGENCODERS)
            {
                if (encoder.CurrentStreamingEncoderType.ID == 1)
                {
                    Room room = _oyster.GetRoomById(encoder.RoomID);
                    if (room.ID != 7)
                    {
                        ListViewItem lvi = new ListViewItem(room.Description);
                        lvi.SubItems.Add(encoder.ControlAddress);
                        lvi.SubItems.Add("No");
                        lvi.SubItems.Add(string.Empty);
                        lvi.Tag = encoder;
                        listView1.Items.Add(lvi);
                    }
                }
            }
            //_updateThread.Start(); // TODO: possibly move this to a checkbox that disables the update button and starts continuous updates
        }
コード例 #6
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void btnPostBack_ServerClick(object sender, System.EventArgs e)
        {
            txtWaitMessage.Value = "waiting";
            OSystem = (Oyster)Session["Oyster"];

            if(tbDialogResult.Value != "")
            {
                string[] sResponse = tbDialogResult.Value.Split('~');
                tbDialogResult.Value = "";
                switch(sResponse[1])
                {
                    case "RenameRecording":
                        Recording R = (Recording)Session["Recording"];
                        try
                        {
                            R.Update(R.Description,sResponse[0],R.VideoStorageServerID,R.StreamingEncoderID,R.IsReady);
                            DDL_SelectedIndexChanged(DDL,new EventArgs());
                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;
                        }
                        break;
                    case "RenameSession":
                        TreeNode XNode = (TreeNode)Session["SessionInfo"];
                        try
                        {
                            string[] SID = XNode.NodeData.Split(':');
                            Functions F = new Functions();
                            F.RenameSession(SID[0],sResponse[0]);
                            //OSystem.RenameSession(SID[0],sResponse[0]);

                            DDL_SelectedIndexChanged(DDL,new EventArgs());
                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;

                        }
                        Session["IsCancel"] = false;
                        break;
                    case "MoveRecording":
                        string[] sSelectedSection= sResponse[0].Split(':');
                        Section CS = (Section)Session["Section"];
                        Recording MRRec = (Recording)Session["Recording"];
                        User CU = (User)Session["User"];
                        int ThisSectionId = Convert.ToInt32(sSelectedSection[1],10);

                        try
                        {
                            OSystem.MoveRecording(MRRec.ID,CU.ID,ThisSectionId,CU.ID,CS.ID);
                            DDL_SelectedIndexChanged(DDL,new EventArgs());
                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;
                        }
                        break;
                    case "MoveSession":
                        string[] sSelection = sResponse[0].Split(':');
                        string SessionId = (string)Session["SessionId"];
                        Section MSec =(Section)Session["Section"];
                        User MUser = (User)Session["User"];
                        int NewSectionId = Convert.ToInt32(sSelection[1],10);
                        foreach(OysterClassLibrary.Recording MRec in MSec.CurrentRecordings)
                        {
                            if((MRec.CurrentUserID == MUser.ID)&&(SessionId == MRec.SessionID))
                            {
                                try
                                {
                                    OSystem.MoveRecording(MRec.ID,MUser.ID,NewSectionId,MRec.CurrentUserID,MRec.CurrentSectionID);
                                    DDL_SelectedIndexChanged(DDL,new EventArgs());
                                }
                                catch(Exception Err)
                                {
                                    txtAlert.Value = Err.Message;
                                }
                            }
                        }
                        break;
                    case "NewNote":
                        string[] NodeData = txtNotes.Value.Split('~');
            //						Functions FF = new Functions();
                        string[] sEnteredData = sResponse[0].Split('*');
                        string sNoteValue = sEnteredData[1];
            //                        FF.AddNote(Convert.ToInt32(NodeData[0],10),NodeData[2],sNoteValue);
                        string sTimeStamp = sEnteredData[0];
                        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);
                            //OSystem.InsertNewNote(ref DS);
                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;
                        }
                        SwitchButtons(3);
                        //RefreshGrid();
                        //Session["NoteAction"] = "Nutn";
                        TabStrip1.Enabled = true;
                        break;
                    case "EditNote":
                        string[] NodeData2 = txtNotes.Value.Split('~');

                        string[] sEnteredData2 = sResponse[0].Split('*');
                        string sNoteValue2 = sEnteredData2[1];
                        string sTimeStamp2 = sEnteredData2[0];
                        DS = (DataSet)Session["DS"];
                        DA = (SqlDataAdapter)Session["DA"];
                        SC = (SqlConnection)Session["SC"];

                        DataRow r2 = DS.Tables[0].Rows[dgNotes.SelectedIndex];
                        r2[1] = sTimeStamp2;
                        r2[2] = sNoteValue2;
                        r2.AcceptChanges();
                        DS.Tables[0].AcceptChanges();
                        int NoteID = Convert.ToInt32(r2[0]);
                        int RecID = Convert.ToInt32(r2[3]);

                        try
                        {
                            //OSystem.UpdateNote(ref DS);
                            Functions FNE = new Functions();
                            OysterClassLibrary.Notes RNotes = FNE.GetNotes(RecID);
                            foreach(OysterClassLibrary.Note RecNote in RNotes)
                            {
                                if(RecNote.ID == NoteID)
                                {
                                    RecNote.Update(sTimeStamp2,sNoteValue2);
                                }
                            }
                            //DA.Update(DS);
                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;
                        }

                        SwitchButtons(3);
                        //RefreshGrid();
                        //Session["NoteAction"] = "Nutn";
                        TabStrip1.Enabled = true;
                        break;
                    case "DeleteNote":
                        DS = (DataSet)Session["DS"];
                        DA = (SqlDataAdapter)Session["DA"];
                        SC = (SqlConnection)Session["SC"];
                        DataRow r3 = DS.Tables[0].Rows[dgNotes.SelectedIndex];
                        int NoteID2 = Convert.ToInt32(r3[0]);
                        int RecID2 = Convert.ToInt32(r3[3]);

                        //DS.Tables[0].AcceptChanges();
                        try
                        {
                            //OSystem.DeleteNote(ref DS);
                            //DA.Update(DS);
                            OysterClassLibrary.Functions FND = new OysterClassLibrary.Functions();
                            FND.RemoveNote(NoteID2);

                        }
                        catch(Exception Err)
                        {
                            txtAlert.Value = Err.Message;
                        }

                        SwitchButtons(3);
                       // RefreshGrid();
                        break;
                }
            }
            else if(txtSelectedIndex.Value == "1")
                RefreshGrid();
        }
コード例 #7
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void FillCameras()
        {
            CTV.Nodes[0].Nodes.Clear();
            CTV.Nodes[0].Expanded = true;
            Functions F = new Functions();
            Rooms AR = F.ALLRooms();
            LUser = (OysterClassLibrary.User)Session["LUser"];
            OSystem = (OysterClassLibrary.Oyster)Session["Oyster"];
            OysterClassLibrary.Groups AG = null;
            if(LUser.HighestAuthorityLevel.ID == OSystem.SectionTypeSysAdmin.ID)
            {
                AG = OSystem.GetALLGroups(false);
            }
            else
                AG = LUser.CurrentGroups;

            TreeNode NPublic = new TreeNode();
            NPublic.Type = "Group";
            NPublic.ImageUrl = CTV.TreeNodeTypes[4].ImageUrl;
            NPublic.Text = "Public Groups";
            NPublic.DefaultStyle.Add("color","DarkBlue");

            CTV.Nodes[0].Nodes.Add(NPublic);

            TreeNode NPrivate = new TreeNode();
            NPrivate.Type = "Group";
            NPrivate.ImageUrl = CTV.TreeNodeTypes[5].ImageUrl;
            NPrivate.DefaultStyle.Add("color","DarkGreen");
            NPrivate.Text = "Private Groups";
            CTV.Nodes[0].Nodes.Add(NPrivate);
            int[] UO = OSystem.UnassignedIDs;

            foreach(OysterClassLibrary.Group CurrentGroup in AG)
            {
                TreeNode GroupNODE = new TreeNode();
                GroupNODE.Text = CurrentGroup.Description;
                GroupNODE.ImageUrl = CTV.TreeNodeTypes[3].ImageUrl;

                if(CurrentGroup.IsPublicAccess)
                {

                    int NumEncoders = CurrentGroup.CurrentStreamingEncoders.Count;
                    if(NumEncoders > 0)
                        NPublic.Nodes.Add(GroupNODE);
                    GroupNODE.DefaultStyle.Add("color","Blue");
                    TreeNode[] PubScenes = new TreeNode[NumEncoders];
                    int iCount = 0;

                    ListBox LB = new ListBox();

                    foreach(OysterClassLibrary.StreamingEncoder S in CurrentGroup.CurrentStreamingEncoders)
                    {
                        foreach(ListItem LI in LB.Items)
                        {
                            if(S.RoomID.ToString() == LI.Value)
                            {
                                goto skipme;
                            }
                        }

                        ListItem LA = new ListItem(S.CurrentRoom.Description,S.RoomID.ToString());
                        LB.Items.Add(LA);
                        PubScenes[iCount] = new TreeNode();
                        PubScenes[iCount].Type = "Scene";
                        PubScenes[iCount].ImageUrl = CTV.TreeNodeTypes[2].ImageUrl;
                        PubScenes[iCount].NodeData = CurrentGroup.ID.ToString() + "~" + S.RoomID.ToString();
                        PubScenes[iCount].Text = S.CurrentRoom.Description;
                        GroupNODE.Nodes.Add(PubScenes[iCount]);
                        iCount++;

                    skipme:{}
                    }

                    foreach(OysterClassLibrary.StreamingEncoder S in CurrentGroup.CurrentStreamingEncoders)
                    {
                        for(int i=0;i<iCount;i++)
                        {
                            string sMatch = CurrentGroup.ID.ToString() + "~" + S.RoomID.ToString();
                            if(sMatch == PubScenes[i].NodeData)
                            {
                                TreeNode SEncoder = new TreeNode();
                                SEncoder.Type = "Camera";
                                SEncoder.ImageUrl = CTV.TreeNodeTypes[1].ImageUrl;
                                SEncoder.NodeData = S.ID.ToString();
                                SEncoder.Text = S.Description;
                                PubScenes[i].Nodes.Add(SEncoder);
                            }
                        }
                    }

                }
                else
                {
                    if(CurrentGroup.CurrentRooms.Count > 0)
                        NPrivate.Nodes.Add(GroupNODE);
                    foreach(Room r in CurrentGroup.CurrentRooms)
                    {

                        if(r.ID != UO[1])
                        {
                            int NumEncoders = r.AllCurrentStreamingEncoders.Count;

                            GroupNODE.DefaultStyle.Add("color","Green");
                            TreeNode Scene = new TreeNode();
                            Scene.Type = "Scene";
                            Scene.ImageUrl = CTV.TreeNodeTypes[2].ImageUrl;
                            Scene.NodeData = CurrentGroup.ID.ToString() + "~" + r.ID.ToString();
                            Scene.Text = r.Description;

                            Scene.DefaultStyle.Add("color","Green");
                            GroupNODE.Nodes.Add(Scene);

                            int NumCameras = 0;

                            StreamingEncoders ASE = r.AllCurrentStreamingEncoders;
                            foreach(StreamingEncoder SE in ASE)
                            {
                                NumCameras++;
                                TreeNode SEncoder = new TreeNode();
                                SEncoder.Type = "Camera";
                                SEncoder.ImageUrl = CTV.TreeNodeTypes[1].ImageUrl;
                                SEncoder.NodeData = SE.ID.ToString();
                                SEncoder.Text = SE.Description;
                                Scene.Nodes.Add(SEncoder);
                            }
                            //if(NumCameras > 0)
                            //{
                            //	CTV.Nodes[0].Nodes.Add(Scene);
                            //}
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void SwitchButtons(int PanelId)
        {
            try
            {
                LUser = (User)Session["LUser"];
                OSystem = (Oyster)Session["Oyster"];
                imgButtonView.Visible = true;
                imgButtonRename.Visible = true;
                imgButtonMove.Visible = true;
                switch(PanelId)
                {
                    case 1:  /*Recordings Tab (Recording)*/
                        imgButtonView.ImageUrl = "images/Tab_B_ViewRec.jpg";
                        imgButtonRename.ImageUrl = "images/Tab_B_RenameRec.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_MoveRec.jpg";
                        imgButtonView.ToolTip = "Opens selected recording in a new player window";
                        imgButtonRename.ToolTip = "Renames selected recording";
                        imgButtonMove.ToolTip = "Move selected recording";
                        imgButtonMove.Visible = true;
                        TreeNode TN = tv.GetNodeFromIndex(tv.SelectedNodeIndex);
                        if(TN == null)
                            return;
                        else if(TN.Type == "Recording")
                        {
                            string[] sarray = TN.NodeData.Split(':');
                            int RecordingId = Convert.ToInt32(sarray[0],10);
                            int SectionId = Convert.ToInt32(sarray[2],10);
                            Recording Rec = OSystem.GetRecordingById(RecordingId);
                            Section S = OSystem.GetSectionById(SectionId);
                            TreeNode CN = (TreeNode)TN.Parent;
                            bool IsUnassigned = false;
                            imgButtonRename.ImageUrl = "images/Tab_B_RenameRec_Disabled.jpg";
                            imgButtonMove.ImageUrl = "images/Tab_B_MoveRec_Disabled.jpg";

                            while((CN.Type != "User")&&(CN.Type != "labelGroup"))
                            {
                                if(CN.Text == "Unassigned Recordings")
                                    IsUnassigned = true;

                                CN = (TreeNode)CN.Parent;
                            }
                            if(CN.Type == "User")
                            {
                                imgButtonView.Visible = true;
                                if(LUser.ID == Rec.OwnerID)
                                {
                                    imgButtonRename.ImageUrl = "images/Tab_B_RenameRec.jpg";
                                }

                                if((LUser.ID == Rec.OwnerID)||((LUser.ID!=Rec.OwnerID)&&(IsUnassigned == false)))
                                {
                                    foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                    {
                                        if(P.CanOperateOn == S.CreatedBySectionTypeID)
                                        {
                                            imgButtonMove.ImageUrl = "images/Tab_B_MoveRec.jpg";
                                            break;
                                        }
                                    }
                                }
                                //                            else
                                //                            {
                                //                                foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                //                                {
                                //                                    if(P.CanOperateOn == S.CreatedBySectionTypeID)
                                //                                    {
                                //                                        imgButtonMove.Visible = true;
                                //                                        break;
                                //                                    }
                                //                                }
                                //                            }

                            }
                            else
                            {

                                imgButtonView.ImageUrl = "images/Tab_B_ViewRec.jpg";
                                imgButtonRename.ImageUrl = "images/Tab_B_RenameRec_Disabled.jpg";
                                imgButtonMove.ImageUrl = "images/Tab_B_MoveRec_Disabled.jpg";
                            }

                        }
                        else
                        {
                            imgButtonView.ImageUrl = "images/Tab_B_ViewRec_Disabled.jpg";
                            imgButtonRename.ImageUrl = "images/Tab_B_RenameRec_Disabled.jpg";
                            imgButtonMove.ImageUrl = "images/Tab_B_MoveRec_Disabled.jpg";
                        }
                        string sview = ResponseToHandle.Value;
                        if(txtEnableViewButton.Value == "false")
                            imgButtonView.ImageUrl = "images/Tab_B_ViewRec_Disabled.jpg";
                        //imgButtonMisc.Visible = false;
                        break;
                    case 2: /*Recordings Tab (Sessions)*/
                        imgButtonView.ImageUrl = "images/Tab_B_ViewSes_Disabled.jpg";
                        imgButtonRename.ImageUrl = "images/Tab_B_RenameSes_Disabled.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_MoveSes_Disabled.jpg";
                        imgButtonMove.Visible = true;

                        imgButtonView.ToolTip = "Opens selected session's recordings into player windows";
                        imgButtonRename.ToolTip = "Renames selected session";
                        imgButtonMove.ToolTip = "Move selected session";

                        TreeNode TN2 = tv.GetNodeFromIndex(tv.SelectedNodeIndex);
                        if(TN2 == null)
                            return;
                        else if(TN2.Type == "RecordingSession")
                        {
                            string[] sarray2 = TN2.NodeData.Split(':');
                            string SessionId = Convert.ToString(sarray2[0]);
                            int SectionId = Convert.ToInt32(sarray2[2]);
                            Section S = OSystem.GetSectionById(SectionId);
                            int CUserId = Convert.ToInt32(sarray2[1]);

                            TreeNode CN = (TreeNode)TN2.Parent;
                            bool IsUnassigned = false;
                            //imgButtonRename.Visible = false;
                            //imgButtonMove.Visible = false;

                            while((CN.Type != "User")&&(CN.Type != "labelGroup"))
                            {
                                if(CN.Text == "Unassigned Recordings")
                                    IsUnassigned = true;

                                CN = (TreeNode)CN.Parent;
                            }
                            if(CN.Type == "User")
                            {
                                imgButtonView.ImageUrl = "images/Tab_B_ViewSes.jpg";

                                if(OSystem.CanRenameSession(SessionId,LUser.ID))
                                    imgButtonRename.ImageUrl = "images/Tab_B_RenameSes.jpg";

                                if((LUser.ID == CUserId)||((LUser.ID != CUserId)&&(IsUnassigned == false)))
                                {
                                    foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                    {
                                        if(P.CanOperateOn == S.CreatedBySectionTypeID)
                                        {
                                            imgButtonMove.ImageUrl = "images/Tab_B_MoveSes.jpg";
                                            break;
                                        }
                                    }
                                }
                                //                            else
                                //                            {
                                //                                foreach(Permission P in LUser.HighestAuthorityLevel.CanMoveRecordings)
                                //                                {
                                //                                    if(P.CanOperateOn == S.CreatedBySectionTypeID)
                                //                                    {
                                //                                        imgButtonMove.Visible = true;
                                //                                        break;
                                //                                    }
                                //                                }
                                //                            }

                            }
                            else
                            {

                                imgButtonView.ImageUrl = "images/Tab_B_ViewSes.jpg";
                                imgButtonRename.ImageUrl = "images/Tab_B_RenameSes_Disabled.jpg";
                                imgButtonMove.ImageUrl = "images/Tab_B_MoveSes_Disabled.jpg";
                            }

                        }
                        else
                        {
                            imgButtonView.ImageUrl = "images/Tab_B_ViewSes_Disabled.jpg";
                            imgButtonRename.ImageUrl = "images/Tab_B_RenameSes_Disabled.jpg";
                            imgButtonMove.ImageUrl = "images/Tab_B_MoveSes_Disabled.jpg";
                        }
                        if(txtEnableViewButton.Value == "false")
                            imgButtonView.ImageUrl = "images/Tab_B_ViewSes_Disabled.jpg";

                        //imgButtonMisc.Visible = false;
                        break;
                    case 3: /*Notes Tab (Sessions)*/

                        imgButtonView.ImageUrl = "images/Tab_B_NewNote_Disabled.jpg";
                        imgButtonRename.ImageUrl = "images/Tab_B_EditNote_Disabled.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote_Disabled.jpg";
                        imgButtonMove.Visible = true;
                        RefreshGrid();

                        imgButtonView.ToolTip = "Create a new Note";
                        imgButtonRename.ToolTip = "Edit selected Note";
                        imgButtonMove.ToolTip = "Permanently removes selected Note";

                        //imgButtonMisc.Visible = false;
                        break;
                    case 4: /*Camera Tab (Camera)*/
                        imgButtonView.ImageUrl = "images/Tab_B_ViewCam.jpg";
                        imgButtonRename.ImageUrl = "images/Tab_B_RecordSce_Disabled.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_MoveCamera_Disabled.jpg";
                        imgButtonRename.Visible = false;

                        imgButtonView.ToolTip = "Opens selected stream in a new player window";
                        imgButtonRename.ToolTip = "Begin recording this entire Scene";
                        imgButtonMove.ToolTip = "Moves camera";

                        TreeNode TN3 = CTV.GetNodeFromIndex(CTV.SelectedNodeIndex);
                        if(TN3 != null)
                        {

                            if(TN3.Type == "Camera")
                            {
                                imgButtonView.ImageUrl = "images/Tab_B_ViewCam.jpg";
                                int SEID = Convert.ToInt32(TN3.NodeData,10);
                                OysterClassLibrary.StreamingEncoder SE = OSystem.GetStreamingEncoderById(SEID);

                                if(SE.HasControlableCamera)
                                {
                                    imgButtonMove.ImageUrl = "images/Tab_B_MoveCamera.jpg";
                                }
                                if(LUser.CanRecord)
                                {
                                    //imgButtonRename.ImageUrl = "images/Tab_B_RecordSce.jpg";
                                    imgButtonRename.ImageUrl = "images/Tab_B_RecordSce_Disabled.jpg";
                                }
                            }
                            else
                                imgButtonView.ImageUrl = "images/Tab_B_ViewCam_Disabled.jpg";
                        }
                        else
                            imgButtonView.ImageUrl = "images/Tab_B_ViewCam_Disabled.jpg";

                        if(NumPlayers.Value == "enabled")
                            imgButtonView.ImageUrl = "images/Tab_B_ViewCam_Disabled.jpg";
                        //imgButtonRename.Visible = false;
                        imgButtonMove.Visible = true;
                        imgButtonMisc.Visible = false;
                        break;
                    case 5:
                        imgButtonView.ImageUrl = "images/Tab_B_ViewSce.jpg";
                        //imgButtonView.ImageUrl = "images/Tab_B_ViewCam_Disabled.jpg";
                        imgButtonRename.ImageUrl = "images/Tab_B_RecordSce_Disabled.jpg";
                        //imgButtonMove.ImageUrl = "images/Tab_B_MoveSce.jpg";
                        if(txtEnableViewButton.Value == "false")
                            imgButtonView.ImageUrl = "images/Tab_B_ViewSce_Disabled.jpg";
                        imgButtonRename.Visible = false;
                        imgButtonMove.Visible = false;
                        imgButtonMisc.Visible = false;
                        break;

                }
            }
            catch(Exception Err)
            {
                txtAlert.Value = Err.Message;
            }
        }
コード例 #9
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void RefreshNoteButtons()
        {
            try
            {
                imgButtonView.ImageUrl = "images/Tab_B_NewNote_Disabled.jpg";
                imgButtonRename.ImageUrl = "images/Tab_B_EditNote_Disabled.jpg";
                imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote_Disabled.jpg";

                imgButtonView.ToolTip = "Create a new Note";
                imgButtonRename.ToolTip = "Edit selected Note";
                imgButtonMove.ToolTip = "Permanently removes selected Note";
                OSystem = (Oyster)Session["Oyster"];
                LUser = (User)Session["LUser"];

                TabStrip1.Enabled = true;
                int SelectedIndex = Convert.ToInt32(txtSelectedIndex.Value,10);

                if(SelectedIndex != 1)
                {
                    dgNotes.Visible = false;
                    lblSync.Visible = false;
                    tbSync.Visible = false;
                    taNote.Visible = false;
                    return;
                }
                int numselected = 0;
                try
                {
                    numselected = Convert.ToInt32(NumSelected.Value,10);
                }
                catch(Exception Err)
                {
                    return;
                }
                lblNoNote.Visible = true;
                dgNotes.Visible = false;

                if(numselected == 0)
                    lblNoNote.Text = "Notes for each recording are available only after selecting a Player View.  To do this: Click the Recording Tab then select the desired recording.       Click View Recording.        When ever the recording is selected in the view area, its Notes options will become available by clicking the Notes Tab.";
                else if(numselected > 1)
                    lblNoNote.Text = "Notes will not show if multiple Players are selected. Please choose only one Player to view it's Notes.";
                else
                {
                    lblNoNote.Visible = false;
                    dgNotes.Visible = true;
                }
                if((txtLastNote.Value != "")&&(txtLastNote.Value != "Restricted"))
                {
                    taNote.Visible = false;
                    string[] NodeData = txtLastNote.Value.Split('~');
                    //Functions F = new Functions();
                    int RecordingId = Convert.ToInt32(NodeData[0]);

                    //imgButtonMisc.ImageUrl = "images/Tab_B_UpdateNote.jpg";
                    //imgButtonMisc.Visible = false;
                    dgNotes.Visible = true;
                    lblSync.Visible = false;
                    tbSync.Visible = false;
                    tbSync.Disabled = true;
                    taNote.Visible = false;
                    lblNoNote.Visible = false;
                    Recording R = OSystem.GetRecordingById(RecordingId);
                    Session["NoteRecording"] = R;
                    bool bEnableControls = false;
                    if(R.OwnerID == LUser.ID)
                        bEnableControls = true;
                    if(bEnableControls == true)
                    {
                        imgButtonView.ImageUrl = "images/Tab_B_NewNote.jpg";
                    }
                    else
                    {
                        imgButtonView.ImageUrl = "images/Tab_B_NewNote_Disabled.jpg";

                    }

                    if(dgNotes.Items.Count != 0)
                    {
                        if((dgNotes.SelectedItem != null)&&(bEnableControls == true))
                        {
                            imgButtonRename.ImageUrl = "images/Tab_B_EditNote.jpg";
                            imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote.jpg";
                        }
                        else
                        {

                        }
                    }
                    else
                    {
                        imgButtonRename.ImageUrl = "images/Tab_B_EditNote_Disabled.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote_Disabled.jpg";
                        dgNotes.Visible = false;
                        lblNoNote.Text = "There are currently no notes associated with this recording";
                    }

                }
                else
                {

                    imgButtonMisc.ImageUrl = "images/Tab_B_UpdateNote.jpg";
                    imgButtonMisc.Visible = false;
                    lblSync.Visible = false;
                    tbSync.Visible = false;
                    taNote.Visible = false;
                }
            }
            catch(Exception Err)
            {
               string peekerror = Err.Message;
            }
        }
コード例 #10
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void RefreshGrid()
        {
            try
            {
                imgButtonView.ImageUrl = "images/Tab_B_NewNote_Disabled.jpg";
                imgButtonRename.ImageUrl = "images/Tab_B_EditNote_Disabled.jpg";
                imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote_Disabled.jpg";

                imgButtonView.ToolTip = "Create a new Note";
                imgButtonRename.ToolTip = "Edit selected Note";
                imgButtonMove.ToolTip = "Permanently removes selected Note";
                OSystem = (Oyster)Session["Oyster"];
                LUser = (User)Session["LUser"];

                //TabStrip1.Enabled = true;
                int SelectedIndex = Convert.ToInt32(txtSelectedIndex.Value,10);

                if(SelectedIndex != 1)
                {
                    return;
                }
                int numselected = Convert.ToInt32(NumSelected.Value,10);

                lblNoNote.Visible = true;
                dgNotes.Visible = false;

                if(numselected == 0)
                    lblNoNote.Text = "Notes for each recording are available only after selecting a Player View.  To do this: Click the Recording Tab then select the desired recording.       Click View Recording.        When ever the recording is selected in the view area, its Notes options will become available by clicking the Notes Tab.";
                else if(numselected > 1)
                    lblNoNote.Text = "Notes will not show if multiple Players are selected. Please choose only one Player to view it's Notes.";
                else
                {
                    lblNoNote.Visible = false;
                    dgNotes.Visible = true;
                }
                if((txtLastNote.Value != "")&&(txtLastNote.Value != "Restricted"))
                {
                    taNote.Visible = false;
                    string[] NodeData = txtLastNote.Value.Split('~');
                    Functions F = new Functions();

                    int RecordingId = Convert.ToInt32(NodeData[0],10);

                    F.GetNotes(RecordingId,ref DA,ref DS,ref SC);
                    //OSystem.GetNotes(RecordingId,ref DS);
                    DS.Tables[0].Columns[0].ColumnMapping = MappingType.Hidden;

                    Session["DS"] = DS;
                    Session["DA"] = DA;
                    Session["SC"] = SC;

                    dgNotes.DataSource = DS.Tables[0];
                    dgNotes.SelectedIndex = -1;
                    //dgNotes.AllowSorting = true;
                    dgNotes.DataBind();

                    //imgButtonMisc.ImageUrl = "images/Tab_B_UpdateNote.jpg";
                    //imgButtonMisc.Visible = false;
                    dgNotes.Visible = true;
                    lblSync.Visible = false;
                    tbSync.Visible = false;
                    tbSync.Disabled = true;
                    taNote.Visible = false;
                    lblNoNote.Visible = false;
                    Recording R = OSystem.GetRecordingById(RecordingId);
                    Session["NoteRecording"] = R;
                    bool bEnableControls = false;
                    if(R.OwnerID == LUser.ID)
                        bEnableControls = true;
                    if(bEnableControls == true)
                    {
                        imgButtonView.ImageUrl = "images/Tab_B_NewNote.jpg";
                    }
                    else
                    {
                        imgButtonView.ImageUrl = "images/Tab_B_NewNote_Disabled.jpg";

                    }
                    if(dgNotes.Items.Count != 0)
                    {
                        if((dgNotes.SelectedItem != null)&&(bEnableControls == true))
                        {
                            imgButtonRename.ImageUrl = "images/Tab_B_EditNote.jpg";
                            imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote.jpg";
                        }
                        else
                        {

                        }
                    }
                    else
                    {
                        imgButtonRename.ImageUrl = "images/Tab_B_EditNote_Disabled.jpg";
                        imgButtonMove.ImageUrl = "images/Tab_B_RemoveNote_Disabled.jpg";
                        dgNotes.Visible = false;
                        lblNoNote.Visible = true;
                        lblNoNote.Text = "There are currently no notes associated with this recording";
                    }

                    if(DS.Tables[0].Rows.Count < 1)
                    {

                        //                    imgButtonRename.Visible = false;
                        //                    imgButtonMove.Visible = false;
                        //                    imgButtonMisc.Visible = false;
                        //                    imgButtonView.Visible = true;

                        //                    lblNoNote.Visible = true;
                        //                    dgNotes.Visible = false;
                        //                    if(numselected == 0)
                        //                        lblNoNote.Text = "Notes for each recording are available only after selecting a Player View.  To do this: Click the Recording Tab then select the desired recording.       Click View Recording.        When ever the recording is selected in the view area, its Notes options will become available by clicking the Notes Tab.";
                        //                    else if(numselected > 1)
                        //                        lblNoNote.Text = "Notes will not show if multiple Players are selected. Please choose only one Player to view it's Notes.";
                        //                    else
                        //                    {
                        //                        lblNoNote.Visible = false;
                        //                        dgNotes.Visible = true;
                        //                    }

                    }
                    //                else
                    //                {
                    //                    imgButtonRename.Visible = false;
                    //                    imgButtonMove.Visible = false;
                    //                    imgButtonMisc.Visible = false;
                    //                    imgButtonView.Visible = true;
                    //                }

                }
                else
                {
                    //DataTable dt = new DataTable();
                    //dgNotes.DataSource = dt;

                    imgButtonMisc.ImageUrl = "images/Tab_B_UpdateNote.jpg";
                    imgButtonMisc.Visible = false;
                    lblSync.Visible = false;
                    tbSync.Visible = false;
                    taNote.Visible = false;
                    //                lblNoNote.Visible = true;
                    //                dgNotes.Visible = false;
                    //                if(numselected == 0)
                    //                    lblNoNote.Text = "Notes for each recording are available only after selecting a Player View.  To do this: Click the Recording Tab then select the desired recording.       Click View Recording.        When ever the recording is selected in the view area, its Notes options will become available by clicking the Notes Tab.";
                    //                else if(numselected > 1)
                    //                    lblNoNote.Text = "Notes will not show if multiple Players are selected. Please choose only one Player to view it's Notes.";
                    //                else
                    //                {
                    //                    lblNoNote.Visible = false;
                    //                    dgNotes.Visible = true;
                    //                }
                    //                if(txtNotes.Value == "")
                    //                    lblNoNote.Text = "Notes for each recording are available only after selecting a Player View.  To do this: Click the Recording Tab then select the desired recording.       Click View Recording.        When ever the recording is selected in the view area, its Notes options will become available by clicking the Notes Tab.";
                    //                else
                    //                    lblNoNote.Text = "Notes will not show if multiple Players are selected. Please choose only one Player to view it's Notes.";
                    //                //imgButtonRename.Visible = false;
                    //imgButtonMove.Visible = false;
                    //imgButtonMisc.Visible = false;
                    //imgButtonView.Visible = false;
                }
            }
            catch(Exception Err)
            {
                string peekerror = Err.Message;
            }
        }
コード例 #11
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            InitializeEvents();
            if(!this.IsPostBack)
            {
                Functions F = new Functions();
                taNote.Visible = false;
                tbSync.Visible = false;
                //Session["IsRecording"] = "RecordingSession";
                OSystem = (Oyster)Session["Oyster"];
                LUser = (User)Session["LUser"];
                HideButtons(false);
                int timestried = 0;
                txtEnableViewButton.Value = "true";
            tryagain:{}
                try
                {
                    User CurrentUser = (User)Session["User"];
                    if(CurrentUser == null)
                        CurrentUser = LUser;

                    int SelectedIndex = Convert.ToInt32(txtSelectedIndex.Value,10);
                    switch(SelectedIndex)
                    {
                        case 0:
                            Users MyMembers = LUser.AllMembersInHierarchy;
                            MyMembers.SortAscending();

                            int NoID = OSystem.UnassignedIDs[0];

                            foreach(User NewUser in MyMembers)
                            {
                                if(NewUser.ID != NoID)
                                {
                                    ListItem LI = new ListItem(NewUser.Description,NewUser.ID.ToString());
                                    DDL.Items.Add(LI);
                                }
                            }
                            bool NoNeed = false;
                            foreach(ListItem LI in DDL.Items)
                            {
                                int MatchID = Convert.ToInt32(LI.Value);
                                if(MatchID == LUser.ID)
                                {
                                    NoNeed = true;
                                    if(CurrentUser.ID == LUser.ID)
                                        LI.Selected = true;
                                }
                            }
                            if(NoNeed == false)
                            {
                                ListItem LIL = new ListItem(LUser.Description,LUser.ID.ToString());
                                if(CurrentUser.ID == LUser.ID)
                                    LIL.Selected = true;
                                DDL.Items.Add(LIL);
                            }
                            if(CurrentUser.ID != LUser.ID)
                            {
                                foreach(ListItem LI in DDL.Items)
                                {
                                    int MatchID = Convert.ToInt32(LI.Value);
                                    if(MatchID == CurrentUser.ID)
                                    {
                                        LI.Selected = true;
                                    }
                                }
                            }
                            FillTree(CurrentUser.ID);
                            SwitchButtons(1);
                            System.GC.Collect();
                            break;
                        case 1:
                            if((txtNotes.Value != "")&&(txtNotes.Value != "Restricted"))
                            {
                                string[] NodeData = new string[0];
                                NodeData = txtNotes.Value.Split(' ');

                                try
                                {
                                    int id = Convert.ToInt32(NodeData[0]);
                                    F.GetNotes(id,ref DA,ref DS,ref SC);
                                    dgNotes.DataSource = DS.Tables[0];
                                    dgNotes.DataBind();
                                    dgNotes.AllowSorting = true;
                                }
                                catch(Exception Err)
                                {
                                    txtAlert.Value = Err.Message;
                                }
                            }
                            else
                            {
                                dgNotes = new DataGrid();
                            }
                            SwitchButtons(2);
                            break;
                        case 2:
                            SwitchButtons(4);
                            break;
                    }
                }
                catch(Exception Err)
                {

                    if(timestried > 4)
                    {
                        txtAlert.Value = Err.Message;
                        return;
                    }
                    timestried++;
                    goto tryagain;
                }

            }
            else
            {
                if(Transitioning == true)
                {
                    Transitioning = false;
                }
                txtRecording.Value = "";
                int SelectedIndex = Convert.ToInt32(txtSelectedIndex.Value,10);
                if(SelectedIndex == 0)
                {
                    dgNotes.Visible = false;
                    TreeNode TN = tv.GetNodeFromIndex(tv.SelectedNodeIndex);
                    if(TN != null)
                    {
                        if(TN.Type == "RecordingSession")
                            SwitchButtons(2);
                        else
                            SwitchButtons(1);
                    }
                    else
                        SwitchButtons(1);
                }
                else if(SelectedIndex == 1)
                {
                    DS = (DataSet)Session["DS"];
                    DA = (SqlDataAdapter)Session["DA"];
                    SC = (SqlConnection)Session["SC"];

                    if(txtNotes.Value != txtLastNote.Value)
                    {
                        SwitchButtons(3);
                    }
                    else
                        RefreshNoteButtons();

                    //dgNotes.DataSource = DS.Tables[0];
                }
                else if(SelectedIndex == 2)
                {
                    dgNotes.Visible = false;
                    TreeNode CTVNode = (TreeNode)Session["CTVNode"];

                    if(CTVNode != null)
                    {
                        if(CTVNode.Type == "Scene")
                            SwitchButtons(5);
                        else
                            SwitchButtons(4);
                    }
                    else
                    {
                        SwitchButtons(4);
                    }
                }

            }
            txtWaitMessage.Value = "safetocontinue";
            //Response.Write("<script> HideTable(WaitMessage); </script>");
             //   txtLastNote.Value = txtNotes.Value;
        }
コード例 #12
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        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;
            }
        }
コード例 #13
0
ファイル: Temp1.aspx.cs プロジェクト: CarverLab/Oyster
        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;
            }
        }
コード例 #14
0
ファイル: ScheduledFTP.cs プロジェクト: CarverLab/Oyster
        private void ThreadProc()
        {
            Log.Verbose("Starting the thread proc.");
            _stopEvent.Reset();
            string SourceDirectoryPath;
            string FailedDirectoryPath;
            string ManagementServerAddress;
            string ManagementServerPassword;

            if (Settings.Default.SourceDirectory.Length == 0)
            {
                Log.WriteError("SourceDirectory is empty. Exiting.");
                _done = true;
                return;
            }

            ManagementServerAddress = Settings.Default.ManagementServerAddress;
            if (ManagementServerAddress.Length == 0)
            {
                Log.WriteError("ManagementServerAddress is empty. Exiting.");
                _done = true;
                return;
            }

            if (Settings.Default.IsIdEncrypted)
                ManagementServerPassword = Crypto.DecryptFromBase64String(
                    Settings.Default.ManagementServerId);
            else
                ManagementServerPassword = Settings.Default.ManagementServerId;

            SourceDirectoryPath = Settings.Default.SourceDirectory;
            FailedDirectoryPath = Path.Combine(SourceDirectoryPath, "Failed");
            DirectoryInfo SourceDirectoryInfo = TryGetDirectory(SourceDirectoryPath);
            if (SourceDirectoryInfo == null)
            {
                Log.WriteError("SourceDirectoryInfo is empty. Exiting.");
                _done = true;
                return;
            }
            DirectoryInfo FailedDirectoryInfo = TryGetDirectory(FailedDirectoryPath);
            if (FailedDirectoryInfo == null)
            {
                Log.WriteError("FailedDirectoryInfo is empty. Exiting.");
                _done = true;
                return;
            }

            Log.Verbose("Entering thread loop.");
            while (!_done)
            {
                try
                {
                    FileInfo[] FileInfoList = SourceDirectoryInfo.GetFiles("*.xml");
                    var SortedFileInfoList = new SortedList(
                        new FileInfoDateComparer(FileInfoDateComparer.DateCompareType.CreationTime));
                    foreach (FileInfo fi in FileInfoList)
                    {
                        if (!SortedFileInfoList.Contains(fi))
                            SortedFileInfoList.Add(fi, fi);
                        else // this should never happen, but it did! what?!??!
                            Log.WriteError("For some reason, " + fi.FullName + " showed up twice in the directory!");
                    }
                    foreach (DictionaryEntry entry in SortedFileInfoList)
                    {
                        if (_done)
                            break;
                        var xmlFileInfo = entry.Value as FileInfo;
                        var transferFile = new ScheduledFTPFile();
                        ScheduledFTPFile.FileUploadRow row;
                        try
                        {
                            transferFile.ReadXml(xmlFileInfo.FullName);
                        }
                        catch (Exception e)
                        {
                            Log.WriteError(xmlFileInfo.FullName + " Exception: " + e.Message);
                            OnFireUploadedEvent(xmlFileInfo.FullName, false);
                            continue;
                        }
                        row = transferFile.FileUpload[0];
                        string wmvPath = row.FilePath;
                        if (!File.Exists(wmvPath))
                        {
                            Log.WriteLog(wmvPath + " does not exist. Moving to Failed directory.");
                            try
                            {
                                File.Move(xmlFileInfo.FullName,
                                          Path.Combine(FailedDirectoryInfo.FullName, xmlFileInfo.Name));
                            }
                            catch (Exception e)
                            {
                                Log.WriteError("Could not move " + xmlFileInfo.FullName + ": " + e.Message);
                            }
                            OnFireUploadedEvent(xmlFileInfo.FullName, false);
                            continue;
                        }

                        // open the file and see if it is in use... if it is, continue and try again...
                        // and keep trying until WME lets go of the file... sheesh
                        try
                        {
                            Log.WriteLog("Checking to see if " + wmvPath + " is still held by the encoder...");
                            var fileCheck = new FileStream(wmvPath, FileMode.Open, FileAccess.ReadWrite);
                            fileCheck.Close();
                            Log.WriteLog(wmvPath + " is free to upload.");
                        }
                        catch (Exception e)
                        {
                            if (e.Message.IndexOf("because it is being used") != -1)
                            {
                                Log.WriteLog("Yep, {0} is in use. Will try again... and again.", wmvPath);
                                continue;
                            }
                            // just try again anyway...
                            Log.WriteError("Error: {0} error: {1}", wmvPath, e.Message);
                            continue;
                        }

                        if (FtpSession.State != FtpState.Disconnected)
                        {
                            Log.WriteLog("Closing FTP session at {0}", (IPEndPoint) FtpSession.RemoteEndPoint);
                            FtpSession.Disconnect();
                        }
                        string user, pass;
                        if (row.EncryptedCredentials)
                        {
                            user = Crypto.DecryptFromBase64String(row.User);
                            pass = Crypto.DecryptFromBase64String(row.Password);
                        }
                        else
                        {
                            user = row.User;
                            pass = row.Password;
                        }
                        try
                        {
                            Log.WriteLog("Connecting to ftp server at {0}:{1} ...", row.ServerAddress, row.ServerPort);
                            FtpSession.Connect(row.ServerAddress, row.ServerPort);
                            FtpSession.Login(user, pass);
                        }
                        catch (Exception ftpex)
                        {
                            Log.WriteError("Could not connect to " + row.ServerAddress + ":" + row.ServerPort +
                                           ftpex.Message);
                            OnFireUploadedEvent(xmlFileInfo.FullName, false);
                            Log.Verbose("Pausing for " + Settings.Default.WaitTimeAfterUploadFailureInSeconds + " seconds.");
                            Thread.Sleep(Settings.Default.WaitTimeAfterUploadFailureInSeconds*1000); // sleep for awhile after a failure
                            continue;
                        }

                        try
                        {
                            lock (_statusLock)
                            {
                                StatusContract.AttemptedLastUploadTime = DateTime.Now;
                                StatusContract.AttemptedTransferCountSinceStartup++;
                                StatusContract.AttemptedLastUploadFileName = wmvPath;
                            }
                            _uploadingFile = new FileInfo(wmvPath);
                            string wmvName = Path.GetFileName(wmvPath);
                            Log.WriteLog("Transferring {0}", wmvPath);

                            long bytesSent = FtpSession.PutFile(wmvPath, wmvName);

                            Log.WriteLog(string.Format("Transfer complete. {0} bytes sent in file {1}.",
                                                       bytesSent, wmvPath));

                            Log.WriteLog("Connecting to Oyster system at " + ManagementServerAddress);

                            var oyster = new OysterClassLibrary.Oyster(
                                ManagementServerAddress, ManagementServerPassword);
                            Recording rec =
                                oyster.GetRecordingByName(wmvName);
                            if (rec == null)
                            {
                                throw new ApplicationException(wmvName + " is not a valid recording on the server.");
                            }
                            rec.IsReady = true;
                            Log.Verbose("Recording is ready: " + wmvName);

                            xmlFileInfo.Delete();
                            Log.WriteLog("Deleted : " + xmlFileInfo.Name);
                            File.Delete(wmvPath);
                            Log.WriteLog("Deleted : " + wmvName);
                            OnFireUploadedEvent(xmlFileInfo.FullName, true);
                            _uploadingFile = null;
                            lock (_statusLock)
                            {
                                StatusContract.TransferCountSinceStartup++;
                                StatusContract.LastUploadTime = StatusContract.AttemptedLastUploadTime;
                                StatusContract.AttemptedLastUploadFileName = wmvPath;
                                StatusContract.LastUploadTimeSpan = DateTime.Now - StatusContract.LastUploadTime;
                            }
                        }
                        catch (Exception upex)
                        {
                            Log.WriteLog("Transfer failed: " + xmlFileInfo.FullName + ": " + upex.Message);
                            Log.Verbose("Pausing for " + Settings.Default.WaitTimeAfterUploadFailureInSeconds + " seconds.");
                            Thread.Sleep(Settings.Default.WaitTimeAfterUploadFailureInSeconds*1000); // sleep for awhile after a failure
                            OnFireUploadedEvent(xmlFileInfo.FullName, false);
                            _uploadingFile = null;
                            continue;
                        }
                    }
                    Thread.Sleep(1000);
                }
                catch (Exception mainex)
                {
                    lock (_statusLock)
                    {
                        StatusContract.LastException = mainex;
                    }
                    Log.WriteError("Exception in main loop: " + mainex);

                    try
                    {
                        FtpSession.Disconnect();
                    }
                    catch (Exception ftpex)
                    {
                        lock (_statusLock)
                        {
                            StatusContract.LastException = ftpex;
                        }
                        Log.Verbose("Exception on ftp disconnect: " + ftpex);
                    }
                }
            }
            Log.Verbose("Thread loop exited.");
            _stopEvent.Set();
        }