示例#1
0
        public AConFlowStep AddMathodStep(bool isBuildIn, string comguidi, string dllName, string typeName, string methodInfoName,
                                          string returnValueName = null, List <string> Inparas = null)
        {
            var methodInfo = APP.GetMethodFromConfig(isBuildIn, dllName, typeName, methodInfoName);

            return(AddMathodStep(comguidi, methodInfo, returnValueName, Inparas));
        }
示例#2
0
        public Guid InsertApp(AppModel App)
        {
            Guid id = Guid.NewGuid();

            if (App == null)
            {
                throw new NullReferenceException();
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                APP _new = new APP
                {
                    ID            = id,
                    ENTERPRISE    = data.ENTERPRISE.Where(f => f.ID == App.Enterprise.Id).FirstOrDefault(),
                    NAME          = App.Name,
                    DESCRIPTION   = App.Description,
                    VERSION       = App.Version,
                    URL           = App.URL,
                    CREATION_DATE = DateTime.Now,
                    UPDATE_DATE   = DateTime.Now
                };

                data.APP.AddObject(_new);
                data.SaveChanges();
            }

            return(id);
        }
示例#3
0
        public void UpdateApp(AppModel App)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                APP current = data.APP.Where(x => App.Id == x.ID).SingleOrDefault();
                if (current != null)
                {
                    try
                    {
                        current.NAME          = App.Name;
                        current.ENTERPRISE    = data.ENTERPRISE.Where(f => f.ID == App.Enterprise.Id).FirstOrDefault();
                        current.DESCRIPTION   = App.Description;
                        current.VERSION       = App.Version;
                        current.URL           = App.URL;
                        current.CREATION_DATE = App.CreationDate;
                        current.UPDATE_DATE   = DateTime.Now;

                        data.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        if (e.InnerException != null)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                        throw;
                    }
                }
            }
        }
示例#4
0
        public static IServiceProvider InitAutofac(this IServiceCollection services, IEnumerable <Assembly> modulesAssembly)
        {
            if (s_isInit)
            {
                return(autofacServiceProvider);
            }
            //services.AddAutofac();
            //APP.Resover.RegistAutofacModule();

            APP.RegisterAutofacModuleTypes();
            //APP.RegisterAutofacAssemblies(modulesAssembly);



            ///////////using /////////////////////
            using (var scope = APP.Resover.Resovertot.BeginLifetimeScope())
            {
                var memoryCache = scope.Resolve <IMemoryCache>();
                APP.RuntimeCache       = new RuntimeCache(memoryCache);
                autofacServiceProvider = scope.Resolve <IServiceProvider>();
                //var systemResover = new AutofacResover() { Container = container };
                //APP.Builder.RegisterInstance<IResover>(systemResover);
            }


            //  APP.Container = systemResover;
            return(autofacServiceProvider);
        }
示例#5
0
        public async Task <int> UpdateCache()
        {
            APP.Dlls.Clear();
            APP.Types.Clear();
            APP.MethodInfos.Clear();
            APP.RuntimeCodes.Clear();
            APP.Composeentitys.Clear();
            APP.DynamicReferenceDlls.Clear();
            APP.AConFlowSteps.Clear();
            APP.ComposeTemplates.Clear();
            APP.ClearCache();
            //var razorlist = m_codeService.GetSimpleCode<SystemHtml>(null);
            //foreach(var ss in razorlist)
            //{
            //    if(APP.Razorengine.Handler.Cache.Contains(ss.Name))
            //    {
            //        APP.Razorengine.Handler.Cache.Remove(ss.Name);
            //    }
            //}
            await WebSetup.ClearAllDynamicActions(_actionProvider, _dynamicChangeTokenProvider);

            await WebSetup.BuildAllDynamicActions(_actionProvider, _dynamicChangeTokenProvider);

            APPCommon.InitRazorEngine();
            return(0);
        }
示例#6
0
        public FileLogOutput()
        {
            APP.GetInstance().onApplicationQuit += Close;
            this.mWritingLogQueue = new Queue <LogData>();
            this.mWaitingLogQueue = new Queue <LogData>();
            this.mLogLock         = new object();
            DateTime _nowTime = DateTime.Now;
            string   logName  = string.Format("Q{0}{1}{2}{3}{4}{5}", _nowTime.Year, _nowTime.Month
                                              , _nowTime.Day, _nowTime.Hour, _nowTime.Minute, _nowTime.Second);
            //string logPath="";
            string _logPath = string.Format("{0}/{1}/{2}.log", m_devicePath, logPath, logName);

            string logDir = Path.GetDirectoryName(_logPath);

            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }
            if (File.Exists(_logPath))
            {
                File.Delete(_logPath);
            }
            this.mLogWriter           = new StreamWriter(_logPath);
            this.mLogWriter.AutoFlush = true;
            this.mIsRunning           = true;
            this.mFileLogThread       = new Thread(new ThreadStart(WriteLog));
            this.mFileLogThread.Start();
        }
示例#7
0
 public void DeleteApp(AppModel App)
 {
     if (App == null)
     {
         throw new ArgumentNullException();
     }
     using (AppTourEntities data = new AppTourEntities())
     {
         APP current = data.APP.Where(p => p.ID == App.Id).SingleOrDefault();
         if (current != null)
         {
             try
             {
                 data.DeleteObject(current);
                 data.SaveChanges();
             }
             catch (Exception e)
             {
                 if (e.InnerException != null)
                 {
                     throw new Exception(e.InnerException.Message);
                 }
                 throw;
             }
         }
     }
 }
示例#8
0
 private GUIConsole()
 {
     this.fpsCounter     = new FPSCounter(this);
     this.memoryDetector = new QMemoryDetector(this);
     //        this.showGUI = App.Instance().showLogOnGUI;
     APP.GetInstance().onUpdate += Update;
     APP.GetInstance().onGUI    += OnGUI;
     Application.logMessageReceived += HandleLog;
 }
示例#9
0
    /// <summary>
    /// 读取csv数据
    /// </summary>
    /// <param name="_path">完整路径</param>
    /// <param name="directoryDelegate">Dictionary<string,List<string>>数据类型数据</param>
    /// <returns></returns>
    private IEnumerator StartLoad(string _path, DirectoryDelegate directoryDelegate)
    {
        string csvTxt = null;

        yield return(APP.GetInstance().StartCoroutine(LoadTxt(_path, (_txt) => { csvTxt = _txt; })));

        Dictionary <string, List <string> > keyValues = ToDictionary(AnalysisCsvTxt(csvTxt));

        directoryDelegate(keyValues);
    }
示例#10
0
 protected void btnGuardarPatologiaPeronal_Click(object sender, EventArgs e)
 {
     if (Session["Paciente"] != null && txtPatologiasPersonales.Text != "")
     {
         Paciente P = Session["Paciente"] as Paciente;
         APP      A = new APP(P.ID, txtPatologiasPersonales.Text);
         A.Guardar();
         txtPatologiasPersonales.Text = "";
     }
 }
示例#11
0
 /// <summary>
 /// 数据加载操作
 /// </summary>
 private bool doLoadData()
 {
     //开始验证数据
     //添加事件
     //设置全局工作目录
     APP.Application.Global.AppFolder = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
     APP.Application.Global.Init();
     APP.InitCompatle();
     //功能修改,判断加密狗是否工作正常,并且通过验证,无论成功与否 都进入到主界面
     doSecurity();
     return(true);
 }
示例#12
0
        /// <summary>
        /// PLC連線
        /// </summary>
        public static void PLC_Connect()
        {
            GlobalData.PLC_D區起始位址      = 8000; GlobalData.PLC_D區結束位址 = 8400;
            GlobalData.PLC_DM_Scan_NUM = GlobalData.PLC_D區結束位址 - GlobalData.PLC_D區起始位址;
            GlobalData.DM = new string[GlobalData.PLC_D區結束位址];
            APP.全部陣列區域歸零_Initial();
            GlobalData.PLC_Remote_Port = 8501;
            string error = string.Empty;

            APP.Connect_Keyence_PLC(GlobalParameter.PLCIP, GlobalData.PLC_Remote_Port, ref error);
            if (GlobalData.PLC初始連線是否成功)
            {
                ThreadPool.QueueUserWorkItem(PLC循環);
            }
        }
        public void AttachedPropOnCtor_TreeValidator(object o)
        {
            Element10    root = (Element10)o;
            ColorElement color;
            string       attachedString;

            color = (ColorElement)root.Element0;
            Assert.AreEqual("Blue", color.ColorName);
            attachedString = APP.GetFoo(color);
            Assert.AreEqual("FooString", attachedString);

            color = (ColorElement)root.Element1;
            Assert.AreEqual("Red", color.ColorName);
            attachedString = APP.GetFoo(color);
            Assert.AreEqual("RedElement", attachedString);
        }
示例#14
0
 public AppConfigurationViewModel()
 {
     if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
     {
         return;
     }
     try
     {
         _APP = new ApplicationSettings();
         APP.LoadSettings();
     }
     catch (Exception E)
     {
         ExepionLogger.Logger.LogException(E);
         ExepionLogger.Logger.Show(E);
     }
 }
示例#15
0
    // Use this for initialization
    public override void Initialize(Action <SystemBase> OnInitialized = null)
    {
        if (!APP.IsReady) // checking whether APP is active or not
        {
            APP.WaitForSubsystem(APP.PlayerTankManager, Start);
            return;
        }

        if (APP.PlayerTankManager.isArcade) // checking if current game mode is arcade mode
        {
            if (APP.PlayerTankManager._ArcadeMode == arcadeMode.defend || APP.PlayerTankManager._ArcadeMode == arcadeMode.SearchAndDestroy)
            {
                defendModeSettings = FindObjectOfType <ExitZone>();
            }
        }

        levelManagerRef = FindObjectOfType <LevelManager>();
        myCanvas        = GetComponent <Canvas>();

        myCanvas.enabled = false;
        Time.timeScale   = 1;

        if (loadingOverlay)
        {
            loadingOverlay.SetActive(false);
        }

        if (restartMissionPrompt)
        {
            restartMissionPrompt.SetActive(false);
        }

        if (leaveMissionPrompt)
        {
            leaveMissionPrompt.SetActive(false);
        }

        gameWon       = false;
        IsInitialized = true;

        if (OnInitialized != null)
        {
            OnInitialized.Invoke(this);
        }
    }
示例#16
0
        public async Task <object> Login(string userName, string password)
        {
            var user = APP.LoginAdmin(userName, password);

            // var user = _userService.Login(userName, password);
            if (user != null)
            {
                var authenticationType = AdminAuthorizeAttribute.CustomerAuthenticationScheme;
                var identity           = new ClaimsIdentity(authenticationType);
                identity.AddClaim(new Claim(ClaimTypes.Sid, userName));
                identity.AddClaim(new Claim(ClaimTypes.Name, userName));
                identity.AddClaim(new Claim(ClaimTypes.Role, "admin"));
                await HttpContext.SignInAsync(authenticationType, new ClaimsPrincipal(identity));

                return(new { isok = true, msg = "" });
            }
            return(new { isok = false, msg = "登录失败,用户名密码不正确" });
        }
示例#17
0
        //Lee los valores en el registro
        public static bool LoadConfig(APP caller, string path)
        {
            try
            {
                TRY_REGREAD:

                // Opening the registry key
                RegistryKey key = Registry.LocalMachine.OpenSubKey(path);
                if (key == null)
                {
                    if ((key = saveRegistryDefault()) == null)
                    {
                        MessageBox.Show("No se pudo escribir en el registro. Verifique que tenga los permisos necesarios. Se continuara la carga del programa pero sus configuraciones se perderan.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        _administrator = false;
                        return true;
                    }
                }

                //Lee
                try
                {
                    caller.PowerChangePoint = (key.GetValue("PowerChangePoint").ToString());
                    caller.PlugCheck = (key.GetValue("PlugCheck").ToString());
                    caller.ChangePointOn = (key.GetValue("ChangePointOn").ToString());
                    caller.ButtonSize = (key.GetValue("ButtonSize").ToString());
                    caller.Position = (key.GetValue("Position").ToString());
                    caller.EcoPlan = (key.GetValue("EcoPlan").ToString());
                    caller.MaxPlan = (key.GetValue("MaxPlan").ToString());
                }
                catch
                {
                    saveRegistryDefault();
                    goto TRY_REGREAD;
                }

            }
            catch
            {
                MessageBox.Show("Hubo un problema al leer los datos del registro!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            return true;
        }
示例#18
0
        /// <summary>
        /// 回复站内信
        /// </summary>
        public void Message_Reply()
        {
            if (!EX_Admin.Power("message_reply", "回复站内信"))
            {
                AjaxNoPower();
                return;
            }
            int          id      = RequestTool.RequestInt("id", 0);
            string       Title   = RequestTool.RequestString("Title");
            string       Content = RequestTool.RequestString("Content");
            Lebi_Message mes     = B_Lebi_Message.GetModel(id);
            Lebi_Message model   = new Lebi_Message();

            if (mes == null)
            {
                Response.Write("{\"msg\":\"" + Tag("回复信息不存在") + "\"}");
                return;
            }
            else
            {
                model.Message_Type_id = mes.Message_Type_id;
            }
            model.Title          = Title;
            model.Content        = Content;
            model.User_id_From   = 0;
            model.User_Name_From = "管理员";
            model.User_id_To     = mes.User_id_From;
            model.User_Name_To   = mes.User_Name_From;
            model.IsRead         = 0;
            model.IsSystem       = 0;
            model.Time_Add       = System.DateTime.Now;
            model.Language       = mes.Language;
            model.IP             = RequestTool.GetClientIP();
            model.Supplier_id    = mes.Supplier_id;
            B_Lebi_Message.Add(model);
            Log.Add("回复站内信", "Message", "", CurrentAdmin, mes.User_Name_From);
            //发送短信
            SMS.SendSMS_messagereply(model);
            //APP推送
            APP.Push_messagereply(model);
            Response.Write("{\"msg\":\"OK\"}");
        }
示例#19
0
        public IActionResult Get(string grant_type, string appid, string secret)
        {
            CommonResult result = new CommonResult();

            if (!grant_type.Equals(GrantType.ClientCredentials))
            {
                result.ErrCode = "40003";
                result.ErrMsg  = ErrCode.err40003;
                return(ToJsonContent(result));
            }
            else if (string.IsNullOrEmpty(grant_type))
            {
                result.ErrCode = "40003";
                result.ErrMsg  = ErrCode.err40003;
                return(ToJsonContent(result));
            }
            string strHost = Request.Host.ToString();
            APP    app     = _iAPPService.GetAPP(appid, secret);

            if (app == null)
            {
                result.ErrCode = "40001";
                result.ErrMsg  = ErrCode.err40001;
            }
            else
            {
                if (!app.RequestUrl.Contains(strHost) || !strHost.Contains("localhost"))
                {
                    result.ErrCode = "40002";
                    result.ErrMsg  = ErrCode.err40002 + ",你当前请求主机:" + strHost;
                }
                else
                {
                    TokenProvider tokenProvider = new TokenProvider(_jwtModel);
                    TokenResult   tokenResult   = tokenProvider.GenerateToken(grant_type, appid, secret);
                    result.ResData = tokenResult;
                    result.ErrCode = "0";
                    return(ToJsonContent(result));
                }
            }
            return(ToJsonContent(result));
        }
示例#20
0
        private static object HandleGetData(HttpContext httpContext, RuntimeStepModel newrunmodel, ISqlSugarClient dbFactory, AConFlowStep s)
        {
            object dynaObject = null;

            //var objParams2 = new List<object>();
            //if (!string.IsNullOrEmpty(s.ArgNames))
            //{
            //    var args = s.ArgNames.Split(',');
            //    foreach (var aarg in args)
            //    {
            //        object obj = aarg;
            //        if (aarg.StartsWith("&"))
            //        {
            //            obj = newrunmodel.Resuce(aarg);

            //        }
            //        objParams2.Add(obj);
            //    }
            //}
            if (!String.IsNullOrEmpty(s.ArgNames))
            {
                if (s.ArgNames.Contains(','))
                {
                    dynaObject = newrunmodel.Resuce(s.ArgNames.Split(',')[0]);
                }
                else
                {
                    dynaObject = newrunmodel.Resuce(s.ArgNames);
                }
            }

            //if (objParams2 == null || objParams2.Count == 0)
            //{
            //    dynaObject = APP.GetData( s.InParamter1);
            //}
            //else
            //{
            dynaObject = APP.GetData(s.InParamter1, dynaObject);
            //}

            return(dynaObject);
        }
示例#21
0
        public object SetupConstring(int dbType, string dbserverName, string port, string DBName, string user, string password, string filename = null)
        {
            bool IsInstallDB            = true;
            var  CmsInstallDir          = APP.GetDicstring("CmsInstallDir");
            var  CmsInstallLockFileName = APP.GetDicstring("CmsInstallLockFileName");
            var  pyDir = Path.Combine(APPCommon.AppContentDir, CmsInstallDir);

            if (!Directory.Exists(pyDir))
            {
                Directory.CreateDirectory(pyDir);
            }
            var      lockfilePath = Path.Combine(pyDir, CmsInstallLockFileName);
            FileInfo fileInfo     = new FileInfo(lockfilePath);

            if (!fileInfo.Exists)
            {
                IsInstallDB = false;
            }
            var dbtype           = dbType;//0 sqlite,1 mssql 2 mysql
            var connectionString = string.Empty;

            if (!IsInstallDB)
            {
                switch (dbtype)
                {
                case 0:
                    connectionString = filename;
                    break;

                case 1:
                    connectionString = "Data Source={dbserverName};Initial Catalog={DBName};Port={port};User ID={user};Password={password};Connect Timeout=3000;Max Pool Size =2024;";
                    break;

                case 2:
                    connectionString = "Server={dbserverName};Port={port};Database={DBName}; User={user};Password={password};";
                    break;
                }
            }

            return(new { isok = false, msg = "Already installed" });
        }
示例#22
0
    // Is intializing for the systems and the logs
    public void Initialize()
    {
        if (OnScreenLog)
        {
            GameObject DeugLog = Instantiate(Resources.Load("Managers/AppLog"), null) as GameObject;
            AppLogger = DeugLog.GetComponent <AppLog>();
            DontDestroyOnLoad(DeugLog.gameObject);
        }

        if (IsReady)
        {
            // Ensure there is only one App, ever
            Destroy(gameObject);
            return;
        }

        // Start App
        Instance = Inst;

        SetLoadState(LoadStates.Starting);
    }
示例#23
0
 public int UpdateCache()
 {
     APP.Dlls.Clear();
     APP.Types.Clear();
     APP.MethodInfos.Clear();
     APP.RuntimeCodes.Clear();
     APP.Composeentitys.Clear();
     APP.DynamicReferenceDlls.Clear();
     APP.AConFlowSteps.Clear();
     APP.ComposeTemplates.Clear();
     APP.ClearCache();
     //var razorlist = m_codeService.GetSimpleCode<SystemHtml>(null);
     //foreach(var ss in razorlist)
     //{
     //    if(APP.Razorengine.Handler.Cache.Contains(ss.Name))
     //    {
     //        APP.Razorengine.Handler.Cache.Remove(ss.Name);
     //    }
     //}
     APP.InitRazorEngine();
     return(0);
 }
示例#24
0
        public override void Ashx_Load()
        {
            string ErrInfo_ = string.Empty;
            string pageIndex = "1", dataCount = "10", dataSort = "EventID desc", PersonId;
            string retStr = "{\"rows\":" + "/*Rows*/" + ",\"total\":/*Total*/" + ",\"ErrCode\":0}";

            CheckRequery.check("PersonId", out PersonId);
            CheckRequery.checkNotNull("page", out pageIndex);
            CheckRequery.checkNotNull("rows", out dataCount);
            string    sql    = string.Format(@"Select a.EventID,a.UpTime,a.EventAddress,a.EventX,a.EventY,a.EventPictures,a.EventDesc,a.PersonId, b.PersonName,c.EventFromName,d.DeptName,ET1.EventTypeName as EventType,ET2.EventTypeName as EventContent,f.UrgencyName,g.HandlerLevelName,wo.OperName 
              From M_Event as a 
              left join L_Person as b ON a.PersonId = b.PersonId 
              left join M_EventFrom as c ON a.EventFromId = c.EventFromId 
              left join L_Department as d ON a.DeptId = d.DeptId 
              left join (select EventTypeId, EventTypeName from M_EventType where ParentTypeId = 0) ET1 on a.EventTypeId = ET1.EventTypeId 
              left join (select EventTypeId, EventTypeName from M_EventType where ParentTypeId <> 0) ET2 on a.EventTypeId2 = ET2.EventTypeId 
              left join M_Urgency as f ON a.UrgencyId = f.UrgencyId 
              left join M_HandlerLevel as g ON a.HandlerLevelId = g.HandlerLevelId 
              left join L_Person p on a.DispatchPerson = p.PersonId 
              left join M_WorkOrder mw on mw.EventID = a.EventID and mw.OrderStatus = 0 
              left join (select MAX(OperId) OperId, OrderId from M_WorkOrder_Oper_History Group by OrderId) h ON mw.OrderId = h.OrderId 
              left join M_WorkOrder_Oper as wo on h.OperId = wo.OperId 
              Where a.DeleteStatus = 0 and a.PersonId = {0}", PersonId);
            DataTable dt     = APP.SQLServer_Helper.SelectDataTable(sql, out ErrInfo_);
            string    sqlStr = APP.MakeSqlByPage(sql, dataSort, Convert.ToInt16(pageIndex), Convert.ToInt16(dataCount));
            DataSet   ds     = APP.SQLServer_Helper.Query(sqlStr);

            if (string.IsNullOrEmpty(ErrInfo_))
            {
                Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
                retStr = retStr.Replace("/*Total*/", ds.Tables[1].Rows[0][0].ToString()).Replace("/*Rows*/", JsonConvert.SerializeObject(ds.Tables[0], timeConverter));
                Context.Response.Write(retStr);
            }
            else
            {
                Context.Response.Write(EasyUI_Pagination.ExportErrMsg(ErrInfo_));
            }
        }
示例#25
0
        private void loginForm_Load(object sender, EventArgs e)
        {
            APP.Init();

            //首先加密狗验证读取加密狗信息
            APP.GoldSoftClient.FirstLogin();
            if (APP.GoldSoftClient.ClientResult.IsLoginSucess)
            {
                switch (APP.GoldSoftClient.ClientResult.Fun)
                {
                case 1:
                    myflash.Movie = AppDomain.CurrentDomain.BaseDirectory + "\\config\\专业版.swf";
                    break;

                case 2:
                    myflash.Movie = AppDomain.CurrentDomain.BaseDirectory + "\\config\\旗舰版.swf";
                    break;

                case 3:
                    myflash.Movie = AppDomain.CurrentDomain.BaseDirectory + "\\config\\网络版.swf";
                    break;

                default:
                    myflash.Movie = AppDomain.CurrentDomain.BaseDirectory + "\\config\\领先版.swf";
                    break;
                }
            }
            else
            {
                myflash.Movie = AppDomain.CurrentDomain.BaseDirectory + "\\config\\领先版.swf";
            }
            myflash.Play();

            //this.BackgroundImage = GOLDSOFT.QDJJ.UI.Properties.Resources.登陆2;
            //this.BackgroundImage = GOLDSOFT.QDJJ.UI.Properties.Resources.登陆_旗舰版3;
            //系统入口程序(数据加载 全局应用程序配置)
            this.timer1.Start();
        }
示例#26
0
 public static void Register()
 {
     APP.DB_DEFAULT_CONN_NAME = "Sys";
     APP.OnDbExecuting        = OnDbExecuting;
     APP.Init();
 }
示例#27
0
 /// <summary>
 /// 读取csv数据
 /// </summary>
 /// <param name="_path">完整路径</param>
 /// <param name="directoryDelegate">Dictionary<string,List<string>>数据类型数据</param>
 public void LoadCsv(string _path, DirectoryDelegate directoryDelegate)
 {
     APP.GetInstance().StartCoroutine(StartLoad(_path, directoryDelegate));
 }
示例#28
0
        //public void GetRequestHash(ActionExecutingContext actionExecutingContext)
        //{
        //    //actionExecutingContext.HttpContext.req
        //}

        private async static Task RunComposity(int requsetHash, HttpContext httpContext, RuntimeStepModel newrunmodel, ISqlSugarClient dbFactory, ISysDatabaseService codeService, IConfiguration config)
        {
            var cons = newrunmodel.ComposeEntity;

            if (cons.RunMode == RunMode.Coding)
            {
                if (newrunmodel.ComposeTemplate != null)
                {
                    //TODO :add template
                }
                //Manager.RuntimeModels.Add(newrunmodel);
                else
                {
                    var steps = FindSteps(cons.Guid, codeService);

                    foreach (var s in steps)
                    {
                        object rebject    = null;
                        object DynaObject = null;

                        if (s.IsUsingAuth.ToBool())
                        {
                            await httpContext.AuthenticateAsync();

                            if (httpContext.User.Identity.Name != s.UserName || !httpContext.User.Identity.IsAuthenticated)
                            {
                                APPCommon.ResponseUnAuth((ActionExecutingContext)newrunmodel.Res["__actioncontext"], s.LoginUrl);

                                return;
                            }
                        }

                        var    cacheKey   = string.Concat(cons.Guid, "_", s.ExcuteType, "_", s.FlowStepType, "_", s.Guid, "_", s.ArgNames);
                        object stepResult = APP.RuntimeCache.GetOrCreate(cacheKey, entry =>
                        {
                            object newobj = null;
                            APP.RuntimeCache.Set(cacheKey, newobj);
                            return(newobj);
                        });

                        if (s.IsUsingCache && stepResult != null)
                        {
                            rebject = stepResult;
                        }
                        else
                        {
                            if (!s.IsUsingCache || stepResult == null)
                            {
                                switch (s.FlowStepType)
                                {
                                case FlowStepType.Declare:
                                {
                                    lock (lockobj)
                                    {
                                        //root.Usings[2].Name.ToString()
                                        // var rebject2 = Manager.GetData(spec.InParamter1, spec.InParamter2);
                                        var runcode    = APP.FindOrAddRumtimeCode(s.Guid);
                                        var so_default = ScriptOptions.Default;
                                        if (runcode == null)
                                        {
                                            runcode = new RuntimeCode()
                                            {
                                                StepGuid  = s.Guid,
                                                CodeLines = s.ProxyCode,
                                            };
                                            List <string> dlls = new List <string>();

                                            var    isref   = false;
                                            string dllbase = APPCommon.AppRootDir;


                                            if (!string.IsNullOrEmpty(s.TypeLib))
                                            {
                                                var dllfile = dllbase + s.TypeLib;
                                                if (APP.DynamicReferenceDlls.Contains(dllfile))
                                                {
                                                    isref = false;
                                                }
                                                else
                                                {
                                                    APP.DynamicReferenceDlls.Add(dllfile);
                                                    isref = true;
                                                    dlls.Add(dllfile);
                                                }
                                            }
                                            if (!string.IsNullOrEmpty(s.ReferenceDlls))
                                            {
                                                isref = true;
                                                string[] dllnams = s.ReferenceDlls.Split(',');
                                                foreach (var n in dllnams)
                                                {
                                                    APP.DynamicReferenceDlls.Add(dllbase + n);
                                                }

                                                dlls.AddRange(dllnams);
                                            }
                                            if (isref)
                                            {
                                                so_default = so_default.WithReferences(dlls.ToArray());
                                            }
                                            so_default = so_default.WithReferences(Assembly.GetExecutingAssembly());

                                            var state = CSharpScript.Create <object>(s.ProxyCode, so_default, typeof(Dictionary <string, object>));

                                            runcode.Script = state;
                                            APP.RuntimeCodes.Add(s.Guid, runcode);
                                        }
                                        if (!string.IsNullOrEmpty(s.ReferenceDlls))
                                        {
                                            string dllbase = APPCommon.AppRootDir;
                                        }
                                        rebject = runcode.Script.RunAsync(newrunmodel.Res).Result.ReturnValue;
                                        Logger.LogInfo(LoggerName, $"AComposityId id {s.AComposityId} ,step {s.StepOrder}, Declare: result {rebject}  ");
                                    }
                                }
                                break;

                                case FlowStepType.GetData:
                                {
                                    DynaObject = HandleGetData(httpContext, newrunmodel, dbFactory, s);
                                }
                                break;

                                case FlowStepType.CallMethod:
                                {
                                    var methodsub = APP.GetMethodFromConfig(s.IsBuildIn.Value, s.TypeLib, s.TypeFullName, s.MethodName);
                                    var objParams = new List <object>();
                                    if (!string.IsNullOrEmpty(s.ArgNames))
                                    {
                                        objParams = newrunmodel.GetPoolResuce(s.ArgNames.Split(','));
                                    }

                                    else
                                    {
                                        objParams = null;
                                    }
                                    try
                                    {
                                        if (methodsub.IsStatic)
                                        {
                                            DynaObject = methodsub.Invoke(null, objParams.ToArray());
                                        }
                                        else
                                        {
                                            var instance = newrunmodel.Res[s.InstanceName];
                                            DynaObject = methodsub.Invoke(instance, objParams.ToArray());
                                        }
                                    }
                                    catch (Exception exp)
                                    {
                                        Logger.LogError(logName, "Run -> FlowStepType.CallMethod error,composity:{0},step:{1},-------------exception:{2}", cons.Id, s.Guid, LoggerHelper.GetExceptionString(exp));
                                        break;
                                    }
                                    Logger.LogInfo(LoggerName, $"AComposityId id {s.AComposityId} ,step {s.StepOrder}, CallMethod {s.MethodName}: result {DynaObject}  ");
                                }
                                break;

                                case FlowStepType.Text:
                                {
                                    rebject = s.OutPutText;
                                }
                                break;

                                case FlowStepType.Function:
                                {
                                    DynaObject = DealTheFunction(newrunmodel, s, httpContext);
                                    Logger.LogInfo(LoggerName, $"DealTheFunction: result {DynaObject}  ");
                                }
                                break;

                                case FlowStepType.RazorKey:
                                    try
                                    {
                                        rebject = stepResult = await HandleRazorKey(newrunmodel, s);
                                    }
                                    catch (Exception exp)
                                    {
                                        Logger.LogError(logName, $"parser RazorText wrong: {exp.Message}-------{LoggerHelper.GetExceptionString(exp)}");
                                    }
                                    break;

                                case FlowStepType.RazorText:
                                    try
                                    {
                                        rebject = stepResult = await HandleRazorText(newrunmodel, s, httpContext, s.ProxyCode);
                                    }
                                    catch (Exception exp)
                                    {
                                        Logger.LogError(logName, $"parser RazorText wrong: {exp.Message}-------{LoggerHelper.GetExceptionString(exp)}");
                                    }
                                    break;

                                case FlowStepType.RazorFile:
                                    try
                                    {
                                        var    filePath = s.ProxyCode;
                                        string template = File.ReadAllText(Path.Combine(APPCommon.UserUploadBaseDir, filePath));
                                        rebject = stepResult = await HandleRazorText(newrunmodel, s, httpContext, template);
                                    }
                                    catch (Exception exp)
                                    {
                                        Logger.LogError(logName, "parser RazorFile wrong: " + exp.Message + "-------" + LoggerHelper.GetExceptionString(exp));
                                    }
                                    break;
                                }

                                if (rebject == null)
                                {
                                    rebject = MagicExtension.BackToInst(DynaObject);
                                }
                                if (s.IsUsingCache)
                                {
                                    APP.RuntimeCache.Set(cacheKey, rebject);
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(s.StorePoolKey) && rebject != null)
                        {
                            newrunmodel.SetComposityResourceValue(s.StorePoolKey, rebject);
                        }
                    }
                    await CheckAndRunNextRuntimeComposity(requsetHash, httpContext, newrunmodel, dbFactory, codeService, config);
                }

                //Manager.RuntimeModels.Remove(newrunmodel);
            }
        }
 public void ValidateAPPFoo(object o)
 {
     Assert.AreEqual("Hello", APP.GetFoo(o));
 }
示例#30
0
        public async Task <IActionResult> GetCheckUser(string username, string password, string vcode, string vkey, string appId, string systemCode)
        {
            CommonResult      result            = new CommonResult();
            RemoteIpParser    remoteIpParser    = new RemoteIpParser();
            string            strIp             = remoteIpParser.GetClientIp(HttpContext).MapToIPv4().ToString();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            var    vCode = yuebonCacheHelper.Get("ValidateCode" + vkey);
            string code  = vCode != null?vCode.ToString() : "11";

            if (vcode.ToUpper() != code)
            {
                result.ErrMsg = "验证码错误";
                return(ToJsonContent(result));
            }
            Log  logEntity = new Log();
            bool blIp      = _filterIPService.ValidateIP(strIp);

            if (blIp)
            {
                result.ErrMsg = strIp + "该IP已被管理员禁止登录!";
            }
            else
            {
                if (string.IsNullOrEmpty(username))
                {
                    result.ErrMsg = "用户名不能为空!";
                }
                else if (string.IsNullOrEmpty(password))
                {
                    result.ErrMsg = "密码不能为空!";
                }
                if (string.IsNullOrEmpty(systemCode))
                {
                    result.ErrMsg = ErrCode.err40006;
                }
                else
                {
                    string strHost = Request.Host.ToString();
                    APP    app     = _appService.GetAPP(appId);
                    if (app == null)
                    {
                        result.ErrCode = "40001";
                        result.ErrMsg  = ErrCode.err40001;
                    }
                    else
                    {
                        if (!app.RequestUrl.Contains(strHost, StringComparison.Ordinal) && !strHost.Contains("localhost", StringComparison.Ordinal))
                        {
                            result.ErrCode = "40002";
                            result.ErrMsg  = ErrCode.err40002 + ",你当前请求主机:" + strHost;
                        }
                        else
                        {
                            SystemType systemType = _systemTypeService.GetByCode(systemCode);
                            if (systemType == null)
                            {
                                result.ErrMsg = ErrCode.err40006;
                            }
                            else
                            {
                                Tuple <User, string> userLogin = await this._userService.Validate(username, password);

                                if (userLogin != null)
                                {
                                    string ipAddressName = IpAddressUtil.GetCityByIp(strIp);
                                    if (userLogin.Item1 != null)
                                    {
                                        result.Success = true;
                                        User              user           = userLogin.Item1;
                                        JwtOption         jwtModel       = App.GetService <JwtOption>();
                                        TokenProvider     tokenProvider  = new TokenProvider(jwtModel);
                                        TokenResult       tokenResult    = tokenProvider.LoginToken(user, appId);
                                        YuebonCurrentUser currentSession = new YuebonCurrentUser
                                        {
                                            UserId         = user.Id,
                                            Name           = user.RealName,
                                            AccessToken    = tokenResult.AccessToken,
                                            AppKey         = appId,
                                            CreateTime     = DateTime.Now,
                                            Role           = _roleService.GetRoleEnCode(user.RoleId),
                                            ActiveSystemId = systemType.Id,
                                            CurrentLoginIP = strIp,
                                            IPAddressName  = ipAddressName
                                        };
                                        TimeSpan expiresSliding = DateTime.Now.AddMinutes(120) - DateTime.Now;
                                        yuebonCacheHelper.Add("login_user_" + user.Id, currentSession, expiresSliding, true);

                                        List <AllowCacheApp> list = yuebonCacheHelper.Get("AllowAppId").ToJson().ToList <AllowCacheApp>();
                                        if (list.Count == 0)
                                        {
                                            IEnumerable <APP> appList = _appService.GetAllByIsNotDeleteAndEnabledMark();
                                            yuebonCacheHelper.Add("AllowAppId", appList);
                                        }
                                        CurrentUser    = currentSession;
                                        result.ResData = currentSession;
                                        result.ErrCode = ErrCode.successCode;
                                        result.Success = true;

                                        logEntity.Account       = user.Account;
                                        logEntity.NickName      = user.NickName;
                                        logEntity.Date          = logEntity.CreatorTime = DateTime.Now;
                                        logEntity.IPAddress     = CurrentUser.CurrentLoginIP;
                                        logEntity.IPAddressName = CurrentUser.IPAddressName;
                                        logEntity.Result        = true;
                                        logEntity.ModuleName    = "登录";
                                        logEntity.Description   = "登录成功";
                                        logEntity.Type          = "Login";
                                        _logService.Insert(logEntity);
                                    }
                                    else
                                    {
                                        result.ErrCode          = ErrCode.failCode;
                                        result.ErrMsg           = userLogin.Item2;
                                        logEntity.Account       = username;
                                        logEntity.Date          = logEntity.CreatorTime = DateTime.Now;
                                        logEntity.IPAddress     = strIp;
                                        logEntity.IPAddressName = ipAddressName;
                                        logEntity.Result        = false;
                                        logEntity.ModuleName    = "登录";
                                        logEntity.Type          = "Login";
                                        logEntity.Description   = "登录失败," + userLogin.Item2;
                                        _logService.Insert(logEntity);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            yuebonCacheHelper.Remove("LoginValidateCode");
            return(ToJsonContent(result, true));
        }
示例#31
0
        public IActionResult SysConnect(string openmf, string appId, string systemCode)
        {
            CommonResult   result         = new CommonResult();
            RemoteIpParser remoteIpParser = new RemoteIpParser();
            string         strIp          = remoteIpParser.GetClientIp(HttpContext).MapToIPv4().ToString();

            if (string.IsNullOrEmpty(openmf))
            {
                result.ErrMsg = "切换参数错误!";
            }

            bool blIp = _filterIPService.ValidateIP(strIp);

            if (blIp)
            {
                result.ErrMsg = strIp + "该IP已被管理员禁止登录!";
            }
            else
            {
                string ipAddressName = IpAddressUtil.GetCityByIp(strIp);
                if (string.IsNullOrEmpty(systemCode))
                {
                    result.ErrMsg = ErrCode.err40006;
                }
                else
                {
                    string strHost = Request.Host.ToString();
                    APP    app     = _appService.GetAPP(appId);
                    if (app == null)
                    {
                        result.ErrCode = "40001";
                        result.ErrMsg  = ErrCode.err40001;
                    }
                    else
                    {
                        if (!app.RequestUrl.Contains(strHost, StringComparison.Ordinal) && !strHost.Contains("localhost", StringComparison.Ordinal))
                        {
                            result.ErrCode = "40002";
                            result.ErrMsg  = ErrCode.err40002 + ",你当前请求主机:" + strHost;
                        }
                        else
                        {
                            SystemType systemType = _systemTypeService.GetByCode(systemCode);
                            if (systemType == null)
                            {
                                result.ErrMsg = ErrCode.err40006;
                            }
                            else
                            {
                                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                                object            cacheOpenmf       = yuebonCacheHelper.Get("openmf" + openmf);
                                yuebonCacheHelper.Remove("openmf" + openmf);
                                if (cacheOpenmf == null)
                                {
                                    result.ErrCode = "40007";
                                    result.ErrMsg  = ErrCode.err40007;
                                }
                                else
                                {
                                    User user = _userService.Get(cacheOpenmf.ToString());
                                    if (user != null)
                                    {
                                        result.Success = true;
                                        JwtOption         jwtModel       = App.GetService <JwtOption>();
                                        TokenProvider     tokenProvider  = new TokenProvider(jwtModel);
                                        TokenResult       tokenResult    = tokenProvider.LoginToken(user, appId);
                                        YuebonCurrentUser currentSession = new YuebonCurrentUser
                                        {
                                            UserId          = user.Id,
                                            Name            = user.RealName,
                                            AccessToken     = tokenResult.AccessToken,
                                            AppKey          = appId,
                                            CreateTime      = DateTime.Now,
                                            Role            = _roleService.GetRoleEnCode(user.RoleId),
                                            ActiveSystemId  = systemType.Id,
                                            CurrentLoginIP  = strIp,
                                            IPAddressName   = ipAddressName,
                                            ActiveSystemUrl = systemType.Url
                                        };
                                        TimeSpan expiresSliding = DateTime.Now.AddMinutes(120) - DateTime.Now;
                                        yuebonCacheHelper.Add("login_user_" + user.Id, currentSession, expiresSliding, true);
                                        CurrentUser    = currentSession;
                                        result.ResData = currentSession;
                                        result.ErrCode = ErrCode.successCode;
                                        result.Success = true;
                                    }
                                    else
                                    {
                                        result.ErrCode = ErrCode.failCode;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(ToJsonContent(result));
        }