Beispiel #1
0
        //1.檢查必要的input parameter
        public static void ValidateParameter(DCItem dcItem)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            BaseLog.LoggingBegin(logger, methodName);
            try
            {
                //Check the condition column first!
                if (dcItem.Type == "")
                {
                    throw new Exception("These columns of Type are null or no data ! ");
                }
                

                List<string> NotNullItemList = new List<string> {"TxnId",
                                                                 "BatchID",
                                                                 "Type"};

                List<string> NotNullItemList2 = new List<string> {"TxnId",
                                                                 "BatchID",
                                                                 "Type",
                                                                 "Family",
                                                                 "IECPn",
                                                                 "Vendor",
                                                                 "DefectCode"};

                //Check null data
                string className = dcItem.GetType().BaseType.Name;
                if (className == "Object")
                { className = dcItem.GetType().Name; }
                string title = "These columns of " + className + " are null or no data : ";
                string error = "";

                if (dcItem.Type == "")
                    { error = "Type"; }
                else if (dcItem.Type == "0")
                {
                    foreach (string itemcolumn in NotNullItemList)
                    {
                        if (string.IsNullOrEmpty(GetValueByType(itemcolumn, dcItem).Trim()))
                        { error = error + itemcolumn + ","; }
                    }
                }
                else if (dcItem.Type == "1")
                {
                    foreach (string itemcolumn in NotNullItemList2)
                    {
                        if (string.IsNullOrEmpty(GetValueByType(itemcolumn, dcItem).Trim()))
                        { error = error + itemcolumn + ","; }
                    }
                }

                if (error != "")
                {
                    error = title + error;
                    throw new Exception(error);
                }
                //ObjectTool.CheckNullData(NotNullItemList, item);


            }
            catch (Exception e)
            {
                BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e);
                throw e;
            }
            finally
            {
                BaseLog.LoggingEnd(logger, methodName);
            }
            
        }