private void setFileResult(bool result, string message = null, FileWorkerParams fileparams = null)
 {
     if (result)
     {
         InternalCommunication.GetInternalCommunication().IsSuccess = true;
         InternalCommunication.GetInternalCommunication().Results   = fileparams;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = TcpCommand.Header,
             Description      = message ?? TcpCommand.Description,
             NotificationType = NotificationType.Success,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
     else
     {
         InternalCommunication.GetInternalCommunication().HasError = true;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = TcpCommand.Header,
             Description      = TcpCommand.Description + Environment.NewLine + message,
             NotificationType = NotificationType.Error,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
 }
 private void setPrintResult(bool printResult)
 {
     if (printResult)
     {
         InternalCommunication.GetInternalCommunication().IsSuccess = true;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = TcpCommand.Header,
             Description      = TcpCommand.Description,
             NotificationType = NotificationType.Success,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
     else
     {
         InternalCommunication.GetInternalCommunication().HasError = true;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header      = TcpCommand.Header,
             Description = TcpCommand.Description + Environment.NewLine +
                           "Yazdırma başarısız. Yazıcının bağlantılarının tam ve açık olduğundan emin olunuz.",
             NotificationType = NotificationType.Error,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
 }
 public void DoWork()
 {
     if (string.IsNullOrEmpty(TcpCommand.PrinterName))
     {
         InternalCommunication.GetInternalCommunication().HasError = true;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = "Yazdırma",
             Description      = "Yazdırma başarısız. Yazıcı boş olamaz.",
             NotificationType = NotificationType.Warning,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
     else if (string.IsNullOrEmpty(TcpCommand.Content))
     {
         InternalCommunication.GetInternalCommunication().HasError = true;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header      = "Yazdırma",
             Description = TcpCommand.Description + Environment.NewLine +
                           "Yazdırmak için herhangi bir döküman bulunmadı.",
             NotificationType = NotificationType.Warning,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
     else
     {
         string type = TcpCommand.Type;
         if (!(type == "PrintToImage"))
         {
             if (!(type == "PrintToDos"))
             {
                 if (!(type == "PrintToHtml"))
                 {
                     return;
                 }
                 setPrintResult(Helpers.PrinterHelper.PrintToHtml(TcpCommand.PrinterName, TcpCommand.Content));
             }
             else
             {
                 setPrintResult(Helpers.PrinterHelper.PrintToDOS(TcpCommand.PrinterName, TcpCommand.Content));
             }
         }
         else
         {
             Image image;
             using (MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(TcpCommand.Content)))
                 image = Image.FromStream(memoryStream, true);
             setPrintResult(Helpers.PrinterHelper.PrintToImage(TcpCommand.PrinterName, image));
         }
     }
 }
示例#4
0
        public void DoWork()
        {
            string type = TcpCommand.Type;

            if (type == "PrintToImage" || type == "PrintToDos")
            {
                (new PrinterWorker(TcpCommand)).DoWork();
                return;
            }

            if (type == "LocalPrinters")
            {
                IEnumerable <Printer> printers = Helpers.PrinterHelper.GetPrinters();
                InternalCommunication.GetInternalCommunication().IsSuccess = true;
                InternalCommunication.GetInternalCommunication().Results   = JsonConvert.SerializeObject(printers);
                return;
            }

            if (type == "Sales")
            {
                (new OKCWorker(TcpCommand)).DoWork();
                return;
            }

            if (type == "LocalCashId")
            {
                string cashId = Helpers.RegistryHelper.GetCashId();
                InternalCommunication.GetInternalCommunication().IsSuccess = true;
                InternalCommunication.GetInternalCommunication().Results   = JsonConvert.SerializeObject(cashId);
                return;
            }

            if (type == "Restart")
            {
                App.AllowMultipleApplication(true);
                return;
            }

            if (!(type == "SaveFile") && !(type == "GetFile"))
            {
                throw new NotSupportedException();
            }

            (new FileWorker(TcpCommand)).DoWork();
        }
示例#5
0
            public static void UpdateCashId(string cashId)
            {
                using (RegistryKey registryKey =
                           RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32))
                {
                    using (registryKey.OpenSubKey("Software\\Classes\\CLSID\\", false))
                    {
                    }

                    ;
                }

                using (RegistryKey registryKey =
                           Registry.LocalMachine.OpenSubKey("SOFTWARE\\Panaroma\\Communication", true))
                {
                    if (registryKey == null)
                    {
                        bool isNeedAdminMode;
                        IfNotExistsCashIdThenAdd(cashId, out isNeedAdminMode);
                    }
                    else if (!UserIdAdmin)
                    {
                        InternalCommunication.GetInternalCommunication().HasError = true;
                        InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(
                            new NotificationWindows()
                        {
                            Header      = "Kasa Numarası",
                            Description =
                                "Kasa numarası oluşturulmadı. Lütfen uygulamanın kısayoluna sağ tıklayarak Yönetici olarak çalıştır (Run as Administrator) deyiniz.",
                            NotificationType = NotificationType.Warning,
                            Time             = DateTimeHelper.GetDateTime()
                        });
                    }
                    else
                    {
                        Registry.LocalMachine
                        .OpenSubKey(Path.Combine("SOFTWARE\\Panaroma\\Communication", "Cash"), true)
                        ?.SetValue("CashId", cashId);
                    }
                }
            }
示例#6
0
 public static void SetToCommunicationResult(bool hasError, object result, TcpCommand tcpCommand,
                                             Exception exception = null, bool showDesktop = false)
 {
     if (hasError)
     {
         InternalCommunication.GetInternalCommunication().HasError    = true;
         InternalCommunication.GetInternalCommunication().ShowDesktop = showDesktop;
         InternalCommunication.GetInternalCommunication().Results     =
             (exception != null ? exception.Message : null) ?? result;
         InternalCommunication.GetInternalCommunication().Exceptions.Add(exception);
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = tcpCommand.Header,
             NotificationType = NotificationType.Error,
             Description      = tcpCommand.Description + (!string.IsNullOrEmpty(result.ToString())
                               ? result
                               : (string.IsNullOrEmpty(exception?.Message)
                                   ? (exception != null ? exception.Message : null)
                                   : "")),
             Time = Helpers.DateTimeHelper.GetDateTime()
         });
     }
     else
     {
         InternalCommunication.GetInternalCommunication().IsSuccess   = true;
         InternalCommunication.GetInternalCommunication().ShowDesktop = showDesktop;
         InternalCommunication.GetInternalCommunication().Results     = result;
         InternalCommunication.GetInternalCommunication().Method      = tcpCommand.Method;
         InternalCommunication.GetInternalCommunication().NotificationWindowses.Add(new NotificationWindows()
         {
             Header           = tcpCommand.Header,
             Description      = tcpCommand.Description + " Başarılı.",
             NotificationType = NotificationType.Success,
             Time             = Helpers.DateTimeHelper.GetDateTime()
         });
     }
 }