예제 #1
0
        public void ChangerQuestion()
        {
            rbA.Checked = true;
            if (Indexs.Count != 0)
            {
                Index = Indexs[r.Next(Indexs.Count)];
                Indexs.Remove(Index);

                numQuestion.Text = (19 - Indexs.Count()).ToString();

                TestFrage question = Questions[Index];
                rbA.Text                  = question.Reponses[0];
                rbB.Text                  = question.Reponses[1];
                rbC.Text                  = question.Reponses[2];
                rbD.Text                  = question.Reponses[3];
                questionLabel.Text        = question.Question;
                pictureBox1.ImageLocation = question.Image;
            }
            else
            {
                Index = -1;
                double score = CptPoints * 20 / sommePoids;
                scoreLabel.Text = "" + score + " / 20";
            }
        }
        /// <summary>
        /// 添加指标分解表
        /// </summary>
        /// <param name="indexs"></param>
        /// <returns></returns>
        public int GoalIndexsAdd(Indexs indexs)
        {
            context.Indexs.Add(indexs);
            int i = context.SaveChanges();

            return(i);
        }
예제 #3
0
        public void Add(DataTable table)
        {
            int index = Values.Count;

            Values.Add(table);
            Indexs.Add(table.TableName, index);
        }
예제 #4
0
 private void InitListeIndex()
 {
     for (int i = 0; i < 19; i++)
     {
         Indexs.Add(i);
     }
 }
예제 #5
0
        protected EntityGeneralPipeline(Schema schema, JObject entityDefine, string connectString)
        {
#if NET_CORE
            Logger.Info($"Db ConnectString: {connectString}", true);
#endif

            ConnectString = connectString;

            Schema  = GenerateSchema(schema);
            Columns = entityDefine.SelectTokens("$.Fields[*]").Select(j => j.ToObject <Column>()).ToList();

            Primary       = entityDefine.SelectToken("$.Primary").ToObject <List <string> >();
            AutoIncrement = entityDefine.SelectToken("$.AutoIncrement")?.ToString();
            foreach (var index in entityDefine.SelectTokens("$.Indexs[*]"))
            {
                Indexs.Add(index.ToObject <List <string> >());
            }

            foreach (var index in entityDefine.SelectTokens("$.Uniques[*]"))
            {
                Uniques.Add(index.ToObject <List <string> >());
            }

            Type = GenerateType(schema, Columns);
            Logger.Info($"TYPE-> Name: {Type.Name} Properties: [{Type.GetProperties().Select(p=>p.Name)}]");
        }
예제 #6
0
        public IList <T> ExtractElementsAt <T>(IList <T> data, params int[] Indexs)
        {
            IList <T> result = new List <T>();
            int       index  = 0;

            foreach (var item in data)
            {
                if (Indexs.Contains(index++))
                {
                    result.Add(item);
                }
            }
            return(result);
        }
        protected EntityGeneralPipeline(Schema schema, Entity entityDefine, string connectString, PipelineMode mode = PipelineMode.Insert)
        {
            Mode          = mode;
            ConnectString = connectString;

            Schema  = GenerateSchema(schema);
            Columns = entityDefine.Fields.Where(f => f.DataType != null).ToList();
            var primary = entityDefine.Primary;

            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (mode == PipelineMode.Update && entityDefine.Updates != null)
            {
                foreach (var column in entityDefine.Updates)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == column);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as update is not a property of your entity.");
                    }
                    else
                    {
                        UpdateColumns.Add(col);
                    }
                }
                if (UpdateColumns == null || UpdateColumns.Count == 0)
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));
                }
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderExceptoin("Do you forget set the Primary in IndexesAttribute for your entity class.");
                }
            }

            AutoIncrement = entityDefine.AutoIncrement;

            if (entityDefine.Indexes != null)
            {
                foreach (var index in entityDefine.Indexes)
                {
                    List <string> tmpIndex = new List <string>();
                    foreach (var i in index)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as index is not a property of your entity.");
                        }
                        else
                        {
                            tmpIndex.Add(col.Name);
                        }
                    }
                    if (tmpIndex.Count != 0)
                    {
                        Indexs.Add(tmpIndex);
                    }
                }
            }
            if (entityDefine.Uniques != null)
            {
                foreach (var unique in entityDefine.Uniques)
                {
                    List <string> tmpUnique = new List <string>();
                    foreach (var i in unique)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as unique is not a property of your entity.");
                        }
                        else
                        {
                            tmpUnique.Add(col.Name);
                        }
                    }
                    if (tmpUnique.Count != 0)
                    {
                        Uniques.Add(tmpUnique);
                    }
                }
            }
        }
        public override void InitiEntity(EntityMetadata metadata)
        {
            if (metadata.Schema == null)
            {
                Spider.Log("Schema is necessary", LogLevel.Warn);
                IsEnabled = false;
                return;
            }
            Schema = GenerateSchema(metadata.Schema);
            foreach (var f in metadata.Entity.Fields)
            {
                if (!string.IsNullOrEmpty(((Field)f).DataType))
                {
                    Columns.Add((Field)f);
                }
            }
            if (Columns.Count == 0)
            {
                Spider.Log("Columns is necessary", LogLevel.Warn);
                IsEnabled = false;
                return;
            }
            var primary = metadata.Primary;

            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderException("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (Mode == PipelineMode.Update)
            {
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderException("Set Primary in the Indexex attribute.");
                }

                if (metadata.Updates != null && metadata.Updates.Count > 0)
                {
                    foreach (var column in metadata.Updates)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == column);
                        if (col == null)
                        {
                            throw new SpiderException("Columns set as update is not a property of your entity.");
                        }
                        else
                        {
                            UpdateColumns.Add(col);
                        }
                    }

                    UpdateColumns.RemoveAll(c => Primary.Contains(c));

                    if (UpdateColumns.Count == 0)
                    {
                        throw new SpiderException("There is no column need update.");
                    }
                }
                else
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));

                    if (UpdateColumns.Count == 0)
                    {
                        throw new SpiderException("There is no column need update.");
                    }
                }
            }

            AutoIncrement = metadata.AutoIncrement;

            if (metadata.Indexes != null)
            {
                foreach (var index in metadata.Indexes)
                {
                    List <string> tmpIndex = new List <string>();
                    foreach (var i in index)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderException("Columns set as index is not a property of your entity.");
                        }
                        else
                        {
                            tmpIndex.Add(col.Name);
                        }
                    }
                    if (tmpIndex.Count != 0)
                    {
                        Indexs.Add(tmpIndex);
                    }
                }
            }
            if (metadata.Uniques != null)
            {
                foreach (var unique in metadata.Uniques)
                {
                    List <string> tmpUnique = new List <string>();
                    foreach (var i in unique)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderException("Columns set as unique is not a property of your entity.");
                        }
                        else
                        {
                            tmpUnique.Add(col.Name);
                        }
                    }
                    if (tmpUnique.Count != 0)
                    {
                        Uniques.Add(tmpUnique);
                    }
                }
            }
        }
        public async Task <IActionResult> GoalSubmit([FromForm] IFormCollection formData, GoalBaseData baseData)
        {
            //添加目标表
            var goal = new Goal()
            {
                GoalName           = baseData.GoalName,
                RoleId             = baseData.RoleId,
                GoalTypeId         = baseData.GoalTypeId,
                FrequencyId        = baseData.FrequencyId,
                IndexLevelId       = baseData.IndexLevelId,
                GoalStartTime      = baseData.GoalStartTime,
                GoalEndTime        = baseData.GoalEndTime,
                GoalWeight         = baseData.GoalWeight,
                Goal_DutyUserId    = baseData.Goal_DutyUserId,
                Goal_DutyCommanyId = baseData.Goal_DutyCommanyId,
                Goal_ParentId      = baseData.Goal_ParentId,
                BusinessState      = 0,
                FeedbackId         = 1,
                FileId             = 0,
                GoalCreateTime     = Convert.ToDateTime(DateTime.Now.ToString("yyyy MM dd")),
                GoalFormula        = baseData.GoalFormula,
                GoalPeriod         = baseData.GoalPeriod,
                GoalSources        = baseData.GoalSources,
                GoalInformant      = RedisHelper.Get("username"),
                GoalChargePeople   = "admin",
                GoalOrganiser      = baseData.GoalOrganiser,
                GoalUnit           = DateTime.Now.ToString("yyyy MM dd"),
                GoalStateId        = 4,
            };
            string auditValue = baseData.AuditValue;                                             //获取到审核人id
            var    goaldata   = JsonConvert.SerializeObject(goal);
            var    goalId     = HelperHttpClient.GetAll("post", "GoalManage/GoalAdd", goaldata); //添加成功返回自增长id

            //添加到配置表
            ApprconfigurationDto apprconfigurationDto = new ApprconfigurationDto();

            apprconfigurationDto.AuditValue = auditValue;
            apprconfigurationDto.GoalId     = int.Parse(goalId);
            AddrConfiguration(apprconfigurationDto);

            //添加进展表
            Feedback feedback = new Feedback();

            feedback.GoalId                    = int.Parse(goalId);
            feedback.StateId                   = 1;
            feedback.FeedbackWorkEvolve        = "未启动";
            feedback.FeedbackDayEvolve         = "完成0%";
            feedback.FeedbackQuestion          = "无问题";
            feedback.FeedbackMeasure           = "无";
            feedback.FeedbackCoordinateMatters = "无";
            feedback.FeedbackNowEvolve         = 0;
            AddFeedBack(feedback);

            //添加指标分解表
            Indexs indexs = new Indexs();

            indexs.IndexsJanuary    = baseData.IndexsJanuary;
            indexs.IndexsFebruary   = baseData.IndexsFebruary;
            indexs.IndexsMarch      = baseData.IndexsMarch;
            indexs.IndexsApril      = baseData.IndexsApril;
            indexs.IndexsMay        = baseData.IndexsMay;
            indexs.IndexsJune       = baseData.IndexsJune;
            indexs.IndexsJuly       = baseData.IndexsJuly;
            indexs.IndexsAugust     = baseData.IndexsAugust;
            indexs.IndexsSeptember  = baseData.IndexsSeptember;
            indexs.IndexsOctober    = baseData.IndexsOctober;
            indexs.IndexsNovember   = baseData.IndexsNovember;
            indexs.IndexsYearTarget = baseData.IndexsYearTarget;
            indexs.GoalId           = int.Parse(goalId);
            indexs.IndexsCreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy MM dd"));
            var index = HelperHttpClient.GetAll("post", "GoalManage/GoalIndexsAdd", indexs);

            //上传文件
            IFormFileCollection files = formData.Files;
            long size = files.Sum(f => f.Length);
            var  i    = "";

            foreach (var item in files)
            {
                var inputName = item.Name;
                var filePath  = "Common/UpdateFiles/" + item.FileName.Substring(item.FileName.LastIndexOf("\\") + 1);
                if (item.Length > 0)
                {
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        await item.CopyToAsync(stream);
                    }
                }
                var file = new Files()
                {
                    FileName   = item.FileName,
                    FileUrl    = filePath,
                    CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy MM dd")),
                    GoalId     = int.Parse(goalId),
                };
                i = HelperHttpClient.GetAll("post", "GoalManage/GoalFileAdd", file);
            }
            return(Json("目标下达成功,望督促按时完成任务!"));
        }
예제 #10
0
 public void Clear()
 {
     Values.Clear();
     Indexs.Clear();
 }
예제 #11
0
 public bool ContainsTable(string tableName)
 {
     return(Indexs.ContainsKey(tableName));
 }
예제 #12
0
        protected EntityGeneralPipeline(Schema schema, JObject entityDefine, string connectString, PipelineMode mode = PipelineMode.Insert)
        {
            Mode          = mode;
            ConnectString = connectString;

            Schema  = GenerateSchema(schema);
            Columns = entityDefine.SelectTokens("$.Fields[*]").Select(j => j.ToObject <Column>()).Where(c => !string.IsNullOrEmpty(c.DataType)).ToList();
            var primary = entityDefine.SelectToken("$.Primary")?.ToObject <List <string> >();

            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (mode == PipelineMode.Update)
            {
                var tmpUpdateColumns = entityDefine.SelectTokens("$.Update[*]").Select(u => u.ToString()).ToList();
                foreach (var column in tmpUpdateColumns)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == column);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as update is not a property of your entity.");
                    }
                    else
                    {
                        UpdateColumns.Add(col);
                    }
                }
                if (UpdateColumns == null || UpdateColumns.Count == 0)
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));
                }
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderExceptoin("Do you forget set the Primary in IndexesAttribute for your entity class.");
                }
            }

            AutoIncrement = entityDefine.SelectToken("$.AutoIncrement")?.ToString();

            foreach (var index in entityDefine.SelectTokens("$.Indexs[*]"))
            {
                List <string> tmpIndex = new List <string>();
                foreach (var i in index.ToObject <List <string> >())
                {
                    var col = Columns.FirstOrDefault(c => c.Name == i);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as index is not a property of your entity.");
                    }
                    else
                    {
                        tmpIndex.Add(col.Name);
                    }
                }
                if (tmpIndex.Count != 0)
                {
                    Indexs.Add(tmpIndex);
                }
            }

            foreach (var unique in entityDefine.SelectTokens("$.Uniques[*]"))
            {
                List <string> tmpUnique = new List <string>();
                foreach (var i in unique.ToObject <List <string> >())
                {
                    var col = Columns.FirstOrDefault(c => c.Name == i);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as unique is not a property of your entity.");
                    }
                    else
                    {
                        tmpUnique.Add(col.Name);
                    }
                }
                if (tmpUnique.Count != 0)
                {
                    Uniques.Add(tmpUnique);
                }
            }
        }
예제 #13
0
        public int GoalIndexsAdd([FromBody] Indexs indexs)
        {
            int i = iGoalManageRepository.GoalIndexsAdd(indexs);

            return(i);
        }
예제 #14
0
 public Table AddIndex(string name, string expression)
 {
     Indexs.Add(new Index(name, expression));
     return(this);
 }
예제 #15
0
 public Table AddIndex(Index index)
 {
     Indexs.Add(index);
     return(this);
 }