コード例 #1
0
        /// <summary>
        /// UpdateMetadataInfo
        /// </summary>
        /// <param name="payload"></param>
        /// <returns></returns>
        public dynamic UpdateMetadataInfo(UpdateMetadataPayload payload)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();
                foreach (var data in payload.metaDataItems)
                {
                    string sql;
                    if ((data.value.GetType() == typeof(Int64) ||
                         data.value.GetType() == typeof(float) ||
                         data.value.GetType() == typeof(double) ||
                         data.value.GetType() == typeof(Int32) ||
                         data.value.GetType() == typeof(Int16) ||
                         data.value.GetType() == typeof(decimal)) && (data.value as string).ToLower() != "appname" && (data.value as string).ToLower() != "id")
                    {
                        sql = "update xrn_clone set " + data.name + " = " + (data.value == null) ? DBNull.Value : data.value + " where  id=@id";
                    }
                    else if (data.value != null)
                    {
                        sql = "update xrn_clone set " + data.name + " = '" + data.value + "' where  id=@id";
                    }
                    else
                    {
                        sql = "update xrn_clone set " + data.name + " = NULL' where  id=@id";
                    }

                    SqlCommand reply;

                    reply = new SqlCommand(sql, sqlCon);
                    reply.CommandTimeout = 60;
                    reply.Parameters.AddWithValue("@id", payload.id);
                    reply.ExecuteNonQuery();
                }
                sqlCon.Close();
                sqlCon.Dispose();
                string userName;
                if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268)
                {
                    userName = "******";// HttpContext.Current.User.Identity.Name;
                }
                else
                {
                    userName = HttpContext.Current.User.Identity.Name;
                }
                var guidelines = new GuidelinesLayer();
                try
                {
                    return(guidelines.GetGuidelines(0, null, payload.id, userName));
                }
                catch (InvalidOperationException)
                {
                    return("Selected scorecard does not contain record with this ID");
                }
                catch (Exception)
                {
                    return(new GuidelineScorecardInfo());
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// RemoveSchoolDataInfo
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public dynamic RemoveSchoolDataInfo(SchoolDataItem info)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();

                string     sql;
                SqlCommand reply;

                sql = "delete from school_clone where id = @id";

                reply = new SqlCommand(sql, sqlCon);
                reply.CommandTimeout = 60;

                reply.Parameters.AddWithValue("@id", info.id);

                try
                {
                    reply.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                }

                sqlCon.Close();
                sqlCon.Dispose();
                string userName;
                if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268)
                {
                    userName = "******";// HttpContext.Current.User.Identity.Name;
                }
                else
                {
                    userName = HttpContext.Current.User.Identity.Name;
                }
                var guidelines = new GuidelinesLayer();
                try
                {
                    return(guidelines.GetGuidelines(0, null, info.xccId, userName));
                }
                catch (InvalidOperationException)
                {
                    return("Selected scorecard does not contain record with this ID");
                }
                catch (Exception)
                {
                    return(new GuidelineScorecardInfo());
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// SaveOtherDataInfo
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public dynamic SaveOtherDataInfo(List <OtherDataItem> info)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();
                foreach (var data in info)
                {
                    string     sql;
                    SqlCommand reply;
                    if (data.id != null)
                    {
                        sql = "update other_clone set form_id=@formId,data_key=@dataKey,data_value=@dataValue,data_type=@dataType,school_name=@schoolName,label=@label"
                              + "where id = @id";
                    }
                    else
                    {
                        sql = "insert into other_clone " +
                              "(id,form_id,data_key,data_value,data_type,xcc_id,school_name,label)" +
                              "values" +
                              "((select max(id)+1000000 from otherFormData ),@formId,@dataKey, @dataValue, @dataType,@xcc_id,@schoolName, @label )";
                    }


                    reply = new SqlCommand(sql, sqlCon);
                    reply.CommandTimeout = 60;
                    if (data.id != null)
                    {
                        reply.Parameters.AddWithValue("id", data.id);
                    }
                    else
                    {
                        reply.Parameters.AddWithValue("xcc_id", data.xccId);
                    }
                    reply.CommandType = CommandType.Text;
                    reply.Parameters.AddWithValue("@formId", (data.formId == null) ? DBNull.Value : (object)data.formId);
                    reply.Parameters.AddWithValue("@dataKey", (data.dataKey == null) ? DBNull.Value : (object)data.dataKey);
                    reply.Parameters.AddWithValue("@dataValue", data.dataValue == null ? DBNull.Value : (object)data.dataValue);
                    reply.Parameters.AddWithValue("@dataType", data.dataType == null ? DBNull.Value : (object)data.dataType);
                    reply.Parameters.AddWithValue("@schoolName", data.schoolName == null ? DBNull.Value : (object)data.schoolName);
                    reply.Parameters.AddWithValue("@label", data.label == null ? DBNull.Value : (object)data.label);
                    try
                    {
                        reply.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                    }
                }
                sqlCon.Close();
                sqlCon.Dispose();
                var    guidelines = new GuidelinesLayer();
                string userName;
                if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268)
                {
                    userName = "******";// HttpContext.Current.User.Identity.Name;
                }
                else
                {
                    userName = HttpContext.Current.User.Identity.Name;
                }
                try
                {
                    return(guidelines.GetGuidelines(0, null, info.First().xccId, userName));
                }
                catch (InvalidOperationException)
                {
                    return("Selected scorecard does not contain record with this ID");
                }
                catch (Exception)
                {
                    return(new GuidelineScorecardInfo());
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// SaveSchoolDataInfo
        /// </summary>
        /// <param name="payload"></param>
        /// <returns></returns>
        public dynamic SaveSchoolDataInfo(List <SchoolDataItem> payload)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();
                foreach (var data in payload)
                {
                    string     sql;
                    SqlCommand reply;
                    if (data.id != null)
                    {
                        sql = "update school_clone set School = @School,	AOI1 = @AOI1,AOI2 = @AOI2,L1_SubjectName = @L1_SubjectName,L2_SubjectName = @L2_SubjectName,"
                              + "Modality = @Modality,College = @College,DegreeOfInterest = @DegreeOfInterest,origin = @origin,tcpa = @tcpa where id = @id";
                    }
                    else
                    {
                        sql = "insert into school_clone " +
                              "(id,School,AOI1,AOI2,L1_SubjectName,L2_SubjectName,Modality,College,DegreeOfInterest,origin,tcpa,xcc_id)" +
                              "values" +
                              "((select max(id)+1000000 from School_X_Data ),@School,@AOI1, @AOI2, @L1_SubjectName,	@L2_SubjectName, @Modality, @College, @DegreeOfInterest,@origin,@tcpa,@xcc_id)";
                    }


                    reply = new SqlCommand(sql, sqlCon);
                    reply.CommandTimeout = 60;
                    if (data.id != null)
                    {
                        reply.Parameters.AddWithValue("id", data.id);
                    }
                    else
                    {
                        reply.Parameters.AddWithValue("xcc_id", data.xccId);
                    }
                    reply.CommandType = CommandType.Text;
                    reply.Parameters.AddWithValue("@School", (data.school == null) ? DBNull.Value : (object)data.school);
                    reply.Parameters.AddWithValue("@AOI1", (data.AOI1 == null) ? DBNull.Value : (object)data.AOI1);
                    reply.Parameters.AddWithValue("@AOI2", data.AOI2 == null ? DBNull.Value : (object)data.AOI2);
                    reply.Parameters.AddWithValue("@L1_SubjectName", data.L1_SubjectName == null ? DBNull.Value : (object)data.L1_SubjectName);
                    reply.Parameters.AddWithValue("@L2_SubjectName", data.L2_SubjectName == null ? DBNull.Value : (object)data.L2_SubjectName);
                    reply.Parameters.AddWithValue("@Modality", data.Modality == null ? DBNull.Value : (object)data.Modality);
                    reply.Parameters.AddWithValue("@College", data.College == null ? DBNull.Value : (object)data.College);
                    reply.Parameters.AddWithValue("@DegreeOfInterest", data.DegreeOfInterest == null ? DBNull.Value : (object)data.DegreeOfInterest);
                    reply.Parameters.AddWithValue("@origin", data.origin == null ? DBNull.Value : (object)data.origin);
                    reply.Parameters.AddWithValue("@tcpa", data.tcpa == null ? DBNull.Value : (object)data.tcpa);
                    try
                    {
                        reply.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                    }
                }
                sqlCon.Close();
                sqlCon.Dispose();
                var    guidelines = new GuidelinesLayer();
                string userName;
                if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268)
                {
                    userName = "******";// HttpContext.Current.User.Identity.Name;
                }
                else
                {
                    userName = HttpContext.Current.User.Identity.Name;
                }
                try
                {
                    return(guidelines.GetGuidelines(0, null, payload[0].xccId, userName));
                }
                catch (InvalidOperationException)
                {
                    return("Selected scorecard does not contain record with this ID");
                }
                catch (Exception)
                {
                    return(new GuidelineScorecardInfo());
                }
            }
        }