Beispiel #1
0
        public IActionResult DownForm(string key, string orderBy)
        {
            var model = new DownUrlModel();

            if (!string.IsNullOrEmpty(key))
            {
                var item = FastRead.Query <ApiGatewayDownParam>(a => a.Key.ToLower() == key.ToLower() && a.OrderBy == orderBy.ToInt(1), null, App.DbKey.Api).ToItem <ApiGatewayDownParam>();

                model.Name          = item.Name;
                model.IsBody        = item.IsBody;
                model.IsDecode      = item.IsDecode;
                model.IsResult      = item.IsResult;
                model.Key           = item.Key;
                model.Method        = item.Method;
                model.Name          = item.Name;
                model.Protocol      = item.Protocol;
                model.SoapMethod    = item.SoapMethod;
                model.SoapParamName = item.SoapParamName;
                model.SourceParam   = item.SourceParam;
                model.Url           = item.Url;
                model.WaitHour      = item.WaitHour;

                if (model.Key == null)
                {
                    model.IsResult = 1;
                    model.IsDecode = 1;
                    model.IsBody   = 0;
                }
            }

            return(PartialView("OptionLeaf", model));
        }
        public IActionResult UserOption(UserModel item)
        {
            var isSuccess = false;
            var model     = new ApiGatewayUser();

            model.AppKey    = item.AppKey;
            model.AppSecret = Guid.NewGuid().ToString().Substring(0, 31);
            model.Power     = item.Power;
            model.Ip        = item.Ip;

            using (var db = new DataContext(App.DbKey.Api))
            {
                if (FastRead.Query <ApiGatewayUser>(a => a.AppKey == model.AppKey).ToCount(db) > 0)
                {
                    isSuccess = db.Update <ApiGatewayUser>(model, a => a.AppKey.ToLower() == model.AppKey.ToLower(), a => new { a.AppKey, a.Ip, a.Power }).writeReturn.IsSuccess;
                }
                else
                {
                    isSuccess = db.Add(model).writeReturn.IsSuccess;
                }
            }

            if (isSuccess)
            {
                return(Json(new { success = isSuccess, msg = "操作成功" }));
            }
            else
            {
                return(Json(new { success = isSuccess, msg = "操作失败" }));
            }
        }
Beispiel #3
0
        /// <summary>
        /// foreach数据
        /// </summary>
        /// <param name="name"></param>
        /// <param name="db"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static List <Dictionary <string, object> > MapForEach(List <Dictionary <string, object> > data, string name, DataContext db, string key, ConfigModel config, int i = 1)
        {
            var result  = new List <Dictionary <string, object> >();
            var param   = new List <DbParameter>();
            var dicName = DbCache.Get(config.CacheType, string.Format("{0}.foreach.name.{1}", name.ToLower(), i));
            var field   = DbCache.Get(config.CacheType, string.Format("{0}.foreach.field.{1}", name.ToLower(), i));
            var sql     = DbCache.Get(config.CacheType, string.Format("{0}.foreach.sql.{1}", name.ToLower(), i));

            data.ForEach(a => {
                param.Clear();
                if (field.IndexOf(',') > 0)
                {
                    foreach (var split in field.Split(','))
                    {
                        var tempParam           = DbProviderFactories.GetFactory(config).CreateParameter();
                        tempParam.ParameterName = split;
                        tempParam.Value         = a.GetValue(split);
                        param.Add(tempParam);
                    }
                }
                else
                {
                    var tempParam           = DbProviderFactories.GetFactory(config).CreateParameter();
                    tempParam.ParameterName = field;
                    tempParam.Value         = a.GetValue(field);
                    param.Add(tempParam);
                }

                a.Add(dicName, FastRead.ExecuteSql(sql, param.ToArray(), db, key));
                result.Add(a);
            });

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 获取token
        /// </summary>
        /// <param name="item"></param>
        /// <param name="context"></param>
        private static Task Token(HttpContext context, DataContext db, string urlParam)
        {
            var dic       = new Dictionary <string, object>();
            var AppKey    = GetUrlParamKey(urlParam, "AppKey");
            var AppSecret = GetUrlParamKey(urlParam, "AppSecret");

            if (FastRead.Query <ApiGatewayUser>(a => a.AppKey.ToLower() == AppKey.ToLower() && a.AppSecret.ToLower() == AppSecret.ToLower()).ToCount(db) <= 0)
            {
                context.Response.StatusCode = 200;
                dic.Add("success", false);
                dic.Add("result", "AppKey和AppSecret参数不存在");
                return(context.Response.WriteAsync(JsonConvert.SerializeObject(dic).ToString(), Encoding.UTF8));
            }
            else
            {
                var info = FastRead.Query <ApiGatewayUser>(a => a.AppKey.ToLower() == AppKey.ToLower() && a.AppSecret.ToLower() == AppSecret.ToLower()).ToItem <ApiGatewayUser>(db);
                info.Ip            = GetClientIp(context);
                info.AccessExpires = DateTime.Now.AddHours(24).AddHours(8);
                info.AccessToken   = BaseSymmetric.Generate(string.Format("{0}_{1}_{2}", info.AppKey, info.AppSecret, info.AccessExpires)).ToLower();

                //修改信息
                FastWrite.Update <ApiGatewayUser>(info,
                                                  a => a.AppKey.ToLower() == AppKey.ToLower() && a.AppSecret.ToLower() == AppSecret.ToLower()
                                                  , a => new { a.AccessExpires, a.Ip, a.AccessToken }, db);

                dic.Add("success", true);
                dic.Add("AccessToken", info.AccessToken);
                dic.Add("AccessExpires", info.AccessExpires);

                context.Response.StatusCode = 200;
                return(context.Response.WriteAsync(JsonConvert.SerializeObject(dic).ToString(), Encoding.UTF8));
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            dbConn = BaseLink.GetConnStr(dbType, txtUserName, txtPwd, txtHostName, txtPort, txtServerName);

            if (!BaseLink.CheckLink(dbType, dbConn))
            {
                CodeBox.Show("连接数据库失败!", this);
            }
            else
            {
                var buildLink = BaseLink.ControlsToData(dbType, txtHostName, txtUserName, txtPwd, txtPort, txtServerName, labServerName, true, txtLinkName);
                buildLink.LinkName = buildLink.LinkName == "" ? BaseLink.GetLinkName(buildLink) : buildLink.LinkName;
                buildLink.Id       = Guid.NewGuid().ToString();
                AppCache.SetLink(buildLink);

                if (FastRead.Query <Data_Source>(a => a.LinkName == buildLink.LinkName).ToCount() == 1)
                {
                    FastWrite.Update <Data_Source>(buildLink, a => a.LinkName == buildLink.LinkName,
                                                   a => new { a.Host, a.PassWord, a.Port, a.ServerName, a.Type, a.UserName });
                }
                else
                {
                    FastWrite.Add(buildLink);
                }

                CodeBox.Show("连接数据库成功!", this);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 缓存结果
        /// </summary>
        /// <param name="info"></param>
        /// <param name="item"></param>
        private static void CacheResult(ApiGatewayUrl item, DataContext db, ReturnModel info = null, Dictionary <string, object> dic = null)
        {
            var model = new ApiGatewayCache();

            model.Key     = item.Key.ToLower();
            model.TimeOut = DateTime.Now.AddDays(item.CacheTimeOut.ToStr().ToDouble(0)).AddHours(8);

            if (info != null)
            {
                model.result = BaseJson.ModelToJson(info.msg);
            }

            if (dic != null)
            {
                model.result = BaseJson.ModelToJson(dic);
            }

            if (FastRead.Query <ApiGatewayCache>(a => a.Key.ToUpper() == model.Key.ToUpper()).ToCount(db) <= 0)
            {
                FastWrite.Add(model);
            }
            else
            {
                FastWrite.Update <ApiGatewayCache>(model, a => a.Key.ToUpper() == model.Key.ToUpper(), a => new { a.result, a.TimeOut }, db);
            }
        }
        /// <summary>
        /// 加载用户操作
        /// </summary>
        /// <returns></returns>
        public IActionResult Option(string key)
        {
            var list  = new List <ApiGatewayUrl>();
            var model = new UserModel();

            model.AppKey = key;

            using (var db = new DataContext(App.DbKey.Api))
            {
                list = FastRead.Query <ApiGatewayUrl>(a => a.Key != "", a => new { a.Key, a.Name }).ToList <ApiGatewayUrl>(db);

                if (!string.IsNullOrEmpty(key))
                {
                    var info = FastRead.Query <ApiGatewayUser>(a => a.AppKey.ToLower() == key.ToLower()).ToItem <ApiGatewayUser>();
                    model.Ip    = info.Ip;
                    model.Power = info.Power;
                    if (!string.IsNullOrEmpty(model.Power))
                    {
                        ViewBag.Power = model.Power.Split(",");
                    }
                    else
                    {
                        ViewBag.Power = new string[0];
                    }
                }
                else
                {
                    ViewBag.Power = new string[0];
                }
            }

            ViewBag.List   = list;
            ViewData.Model = model;
            return(View());
        }
Beispiel #8
0
        /// <summary>
        /// 验证token
        /// </summary>
        /// <param name="item"></param>
        /// <param name="context"></param>
        private static bool CheckToken(ApiGatewayUrl item, HttpContext context, DataContext db, string urlParam)
        {
            var dic   = new Dictionary <string, object>();
            var token = GetUrlParamKey(urlParam, "token");

            if (FastRead.Query <ApiGatewayUser>(a => a.AccessToken.ToUpper() == token.ToUpper()).ToCount(db) == 0)
            {
                context.Response.StatusCode = 200;
                dic.Add("success", false);
                dic.Add("result", "token不存在");
                context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                return(false);
            }
            else
            {
                var tokenInfo = FastRead.Query <ApiGatewayUser>(a => a.AccessToken.ToUpper() == token.ToUpper()).ToItem <ApiGatewayUser>(db);
                if (DateTime.Compare(tokenInfo.AccessExpires, DateTime.Now) < 0)
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", "token过期");
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }

                if (tokenInfo.Ip != GetClientIp(context))
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", "token授权ip地址异常");
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }

                if (tokenInfo.Power.IndexOf(',') > 0)
                {
                    foreach (var temp in tokenInfo.Power.Split(','))
                    {
                        if (temp.ToLower() == item.Key.ToLower())
                        {
                            return(true);
                        }
                    }

                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", string.Format("{0}没有权限访问", item.Key));
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }
                else
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", string.Format("{0}没有权限访问", item.Key));
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUserListByUserFilter()
        {
            using (var db = new DataContext(AppEmr.DbConst.EmrDb))
            {
                var list = FastRead.Query <GI_USERINFO>(a => a.ISCANCE != 1).ToDics(db);

                return(Json(new { code = 1, data = list }));
            }
        }
Beispiel #10
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public ActionResult login(string password, string account)
        {
            using (var db = new DataContext(AppEmr.DbConst.EmrDb))
            {
                var info = FastRead.Query <GI_USERINFO>(a => a.USERCODE.ToLower() == account.ToLower()).ToItem <GI_USERINFO>(db);

                if (string.IsNullOrEmpty(info.USERCODE))
                {
                    return(Json(new { code = 1, msg = "登录失败!该用户信息不存在或已被停用。" }));
                }

                if (info.PASSWORD == BaseSymmetric.md5(32, password) || info.PASSWORD == null)
                {
                    var token     = Common.Encrypt.MD5Encrypt(string.Format("{0}{1}", Guid.NewGuid().ToString("D"), DateTime.Now.Ticks));
                    var cache     = RedisCacheManager.CreateInstance();
                    var tokenlist = new List <UserToken>();

                    if (cache.IsSet("tokenlist"))
                    {
                        tokenlist = cache.Get <List <UserToken> >("tokenlist");
                        var usertoken = tokenlist.Find(f => f.UserId == info.USERID);
                        if (usertoken != null)
                        {
                            tokenlist.Remove(usertoken);
                            cache.Remove("tokenlist");
                        }
                    }

                    var _userToken = new UserToken()
                    {
                        UserId      = info.USERID,
                        ORGANID     = info.ORGANID,
                        USERCODE    = info.USERCODE,
                        USERNAME    = info.USERNAME,
                        InpatientID = info.INPATIENTID,
                        UserPhoto   = info.USERPHOTO,
                        Permission  = "",
                        Timeout     = DateTime.Now.AddMinutes(600),
                        Token       = token
                    };
                    if (_userToken.UserPhoto == null || System.IO.File.Exists(Server.MapPath("../../../" + _userToken.UserPhoto)) == false)
                    {
                        _userToken.UserPhoto = "Content/Images/face.png";
                    }
                    tokenlist.Add(_userToken);
                    cache.Update("tokenlist", tokenlist, 600);

                    return(Json(new { code = 0, data = _userToken }));
                }
                else
                {
                    return(Json(new { code = 1, msg = "登录失败!用户名或密码错误" }));
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// 数据源
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="html"></param>
        /// <param name="expression"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static IHtmlContent DropDownListForDataSource <TModel, TProperty>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TProperty> > expression, object htmlAttributes)
        {
            var typeList = new List <SelectListItem>();
            var list     = FastRead.Query <Data_Source>(a => a.Id != "", null, AppEtl.Db).ToList <Data_Source>();

            list.ForEach(a => { typeList.Add(new SelectListItem {
                    Text = string.Format("{0}({1}:{2})", a.LinkName, a.Host, a.Port), Value = a.Id
                }); });

            return(html.DropDownListFor(expression, typeList, htmlAttributes));
        }
Beispiel #12
0
        /// <summary>
        /// 初始化字典数据
        /// </summary>
        private void InitDic()
        {
            var list = FastRead.Query <Data_Dic>(a => a.Id != null).ToList <Data_Dic>();

            list.Add(new Data_Dic());
            Dic.ItemsSource = list;

            var tempList = new List <Data_Dic_Details>();

            tempList.Add(new Data_Dic_Details());
            DicLeaf.ItemsSource = tempList;
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var count = FastRead.Query <ApiGatewayLogin>(a => a.UserName.ToLower() == value.ToStr().ToLower(), null, App.DbKey.Api).ToCount();

            if (count > 0)
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult(ErrorMessage = "用户名不正确"));
            }
        }
Beispiel #14
0
        public void ConfigureServices(IServiceCollection services)
        {
            //注册gbk
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            Encoding encoding = Encoding.GetEncoding("GB2312");

            //http请求
            using (var db = new DataContext("ApiGateway"))
            {
                var list = FastRead.Query <ApiGatewayDownParam>(a => a.Protocol != "",
                                                                a => new { a.Key, a.Url }).ToList <ApiGatewayDownParam>(db);
                foreach (var item in list)
                {
                    services.AddHttpClient(item.Key, client =>
                    {
                        client.BaseAddress = new Uri(item.Url);
                    }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
                    {
                        ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true,
                        AllowAutoRedirect      = false,
                        AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
                    });
                }
            }

            //压缩
            services.AddResponseCompression();

            //注入
            services.AddTransient <IFastApiGatewayDb, FastApiGatewayDb.FastApiGatewayDb>();

            //跨域
            services.AddCors(options =>
            {
                options.AddPolicy("any", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); });
            });

            //oracle
            FastMap.InstanceProperties("FastApiGatewayDb.DataModel.Oracle", "FastApiGatewayDb.dll");
            FastMap.InstanceTable("FastApiGatewayDb.DataModel.Oracle", "FastApiGatewayDb.dll");

            //MySql
            //FastMap.InstanceProperties("FastApiGatewayDb.DataModel.MySql", "FastApiGatewayDb.dll");
            //FastMap.InstanceTable("FastApiGatewayDb.DataModel.MySql", "FastApiGatewayDb.dll");

            //SqlServer
            //FastMap.InstanceProperties("FastApiGatewayDb.DataModel.SqlServer", "FastApiGatewayDb.dll");
            //FastMap.InstanceTable("FastApiGatewayDb.DataModel.SqlServer", "FastApiGatewayDb.dll");
        }
Beispiel #15
0
        /// <summary>
        /// maq 执行返回 List<Dictionary<string, object>>
        /// </summary>
        public List <Dictionary <string, object> > Query(string name, DbParameter[] param, DataContext db = null, string key = null, bool isOutSql = false)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);
                isOutSql = isOutSql ? isOutSql : IsMapLog(name);

                BaseAop.AopMapBefore(name, sql, param, config, AopType.Map_List_Dic);

                var result = FastRead.ExecuteSql(sql, param, db, key, isOutSql, false);

                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result = MapXml.MapForEach(result, name, tempDb, key, config, i);
                            }
                        }
                    }
                    else
                    {
                        result = MapXml.MapForEach(result, name, db, key, config);
                    }
                }

                BaseAop.AopMapAfter(name, sql, param, config, AopType.Map_List_Dic, result);
                return(result);
            }
            else
            {
                BaseAop.AopMapBefore(name, "", param, config, AopType.Map_List_Dic);
                var data = new List <Dictionary <string, object> >();
                BaseAop.AopMapAfter(name, "", param, config, AopType.Map_List_Dic, data);
                return(data);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 选中数据源
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dic_Selected(object sender, RoutedEventArgs e)
        {
            var item = Dic.SelectedItem as Data_Dic;

            if (item != null && !string.IsNullOrEmpty(item.Id))
            {
                var list = FastRead.Query <Data_Dic_Details>(a => a.DicId == item.Id).ToList <Data_Dic_Details>();
                list.Add(new Data_Dic_Details());
                DicLeaf.ItemsSource = list;
            }
            else
            {
                var list = new List <Data_Dic_Details>();
                list.Add(new Data_Dic_Details());
                DicLeaf.ItemsSource = list;
            }
        }
Beispiel #17
0
        /// <summary>
        /// 字典
        /// </summary>
        /// <param name="html"></param>
        /// <param name="name"></param>
        /// <param name="htmlAttributes"></param>
        /// <param name="isAll"></param>
        /// <returns></returns>
        public static IHtmlContent DropDownListForDic(this IHtmlHelper html, string name, object htmlAttributes, bool isAll = false)
        {
            var typeList = new List <SelectListItem>();
            var list     = FastRead.Query <Data_Dic>(a => a.Id != "", null, AppEtl.Db).ToList <Data_Dic>();

            if (isAll)
            {
                typeList.Add(new SelectListItem {
                    Text = "全部", Value = ""
                });
            }

            list.ForEach(a => { typeList.Add(new SelectListItem {
                    Text = a.Name, Value = a.Id
                }); });
            return(html.DropDownList(name, typeList, htmlAttributes));
        }
        /// <summary>
        /// maq 执行返回 List<Dictionary<string, object>>
        /// </summary>
        public List <Dictionary <string, object> > Query(string name, DbParameter[] param, DataContext db = null, string key = null)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);

                var result = FastRead.ExecuteSql(sql, param, db, key);

                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result = MapXml.MapForEach(result, name, tempDb, key, config, i);
                            }
                        }
                    }
                    else
                    {
                        result = MapXml.MapForEach(result, name, db, key, config);
                    }
                }

                return(result);
            }
            else
            {
                return(new List <Dictionary <string, object> >());
            }
        }
Beispiel #19
0
        /// <summary>
        /// 初始化取数据长连接
        /// </summary>
        /// <returns></returns>
        public static List <Dictionary <string, object> > InitColLink(List <Data_Business_Details> list, DataContext db)
        {
            var result = new List <Dictionary <string, object> >();

            foreach (var item in list)
            {
                var link = FastRead.Query <Data_Source>(a => a.Id == item.DataSourceId).ToItem <Data_Source>(db);

                if (link.Type.ToLower() == FastApp.DataDbType.SqlServer.ToLower())
                {
                    var dic  = new Dictionary <string, object>();
                    var conn = DbProviderFactories.GetFactory(FastApp.Provider.SqlServer).CreateConnection();
                    conn.ConnectionString = GetConnStr(link);
                    conn.Open();
                    dic.Add("conn", conn);
                    dic.Add("type", FastApp.DataDbType.SqlServer.ToLower());
                    result.Add(dic);
                }
                if (link.Type.ToLower() == FastApp.DataDbType.MySql.ToLower())
                {
                    var dic  = new Dictionary <string, object>();
                    var conn = DbProviderFactories.GetFactory(FastApp.Provider.MySql).CreateConnection();
                    conn.ConnectionString = GetConnStr(link);
                    conn.Open();
                    dic.Add("conn", conn);
                    dic.Add("type", FastApp.DataDbType.MySql.ToLower());
                    result.Add(dic);
                }

                if (link.Type.ToLower() == FastApp.DataDbType.Oracle.ToLower())
                {
                    var dic  = new Dictionary <string, object>();
                    var conn = DbProviderFactories.GetFactory(FastApp.Provider.Oracle).CreateConnection();
                    conn.ConnectionString = GetConnStr(link);
                    conn.Open();
                    dic.Add("conn", conn);
                    dic.Add("type", FastApp.DataDbType.Oracle.ToLower());
                    result.Add(dic);
                }
            }
            return(result);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Del_Click(object sender, RoutedEventArgs e)
        {
            var item = dbTypeLink.SelectedItem as Data_Source;

            if (item != null)
            {
                if (FastRead.Query <Data_Business_Details>(a => a.DataSourceId == item.Id).ToCount() == 0)
                {
                    FastWrite.Delete <Data_Source>(a => a.LinkName == item.LinkName);
                    AppCache.RemoveLink();
                    dbTypeLink.ItemsSource = AppCache.GetAllLink;
                    InitLinkInfo();
                    CodeBox.Show("删除成功", this);
                }
                else
                {
                    InitLinkInfo();
                    CodeBox.Show("删除失败数据源在使用中", this);
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// 加载接口
        /// </summary>
        /// <returns></returns>
        public IActionResult Option(string key)
        {
            var model = new UrlModel();

            if (!string.IsNullOrEmpty(key))
            {
                var item = FastRead.Query <ApiGatewayUrl>(a => a.Key.ToLower() == key.ToLower(), null, App.DbKey.Api).ToItem <ApiGatewayUrl>();
                model.IsAnonymous  = item.IsAnonymous;
                model.CacheTimeOut = item.CacheTimeOut;
                model.IsCache      = item.IsCache;
                model.IsDbLog      = item.IsDbLog;
                model.IsGetToken   = item.IsGetToken;
                model.IsTxtLog     = item.IsTxtLog;
                model.Key          = item.Key;
                model.Schema       = item.Schema;
                model.Name         = item.Name;
            }

            ViewData.Model = model;
            return(View());
        }
Beispiel #22
0
        /// <summary>
        /// 字典
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="html"></param>
        /// <param name="expression"></param>
        /// <param name="htmlAttributes"></param>
        /// <param name="selectValue"></param>
        /// <returns></returns>
        public static IHtmlContent DropDownListForDic <TModel, TProperty>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TProperty> > expression, object htmlAttributes, object selectValue)
        {
            var typeList = new List <SelectListItem>();
            var list     = FastRead.Query <Data_Dic>(a => a.Id != "", null, AppEtl.Db).ToList <Data_Dic>();

            list.ForEach(a => {
                if (selectValue.ToStr() == a.Id)
                {
                    typeList.Add(new SelectListItem {
                        Text = a.Name, Value = a.Id, Selected = true
                    });
                }
                else
                {
                    typeList.Add(new SelectListItem {
                        Text = a.Name, Value = a.Id
                    });
                }
            });

            return(html.DropDownListFor(expression, typeList, htmlAttributes));
        }
Beispiel #23
0
        public IActionResult DownUrlOption(DownUrlModel item)
        {
            using (var db = new DataContext(App.DbKey.Api))
            {
                var success = true;
                var model   = new ApiGatewayDownParam();
                model.Key           = item.Key;
                model.IsBody        = (int)item.IsBody;
                model.IsDecode      = (int)item.IsDecode;
                model.IsResult      = (int)item.IsResult;
                model.Method        = item.Method;
                model.Name          = item.Name;
                model.OrderBy       = item.OrderBy;
                model.Protocol      = item.Protocol;
                model.SoapMethod    = item.SoapMethod;
                model.SoapParamName = item.SoapParamName;
                model.SourceParam   = item.SourceParam;
                model.Url           = item.Url;
                model.WaitHour      = item.WaitHour;

                if (FastRead.Query <ApiGatewayDownParam>(a => a.Key.ToLower() == item.Key.ToLower() && a.OrderBy == item.OrderBy).ToCount(db) > 0)
                {
                    success = db.Update <ApiGatewayDownParam>(model, a => a.Key.ToLower() == item.Key.ToLower() && a.OrderBy == item.OrderBy).writeReturn.IsSuccess;
                }
                else
                {
                    success = db.Add(model).writeReturn.IsSuccess;
                }

                if (success)
                {
                    return(Json(new { success = true, msg = "操作成功" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "操作失败" }));
                }
            }
        }
Beispiel #24
0
        public IActionResult Login(LoginModel item)
        {
            var isSuccess = false;

            using (var db = new DataContext(App.DbKey.Api))
            {
                var info = FastRead.Query <ApiGatewayLogin>(a => a.UserName.ToLower() == item.Code.ToLower()).ToDic(db);

                isSuccess = BaseSymmetric.Generate(item.Pwd).ToLower() == info.GetValue("UserPwd").ToStr().ToLower();

                info.Add("ip", App.Ip.Get(HttpContext));

                if (isSuccess)
                {
                    BaseCache.Set <Dictionary <string, object> >(App.Cache.UserInfo, info);
                    return(Json(new { success = isSuccess, url = "/home/index" }));
                }
                else
                {
                    return(Json(new { success = isSuccess, msg = "密码不正确" }));
                }
            }
        }
Beispiel #25
0
        public IActionResult UrlOption(UrlModel item)
        {
            using (var db = new DataContext(App.DbKey.Api))
            {
                var success = true;
                var model   = new ApiGatewayUrl();

                model.CacheTimeOut = item.CacheTimeOut;
                model.IsAnonymous  = item.IsAnonymous;
                model.IsCache      = item.IsCache;
                model.IsDbLog      = item.IsDbLog;
                model.IsGetToken   = item.IsGetToken;
                model.IsTxtLog     = item.IsTxtLog;
                model.Key          = item.Key;
                model.Name         = item.Name;
                model.Schema       = item.Schema;

                if (FastRead.Query <ApiGatewayUrl>(a => a.Key.ToLower() == item.Key.ToLower()).ToCount(db) > 0)
                {
                    success = db.Update <ApiGatewayUrl>(model, a => a.Key.ToLower() == item.Key.ToLower()).writeReturn.IsSuccess;
                }
                else
                {
                    success = db.Add(model).writeReturn.IsSuccess;
                }

                if (success)
                {
                    return(Json(new { success = true, msg = "操作成功" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "操作失败" }));
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// 绑定datagrid中combobox
        /// </summary>
        private void BindComboBox(object selectedItem, DataGrid grid, bool isDataSource = false, bool isTable = false)
        {
            var item = selectedItem as Data_Business_Details ?? new Data_Business_Details();

            if (item == null)
            {
                return;
            }

            //数据源
            var dataBox = Common.GetTemplateColumn <ComboBox>(grid, 1, "DataSourceBox", selectedItem);

            if (dataBox != null && dataBox.ItemsSource == null)
            {
                var itemSource = AppCache.GetAllLink;
                dataBox.ItemsSource  = itemSource;
                dataBox.SelectedItem = itemSource.Find(a => a.Id == item.DataSourceId);
            }

            Common.UpdateWindow();

            //表名
            var tableBox = Common.GetTemplateColumn <ComboBox>(grid, 2, "TabelBox", selectedItem);

            if (isDataSource && tableBox != null)
            {
                tableBox.ItemsSource = null;
            }

            if (tableBox != null && tableBox.ItemsSource == null)
            {
                if (dataBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetTableList(dataBox.SelectedItem as Data_Source) ?? new List <Cache_Table>();

                    if (itemSource.Count == 0)
                    {
                        itemSource.Add(new Cache_Table {
                            Name = "请加载数据源"
                        });
                    }

                    tableBox.ItemsSource  = itemSource;
                    tableBox.SelectedItem = itemSource.Find(a => a.Name == item.TableName);
                }
            }

            Common.UpdateWindow();

            //列名
            var columnBox = Common.GetTemplateColumn <ComboBox>(grid, 3, "ColumnBox", selectedItem);

            if (isTable && columnBox != null)
            {
                columnBox.ItemsSource = null;
            }

            if (columnBox != null && columnBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    columnBox.ItemsSource  = itemSource;
                    columnBox.SelectedItem = itemSource.Find(a => a.Name == item.ColumnName);
                }
            }

            //主键
            var keyBox = Common.GetTemplateColumn <ComboBox>(grid, 4, "KeyBox", selectedItem);

            if (isTable && keyBox != null)
            {
                keyBox.ItemsSource = null;
            }

            if (keyBox != null && keyBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    keyBox.ItemsSource  = itemSource;
                    keyBox.SelectedItem = itemSource.Find(a => a.Name == item.Key);
                }
            }

            //排序
            var orderByBox = Common.GetTemplateColumn <ComboBox>(grid, 5, "OrderByBox", selectedItem);

            if (isTable && orderByBox != null)
            {
                orderByBox.ItemsSource = null;
            }

            if (orderByBox != null && orderByBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    orderByBox.ItemsSource  = itemSource;
                    orderByBox.SelectedItem = itemSource.Find(a => a.Name == item.OrderBy);
                }
            }

            //字典
            var dicBox = Common.GetTemplateColumn <ComboBox>(grid, 6, "DicBox", selectedItem);

            if (isTable && dicBox != null)
            {
                dicBox.ItemsSource = null;
            }

            if (dicBox != null && dicBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var tempSource = FastRead.Query <Data_Dic>(a => a.Id != null).ToList <Data_Dic>();
                    dicBox.ItemsSource  = tempSource;
                    dicBox.SelectedItem = tempSource.Find(a => a.Id == item.Dic);
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="downparam">下游</param>
        /// <param name="param">请求参数</param>
        /// <param name="content">请求参数body</param>
        /// <returns></returns>
        private static ReturnModel GetReuslt(ApiGatewayDownParam downparam, string param, string key, int isTextLog, int isDbLog, DataContext db, HttpContext context, string ActionId, int OrderBy, IHttpClientFactory client)
        {
            var info = FastRead.Query <ApiGatewayWait>(a => a.Key.ToLower() == key.ToLower() && a.Url.ToLower() == downparam.Url.ToLower()).ToItem <ApiGatewayWait>(db) ?? new ApiGatewayWait();

            if (info.Key.ToStr().ToLower() == key.ToLower() && DateTime.Compare(info.NextAction, DateTime.Now) > 0)
            {
                //return time out
                var dic = new Dictionary <string, object>();
                dic.Add("success", false);
                dic.Add("result", "等待恢复");
                return(new ReturnModel {
                    msg = BaseJson.ModelToJson(dic), status = 408
                });
            }
            else
            {
                var result    = new ReturnModel();
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                if (downparam.Protocol.ToLower() == "soap")
                {
                    result = BaseUrl.SoapUrl(downparam.Url, downparam.SoapParamName, downparam.SoapMethod, param, client, key, downparam.SoapNamespace);
                }
                else if (downparam.Protocol.ToLower() == "http")
                {
                    //http
                    if (downparam.Method.ToStr().ToLower() == "post")
                    {
                        if (downparam.IsBody == 1)
                        {
                            result = BaseUrl.PostContent(downparam.Url, param, key, client);
                        }
                        else
                        {
                            result = BaseUrl.PostUrl(downparam.Url, param, key, client);
                        }
                    }
                    else if (downparam.Method.ToStr().ToLower() == "get")
                    {
                        result = BaseUrl.GetUrl(downparam.Url, param, key, client);
                    }
                }
                //else if (downparam.Protocol.ToLower() == "mq")
                //    //mq
                //    result = BaseUrl.RabbitUrl(downparam.QueueName, param);
                else
                {
                    result.status = 408;
                }

                if (result.status == 408)
                {
                    //time out
                    var wait = new ApiGatewayWait();
                    wait.Key        = key;
                    wait.Url        = downparam.Url;
                    wait.WaitHour   = downparam.WaitHour.ToInt(0);
                    wait.ErrorMsg   = result.msg;
                    wait.NextAction = DateTime.Now.AddHours(wait.WaitHour.ToStr().ToDouble(0));

                    FastWrite.Add(wait, db);
                }
                else if (info.Key.ToStr().ToLower() == key.ToLower())
                {
                    FastWrite.Delete <ApiGatewayWait>(a => a.Key.ToLower() == key.ToLower(), db);
                }

                stopwatch.Stop();

                var logInfo = new ApiGatewayLog();
                logInfo.ActionId     = ActionId;
                logInfo.OrderBy      = OrderBy;
                logInfo.Key          = key;
                logInfo.ActionTime   = DateTime.Now;
                logInfo.Url          = downparam.Url;
                logInfo.Protocol     = downparam.Protocol;
                logInfo.Success      = result.status == 200 ? 1 : 0;
                logInfo.Result       = result.msg;
                logInfo.Milliseconds = stopwatch.Elapsed.TotalMilliseconds;
                logInfo.ActionIp     = GetClientIp(context);
                logInfo.ActionParam  = param;

                if (isDbLog == 1)
                {
                    FastWrite.Add(logInfo, null, DbApi);
                }

                if (isTextLog == 1)
                {
                    BaseLog.SaveLog(BaseJson.ModelToJson(logInfo), logInfo.Key);
                }

                return(result);
            }
        }
Beispiel #28
0
        public Task ContentAsync(HttpContext context, IHttpClientFactory client)
        {
            var urlParam       = GetUrlParam(context);
            var urlParamDecode = HttpUtility.UrlDecode(urlParam);

            using (var db = new DataContext(DbApi))
            {
                context.Response.ContentType = "application/Json";
                var key = context.Request.Path.Value.ToStr().Replace("/", "");

                if (FastRead.Query <ApiGatewayUrl>(a => a.Key.ToUpper() == key.ToUpper()).ToCount(db) <= 0 || string.IsNullOrEmpty(key))
                {
                    var dic = new Dictionary <string, object>();
                    dic.Add("success", false);
                    dic.Add("result", string.Format("请求地址{0}无效", key));
                    context.Response.StatusCode = 404;
                    return(context.Response.WriteAsync(JsonConvert.SerializeObject(dic).ToString(), Encoding.UTF8));
                }
                else
                {
                    var item      = FastRead.Query <ApiGatewayUrl>(a => a.Key.ToUpper() == key.ToUpper()).ToItem <ApiGatewayUrl>(db) ?? new ApiGatewayUrl();
                    var downParam = FastRead.Query <ApiGatewayDownParam>(a => a.Key.ToUpper() == key.ToUpper()).OrderBy <ApiGatewayDownParam>(a => new { a.OrderBy }, false).ToList <ApiGatewayDownParam>(db);

                    //获取token
                    if (item.IsGetToken == 1)
                    {
                        return(Token(context, db, urlParam));
                    }
                    else
                    {
                        //是否匿名访问
                        if (item.IsAnonymous == 0)
                        {
                            if (!CheckToken(item, context, db, urlParam))
                            {
                                return(Task.CompletedTask);
                            }
                        }

                        //结果是否缓存
                        if (item.IsCache == 1)
                        {
                            var resultInfo = FastRead.Query <ApiGatewayCache>(a => a.Key.ToUpper() == key).ToItem <ApiGatewayCache>(db);
                            if (DateTime.Compare(resultInfo.TimeOut, DateTime.Now) > 0)
                            {
                                context.Response.StatusCode = 200;
                                return(context.Response.WriteAsync(resultInfo.result, Encoding.UTF8));
                            }
                            else
                            {
                                if (item.Schema.ToStr().ToLower() == "polling") //polling 轮循请求
                                {
                                    return(Polling(item, context, db, downParam, urlParamDecode, urlParam, client));
                                }
                                else if (item.Schema.ToStr().ToLower() == "composite") //composite 合并请求
                                {
                                    return(Composite(item, context, db, downParam, urlParamDecode, urlParam, client));
                                }
                                else
                                {
                                    return(Normal(item, context, db, downParam, urlParamDecode, urlParam, client));
                                }
                            }
                        }
                        else
                        {
                            if (item.Schema.ToStr().ToLower() == "polling") //polling 轮循请求
                            {
                                return(Polling(item, context, db, downParam, urlParamDecode, urlParam, client));
                            }
                            else if (item.Schema.ToStr().ToLower() == "composite") //composite 合并请求
                            {
                                return(Composite(item, context, db, downParam, urlParamDecode, urlParam, client));
                            }
                            else
                            {
                                return(Normal(item, context, db, downParam, urlParamDecode, urlParam, client));
                            }
                        }
                    }
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// map xml 存数据库
        /// </summary>
        /// <param name="dbKey"></param>
        /// <param name="key"></param>
        /// <param name="info"></param>
        public static bool SaveXml(string dbKey, string key, FileInfo info, ConfigModel config, DataContext db)
        {
            if (config.IsMapSave)
            {
                //加密
                var enContent = File.ReadAllText(info.FullName);

                //明文
                var deContent = "";

                if (config.IsEncrypt)
                {
                    deContent = BaseSymmetric.DecodeGB2312(deContent);
                    if (deContent == "")
                    {
                        deContent = enContent;
                    }
                }
                else
                {
                    deContent = enContent;
                }

                if (config.DbType == DataDbType.MySql)
                {
                    var model = new DataModel.MySql.Data_MapFile();
                    model.MapId = key;
                    var query = FastRead.Query <DataModel.MySql.Data_MapFile>(a => a.MapId == key, null, dbKey);

                    if (query.ToCount() == 0)
                    {
                        model.FileName      = info.Name;
                        model.FilePath      = info.FullName;
                        model.LastTime      = info.LastWriteTime;
                        model.EnFileContent = enContent;
                        model.DeFileContent = deContent;
                        return(db.Add(model).writeReturn.IsSuccess);
                    }
                    else
                    {
                        return(db.Update <DataModel.MySql.Data_MapFile>(model, a => a.MapId == model.MapId, a => new { a.LastTime, a.EnFileContent, a.DeFileContent }).writeReturn.IsSuccess);
                    }
                }

                if (config.DbType == DataDbType.Oracle)
                {
                    var model = new DataModel.Oracle.Data_MapFile();
                    model.MapId = key;
                    var query = FastRead.Query <DataModel.Oracle.Data_MapFile>(a => a.MapId == key, null, dbKey);

                    if (query.ToCount() == 0)
                    {
                        model.FileName      = info.Name;
                        model.FilePath      = info.FullName;
                        model.LastTime      = info.LastWriteTime;
                        model.EnFileContent = enContent;
                        model.DeFileContent = deContent;
                        return(db.Add(model).writeReturn.IsSuccess);
                    }
                    else
                    {
                        return(db.Update <DataModel.Oracle.Data_MapFile>(model, a => a.MapId == model.MapId, a => new { a.LastTime, a.EnFileContent, a.DeFileContent }).writeReturn.IsSuccess);
                    }
                }

                if (config.DbType == DataDbType.SqlServer)
                {
                    var model = new DataModel.SqlServer.Data_MapFile();
                    model.MapId = key;
                    var query = FastRead.Query <DataModel.SqlServer.Data_MapFile>(a => a.MapId == key, null, dbKey);

                    if (query.ToCount() == 0)
                    {
                        model.FileName      = info.Name;
                        model.FilePath      = info.FullName;
                        model.LastTime      = info.LastWriteTime;
                        model.EnFileContent = enContent;
                        model.DeFileContent = deContent;
                        return(db.Add(model).writeReturn.IsSuccess);
                    }
                    else
                    {
                        return(db.Update <DataModel.SqlServer.Data_MapFile>(model, a => a.MapId == model.MapId, a => new { a.LastTime, a.EnFileContent, a.DeFileContent }).writeReturn.IsSuccess);
                    }
                }
            }

            return(true);
        }
Beispiel #30
0
        /// <summary>
        /// 定时任务同步产品数据
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void SynData(object source, ElapsedEventArgs e)
        {
            try
            {
                //防止重复执行
                lock (thisLock)
                {
                    using (var db = new DataContext())
                    {
                        BaseLog.SaveLog("开始抽取", "FastEtlService");

                        //不允许停止服务
                        this.CanStop = false;

                        var list = FastRead.Query <Data_Business>(a => a.Id != null).ToList <Data_Business>(db);

                        foreach (var item in list)
                        {
                            if (DataSchema.IsExistsTable(db, item.TableName) && item.UpdateTime == DateTime.Now.Hour && item.LastUpdateTime.Day + item.UpdateDay >= DateTime.Now.Day)
                            {
                                Parallel.Invoke(() =>
                                {
                                    var leaf = FastRead.Query <Data_Business_Details>(a => a.Id == item.Id).ToList <Data_Business_Details>(db);

                                    if (leaf.Count > 0)
                                    {
                                        var isAdd      = true;
                                        var dt         = DataSchema.GetTable(db, item.TableName);
                                        var columnName = dt.Columns[3].ColumnName.ToLower();

                                        if (leaf.Exists(a => a.FieldName.ToLower() == columnName))
                                        {
                                            DataSchema.ExpireData(db, item);

                                            //第一列
                                            var link     = DataSchema.InitColLink(leaf, db);
                                            var tempLeaf = leaf.Find(a => a.FieldName.ToLower() == columnName);
                                            var pageInfo = DataSchema.GetTableCount(link[0], tempLeaf, item);

                                            for (var i = 1; i <= pageInfo.pageCount; i++)
                                            {
                                                var log           = new Data_Log();
                                                log.Id            = Guid.NewGuid().ToStr();
                                                log.TableName     = string.Format("{0}_page_{1}", item.TableName, i);
                                                log.BeginDateTime = DateTime.Now;

                                                pageInfo.pageId = i;
                                                var pageData    = DataSchema.GetFirstColumnData(link[0], tempLeaf, item, pageInfo);

                                                //遍历填充table
                                                for (var row = 0; row < pageData.list.Count; row++)
                                                {
                                                    var dtRow         = dt.NewRow();
                                                    dtRow["Id"]       = Guid.NewGuid().ToString();
                                                    dtRow["AddTime"]  = DateTime.Now;
                                                    dtRow["Key"]      = pageData.list[row].GetValue("key");
                                                    dtRow[columnName] = pageData.list[row].GetValue("data");

                                                    //字典对照
                                                    if (!string.IsNullOrEmpty(tempLeaf.Dic))
                                                    {
                                                        dtRow[columnName] = FastRead.Query <Data_Dic_Details>(a => a.Value.ToLower() == dtRow[columnName].ToStr().ToLower() && a.DicId == tempLeaf.Dic, a => new { a.ContrastValue }).ToDic(db).GetValue("ContrastValue");
                                                    }

                                                    //数据策略
                                                    isAdd = DataSchema.DataPolicy(db, item, dtRow["Key"], columnName, dtRow[columnName]);

                                                    for (var col = 3; col < dt.Columns.Count; col++)
                                                    {
                                                        columnName = dt.Columns[col].ColumnName.ToLower();
                                                        if (leaf.Exists(a => a.FieldName.ToLower() == columnName))
                                                        {
                                                            tempLeaf          = leaf.Find(a => a.FieldName.ToLower() == columnName);
                                                            dtRow[columnName] = DataSchema.GetColumnData(link[col - 3], tempLeaf, dtRow["Key"]);

                                                            //字典对照
                                                            if (!string.IsNullOrEmpty(tempLeaf.Dic))
                                                            {
                                                                dtRow[columnName] = FastRead.Query <Data_Dic_Details>(a => a.Value.ToLower() == dtRow[columnName].ToStr().ToLower() && a.DicId == tempLeaf.Dic, a => new { a.ContrastValue }).ToDic(db).GetValue("ContrastValue");
                                                            }

                                                            //数据策略
                                                            if (item.Policy == "2")
                                                            {
                                                                isAdd = DataSchema.DataPolicy(db, item, dtRow["Key"], columnName, dtRow[columnName]);
                                                            }
                                                        }
                                                    }

                                                    if (isAdd)
                                                    {
                                                        dt.Rows.Add(dtRow);
                                                    }
                                                }

                                                if (dt.Rows.Count > 0)
                                                {
                                                    DataSchema.AddList(db, dt, ref log);
                                                }
                                                db.Add(log);
                                                dt.Clear();
                                            }

                                            DataSchema.CloseLink(link);
                                            item.LastUpdateTime = DateTime.Now;
                                            FastWrite.Update <Data_Business>(item, a => a.Id == item.Id, a => new { a.LastUpdateTime }, db);
                                        }
                                    }
                                });
                            }
                        }

                        //允许停止服务
                        this.CanStop = true;

                        BaseLog.SaveLog("结束抽取", "FastEtlService");
                    }
                }
            }
            catch (Exception ex)
            {
                BaseLog.SaveLog(ex.ToString(), "FastEtlServiceError");
            }
        }