Пример #1
0
        public Transfer(Log poLog, string psFTP_A, string psFTP_B, string psFTP_User, string psFTP_Pass, string psFilesPath)
        {
            this.objLog            = poLog;
            this.sFTP_A            = psFTP_A;
            this.sFTP_B            = psFTP_B;
            this.sFTP_User         = psFTP_User;
            this.sFTP_Pass         = psFTP_Pass;
            this.sFilesPath        = psFilesPath;
            this.sCurrentServerFTP = this.sFTP_A;

            if (!Directory.Exists(this.sFilesPath))
            {
                Directory.CreateDirectory(this.sFilesPath);
            }

            this.bTransfering          = false;
            this.bCurrentServerChanged = false;

            tCRIFile tCriFile = new tCRIFile();

            try
            {
                tCriFile.GetData();
                this.sCRIFiles = tCriFile.Table.Where(_ => _.bitClosed).Select(_ => _.vchFileName).ToList();
            }
            finally
            {
                tCriFile.Dispose();
            }
        }
Пример #2
0
        private void InsertDataBase(string psFile, string psType, bool pbClosed)
        {
            tCRIFile tCriFile = new tCRIFile();

            try
            {
                tCriFile.GetDataByFileName(psFile);
                if (tCriFile.Table.Count == 0)
                {
                    if (pbClosed && psType == "te")
                    {
                        return;
                    }

                    DateTime dtFile = DateTime.ParseExact(psFile.Substring(2, 6), "yyMMdd", CultureInfo.InvariantCulture);
                    tCriFile.Insert(psFile, dtFile, pbClosed, psType);
                    this.objLog.GravarLog(Log.TypeMessage.Success, "File \"" + psFile + "\" inserted. Closed {" + pbClosed + "}.");

                    if (psType == "ev")
                    {
                        string teFile = psFile.Replace("ev", "te");
                        this.InsertDataBase(teFile, "te", true);
                    }
                }
                else
                {
                    if (tCriFile.Columns.bitClosed)
                    {
                        throw new Exception("File \"" + psFile + "\" already closed.");
                    }
                    else if (pbClosed && !tCriFile.Columns.bitClosed)
                    {
                        tCriFile.Columns.bitClosed = true;
                        tCriFile.Apply();
                        this.objLog.GravarLog(Log.TypeMessage.Success, "File \"" + psFile + "\" closed.");
                    }
                }
            }
            catch (Exception ex)
            {
                this.objLog.GravarLog(Log.TypeMessage.Error, ex.Message + " | " + ex.StackTrace);
            }
        }