Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public int insertNisLateOrder(NISLateOrders order)
        {
            object orderId = 0;

            try
            {
                System.Collections.Specialized.NameValueCollection args = new NameValueCollection();
                args.Add("@ID", order.ID.ToString());
                args.Add("@userID", order.UserId);
                args.Add("@email", order.Email);
                args.Add("@orderDate", order.OrderDate.ToString());
                args.Add("@dateReq", order.DateReq.ToString());
                args.Add("@PO", order.PO);
                args.Add("@sentDate", order.SentDate.ToString());
                args.Add("@items", order.Items.ToString());
                args.Add("@SON", order.SON);
                args.Add("@cutOff", order.CutOff.ToString());
                args.Add("@imported", order.Imported.ToString());
                DBContext.DBAccess access = new DBContext.DBAccess();
                //
                orderId = access.ExecuteScalar("MW_NISLateOrderInsert", DBContext.DBAccess.DBConnection.NameSys, args);
            }
            catch (Exception)
            {
            }
            return(Convert.ToInt32(orderId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a list of all NIS sent orders that have been imported after cutoff time
        /// No parameters requiered.
        /// </summary>
        /// <returns>Late orders list</returns>
        public List <NISLateOrders> getNisLateOrders()
        {
            SqlDataReader        dr   = null;
            List <NISLateOrders> list = new List <NISLateOrders>();
            int items = 0;

            try
            {
                System.Collections.Specialized.NameValueCollection args = new NameValueCollection();
                DBContext.DBAccess access = new DBContext.DBAccess();
                //
                dr = access.ExecuteReader("[MW_NISLateOrdersControl]", DBContext.DBAccess.DBConnection.NameSys, args);
                //
                while (dr != null && dr.Read())
                {
                    NISLateOrders ord = new NISLateOrders();
                    ord.ID        = (Int32)(dr["ID"].ToString().Length > 0 ? Int32.Parse(dr["ID"].ToString()) : 0);
                    ord.UserId    = (dr["userID"].ToString().Length > 0 ? (dr["userID"].ToString()) : "");
                    ord.Email     = dr["email"].ToString().Length > 0 ? dr["email"].ToString() : "";
                    ord.OrderDate = dr["orderDate"].ToString().Length > 0 ? DateTime.Parse(dr["orderDate"].ToString()) : DateTime.Now;
                    ord.DateReq   = dr["dateReq"].ToString().Length > 0 ? DateTime.Parse(dr["dateReq"].ToString()) : DateTime.Now;
                    ord.PO        = dr["PO"].ToString().Length > 0 ? dr["PO"].ToString() : "";
                    ord.SentDate  = dr["sentDate"].ToString().Length > 0 ? DateTime.Parse(dr["sentDate"].ToString()) : DateTime.Now;
                    ord.Items     = (Int32)(dr["items"].ToString().Length > 0 ? Int32.Parse(dr["items"].ToString()) : 0);
                    ord.SON       = dr["SON"].ToString().Length > 0 ? dr["SON"].ToString() : "";
                    ord.CutOff    = dr["cutoff"].ToString().Length > 0 ? DateTime.Parse(dr["cutoff"].ToString()) : DateTime.Now;
                    ord.Imported  = dr["Imported"].ToString().Length > 0 ? DateTime.Parse(dr["Imported"].ToString()) : DateTime.Now;
                    //
                    list.Add(ord);   //  Store order Items information
                }
            }
            finally
            {
                if ((dr != null) && (!dr.IsClosed))
                {
                    dr.Close();
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        /// *****************************************************************************************
        /// General files process - Only NIS XML valid Files are processed here:
        ///     (1) - Select orders to process depending on Imported conditions.
        ///     (2) - Route process to the corresponding late orders process using delegates.
        ///     (3) - NIS table reading errors are detected here.
        ///     (4) - Errors are logged in service log and reported through web services.
        /// -----------------------------------------------------------------------------------------
        public void ProcessOrder(NISLateOrders order, EtlTimer sync)
        {
            /// Initialize Error messages object basic information
            ServiceResponse errMsg = new ServiceResponse();

            errMsg.FileType   = "1";
            errMsg.FileName   = "Late Order: " + order.ToString();
            errMsg.NISOrderId = "0";
            errMsg.Status     = "Not Processed";
            errMsg.Message    = string.Empty;
            try
            {
                /// *********************************************************************************
                /// Select files acceptable to be process, all other file types (extension) will not
                /// be processed (they stay in the newFiles folder) and an error message is generated
                /// to the WebServices.
                /// Only NIS (1) row are processed by entry.
                /// ---------------------------------------------------------------------------------
                if (order != null)
                {
                    /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                    /// Route to the corresponding NIS procedure
                    ///  ----------------------------------------------------------------------------
                    int res = Inr.insertNisLateOrder(order);
                    icr.writeSyncLog(1, sync.MwEtlTimerId, 1, sync.ServiceName, "late order inserted: " + order.ID);
                }
                else
                {   //  update error order - set imported on and import problem on
                    int ret = Inr.updNisOrder(order.ID, 0, 1, 0);
                    icr.writeSyncLog(1, sync.MwEtlTimerId, 1, sync.ServiceName, "Table reading error Late orders, order " + order);
                }
            }
            catch (Exception fle)
            {
                int res = icr.updImportControl(sync.MwEtlTimerId, 0);     //  set EtlTimer for this service to not Running (isRunning = false)
                errMsg.Message = "(NIS LateOrders) Table reading error - in order " + errMsg.FileName + ". " + fle;
                icr.writeSyncLog(1, sync.MwEtlTimerId, 1, sync.ServiceName, errMsg.Message);
                int resp = Inr.updNisOrder(Convert.ToInt32(errMsg.FileName), 0, 1, 0);
            }
        }