Пример #1
0
        public ActionResult UserStatus()
        {
            DbContext currentDb = SysContext.GetCurrentDb();
            string    appName   = currentDb.ExecuteScalar <string>("select SettingValue from core_setting where SettingKey = @0", new object[1]
            {
                "AppName"
            });
            core_user core_user = currentDb.FirstOrDefault <core_user>("where id = @0", new object[1]
            {
                SysContext.FastDevUserID
            });

            if (core_user == null)
            {
                return(Json(new
                {
                    statusCode = "3"
                }));
            }
            return(Json(new
            {
                statusCode = "1",
                data = new
                {
                    homeStyle = core_user.HomeStyle,
                    realName = core_user.RealName,
                    userName = core_user.LoginName,
                    appName = appName,
                    id = core_user.ID,
                    myPic = core_user.MyPic
                }
            }));
        }
Пример #2
0
 public ActionResult UpgradePage(string model, string viewname)
 {
     try
     {
         strLogs = "";
         DbContext currentDb = SysContext.GetCurrentDb();
         core_menu core_menu = currentDb.FirstOrDefault <core_menu>("where MenuUrl like '%model=" + model + "%' and MenuUrl like '%viewname=" + viewname + "%'", new object[0]);
         if (core_menu == null)
         {
             core_menu = currentDb.FirstOrDefault <core_menu>("where MenuUrl like '%model=" + model + "%' and MenuUrl like '%viewtype=" + viewname + "%'", new object[0]);
         }
         if (core_menu != null)
         {
             UpdateCoreMenu(core_menu);
         }
         GenUpdateFile(model, viewname);
         return(Json(new AjaxResult
         {
             statusCode = "1"
         }));
     }
     catch (Exception ex)
     {
         ServiceHelper.Log(ex);
         return(Json(new AjaxResult
         {
             statusCode = ((ex is UserException) ? "2" : "3"),
             message = ex.Message
         }));
     }
 }
Пример #3
0
 public ActionResult JList(string variableid)
 {
     if (variableid != null)
     {
         byte[] data; string text = string.Empty;
         if (HttpContext.Session.TryGetValue(variableid, out data))
         {
             text = Encoding.UTF8.GetString(data);
         }
         if (text != null)
         {
             base.ViewBag.FilterJson = text;
             FilterGroup filter         = JsonHelper.DeserializeJsonToObject <FilterGroup>(text);
             DbContext   currentDb      = SysContext.GetCurrentDb();
             IList       commonListData = DataAccessHelper.GetCommonListData(currentDb, "crm_customer", filter, "order by createdate desc");
             base.ViewBag.DataJson = JsonHelper.SerializeObject(commonListData);
         }
         else
         {
             base.ViewBag.DataJson = "[]";
         }
     }
     else
     {
         base.ViewBag.DataJson = "[]";
     }
     return(View());
 }
Пример #4
0
        public ActionResult AutoUpgrade()
        {
            DbContext        currentDb = SysContext.GetCurrentDb();
            List <core_menu> list      = currentDb.Fetch <core_menu>("", new object[0]);

            foreach (core_menu item in list)
            {
                UpdateCoreMenu(item);
            }
            string[] files = Directory.GetFiles(Server.MapPath("~/UI/"), "*", SearchOption.AllDirectories);
            string[] array = files;
            foreach (string text in array)
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
                string text2 = text.Replace(Path.GetFileName(text), "");
                text2 = text2.Substring(0, text2.Length - 1);
                text2 = text2.Substring(text2.ToLower().IndexOf("\\ui\\") + 4);
                string text3 = text2.Contains("\\") ? text2.Substring(text2.LastIndexOf("\\") + 1) : text2;
                text3 = text3.Replace("\\", "");
                Server.MapPath("~/pages/" + text3 + "/");
                if (fileNameWithoutExtension.Contains("service_"))
                {
                    fileNameWithoutExtension = fileNameWithoutExtension.Replace("service_", "") + ".service.js";
                    string str = System.IO.File.ReadAllText(text);
                    str = "\r\n                    define([], function ()\r\n                    {\r\n                        return " + str + " \r\n                    }); ";
                }
                else
                {
                    GenUpdateFile(text3, fileNameWithoutExtension);
                }
            }
            ServiceHelper.Log("更新日志", strLogs);
            return(Content(strLogs.Replace("\n", "<br />"), "text/html"));
        }
Пример #5
0
        public ActionResult test_setup(string content)
        {
            string    updatePackagePath = GetUpdatePackagePath();
            DbContext currentDb         = SysContext.GetCurrentDb();

            System.IO.File.WriteAllBytes(updatePackagePath, Convert.FromBase64String(content));
            return(Content(updatePackagePath));
        }
Пример #6
0
        public void FillUserInfo(int page, int pageCount)
        {
            var       u         = SysContext.GetWanJiangUser();
            DbContext currentDb = SysContext.GetCurrentDb();

            dicPageInfo["page"]      = ObjectExtensions.ToStr((object)page);
            dicPageInfo["pagecount"] = ObjectExtensions.ToStr((object)pageCount);
            dicPageInfo["loginname"] = u.AccountId;
            dicPageInfo["now"]       = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
        }
Пример #7
0
        public ActionResult ResetMd5Password()
        {
            DbContext currentDb = SysContext.GetCurrentDb();
            int       num       = currentDb.Execute("update core_user set LoginPassword = @0", new object[1]
            {
                HashHelper.GetMd5("1")
            });

            return(Content("操作成功"));
        }
Пример #8
0
        public ActionResult AutoUpgradeMenus()
        {
            DbContext        currentDb = SysContext.GetCurrentDb();
            List <core_menu> list      = currentDb.Fetch <core_menu>("", new object[0]);

            foreach (core_menu item in list)
            {
                UpdateCoreMenu(item);
            }
            return(Content(strLogs.Replace("\n", "<br />"), "text/html"));
        }
Пример #9
0
        public ActionResult DownloadUserPics2(string context)
        {
            //IL_0016: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ed: Expected O, but got Unknown
            DbContext currentDb = SysContext.GetCurrentDb();

            if (string.IsNullOrEmpty(context))
            {
                throw new UserException("请选择用户");
            }
            currentDb.BeginTransaction();
            List <ZipFileInfo> list = new List <ZipFileInfo>();

            try
            {
                string[] array  = context.Split(';');
                string[] array2 = array;
                foreach (string text in array2)
                {
                    Model.Core.Entity.core_user core_user = currentDb.FirstOrDefault <Model.Core.Entity.core_user>("where ID = @0", new object[1]
                    {
                        text
                    });
                    if (System.IO.File.Exists(Server.MapPath("~/" + core_user.MyPic)))
                    {
                        currentDb.Update("core_user", "ID", (object)new
                        {
                            ID  = text,
                            字段1 = 1
                        });
                        string extension = Path.GetExtension(core_user.MyPic);
                        list.Add(new ZipFileInfo(Server.MapPath("~/" + core_user.MyPic), core_user.RealName + extension));
                    }
                }
                currentDb.CompleteTransaction();
            }
            catch (Exception ex)
            {
                currentDb.AbortTransaction();
                throw ex;
            }
            string text2 = Server.MapPath("~/" + DateTime.Now.ToString("yyyyMMddHHmmssss") + ".zip");

            ZipHelper.Zip((IList <ZipFileInfo>)list, text2);
            return(File(new FileStream(text2, FileMode.Open), "application/octet-stream", Server.UrlEncode("匹配下载图片.zip")));
        }
Пример #10
0
        /// <summary>
        /// 获取报表相关参数
        /// </summary>
        /// <param name="model"></param>
        /// <param name="arg"></param>
        /// <returns></returns>
        public ReportResult GetReportResult(string model, ReportArg arg)
        {
            DbContext    currentDb    = SysContext.GetCurrentDb();
            ReportResult reportResult = new ReportResult();

            reportModelName   = model;
            reportModelConfig = ServiceHelper.GetServiceConfig(model);

            List <NameValue> list_0 = GetLegendNameValues(currentDb, arg);
            List <NameValue> list_1 = GetAxisNameValues(currentDb, arg);

            foreach (NameValue item in list_1)
            {
                reportResult.axis.Add(item.name);
            }
            foreach (NameValue item2 in list_0)
            {
                reportResult.legend.Add(item2.name);
                object obj = null;
                if (!string.IsNullOrEmpty(arg.axisField) && arg.legendType != "pie")
                {
                    List <object> list = new List <object>();
                    foreach (NameValue item3 in list_1)
                    {
                        FilterGroup      group            = GetDateTimeLegendFilter(currentDb, arg, item2.value, item3.value);
                        FilterTranslator filterTranslator = new FilterTranslator(group);
                        filterTranslator.Translate();
                        list.Add(GetCountValue(currentDb, arg.valueField, arg.valueFieldType, filterTranslator.CommandText, filterTranslator.Parms.ToArray()));
                    }
                    obj = list;
                }
                else
                {
                    FilterGroup      group            = GetDateTimeLegendFilter(currentDb, arg, item2.value, null);
                    FilterTranslator filterTranslator = new FilterTranslator(group);
                    filterTranslator.Translate();
                    obj = GetCountValue(currentDb, arg.valueField, arg.valueFieldType, filterTranslator.CommandText, filterTranslator.Parms.ToArray());
                }
                reportResult.series.Add(new
                {
                    name  = item2.name,
                    value = obj
                });
            }
            return(reportResult);
        }
Пример #11
0
        public ActionResult Index(string homestyle)
        {
            DbContext currentDb = SysContext.GetCurrentDb();

            core_user core_user = currentDb.FirstOrDefault <core_user>("where id = @0", new object[1]
            {
                SysContext.FastDevUserID
            });

            if (core_user == null)
            {
                return(new RedirectResult("/home/login"));
            }
            if (core_user.HomeStyle == "swin" || homestyle == "swin")
            {
                return(View("Index_StyleWin"));
            }
            //return View();
            return(Content(System.IO.File.ReadAllText(Server.MapPath("~/index.html")), "text/html"));
        }
Пример #12
0
        private void UpdateCoreMenu(core_menu menuData)
        {
            DbContext currentDb = SysContext.GetCurrentDb();

            if (menuData.MenuUrl != null)
            {
                string text = "http://a.com/" + menuData.MenuUrl;
                if (menuData.MenuUrl != null && menuData.MenuUrl.EndsWith(".js"))
                {
                    currentDb.Update("core_menu", "ID", new
                    {
                        ID      = menuData.ID,
                        MenuUrl = menuData.MenuUrl.Replace(".js", ".w")
                    });
                }
                if (menuData.MenuUrl != null && menuData.MenuUrl.Contains(".js?"))
                {
                    currentDb.Update("core_menu", "ID", new
                    {
                        ID      = menuData.ID,
                        MenuUrl = menuData.MenuUrl.Replace(".js", ".w")
                    });
                }
                if (text.Contains("model="))
                {
                    string newUrl = GetNewUrl(text);
                    if (!(newUrl == text))
                    {
                        strLogs += string.Format("\n更新菜单({0})链接为{1}", menuData.MenuName, newUrl);
                        currentDb.Update("core_menu", "ID", new
                        {
                            ID      = menuData.ID,
                            MenuUrl = newUrl
                        });
                    }
                }
            }
        }
Пример #13
0
 public static void Log(string content)
 {
     try
     {
         DbContext currentDb = SysContext.GetCurrentDb();
         core_log  coreLog   = new core_log
         {
             CreateDate   = DateTime.Now,
             CreateUserID = SysContext.WanJiangUserID,
             ID           = ObjectExtensions.ToStr((object)Guid.NewGuid()),
             Logtime      = DateTime.Now,
             Title        = "设计模式",
             Logcontent   = content,
             Logtype      = "designer",
             Systempath   = FastDev.Common.HttpContext.Current.Request.Path.ToString(),
             UserID       = SysContext.WanJiangUserID
         };
         currentDb.Insert("core_log", "ID", false, coreLog);
     }
     catch (Exception)
     {
     }
 }
Пример #14
0
        public ActionResult setup(string content)
        {
            string    updatePackagePath = GetUpdatePackagePath();
            DbContext currentDb         = SysContext.GetCurrentDb();

            System.IO.File.WriteAllBytes(updatePackagePath, Convert.FromBase64String(content));
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            List <string> lstLogs = (List <string>)(dictionary["logs"] = new List <string>());

            try
            {
                if (System.IO.File.Exists(updatePackagePath))
                {
                    dictionary["exist"] = true;
                    string projectPath = GetProjectPath();
                    string zipRootPath = updatePackagePath.Substring(0, updatePackagePath.Length - ".zip".Length) + "\\";
                    ZipHelper.UnZip(updatePackagePath, zipRootPath);
                    System.IO.File.Delete(updatePackagePath);
                    string[] files = Directory.GetFiles(zipRootPath, "*", SearchOption.AllDirectories);
                    dictionary["files_count"] = files.Count();
                    dictionary["files"]       = files;
                    bool     modelBuild   = false;
                    bool     serviceBuild = false;
                    string[] array        = files;
                    foreach (string f in array)
                    {
                        try
                        {
                            string fileName = f.Replace(zipRootPath, "");
                            lstLogs.Add("path:" + fileName);
                            if (fileName.StartsWith("db\\"))
                            {
                                string sqlContent = System.IO.File.ReadAllText(f);
                                int    num        = 0;
                                if (fileName.EndsWith(".sqljson"))
                                {
                                    Dictionary <string, object> sqlJson = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(sqlContent);
                                    sqlContent = ObjectExtensions.ToStr(sqlJson["sql"]);
                                    var ags = sqlJson["args"];
                                    if (ags is Array)
                                    {
                                        num = currentDb.Execute(sqlContent, ((Array)ags));
                                    }
                                    else
                                    {
                                        num = currentDb.Execute(sqlContent, ags);
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        currentDb.Execute(sqlContent, new object[0]);
                                    }
                                    catch (Exception ex)
                                    {
                                        Log("写入SQL失败:" + sqlContent + "(" + ex.Message + ")");
                                    }
                                }
                                try
                                {
                                    lstLogs.Add("写入SQL:" + sqlContent + "(" + num + ")");
                                    Log("写入SQL:" + sqlContent + "(" + num + ")");
                                }
                                catch (Exception ex)
                                {
                                    lstLogs.Add("写入SQL:" + sqlContent + "\n出错:" + ex.Message);
                                    Log("写入SQL:" + sqlContent + "\n出错:" + ex.Message);
                                }
                            }
                            else if (fileName == "update.json")
                            {
                                string     input      = System.IO.File.ReadAllText(f);
                                updateinfo updateinfo = JsonHelper.DeserializeJsonToObject <updateinfo>(input);
                                if (updateinfo.model != null && updateinfo.model.Any())
                                {
                                    AddCSFiles("Model", zipRootPath, updateinfo.model);
                                    modelBuild = true;
                                }
                                if (updateinfo.model_remove != null && updateinfo.model_remove.Any())
                                {
                                    RemvoeCSFiles("Model", zipRootPath, updateinfo.model_remove);
                                    modelBuild = true;
                                }
                                if (updateinfo.web != null && updateinfo.web.Any())
                                {
                                    AddStaticFiles("web", zipRootPath, updateinfo.web);
                                }
                                if (updateinfo.web_remove != null && updateinfo.web_remove.Any())
                                {
                                    RemvoeStaticFiles("web", zipRootPath, updateinfo.web_remove);
                                }
                                if (updateinfo.mobileWeb != null && updateinfo.mobileWeb.Any())
                                {
                                    AddStaticFiles("mobileWeb", zipRootPath, updateinfo.mobileWeb);
                                }
                                if (updateinfo.mobileWeb_remove != null && updateinfo.mobileWeb_remove.Any())
                                {
                                    RemvoeStaticFiles("mobileWeb", zipRootPath, updateinfo.mobileWeb_remove);
                                }
                                if (updateinfo.service != null && updateinfo.service.Any())
                                {
                                    AddCSFiles("Service", zipRootPath, updateinfo.service);
                                    serviceBuild = true;
                                }
                                if (updateinfo.service_remove != null && updateinfo.service_remove.Any())
                                {
                                    RemvoeCSFiles("Service", zipRootPath, updateinfo.service_remove);
                                    serviceBuild = true;
                                }
                                if (updateinfo.bin != null && updateinfo.bin.Any())
                                {
                                    AddBinFiles(zipRootPath, updateinfo.bin);
                                }
                                if (updateinfo.bin_remove != null && updateinfo.bin_remove.Any())
                                {
                                    RemoveBinFiles(zipRootPath, updateinfo.bin_remove);
                                }
                                if (updateinfo.menu != null && updateinfo.menu.Any())
                                {
                                    foreach (updatemenu item in updateinfo.menu)
                                    {
                                        core_menu core_menu = new core_menu();
                                        core_menu.ID           = Guid.NewGuid().ToString();
                                        core_menu.CreateUserID = SysContext.WanJiangUserID;
                                        core_menu.CreateDate   = DateTime.Now;
                                        core_menu.MenuName     = item.title;
                                        core_menu.MenuUrl      = item.url;
                                        core_menu.MenuNo       = item.menuNo;
                                        core_menu.MenuIcon     = "/contents/icons/bubbles/02.Shop.png";
                                        if (!string.IsNullOrEmpty(item.parentNo))
                                        {
                                            string text6 = core_menu.ParentID = currentDb.ExecuteScalar <string>("select ID from core_menu where MenuNo = @0", new object[1]
                                            {
                                                item.parentNo
                                            });
                                        }
                                        currentDb.Insert("core_menu", "ID", false, (object)core_menu);
                                    }
                                }
                            }
                        }
                        catch (Exception ex2)
                        {
                            lstLogs.Add("Error2:" + ex2.Message + ",StackTrace2:" + ex2.StackTrace);
                        }
                    }
                    //if (modelBuild)
                    //{
                    //    string projectName = ConfigurationManager.AppSettings["ModelProjectName"];
                    //    CompileProject($"{projectPath}{projectName}\\{projectName}.csproj");
                    //}
                    //if (serviceBuild)
                    //{
                    //    string projectName = ConfigurationManager.AppSettings["ServiceProjectName"];
                    //    CompileProject($"{projectPath}{projectName}\\{projectName}.csproj");
                    //}
                    //if (modelBuild || serviceBuild)
                    //{
                    //    string projectName = ConfigurationManager.AppSettings["WebProjectName"];
                    //    CompileProject($"{projectPath}{projectName}\\{projectName}.csproj");
                    //}
                }
                else
                {
                    dictionary["exist"] = false;
                }
            }
            catch (Exception ex)
            {
                lstLogs.Add("Error:" + ex.Message + ",StackTrace:" + ex.StackTrace);
            }
            return(Json(new AjaxResult
            {
                data = dictionary,
                statusCode = "1"
            }));
        }
Пример #15
0
        public List <TemplatePageInfo> GetTemplatePageInfo(string contextIds)
        {
            List <TemplatePageInfo> list = new List <TemplatePageInfo>();

            if (printTemp != null)
            {
                ServiceConfig serviceConfig   = ServiceHelper.GetServiceConfig(printTemp.ModelName);
                string        detailFieldName = GetReportDetialHtml();
                int           num             = 1;
                if (string.IsNullOrEmpty(detailFieldName))
                {
                    string[] array = contextIds.Split(';');
                    foreach (string context in array)
                    {
                        TemplatePageInfo templatePageInfo = new TemplatePageInfo
                        {
                            Context      = context,
                            PageIndex    = 1,
                            AllPageIndex = num++
                        };
                        list.Add(templatePageInfo);
                    }
                }
                else
                {
                    DbContext currentDb = SysContext.GetCurrentDb();
                    Field     field     = (from a in serviceConfig.fields
                                           where a.name == detailFieldName
                                           select a).FirstOrDefault();
                    if (field != null)
                    {
                        ServiceHelper.GetService(field.relationModel);
                        string[] array = contextIds.Split(';');
                        foreach (string context in array)
                        {
                            int num2 = 1;
                            int num4 = currentDb.ExecuteScalar <int>(string.Format("select count(*) from {0} where {1} = @0", field.relationModel, field.relationField), new object[1]
                            {
                                context
                            });
                            double a2   = (double)num4 * 1.0 / (double)printTemp.PageSize.Value;
                            int    num5 = (int)Math.Ceiling(a2);
                            if (num5 == 0)
                            {
                                list.Add(new TemplatePageInfo
                                {
                                    Context      = context,
                                    PageIndex    = num2++,
                                    AllPageIndex = num++
                                });
                            }
                            else
                            {
                                for (int j = 1; j <= num5; j++)
                                {
                                    list.Add(new TemplatePageInfo
                                    {
                                        Context      = context,
                                        PageIndex    = num2++,
                                        AllPageIndex = num++
                                    });
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Пример #16
0
        public ActionResult Welcome()
        {
            DbContext currentDb = SysContext.GetCurrentDb();

            return(View());
        }
Пример #17
0
 public ActionResult Login(string username, string password)
 {
     try
     {
         DbContext currentDb = SysContext.GetCurrentDb();
         if (SysContext.EnabledMD5Password)
         {
             password = HashHelper.GetMd5(password);
         }
         bool flag = false;
         flag = currentDb.Exists <core_user>("Loginname = @0 and LoginPassword = @1", new object[2]
         {
             username,
             password
         });
         Regex regex = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$");
         if (regex.IsMatch(username))
         {
             if (flag = currentDb.Exists <core_user>("Email = @0 and LoginPassword = @1", new object[2]
             {
                 username,
                 password
             }))
             {
                 username = currentDb.ExecuteScalar <string>("select Loginname from core_user where Email = @0 and LoginPassword = @1", new object[2]
                 {
                     username,
                     password
                 });
             }
         }
         else
         {
             flag = currentDb.Exists <core_user>("Loginname = @0 and LoginPassword = @1", new object[2]
             {
                 username,
                 password
             });
         }
         if (flag)
         {
             currentDb.ExecuteScalar <string>("select ID from core_user where Loginname = @0 and LoginPassword = @1", new object[2]
             {
                 username,
                 password
             });
             HttpCookie httpCookie = new HttpCookie(cookie_user);
             httpCookie.Path    = "/";
             httpCookie.Value   = SSOHelper.CreateContextValue(username, password);
             httpCookie.Expires = DateTime.Now.AddHours(2.0);
             CookieHelper.SetCookie(httpCookie);
         }
         return(Json(new
         {
             statusCode = "1",
             data = flag
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             statusCode = "3",
             message = ex.Message
         }));
     }
 }
Пример #18
0
        public static void Update()
        {
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_005e: Unknown result type (might be due to invalid IL or missing references)
            string            version     = GetVersion();
            List <UpdateInfo> updateInfos = GetUpdateInfos(version, true);

            if (updateInfos == null || !updateInfos.Any())
            {
                throw new UserException("已经是最新版本,无需更新");
            }
            int myIndex = GetVersionSort(version);

            updateInfos = (from a in updateInfos
                           where GetVersionSort(a.version) > myIndex
                           select a).ToList();
            if (!updateInfos.Any())
            {
                throw new UserException("已经是最新版本,无需更新");
            }
            updateInfos = updateInfos.OrderBy(o => GetVersionSort(o.version)).ToList();
            DbContext currentDb = SysContext.GetCurrentDb();

            foreach (UpdateInfo item in updateInfos)
            {
                if (!string.IsNullOrEmpty(item.data))
                {
                    bool   flag  = item == updateInfos[0];
                    string oPath = GetOneItemPath(item);
                    File.WriteAllBytes(oPath, Convert.FromBase64String(item.data));
                    File.WriteAllText(oPath.Replace(".zip", ".txt"), item.content);
                    if (File.Exists(oPath))
                    {
                        string unZipDir = oPath.Substring(0, oPath.Length - ".zip".Length) + "\\";
                        string newValue = oPath.Substring(0, oPath.Length - ".zip".Length) + "_bak\\";
                        ZipHelper.UnZip(oPath, unZipDir);
                        File.Delete(oPath);
                        string str = "db";
                        if (CheckIsSQLite())
                        {
                            str = "db_sqlite";
                        }
                        string zipFilesPath = unZipDir + "files\\";
                        if (Directory.Exists(zipFilesPath))
                        {
                            string[] files = Directory.GetFiles(zipFilesPath, "*", SearchOption.AllDirectories);
                            string[] array = files;
                            foreach (string text4 in array)
                            {
                                DirectoryInfo directoryInfo = new DirectoryInfo(new HttpServerUtility(HttpContext.Current).MapPath("~/"));
                                string        newValue2     = directoryInfo.Parent.FullName + "\\";
                                string        text5         = text4.Replace(zipFilesPath, newValue2);
                                if (File.Exists(text5))
                                {
                                    string text6 = text4.Replace(zipFilesPath, newValue);
                                    FileHelper.Copy(text5, text6);
                                }
                                FileHelper.Copy(text4, text5);
                            }
                        }
                        if (Directory.Exists(unZipDir + str + "\\"))
                        {
                            string[] files2 = Directory.GetFiles(unZipDir + str + "\\", "*", SearchOption.AllDirectories);
                            string[] array  = files2;
                            foreach (string path in array)
                            {
                                string text7 = File.ReadAllText(path);
                                try
                                {
                                    if (!string.IsNullOrEmpty(text7))
                                    {
                                        currentDb.Execute(text7, new object[0]);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    WriteLog("执行SQL(" + text7 + ")出错:" + ex.Message);
                                }
                            }
                        }
                        WriteLog(string.Format("更新:{0}\r\n更新内容:\r\n{1}", item.version, item.content));
                        UpdatetVersion(item.version);
                    }
                }
            }
        }
Пример #19
0
        public ActionResult Index()
        {
            string    text      = "<div style='font-size:12px;'>";
            DbContext currentDb = SysContext.GetCurrentDb();
            bool      flag      = false;

            try
            {
                currentDb.ExecuteScalar <string>("select id from core_user", new object[0]);
                text += "数据库测试成功<br />";
            }
            catch (Exception ex)
            {
                flag = true;
                text = text + "数据库测试不成功,错误信息:" + ex.Message + "<br />";
            }
            try
            {
                FileInfo fileInfo = new FileInfo(Server.MapPath("~/bin/ne.model.dll"));
                if (fileInfo != null)
                {
                    text = text + "FastDev.Model.dll更新时间:" + fileInfo.LastWriteTime.ToString() + "<br>";
                }
            }
            catch
            {
            }
            try
            {
                string text2 = ConfigurationManager.AppSettings["ProjectPath"];
                string text3 = ConfigurationManager.AppSettings["MSBuildPath"];
                if (!text2.EndsWith("\\"))
                {
                    text2 += "\\";
                }
                text2 = text2.Replace("#ROOT#", GetRootPath());
                text3 = text3.Replace("#ROOT#", GetRootPath());
                text  = text + "ProjectPath:" + text2 + "<br />";
                if (!Directory.Exists(text2))
                {
                    text += "ProjectPath配置路径不存在,请检查<br />";
                }
                text = text + "MSBuildPath:" + text3 + "<br />";
                if (!System.IO.File.Exists(text3))
                {
                    text += "MSBuildPath配置路径不存在,请检查<br />";
                }
                string text4 = CompileProject(text3, text2 + "FastDev.Model\\FastDev.Model.csproj");
                if (!string.IsNullOrEmpty(text4))
                {
                    if (text4.Length < 2000)
                    {
                        text = text + "<b>实体类编译信息:</b><br>" + text4 + "<br>";
                    }
                }
                else
                {
                    text += "实体类编译成功<br>";
                }
                text3 = "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe";
                if (System.IO.File.Exists(text3))
                {
                    text4 = CompileProject(text3, text2 + "FastDev.Model\\FastDev.Model.csproj");
                    if (!string.IsNullOrEmpty(text4))
                    {
                        if (text4.Length < 2000)
                        {
                            text = text + "<b>实体类编译信息2:</b><br>" + text4 + "<br>";
                        }
                    }
                    else
                    {
                        text += "实体类编译成功2<br>";
                    }
                }
            }
            catch
            {
            }
            try
            {
                FileInfo     fileInfo     = new FileInfo(Server.MapPath("~/bin/ne.model.dll"));
                Assembly     assembly     = Assembly.Load("FastDev.Model");
                ModelsConfig modelsConfig = ServiceHelper.GetModelsConfig();
                foreach (FastDev.DevDB.Model.Config.Model model in modelsConfig.models)
                {
                    try
                    {
                        ServiceConfig serviceConfig = ServiceHelper.GetServiceConfig(model.name);
                        if (serviceConfig != null && !flag)
                        {
                            List <string> list  = currentDb.Fetch <string>("select name from syscolumns where id=object_id('" + model.name + "')", new object[0]);
                            bool          flag2 = assembly.GetTypes().Any((Type a) => a.FullName.EndsWith("." + model.name));
                            int           num   = 0;
                            if (flag2)
                            {
                                num = assembly.GetTypes().FirstOrDefault((Type a) => a.FullName.EndsWith("." + model.name)).GetProperties()
                                      .Count();
                            }
                            text += string.Format("<b>【{0}】【{1}】(包括{2}个字段)(包括{3}个DB字段)【状态:{4}】</b><br>", model.moduleName, model.name, serviceConfig.fields.Count, list.Count, flag2 ? "正常" : "未编译");
                            if (!ExistSql(currentDb, "SELECT\r\ncount(*),\r\ntbl.name AS [Name]\r\nFROM sys.tables AS tbl\r\nWHERE (tbl.name=N'" + model.name + "' and SCHEMA_NAME(tbl.schema_id)=N'dbo')"))
                            {
                                text += "不存在于数据库 <br>";
                            }
                            string text5 = Server.MapPath(string.Format("~/UI/{0}/{1}/", model.moduleName, model.name));
                            if (Directory.Exists(text5))
                            {
                                string[] files = Directory.GetFiles(text5);
                                text += "包括以下界面:<br>";
                                string[] array = files;
                                foreach (string text6 in array)
                                {
                                    string text7 = text6.Replace(text5, "");
                                    if (!text7.StartsWith("service_"))
                                    {
                                        text = text + text7 + "<br>";
                                    }
                                }
                            }
                            foreach (Field field in serviceConfig.fields)
                            {
                                if (!IsMatch(field.name, "^[a-zA-Z][a-zA-Z0-9_]+$"))
                                {
                                    text = text + "字段" + field.name + "命名不规范<br>";
                                }
                                if (field.type == "many2one")
                                {
                                    if (!list.Any((string a) => a == field.dbName))
                                    {
                                        text = text + "数据库缺少字段" + field.dbName + "<br>";
                                    }
                                }
                                else if (!field.type.Contains("2") && !list.Any((string a) => a == field.name))
                                {
                                    text = text + "数据库缺少字段" + field.name + "<br>";
                                }
                                if (flag2)
                                {
                                    Type type = assembly.GetTypes().FirstOrDefault((Type a) => a.FullName.EndsWith("." + model.name));
                                    if (field.type == "many2one")
                                    {
                                        if (!type.GetProperties().Any((PropertyInfo a) => a.Name == field.dbName))
                                        {
                                            text = text + "缺少字段" + field.name + "<br>";
                                        }
                                    }
                                    else if (!field.type.Contains("2") && !type.GetProperties().Any((PropertyInfo a) => a.Name == field.name))
                                    {
                                        text = text + "缺少字段" + field.name + "<br>";
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (model != null)
                        {
                            string text8 = text;
                            text = text8 + "<b>模型" + model.name + "</b>检查出错:" + ex.Message + "<br>";
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            text += "</div>";
            return(Content(text, "text/html"));
        }