Пример #1
0
        // GET api/<controller>/5
        public ImportExcelModel Get(int id)
        {
            var info   = ImportExcelRepository.GetInfo(id);
            var retVal = ImportExcelModel.FromInfo(info);

            if (retVal.ImportStatus.HasValue && retVal.ImportStatus == 1)
            {
                //StoreData.LoadData();
                StoreData.LoadImportExcel();
            }
            return(retVal);
        }
Пример #2
0
        /// <summary>
        /// Thread method that does the communication to the client. This
        /// thread tries to receive from client and if client sends any data
        /// then parses it and again wait for the client data to come in a
        /// loop. The recieve is an indefinite time receive.
        /// </summary>
        private void SocketListenerThreadStart()
        {
            m_lastReceiveDateTime    = DateTime.Now;
            m_currentReceiveDateTime = DateTime.Now;

            var t = new Timer(CheckClientCommInterval, null, 15000, 15000);

            while (!m_stopClient)
            {
                try
                {
                    var networkStream = new NetworkStream(m_clientSocket);
                    var streamReader  = new StreamReader(networkStream);
                    var importId      = ConvertHelper.ToInt32(streamReader.ReadLine());
                    var importInfo    = ImportExcelRepository.GetInfo(importId);

                    if (importInfo == null)
                    {
                        continue;
                    }
                    var importProcess = new ImportProcess(importInfo);
                    var thread        = new Thread(StartImport);
                    thread.Start(importProcess);
                    //size = m_clientSocket.Receive(byteBuffer);
                    //m_currentReceiveDateTime = DateTime.Now;
                    //ParseReceiveBuffer(byteBuffer, size);
                    //Console.WriteLine(m_oneLineBuf.ToString());
                }
                catch
                {
                    m_stopClient        = true;
                    m_markedForDeletion = true;
                }
            }
            t.Change(Timeout.Infinite, Timeout.Infinite);
        }
Пример #3
0
        private void StartQueueImport()
        {
            while (!stopFlag)
            {
                var importId = 0;
                Monitor.Enter(Messages.SyncRoot);
                if (Messages.Count > 0)
                {
                    importId = ConvertHelper.ToInt32(Messages.Dequeue());
                }
                Monitor.Exit(Messages.SyncRoot);
                var importInfo = ImportExcelRepository.GetInfo(importId);

                if (importInfo != null)
                {
                    var importProcess = new ImportProcess(importInfo);
                    var t             = new Thread(importProcess.Start);
                    t.Start();
                    Console.WriteLine(importInfo.FilePath);
                }

                Thread.Sleep(10);
            }
        }
Пример #4
0
        public string Edit(FormDataCollection form)
        {
            var retVal    = string.Empty;
            var operation = form.Get("oper");
            var id        = ConvertHelper.ToInt32(form.Get("ImportExcelId"));

            if (!string.IsNullOrEmpty(operation))
            {
                ImportExcelInfo info;
                switch (operation)
                {
                case "edit":
                    info = ImportExcelRepository.GetInfo(id);
                    if (info != null)
                    {
                        /*
                         *
                         *      info.ImportId = form.Get("ImportId");
                         *
                         *      info.UserId = form.Get("UserId");
                         *
                         *      info.TypeId = form.Get("TypeId");
                         *
                         *      info.ChannelId = form.Get("ChannelId");
                         *
                         *      info.CollectorId = form.Get("CollectorId");
                         *
                         *      info.BranchId = form.Get("BranchId");
                         *
                         *      info.Status = form.Get("Status");
                         *
                         *      info.FilePath = form.Get("FilePath");
                         *
                         *      info.TotalRow = form.Get("TotalRow");
                         *
                         *      info.CheckCount = form.Get("CheckCount");
                         *
                         *      info.ErrorCount = form.Get("ErrorCount");
                         *
                         *      info.DuplicateCount = form.Get("DuplicateCount");
                         *
                         *      info.ImportedDate = form.Get("ImportedDate");
                         *
                         * ImportExcelRepository.Update(info);
                         */
                    }
                    break;

                case "add":
                    info = new ImportExcelInfo();

                    /*
                     *
                     * info.ImportId = form.Get("ImportId");
                     *
                     * info.UserId = form.Get("UserId");
                     *
                     * info.TypeId = form.Get("TypeId");
                     *
                     * info.ChannelId = form.Get("ChannelId");
                     *
                     * info.CollectorId = form.Get("CollectorId");
                     *
                     * info.BranchId = form.Get("BranchId");
                     *
                     * info.Status = form.Get("Status");
                     *
                     * info.FilePath = form.Get("FilePath");
                     *
                     * info.TotalRow = form.Get("TotalRow");
                     *
                     * info.CheckCount = form.Get("CheckCount");
                     *
                     * info.ErrorCount = form.Get("ErrorCount");
                     *
                     * info.DuplicateCount = form.Get("DuplicateCount");
                     *
                     * info.ImportedDate = form.Get("ImportedDate");
                     *
                     */
                    ImportExcelRepository.Create(info);
                    break;

                case "del":
                    ImportExcelRepository.Delete(id);
                    break;
                }
            }
            return(retVal);
        }