Esempio n. 1
0
        private void LogInputParameter(clsDTOrder dtOrder, clsDTOrderItem dtOrderItem, int atpCtpLogicId)
        {
            try
            {
                string tmpLog = string.Empty;
                tmpLog = "Order Level => ";
                foreach (DataRow DR in dtOrder.DT.Rows)
                {
                    foreach (DataColumn DC in dtOrder.DT.Columns)
                    {
                        tmpLog += $@" {DC.ColumnName}: {DR[DC.ColumnName]},";
                    }
                }
                log.LogAlert(clsLog.Logger.ATPCTP, clsLog.ErrorLevel.NoImpact, clsLog.ProcessCategory.RequestATPCTP, tmpLog);

                tmpLog = "OrderItem Level => ";
                foreach (DataRow DR in dtOrderItem.DT.Rows)
                {
                    foreach (DataColumn DC in dtOrderItem.DT.Columns)
                    {
                        tmpLog += $@" {DC.ColumnName}: {DR[DC.ColumnName]},";
                    }
                }
                log.LogAlert(clsLog.Logger.ATPCTP, clsLog.ErrorLevel.NoImpact, clsLog.ProcessCategory.RequestATPCTP, tmpLog);
            }
            catch (Exception ex)
            {
                throw new Exception($@"Error on LogInputParameter:{ex.Message}");
            }
        }
        static void Main_TestATPCTPRequest()
        {
            String ConStrCustom;
            String ConstrStd;
            int    @UserID;

            UserID = 99;

            Cls_Connection t = new Cls_Connection();

            ConStrCustom = t.GetConnectionString_Custom();
            ConstrStd    = t.GetConnectionString_Std();
            DateTime OrderreqDate = DateTime.Today.AddDays(-1); // DateTime.Parse("2019/8/31"); //DateTime.Today.AddDays(1d);

            d = new ATPCTP(ConStrCustom, ConstrStd);


            clsDTOrder dtOrder = new clsDTOrder {
                Id = 1000000290, Ordernumber = "TON19082401", OrderHierarchyID = 1000000065, BillToID = 1000036, PoNumber = "PO-xxx", ShipToID = 222, ContractID = 123, Remark = "Test Remark", UserID = UserID
            };

            dtOrder.AddRow();

            clsDTOrderItem dtOrderItem = new clsDTOrderItem {
                Id = -1, OrderID = 1000000290, ItemNumber = 10, MaterialID = 1000009520, ShiptoID = 111, ContractID = 222, RequestQTY_OrdU = 20, RequestDate = OrderreqDate, UserID = UserID
            };

            dtOrderItem.AddRow();

            //ds = d.Request(1, 10, new DateTime (2019,6/7), 1, 0); old one 1000009524
            try
            {
                string ErrMsg = String.Empty;
                ds = d.Request(dtOrder, dtOrderItem, 1000000002, ref ErrMsg);

                Console.WriteLine("done for " + ConStrCustom);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error found:" + ex.Message);
            }
        }
        static void Main_TestATPCTPForceUpdate()
        {
            String ConStrCustom;
            String ConstrStd;
            int    UserID = 0;

            Cls_Connection t = new Cls_Connection();

            ConStrCustom = t.GetConnectionString_Custom();
            ConstrStd    = t.GetConnectionString_Std();
            DateTime OrderreqDate = DateTime.Today.AddDays(5d);

            d = new ATPCTP(ConStrCustom, ConstrStd);



            clsDTOrder dtOrder = new clsDTOrder
            {
                Id               = 1000000290,
                Ordernumber      = "TON19082401",
                OrderHierarchyID = 1000000065,
                BillToID         = 3,
                PoNumber         = "po-ssss",
                ShipToID         = 0,
                ContractID       = 0,
                Remark           = "Test Remark",
                UserID           = UserID
            };

            dtOrder.AddRow();

            clsDTOrderItem dtOrderItem = new clsDTOrderItem
            {
                Id              = 1000001305,
                OrderID         = 1000000290,
                ItemNumber      = 10,
                MaterialID      = 1000009605,
                ShiptoID        = 0,
                ContractID      = 0,
                RequestQTY_OrdU = 60,
                RequestDate     = OrderreqDate,
                UserID          = UserID
            };

            dtOrderItem.AddRow();


            try
            {
                string ErrMsg = string.Empty;
                ds = d.Request(dtOrder, dtOrderItem, 1000000008, ref ErrMsg);
                if (ErrMsg.Length > 0)
                {
                    Console.WriteLine($"Warning:{ErrMsg}");
                }
                else
                {
                    Console.WriteLine("done for " + ConStrCustom);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error found:" + ex.Message);
            }
        }
        static void Main_TestATPCTPRequest2()
        {
            String ConStrCustom;
            String ConstrStd;
            int    UserID = 0;

            Cls_Connection t = new Cls_Connection();

            ConStrCustom = t.GetConnectionString_Custom();
            ConstrStd    = t.GetConnectionString_Std();
            DateTime OrderreqDate = DateTime.Today.AddDays(1d);

            d = new ATPCTP(ConStrCustom, ConstrStd);


            //clsDTOrder dtOrder = new clsDTOrder { Id = 1000000070, Ordernumber = "OD-190727-0004", OrderHierarchyID = 1000000065, BillToID = 5, PoNumber = "PO-xxx", ShipToID = 222, ContractID = 123, Remark = "Test Remark", UserID = 99 };
            //dtOrder.AddRow();

            //clsDTOrderItem dtOrderItem = new clsDTOrderItem { Id = -1, OrderID = 1000000070, ItemNumber = 10, MaterialID = 1000000034, ShiptoID = 111, ContractID = 222, RequestQTY_OrdU = 20, RequestDate = OrderreqDate };
            //dtOrderItem.AddRow();

            //ds = d.Request(1, 10, new DateTime (2019,6/7), 1, 0);

            //clsDTOrder dtOrder = new clsDTOrder
            //{
            //    Id = 1000000070,
            //    Ordernumber = "OD-190727-0004",
            //    OrderHierarchyID = 1000000065,
            //    BillToID = 5,
            //    PoNumber = "po-ppppp",
            //    ShipToID = 0,
            //    ContractID = 0,
            //    Remark = "ssss",
            //    UserID = UserID
            //};
            //dtOrder.AddRow();

            //clsDTOrderItem dtOrderItem = new clsDTOrderItem
            //{
            //    Id = -1,
            //    OrderID = 1000000070,
            //    ItemNumber = 10,
            //    MaterialID = 1000000034,
            //    ShiptoID = 111,
            //    ContractID = 222,
            //    RequestQTY_OrdU = 20,
            //    RequestDate = OrderreqDate,
            //    InsertUserID = UserID

            //};
            //dtOrderItem.AddRow();

            clsDTOrder dtOrder = new clsDTOrder
            {
                Id               = 1000000147,
                Ordernumber      = "OD-190731-0014",
                OrderHierarchyID = 1000000065,
                BillToID         = 3,
                PoNumber         = "po-ssss",
                ShipToID         = 0,
                ContractID       = 0,
                Remark           = "Test Remark",
                UserID           = UserID
            };

            dtOrder.AddRow();

            clsDTOrderItem dtOrderItem = new clsDTOrderItem
            {
                Id              = -1,
                OrderID         = 1000000128,
                ItemNumber      = 0,
                MaterialID      = 1000000034,
                ShiptoID        = 0,
                ContractID      = 0,
                RequestQTY_OrdU = 10,
                RequestDate     = new DateTime(2019, 8, 9),
                UserID          = UserID
            };

            dtOrderItem.AddRow();


            try
            {
                string ErrMsg = string.Empty;
                ds = d.Request(dtOrder, dtOrderItem, 1000000002, ref ErrMsg);
                if (ErrMsg.Length > 0)
                {
                    Console.WriteLine($"Warning:{ErrMsg}");
                }
                else
                {
                    Console.WriteLine("done for " + ConStrCustom);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error found:" + ex.Message);
            }
        }
 static void t1()
 {
     clsDTOrder xx = new clsDTOrder();
 }
Esempio n. 6
0
        /// <summary>
        /// For caller to call for ATPCTP result.
        /// </summary>
        /// <param name="materialID"></param>
        /// <param name=""></param>
        /// <returns></returns>
        //public DataSet Request(DataTable dtOrder, DataTable dtOrderItem, int atpCtpLogicId)
        public DataSet Request(clsDTOrder dtOrder, clsDTOrderItem dtOrderItem, int atpCtpLogicId, ref string WarningMsg)
        {
            try
            {
                WarningMsg = string.Empty;
                Console.WriteLine("Start Request ...");
                int logID;
                logID = log.LogProcessInsert(clsLog.Logger.ATPCTP, clsLog.ProcessCategory.RequestATPCTP, "ATPCTP Request", DateTime.Now);
                _ds   = new DataSet();
                LogInputParameter(dtOrder, dtOrderItem, atpCtpLogicId);
                string    procName = "proc_DUP_ATPCTPRequestSelect_4096";
                DataTable dt1;
                DataTable dt2;
                dt1 = dtOrder.DT;
                dt2 = dtOrderItem.DT;
                //ClsConnection con = new ClsConnection(_conStr);

                using (SqlConnection con = new SqlConnection(_conStr))
                {
                    con.Open();
                    using (SqlCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = procName;
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.AddWithValue("@DTOrder", dt1);
                        cmd.Parameters.AddWithValue("@DTOrderItem", dt2);
                        cmd.Parameters.AddWithValue("@ATPCTPLogicID", atpCtpLogicId);
                        using (SqlDataAdapter sd = new SqlDataAdapter(cmd))
                        {
                            sd.Fill(_ds);
                        }
                    }
                }
                _ds.Tables[0].TableName = "DTOrderItem";
                _ds.Tables[1].TableName = "DTOrderItemOperation";
                _ds.Tables[2].TableName = "DTOrderItemOperationDetail";
                log.LogProcessUpdate(logID, DateTime.Now);
                WarningMsg = string.Empty;
                Console.WriteLine("End ATPCTPRequest");
                if (_ds.Tables.Count > 0)
                {
                    if (_ds.Tables[0].Rows.Count == 0 && WarningMsg == string.Empty)
                    {
                        WarningMsg = "No WIP found either in Balance inventory or Material Master";
                    }
                }
                LogOutputResult(_ds);
                return(_ds);
            }
            catch (Exception ex)
            {
                string errmsg     = ex.Message;
                string showerrmsg = string.Empty;
                if (_ds != null)
                {
                    _ds.Tables[0].TableName = "DTOrderItem";
                    _ds.Tables[1].TableName = "DTOrderItemOperation";
                    _ds.Tables[2].TableName = "DTOrderItemOperationDetail";
                }
                if (IsRealError(errmsg, ref showerrmsg) == true)
                {
                    WarningMsg = string.Empty;
                    Console.WriteLine($"Error found on Request:{ex.Message}");
                    throw ex;
                }
                else
                {
                    WarningMsg = showerrmsg;
                    if (_ds.Tables.Count > 0)
                    {
                        if (_ds.Tables[0].Rows.Count == 0 && WarningMsg == string.Empty)
                        {
                            WarningMsg = "No WIP found either in Balance inventory or Material Master";
                        }
                    }
                    return(_ds);
                }
            }
        }