예제 #1
0
        public static FolderStatus Validate(string path)
        {
            FolderStatus status = FolderStatus.Valid;

            if (String.IsNullOrEmpty(path))
            {
                status |= FolderStatus.NullPath;
            }
            else if (!FileSupport.IsValidPath(path))
            {
                status |= FolderStatus.InvalidPath;
            }
            else if (!System.IO.Path.IsPathFullyQualified(path))
            {
                status |= FolderStatus.NotFullyQualified;
            }
            else if (!Directory.Exists(path))
            {
                status |= FolderStatus.Nonextant;
            }
            else if (!FileSupport.IsFolderReadable(path))
            {
                status |= FolderStatus.Unreadable;
            }
            return(status);
        }
예제 #2
0
        public static string GetStatusDescription(FolderStatus status)
        {
            StringBuilder sb = new StringBuilder();

            if (status == FolderStatus.Valid)
            {
                return("Valid");
            }
            else if ((status & FolderStatus.NullPath) != 0)
            {
                sb.Append("Null path");
            }
            else if ((status & FolderStatus.InvalidPath) != 0)
            {
                sb.Append("Invalid path");
            }
            else if ((status & FolderStatus.NotFullyQualified) != 0)
            {
                sb.Append("Not fully qualified");
            }
            else if ((status & FolderStatus.Nonextant) != 0)
            {
                sb.Append("Does not exist");
            }
            else if ((status & FolderStatus.Unreadable) != 0)
            {
                sb.Append("Cannot be read");
            }
            else if ((status & FolderStatus.Duplicate) != 0)
            {
                sb.Append("Duplicate");
            }
            return(sb.ToString());
        }
예제 #3
0
        public FolderStatus GetProjectStatus()
        {
            FolderStatus StatusResult;

            lock (StatusLock) { StatusResult = LastStatusCheckResult; LastRetrievedStatus = StatusResult; }
            return(StatusResult);
        }
예제 #4
0
        static void Main()
        {
            using (Imap imap = new Imap())
            {
                imap.Connect(_server);                              // Use overloads or ConnectSSL if you need to specify different port or SSL.
                imap.Login(_user, _password);                       // You can also use: LoginPLAIN, LoginCRAM, LoginDIGEST, LoginOAUTH methods,
                                                                    // or use UseBestLogin method if you want Mail.dll to choose for you.

                List <FolderInfo> folders = imap.GetFolders();      // List all folders on the IMAP server

                Console.WriteLine("Folders on IMAP server: ");
                foreach (FolderInfo folder in folders)
                {
                    FolderStatus status = imap.Examine(folder.Name);    // Examine each folder for number of total and recent messages

                    Console.WriteLine(                                  // Display folder information
                        string.Format("{0}, Recent: {1}, Total: {2}",
                                      folder.Name,
                                      status.MessageCount,
                                      status.Recent));
                }

                // You can also Create, Rename and Delete folders:
                imap.CreateFolder("Temporary");
                imap.RenameFolder("Temporary", "Temp");
                imap.DeleteFolder("Temp");

                imap.Close();
            }
        }
예제 #5
0
 // Connstructor that sets the private member variables
 public FolderValidator(FolderStatus folderStatus, string folderTree, string root, ReportList reportList)
 {
     _folderStatus          = folderStatus;
     _folderTreePathAndFile = Environment.CurrentDirectory + @"\FolderTrees\" + folderTree;
     _folderTreePathAndFile = _folderTreePathAndFile.Replace(@"\bin", "").Replace(@"\Debug", "").Replace(@"\Release", "");
     _reportList            = reportList;
     _root = root;
 }
예제 #6
0
 public void UpdateIndexedFolder(string path, string newPath, uint newDepth, FolderStatus newStatus)
 {
     if (newDepth > LargeIndexLevel)
     {
         Log <IndexedFolderCollection> .Warn(LargeIndexLevelWarning, newPath, newDepth);
     }
     UpdateIndexedFolder(path, new IndexedFolder(newPath, newDepth, newStatus));
 }
예제 #7
0
 public Folder(string folderId, string path, FolderSyncState syncState, FolderStatus status)
 {
     this.FolderId     = folderId;
     this.Path         = path;
     this.SyncState    = syncState;
     this.syncingPaths = new HashSet <string>();
     this._status      = status;
     this.FolderErrors = new List <FolderError>().AsReadOnly();
 }
예제 #8
0
 public Folder(string folderId, string label, string path, FolderSyncState syncState, FolderStatus status)
 {
     this.FolderId     = folderId;
     this.Label        = String.IsNullOrWhiteSpace(label) ? folderId : label;
     this.Path         = path;
     this.SyncState    = syncState;
     this.syncingPaths = new HashSet <string>();
     this._status      = status;
     this.FolderErrors = new List <FolderError>().AsReadOnly();
 }
예제 #9
0
파일: FolderCreated.cs 프로젝트: xlgwr/osdr
 public FolderCreated(Guid id, Guid correlationId, Guid userId, Guid?parentId, string name, Guid sessionId, FolderStatus status)
 {
     Id            = id;
     CorrelationId = correlationId;
     UserId        = userId;
     ParentId      = parentId;
     Name          = name;
     SessionId     = sessionId;
     Status        = status;
 }
예제 #10
0
        private void FolderStatusChanged(string folderId, FolderStatus folderStatus)
        {
            if (!this.folders.TryGetValue(folderId, out var folder))
            {
                return; // Don't know about it
            }
            folder.Status = folderStatus;

            this.OnStatusChanged(folder, folderStatus);
        }
예제 #11
0
        public IndexedFolder(string path, uint level, FolderStatus status) : this()
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            Path   = Services.Environment.ExpandPath(path);
            Level  = level;
            Status = status;
        }
예제 #12
0
    public override void OnInspectorGUI()
    {
        SetGUIStyles();
        FStatus();

        if (m_activeEntity == null || !m_activeEntity.CompareTag("Player"))
        {
            SetActiveObject();
        }

        if (m_folderStatus == FolderStatus.NONE)
        {
            if (GUILayout.Button("Set Extraction Data"))
            {
                Debug.Log("Set Folder");
                m_folderPath = EditorUtility.OpenFolderPanel("Set Extraction Folder", "", "");

                if (m_folderPath.Length > 0)
                {
                    m_folderStatus = FolderStatus.SET;
                }
            }
        }
        else
        {
            GUILayout.TextField("Current Path:");
            GUILayout.TextField(m_folderPath);
            if (GUILayout.Button("Extract Data"))
            {
                using (StreamWriter writer = new StreamWriter(m_folderPath + "/EntityData.txt", false))
                {
                    string entityData = m_activeEntity.SerializedEntityData();
                    writer.Write(entityData);
                }

                using (StreamWriter writer = new StreamWriter(m_folderPath + "/PlayerData.txt", false))
                {
                    string playerData = m_activeEntity.SerializedPlayerData();
                    writer.Write(playerData);
                }
            }

            if (GUILayout.Button("Reset Folder Path"))
            {
                m_folderPath   = null;
                m_folderStatus = FolderStatus.NONE;
            }
        }

        DrawDefaultInspector();
    }
예제 #13
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FolderStatus folderStatus = (FolderStatus)value;

            switch (folderStatus)
            {
            case FolderStatus.Matched: return(Visibility.Hidden);

            default:
            case FolderStatus.Contained:
            case FolderStatus.Different:
            case FolderStatus.LeftOnly:
            case FolderStatus.RightOnly:
            case FolderStatus.Unknown: return(Visibility.Visible);
            }
        }
예제 #14
0
        public static FolderStatus CreateDir(string Path)
        {
            FolderStatus tempStatus = FolderStatus.Failed;

            bool exists = System.IO.Directory.Exists(Path);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(Path);
                tempStatus = System.IO.Directory.Exists(Path) ? FolderStatus.Success : FolderStatus.Failed;
            }
            else
            {
                tempStatus = FolderStatus.Exists;
            }

            return(tempStatus);
        }
예제 #15
0
        private void StatusMonitor()
        {
            Thread.CurrentThread.Name = "Status Monitor for Project '" + Name + "'";
            while (!Closing)
            {
                FolderStatus fsResult = GetProjectStatusAux();
                lock (StatusLock)
                {
                    LastStatusCheckResult = fsResult;
                    LastStatusCheck       = DateTime.Now;
                }

                int CummulativeElapsed = 0;
                while (CummulativeElapsed < 15000 && !Closing)
                {
                    Thread.Sleep(100); CummulativeElapsed += 100;
                }
            }
        }
예제 #16
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FolderStatus folderStatus = (FolderStatus)value;

            switch (folderStatus)
            {
            case FolderStatus.Matched: return("Identical (shift to swap in viewer)");

            default:
            case FolderStatus.Contained: return("Contained");

            case FolderStatus.Different: return("Different (shift to swap in viewer)");

            case FolderStatus.LeftOnly: return("Left only");

            case FolderStatus.RightOnly: return("Right only");

            case FolderStatus.Unknown: return("Unknown");
            }
        }
예제 #17
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FolderStatus folderState = (FolderStatus)value;

            switch (folderState)
            {
            case FolderStatus.Different: return(new SolidColorBrush(Colors.Yellow));

            case FolderStatus.LeftOnly: return(new SolidColorBrush(Colors.Red));

            case FolderStatus.RightOnly: return(new SolidColorBrush(Colors.Green));

            case FolderStatus.Matched: return(new SolidColorBrush(Colors.White));

            case FolderStatus.Contained: return(new SolidColorBrush(Colors.DarkGray));

            default:
            case FolderStatus.Unknown: return(new SolidColorBrush(Colors.Gray));
            }
        }
예제 #18
0
 private void OnStatusChanged(Folder folder, FolderStatus folderStatus)
 {
     this.eventDispatcher.Raise(this.StatusChanged, new FolderStatusChangedEventArgs(folder.FolderId, folderStatus));
 }
예제 #19
0
 public FolderStatusChangedEventArgs(string folderId, FolderStatus folderStatus)
 {
     this.FolderId     = folderId;
     this.FolderStatus = folderStatus;
 }
예제 #20
0
        public void GetMessages()
        {
            //LastRun last = LoadPreviousRun();
            SendMail.LastRunMessage last = null;

            using (Imap imap = new Imap())
            {
                imap.ConnectSSL("imap.ukr.net");
                imap.UseBestLogin("*****@*****.**", "DKB2pSzrIcs25QL2");

                FolderStatus status = imap.SelectInbox();

                //List<long> uids = imap.GetAll();
                List <long> uids;
                if (last == null || last.UIDValidity != status.UIDValidity)
                {
                    uids = imap.GetAll();
                }
                else
                {
                    uids = imap.Search().Where(Expression.UID(Range.From(last.LargestUID)));
                    uids.Remove(last.LargestUID);
                }
                maleGrid.Columns.AddRange(new DataGridViewColumn[] {
                    new DataGridViewTextBoxColumn()
                    {
                        Width = 100
                    },
                    new DataGridViewTextBoxColumn()
                    {
                        Width = 300
                    },
                    new DataGridViewTextBoxColumn()
                    {
                        Width = 380
                    },
                });
                foreach (long uid in uids)
                {
                    var eml = imap.GetMessageByUID(uid);
                    email = new MailBuilder().CreateFromEml(eml);
                    //maleGrid.Rows.Add(email.Sender.Name, email.Subject.ToString(), email.Text);
                    int rowNumber = maleGrid.Rows.Add();
                    maleGrid.Rows[rowNumber].Cells[0].Value       = email.Sender.Name;
                    maleGrid.Rows[rowNumber].Cells[1].Value       = email.Subject.ToString();
                    maleGrid.Rows[rowNumber].Cells[2].Value       = email.Text;
                    maleGrid.Rows[rowNumber].Cells[2].ToolTipText = email.Text;
                    //ToolTip t = new ToolTip();
                    //t.SetToolTip(maleGrid, email.Text);

                    //MessageBox.Show(email.Sender.Name);
                    //MessageBox.Show(email.Subject.ToString());
                    //MessageBox.Show(email.Text);

                    SendMail.LastRunMessage current = new SendMail.LastRunMessage
                    {
                        UIDValidity = status.UIDValidity,
                        LargestUID  = uid
                    };
                    //SaveThisRun(current);
                }
                imap.Close();
            }
        }
예제 #21
0
 public void ChangeStatus(Guid userId, FolderStatus status)
 {
     ApplyChange(new StatusChanged(Id, userId, status));
 }
예제 #22
0
        public async Task <IActionResult> GetBankTransactions(string accountNumber = null)
        {
            List <string> vs = new List <string>();

            BankAccount bankAccount = await FindBankAccount(accountNumber);

            GoogleAuth googleAuth = await GetGoogleAuth(bankAccount?.AlertEmail, bankAccount?.AccountNumber);

            List <BankTransaction> bankTransactions = new List <BankTransaction>();

            //long? largestUID = googleAuth.LargestUID;

            try
            {
                using (Imap imap = new Imap())
                {
                    GoogleApi api  = new GoogleApi(googleAuth?.AccessToken);
                    string    user = api.GetEmail();

                    imap.ConnectSSL("imap.gmail.com");  // or ConnectSSL for SSL
                    imap.LoginOAUTH2(user, googleAuth?.AccessToken);

                    FolderStatus status = imap.SelectInbox();


                    imap.SelectInbox();

                    //while (true)
                    //{
                    //Uncomment the line below for instant push  email notification
                    //FolderStatus currentStatus = imap.Idle();
                    List <long> uids;
                    if (googleAuth.LargestUID == 0 || googleAuth.UIDValidity != status.UIDValidity)
                    {
                        //get emails in the last one month
                        uids = imap.Search().Where(
                            Expression.And(
                                Expression.From("*****@*****.**"),
                                Expression.SentSince(DateTime.Now.AddMonths(-1)))
                            );
                    }
                    else
                    {
                        uids = imap.Search().Where(
                            Expression.And(
                                Expression.From("*****@*****.**"),
                                Expression.UID(Range.From(googleAuth.LargestUID))
                                ));
                        uids.Remove(googleAuth.LargestUID);
                    }
                    //List<MessageInfo> infos = imap.GetMessageInfoByUID(uids);

                    //int counter = 0;
                    foreach (long uid in uids)
                    {
                        //counter++;
                        MessageInfo info = imap.GetMessageInfoByUID(uid);
                        //var
                        if (info.Envelope.Subject.Contains("Transaction Alert [Credit", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        var   eml   = imap.GetMessageByUID(uid);
                        IMail email = new MailBuilder().CreateFromEml(eml);

                        //List<long> uids = imap.Search(Expression.From("gtbank.com"));
                        //for (int i = 1; i < 20; i++)
                        //{

                        //IMail email = new MailBuilder()
                        //    .CreateFromEml(imap.GetMessageByUID(uids[uids.Count - i]));
                        if (email.Subject.Contains("Transaction Alert [Debit", StringComparison.OrdinalIgnoreCase) ||
                            (email.GetBodyAsText().Contains("eLectronic Notification Service", StringComparison.OrdinalIgnoreCase) &&
                             email.GetBodyAsText().Contains("Debit transaction", StringComparison.OrdinalIgnoreCase))
                            //&& email.GetBodyAsText().Contains($"{bankRegistered.AccountNo}")
                            )
                        {
                            Dictionary <string, string> transactionDetails = new Dictionary <string, string>();
                            string emailAsText      = email.GetBodyAsText();
                            string emailAsTextTwo   = email.GetTextFromHtml();
                            string emailAsTextThree = email.Text;
                            if (emailAsText.Length < 10)
                            {
                                continue;
                            }

                            transactionDetails = ExtractText(emailAsText);
                            if (transactionDetails["Account Number"] != accountNumber)
                            {
                                continue;
                            }
                            BankTransaction transaction = new BankTransaction
                            {
                                //transaction.AccountNo = transactionDetails["AccountNo"];
                                Subject = email.Subject
                            };
                            if (email.Subject.Contains("Debit", StringComparison.OrdinalIgnoreCase) ||
                                email.GetBodyAsText().Contains("Debit", StringComparison.OrdinalIgnoreCase))
                            {
                                transaction.TransactionType = "Debit";
                            }
                            if (email.Subject.Contains("Credit", StringComparison.OrdinalIgnoreCase) ||
                                email.GetBodyAsText().Contains("Credit", StringComparison.OrdinalIgnoreCase))
                            {
                                transaction.TransactionType = "Credit";
                            }
                            transaction.Description       = transactionDetails["Description"];
                            transaction.TransactionAmount = Convert.ToDecimal(transactionDetails["Amount"]);
                            transaction.Remarks           = transactionDetails["Remarks"];
                            transaction.AccountNumber     = transactionDetails["Account Number"];
                            //You can try to format the datetime to a britain english culture, IFormatProvider
                            transaction.TransactionDate = Convert.ToDateTime(transactionDetails["Date"] + " " + transactionDetails["Time"]);
                            bool IsExists = await VerifyTransaction(transaction.AccountNumber, transaction.TransactionDate,
                                                                    transaction.TransactionType, transaction.TransactionAmount);

                            if (IsExists)
                            {
                                continue;
                            }

                            //appuser Id is set in the Save transaction Method
                            await SaveTransaction(transaction);

                            bankTransactions.Add(transaction);
                        }
                    }
                    UpdateLargestUID(uids[(uids.Count) - 1], googleAuth, status.UIDValidity);
                    //}
                    imap.Close();
                }
            }
            catch (ImapResponseException ex)
            {
                Debug.WriteLine(ex.Message);
                _logger.LogError(ex.StackTrace);
                googleAuth.AccessToken = await RefreshAccessToken(googleAuth.RefreshToken);

                UpdateGoogleOAuth(googleAuth);
                await GetBankTransactions(accountNumber);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                //log exception
                _logger.LogError(ex.StackTrace);
            }
            return(RedirectToAction("Index", "BankTransaction", new { accountId = bankAccount.BankAccountId }));
        }
예제 #23
0
 public void SetDuplicate()
 {
     _status |= FolderStatus.Duplicate;
 }
예제 #24
0
 public Folder(Guid id, Guid correlationId, Guid userId, Guid?parentId, string name, Guid sessionId, FolderStatus status = FolderStatus.Created)
 {
     Id = id;
     ApplyChange(new FolderCreated(Id, correlationId, userId, parentId, name, sessionId, status));
 }
예제 #25
0
 protected override void setup()
 {
     status_ = new FolderStatus();
 }
예제 #26
0
 private void OnFolderSummaryChanged(string folderId, FolderStatus summary)
 {
     this.FolderStatusChanged?.Invoke(this, new FolderStatusChangedEventArgs(folderId, summary));
 }
예제 #27
0
 public PathFolder(string path)
 {
     _path   = path;
     _status = Validate(path);
 }
예제 #28
0
파일: StatusChanged.cs 프로젝트: xlgwr/osdr
 public StatusChanged(Guid id, Guid userId, FolderStatus status)
 {
     Id     = id;
     UserId = userId;
     Status = status;
 }