Exemple #1
0
        /// <summary>检查指定目录下是否有同名静态库</summary>
        /// <param name="di"></param>
        /// <param name="root"></param>
        /// <returns></returns>
        private Boolean CheckPartial(DirectoryInfo di, String root)
        {
            var fi = di.GetAllFiles("*.lib;*.a").FirstOrDefault();

            if (fi != null && fi.Exists)
            {
                if (!Libs.Contains(fi.FullName))
                {
                    var lib = new LibFile(fi.FullName);
                    WriteLog("发现静态库:{0, -12} {1}".F(lib.Name, fi.FullName));
                    Libs.Add(fi.FullName);
                }
                return(true);
            }

            var p = di.Parent;

            if (p == null || p == di)
            {
                return(false);
            }
            // 截止到当前目录
            if (p.FullName.EnsureEnd("\\").EqualIgnoreCase(root.GetFullPath().EnsureEnd("\\")))
            {
                return(false);
            }

            return(CheckPartial(p, root));
        }
Exemple #2
0
 private void LoadData()
 {
     if (id > 0)
     {
         var f = BLL.TcArticle.Instance.GetModel(id);
         if (f != null)
         {
             txt_title.Text           = f.Title;
             txt_jianyao.Text         = f.Jianyao;
             ddl_fenlei.SelectedValue = f.Fenleiid.GetString();
             content = f.Content;
             if (f.Tupian.GetString().Length > 0)
             {
                 dp              = "";
                 tupianurl       = LibFile.get_img(f.Tupian.GetString(), "", "");
                 hd_tupian.Value = f.Tupian.GetString();
             }
             var c = BLL.TcChanpin.Instance.GetModelList("articleid=" + f.ID);
             if (c.Count > 0)
             {
                 txt_jianyao.Text = c[0].Shuxing;
             }
         }
     }
 }
Exemple #3
0
        /// <summary>加载库文件</summary>
        /// <param name="sb"></param>
        protected virtual void LoadLib(StringBuilder sb)
        {
            var dic = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in Libs)
            {
                var lib = new LibFile(item);
                // 调试版/发行版 优先选用最佳匹配版本
                // 不包含,直接增加
                if (!dic.TryGetValue(lib.Name, out var old))
                {
                    dic.Add(lib.Name, lib.FullName);
                }
                // 已包含,并且新版本更合适,替换
                else
                {
                    //Console.WriteLine("{0} Debug={1} Tiny={2}", lib.FullName, lib.Debug, lib.Tiny);
                    var lib2 = new LibFile(old);
                    if (!(lib2.Debug == Debug && lib2.Tiny == Tiny) &&
                        (lib.Debug == Debug && lib.Tiny == Tiny))
                    {
                        dic[lib.Name] = lib.FullName;
                    }
                }
            }

            Console.WriteLine("使用静态库:");
            foreach (var item in dic)
            {
                sb.Append(" ");
                sb.Append(item.Value);
                Console.WriteLine("\t{0}\t{1}", item.Key, item.Value);
            }
        }
Exemple #4
0
        private void LoadData()
        {
            if (id > 0)
            {
                using (MAction action = new MAction("TcFenlei"))
                {
                    if (action.Fill(id))
                    {
                        action.UI.SetAutoPrefix("txt", "txt_", "ddl_");
                        action.UI.SetToAll(this);

                        //txtUrl.Text = action.Data["url"].GetString();

                        if (action.Data["Tupian"].GetString().Length > 0)
                        {
                            tupian = LibFile.get_img(action.Data["Tupian"].GetString(), "", "");
                        }

                        if (action.Data["SeoTitle"].GetString().Length > 0)
                        {
                            tupian2 = LibFile.get_img(action.Data["SeoTitle"].GetString(), "", "");
                        }
                    }
                }
            }
        }
Exemple #5
0
 public string getimg(string logourl, string width, string height)
 {
     logourl = logourl.GetString();
     if (logourl.Length > 0)
     {
         return("<img src='" + LibFile.get_img(logourl, width, height) + "' />");
     }
     else
     {
         return("");
     }
 }
Exemple #6
0
 private void LoadData()
 {
     if (id > 0)
     {
         var f = BLL.TcLinks.Instance.GetModel(id);
         txt_name.Text            = f.Name;
         txt_url.Text             = f.Url.GetString();
         rb_xianshi.SelectedValue = f.IsXianshi.GetString();
         txt_paixu.Text           = f.Paixu.GetString();
         if (f.LogoUrl.GetString().Length > 0)
         {
             dp              = "";
             tupianurl       = LibFile.get_img(f.LogoUrl.GetString(), "88", "31");
             hd_tupian.Value = f.LogoUrl.GetString();
         }
     }
 }
Exemple #7
0
 private void LoadData()
 {
     if (id > 0)
     {
         var f = BLL.TcHuandeng.Instance.GetModel(id);
         if (f != null)
         {
             txt_title.Text = f.Title;
             txt_url.Text   = f.Url;
             txt_paixu.Text = f.Paixu.GetString();
             if (f.Tupian.GetString().Length > 0)
             {
                 dp              = "";
                 tupianurl       = LibFile.get_img(f.Tupian.GetString(), width, height);
                 hd_tupian.Value = f.Tupian.GetString();
             }
         }
     }
 }
Exemple #8
0
 private void LoadData()
 {
     if (id > 0)
     {
         using (MAction action = new MAction("TcArticle"))
         {
             if (action.Fill(id))
             {
                 action.UI.SetAutoPrefix("txt_", "ddl_");
                 action.UI.SetToAll(this);
                 content = action.Data["content"].GetString();
                 if (action.Data["Tupian"].GetString().Length > 0)
                 {
                     tupian = LibFile.get_img(action.Data["Tupian"].GetString(), "", "");
                 }
             }
         }
     }
 }
Exemple #9
0
 private void LoadData()
 {
     if (id > 0)
     {
         var f = BLL.TcDanye.Instance.GetModel(id);
         if (f != null)
         {
             txt_title.Text           = f.Name;
             txt_ename.Text           = f.Ename;
             ddl_fenlei.SelectedValue = f.Fenlei.GetString();
             content = f.Content;
             if (f.Tupian.GetString().Length > 0)
             {
                 dp              = "";
                 tupianurl       = LibFile.get_img(f.Tupian.GetString(), "", "");
                 hd_tupian.Value = f.Tupian.GetString();
             }
         }
     }
 }
Exemple #10
0
        private void LoadData()
        {
            DataTable dt = new Model.TcConfig().Select("types='web'").ToDataTable();

            foreach (DataRow item in dt.Rows)
            {
                var name = item["Ename"].GetString();
                var c    = FindControl("txt_" + name) as TextBox;
                if (name == "weblogo")
                {
                    if (item["content"].GetString().Length > 0)
                    {
                        weblogo = LibFile.get_img(item["content"].GetString(), "", "");
                    }
                }
                if (c != null)
                {
                    c.Text = item["content"].GetString();
                }
            }
        }
Exemple #11
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (txt_Name.Text.Trim().Length > 0)
            {
                using (MAction action = new MAction("TcFenlei"))
                {
                    action.UI.SetAutoPrefix("txt", "txt_", "ddl_");
                    action.Data.Set("types", types);
                    //action.Data.Set("url", txtUrl.Text);

                    if (filefm.HasFile)
                    {
                        action.Set("Tupian", LibFile.ProcessTupian(filefm));
                    }

                    if (filefm2.HasFile)
                    {
                        action.Set("SeoTitle", LibFile.ProcessTupian(filefm2));
                    }

                    if (id > 0)
                    {
                        action.Update("id=" + id, true);
                    }
                    else
                    {
                        action.Insert(true);
                    }
                    LibCache.remove();
                    alert("保存成功", "list.aspx?types=" + types);
                }
            }
            else
            {
                alert("请输入名称!");
            }
        }
Exemple #12
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            var title = txt_title.Text.Trim().FilterSql();

            if (title.Length > 0)
            {
                using (MAction action = new MAction("TcArticle"))
                {
                    action.UI.SetAutoPrefix("txt_", "ddl_");
                    var content = Request.Form["Editor1"].GetString().FilterSql();
                    action.Set("Content", content);
                    action.Set("Jianyao", content.DeleteHMTL().Subs(180));

                    action.Set("seotitle", txt_seotitle.Text.Replace(",", ","));
                    if (filefm.HasFile)
                    {
                        action.Set("Tupian", LibFile.ProcessTupian(filefm));
                    }

                    if (id > 0)
                    {
                        action.Update("id=" + id, true);
                    }
                    else
                    {
                        action.Set("Types", types);
                        action.Set("addtime", DateTime.Now);
                        action.Insert(true);
                    }
                    alert("保存成功!", "list.aspx?types=" + types);
                }
            }
            else
            {
                alert("请输入标题!");
            }
        }
Exemple #13
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            var list = new Model.TcConfig().Select("types='web'").ToList <Model.TcConfig>();

            foreach (var item in list)
            {
                var name = item.Ename.GetString();
                var c    = FindControl("txt_" + name) as TextBox;
                if (c != null)
                {
                    item.Content = c.Text.GetString();
                    item.Update("id=" + item.ID);
                }
                if (filefm.HasFile && name == "weblogo")
                {
                    item.Content = LibFile.ProcessTupian(filefm);
                    item.Update("id=" + item.ID);
                }
            }

            Cache.Remove("wangzhanpeizhilist");

            alert("保存成功!");
        }
Exemple #14
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            using (MAction action = new MAction("TcArticle"))
            {
                action.UI.SetAutoPrefix("txt_", "ddl_");
                var content = Request.Form["Editor1"].GetString().FilterSql();
                action.Set("Content", content);
                action.Set("Jianyao", content.DeleteHMTL().Subs(180));

                action.Set("seotitle", txt_seotitle.Text.Replace(",", ","));
                if (filefm.HasFile)
                {
                    action.Set("Tupian", LibFile.ProcessTupian(filefm));
                }

                if (id > 0)
                {
                    action.Update("id=" + id, true);
                }
                else
                {
                    action.Set("Types", types);
                    action.Set("addtime", DateTime.Now);
                    action.Insert(true);

                    id = action.Data["id"].GetInt();
                }

                using (MProc proc = new MProc("update tctupian set fid=" + id + " where TabName='TcArticle' and Fid=-" + MyID))
                {
                    proc.ExeNonQuery();
                }

                alert("保存成功!", "list.aspx?types=" + types);
            }
        }
Exemple #15
0
        /// <summary>添加对象文件</summary>
        /// <param name="path"></param>
        /// <param name="filter"></param>
        /// <param name="allSub"></param>
        public void AddObjs(String path, String filter = null, Boolean allSub = false)
        {
            path = path.GetFullPath();
            if (!Directory.Exists(path))
            {
                return;
            }

            if (filter.IsNullOrEmpty())
            {
                filter = "*.o";
            }
            //var opt = allSub ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
            foreach (var item in path.AsDirectory().GetAllFiles(filter, allSub))
            {
                // 不包含,直接增加
                if (!Objs.Contains(item.FullName))
                {
                    var lib = new LibFile(item.FullName);
                    WriteLog("发现对象文件:{0, -12} {1}".F(lib.Name, item.FullName));
                    Objs.Add(item.FullName);
                }
            }
        }
Exemple #16
0
        /// <summary>加载库文件</summary>
        /// <param name="sb"></param>
        protected override void LoadLib(StringBuilder sb)
        {
            var dic = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in Libs)
            {
                var lib = new LibFile(item);
                // 调试版/发行版 优先选用最佳匹配版本
                var old = "";
                // 不包含,直接增加
                if (!dic.TryGetValue(lib.Name, out old))
                {
                    dic.Add(lib.Name, lib.FullName);
                }
                // 已包含,并且新版本更合适,替换
                else
                {
                    //Console.WriteLine("{0} Debug={1} Tiny={2}", lib.FullName, lib.Debug, lib.Tiny);
                    var lib2 = new LibFile(old);
                    if (!(lib2.Debug == Debug && lib2.Tiny == Tiny) &&
                        (lib.Debug == Debug && lib.Tiny == Tiny))
                    {
                        dic[lib.Name] = lib.FullName;
                    }
                }
            }

            var hs = new HashSet <String>(StringComparer.OrdinalIgnoreCase);

            Console.WriteLine("使用静态库:");
            foreach (var item in dic)
            {
                if (!item.Value.EndsWithIgnoreCase(".a"))
                {
                    continue;
                }

                var fi = Path.GetFileName(item.Value);
                if (!fi.StartsWith("lib") || !fi.EndsWith(".a"))
                {
                    continue;
                }

                var dir = Path.GetDirectoryName(item.Value);
                if (!hs.Contains(dir))
                {
                    hs.Add(dir);

                    sb.AppendFormat(" -L{0}", dir);
                }
            }
            var n = 0;

            foreach (var item in dic)
            {
                if (!item.Value.EndsWithIgnoreCase(".a"))
                {
                    continue;
                }

                var fi = Path.GetFileName(item.Value);
                if (!fi.StartsWith("lib") || !fi.EndsWith(".a"))
                {
                    continue;
                }

                Console.WriteLine("\t{0}\t{1}", item.Key, item.Value);

                //if (n++ == 0) sb.Append(" -Xlinker \"-(\"");

                sb.AppendFormat(" -l{0}", fi.TrimStart("lib").TrimEnd(".a"));
            }
            if (n > 0)
            {
                sb.Append(" -Xlinker \"-)\"");
            }
        }
Exemple #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string         path     = LibFile.rootpath;
                HttpPostedFile postfile = Request.Files[0];
                string         res      = "0";
                string         filename = "";
                var            sj       = DateTime.Now.ToString("yyyyMM");
                if (!Directory.Exists(Server.MapPath(path + sj)))
                {
                    Directory.CreateDirectory(Server.MapPath(path + sj));
                }
                var viewwidth  = "";
                var viewheight = "";
                try
                {
                    path = path + sj + "/";
                    FileInfo file       = new FileInfo(postfile.FileName);
                    string   ext        = file.Extension;
                    Random   rd         = new Random();
                    var      randomname = DateTime.Now.ToString("ddHHmmss") + rd.Next(100000, 200000);
                    filename = randomname + ext;
                    postfile.SaveAs(Server.MapPath(path + "y_" + filename));

                    ProcessImage p = new ProcessImage();

                    //0:创建缩略图失败,1:传入的文件格式错误,2:创建成功
                    int r = p.CreateThumbnail(postfile, Server.MapPath(path + filename));
                    if (r == 2)
                    {
                        string[] wh  = Request.QueryString["wh"].GetString().Split(',');
                        var      len = wh.Length;
                        if (len >= 2)
                        {
                            viewwidth  = wh[0];
                            viewheight = wh[1];
                            for (int i = 0; i + 1 < len; i += 2)
                            {
                                if (wh[i].GetInt() > 0 && wh[i + 1].GetInt() > 0)
                                {
                                    r = p.CreateThumbnail(postfile, Server.MapPath(path + wh[i] + wh[i + 1] + "_" + filename), wh[i].GetInt(), wh[i + 1].GetInt(), true);
                                }
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            File.Delete(Server.MapPath(path + sj + "/y_" + filename));
                        }
                        catch { }
                    }
                    if (r == 2)
                    {
                        res = "1";
                    }
                    else
                    {
                        res = "0";
                    }
                }
                catch
                {
                    Response.Write(res);
                    Response.End();
                }

                //状态(1:成功,0:失败)|文件名称
                Response.Write("{res:'" + res + "',rukuname:'" + sj + "/" + filename + "',viewname:'" + LibFile.get_img(sj + "/" + filename, viewwidth, viewheight) + "'}");
                Response.End();
            }
        }
Exemple #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var id       = Request.QueryInt("id");
                var fenleiid = Request.QueryInt("fenleiid");
                var tabname  = Request.QueryString["tabname"].GetString();

                string         path        = LibFile.rootpath;
                HttpPostedFile postfile    = Request.Files["Filedata"];
                string         res         = "0";
                string         filename    = ""; //随机产生的文件名
                string         yuanshiname = ""; //原始文件名
                var            sj          = DateTime.Now.ToString("yyyyMM");

                if (!Directory.Exists(Server.MapPath(path + sj)))
                {
                    Directory.CreateDirectory(Server.MapPath(path + sj));
                }
                var viewwidth  = "";
                var viewheight = "";
                try
                {
                    path = path + sj + "/";
                    FileInfo file = new FileInfo(postfile.FileName);
                    string   ext  = file.Extension;

                    yuanshiname = file.Name.Replace(file.Extension, "");

                    Random rd         = new Random();
                    var    randomname = DateTime.Now.ToString("ddHHmmss") + rd.Next(100000, 200000);
                    filename = randomname + ext;

                    ProcessImage p = new ProcessImage();

                    //0:创建缩略图失败,1:传入的文件格式错误,2:创建成功
                    int r = p.CreateThumbnail(postfile, Server.MapPath(path + filename));
                    if (r == 2)
                    {
                        string[] wh  = Request.QueryString["wh"].GetString().Split(',');
                        var      len = wh.Length;
                        if (len >= 2)
                        {
                            viewwidth  = wh[0];
                            viewheight = wh[1];
                            for (int i = 0; i + 1 < len; i += 2)
                            {
                                if (wh[i].GetInt() > 0 && wh[i + 1].GetInt() > 0)
                                {
                                    r = p.CreateThumbnail(postfile, Server.MapPath(path + wh[i] + wh[i + 1] + "_" + filename), wh[i].GetInt(), wh[i + 1].GetInt(), false);
                                }
                            }
                        }

                        #region 能生成缩略图的情况下,才保存原图

                        postfile.SaveAs(Server.MapPath(path + "y_" + filename));

                        #endregion 能生成缩略图的情况下,才保存原图
                    }
                    else
                    {
                        try
                        {
                            File.Delete(Server.MapPath(path + "y_" + filename));
                        }
                        catch { }
                    }
                    if (r == 2)
                    {
                        res = "1";

                        #region 保存图片数据

                        var tp = new Model.TcTupian()
                        {
                            Fid      = id,
                            Fenleiid = fenleiid,
                            TabName  = tabname,
                            Url      = sj + "/" + filename,
                            Name     = yuanshiname,
                            RukuSj   = DateTime.Now
                        };

                        tp.Insert();

                        #endregion 保存图片数据
                    }
                    else
                    {
                        res = "0";
                    }
                }
                catch
                {
                    Response.Write(res);
                    Response.End();
                }

                //状态(1:成功,0:失败)|文件名称
                Response.Write("{res:'" + res + "',yuanshiname:'" + yuanshiname + "',rukuname:'" + sj + "/" + filename + "',viewname:'" + LibFile.get_img(sj + "/" + filename, viewwidth, viewheight) + "'}");
                Response.End();
            }
        }