public void Renamed_Success()
        {
            using (var testDirectory = new TempDirectory(GetTestFilePath()))
            using (var fsw = new FileSystemWatcher(testDirectory.Path))
            {
                Task<WaitForChangedResult> t = Task.Run(() =>
                    fsw.WaitForChanged(WatcherChangeTypes.Renamed | WatcherChangeTypes.Created, SuccessTimeoutMilliseconds)); // on some OSes, the renamed might come through as Deleted/Created

                string name = Path.Combine(testDirectory.Path, Path.GetRandomFileName());
                File.Create(name).Dispose();

                while (!t.IsCompleted)
                {
                    string newName = Path.Combine(testDirectory.Path, Path.GetRandomFileName());
                    File.Move(name, newName);
                    name = newName;
                    Task.Delay(BetweenOperationsDelayMilliseconds).Wait();
                }

                Assert.Equal(TaskStatus.RanToCompletion, t.Status);
                Assert.True(t.Result.ChangeType == WatcherChangeTypes.Created || t.Result.ChangeType == WatcherChangeTypes.Renamed);
                Assert.NotNull(t.Result.Name);
                Assert.False(t.Result.TimedOut);
            }
        }
Пример #2
1
    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
        switch (e.MenuItem.Value)
        {

            case "NewFolder":
                if ((RadTreeView1.SelectedNode != null) && (RadTreeView1.SelectedNode.Level == 0))
                {
                    string newNodeTitle = ("New Folder");
                    e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                    e.Node.Category = "Folder";
                    e.Node.ImageUrl = "/admin/images/folder.gif";
                    e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                    e.Node.ContextMenuID = "MainContextMenu";
                    e.Node.Value = getpath(Request["pg"].ToString()) + "\\" + newNodeTitle;
                    e.Node.Expanded = true;
                    Directory.CreateDirectory(getpath(Request["pg"].ToString()) + "\\" + newNodeTitle);
                    createtree("");
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                else
                {
                    string newNodeTitle = string.Format("New Folder", e.Node.ParentNode.Nodes.Count + 1);
                    e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                    e.Node.Category = "Folder";
                    e.Node.ImageUrl = "/admin/images/folder.gif";
                    e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                    e.Node.ContextMenuID = "MainContextMenu";
                    e.Node.Value = getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle;
                    e.Node.Expanded = true;
                    Directory.CreateDirectory(getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle);
                    createtree(getpath(Request["pg"].ToString()) + (RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1)).Replace("/", "\\"));
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                break;

            case "Delete":

                break;

            case "Rename":

                if (RadTreeView1.SelectedNode != null)
                {
                    GC.Collect();
                    RadTreeNode nodeEdited = e.Node;
                    string oldtext = e.Node.Text;
                    string oldpath = e.Node.Value.Substring(0, e.Node.Value.LastIndexOf("\\") + 1);
                    string newText = e.Node.Text;

                    nodeEdited.Text = newText;

                    string newpath = nodeEdited.Value;
                    if (e.Node.Category == "Files")
                    {

                        getitemonserver(e.Node.Category, e.Node.Value, oldpath + newText);
                    }
                    else
                    {

                        getitemonserver(e.Node.Category, oldpath + oldtext, oldpath + newText);
                    }
                    System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(oldpath);
                    mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
                    createtree(oldpath.Substring(0, oldpath.LastIndexOf("\\")));
                    getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
                }
                break;

        }
    }
 public void NonZeroTimeout_NoEvents_TimesOut(bool enabledBeforeWait)
 {
     using (var testDirectory = new TempDirectory(GetTestFilePath()))
     using (var dir = new TempDirectory(Path.Combine(testDirectory.Path, GetTestFileName())))
     using (var fsw = new FileSystemWatcher(testDirectory.Path))
     {
         if (enabledBeforeWait) fsw.EnableRaisingEvents = true;
         AssertTimedOut(fsw.WaitForChanged(0, 1));
         Assert.Equal(enabledBeforeWait, fsw.EnableRaisingEvents);
     }
 }
        public void Changed_Success()
        {
            using (var testDirectory = new TempDirectory(GetTestFilePath()))
            using (var fsw = new FileSystemWatcher(testDirectory.Path))
            {
                string name = Path.Combine(testDirectory.Path, Path.GetRandomFileName());
                File.Create(name).Dispose();

                Task<WaitForChangedResult> t = Task.Run(() => fsw.WaitForChanged(WatcherChangeTypes.Changed, SuccessTimeoutMilliseconds));
                while (!t.IsCompleted)
                {
                    File.AppendAllText(name, "text");
                    Task.Delay(BetweenOperationsDelayMilliseconds).Wait();
                }

                Assert.Equal(TaskStatus.RanToCompletion, t.Status);
                Assert.Equal(WatcherChangeTypes.Changed, t.Result.ChangeType);
                Assert.NotNull(t.Result.Name);
                Assert.Null(t.Result.OldName);
                Assert.False(t.Result.TimedOut);
            }
        }
Пример #5
0
    protected void RadTreeView1_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
    {
        RadTreeNode nodeEdited = e.Node;
        string newText = e.Text;
        nodeEdited.Text = newText;

        string oldpath = e.Node.Value.Substring(0, e.Node.Value.LastIndexOf("\\") + 1);
        string oldtext = e.Node.Value.Substring(oldpath.Length);

        if (nodeEdited.Category == "Files")
        {
            getitemonserver(nodeEdited.Category, nodeEdited.Value, oldpath + newText);
        }
        else { getitemonserver(nodeEdited.Category, oldpath + oldtext, oldpath + newText); }

        System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(oldpath);
        mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
        createtree(oldpath.Substring(0, oldpath.LastIndexOf("\\")));

        //UpdatePanel1.Update();
    }
Пример #6
0
    protected void RadTreeView1_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
        RadTreeNode sourceNode = e.SourceDragNode;
        RadTreeNode destNode = e.DestDragNode;
        RadTreeViewDropPosition dropPosition = e.DropPosition;

        string result = "";

        if (destNode != null)//drag&drop is performed between trees
        {

            if (sourceNode.TreeView.SelectedNodes.Count <= 1)
            {
                result += "<b>" + sourceNode.Text + "</b>" + ";";
                PerformDragAndDrop(dropPosition, sourceNode, destNode);
            }
            else if (sourceNode.TreeView.SelectedNodes.Count > 1)
            {
                foreach (RadTreeNode node in sourceNode.TreeView.SelectedNodes)
                {
                    result += "<b>" + node.Text + "</b>" + ";";
                    PerformDragAndDrop(dropPosition, node, destNode);
                }

            }
            else//dropped node will be a sibling of the destination node
            {
                if (sourceNode.TreeView.SelectedNodes.Count <= 1)
                {

                    if (!sourceNode.IsAncestorOf(destNode))
                    {
                        result += "<b>" + sourceNode.Text + "</b>" + ";";
                        sourceNode.Owner.Nodes.Remove(sourceNode);
                        destNode.Nodes.Add(sourceNode);
                    }
                }
                else if (sourceNode.TreeView.SelectedNodes.Count > 1)
                {
                    foreach (RadTreeNode node in RadTreeView1.SelectedNodes)
                    {
                        if (!node.IsAncestorOf(destNode))
                        {
                            result += "<b>" + node.Text + "</b>" + ";";
                            node.Owner.Nodes.Remove(node);
                            destNode.Nodes.Add(node);
                        }
                    }
                }
            }

            if (e.SourceDragNode.Category == "Files")
            {
                if (!System.IO.File.Exists(e.SourceDragNode.Value))
                {
                    System.IO.File.Move(e.SourceDragNode.Value, e.DestDragNode.Value + "\\" + e.SourceDragNode.Text);

                }
                else
                {
                    string fname = e.SourceDragNode.Text.Substring(0, e.SourceDragNode.Text.LastIndexOf("."));
                    string ext = e.SourceDragNode.Text.Substring(fname.Length);
                    int counter = 1;
                    string targetFileName = Path.Combine(e.DestDragNode.Value, fname + counter.ToString() + ext);

                    while (System.IO.File.Exists(targetFileName))
                    {
                        counter++;
                        targetFileName = Path.Combine(e.DestDragNode.Value, fname + counter.ToString() + ext);

                    }

                    System.IO.File.Move(e.SourceDragNode.Value, targetFileName);
                }
            }
            else
            {
                if (!System.IO.Directory.Exists(e.DestDragNode.Value + "\\" + e.SourceDragNode.Text))
                {
                    if (System.IO.Directory.Exists(e.SourceDragNode.Value))
                    {
                        System.IO.Directory.Move(e.SourceDragNode.Value, e.DestDragNode.Value + "\\" + e.SourceDragNode.Text);
                    }
                }
            }

            destNode.Expanded = true;
            System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(e.DestDragNode.Value);
            mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
            sourceNode.TreeView.ClearSelectedNodes();
            createtree(e.DestDragNode.Value);
            // UpdatePanel1.Update();

        }
    }
Пример #7
0
        /// <summary>
        /// Main EntryPoint
        /// </summary>
        static void Main()
        {
            #region CreateRsyncProcessStartInfo

            rsyncProcessStartInfo.FileName        = Settings.Default.RsyncPath;
            rsyncProcessStartInfo.Arguments       = CreateRsyncArgs();
            rsyncProcessStartInfo.CreateNoWindow  = true;
            rsyncProcessStartInfo.UseShellExecute = false;
            rsyncProcessStartInfo.WindowStyle     = ProcessWindowStyle.Hidden;

            #endregion

            #region Console

            Console.WriteLine($"watching:{Settings.Default.LocalPath}");

            #endregion

            #region IntervalMode

            if (Settings.Default.IntervalSeconds > 0)
            {
                new Thread(new ThreadStart(() =>
                {
                    while (true)
                    {
                        Thread.Sleep(IntervalTimeSpan);

                        if (Settings.Default.NotifyMode)
                        {
                            Console.WriteLine("rsync by interval");
                        }

                        Rsync(false);
                    }
                })).Start();
            }

            #endregion

            #region Watch

            using (var fileSystemWatcher = new FileSystemWatcher(Settings.Default.LocalPath))
            {
                fileSystemWatcher.EnableRaisingEvents = true;
                fileSystemWatcher.Created            += (o, e) =>
                {
                    if (Settings.Default.NotifyMode)
                    {
                        Console.WriteLine($"rsync by created: {e.FullPath}");
                    }

                    Rsync();
                };
                fileSystemWatcher.Deleted += (o, e) =>
                {
                    if (Settings.Default.NotifyMode)
                    {
                        Console.WriteLine($"rsync by deleted: {e.FullPath}");
                    }

                    Rsync();
                };
                fileSystemWatcher.Changed += (o, e) =>
                {
                    if (Settings.Default.NotifyMode)
                    {
                        Console.WriteLine($"rsync by changed: {e.FullPath}");
                    }

                    Rsync();
                };
                fileSystemWatcher.Renamed += (o, e) =>
                {
                    if (Settings.Default.NotifyMode)
                    {
                        Console.WriteLine($"rsync by renamed: {e.OldFullPath} -> {e.FullPath}");
                    }

                    Rsync();
                };

                while (true)
                {
                    fileSystemWatcher.WaitForChanged(WatcherChangeTypes.All);
                }
            }

            #endregion
        }
        public void CreatedDeleted_Success(WatcherChangeTypes changeType)
        {
            using (var testDirectory = new TempDirectory(GetTestFilePath()))
            using (var fsw = new FileSystemWatcher(testDirectory.Path))
            {
                Task<WaitForChangedResult> t = Task.Run(() => fsw.WaitForChanged(changeType, LongWaitTimeout));
                while (!t.IsCompleted)
                {
                    string path = Path.Combine(testDirectory.Path, Path.GetRandomFileName());
                    File.WriteAllText(path, "text");
                    Task.Delay(BetweenOperationsDelayMilliseconds).Wait();
                    if ((changeType & WatcherChangeTypes.Deleted) != 0)
                    {
                        File.Delete(path);
                    }
                }

                Assert.Equal(TaskStatus.RanToCompletion, t.Status);
                Assert.Equal(changeType, t.Result.ChangeType);
                Assert.NotNull(t.Result.Name);
                Assert.Null(t.Result.OldName);
                Assert.False(t.Result.TimedOut);
            }
        }
Пример #9
0
    protected void RadTreeView1_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
        RadTreeNode             sourceNode   = e.SourceDragNode;
        RadTreeNode             destNode     = e.DestDragNode;
        RadTreeViewDropPosition dropPosition = e.DropPosition;

        string result = "";

        if (destNode != null)//drag&drop is performed between trees
        {
            if (sourceNode.TreeView.SelectedNodes.Count <= 1)
            {
                result += "<b>" + sourceNode.Text + "</b>" + ";";
                PerformDragAndDrop(dropPosition, sourceNode, destNode);
            }
            else if (sourceNode.TreeView.SelectedNodes.Count > 1)
            {
                foreach (RadTreeNode node in sourceNode.TreeView.SelectedNodes)
                {
                    result += "<b>" + node.Text + "</b>" + ";";
                    PerformDragAndDrop(dropPosition, node, destNode);
                }
            }
            else//dropped node will be a sibling of the destination node
            {
                if (sourceNode.TreeView.SelectedNodes.Count <= 1)
                {
                    if (!sourceNode.IsAncestorOf(destNode))
                    {
                        result += "<b>" + sourceNode.Text + "</b>" + ";";
                        sourceNode.Owner.Nodes.Remove(sourceNode);
                        destNode.Nodes.Add(sourceNode);
                    }
                }
                else if (sourceNode.TreeView.SelectedNodes.Count > 1)
                {
                    foreach (RadTreeNode node in RadTreeView1.SelectedNodes)
                    {
                        if (!node.IsAncestorOf(destNode))
                        {
                            result += "<b>" + node.Text + "</b>" + ";";
                            node.Owner.Nodes.Remove(node);
                            destNode.Nodes.Add(node);
                        }
                    }
                }
            }


            if (e.SourceDragNode.Category == "Files")
            {
                if (!System.IO.File.Exists(e.SourceDragNode.Value))
                {
                    System.IO.File.Move(e.SourceDragNode.Value, e.DestDragNode.Value + "\\" + e.SourceDragNode.Text);
                }
                else
                {
                    string fname          = e.SourceDragNode.Text.Substring(0, e.SourceDragNode.Text.LastIndexOf("."));
                    string ext            = e.SourceDragNode.Text.Substring(fname.Length);
                    int    counter        = 1;
                    string targetFileName = Path.Combine(e.DestDragNode.Value, fname + counter.ToString() + ext);

                    while (System.IO.File.Exists(targetFileName))
                    {
                        counter++;
                        targetFileName = Path.Combine(e.DestDragNode.Value, fname + counter.ToString() + ext);
                    }

                    System.IO.File.Move(e.SourceDragNode.Value, targetFileName);
                }
            }
            else
            {
                if (!System.IO.Directory.Exists(e.DestDragNode.Value + "\\" + e.SourceDragNode.Text))
                {
                    if (System.IO.Directory.Exists(e.SourceDragNode.Value))
                    {
                        System.IO.Directory.Move(e.SourceDragNode.Value, e.DestDragNode.Value + "\\" + e.SourceDragNode.Text);
                    }
                }
            }

            destNode.Expanded = true;
            System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(e.DestDragNode.Value);
            mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
            sourceNode.TreeView.ClearSelectedNodes();
            createtree(e.DestDragNode.Value);
            // UpdatePanel1.Update();
        }
    }
Пример #10
0
    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
        switch (e.MenuItem.Value)
        {
        case "NewFolder":
            if ((RadTreeView1.SelectedNode != null) && (RadTreeView1.SelectedNode.Level == 0))
            {
                string newNodeTitle = ("New Folder");
                e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                e.Node.Category         = "Folder";
                e.Node.ImageUrl         = "/admin/images/folder.gif";
                e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                e.Node.ContextMenuID    = "MainContextMenu";
                e.Node.Value            = getpath(Request["pg"].ToString()) + "\\" + newNodeTitle;
                e.Node.Expanded         = true;
                Directory.CreateDirectory(getpath(Request["pg"].ToString()) + "\\" + newNodeTitle);
                createtree("");
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            else
            {
                string newNodeTitle = string.Format("New Folder", e.Node.ParentNode.Nodes.Count + 1);
                e.Node.Nodes.Add(new RadTreeNode(newNodeTitle));
                e.Node.Category         = "Folder";
                e.Node.ImageUrl         = "/admin/images/folder.gif";
                e.Node.ExpandedImageUrl = "/admin/images/folder.gif";
                e.Node.ContextMenuID    = "MainContextMenu";
                e.Node.Value            = getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle;
                e.Node.Expanded         = true;
                Directory.CreateDirectory(getpath(Request["pg"].ToString()) + RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1) + "\\" + newNodeTitle);
                createtree(getpath(Request["pg"].ToString()) + (RadTreeView1.SelectedNode.FullPath.Substring(getmainfolder(Request["pg"].ToString()).Length + 1)).Replace("/", "\\"));
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            break;

        case "Delete":

            break;

        case "Rename":

            if (RadTreeView1.SelectedNode != null)
            {
                GC.Collect();
                RadTreeNode nodeEdited = e.Node;
                string      oldtext    = e.Node.Text;
                string      oldpath    = e.Node.Value.Substring(0, e.Node.Value.LastIndexOf("\\") + 1);
                string      newText    = e.Node.Text;

                nodeEdited.Text = newText;

                string newpath = nodeEdited.Value;
                if (e.Node.Category == "Files")
                {
                    getitemonserver(e.Node.Category, e.Node.Value, oldpath + newText);
                }
                else
                {
                    getitemonserver(e.Node.Category, oldpath + oldtext, oldpath + newText);
                }
                System.IO.FileSystemWatcher mywatcher = new FileSystemWatcher(oldpath);
                mywatcher.WaitForChanged(WatcherChangeTypes.All, 2000);
                createtree(oldpath.Substring(0, oldpath.LastIndexOf("\\")));
                getfold(ref al, Server.MapPath("~/App_Uploads_Img/"));
            }
            break;
        }
    }
Пример #11
0
        public void Processor(object data)
        {
            string path = (string)data;

            using (var w = new FileSystemWatcher {
                Path = path,
                IncludeSubdirectories = _args.Recursive,
                Filter = "*.*"
            }) {
                w.Error += new ErrorEventHandler(OnWatcherError);

                // Parse "events" argument
                WatcherChangeTypes changes = 0;
                if (_args.Events.Contains("create"))
                {
                    changes |= WatcherChangeTypes.Created;
                }
                if (_args.Events.Contains("modify"))
                {
                    changes |= WatcherChangeTypes.Changed;
                }
                if (_args.Events.Contains("delete"))
                {
                    changes |= WatcherChangeTypes.Deleted;
                }
                if (_args.Events.Contains("move"))
                {
                    changes |= WatcherChangeTypes.Renamed;
                }

                // Main loop
                if (!_args.Quiet)
                {
                    Console.Error.WriteLine(
                        "===> {0} for {1} in {2}{3} for {4}",
                        _args.Monitor ? "Monitoring" : "Watching",
                        changes,
                        path,
                        _args.Recursive ? " -r" : "",
                        String.Join(", ", _args.Events.ToArray())
                        );
                }
                w.EnableRaisingEvents = true;
                while (true)
                {
                    var e = w.WaitForChanged(changes);
                    _mutex.WaitOne();
                    if (_eventOccured)
                    {
                        _mutex.ReleaseMutex();
                        break;
                    }
                    if (null != _args.Exclude && _args.Exclude.IsMatch(e.Name))
                    {
                        continue;
                    }
                    if (WatcherChangeTypes.Renamed.Equals(e.ChangeType))
                    {
                        Output(Console.Out, _args.Format, w, Change.MOVE_FROM, e.OldName);
                        Output(Console.Out, _args.Format, w, Change.MOVE_TO, e.Name);
                    }
                    else
                    {
                        Output(Console.Out, _args.Format, w, Changes[e.ChangeType], e.Name);
                    }
                    if (!_args.Monitor)
                    {
                        _eventOccured = true;
                        _semaphore.Release();
                    }
                    _mutex.ReleaseMutex();
                }
            }
        }
Пример #12
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            double amtDebt = PIn.Double(textAmount.Text);

            if (amtDebt == 0)
            {
                MessageBox.Show("Please fill in an amount.");
                return;
            }
            if (amtDebt < 25)
            {
                MessageBox.Show("Amount of debt must be at least $25.00.");
                return;
            }
            if (amtDebt > 9999999.00)           //limit 10 char
            {
                MessageBox.Show("Amount of debt is unreasonably large.");
                return;
            }
            DateTime dateDelinquency = PIn.Date(textDate.Text);

            if (dateDelinquency.Year < 1950)
            {
                MessageBox.Show("Date is not valid.");
                return;
            }
            if (dateDelinquency > DateTime.Today)
            {
                MessageBox.Show("Date cannot be a future date.");
                return;
            }
            if (!Regex.IsMatch(textPassword.Text, @"^[A-Z]{2}\d{4}$"))
            {
                MessageBox.Show("Password is not in correct format. Must be like this: AB1234");
                return;
            }
            if (textPassword.Text != PrefC.GetString(PrefName.TrojanExpressCollectPassword))          //user changed password
            {
                Prefs.UpdateString(PrefName.TrojanExpressCollectPassword, textPassword.Text);
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            Cursor = Cursors.WaitCursor;
            string folderPath = PrefC.GetString(PrefName.TrojanExpressCollectPath);

            if (folderPath == "")
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Export folder has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            if (!folderPath.EndsWith("\\"))
            {
                folderPath += "\\";
            }
            if (!File.Exists(folderPath + "TROBEN.HB"))
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not installed or is not configured for the folder: "
                                + folderPath + ".  Please contact Trojan Software Support at 800-451-9723 x1 or x2");
                return;
            }
            File.Delete(folderPath + "TROBEN.HB");
            FileSystemWatcher    watcher    = new FileSystemWatcher(folderPath, "TROBEN.HB");
            WaitForChangedResult waitResult = watcher.WaitForChanged(WatcherChangeTypes.Created, 10000);

            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not running. Please check it.");
                return;
            }
            long billingType = PrefC.GetLong(PrefName.TrojanExpressCollectBillingType);

            if (billingType == 0)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Billing type has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            StringBuilder str = new StringBuilder();

            if (radioDiplomatic.Checked)
            {
                str.Append("D*");
            }
            else if (radioFirm.Checked)
            {
                str.Append("F*");
            }
            else if (radioSkip.Checked)
            {
                str.Append("S*");
            }
            str.Append(Clip(patCur.LName, 18) + "*");
            str.Append(Clip(patCur.FName, 18) + "*");
            str.Append(Clip(patCur.MiddleI, 1) + "*");
            str.Append(Clip(guarCur.LName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.FName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.MiddleI, 1) + "*");
            str.Append(guarCur.SSN.Substring(0, 3) + "-" + guarCur.SSN.Substring(3, 2) + "-" + guarCur.SSN.Substring(5, 4) + "*"); //validated
            if (guarCur.Birthdate.Year < 1880)
            {
                str.Append("*");
            }
            else
            {
                str.Append(guarCur.Birthdate.ToString("MM/dd/yyyy") + "*");
            }
            str.Append(Clip(guarCur.HmPhone, 13) + "*");
            if (empCur == null)
            {
                str.Append("**");
            }
            else
            {
                str.Append(Clip(empCur.EmpName, 35) + "*");
                str.Append(Clip(empCur.Phone, 13) + "*");
            }
            string address = guarCur.Address;          //validated

            if (guarCur.Address2 != "")
            {
                address += ", " + guarCur.Address2;
            }
            str.Append(Clip(address, 30) + "*");
            str.Append(Clip(guarCur.City, 20) + "*");                 //validated
            str.Append(Clip(guarCur.State, 2) + "*");                 //validated
            str.Append(Clip(guarCur.Zip, 5) + "*");                   //validated
            str.Append(amtDebt.ToString("F2") + "*");                 //validated
            str.Append(dateDelinquency.ToString("MM/dd/yyyy") + "*"); //validated
            str.Append(textPassword.Text + "*");                      //validated
            str.Append(Clip(Security.CurUser.UserName, 25) + "\r\n"); //There is always a logged in user
            int    thisNum    = TrojanQueries.GetUniqueFileNum();
            string outputFile = "CT" + thisNum.ToString().PadLeft(6, '0') + ".TRO";

            File.AppendAllText(folderPath + outputFile, str.ToString());
            watcher    = new FileSystemWatcher(folderPath, outputFile);
            waitResult = watcher.WaitForChanged(WatcherChangeTypes.Deleted, 10000);
            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Warning!! Request was not sent to Trojan within the 10 second limit.");
                return;
            }
            Patients.UpdateFamilyBillingType(billingType, patCur.Guarantor);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }
Пример #13
0
 /// <summary>
 /// A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor.
 /// </summary>
 /// <returns>A <see cref="WaitForChangedResult"/> that contains specific information on the change that occurred.</returns>
 /// <param name="changeType">The <see cref="WatcherChangeTypes"/> to watch for.</param>
 public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => m_fileSystemWatcher.WaitForChanged(changeType);