Exemple #1
0
        /// <summary>
        /// Request the list of direct message from Twitter using the token and the URL given in parameter
        /// Handle the exception when the token represents a user who did not authorize the application to get the direct messages
        /// </summary>
        /// <param name="token"></param>
        /// <param name="url"></param>
        /// <param name="directMessageDelegate"></param>
        /// <returns>The list of messages retrieved from the Twitter API</returns>
        private List <IMessage> GetDirectMessages(IToken token,
                                                  string url,
                                                  ObjectCreatedDelegate <IMessage> directMessageDelegate = null)
        {
            token = GetQueryToken(token);

            if (token == null || url == null)
            {
                throw new ArgumentException("token or request url is null");
            }

            WebExceptionHandlingDelegate webExceptionDelegate = delegate(WebException wex)
            {
                int?wexStatusNumber = ExceptionUtils.GetWebExceptionStatusNumber(wex);
                if (wexStatusNumber == null)
                {
                    throw wex;
                }

                switch (wexStatusNumber)
                {
                case 403:
                    Exception e = new Exception("Not enough permission to access direct messages. " +
                                                "Update the application access level and ask the user to reauthorize it.");
                    throw e;

                default:
                    throw wex;
                }
            };

            return(ResultGenerator.GetMessages(token, url, directMessageDelegate, webExceptionDelegate));
        }
Exemple #2
0
        /// <summary>
        /// Get the Home timeline of the current user
        /// </summary>
        /// <param name="queryToken">Token to be used to perform the query</param>
        /// <param name="count">Maximum number of Tweet received</param>
        /// <param name="trim_user">User information sent with the Tweet</param>
        /// <param name="exclude_replies">When true the replies to tweet are not retrieved</param>
        /// <param name="since_id">Minimum Id of tweet to receive</param>
        /// <param name="max_id">Maximum Id of twee to receive</param>
        /// <param name="wex">Exception handler</param>
        /// <returns>Tweets from the Home timeline</returns>
        private List <ITweet> GetHomeTimeLine(
            IToken queryToken,
            int count,
            bool trim_user,
            bool exclude_replies,
            int?since_id,
            int?max_id,
            WebExceptionHandlingDelegate wex)
        {
            if (queryToken == null)
            {
                Console.WriteLine("Token must be specified");
                return(null);
            }

            string query;

            if (since_id == null && max_id == null)
            {
                query = String.Format(Resources.TokenUser_GetLatestHomeTimeline, count, trim_user, exclude_replies);
            }
            else
            {
                query = String.Format(Resources.TokenUser_GetHomeTimeline,
                                      count, trim_user, exclude_replies, since_id, max_id);
            }

            return(ResultGenerator.GetTweets(queryToken, query, null, wex));
        }
Exemple #3
0
        public async void Generete_Test()
        {
            List <string> expectedData = new List <string>
            {
                @"f\bla\ra\t.dat",
                @"books\csharp\csharp.pdf",
                @"proj\tools\utils.cpp",
                @"proj\timer\main.cpp"
            };

            int expectedLength = 4;

            IDirectory iDirectory = Substitute.For <IDirectory>();

            iDirectory.GetFilesAsync("", SearchOption.AllDirectories).Returns(expectedData);

            IFileFilter iFileFilter = Substitute.For <IFileFilter>();

            iFileFilter.GetFilteredFiles(iDirectory).Returns(expectedData.ToArray());


            ResultGenerator resultGenerator = new ResultGenerator(iDirectory, iFileFilter);
            IStreamWriter   actual          = await resultGenerator.Generate();


            Assert.Equal(expectedLength, actual.Data.Length);
            Assert.Equal(expectedData.ToArray(), actual.Data);
        }
Exemple #4
0
    private void Awake()
    {
        YouLose.gameObject.SetActive(false);
        InstanceCache.Flush();

        gameRepository   = InstanceCache.GetOrInstanciate <InMemoryGameRepository>(() => new InMemoryGameRepository());
        resultRepository = InstanceCache.GetOrInstanciate <InMemoryResultRepository>(() => new InMemoryResultRepository());
        scoreService     = InstanceCache.GetOrInstanciate <LocalScoreService>(() => new LocalScoreService());
        resultRepository.Clear();
        gameRepository.Clear();
        scoreService.Reset();

        gamePresenter = InstanceCache.GetOrInstanciate <GamePresenter>(
            () => {
            resultGenerator = new ResultGenerator(4, new AdditionOperator(), new RandomNumberGenerator(5, 15));
            return(new GamePresenter(
                       this,
                       new CreateGame(gameRepository,
                                      new FixedInitialNumber(),
                                      resultGenerator,
                                      resultRepository),
                       new Guess(gameRepository, resultRepository, resultGenerator, scoreService),
                       scoreService));
        });
    }
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (context.Controller is Controller controller && !controller.ModelState.IsValid)
     {
         context.Result = ResultGenerator.GetInvalidModelStateErrorResponse(controller.ModelState);
     }
     base.OnActionExecuting(context);
 }
Exemple #6
0
        private static async Task GenerateResultToFile()
        {
            IDirectory  iDirectory  = new FileManager(startDirectory);
            IFileFilter iFileFilter = new FilterManager(filterBy);

            ResultGenerator resultGenerator = new ResultGenerator(iDirectory, iFileFilter);
            IStreamWriter   sWriter         = await resultGenerator.Generate();

            sWriter.WriteToFile(resultFile);
        }
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (!context.ModelState.IsValid)
     {
         var(result, code) = ResultGenerator.GetInvalidModelStateErrorResponse(context.ModelState);
         context.Result    = result;
         context.HttpContext.Response.StatusCode = (int)code;
     }
     base.OnActionExecuting(context);
 }
        private async Task Init(Person per)
        {
            ResultList = new List <Result>();
            var listResults = new List <Result>();

            listResults = await ResultGenerator.CreateResults(per);

            ResultList     = listResults;
            BindingContext = this;
        }
Exemple #9
0
 public CreateGame(GameRepository gameRepository,
                   InitialNumberGenerator initialNumberGenerator,
                   ResultGenerator resultGenerator,
                   IResultRepository resultRepository)
 {
     this.gameRepository         = gameRepository;
     this.initialNumberGenerator = initialNumberGenerator;
     this.resultGenerator        = resultGenerator;
     this.resultRepository       = resultRepository;
 }
Exemple #10
0
 public Guess(GameRepository gameRepository,
              IResultRepository resultRepository,
              ResultGenerator resultGenerator,
              ScoreService scoreService)
 {
     this.gameRepository   = gameRepository;
     this.resultRepository = resultRepository;
     this.resultGenerator  = resultGenerator;
     this.scoreService     = scoreService;
 }
Exemple #11
0
        protected PrintTestRunner TestRunnerFactory(string caseName, IProfile settings)
        {
            var engine          = new EngineFFF();
            var resultGenerator = new ResultGenerator(engine, new ConsoleLogger())
            {
                Settings = settings
            };
            var resultAnalyzer = new ResultAnalyzer <FeatureInfo>(new FeatureInfoFactoryFFF());

            return(new PrintTestRunner(caseName, resultGenerator, resultAnalyzer));
        }
        public async Task <IActionResult> PasswordAuth(PasswordAuthAddressModel model)
        {
            var app = (await _apiService.AppInfoAsync(model.AppId)).App;

            if (app == null)
            {
                return(NotFound());
            }
            var mail = await _dbContext
                       .UserEmails
                       .Include(t => t.Owner)
                       .SingleOrDefaultAsync(t => t.EmailAddress == model.Email);

            if (mail == null)
            {
                ModelState.AddModelError(string.Empty, "Unknown user email.");
                return(ResultGenerator.GetInvalidModelStateErrorResponse(ModelState));
            }
            var user   = mail.Owner;
            var result = await _signInManager.PasswordSignInAsync(user, model.Password, isPersistent : false, lockoutOnFailure : true);

            if (result.Succeeded)
            {
                OAuthPack pack = null;
                if (await user.HasAuthorizedApp(_dbContext, model.AppId))
                {
                    pack = await user.GeneratePack(_dbContext, model.AppId);
                }
                else
                {
                    await user.GrantTargetApp(_dbContext, model.AppId);

                    pack = await user.GeneratePack(_dbContext, model.AppId);
                }
                return(Json(new AiurValue <int>(pack.Code)
                {
                    Code = ErrorType.Success,
                    Message = "Auth success."
                }));
            }
            else if (result.RequiresTwoFactor)
            {
                throw new NotImplementedException();
            }
            else if (result.IsLockedOut)
            {
                throw new NotImplementedException();
            }
            else
            {
                return(this.Protocal(ErrorType.Unauthorized, "Wrong password!"));
            }
        }
        public void FindLap_When_Valid_File()
        {
            var mock = new List <string>();

            mock.Add("23:49:08.277      038 – F.MASSA                           1		1:02.852                        44,275");

            _fileReader.GetLines(Arg.Any <string>()).Returns(mock);
            var service = new ResultGenerator(_fileReader);
            var result  = service.FindLap(38);

            result.Racer.Name.Should().Be("F.MASSA");
        }
Exemple #14
0
    // Use this for initialization
    void Start()
    {
        Vector3 playerLoc = new Vector3(4.0f, -15.96f, (Ysize * 15) - 5.0f); //sets the players inital start location

        player.transform.position = playerLoc;
        buildRoomLists();                                                   //build the lists of parts which contain the same sizes
        if (Ysize == 1)                                                     // if the Y size is 1 set it to 2, to retain robustness
        {
            Debug.Log("one Wide buildings cant be produced; producing a 2 Wide building");
            Ysize = 2;
        }
        ResultGenerator results = new ResultGenerator(Xsize, Ysize);        //create new result generator object

        //loop to produce the data structures
        for (int i = 0; i < height; i++)                                       //for every floor
        {
            results.startTime.Add(System.DateTime.Now);                        //add the start time to the results
            GameObject floor        = new GameObject("floor" + i);             //create the object which holds all the floors parts
            Floor      cur_floor    = new Floor(Xsize, Ysize, i, splitChance); //create a new floor
            int        rndFloorType = Random.Range(0, RoomTypes.Count);        //get the floor type
            cur_floor.setType(rndFloorType);                                   //set the floor type
            cur_floor.buildLayout(splitChance);                                //divide the floor into a layout
            cur_floor.setRoomTypes(typeChance);                                //set the type for every room
            cur_floor.SetEntrance(i, FillStairSpace, height);                  //add the entrance
            cur_floor.SetExit(i, FillStairSpace, height);                      //add the exit
            cur_floor.buildGraph();                                            //build the graph from the floor
            setRandomEdges(cur_floor);                                         //open up some new random doorways
            path(cur_floor);                                                   //create doors via the path
            buildingFloors.Add(cur_floor);                                     //add the floor to the building
            results.endTime.Add(System.DateTime.Now);                          //add the end time to the results
            if (evaluate == true)
            {
                results.addResults(cur_floor);
            }                                                                                         //add the results of the floor
        }
        var InitTime = System.DateTime.Now;

        addStart();                                                         //add the start room
        addGoal();                                                          //add the goal room
        for (int i = 0; i < height; i++)
        {
            Floor cur_floor    = buildingFloors[i];                         //get the current floor
            int   rndFloorType = cur_floor.getType();                       //get the current floors type
            populate(cur_floor, rndFloorType);                              //create a 3d model in relation to the current floor
            addStairs(cur_floor);                                           //add the stairs to the floor
            PhysicalFloors.Add(GameObject.Find("floor" + i));               //add the floor game object  to a list, used for culling
        }
        var endtime = System.DateTime.Now;

        results.calc();                                                     //calculate results
        System.TimeSpan timespan = endtime - InitTime;
        Debug.Log(timespan.TotalMilliseconds);
    }
Exemple #15
0
        /// <summary>
        /// Update the exception handler attribute with the 3rd parameter
        /// Get the list of users matching the Twitter request url (contributors or contributees)
        /// </summary>
        /// <param name="token"> Current user token to access the Twitter API</param>
        /// <param name="url">Twitter requets URL</param>
        /// <param name="exceptionHandlerDelegate">Delegate method to handle Twitter request exceptions</param>
        /// <returns>Null if the token parameter is null or if the Twitter request fails. A list of users otherwise (contributors or contributees).</returns>
        private List <IUser> GetContributionObjects(IToken token, String url,
                                                    WebExceptionHandlingDelegate exceptionHandlerDelegate = null)
        {
            token = GetQueryToken(token);

            if (token == null)
            {
                Console.WriteLine("User's token is required");
                return(null);
            }

            return(ResultGenerator.GetUsers(token, url, null, exceptionHandlerDelegate));
        }
        public void GetAllLaps_When_Valid_File()
        {
            //arrange
            var mock = new List <string>();

            mock.Add("23:49:08.277      038 – F.MASSA                           1		1:02.852                        44,275");

            _fileReader.GetLines(Arg.Any <string>()).Returns(mock);
            var service = new ResultGenerator(_fileReader);
            //action
            var result = service.GetAllLaps();

            result.First().Racer.Name.Should().Be("F.MASSA");
            //assert
            result.Should().NotBeNull();
        }
Exemple #17
0
        public void ExpectFailure <ExceptionType>(GenericRepRapSettings settings) where ExceptionType : Exception
        {
            // Arrange
            var engine          = new EngineFFF();
            var resultGenerator = new ResultGenerator(engine, new ConsoleLogger())
            {
                Settings = settings
            };
            var resultAnalyzer = new ResultAnalyzer <FeatureInfo>(new FeatureInfoFactoryFFF());
            var print          = new PrintTestRunner(CaseName, resultGenerator, resultAnalyzer);

            // Act
            print.GenerateFile();

            // Assert
            Assert.ThrowsException <ExceptionType>(() =>
            {
                print.CompareResults();
            });
        }
Exemple #18
0
        private List <ITweet> GetFavourites(string query, int count, IToken token)
        {
            token = GetQueryToken(token);

            if (token == null || count <= 0 || (_id == null && _screen_name == null))
            {
                return(null);
            }

            // Updating the query to have the appropriate user name/id
            AddUserInformationInQuery(ref query);

            ObjectCreatedDelegate <ITweet> tweetCreated = delegate(ITweet tweet)
            {
                // Set the value of the objectToken depending of the context
                tweet.ObjectToken = _shareTokenWithChild ? this._token : null;
            };

            return(ResultGenerator.GetTweets(token, query, tweetCreated, null));
        }
Exemple #19
0
        public List <IMention> GetLatestMentionsTimeline(int count = 20)
        {
            string query = String.Format(Resources.TokenUser_GetLatestMentionTimeline, count);

            WebExceptionHandlingDelegate wexDelegate = delegate(WebException wex)
            {
                int?wexStatusNumber = ExceptionUtils.GetWebExceptionStatusNumber(wex);
                switch (wexStatusNumber)
                {
                case 400:
                    throw new WebException("Wrong token for user id = " + this.Id, wex);

                default:
                    throw wex;
                }
            };

            LatestMentionsTimeline = ResultGenerator.GetMentions(_token, query, null, wexDelegate);
            return(LatestMentionsTimeline);
        }
 private void resultGenerateButton_Click(object sender, EventArgs e)
 {
     ResultGenerator.GenerateResult();
     MessageBox.Show("Updated Result Generated. Go to Manage Candidates to see seat-wise obtained votes. Go to Teams to see total obtained seats of each team.");
 }
 private void GivenAResultGenerator()
 {
     resultGenerator = new ResultGenerator(QUANTITY, new AdditionOperator(), new RandomNumberGenerator(START, ENDS));
 }
Exemple #22
0
        static async Task Main(string[] args)
        {
            var userSelection             = new LottoSelection();
            var ballSelectionMessage      = $"Enter {LottoSelection.BallCount} ball numbers between 1 and 50, separated by a comma, or simply press ENTER key for lucky dip";
            var powerBallSelectionMessage = $"Enter {LottoSelection.PowerBallCount} powerball numbers between 1 and 8, separated by a comma";

            Console.WriteLine(ballSelectionMessage);

            var firstInput = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(firstInput))
            {
                userSelection = LottoSelector.GenerateSelection();
                Console.WriteLine(userSelection);
            }
            else
            {
                var ballNumbers = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);
                while (!InputValidator.TryValidateInput(ballNumbers, LottoSelection.BallCount, 50, out string error))
                {
                    Console.WriteLine(error);
                    Console.WriteLine(ballSelectionMessage);
                    ballNumbers = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);
                }

                userSelection.Balls[0] = int.Parse(ballNumbers[0]);
                userSelection.Balls[1] = int.Parse(ballNumbers[1]);
                userSelection.Balls[2] = int.Parse(ballNumbers[2]);
                userSelection.Balls[3] = int.Parse(ballNumbers[3]);
                userSelection.Balls[4] = int.Parse(ballNumbers[4]);

                Console.WriteLine(powerBallSelectionMessage);

                var powerballNumbers = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);

                while (!InputValidator.TryValidateInput(powerballNumbers, 2, 8, out string error))
                {
                    Console.WriteLine(error);
                    Console.WriteLine(powerBallSelectionMessage);
                    powerballNumbers = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);
                }

                userSelection.PowerBalls[0] = int.Parse(powerballNumbers[0]);
                userSelection.PowerBalls[1] = int.Parse(powerballNumbers[1]);
            }

            Console.WriteLine("Now enter the number of attempts you would like to try");
            var numOfTimes = Console.ReadLine().Trim();

            while (!int.TryParse(numOfTimes, out _))
            {
                Console.WriteLine("Please enter a whole number. Enter the number of attempts you would like to try");
                numOfTimes = Console.ReadLine();
            }
            var attempts = int.Parse(numOfTimes);

            var test    = new ResultGenerator();
            var results = await test.GenerateResults(attempts);

            var win = LottoChecker.CheckResults(userSelection, results);

            var winString = win ? "won" : "didn't win";

            Console.WriteLine($"Out of {string.Format("{0:n0}", attempts)} attempts, you {winString} the jackpot.");

            var stats = StatsBuilder.BuildMatchedStatistics(results);

            Console.WriteLine(stats);

            Console.Read();
        }
Exemple #23
0
        public List <ITweet> GetLatestHomeTimeline(int count = 40)
        {
            string query = String.Format(Resources.TokenUser_GetLatestHomeTimeline, count, true, true);

            return(ResultGenerator.GetTweets(_token, query));
        }
        public void Constructor_When_Valid_Parameter()
        {
            var result = new ResultGenerator(_fileReader);

            result.Should().NotBeNull();
        }
Exemple #25
0
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="listVW_DIME_RESULT"></param>
        /// <returns></returns>
        public static Dictionary <string, List <string> > batchUpdate(List <VW_DIME_RESULT> listVW_DIME_RESULT, List <BCD_ITEMQUALDESC> listALLBCD_ITEMQUALDESC, List <BCD_ITEM> listALLBCD_ITEM)
        {
            BCB_CHECKSUBBLL        bCB_CHECKSUBBLL        = new BCB_CHECKSUBBLL();
            BCB_CHECKFLOWBLL       bCB_CHECKFLOWBLL       = new BCB_CHECKFLOWBLL();
            BCD_GROUPBLL           bCD_GROUPBLL           = new BCD_GROUPBLL();
            BCD_ITEMBLL            bCD_ITEMBLL            = new BCD_ITEMBLL();
            BCB_GROUPCONCLUSIONBLL bCB_GROUPCONCLUSIONBLL = new BCB_GROUPCONCLUSIONBLL();
            var queryByCheckCode = (from p in listVW_DIME_RESULT group p by p.CHECKCODE into g select g).ToList();
            Dictionary <string, List <string> > dicResult = new Dictionary <string, List <string> >();//key为小组GUID,value为体检编号

            foreach (var item in queryByCheckCode)
            {
                BCB_CHECKMAIN bCB_CHECKMAIN = new BCB_CHECKMAINBLL().GetBy(a => a.CHECKCODE == item.Key);
                List <string> listGROUPGUID = new List <string>();
                int           completeTag   = 0;
                if (bCB_CHECKMAIN != null)
                {
                    int.TryParse(bCB_CHECKMAIN.COMPLETETAG, out completeTag);
                }
                if (bCB_CHECKMAIN == null || completeTag > 1)
                {
                    Console.WriteLine(string.Format("未查询到编号为:{0}的人员信息", item.Key));
                    continue;
                }
                List <BCB_CHECKFLOW> listBCB_CHECKFLOW = bCB_CHECKFLOWBLL.GetListBy(u => u.MAINGUID == bCB_CHECKMAIN.GUID);
                if (listBCB_CHECKFLOW.Count > 0)
                {
                    for (int i = 0; i < listBCB_CHECKFLOW.Count; i++)
                    {
                        string groupGUID = listBCB_CHECKFLOW[i].GROUPGUID;
                    }
                }
                foreach (VW_DIME_RESULT vw_dime_result in item.ToList())
                {
                    int itemId = 0;
                    int.TryParse(vw_dime_result.ITEMEID, out itemId);
                    if (itemId != 0)
                    {
                        BCD_ITEM bCD_ITEM = listALLBCD_ITEM.Where(u => u.ID == itemId).FirstOrDefault();
                        //= new BCD_ITEMBLL().GetBy(a => a.ID == itemId);

                        //if (bCD_ITEM!=null&&listRevertBCB_CHECKFLOW.Where(u => u.GROUPGUID == bCD_ITEM.GROUPGUID).Count() > 0)
                        //{
                        //    continue;
                        //}
                        BCB_CHECKSUB bCB_CHECKSUB = bCB_CHECKSUBBLL.GetBy(a => a.ITEMGUID == bCD_ITEM.GUID && a.MAINGUID == bCB_CHECKMAIN.GUID);
                        if (bCB_CHECKSUB == null)
                        {
                            continue;
                        }
                        BCB_CHECKFLOW bCB_CHECKFLOW = bCB_CHECKFLOWBLL.GetBy(a => a.MAINGUID == bCB_CHECKMAIN.GUID && a.GROUPGUID == bCB_CHECKSUB.GROUPGUID);
                        if (bCB_CHECKFLOW == null)
                        {
                            Console.WriteLine(string.Format("未查询到主表GUID为{0},小组GUID为{1}的流程表信息", bCB_CHECKMAIN.GUID, bCB_CHECKSUB.GROUPGUID));
                            continue;
                        }
                        if (bCB_CHECKFLOW.COMPLETETAG == "1" && vw_dime_result.cp_uncheckflag == 0)
                        {
                            continue;
                        }

                        if (bCB_CHECKSUB != null)
                        {
                            if (!listGROUPGUID.Contains(bCB_CHECKFLOW.GROUPGUID))
                            {
                                listGROUPGUID.Add(bCB_CHECKFLOW.GROUPGUID);
                            }
                            if (!dicResult.ContainsKey(bCB_CHECKFLOW.GROUPGUID))
                            {
                                dicResult.Add(bCB_CHECKFLOW.GROUPGUID, new List <string> {
                                    item.Key
                                });
                            }
                            else if (!dicResult[bCB_CHECKFLOW.GROUPGUID].Contains(item.Key))
                            {
                                dicResult[bCB_CHECKFLOW.GROUPGUID].Add(item.Key);
                            }
                            bCB_CHECKSUB.RESULT = vw_dime_result.RESULT;
                            double result = 0;
                            if (double.TryParse(bCB_CHECKSUB.RESULT, out result))
                            {
                                //定量
                                bCB_CHECKSUB.PASSTAG = (result >= bCB_CHECKSUB.REFVALMIN && result <= bCB_CHECKSUB.REFVALMAX) ? "1" : "0";
                            }
                            else
                            {
                                //定性
                                List <BCD_ITEMQUALDESC> listBCD_ITEMQUALDESC = new BCD_ITEMQUALDESCBLL().GetListBy(u => u.ITEMGUID == bCB_CHECKSUB.ITEMGUID && u.PASS == "1");
                                bCB_CHECKSUB.PASSTAG = "0";
                                foreach (var description in listBCD_ITEMQUALDESC)
                                {
                                    if (description.DESCRIPTION == bCB_CHECKSUB.RESULT)
                                    {
                                        bCB_CHECKSUB.PASSTAG = "1";
                                        break;
                                    }
                                }
                            }
                            bCB_CHECKSUB.DOCTORNAME        = vw_dime_result.DOCTORNAME;
                            bCB_CHECKSUB.DATECHECK         = vw_dime_result.DATECHECK;
                            bCB_CHECKSUB.RECHECKDOCTORNAME = vw_dime_result.RECHECKDOCTORNAME;
                            bCB_CHECKSUB.RECHECKDATE       = vw_dime_result.RECHECKDATE;
                        }
                    }
                }
                bCB_CHECKSUBBLL.SaveChanges();
                #region 更新流程表完成标记
                //更新流程表完成标记
                List <string> updatedGroupGUID = new List <string>();
                foreach (var groupGUID in listGROUPGUID.Distinct())
                {
                    BCD_GROUP bCD_GROUP = bCD_GROUPBLL.GetBy(u => u.GUID == groupGUID);
                    if (bCD_GROUP == null)
                    {
                        Console.WriteLine(string.Format("未查询到GUID为{0}的小组", groupGUID));
                        continue;
                    }
                    if (bCD_GROUP.ISPRECONDITION == "1")
                    {
                        continue;
                    }
                    List <BCB_CHECKSUB> listBCB_CHECKSUB = bCB_CHECKSUBBLL.GetListBy(u => u.MAINGUID == bCB_CHECKMAIN.GUID && u.GROUPGUID == groupGUID);
                    bool allCompleted = true;
                    foreach (var checksub in listBCB_CHECKSUB)
                    {
                        if (string.IsNullOrEmpty(checksub.RESULT))
                        {
                            allCompleted = false;
                            break;
                        }
                    }
                    bool isPreconditionComplete = true;

                    if (bCD_GROUP != null)
                    {
                        if (bCD_GROUP.NEEDPRECONDITION == "1")
                        {
                            BCD_GROUP preCondition = bCD_GROUPBLL.GetBy(u => u.GUID == bCD_GROUP.PRECONDITION);
                            if (preCondition == null)
                            {
                                Console.WriteLine(string.Format("未查询到{0}对应的前置小组", bCD_GROUP.GROUPNAME));
                            }
                            else
                            {
                                BCB_CHECKFLOW bCB_CHECKFLOW = new BCB_CHECKFLOWBLL().GetBy(u => u.GROUPGUID == preCondition.GUID && u.MAINGUID == bCB_CHECKMAIN.GUID);
                                if (bCB_CHECKFLOW != null)
                                {
                                    if (bCB_CHECKFLOW.COMPLETETAG != "1")
                                    {
                                        isPreconditionComplete = false;
                                    }
                                }
                            }
                        }
                    }
                    if (allCompleted && isPreconditionComplete)
                    {
                        updatedGroupGUID.Add(groupGUID);
                    }
                }
                new BCB_CHECKFLOWBLL().UpdateByMainGUIDANDGroupGUID(bCB_CHECKMAIN.GUID, updatedGroupGUID.Distinct().ToList());
                #endregion
                //更新小组结论
                foreach (var groupGUID in updatedGroupGUID.Distinct().ToList())
                {
                    List <BCBCHECKSUB>  listBCBCHECKSUB = new List <BCBCHECKSUB>();
                    List <BCB_CHECKSUB> list            = bCB_CHECKSUBBLL.GetListBy(u => u.GROUPGUID == groupGUID && u.MAINGUID == bCB_CHECKMAIN.GUID);
                    foreach (var BCB_CHECKSUB in list)
                    {
                        BCBCHECKSUB temp = new BCBCHECKSUB();
                        temp.BCB_CHECKSUB = BCB_CHECKSUB;
                        temp.BCDITEM      = new BCDITEM
                        {
                            BCD_ITEM = bCD_ITEMBLL.GetBy(u => u.GUID == BCB_CHECKSUB.ITEMGUID)
                        };
                        listBCBCHECKSUB.Add(temp);
                    }
                    if (list.Count > 0)
                    {
                        string result = ResultGenerator.GenerateResult(listBCBCHECKSUB, listALLBCD_ITEMQUALDESC);
                        BCB_GROUPCONCLUSION bCB_GROUPCONCLUSION = bCB_GROUPCONCLUSIONBLL.GetBy(u => u.MAINGUID == bCB_CHECKMAIN.GUID && u.GROUPGUID == groupGUID);
                        if (bCB_GROUPCONCLUSION == null)
                        {
                            bCB_GROUPCONCLUSION            = new BCB_GROUPCONCLUSION();
                            bCB_GROUPCONCLUSION.GUID       = Guid.NewGuid().ToString();
                            bCB_GROUPCONCLUSION.MAINGUID   = bCB_CHECKMAIN.GUID;
                            bCB_GROUPCONCLUSION.GROUPGUID  = groupGUID;
                            bCB_GROUPCONCLUSION.CONSLUSION = result;
                            bCB_GROUPCONCLUSION.TIMECREATE = DateTime.Now;
                            bCB_GROUPCONCLUSIONBLL.Add(bCB_GROUPCONCLUSION);
                        }
                        else
                        {
                            bCB_GROUPCONCLUSION.MAINGUID   = bCB_CHECKMAIN.GUID;
                            bCB_GROUPCONCLUSION.CONSLUSION = result;

                            bCB_GROUPCONCLUSIONBLL.SaveChanges();
                        }
                    }
                }

                List <BCB_GROUPCONCLUSION> listBCB_GROUPCONCLUSION = bCB_GROUPCONCLUSIONBLL.GetListBy(u => u.MAINGUID == bCB_CHECKMAIN.GUID);
                StringBuilder sbResult = new StringBuilder(1024);
                foreach (var bCB_GROUPCONCLUSION in listBCB_GROUPCONCLUSION)
                {
                    if (!string.IsNullOrEmpty(bCB_GROUPCONCLUSION.CONSLUSION) && bCB_GROUPCONCLUSION.CONSLUSION != "未见明显异常")
                    {
                        sbResult.AppendFormat("[{0}]{1}", bCD_GROUPBLL.GetBy(u => u.GUID == bCB_GROUPCONCLUSION.GROUPGUID).GROUPNAME, bCB_GROUPCONCLUSION.CONSLUSION);
                        sbResult.Append(Environment.NewLine);
                    }
                }
                if (string.IsNullOrEmpty(sbResult.ToString()))
                {
                    sbResult.Append("所检项目未见明显异常");
                }
                else
                {
                    sbResult.Append("其余所检项目未见明显异常");
                }
                //更新主表完成标记
                bool isAllPassed = bCB_CHECKSUBBLL.IsAllPassed(u => u.MAINGUID == bCB_CHECKMAIN.GUID);
                int  j           = new BCB_CHECKMAINBLL().UpdateAfterUpload(bCB_CHECKMAIN.GUID, isAllPassed, sbResult.ToString().Trim());


                //int j = new BCB_CHECKMAINBLL().UpdateIfAllCompleted(bCB_CHECKMAIN.GUID, isAllPassed, sbResult.ToString().Trim(), targetConnString);
            }
            return(dicResult);
        }
Exemple #26
0
 public void Setup()
 {
     gameRepository   = new InMemoryGameRepository();
     resultGenerator  = new ResultGenerator(4, new AdditionOperator(), new RandomNumberGenerator(1, 10));
     resultRepository = Substitute.For <IResultRepository>();
 }