Ejemplo n.º 1
0
        private void btn_SelectData_Click(object sender, EventArgs e)
        {
            //---------点击查询前,先清理表格上的数据
            grid.Reset();
            SelectData();

            progressBar1.Value = 0;

            sqlstr = System.Configuration.ConfigurationManager.AppSettings["R_materialConnString"];


            m.Catalog = DealData.RetSubstringBracket(txbList.Text);
            SqlConnection sqlConn = new SqlConnection(sqlstr);

            sqlConn.Open();
            string        selectStr = "select * from tb_Resource where Catalog = ('" + m.Catalog + "')";
            SqlCommand    sc        = new SqlCommand(selectStr, sqlConn);
            SqlDataReader reader    = sc.ExecuteReader();

            row = 0;
            int k = 1;

            dataload();


            progressBar1.Value = 5;
            while (reader.Read())
            {
                worksheet[row, 0] = false;
                worksheet[row, 1] = k;                                                                                //序号
                worksheet[row, 2] = reader["Title"];                                                                  //显示名称2
                worksheet[row, 4] = DealData.SelectString(resultRSORTList, Convert.ToInt32(reader["ResourceStyle"])); //资源类型10
                worksheet[row, 5] = txbCe.Text.Split('_')[0] + "_" + txbCe.Text.Split('_')[1];                        //教材名称
                worksheet[row, 6] = txbList.Text;                                                                     //教材目录
                worksheet[row, 7] = reader["KeyWords"];                                                               //关键字12
                worksheet[row, 8] = reader["Description"];                                                            //描述16
                int copyright = Convert.ToInt32(reader["Copyright"]);
                worksheet[row, 11] = banquanMirror[copyright];
                worksheet[row, 12] = reader["ResourceClass"];
                worksheet[row, 13] = reader["FileID"];
                k++;
                row++;
                if (progressBar1.Value < 95)
                {
                    progressBar1.Value += 5;
                }
            }
            for (int i = 1; i < reader.FieldCount; i++)
            {
                worksheet.SetColumnsWidth(i, reader.FieldCount, 150);
                //worksheet.AutoFitColumnWidth(i, true);
                worksheet.HideColumns(13, 1);
            }
            progressBar1.Value = 100;
        }
Ejemplo n.º 2
0
        public void ResourceData(int i)
        {
            string head       = System.Configuration.ConfigurationManager.AppSettings["MetadataService"];
            string tail       = System.Configuration.ConfigurationManager.AppSettings["mField"];
            string urlRSORT   = String.Format(head + tail, "RSORT");          //14资源类型
            string jsonRSORT  = Common.HttpGet(urlRSORT);                     //y({....})
            string jsonRSORT2 = jsonRSORT.Substring(2, jsonRSORT.Length - 3); //{}
            string tep        = jsonRSORT2.Substring(7, jsonRSORT2.Length - 8);

            m.Title        = worksheet[i, 2].ToString();
            m.StandardBook = DealData.RetSubstringUnderline(worksheet[i, 5].ToString());
            #region  版本 册别 学科 年级
            //foreach (KeyValuePair<string, string> kvp in Testdic)
            //{
            //    if (kvp.Key == m.StandardBook.ToString())
            //    {
            //        testValue = kvp.Value;
            //    }
            //}
            //if (testValue != "")
            //{
            //    string[] sArray = testValue.Split(',');
            //    if (sArray == null || sArray.Length == 0)
            //    {
            //        m.SchoolStage = null;
            //        m.Subject = null;
            //        m.Grade = null;
            //        m.BookReel = null;
            //        m.Edition = null;
            //    }
            //    else
            //    {
            //        m.SchoolStage = int.Parse(sArray[0]);
            //        m.Subject = int.Parse(sArray[1]);
            //        m.Grade = int.Parse(sArray[2]);
            //        m.BookReel = int.Parse(sArray[3]);
            //        m.Edition = int.Parse(sArray[4]);

            //    }
            //}
            //else
            //{
            //    m.SchoolStage = null;

            //    m.Subject = null;

            //    m.Grade = null;

            //    m.BookReel = null;

            //    m.Edition = null;
            //}
            #endregion
            m.Catalog = DealData.RetSubstringBracket(worksheet[i, 6].ToString());
            //m.Copyright = Mirror[worksheet[i, 23].ToString()];
            //string CopyrightName = banquanxinxi[m.Copyright].Split('_')[0];

            //资源类型
            int    eId           = DealData.RetSubstringBracket(worksheet[i, 4].ToString());
            string ResourceType  = string.Empty;
            string ResourceStyle = string.Empty;
            GetResType(tep, eId.ToString(), out ResourceType, out ResourceStyle);
            if (ResourceType != string.Empty)
            {
                ResourceType = int.Parse(ResourceType).ToString();
            }
            if (ResourceStyle != string.Empty)
            {
                ResourceStyle = int.Parse(ResourceStyle).ToString();
            }
            m.KeyWords    = worksheet[i, 7].ToString().Replace("\'", "\'\'");
            m.Description = worksheet[i, 8].ToString().Replace("\'", "\'\'");

            updateStr = "update dbo.[tb_Resource] set Title = '" + m.Title + "',Catalog ='" + m.Catalog + "', ResourceType ='" + ResourceType
                        + "',ResourceStyle = '" + ResourceStyle + "',KeyWords ='" + m.KeyWords + "',Description = '" + m.Description + "' where " + "FileID ='" + worksheet[i, 13] + "'";
            SqlConnection sqlconn = new SqlConnection(sqlstr);
            sqlconn.Open();
            SqlCommand cmd    = new SqlCommand(updateStr, sqlconn);
            int        uptnum = cmd.ExecuteNonQuery();
            if (false)
            {
                string url      = System.Configuration.ConfigurationManager.AppSettings["ResourceImplement"] + "Handler.ashx";
                string str      = "'{'Form':'{\'RID\':\'BEC2C674-AADE-283D-A506-35BFE61B1387\',\'SKEY\':\'ResourceImplement\',\'Pack\':\'{\\\'ID\\\':\\\'BEC2C674-AADE-283D-A506-35BFE61B1387\\\',\\\'Function\\\':\\\'PushResource\\\',\\\'Data\\\':\\\'{}\\\'}\',\'Ticket\':\'\'}'}'";
                var    response = PostData.RequestData(url, str);
            }
        }