Example #1
0
        public static void NotifYUser(Settings settings, SettingsPrinter printer, List<InkLevel> inkLevel)
        {
            string title = "Printer Ink is at low level";
            string body = "";
            //body += title + "\n\r\n\r";
            body += "Printer Details:\n\r";
            body += printer.Name + "\n\r";

            foreach (var level in inkLevel)
            {
                if (level.Value <= printer.Level)
                {
                    body += string.Format("{0} - {1:00%}\n\r", level.Name, level.Value);
                }
            }
            body += "\n\r\n\r*****";

            try
            {
                var pipeClient = new NamedPipeClientStream("InkMonPipe");

                pipeClient.Connect(3000);

                if (pipeClient.IsConnected)
                {
                    var buf = Encoding.ASCII.GetBytes(body);
                    pipeClient.Write(buf, 0, buf.Length);
                    pipeClient.WaitForPipeDrain();
                    pipeClient.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #2
0
 public static bool LoadFromFile(string fileName, out SettingsPrinter obj)
 {
     Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
Example #3
0
 /// <summary>
 ///     Deserializes xml markup from file into an SettingsPrinter object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output SettingsPrinter object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out SettingsPrinter obj, out Exception exception)
 {
     exception = null;
     obj = default(SettingsPrinter);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Example #4
0
 public static bool Deserialize(string input, out SettingsPrinter obj)
 {
     Exception exception;
     return Deserialize(input, out obj, out exception);
 }
Example #5
0
 /// <summary>
 ///     Deserializes workflow markup into an SettingsPrinter object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output SettingsPrinter object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out SettingsPrinter obj, out Exception exception)
 {
     exception = null;
     obj = default(SettingsPrinter);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Example #6
0
 private void SetPrinterDriver(SettingsPrinter printer)
 {
     var info = new PrinterInfo();
     info.Caption = printer.Caption;
     if (PrinterHelper.GetPrinterInfo(ref info))
     {
         printer.Name = info.Name;
         printer.Port = info.Port;
     }
     var manf = info.Name.Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries)[0];
     var pluginName = _pluginsManager.LoadedPlugins[0].Name;
     foreach (var loadedPlugin in _pluginsManager.LoadedPlugins)
     {
         if (loadedPlugin.Brand.ToLower().Contains(manf.ToLower()))
         {
             pluginName = loadedPlugin.Name;
             var ports = loadedPlugin.Port.Split(',');
             var foundMatch = false;
             foreach (var port in ports)
             {
                 if (port.Trim().ToLower().Contains(info.Port.Substring(0, port.Trim().Length).ToLower()) ||
                     port.Trim() == "*" || (port.Trim().ToLower() == "network" && info.Network))
                 {
                     foundMatch = true;
                     break;
                 }
             }
             if (foundMatch)
                 break;
         }
     }
     printer.Plugin = pluginName;
 }
Example #7
0
        private void SendNotification(SettingsPrinter printer, List<InkLevel> inkLevel)
        {
            try
            {
                //if (string.IsNullOrWhiteSpace(printer.LastNotification) || DateTime.Parse(printer.LastNotification).ToUniversalTime() < DateTime.Now.AddDays(-7))
                {
                    printer.LastNotification = DateTime.Now.ToString("u");
                    _setting.SaveToFile(Global.SettingsFileName);
                    string msg = "User Details:\r\n\r\n";
                    msg += _setting.Customer.Name + "\r\n\r\n";
                    msg += _setting.Customer.Email + "\r\n\r\n";

                    msg += "Printer Details:\r\n\r\n";
                    msg += printer.Name + "\r\n";

                    foreach (var level in inkLevel)
                    {
                        if (level.Value <= printer.Level)
                        {
                            msg += string.Format("{0} - {1:00%}\r\n", level.Name, level.Value);
                        }
                    }

                    msg += "\r\n\r\n";
                    msg += "Referring Details:\r\n\r\n";
                    msg += "Person Referring Code:  " + _setting.Customer.RefByCode;


                    HttpHelper.PostNotification(_setting, msg);
                    if (_setting.General.UserNotification.ToLower() == "true")
                    {
                        UserInterfaceHelper.NotifYUser(_setting, printer, inkLevel);
                    }
                }
            }
            catch (Exception e)
            {
                Global.Logger.Fatal(e.Message);
            }
        }