public string Scanhtml(string htmlIds, string clientInf)
        {
            Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null;
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                string rootpath = Eva.Library.Format.FormatTextTool.GetMapPath(Eva.Library.Configuration.ConfigurationManager.AppSettings["AppResourceRootPath"].ToString() + "html/", Server);

                sara.dd.ldsw.dal.tbl_app_version_html dal = new sara.dd.ldsw.dal.tbl_app_version_html();

                t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                t.getTrans().begin();

                System.Data.DataTable dt = dal.GetDataTableForPC(" sys_id in ('" + htmlIds.Replace("^", "','") + "') ", "", "sys_id,f_htmlname,f_htmlversion,f_htmlcontent", "", "", t);
                foreach (System.Data.DataRow item in dt.Rows)
                {
                    sara.dd.ldsw.model.tbl_app_version_html model = new sara.dd.ldsw.model.tbl_app_version_html();
                    //item["f_htmlname"].ToString();
                    //item["f_htmlversion"];
                    //item["f_htmlcontent"]
                    //读取文件

                    string htmlName = (rootpath + item["f_htmlname"].ToString()).Replace("/", "\\");

                    string htmlContent = "";
                    if (htmlName.IndexOf(".html") > -1 || htmlName.IndexOf(".js") > -1 || htmlName.IndexOf(".css") > -1)
                    {
                        htmlContent = FileOperation.ReadFile(htmlName);
                    }
                    //比较是否相同
                    if (htmlContent != item["f_htmlcontent"].ToString())
                    {
                        model.sys_id           = int.Parse(item["sys_id"].ToString());
                        model.f_htmlversion    = GetVersion(item["f_htmlversion"].ToString());
                        model.f_htmlcontent    = htmlContent;
                        model.sys_lasteditdate = System.DateTime.Now;
                        dal.Update(model, "sys_id,f_htmlversion,f_htmlcontent,sys_lasteditdate", t);
                    }
                }

                t.getTrans().commit();
                resultDic["result"]  = "true";
                resultDic["message"] = "";
            }
            catch (Exception ex)
            {
                if (t != null)
                {
                    t.getTrans().rollback();
                }

                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
        public string ScanAllhtml(string clientInf)
        {
            Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null;
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                string rootpath = Eva.Library.Format.FormatTextTool.GetMapPath(Eva.Library.Configuration.ConfigurationManager.AppSettings["AppResourceRootPath"].ToString() + "html/", Server);

                List <FileInformation> activeFile = new List <FileInformation>();
                List <FileInformation> allFile    = DirectoryAllFiles.GetAllFiles(new System.IO.DirectoryInfo(rootpath));
                #region 剔除不必要的文件
                foreach (var item in allFile)
                {
                    if (item.FilePath.IndexOf("lib\\framework7\\kitchen-sink-material") > -1 && (item.FileExtName == ".html" || item.FileExtName == ".json" || item.FileExtName == ".php"))
                    {
                    }
                    else if (item.FilePath.IndexOf("lib\\hello-mui") > -1)
                    {
                    }
                    else if (item.FileName.Contains(".min."))
                    {
                    }
                    else if (item.FileExtName == ".html" || item.FileExtName == ".js" || item.FileExtName == ".css")
                    {
                        activeFile.Add(item);
                    }
                }
                #endregion

                sara.dd.ldsw.dal.tbl_app_version_html dal = new sara.dd.ldsw.dal.tbl_app_version_html();

                t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                t.getTrans().begin();

                System.Data.DataTable dt = dal.GetDataTableForPC("", "", "sys_id,f_htmlname,f_htmlversion,f_htmlcontent", "", "", t);
                foreach (var item in activeFile)
                {
                    sara.dd.ldsw.model.tbl_app_version_html model = new sara.dd.ldsw.model.tbl_app_version_html();
                    string htmlName = item.FilePath + "\\" + item.FileName;
                    htmlName = htmlName.Replace(rootpath, "").Replace("\\", "/");

                    string htmlContent = "";
                    if (item.FileExtName == ".html" || item.FileExtName == ".js" || item.FileExtName == ".css")
                    {
                        htmlContent = FileOperation.ReadFile(item.FilePath + "\\" + item.FileName);
                    }
                    //验证如果文件存在于数据库中
                    System.Data.DataRow[] drs = dt.Select(" f_htmlname = '" + htmlName + "'");
                    if (drs.Length > 0)
                    {
                        //比较是否相同
                        if (htmlContent != drs[0]["f_htmlcontent"].ToString())
                        {
                            model.sys_id           = int.Parse(drs[0]["sys_id"].ToString());
                            model.f_htmlversion    = GetVersion(drs[0]["f_htmlversion"].ToString());
                            model.f_htmlcontent    = htmlContent;
                            model.sys_lasteditdate = System.DateTime.Now;
                            dal.Update(model, "sys_id,f_htmlversion,f_htmlcontent,sys_lasteditdate", t);
                        }
                    }
                    else
                    {
                        model.f_htmlname       = htmlName;
                        model.f_htmlversion    = "1.0.0";
                        model.f_htmlcontent    = htmlContent;
                        model.sys_delflag      = "0";
                        model.sys_creatdate    = System.DateTime.Now;
                        model.sys_lasteditdate = System.DateTime.Now;
                        dal.Add(model, t);
                    }
                }

                t.getTrans().commit();
                resultDic["result"]  = "true";
                resultDic["message"] = "";
            }
            catch (Exception ex)
            {
                if (t != null)
                {
                    t.getTrans().rollback();
                }

                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
Beispiel #3
0
        public string GetHtmlFileVersion(string htmlVersionJsonString, string clientInf)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                IDictionary <String, String> userInfDic = commonclass.commonclass.CheckClientInf(clientInf);
                if (userInfDic == null)
                {
                    resultDic["result"]  = "false";
                    resultDic["message"] = "客户端信息错误";
                }
                else
                {
                    DataTable clientDataTable = Eva.Library.Format.FormatEntityTool.FormatJsonToDataTable(htmlVersionJsonString);
                    sara.dd.ldsw.dal.tbl_app_version_html dal = new sara.dd.ldsw.dal.tbl_app_version_html();
                    DataTable serverDataTable = dal.GetDataTableForPC("", "", "f_htmlname,f_htmlversion", "", "", null);
                    DataTable resultDataTable = serverDataTable.Clone();
                    if (clientDataTable == null)
                    {
                        resultDataTable = serverDataTable;
                    }
                    else
                    {
                        for (int i = 0; i < serverDataTable.Rows.Count; i++)
                        {
                            //判断client中是否有,
                            DataRow[] drs = clientDataTable.Select(" f_htmlname = '" + serverDataTable.Rows[i]["f_htmlname"].ToString() + "'");

                            if (drs.Length > 0) //如果有
                            {
                                //判断是否版本相同
                                if (drs[0]["f_htmlversion"].ToString() != serverDataTable.Rows[i]["f_htmlversion"].ToString())
                                {
                                    DataRow dr = resultDataTable.NewRow();
                                    dr["f_htmlversion"] = serverDataTable.Rows[i]["f_htmlversion"].ToString();
                                    dr["f_htmlname"]    = serverDataTable.Rows[i]["f_htmlname"].ToString();
                                    resultDataTable.Rows.Add(dr);
                                }
                            }
                            else //如果没有
                            {
                                DataRow dr = resultDataTable.NewRow();
                                dr["f_htmlversion"] = serverDataTable.Rows[i]["f_htmlversion"].ToString();
                                dr["f_htmlname"]    = serverDataTable.Rows[i]["f_htmlname"].ToString();
                                resultDataTable.Rows.Add(dr);
                            }
                        }
                    }
                    resultDic["result"]  = "true";
                    resultDic["message"] = Eva.Library.Format.FormatEntityTool.FormatDataTableToJson(resultDataTable);
                }
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "error";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }