/// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="executeModel"></param>
        /// <returns></returns>
        public RIPListPageModel GetModelPageList(ExecuteModel executeModel)
        {
            using (var db = new DbContext())
            {
                //查询器
                var selectBuilder = CreateBuilder(db, executeModel);
                if (executeModel.Columns != null && executeModel.Columns.Length > 0)
                {//如果更新有指定列,则指定列
                    selectBuilder.Columns(executeModel.Columns);
                }
                else
                {//未指定列
                    selectBuilder.Columns("*");
                }

                //设置分页码
                selectBuilder.Paging(executeModel.Page, executeModel.PageSize);
                var total = 0;
                var dt    = selectBuilder.Select(out total);
                if (dt.HasData())
                {
                    //将对象序列化
                    var data = QWPlatform.SystemLibrary.Serialize.SerializeHelper.SerializeBinary(dt);
                    return(new RIPListPageModel
                    {
                        Total = total,
                        Value = data
                    });
                }

                return(null);
            }
        }
        /// <summary>
        /// 更新数据表
        /// </summary>
        /// <param name="executeModel"></param>
        /// <returns></returns>
        public int Update(ExecuteModel executeModel)
        {
            using (var db = new DbContext())
            {
                //生成操作时间
                //executeModel.Entity.oper_time = db.Database().GetDateTime;

                //设置不立即设置为根据主键更新,后续根据和条件更新
                IUpdateBuilder updateBuilder = db.Update(executeModel.Entity, false);
                if (executeModel.Columns != null && executeModel.Columns.Length > 0)
                {//如果更新有指定列,则指定列
                    updateBuilder.Column(executeModel.Columns);
                }

                //获取条件sql
                var whereSql = GetConitionsql(executeModel.Conditions);
                updateBuilder.Where(whereSql);
                executeModel.Conditions?.ForEach(p =>
                {//先设置参数,组装SQL
                    updateBuilder.Parameters(p.Key, p.Value);
                });

                //执行更新
                return(updateBuilder.Execute());
            }
        }
        //创建一个查询对象构造器
        private ISelectBuilder CreateBuilder(DbContext db, ExecuteModel executeModel)
        {
            //获取当前类名
            var tableName = GetTableName(executeModel.Entity.GetType());

            //查询器
            ISelectBuilder selectBuilder = db.Select(tableName);

            //获取条件sql
            var whereSql = GetConitionsql(executeModel.Conditions);

            //添加SQL条件
            selectBuilder.Where(whereSql);
            executeModel.Conditions?.ForEach(p =>
            {     //先设置参数,组装SQL
                if (p.Oper == Operational.In || p.Oper == Operational.NotIn)
                { //In 或 not in 通过设置参数方式
                    GetParams(p.Key, p.Value, selectBuilder);
                }
                else
                {
                    selectBuilder.Parameters(p.Key, p.Value);
                }
            });

            if (executeModel.OrderColumn.IsNotNullOrEmpty())
            {//如果包括了排序字段,则使用排序
                selectBuilder.OrderBy(executeModel.OrderColumn);
            }//end if

            //返回组装的对象
            return(selectBuilder);
        }
示例#4
0
 private void ExecutingModels(ConcurrentBag <SealedLogModel> item)
 {
     if (item == null)
     {
         return;
     }
     try
     {
         ExecuteModel?.Invoke(item);
         ConvertToOtherPath();
     }
     catch (Exception e)
     {
         item.Add(new SealedLogModel()
         {
             Time           = DateTime.Now,
             ControllerName = "执行操作失败",
             Level          = SealedLogLevel.Error,
             Sign           = "执行任务失败",
             ProjectName    = item.First()?.ProjectName,
             Value          = e.Message
         });
     }
     finally
     {
         if (item != null && item.Count > 0)
         {
             CurrentExecuteModel(item);
         }
     }
 }
        /// <summary>
        /// 查询出一个model数据
        /// </summary>
        /// <param name="executeModel"></param>
        /// <returns></returns>
        public object GetModel(ExecuteModel executeModel)
        {
            using (var db = new DbContext())
            {
                //查询器
                var selectBuilder = CreateBuilder(db, executeModel);
                if (executeModel.Columns != null && executeModel.Columns.Length > 0)
                {//如果更新有指定列,则指定列
                    selectBuilder.Columns(executeModel.Columns);
                }
                else
                {//未指定列
                    selectBuilder.Columns("*");
                }

                var dt = selectBuilder.Select();
                if (dt.HasData())
                {
                    //将对象序列化
                    return(QWPlatform.SystemLibrary.Serialize.SerializeHelper.SerializeBinary(dt));
                }

                return(null);
            }
        }
        public virtual ExecuteModel ExecuteCommand(string fileName = "cmd", string arguments = "/?", string workingDirectory = "")
        {
            var output           = string.Empty;
            var error            = string.Empty;
            var message          = string.Empty;
            var processStartInfo = new ProcessStartInfo(fileName, arguments)
            {
                UseShellExecute        = false,
                CreateNoWindow         = true,
                WindowStyle            = ProcessWindowStyle.Hidden,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            if (!string.IsNullOrEmpty(workingDirectory) && Directory.Exists(workingDirectory))
            {
                processStartInfo.WorkingDirectory = workingDirectory;
            }
            var processCommand = new Process
            {
                StartInfo = processStartInfo
            };

            processCommand.Start();
            processCommand.WaitForExit();
            var executeModel = new ExecuteModel
            {
                Output   = processCommand.StandardOutput.ReadToEnd(),
                Error    = processCommand.StandardError.ReadToEnd(),
                ExitCode = processCommand.ExitCode
            };

            return(executeModel);
        }
示例#7
0
 public Result ExecutionFlow(ExecuteModel model)
 {
     this._executeModel = model;
     this.WriteReqLog()
     .Start()
     .Execute()
     .End()
     .WriteResLog();
     return(this._result);
 }
        /// <summary>
        /// 检查记录是否存
        /// </summary>
        /// <param name="executeModel"></param>
        /// <returns></returns>
        public bool Exists(ExecuteModel executeModel)
        {
            using (var db = new DbContext())
            {
                //查询器
                var selectBuilder = CreateBuilder(db, executeModel);
                selectBuilder.Columns("1");

                //返回执行结果
                return(selectBuilder.Exists());
            }
        }
 private void SectionChecker(ExecuteModel executeModel, string section)
 {
     csvLogger.RegisterObservers(new FileLogger(Path.Combine($"{teamFoundationModel.WorkingDirectory}, {teamFoundationModel.Changeset}.LOG")));
     var findSection = executeModel.Output.IndexOf($"{section}:", StringComparison.OrdinalIgnoreCase);
     var output      = executeModel.Output.Substring(findSection).Split('\n').Skip(1).Select(x => x.Trim()).Where(x => x.IndexOf("$/", StringComparison.OrdinalIgnoreCase) != -1).Select((x, i) => new
     {
         Trim   = x,
         Change = x.Substring(0, x.IndexOf('$')).Trim(),
         Path   = x.Substring(x.IndexOf('$')),
         Index  = i + 1
     });
 }
示例#10
0
        public ActionResult <Result> GetConcert(string concertId)
        {
            string jsonSerarh = "{}";

            if (!String.IsNullOrEmpty(concertId))
            {
                jsonSerarh = "{'_id':'" + concertId + "'}";
            }

            Result result = new Result();

            try
            {
                LogUtil           logger     = new LogUtil();
                RestApiFacade     restFacade = new RestApiFacade(logger);
                DataConfiguration config     = new DataConfiguration {
                    DataProvider = eDataProvider.MongoDb,
                    DatabaseName = "myconcert",
                    TableName    = "concert"
                };
                ExecuteModel model = new ExecuteModel {
                    FileName         = "D:\\Courses\\AspnetCore\\MyConcert\\MyConcert.BLL\\bin\\Debug\\netstandard2.0\\MyConcert.BLL.dll",
                    ClassName        = "MyConcert.BLL.ConcertBLL",
                    MethodName       = "Get",
                    InitParameter    = config,
                    ExecuteParameter = jsonSerarh,
                    Message          = this.Message,
                    UaString         = HttpContext.Request.Headers["User-Agent"].ToString()
                };
                result = restFacade.ExecutionFlow(model);
            }
            catch (Exception err)
            {
                result.Message    = err.Message;
                result.StatusCode = 500;
                result.Status     = BusinessStatus.Error;
            }
            return(result);

            /*  using (ConcertBLL concert = new ConcertBLL())
             * {
             * // string jsonSerarh = String.Format("{Id:'{0}'}",concertId);
             * Result result = concert.Get("{_id:'"+concertId+"'}", this.Message);
             * return result;
             * }
             */
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="executeModel"></param>
        /// <returns></returns>
        public int Delete(ExecuteModel executeModel)
        {
            using (var db = new DbContext())
            {
                //获取当前类名
                var tableName  = GetTableName(executeModel.Entity.GetType());
                var delBuilder = db.Delete(tableName);
                //获取条件sql
                var whereSql = GetConitionsql(executeModel.Conditions);
                delBuilder.Where(whereSql);
                executeModel.Conditions?.ForEach(p =>
                {//先设置参数,组装SQL
                    delBuilder.Parameters(p.Key, p.Value);
                });

                return(delBuilder.Execute());
            }
        }
        public ActionResult Execute(ExecuteModel model)
        {
            var collectors         = _scanner.ScanForImplementsInterface <IPropertyCollector>().ToDictionary(x => x.Processor);
            var propertiesWrapper  = _registration.GetScsRegistration <ScsSitecoreResourceManagerRegistration>().GetPropertiesWrapper(model.Template);
            var propertyDictionary = model.Properties.ToDictionary(x => x.Id);

            foreach (var prop in model.Properties)
            {
                if (propertyDictionary[prop.Id].Value == null)
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(prop.Processor) && !collectors[prop.Processor].Validate(prop.Value))
                {
                    return(Content(prop.Name));
                }
                propertyDictionary[prop.Id].Value = ReplaceAllTokens.ReplaceTokens(propertyDictionary[prop.Id].Value, propertyDictionary.ContainsKey, x => propertyDictionary[x].Value);
                if (propertiesWrapper.Targets[model.Target].ContainsKey(prop.Id) && propertiesWrapper.Targets[model.Target][prop.Id] == "???")
                {
                    _savedProps[$"{model.Target}.{prop.Id}", model.Template] = prop.Value;
                }
                if (propertiesWrapper.Properties.ContainsKey(prop.Id) && propertiesWrapper.Properties[prop.Id].Remember)
                {
                    _savedProps[$"{model.Target}.{prop.Id}", model.Template] = prop.Value;
                }
            }
            var args     = new SitecoreResourceManagerArgs(propertyDictionary, propertiesWrapper);
            var pipeline = CorePipelineFactory.GetPipeline("propertyProcessorPreCompiled", string.Empty);

            pipeline.Run(args);
            foreach (string compilePropertyKey in propertiesWrapper.CompiledProperties.Keys)
            {
                args[compilePropertyKey] = ReplaceAllTokens.ReplaceTokens(propertiesWrapper.CompiledProperties[compilePropertyKey], propertyDictionary.ContainsKey, x => propertyDictionary[x].Value);
            }
            pipeline = CorePipelineFactory.GetPipeline("propertyProcessorPostCompiled", string.Empty);
            pipeline.Run(args);
            pipeline = CorePipelineFactory.GetPipeline("SitecoreResourceManager", string.Empty);
            pipeline.Run(args);
            return(ScsJson(args.Output));
        }
示例#13
0
        public async Task <IActionResult> ExecuteCommand(ExecuteModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User")
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            var Method = new BaseCommands
            {
                Method = "Execute"
            };
            var ExecuteVariables = new ExecuteVariables
            {
                Url   = model.Url,
                Name  = model.Name,
                Proxy = model.Proxy,
                Run   = model.Run,
            };
            var ExecuteCommand = new ExecuteCommand
            {
                newBaseCommand = Method,
                newExecute     = ExecuteVariables
            };
            var bots = new GetBotsByStatusQuery {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(ExecuteCommand).Replace(@"\", ""));

            return(Json(response));
        }
 public static void Execute(ItemModel model)
 {
     if (IsWork)
     {
         MessageBox.Show("Zaten çalışan bir kayıt var.", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     isWork        = true;
     Model         = new ExecuteModel();
     Model.Finish += Model_Finish;
     Data          = model.Data;
     Motor();
     displayForm            = new Forms.ExecuteForm();
     displayForm.TotalValue = Model.GetValueCount;
     displayForm.Show();
     OldClipboard = "";
     Clipboard.Clear();
     if (IsSetup)
     {
         timer.Tick += Timer_Tick;
         IsSetup     = false;
     }
     timer.Start();
 }
示例#15
0
        private static void TestFacade()
        {
            LogUtil       logger = new LogUtil(GetApplicationRoot() + "\\logs\\myapp.txt");
            RestApiFacade facade = new RestApiFacade(logger);

            var aBook = new Book();

            aBook.isbn  = "434-5933-343";
            aBook.title = "Java Script999";
            aBook.price = 999;
            Puppy.Model.Message.IMessage message = BusinessMessage.CreateMessage(Puppy.Model.Business.BusinessLocale.th_TH);

            ExecuteModel model = new ExecuteModel {
                FileName         = "D:\\Courses\\AspnetCore\\MyConcert\\MyConcert.BLL\\bin\\Debug\\netstandard2.0\\MyConcert.BLL.dll",
                ClassName        = "MyConcert.BLL.ConcertBLL",
                MethodName       = "Add",
                InitParameter    = config,
                ExecuteParameter = aBook,
                Message          = message,
                UaString         = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3"
            };
            Result result = (Result)facade.ExecutionFlow(model);
            //InfoLog(result.Message);
        }
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="executeModel"></param>
 /// <returns></returns>
 public Task <int> Update(ExecuteModel executeModel)
 {
     return(Task.FromResult(this.Logic.Update(executeModel)));
 }
 /// <summary>
 /// 查询一个model数据
 /// </summary>
 /// <param name="executeModel"></param>
 /// <returns></returns>
 public Task <object> GetModel(ExecuteModel executeModel)
 {
     return(Task.FromResult(this.Logic.GetModel(executeModel)));
 }
 /// <summary>
 /// 查询分页列表
 /// </summary>
 /// <param name="executeModel"></param>
 /// <returns></returns>
 public Task <RIPListPageModel> GetModelPageList(ExecuteModel executeModel)
 {
     return(Task.FromResult(this.Logic.GetModelPageList(executeModel)));
 }
 /// <summary>
 /// 检查记录是否存在
 /// </summary>
 /// <param name="executeModel"></param>
 /// <returns></returns>
 public Task <bool> Exists(ExecuteModel executeModel)
 {
     return(Task.FromResult(this.Logic.Exists(executeModel)));
 }