示例#1
0
        private void RunProcess()
        {
            // 수식 뒤 "," 제거해야함
            string[]     ExpressionList = GetExpressionList();
            StreamWriter sw;

            //파일 초기화
            File.WriteAllText(SuccessPath, String.Empty);
            File.WriteAllText(FailPath, String.Empty);
            foreach (string Need in ExpressionList)
            {
                string Write;
                bool   isGood;
                string Commmet;
                double?result;
                string Expression = Need.Replace(",", "");
                try
                {
                    result  = (double)Calculate.calculate(Expression);
                    isGood  = true;
                    Commmet = "없음";
                }
                catch (Exception ex)
                {
                    //무언가 문제로 계산이 안됨
                    result  = 0;
                    isGood  = false;
                    Commmet = ex.Message;
                }

                Write = string.Format("{0}, {1}, {2}, {3}", Expression, result, isGood ? "성공" : "실패", Commmet);

                if (isGood)
                {
                    //성공했다면
                    sw = new StreamWriter(SuccessPath, true);
                }
                else
                {
                    //실패했다면
                    sw = new StreamWriter(FailPath, true);
                }
                sw.WriteLine(Write);
                sw.Close();
            }
            MessageBox.Show("처리 완료");
        }