Пример #1
0
 private void miDelete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var gu = this.GetSelctedItem();
         if (gu == null)
         {
             return;
         }
         if (MessageBox.Show("是否删除:" + gu.Source.Number, "警告", MessageBoxButton.YesNo,
                             MessageBoxImage.Asterisk) != MessageBoxResult.Yes)
         {
             return;
         }
         var tmp = gu.Source.Shops.ToArray();
         foreach (var v in tmp)
         {
             ServiceContainer.GetService <GoodsShopService>().Delete(v.Id);
         }
         gu.Source.Shops = null;
         ServiceContainer.GetService <GoodsService>().Delete(gu.Source.Id);
         Directory.Delete(System.IO.Path.Combine(LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR), gu.Source.ImageDir), true);
         MessageBox.Show("删除成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #2
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string number   = this.tbNumber.Text.Trim();
            string password = this.pbPassword.Password.Trim();

            if (string.IsNullOrWhiteSpace(number) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("用户名或密码不能为空");
                return;
            }

            try
            {
                ServiceContainer.ServerAddress = this.cbbSerer.Text.Trim();
                this.operatorService.Login(number, password);
                var urls = this.cbbSerer.ItemsSource.OfType <string>().ToList();
                urls.Remove(ServiceContainer.ServerAddress);
                urls.Insert(0, ServiceContainer.ServerAddress);
                LocalConfigService.UpdateValue(SystemNames.CONFIG_SERVER_ADDRESS, string.Join(",", urls));
                this.DialogResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
            }
        }
Пример #3
0
        public static void SaveVideo(Goods goods, String videoUrl)
        {
            //图片路径为空,或者目标图片与当前图片相同
            if (string.IsNullOrWhiteSpace(videoUrl))
            {
                return;
            }

            if (goods.VendorId < 1)
            {
                throw new Exception("商品VENDORID不能小于1");
            }

            string dir = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR, "");

            if (string.IsNullOrWhiteSpace(dir))
            {
                throw new Exception(SystemNames.CONFIG_WEB_IMAGE_DIR + "不能为空");
            }
            goods.ImageDir = "goods\\" + goods.VendorId.ToString() + "\\" + goods.Number;
            string videoPath  = goods.ImageDir + "\\" + goods.Number + videoUrl.Substring(videoUrl.LastIndexOf("."));
            string fullPath   = dir + "\\" + videoPath;
            var    imageBytes = GetImage(videoUrl);

            FileUtil.EnsureExits(new FileInfo(fullPath));
            File.WriteAllBytes(fullPath, imageBytes);
        }
Пример #4
0
        private List <string> GetUrls()
        {
            string url = LocalConfigService.GetValue(SystemNames.CONFIG_SERVER_ADDRESS, "http://192.168.31.67/shoperp,http://bjcgroup.imwork.net:60014");

            string[] urls = url.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
            return(urls.ToList());
        }
Пример #5
0
 private void btnPrintInfo_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FrameworkElement fe = sender as FrameworkElement;
         if (fe == null)
         {
             MessageBox.Show("事件源不为:FrameworkElement");
             return;
         }
         OrderReturnViewModel vm = fe.DataContext as OrderReturnViewModel;
         if ((int)vm.Source.State < (int)OrderReturnState.WAITPROCESS)
         {
             MessageBox.Show("订单没有处理,不能被打印");
             return;
         }
         OrderReturnPrintDocument orp = new OrderReturnPrintDocument();
         var printTemplate            = PrintTemplateService.GetAllLocal().FirstOrDefault(obj => obj.Type == PrintTemplate.TYPE_RETURN);
         if (printTemplate == null)
         {
             throw new Exception("未找到退货模板");
         }
         string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_RETURN_BARCODE);
         orp.StartPrint(new OrderReturn[] { vm.Source }, printer, false, printTemplate);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #6
0
 protected override void OnStartup(StartupEventArgs e)
 {
     try
     {
         var settings = new CefSettings()
         {
             LogSeverity = LogSeverity.Warning, LogFile = EnvironmentDirHelper.DIR_LOG + "\\CEF.txt", MultiThreadedMessageLoop = true
         };
         settings.ExternalMessagePump = !settings.MultiThreadedMessageLoop;
         if (Cef.Initialize(settings, true, new BrowserProcessHandler()) == false)
         {
             throw new Exception("初始化CEF SHARP 失败");
         }
         Service.Net.MsHttpRestful.NETWORK_MAX_TIME_OUT = int.Parse(LocalConfigService.GetValue(SystemNames.CONFIG_NETWORK_MAX_TIMEOUT, "10"));
         var lw = new LoginWindow {
             Title = "登录网店ERP"
         };
         bool?ret = lw.ShowDialog();
         if (ret == null || ret == false)
         {
             Cef.Shutdown();
             Process.GetCurrentProcess().Kill();
         }
         base.OnStartup(e);
     }
     catch (TypeInitializationException te)
     {
         MessageBox.Show(te.InnerException.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Process.GetCurrentProcess().Kill();
     }
 }
Пример #7
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //图片设置
                LocalConfigService.UpdateValue(SystemNames.CONFIG_WEB_IMAGE_MODE, this.cbbImageMode.Text.Trim());
                LocalConfigService.UpdateValue(SystemNames.CONFIG_WEB_IMAGE_DIR, this.tbImageDir.Text.Trim());

                //电子面单发货人信息
                ServiceContainer.GetService <SystemConfigService>().SaveOrUpdate(-1, SystemNames.CONFIG_CAINIAO_SENDER_NAME, this.tbSenderName.Text.Trim());
                ServiceContainer.GetService <SystemConfigService>().SaveOrUpdate(-1, SystemNames.CONFIG_CAINIAO_SENDER_PHONE, this.tbSenderPhone.Text.Trim());

                //天猫设置
                LocalConfigService.UpdateValue(SystemNames.CONFIG_GOODS_TEMPLATE, this.cbbGoodsTemplateType.Text.Trim());

                //打印机设置
                LocalConfigService.UpdateValue(SystemNames.CONFIG_PRINTER_DELIVERY_HOT, this.cbbPrinterDeliveryHot.Text.Trim());
                LocalConfigService.UpdateValue(SystemNames.CONFIG_PRINTER_RETURN_BARCODE, this.cbbPrinterReturnBarCode.Text.Trim());
                LocalConfigService.UpdateValue(SystemNames.CONFIG_PRINTER_GOODS_BARCODE, this.cbbPrinterGoodsBarCode.Text.Trim());
                LocalConfigService.UpdateValue(SystemNames.CONFIG_PRINTER_A4, this.cbbPrinterA4.Text.Trim());

                //业务设置
                LocalConfigService.UpdateValue(SystemNames.CONFIG_ORDER_DOWNLOAD_MODE, this.cbbOrderDownloadMode.Text.Trim());
                LocalConfigService.UpdateValue(SystemNames.CONFIG_NETWORK_MAX_TIMEOUT, int.Parse(this.tbNetworkMaxTimeOut.Text.Trim()).ToString());
                ServiceContainer.GetService <SystemConfigService>().SaveOrUpdate(-1, "GOODS_PHONE", this.tbGoodsCountPhone.Text.Trim());
                ServiceContainer.GetService <SystemConfigService>().SaveOrUpdate(-1, "GOODS_NAME", this.tbGoodsCountName.Text.Trim());
                MessageBox.Show("保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Random r = new Random(DateTime.Now.Millisecond);
                //检验
                this.tbCheck.Text = "检验:" + Service.Restful.OperatorService.LoginOperator.Number.Substring(2);
                //货号
                ShopErp.Domain.Vendor vendor = ServiceContainer.GetService <VendorService>().GetById(Goods.VendorId);
                if (vendor == null)
                {
                    throw new Exception("厂家获取为空,不能生成图片");
                }
                this.tbNumber.Text = "货号:" + vendor.Id.ToString("D4") + (Goods.Number.Length < 3 ? Goods.Number.PadRight(3, '0') : Goods.Number);

                //尺码
                this.tbSize.Text = "尺码:" + r.Next(34, 39).ToString();

                //材质
                this.cbbParaMateria.Text = Goods.Material;

                //颜色
                string[] colors = Goods.Colors.Split(new char[] { ',', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (colors.Length > 0)
                {
                    this.cbbParaColor.Text = colors[r.Next(0, colors.Length)];
                }
                else
                {
                    this.cbbParaColor.Text = "";
                }
                this.tbParaBrand.Text = LocalConfigService.GetValue(SystemNames.CONFIG_GOODS_BOX_IMAGE_BRAND, "花儿锦");
                string dir    = this.Goods.ImageDir;
                string webdir = LocalConfigService.GetValue(ShopErp.Domain.SystemNames.CONFIG_WEB_IMAGE_DIR);
                if (string.IsNullOrWhiteSpace(webdir))
                {
                    throw new Exception("没有配置网络图片路径,请在系统中配置");
                }
                string file = System.IO.Path.Combine(webdir, dir) + "\\PT\\店主听闻" + this.Goods.Number + ".txt";
                if (File.Exists(file))
                {
                    this.tbSay.Text = File.ReadAllText(file);
                }
                string fileSource = System.IO.Path.Combine(webdir, dir) + "\\PT\\店主听闻来源" + this.Goods.Number + ".txt";
                if (File.Exists(fileSource))
                {
                    this.tbSaySource.Text = File.ReadAllText(fileSource);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #9
0
        private void btnPrintNew_Click(object sender, RoutedEventArgs e)
        {
            var items = this.gcs.ToArray();

            if (items == null || items.Length < 1)
            {
                MessageBox.Show("没有需要打印的数据");
                return;
            }

            try
            {
                string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, "");
                if (string.IsNullOrWhiteSpace(printer))
                {
                    throw new Exception("请在系统配置里面,配置要使用的打印机");
                }

                //数据数量过滤
                int minCount = 1;
                int.TryParse(this.tbMinCount.Text.Trim(), out minCount);
                Dictionary <string, List <GoodsCount> > gcs = new Dictionary <string, List <GoodsCount> >();
                foreach (var gc in items)
                {
                    if (items.Where(obj => obj.Address == gc.Address).Select(o => o.Count).Sum() >= minCount)
                    {
                        if (gcs.ContainsKey(gc.Vendor) == false)
                        {
                            gcs[gc.Vendor] = new List <GoodsCount>();
                        }
                        gcs[gc.Vendor].Add(gc);
                    }
                }

                string message = string.Format("是否打印:\n打印机:{0}\n打印数量:{1}", printer, gcs.Select(obj => obj.Value.Count).Sum());
                if (MessageBox.Show(message, "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return;
                }

                var pd = PrintUtil.GetPrinter(printer);
                GoodsCountPrintDocument2 goodsCountDoc = new GoodsCountPrintDocument2();
                goodsCountDoc.PageSize = new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight);
                goodsCountDoc.SetGoodsCount(gcs, ServiceContainer.GetService <SystemConfigService>().Get(-1, "GOODS_NAME", ""), ServiceContainer.GetService <SystemConfigService>().Get(-1, "GOODS_PHONE", ""));
                pd.PrintDocument(goodsCountDoc, "拿货统计");
                MessageBox.Show("打印完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "打印出错");
            }
        }
Пример #10
0
        /// <summary>
        /// 启动RESTFUL服务
        /// </summary>
        public void Start()
        {
            string def     = Debugger.IsAttached ? "http://localhost/shoperpdebug/" : "http://localhost/shoperp/";
            string hostUrl = LocalConfigService.GetValue(SystemNames.CONFIG_SERVER_ADDRESS, def);

            if (hostUrl == def)
            {
                LocalConfigService.UpdateValue(SystemNames.CONFIG_SERVER_ADDRESS, hostUrl);
            }
            var binding = new WebHttpBinding
            {
                Name           = "long_web_http_binding",
                AllowCookies   = true,
                SendTimeout    = new TimeSpan(0, 5, 0),
                CloseTimeout   = new TimeSpan(0, 1, 0),
                OpenTimeout    = new TimeSpan(0, 1, 0),
                ReceiveTimeout = new TimeSpan(0, 5, 0),
                ReaderQuotas   = new System.Xml.XmlDictionaryReaderQuotas {
                    MaxDepth = 16, MaxArrayLength = 10485760, MaxBytesPerRead = 10485760, MaxStringContentLength = 10485760, MaxNameTableCharCount = 100
                },
                MaxBufferPoolSize      = 10485760,
                MaxBufferSize          = 10485760,
                MaxReceivedMessageSize = 10485760,
                Security = new WebHttpSecurity {
                    Mode = WebHttpSecurityMode.None
                },
            };

            Type[] types = Assembly.GetExecutingAssembly().GetTypes().Where(obj => obj.Namespace == "ShopErp.Server.Service.Restful").OrderBy(obj => obj.Name).ToArray();
            foreach (var v in types)
            {
                if (v.GetCustomAttribute <ServiceContractAttribute>() == null)
                {
                    continue;
                }

                var obj = Activator.CreateInstance(v);
                var s   = new WebServiceHost(obj, new Uri(hostUrl));
                ContractDescription cd = ContractDescription.GetContract(v);
                ServiceEndpoint     se = new ServiceEndpoint(cd, binding, new EndpointAddress(new Uri(hostUrl + v.Name.ToLower().Replace("restful", "").Replace("service", ""), UriKind.Absolute)));
                s.AddServiceEndpoint(se);
                s.Authorization.ServiceAuthorizationManager = this;
                service.Add(s);
                s.Open();
                foreach (var vv in s.Description.Endpoints)
                {
                    Console.WriteLine(vv.Address);
                }
            }
        }
Пример #11
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var str  = (sender as Button).Tag as String;
         var urls = this.cbbSerer.ItemsSource.OfType <string>().ToList();
         urls.Remove(str);
         LocalConfigService.UpdateValue(SystemNames.CONFIG_SERVER_ADDRESS, string.Join(",", urls));
         this.cbbSerer.ItemsSource = urls;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #12
0
 static ConfigConnectionProvider()
 {
     _defaultConfig = new StorageContextConfigurationEntity
     {
         StorageContextConfigurationItemList = new List <StorageContextConfigurationItem>
         {
             new  StorageContextConfigurationItem
             {
                 Name             = "DefaultContext",
                 ProviderName     = "System.Data.SqlClient",
                 ConnectionString = "Server=.;Database=Adhesive;User ID=sa;Password=DLdNa9R+IFkkHxvWszyLHw==;Trusted_Connection=False;Persist Security Info=True",
             }
         }
     };
     _localStorageContextConfig = LocalConfigService.GetConfig("StorageConfig.config", _defaultConfig);
 }
Пример #13
0
 private void Open()
 {
     if (string.IsNullOrWhiteSpace(serialPort))
     {
         serialPort = LocalConfigService.GetValue(SERIAL_PORT, "");
         if (string.IsNullOrWhiteSpace(serialPort))
         {
             throw new Exception("称重设备没有配置串口号");
         }
     }
     this.port              = new SerialPort(serialPort, 9600, Parity.None, 8, StopBits.One);
     this.port.ReadTimeout  = 2000;
     this.port.WriteTimeout = 2000;
     this.port.Encoding     = Encoding.ASCII;
     this.port.Open();
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //class1.RegisterFile("测试项目");

            LogService log = new LogService();

            log.Debug("dgsdgsg");

            log.Error("2222222222222");


            LocalConfigService localConfigService = new LocalConfigService();

            DateTime time = DateTime.Now;

            localConfigService.SaveConfig(time);
        }
Пример #15
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.myLoaded)
            {
                return;
            }

            try
            {
                //图片
                string imageMode = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_MODE, "内网");
                this.cbbImageMode.SelectedIndex = imageMode == "内网" ? 0 : (imageMode == "外网" ? 1 : 2);
                this.tbImageDir.Text            = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR, "");

                //电子面单发货人信息
                this.tbSenderName.Text  = ServiceContainer.GetService <SystemConfigService>().Get(-1, SystemNames.CONFIG_CAINIAO_SENDER_NAME, "贾勇");
                this.tbSenderPhone.Text = ServiceContainer.GetService <SystemConfigService>().Get(-1, SystemNames.CONFIG_CAINIAO_SENDER_PHONE, "19950350106");

                //天猫设置
                this.cbbGoodsTemplateType.ItemsSource  = PrintTemplateService.GetAllLocal().Where(obj => obj.Type == PrintTemplate.TYPE_GOODS).Select(obj => obj.Name).ToArray();
                this.cbbGoodsTemplateType.SelectedItem = LocalConfigService.GetValue(SystemNames.CONFIG_GOODS_TEMPLATE, "");

                //打印机配置
                string[] names = System.Drawing.Printing.PrinterSettings.InstalledPrinters.OfType <string>().ToArray();
                this.cbbPrinterDeliveryHot.ItemsSource    = names;
                this.cbbPrinterDeliveryHot.SelectedItem   = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_DELIVERY_HOT, "");
                this.cbbPrinterReturnBarCode.ItemsSource  = names;
                this.cbbPrinterReturnBarCode.SelectedItem = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_RETURN_BARCODE, "");
                this.cbbPrinterGoodsBarCode.ItemsSource   = names;
                this.cbbPrinterGoodsBarCode.SelectedItem  = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_GOODS_BARCODE, "");
                this.cbbPrinterA4.ItemsSource             = names;
                this.cbbPrinterA4.SelectedItem            = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, "");

                //业务设置
                string odm = LocalConfigService.GetValue(SystemNames.CONFIG_ORDER_DOWNLOAD_MODE, "");
                this.cbbOrderDownloadMode.SelectedIndex = "本地读取" == odm ? 1 : 0;
                this.tbNetworkMaxTimeOut.Text           = LocalConfigService.GetValue(SystemNames.CONFIG_NETWORK_MAX_TIMEOUT, "10");
                this.tbGoodsCountName.Text  = ServiceContainer.GetService <SystemConfigService>().Get(-1, "GOODS_NAME", "贾勇");
                this.tbGoodsCountPhone.Text = ServiceContainer.GetService <SystemConfigService>().Get(-1, "GOODS_PHONE", "19950350106");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #16
0
        private void OpenImageDir(GoodsViewModel goodsViewModel)
        {
            if (string.IsNullOrWhiteSpace(goodsViewModel.Source.ImageDir))
            {
                return;
            }
            string dir = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR) + "\\" + goodsViewModel.Source.ImageDir.Trim();

            if (System.IO.Directory.Exists(dir) == false)
            {
                throw new Exception("文件夹不存在或者被删除:" + dir);
            }

            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    var d = System.IO.Path.Combine(dir, "PT");
                    if (System.IO.Directory.Exists(d) == false)
                    {
                        MessageBox.Show("文件夹不存在或者被删除:" + d);
                    }
                    else
                    {
                        Process.Start(d);
                    }
                }
                if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                {
                    var d = System.IO.Path.Combine(dir, "YT");
                    if (System.IO.Directory.Exists(d) == false)
                    {
                        MessageBox.Show("文件夹不存在或者被删除:" + d);
                    }
                    else
                    {
                        Process.Start(d);
                    }
                }
            }
            else
            {
                Process.Start(dir);
            }
        }
 private void PrintInfo()
 {
     try
     {
         var printTemplate = PrintTemplateService.GetAllLocal().FirstOrDefault(obj => obj.Type == PrintTemplate.TYPE_RETURN);
         if (printTemplate == null)
         {
             throw new Exception("未找到退货模板");
         }
         string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_RETURN_BARCODE);
         OrderReturnPrintDocument orp = new OrderReturnPrintDocument();
         orp.StartPrint(new ShopErp.Domain.OrderReturn[] { this.OrderReturn.Source }, printer, true, printTemplate);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #18
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         string toolBars = LocalConfigService.GetValue("ToolBarControls", "");
         foreach (var menu in MenuConfig.Menus)
         {
             foreach (var v in menu.SubItems)
             {
                 v.IsChecked = v.Type != null && toolBars.Contains(v.Type.FullName);
             }
         }
         this.lb.ItemsSource = MenuConfig.Menus;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #19
0
 private void MiCopyYstPath_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var    goods  = this.GetSelctedItem().Source;
         var    vendor = ServiceContainer.GetService <VendorService>().GetById(goods.VendorId);
         string dir    = goods.ImageDir;
         string webdir = LocalConfigService.GetValue(ShopErp.Domain.SystemNames.CONFIG_WEB_IMAGE_DIR);
         if (string.IsNullOrWhiteSpace(webdir))
         {
             throw new Exception("没有配置网络图片路径,请在系统中配置");
         }
         string ystDir = System.IO.Path.Combine(webdir, dir) + "\\PT\\YST";
         Clipboard.SetText(ystDir);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #20
0
        /// <summary>
        /// 重新读取相关数据,因为有时候配置会变,但读取订单很耗时。
        /// </summary>
        public void LoadBarValue()
        {
            this.WuliuBranches.Clear();
            this.WuliuPrintTemplates.Clear();
            this.Shops.Clear();
            this.Printers.Clear();

            foreach (var s in ServiceContainer.GetService <ShopService>().GetByAll().Datas.Where(obj => obj.WuliuEnabled))
            {
                this.Shops.Add(s);
            }

            var printers = System.Drawing.Printing.PrinterSettings.InstalledPrinters.OfType <string>().ToArray();

            foreach (var s in printers)
            {
                this.Printers.Add(s);
            }
            this.Printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_DELIVERY_HOT, "");
        }
Пример #21
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string tcs = "";
         foreach (var menu in MenuConfig.Menus)
         {
             foreach (var v in menu.SubItems)
             {
                 if (v.IsChecked)
                 {
                     tcs += v.Type.FullName + ",";
                 }
             }
         }
         LocalConfigService.UpdateValue("ToolBarControls", tcs);
         MessageBox.Show("保存成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #22
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                this.tbOperator.Text  = "        " + OperatorService.LoginOperator.Number + " " + OperatorService.LoginOperator.Name;
                this.menu.ItemsSource = MenuConfig.Menus;
                string            toolBars  = LocalConfigService.GetValue("ToolBarControls", "");
                string[]          tbs       = toolBars.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List <MenuConfig> mcs       = new List <MenuConfig>();
                MenuConfig        configBar = null;
                foreach (var menu in MenuConfig.Menus)
                {
                    foreach (var v in menu.SubItems)
                    {
                        if (v.Type != null && toolBars.Contains(v.Type.FullName))
                        {
                            mcs.Add(v);
                        }

                        if (v.Type != null && v.Type == typeof(MenuItemConfigUserControl))
                        {
                            configBar = v;
                        }
                    }
                }
                if (toolBars.Contains(typeof(MenuItemConfigUserControl).FullName) == false && mcs.Count < 1)
                {
                    mcs.Add(configBar);
                }
                this.tb.ItemsSource = mcs;
                //this.FontSize = LocalConfigService.GetValueDouble("FontSize", 12);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #23
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            var items = this.gcs.ToArray();

            if (items == null || items.Length < 1)
            {
                MessageBox.Show("没有需要打印的数据");
                return;
            }

            try
            {
                string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, "");
                if (string.IsNullOrWhiteSpace(printer))
                {
                    throw new Exception("请在系统配置里面,配置要使用的打印机");
                }
                string message = string.Format("是否打印:\n打印机:{0}\n打印数量:{1}", printer,
                                               items.Select(obj => obj.Count).Sum());
                if (MessageBox.Show(message, "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) !=
                    MessageBoxResult.Yes)
                {
                    return;
                }
                var pd = PrintUtil.GetPrinter(printer);
                GoodsCountPrintDocument goodsCountDoc = new GoodsCountPrintDocument();
                goodsCountDoc.PageSize = new Size(796.8, 1123.2);
                goodsCountDoc.SetGoodsCount(items);
                pd.PrintDocument(goodsCountDoc, "拿货统计");
                SaveLastOrderInfo();
                MessageBox.Show("打印完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "打印出错");
            }
        }
Пример #24
0
        private void btnPrintOrderGoodsButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FrameworkElement fe = sender as FrameworkElement;
                if (fe == null)
                {
                    MessageBox.Show("事件源不正确");
                    return;
                }

                var orderGoods = fe.Tag as OrderGoods;
                if (orderGoods == null)
                {
                    MessageBox.Show("Tag对象不为OrderGoods");
                    return;
                }
                var goodsTemplate = LocalConfigService.GetValue(SystemNames.CONFIG_GOODS_TEMPLATE, "");
                if (string.IsNullOrWhiteSpace(goodsTemplate))
                {
                    throw new Exception("系统中没有配置商品模板不能打印");
                }
                var template = PrintTemplateService.GetAllLocal().FirstOrDefault(obj => obj.Type == PrintTemplate.TYPE_GOODS && obj.Name == goodsTemplate);
                if (template == null)
                {
                    throw new Exception("系统中配置的商品模板:" + goodsTemplate + "不存在,或者类型不对");
                }
                var    gpd     = new GoodsPrintDocument();
                string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_GOODS_BARCODE, "");
                gpd.StartPrint(new OrderGoods[] { orderGoods }, printer, false, template);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #25
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.isStop    = false;
                this.isRunning = true;
                this.current   = 0;
                this.Dispatcher.BeginInvoke(new Action(() => this.btnUpdate.Content = "停止"));
                string dir = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR, "");

                if (string.IsNullOrWhiteSpace(dir))
                {
                    throw new Exception("没有配置图片文件夹");
                }

                foreach (var gu in shoes)
                {
                    if (this.isStop)
                    {
                        break;
                    }

                    if (gu.Source.UpdateEnabled == false)
                    {
                        continue;
                    }

                    if (gu.Source.VideoType != GoodsVideoType.VIDEO)
                    {
                        continue;
                    }

                    string state = null;
                    try
                    {
                        string   fullDir = System.IO.Path.Combine(dir, gu.Source.ImageDir);
                        string[] videos  = Directory.GetFiles(fullDir, "*.mp4");
                        if (videos.Length > 0)
                        {
                            FileInfo fileInfo = new FileInfo(videos[0]);
                            string   newPath  = System.IO.Path.Combine(fullDir, gu.Source.Number + ".mp4");
                            File.Move(videos[0], newPath);
                            state = "已处理";
                        }
                        else
                        {
                            state = "已检查,未处理";
                        }
                    }
                    catch (Exception ex)
                    {
                        state = "错误:" + ex.Message;
                    }
                    finally
                    {
                        lock (this.shoes)
                        {
                            current++;
                        }
                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            this.tbProgress.Text = "已经更新:" + current + "/" + this.shoes.Count;
                            gu.State             = state;
                        }));
                        WPFHelper.DoEvents();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.isRunning = false;
                this.isStop    = true;
                this.Dispatcher.BeginInvoke(new Action(() => this.btnUpdate.Content = "更新商品"));
            }
        }
Пример #26
0
        private void QueryTask()
        {
            try
            {
                IList <ShopErp.Domain.Goods>  gus     = ServiceContainer.GetService <GoodsService>().GetByAll(0, GoodsState.NONE, 0, DateTime.MinValue, DateTime.MinValue, "", "", GoodsType.GOODS_SHOES_NONE, "", ColorFlag.None, GoodsVideoType.NONE, "", "", "", 0, 0).Datas.ToList();
                IList <ShopErp.Domain.Vendor> vendors = ServiceContainer.GetService <VendorService>().GetByAll("", "", "", "", 0, 0).Datas;
                List <string> goodsDirs  = new List <string>();
                int           gusCount   = gus.Count;
                string        imgRootDir = LocalConfigService.GetValue(SystemNames.CONFIG_WEB_IMAGE_DIR, "");
                if (string.IsNullOrWhiteSpace(imgRootDir))
                {
                    throw new Exception("系统中没有配置图片文件夹");
                }
                //厂家以数字编号保存在下面,不可能是其它的字符
                List <string> vendorDirs = System.IO.Directory.GetDirectories(imgRootDir + "\\goods").Where(obj => new System.IO.DirectoryInfo(obj).Name.All(c => Char.IsDigit(c))).ToList();
                foreach (var d in vendorDirs)
                {
                    goodsDirs.AddRange(System.IO.Directory.GetDirectories(d));
                }

                foreach (string goodsDir in goodsDirs)
                {
                    ShopErp.Domain.Goods goods = null;
                    bool     check             = false;
                    string   msg = "";
                    string[] ss  = goodsDir.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                    if (ss.Length < 2)
                    {
                        msg = "错误:文件夹名称路径小于2层 ";
                    }
                    else
                    {
                        var vendor = vendors.FirstOrDefault(obj => obj.Id == long.Parse(ss[ss.Length - 2]));
                        if (vendor == null)
                        {
                            msg   = "商品找不到对应厂家";
                            check = true;
                        }
                        else
                        {
                            goods = gus.FirstOrDefault(obj => obj.VendorId == vendor.Id && obj.Number.Equals(ss[ss.Length - 1], StringComparison.OrdinalIgnoreCase));
                            msg   = goods == null ? "商品已不在系统中" : "商品存在";
                            check = goods == null;
                            if (goods != null)
                            {
                                gus.Remove(goods);
                            }
                        }
                    }
                    ImgCleanViewModel d = new ImgCleanViewModel {
                        Check = check, Dir = goodsDir, Goods = goods, State = msg
                    };
                    dirs.Add(d);
                    this.tbMsg.Text = string.Format("已完成解析:{0}/{1}", dirs.Count, this.dirs.Count);
                }

                foreach (var goods in gus)
                {
                    ImgCleanViewModel d = new ImgCleanViewModel {
                        Check = false, Dir = "", Goods = goods, State = "不存在文件夹"
                    };
                    dirs.Add(d);
                    this.tbMsg.Text = string.Format("已完成解析:{0}/{1}", dirs.Count, this.dirs.Count);
                }
                var    g = this.dirs.GroupBy(obj => obj.State);
                string s = "文件夹总数:" + goodsDirs.Count + ",商品总数:" + gusCount + " 解析结果:" + string.Join(",", g.Select(obj => obj.Key + ":" + obj.Count()));
                this.tbMsg.Text = s;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.OrderReturns.Count < 1)
            {
                MessageBox.Show("没有需要打印的数据");
                return;
            }

            try
            {
                string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, "");
                if (string.IsNullOrWhiteSpace(printer))
                {
                    throw new Exception("请在系统配置里面,配置要使用的打印机");
                }

                if (MessageBox.Show("是否使用打印机:" + printer + Environment.NewLine + "打印?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return;
                }

                var           pd            = PrintUtil.GetPrinter(printer);
                VendorService vs            = ServiceContainer.GetService <VendorService>();
                var           goodsCountDoc = new OrderReturnOutPrintDocument();

                List <GoodsCount> counts = new List <GoodsCount>();
                foreach (var item in this.OrderReturns)
                {
                    string[] infos = item.Source.GoodsInfo.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (infos.Length < 4)
                    {
                        MessageBox.Show("退货信息不正确,请检查:" + item.Source.Id);
                        continue;
                    }
                    var vendor = vs.GetByAll(infos[0], "", "", "", 0, 0).First;
                    if (vendor == null)
                    {
                        vendor = vs.GetByAll(infos[0] + infos[1], "", "", "", 0, 0).First;
                    }

                    if (vendor == null)
                    {
                        MessageBox.Show("退货信息厂家找不到,请检查:" + item.Source.Id);
                        continue;
                    }

                    GoodsCount count = null;
                    if (infos.Length >= 5)
                    {
                        count = counts.FirstOrDefault(
                            obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] &&
                            obj.Edtion == infos[2] && obj.Color == infos[3] && obj.Size == infos[4]);
                    }
                    else
                    {
                        count = counts.FirstOrDefault(
                            obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] &&
                            obj.Color == infos[2] && obj.Size == infos[3]);
                    }

                    if (count == null)
                    {
                        count = new GoodsCount
                        {
                            Vendor       = infos[0].Trim(),
                            Number       = infos[1].Trim(),
                            Money        = (int)(item.Source.GoodsMoney / item.Source.Count),
                            Count        = 0,
                            FirstPayTime = item.Source.ProcessTime,
                        };

                        if (infos.Length >= 5)
                        {
                            count.Edtion = infos[2].Trim();
                            count.Color  = infos[3].Trim();
                            count.Size   = infos[4].Trim();
                        }
                        else
                        {
                            count.Edtion = "";
                            count.Color  = infos[2].Trim();
                            count.Size   = infos[3].Trim();
                        }
                        count.Address = vendor.MarketAddressShort;
                        count.Vendor  = VendorService.FormatVendorName(count.Vendor);
                        counts.Add(count);
                    }
                    foreach (var c in counts.Where(obj => obj.Vendor == count.Vendor && obj.Number == count.Number &&
                                                   obj.Edtion == count.Edtion))
                    {
                        //取消最大金额值
                        if (c.Money < count.Money)
                        {
                            c.Money = count.Money;
                        }
                        else
                        {
                            count.Money = c.Money;
                        }
                    }

                    if (count.FirstPayTime >= item.Source.ProcessTime)
                    {
                        count.FirstPayTime = item.Source.ProcessTime;
                    }

                    count.Count += item.Source.Count;
                }
                IComparer <GoodsCount> comparer = new OrderGoodsCountSortByDoor();
                counts.Sort(comparer); //拿货地址
                counts.Sort(comparer); //货号
                counts.Sort(comparer); //版本
                counts.Sort(comparer); //颜色
                counts.Sort(comparer); //尺码
                goodsCountDoc.PageSize = new Size(793, 1122.24);
                goodsCountDoc.SetGoodsCount(counts.ToArray());
                pd.PrintDocument(goodsCountDoc, "退货统计");
                foreach (var item in this.OrderReturns)
                {
                    this.OrderReturnService.Update(item.Source);
                }
                MessageBox.Show("打印完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "打印出错");
            }
        }
Пример #28
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var items = this.dgOrders.ItemsSource as OrderViewModel[];
                if (items == null || items.Length < 1)
                {
                    MessageBox.Show("没有任何数据");
                    return;
                }

                //进行检查,以防止有些订单没有标记到。根据收货人电话号码进行检查,先检查手机号,手机号为空的检查座机
                List <string> failPhones = new List <string>();
                failPhones.AddRange(CheckOrder(items.Where(obj => string.IsNullOrWhiteSpace(obj.Source.ReceiverMobile) == false).ToArray(), true));
                failPhones.AddRange(CheckOrder(items.Where(obj => string.IsNullOrWhiteSpace(obj.Source.ReceiverMobile)).ToArray(), false));
                if (failPhones.Count > 0)
                {
                    string msg = "检查订单失败,有相同电话信息但订单类型不一致:" + Environment.NewLine + string.Join(",", failPhones) + Environment.NewLine + "是否继续导出?";
                    if (MessageBox.Show(msg, "是否继续导出?", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                    {
                        return;
                    }
                }

                items = items.Where(obj => obj.IsChecked).ToArray();
                if (items == null || items.Length < 1)
                {
                    MessageBox.Show("没有选择任何数据");
                    return;
                }

                var      shops         = ServiceContainer.GetService <ShopService>().GetByAll().Datas;
                string[] columnsHeader = new string[] { "店铺", "付款时间", "商品信息", "快递单号", "备注", "姓名", "手机", "地址" };
                Dictionary <string, string[][]> dicContents = new Dictionary <string, string[][]>();
                List <string[]> contents = new List <string[]>();
                contents.Add(columnsHeader);
                //合并订单
                var normalOrders = items.Where(obj => obj.Source.Type == ShopErp.Domain.OrderType.NORMAL).OrderBy(obj => obj.Source.PopType).ToArray();
                Dictionary <OrderViewModel, string> cc = new Dictionary <OrderViewModel, string>();
                foreach (var o in normalOrders)
                {
                    var key = cc.Keys.FirstOrDefault(obj => obj.Source.ShopId == o.Source.ShopId && obj.Source.ReceiverName == o.Source.ReceiverName && obj.Source.ReceiverPhone == o.Source.ReceiverPhone && obj.Source.ReceiverMobile == o.Source.ReceiverMobile && obj.Source.ReceiverAddress == o.Source.ReceiverAddress && (string.IsNullOrWhiteSpace(obj.Source.PopBuyerId) ? true : obj.Source.PopBuyerId == o.Source.PopBuyerId));
                    if (key == null)
                    {
                        cc[o] = o.GoodsInfoCanbeCount;
                    }
                    else
                    {
                        cc[key] = cc[key] + "," + Environment.NewLine + o.GoodsInfoCanbeCount;
                    }
                }

                foreach (var pair in cc)
                {
                    var      v  = pair.Key;
                    string[] ss = new string[] { shops.FirstOrDefault(obj => obj.Id == v.Source.ShopId).Mark, v.Source.PopPayTime.ToString("yyyy-MM-dd HH:mm:ss"), pair.Value, v.Source.DeliveryNumber, v.Source.PopSellerComment, v.Source.ReceiverName, string.IsNullOrWhiteSpace(v.Source.ReceiverPhone) ? v.Source.ReceiverMobile : v.Source.ReceiverMobile + "," + v.Source.ReceiverPhone, v.Source.ReceiverAddress };
                    if (pair.Key.Source.PopType != ShopErp.Domain.PopType.TMALL)
                    {
                        ss[4] += "放拼多多好评卡";
                    }
                    contents.Add(ss);
                }
                dicContents.Add("订单", contents.ToArray());
                Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                sfd.AddExtension     = true;
                sfd.DefaultExt       = "xlsx";
                sfd.Filter           = "*.xlsx|Office 2007 文件";
                sfd.FileName         = "贾勇 " + DateTime.Now.ToString("MM-dd") + ".xlsx";
                sfd.InitialDirectory = LocalConfigService.GetValue("OrderExportSaveDir_" + this.cbbShippers.Text.Trim(), "");
                if (sfd.ShowDialog().Value == false)
                {
                    return;
                }
                Service.Excel.ExcelFile.WriteXlsx(sfd.FileName, dicContents);
                LocalConfigService.UpdateValue("OrderExportSaveDir_" + this.cbbShippers.Text.Trim(), new FileInfo(sfd.FileName).DirectoryName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #29
0
        public static YmatouConfig GetConfig()
        {
            var config = LocalConfigService.GetConfig(new YmatouConfig());

            return(config);
        }
Пример #30
0
        /// <summary>
        /// 获取已付款和已打印的订单,同时会调用接口下载订单
        /// </summary>
        /// <param name="payType">支付类型</param>
        /// <returns></returns>
        public static List <Order> DownloadOrder(PopPayType payType, string shipper)
        {
            var allShops             = ServiceContainer.GetService <ShopService>().GetByAll().Datas.Where(obj => obj.Enabled).ToList();
            var allAppEnabledShops   = allShops.Where(obj => obj.AppEnabled).ToArray();
            var allAppUnEnabledShops = allShops.Where(obj => obj.AppEnabled == false).ToArray();

            if (allShops.Count < 1)
            {
                return(new List <Order>());
            }

            string mode = LocalConfigService.GetValue(SystemNames.CONFIG_ORDER_DOWNLOAD_MODE, "").Trim();

            if (mode.Equals("本地读取"))
            {
                return(ServiceContainer.GetService <OrderService>().GetPayedAndPrintedOrders(null, OrderCreateType.NONE, payType, shipper, 0, 0).Datas.OrderBy(obj => obj.ShopId).ToList());
            }

            OrderDownloadWindow win = new OrderDownloadWindow()
            {
                PayType = payType
            };
            var ret = win.ShowDialog();

            if (ret == null || ret.Value == false)
            {
                return(new List <Order>());
            }
            var onlineOrders = win.Orders.Where(obj => obj.PopPayType == payType).ToList();

            if (allAppEnabledShops.Length > 0)
            {
                //对于采用自动下载订单的店铺,需要再读取其手动创建的订单
                var orders = ServiceContainer.GetService <OrderService>().GetPayedAndPrintedOrders(allAppEnabledShops.Select(obj => obj.Id).ToArray(), OrderCreateType.MANUAL, payType, shipper, 0, 0).Datas;
                if (orders.Count > 0)
                {
                    onlineOrders.AddRange(orders);
                }
            }

            if (allAppUnEnabledShops.Length > 0)
            {
                //对于没有自动下载的订单需要读取所有的订单
                var orders = ServiceContainer.GetService <OrderService>().GetPayedAndPrintedOrders(allAppUnEnabledShops.Select(obj => obj.Id).ToArray(), OrderCreateType.NONE, payType, shipper, 0, 0).Datas;
                if (orders.Count > 0)
                {
                    onlineOrders.AddRange(orders);
                }
            }
            if (string.IsNullOrWhiteSpace(shipper))
            {
                return(onlineOrders);
            }

            var retOrders = new List <Order>();

            foreach (var o in onlineOrders)
            {
                if (o.OrderGoodss == null || o.OrderGoodss.Count < 0)
                {
                    continue;
                }

                if (o.OrderGoodss.Any(obj => obj.Shipper.Equals(shipper, StringComparison.OrdinalIgnoreCase)))
                {
                    retOrders.Add(o);
                }
            }

            return(retOrders);
        }