예제 #1
0
        // PUBLIC INTERFACE METHODS SECTION
        //---------------------------------------------------------------------

        #region Public methods

        /// <summary>
        ///     Send data to the processing center
        /// </summary>
        /// <param name="entityFileName">Entities data</param>
        /// <param name="storeId">Drugstore in in processing center</param>
        /// <param name="xmlFileName">xml file name if error occurs</param>
        /// <returns>Operation result(true or false)</returns>
        public bool TryToSendData(string entityFileName, int storeId, out string xmlFileName)
        {
            // get entities from the storage
            var entityList = _entityRepository.GetAll(entityFileName);

            xmlFileName = string.Empty;

            // create batch list
            var entityBatchList = CreateBatchList(entityList);

            // convert every batch to the XML-entity(create xml batch)
            int  batchTotal   = entityBatchList.Count;
            bool isFirtsBatch = true;

            for (int batchCount = 0; batchCount < batchTotal; ++batchCount)
            {
                //var xmlFile = _xmlConverter.ConvertToXml(entityBatchList[batchCount]);

                //*** generate timestamp
                var timeStamp = 1;
                var args      = new ServiceEventArgs();

                for (int trialCount = 0; trialCount < TrialsTotal; ++trialCount)
                {
                    SendBatch(entityBatchList[batchCount], "clientId", timeStamp, isFirtsBatch);
                    //var responseResult = CallWebService(entityXmlDocument);
                    //if (responseResult)
                    //{
                    //    args.State = ServiceState.SendComplete;
                    //    args.Message = "batch #" + timeStamp + " - send succeeded";
                    //    OnServiceExecuting(args);
                    //    return true;
                    //}

                    //args.State = ServiceState.SendError;
                    //args.Message = "batch #" + timeStamp + " - send failed";
                    //OnServiceExecuting(args);
                }
                isFirtsBatch = false;
                //return false;

                //if (!sendResult)
                //{
                //    xmlFileName = $"batch#{batchCount}_{DateTime.Today.ToShortDateString()}.xml";
                //    xmlFile.Save("rejected/" + xmlFileName);

                //    return false;
                //}
            }

            return(true);
        }
예제 #2
0
        // *BATCH SEND*
        //-------------------------------------------------



        private void OnServiceExecuting(ServiceEventArgs e)
        {
            ServiceExecuting?.Invoke(this, e);
        }