Пример #1
0
        /// <summary>
        /// To Claim Types extensions. Gets the ClaimTypes for a specified IdType
        /// </summary>
        /// <param name="idType"></param>
        /// <returns>ClaimTypes</returns>
        public static string ToClaimTypes(this IdType idType)
        {
            if (claimTypes == null)
            {
                LoadClaimTypes();
            }

            return(claimTypes[idType.ToString()]);
        }
Пример #2
0
        private Id(IdType type, int number)
        {
            if (number < 0)
            {
                throw new ArgumentException("Number must be positive.", nameof(number));
            }

            Type           = type;
            Number         = number;
            FullIdentifier = type.ToString() + Separator + number;
        }
Пример #3
0
        public void Write(XmlWriter writer, IProgress <GexfProgress> progress)
        {
            writer.WriteStartElement(XmlElementName);
            writer.WriteAttributeString(XmlAttibuteNameDefaultEdgeType, DefaultEdgeType.ToString());
            writer.WriteAttributeString(XmlAttibuteNameIdType, IdType.ToString());
            writer.WriteAttributeString(XmlAttibuteNameMode, Mode.ToString());

            _nodeList.Write(writer, progress);
            _edgeList.Write(writer, progress);

            writer.WriteEndElement();
        }
        /// <summary>
        /// To Claim Types extensions. Gets the ClaimTypes for a specified IdType
        /// </summary>
        /// <param name="idType"></param>
        /// <returns>ClaimTypes</returns>
        public static string ToClaimTypes(this IdType idType)
        {
            var claimTypes = IdTypeHelpers.ClaimTypes;

            if (claimTypes == null || !claimTypes.Any())
            {
                IdTypeHelpers.LoadClaimTypes();

                claimTypes = IdTypeHelpers.ClaimTypes;
            }

            return(claimTypes[idType.ToString()]);
        }
Пример #5
0
        public async void Update(IdType opt, string surname, string newMessengerId)
        {
            string sql = "UPDATE Students SET " + opt.ToString() + " = @messengerId WHERE Surname = @Surname";

            SqlCommand cmd = connection.CreateCommand();

            cmd.CommandText = sql;

            cmd.Parameters.Add("@Surname", System.Data.SqlDbType.NVarChar).Value     = surname;
            cmd.Parameters.Add("@messengerId", System.Data.SqlDbType.NVarChar).Value = newMessengerId;

            await cmd.ExecuteNonQueryAsync();
        }
Пример #6
0
        public IHttpActionResult Get([FromUri] IdType idtype = new IdType(), [FromUri] int[] id = null, [FromUri] string modelrunname = null)
        {
            IDbConnection db = HdbController.Connect(this.Request.Headers);
            var           modelRunProcessor = new HdbApi.DataAccessLayer.ModelRunRepository();
            var           result            = modelRunProcessor.GetModelRun(db, idtype.ToString(), id, modelrunname);

            try
            {
                db.Close();
                db.Dispose();
            }
            catch
            {
            }

            return(Ok(result));
        }
Пример #7
0
        private bool getCompleted(IdType type, string id)
        {
            string     sql = "SELECT * FROM Students WHERE " + type.ToString() + " = @id";
            SqlCommand cmd = connection.CreateCommand();

            cmd.CommandText = sql;

            cmd.Parameters.Add("@id", System.Data.SqlDbType.NVarChar).Value = id;

            using (DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    reader.Read();

                    return(reader.GetInt32(9) != 0);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #8
0
        public Student GetByID(IdType opt, string value)
        {
            string     sql = "SELECT * FROM Students WHERE " + opt.ToString() + " = @value";
            SqlCommand cmd = connection.CreateCommand();

            cmd.CommandText = sql;

            cmd.Parameters.Add("@value", System.Data.SqlDbType.NVarChar).Value = value;

            Student student = new Student();

            using (var reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    student.Name        = Convert.ToString(reader.GetValue(2));
                    student.Surname     = Convert.ToString(reader.GetValue(3));
                    student.Class       = Convert.ToString(reader.GetValue(4));
                    student.CurrentTask = Convert.ToInt32(reader.GetValue(7));
                }
            }

            return(student);
        }
Пример #9
0
        public string Get(string id, IdType type)
        {
            string endpoint = _config.Endpoint + ENTITY_COMMAND;

            _restClient.EndPoint = endpoint;

            // Determine which authentication method to use
            if(string.IsNullOrEmpty(_config.AccessToken))
            {
                // use client id/secret
                if(string.IsNullOrEmpty(_config.ClientId) || string.IsNullOrEmpty(_config.ClientSecret))
                {
                    throw new ApplicationException("No credentials were provided. You must either provide a Client ID and Secret or an access token");
                }
                _restClient.AddParameter("client_id", _config.ClientId);
                _restClient.AddParameter("client_secret", _config.ClientSecret);
            }
            else
            {
                _restClient.AddParameter("access_token", _config.AccessToken);
            }

            // id
            _restClient.AddParameter(type.ToString().ToLower(), id);

            // attribute_name

            // attributes

            // created

            // last updated

            string jsonResult = _restClient.MakeRequest();
            JumpResult jr = (JumpResult)DeserializeResult(jsonResult);

            return jr.result;
        }
Пример #10
0
        public static void make(string id, IdType type)
        {
            string prefix = type.ToString();

            id = prefix + id;
        }
Пример #11
0
        private void update <T>(IdType type, string id, UpdateOpt opt, T value)
        {
            string sql = "UPDATE Students SET " + opt.ToString() + " = @val WHERE " + type.ToString() + " = @id";

            SqlCommand cmd = connection.CreateCommand();

            cmd.CommandText = sql;

            System.Data.SqlDbType sqlDbType = System.Data.SqlDbType.Int;
            if (opt == UpdateOpt.CurrentTaskAnswer)
            {
                sqlDbType = System.Data.SqlDbType.Float;
            }

            cmd.Parameters.Add("@val", sqlDbType).Value = value;
            cmd.Parameters.Add("@id", sqlDbType).Value  = id;

            cmd.ExecuteNonQuery();
        }