Exemplo n.º 1
0
        private void SaveSession()
        {
            if (selectedProfile == null)
            {
                return;
            }

            DateTime date      = DateTime.Now;
            ulong    idSession = ulong.Parse(date.ToString("yyMMddHHmmss"));
            List <List <double> > dataOnGraph = new List <List <double> >();

            for (int i = 0; i < PlotModel.Series.Count; i++)
            {
                List <DataPoint> points        = ((LineSeries)PlotModel.Series[i]).Points;
                List <double>    newDataSeries = new List <double>();
                foreach (DataPoint point in points)
                {
                    newDataSeries.Add(point.Y);
                }
                dataOnGraph.Add(newDataSeries);
            }
            while (SignalGen.StateReceive)
            {
                ;
            }
            SignalGen.Data = dataOnGraph;
            LoaderModel.SaveSession(selectedProfile.Id, idSession, SignalGen.Data);
            sessionList = SessionModel.GetSessions(selectedProfile.Id);
            RaisePropertyChanged("SessionsItem");
            SessionModel newSession = new SessionModel
            {
                Id          = idSession,
                DateSession = date.ToString(),
                Сomment     = ""
            };

            SessionModel.SaveSession(selectedProfile.Id, newSession);
            selectedSession = newSession;
            sessionList     = SessionModel.GetSessions(selectedProfile.Id);
            // sessionList.Add(newSession);
            RaisePropertyChanged("SessionsItem");
        }
Exemplo n.º 2
0
        public void SaveSession(string SessionName, DateTime SessionDate, string StartTime, string EndTime, int StudioID, int ProgID, string ProgCode, int CourseID, string CourseCode, int SubjectID, string SubjectCode, string TopicID, int FacultyID, string PlannedCoverage)
        {
            SessionModel SessionObj1 = new SessionModel();

            SqlParameter[] SParam = new SqlParameter[12];

            SParam[0]        = new SqlParameter("@SessionName", SqlDbType.VarChar);
            SParam[0].Value  = SessionName;
            SParam[1]        = new SqlParameter("@SessionDate", SqlDbType.DateTime);
            SParam[1].Value  = SessionDate;
            SParam[2]        = new SqlParameter("@StartTime", SqlDbType.VarChar);
            SParam[2].Value  = StartTime;
            SParam[3]        = new SqlParameter("@EndTime", SqlDbType.VarChar);
            SParam[3].Value  = EndTime;
            SParam[4]        = new SqlParameter("@StudioID", SqlDbType.Int);
            SParam[4].Value  = StudioID;
            SParam[5]        = new SqlParameter("@ProgID", SqlDbType.Int);
            SParam[5].Value  = ProgID;
            SParam[6]        = new SqlParameter("@CourseID", SqlDbType.Int);
            SParam[6].Value  = CourseID;
            SParam[7]        = new SqlParameter("@SubjectID", SqlDbType.Int);
            SParam[7].Value  = SubjectID;
            SParam[8]        = new SqlParameter("@FacultyID", SqlDbType.Int);
            SParam[8].Value  = FacultyID;
            SParam[9]        = new SqlParameter("@CreatedBy", SqlDbType.Int);
            SParam[9].Value  = Convert.ToInt32(Session["USER_ID"]);
            SParam[11]       = new SqlParameter("@PlannedCoverage", SqlDbType.Text);
            SParam[11].Value = PlannedCoverage;
            bool   KeyUnique = false;
            string streamKey = string.Empty;

            // Create session stream key
            while (!KeyUnique)
            {
                streamKey = createRandomKey();
                SqlParameter[] FObj = new SqlParameter[1];
                FObj[0]       = new SqlParameter("@StreamKey", SqlDbType.VarChar);
                FObj[0].Value = streamKey;
                DataTable z = DAL.GetDataTable("ValidateStreamKey", FObj);
                if (z.Rows.Count == 0)
                {
                    KeyUnique = true;
                }
            }
            SParam[10]       = new SqlParameter("@Key", SqlDbType.VarChar);
            SParam[10].Value = streamKey;

            int SessionID = -1;

            try
            {
                string s = SessionObj1.SaveSession(SParam);
                try
                {
                    SessionID = Convert.ToInt32(s);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error converting created SessionID from string to int.");
                }
            }
            catch (Exception ex)
            {
            }

            SParam          = new SqlParameter[1];
            SParam[0]       = new SqlParameter("@UserID", SqlDbType.Int);
            SParam[0].Value = Convert.ToInt32(Session["USER_ID"]);
            DataTable val = DAL.GetDataTable("GetEntity", SParam);

            string EntityCode    = string.Empty;
            string StreamSetName = string.Empty;

            if (val.Rows.Count > 0)
            {
                EntityCode    = Convert.ToString(Convert.IsDBNull(val.Rows[0]["EntityCode"]) ? string.Empty : val.Rows[0]["EntityCode"]);
                StreamSetName = Convert.ToString(Convert.IsDBNull(val.Rows[0]["StreamSetName"]) ? string.Empty : val.Rows[0]["StreamSetName"]);
            }

            Stream stream = new Stream();

            if (StreamSetName.Equals("Passthrough"))
            {
                stream.SaveStream(SessionID, EntityCode, ProgCode, CourseCode, SubjectCode, false);
            }
            else
            {
                stream.SaveStream(SessionID, EntityCode, ProgCode, CourseCode, SubjectCode);
            }
        }