Пример #1
0
        private void moveDirectory(string destination, object order)
        {
            string listBoxSelected = Convert.ToString(order);
              // get destination folder from xml
              string OrderDispatcherXml = GlobalClass.pathsXML;
              XDocument RitzOrderDispatcherXml = XDocument.Load(OrderDispatcherXml);
              var dest = RitzOrderDispatcherXml.Descendants(destination + "_folder").ElementAt(0).Value;
              // let user know we're moving the folder
              listBox.Text = listBoxSelected + "   Moving folder...";

              string orderPath = listBoxSelected.Remove(0, 21);   // remove the new order created message
              string orderDirName = orderPath.Split('\\').Last();   // get just the name of the order folder
              string orderDest = Path.Combine(dest, orderDirName.Replace("order", "temp"));   // set temp path for order move

              try
              {
            if (!Directory.Exists(orderDest))    // create the temp path if it doesnt already exist
            {
              Directory.CreateDirectory(orderDest);
            }
            // get the name of all the files in the order folder
            var orderFiles = from fullFileName in Directory.EnumerateFiles(orderPath)
                         select Path.GetFileName(fullFileName);
            foreach (string orderFile in orderFiles)
            {
              string orderDestFull = Path.Combine(orderDest, orderFile);
              if (File.Exists(orderDestFull))    // if we move a file we cant overwrite
              {
            File.Delete(orderDestFull);
              }

              File.Move(Path.Combine(orderPath, orderFile), orderDestFull);
            }

            Directory.Move(orderDest, Path.Combine(dest, orderDirName));    //rename from temp back to order in the new location
            Directory.Delete(orderPath);

            string userMsg = string.Empty;
            switch (destination)
            {
              case "instore":
            userMsg = "Order " + orderDirName.Replace(".order", "") + " was sent to be printed in-store.";
            break;

              case "outlab":
            userMsg = "Order " + orderDirName.Replace(".order", "") + " was sent to be printed at the outlab.";
            break;
            }
            lblSettingsChanged.Text = userMsg;
            LogIt logEntry = new LogIt(userMsg);
              }
              catch (Exception e)
              {
            lblSettingsChanged.Text = "Error moving order files.\n" + e.ToString();
              }
              listBox.Items.Remove(listBox.SelectedItem);
        }
Пример #2
0
 public void OnDeleted(object sender, FileSystemEventArgs e)
 {
     string userMsg = "Order " + e.Name.Replace(".order", "") + " has been transmitted to the outlab.";
       this.Invoke((MethodInvoker)delegate { lblSettingsChanged.Text = userMsg; });
       LogIt logEntry = new LogIt(userMsg);
 }
Пример #3
0
 public void OnRenamed(object sender, RenamedEventArgs e)
 {
     this.Invoke((MethodInvoker)delegate { listBox.Items.Add(String.Format("New Order Created -- {0}", e.FullPath)); });
       string userMsg = "New Order Created -- " + e.Name.Replace(".order", "");
       LogIt logEntry = new LogIt(userMsg);
 }