Exemple #1
0
        public cm GetCm(string title)
        {
            cm        cm     = null;
            string    sql    = string.Format("select * from PortalTreeData where  PortalTreeData.Name ='{0}'", title);
            string    error  = "";
            List <cm> cmList = DBManage.ExcuteEntity <cm>(sql, System.Data.CommandType.Text, out error);

            if (cmList.Count > 0)
            {
                cm = cmList[0];
            }
            return(cm);
        }
Exemple #2
0
        public void BeginOutPut(object sender, Action callback)
        {
            TextBlock txt = sender as TextBlock;

            if (txtBefore != null)
            {
                txtBefore.Background = new SolidColorBrush(Colors.White);
            }


            txt.Background = new SolidColorBrush(Colors.SkyBlue);

            txtBefore = txt;
            if (txt.Tag != null)
            {
                spClient.List list = txt.Tag as spClient.List;


                #region 执行过程

                cm cm = GetCm(list.Title);
                //if (cm != null)
                if (cm != null)
                {
                    List <Dictionary <string, object> > diclist = client.ClientGetDic(webSite, list.Title, "");
                    if (diclist != null && diclist.Count > 0)
                    {
                        this.listB2.Items.Clear();
                        int count = 0;
                        foreach (var item in diclist)
                        {
                            SpItem spItem = new SpItem(userName, password);
                            if (item.ContainsKey("Title"))
                            {
                                string contentType = "AdvertImgContent";


                                string txtD = Convert.ToString(list.Title);
                                spItem.txt.Text = txtD;


                                //if (txtD == "党员风采" || txtD == "多彩活动" || txtD == "行政领导" || txtD == "语文教师" || txtD == "数学教师" || txtD == "英语教师"
                                //   || txtD == "科任教师" || txtD == "幼儿园教师" || txtD == "后勤职员" || txtD == "教师风采")
                                //{
                                //    contentType = "SchoolStyle";
                                //}
                                //else
                                //{
                                //    contentType = "AdvertImgContent";
                                //}

                                //FileDownLoad(list, contentType);


                                spItem.web.Navicate(Environment.CurrentDirectory + "\\HTMLPage1.html");
                                TimerJob.StartRun(new Action(() =>
                                {
                                    string fileList  = "";
                                    string fileNames = "";
                                    int id           = Convert.ToInt32(item["ID"]);
                                    if (rootDic.ContainsKey(id))
                                    {
                                        string oldfileList = rootDic[id];

                                        string[] dddd = oldfileList.Split(new char[] { ',' });

                                        foreach (var d in dddd)
                                        {
                                            if (!string.IsNullOrEmpty(d))
                                            {
                                                string resalFileName = System.IO.Path.GetFileName(d);

                                                fileNames += resalFileName + ",";

                                                fileList += "/" + rootPart + "/Attatchment/" + contentType + "/" + resalFileName + ",";
                                            }
                                        }
                                    }


                                    if (item.ContainsKey(htmlBody) && !string.IsNullOrEmpty(Convert.ToString(item[htmlBody])))
                                    {
                                        string html = Convert.ToString(item[htmlBody]);

                                        string[] imgUrils = GetHtmlImageUrlList(html);



                                        html = ImageDownload(html, contentType, imgUrils, new Action(() =>
                                        {
                                            //try
                                            //{
                                            //    spItem.webBrowser.Document.Body.InnerHtml = html;
                                            //}
                                            //catch (Exception)
                                            //{
                                            //}

                                            string uriArray = "";
                                            for (int i = 0; i < imgUrils.Count(); i++)
                                            {
                                                if (html.Contains(imgUrils[i]))
                                                {
                                                    string img_uri = System.IO.Path.GetFileName(imgUrils[i]).Replace("%", "_");

                                                    string fln = "/" + rootPart + "/Attatchment/" + contentType + "/" + img_uri;
                                                    uriArray  += fln + ",";
                                                    html       = html.Replace(imgUrils[i], fln);
                                                }
                                            }


                                            #region 插入数据库

                                            if (contentType == "AdvertImgContent")
                                            {
                                                this.Insert(item, html, cm.ID, uriArray, fileNames, fileList);
                                            }
                                            else if (contentType == "SchoolStyle")
                                            {
                                                this.Insert2(item, html, cm.ID, uriArray, fileNames, fileList);
                                            }
                                            count++;
                                            if (count == diclist.Count)
                                            {
                                                if (callback != null)
                                                {
                                                    this.Dispatcher.BeginInvoke(new Action(() =>
                                                    {
                                                        if (checkBox.IsChecked == true)
                                                        {
                                                            nextCount++;
                                                            try
                                                            {
                                                                BeginOutPut(this.listBox.Items[nextCount], () =>
                                                                {
                                                                });
                                                            }
                                                            catch (Exception)
                                                            {
                                                            }
                                                        }
                                                    }));
                                                }
                                                //MessageBox.Show("完成导出");
                                            }
                                            #endregion
                                        }


                                                                                                     ));
                                    }
                                    else
                                    {
                                        #region 插入数据库

                                        if (contentType == "AdvertImgContent")
                                        {
                                            this.Insert(item, "", cm.ID, "", fileNames, fileList);
                                        }
                                        else if (contentType == "SchoolStyle")
                                        {
                                            this.Insert2(item, "", cm.ID, "", fileNames, fileList);
                                        }
                                        count++;
                                        if (count == diclist.Count)
                                        {
                                            if (callback != null)
                                            {
                                                this.Dispatcher.BeginInvoke(new Action(() =>
                                                {
                                                    if (checkBox.IsChecked == true)
                                                    {
                                                        nextCount++;
                                                        try
                                                        {
                                                            BeginOutPut(this.listBox.Items[nextCount], () =>
                                                            {
                                                            });
                                                        }
                                                        catch (Exception)
                                                        {
                                                        }
                                                    }
                                                }));
                                            }
                                            //MessageBox.Show("完成导出");
                                        }
                                        #endregion
                                    }
                                }), 200);

                                listB2.Items.Add(spItem);
                            }
                        }
                    }

                    else
                    {
                        if (checkBox.IsChecked == true)
                        {
                            nextCount++;
                            BeginOutPut(this.listBox.Items[nextCount], () =>
                            {
                            });
                        }
                    }
                }
                else
                {
                    if (checkBox.IsChecked == true)
                    {
                        nextCount++;
                        BeginOutPut(this.listBox.Items[nextCount], () =>
                        {
                        });
                    }
                }

                #endregion
            }
        }