示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("[1] 임포트 데이터가 없습니다. 840만개 숫자와 바로 엑셀 쿼리로부터 시작해주세요. " +
                              Environment.NewLine +
                              "[2] 임포트 데이터가 있습니다. 데이터셋과 엑셀 쿼리로부터 시작해주세요. ");

            string input;

            input = Console.ReadLine();
            AbstractLottoSolution lottoSolution = new LottoSolutionWithAllNumberSet();

            if (input == "1")
            {
                lottoSolution = new LottoSolutionWithAllNumberSet();
            }
            else if (input == "2")
            {
                lottoSolution = new LottoSolutionWithImportData();
            }
            else
            {
                ExceptionDialogService.getInstance().showMessageAndAllert("입력은 1 또는 2만해주세요. ");
            }

            lottoSolution.doJob();
            Logger.getInstance().Dispose();
        }
示例#2
0
 public AbstractExcelAccessor(FileInfo excelFile)
 {
     this.excelFile = excelFile;
     if (!File.Exists(excelFile.Name))
     {
         ExceptionDialogService.getInstance().showMessageAndAllert("File 이 존재하지 않습니다." + Environment.NewLine + $"{excelFile.Name} does not exist. please make it ");
     }
     ;
     package = new ExcelPackage(excelFile);
 }
示例#3
0
        public override void doJob()
        {
            ExcelReader reader = new ExcelReader(new FileInfo("LottoGenXLS.xlsx"));

            reader.ReadGameArgsAndGroupNumberFromfilepath();
            Logger.getInstance().writerFile(reader.Gameargs.Range + " to " + reader.Gameargs.Extract);

            CommonOpenFileDialog source_dialog = new CommonOpenFileDialog();
            CommonOpenFileDialog target_dialog = new CommonOpenFileDialog();

            try
            {
                source_dialog = getSourceDirectory();
                target_dialog = getTargetDirectory();
                if (source_dialog.FileName == target_dialog.FileName)
                {
                    throw new Exception("임포트 데이터 폴더 위치와 출력 폴더 위치는 같을 수 없습니다.");
                }
            }
            catch (Exception ex)
            {
                ExceptionDialogService.getInstance().showMessageAndAllert(ex.Message);
            }

            WriterAndFileMover mover = new WriterAndFileMover(target_dialog.FileName);

            int cnt = 1;

            foreach (var i in reader.ReturnNumberSetAndMinMax())
            {
                IFilesListHave fileList;
                if (cnt == 1)
                {
                    fileList = new FileListHave(Directory.GetFiles(source_dialog.FileName, "*.txt"));
                }
                else
                {
                    fileList = new FileListHaveDeletable(Directory.GetFiles(mover.target_directory_Path_plus_prev, "*.txt"));
                }

                notePadWriter      writer     = new notePadWriter(mover.target_directory_Path_plus + $"/output{cnt}A.txt");
                abstractLottologic lottoLogic = new LottologicWithImportedDataSet(
                    new LogicWithExistNumberSet(i.rule_MinmaxArgs, i.numberSet),
                    writer.WriteFile,
                    fileList,
                    writerDelete: writer.deleteFile
                    );

                Logger.getInstance().writerFile(cnt++ + " 번재 그룹 작업중입니다.");
                lottoLogic.doCalculate();

                mover.Switch();
                writer.CloseWriter();
            }
        }
示例#4
0
        public void SetUp()
        {
            _mockExceptionDialog = new Mock <IExceptionDialog>();

            _mockFactory = new Mock <IDialogFactory>();
            _mockFactory.Setup(p => p.CreateExceptionDialog())
            .Returns(_mockExceptionDialog.Object);

            _service = new ExceptionDialogService(
                _mockFactory.Object);
        }
示例#5
0
 protected bool WriteCellValue(ExcelWorksheet worksheet, string pos, T value, [CallerMemberName] string name = null)
 {
     try
     {
         worksheet.Cells[pos].Value = value.ToString();
     }
     catch (Exception e)
     {
         ExceptionDialogService.getInstance().showMessageAndAllert($"{name} Calls {nameof(WriteCellValue)}. 그러나 예외가 발생했습니다." + Environment.NewLine + e.Message);
     }
     return(true);
 }
        public override void doJob()
        {
            ExcelReader reader = new ExcelReader(new FileInfo("LottoGenXLS.xlsx"));

            reader.ReadGameArgsAndGroupNumberFromfilepath();
            Logger.getInstance().writerFile(reader.Gameargs.Range + " to " + reader.Gameargs.Extract);

            CommonOpenFileDialog target_dialog = new CommonOpenFileDialog();

            try
            {
                target_dialog = getTargetDirectory();
            }
            catch (Exception ex)
            {
                ExceptionDialogService.getInstance().showMessageAndAllert(ex.Message);
            }

            WriterAndFileMover mover = new WriterAndFileMover(target_dialog.FileName);

            int cnt  = 0;
            var list = reader.ReturnNumberSetAndMinMax();

            foreach (var i in reader.ReturnNumberSetAndMinMax())
            {
                notePadWriter      writer = new notePadWriter(mover.target_directory_Path_plus + $"/output{cnt}A.txt");
                abstractLottologic lottologic;
                if (cnt == 0)
                {
                    CreateAllPossibleNumber creater = new CreateAllPossibleNumber(reader.Gameargs, writer.WriteFile);
                    Logger.getInstance().writerFile(cnt++ + " 번째 작업중... 모든 경우의 수를 생성중입니다.  ");
                    creater.createAllPossibleNumber();
                }
                else
                {
                    lottologic = new LottologicWithImportedDataSet(
                        new LogicWithExistNumberSet(i.rule_MinmaxArgs, i.numberSet),
                        writer.WriteFile,
                        new FileListHave(Directory.GetFiles(mover.target_directory_Path_plus_prev, searchPattern: "*.txt")),
                        writer.deleteFile
                        );
                    Logger.getInstance().writerFile(cnt++ + " 번째 그룹 작업중입니다.");
                    lottologic.doCalculate();
                }
                mover.Switch();
                writer.CloseWriter();
            }
        }
示例#7
0
        private async void GetWorkItemTypesBehaviors(GetWorkItemTypesBehaviorsEventArgs args)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    Results.InitializeHttpClient(client, args.Organization.PAT);

                    // TODO(crhodes)
                    // Update Uri  Use args for parameters.
                    var requestUri = $"{args.Organization.Uri}/_apis"
                                     + $"/work/processes/{args.Process.id}/"
                                     + $"/workitemtypesbehaviors/{args.WorkItemType.referenceName}"
                                     + "/behaviors"
                                     + "?api-version=6.1-preview.1";

                    var exchange = Results.InitializeExchange(client, requestUri);

                    using (HttpResponseMessage response = await client.GetAsync(requestUri))
                    {
                        Results.RecordExchangeResponse(response, exchange);

                        response.EnsureSuccessStatusCode();

                        string outJson = await response.Content.ReadAsStringAsync();

                        JObject o = JObject.Parse(outJson);

                        WorkItemTypesBehaviorsRoot resultRoot = JsonConvert.DeserializeObject <WorkItemTypesBehaviorsRoot>(outJson);

                        Results.ResultItems = new ObservableCollection <WorkItemTypesBehavior>(resultRoot.value);

                        IEnumerable <string> continuationHeaders = default;

                        bool hasContinuationToken = response.Headers.TryGetValues("x-ms-continuationtoken", out continuationHeaders);

                        Results.Count = Results.ResultItems.Count;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
                ExceptionDialogService.DisplayExceptionDialog(DialogService, ex);
            }

            EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange);
        }
        //public RESTResult<DType> Results { get; set; } = new RESTResult<DType>();

        #endregion

        #region Event Handlers (none)


        #endregion

        #region Public Methods (none)

        #endregion

        #region Protected Methods (none)


        #endregion

        #region Private Methods

        private async void GetList(EArgs args)
        {
            Int64 startTicks = Log.EVENT_HANDLER($"Enter: ({args.GetType()})", Common.LOG_CATEGORY);

            try
            {
                // NOTE(crhodes)
                // This is easy

                var domainType = new DType();

                // Until we want to pass arguments to the DType Constructor

                //Type dType = typeof(DType);

                //var domainType = Activator.CreateInstance(dType, new object[] { EventAggregator, DialogService });

                MethodInfo getListMethod = domainType.GetType().GetMethod("GetList");

                Task <RESTResult <DType> > almostResults = (Task <RESTResult <DType> >)getListMethod.Invoke(domainType, new object[] { args });

                await almostResults;

                Results.ResultItems = almostResults.Result.ResultItems;

                // NOTE(crhodes)
                // Magic
                Results.ResultItem = almostResults.Result.ResultItem;

                Results.Count = Results.ResultItems.Count();
                Results.RequestResponseExchange = almostResults.Result.RequestResponseExchange;
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
                ExceptionDialogService.DisplayExceptionDialog(DialogService, ex);
            }
            finally
            {
                // NOTE(crhodes)
                // Always publish the exchange so we can see what we were trying to access
                // TODO(crhodes)
                // May need to catch exceptions in getListMethod so can always return Results.
                EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange);
            }

            Log.EVENT_HANDLER($"Exit: ({args.GetType()})", Common.LOG_CATEGORY, startTicks);
        }
        private gameArgs ReadGameArgsAndGroupNumberFromWorkSheet(int idx)
        {
            gameArgs gameargs = new gameArgs(0, 0, 0);

            try
            {
                var worksheets = getWorkSheet(package);
                var worksheet  = worksheets[idx];
                gameargs = new gameArgs(ReadCellValue(worksheet, "D3"), ReadCellValue(worksheet, "B4"), ReadCellValue(worksheet, "B5"));
            }
            catch (Exception e)
            {
                ExceptionDialogService.getInstance().showMessageAndAllert($"error occured in {nameof(ReadGameArgsAndGroupNumberFromWorkSheet)}" + Environment.NewLine + e.Message);
            }
            return(gameargs);
        }
示例#10
0
        private async void GetWidgets(GetWidgetsEventArgs args)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    Results.InitializeHttpClient(client, args.Organization.PAT);

                    var requestUri = $"{args.Organization.Uri}/{args.Project.id}/{args.Team.id}/_apis/dashboard/dashboards/{args.Dashboard}?api-version=6.1-preview.1";

                    //var exchange = Results.InitializeExchange(client, requestUri);
                    var exchange = Results.InitializeExchange(client, requestUri);

                    using (HttpResponseMessage response = await client.GetAsync(requestUri))
                    {
                        Results.RecordExchangeResponse(response, exchange);

                        response.EnsureSuccessStatusCode();

                        string outJson = await response.Content.ReadAsStringAsync();

                        JObject o = JObject.Parse(outJson);

                        //WidgetsRoot resultRoot = JsonConvert.DeserializeObject<WidgetsRoot>(outJson);

                        //Widgets.ResultItems = new ObservableCollection<Domain.Widget>(resultRoot.value);

                        IEnumerable <string> continuationHeaders = default;

                        bool hasContinuationToken = response.Headers.TryGetValues("x-ms-continuationtoken", out continuationHeaders);

                        Results.Count = Results.ResultItems.Count;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
                ExceptionDialogService.DisplayExceptionDialog(DialogService, ex);
            }

            EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange);
        }
示例#11
0
 public bool checkWithValue(object value, string name)
 {
     if ((int)value < 0 || readExceptionRule.checkWithValue(value, name))
     {
         string message = $"UNKOWN ERROR FROM {name}";
         if (name == "ReturnNumberSetAndMinMax")
         {
             message = "게임 set은 숫자 외의 문자이거나, 음수 일 수 없습니다.";
         }
         else if (name == "ReadGameArgsAndGroupNumberFromfilepath")
         {
             message = "게임의 유형 또는 그룹 수는 숫자 외의 문자이거나, 음수 일 수 없습니다.";
         }
         else if (name == "mnNumber" || name == "mxNumber")
         {
             message = "게임 추출 최소값 최대값은 숫자 외의 문자이거나, 음수 일 수 없습니다.";
         }
         ExceptionDialogService.getInstance().showMessageAndAllert(message);
         return(true);
     }
     return(false);
 }