コード例 #1
0
ファイル: Restore.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        ///  读取备份(读取完配置文件后)
        /// </summary>
        internal void ReadBak()
        {
            // 创建路径
            if (string.IsNullOrWhiteSpace(BakFile))
            {
                CreateBakFilePath();
            }


            // 如果文件不存在写入到错误日志
            if (System.IO.File.Exists(BakFile))
            {
                try
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(BakFile, Encoding.UTF8))
                    {
                        // 上次登录的管理员
                        Resources.GetRes().LastLoginAdminNo = sr.ReadLine();
                    }
                }
                catch (Exception ex)
                {
                    ExceptionPro.ExpLog(ex);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 打开客显
        /// </summary>
        public void OpenPriceMonitor(string price, string name = null)
        {
            if (string.IsNullOrWhiteSpace(Resources.GetRes().PriceMonitor) && string.IsNullOrWhiteSpace(name))
            {
                return;
            }
            try
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = Resources.GetRes().PriceMonitor;
                }

                // 清理
                if (null == price)
                {
                    CustomerDisplay.Instance.DisplayData(null, name, 2400, StopBits.One, 8, CustomerDispiayType.Clear);
                }
                else
                {
                    price = price.Replace("-", "");
                    CustomerDisplay.Instance.DisplayData(price, name, 2400, StopBits.One, 8, CustomerDispiayType.Clear);
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #3
0
 /// <summary>
 /// 开启声音
 /// </summary>
 public void EnableSound()
 {
     try
     {
         string keyValue = null;
         keyValue = "%SystemRoot%\\Media\\";
         //xp and 2003
         if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor > 0)
         {
             keyValue += "Windows XP Start.wav";
         }
         else if (Environment.OSVersion.Version.Major >= 6)
         {
             keyValue += "Windows Navigation Start.wav";
         }
         else
         {
             return;
         }
         Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("AppEvents\\Schemes\\Apps\\Explorer\\Navigating\\.Current", true);
         key.SetValue(null, keyValue, Microsoft.Win32.RegistryValueKind.ExpandString);
     }
     catch (Exception ex)
     {
         ExceptionPro.ExpLog(ex);
     }
 }
コード例 #4
0
        /// <summary>
        /// 添加到列表
        /// </summary>
        /// <param name="editMark"></param>
        /// <param name="Id"></param>
        /// <param name="Price"></param>
        /// <param name="IsPayByCard"></param>
        /// <param name="Remark"></param>
        /// <param name="AddTime"></param>
        private void AddToGrid(string editMark, string Id, double Price, string BalanceName, string Remark, long AddTime, CommonPayModel model)
        {
            string AddTimeStr     = "";
            string OperateNameStr = "";

            try
            {
                AddTimeStr = DateTime.ParseExact(AddTime.ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm");

                if (null != model)
                {
                    OperateNameStr = GetOperateName(model);
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }


            if (editMark == "*")
            {
                krpdgList.Rows.Insert(0, editMark, Id, OperateNameStr, GetOperateSymbal(model, Price).ToString(), BalanceName, Remark, AddTimeStr);
            }
            else
            {
                krpdgList.Rows.Add(editMark, Id, OperateNameStr, GetOperateSymbal(model, Price).ToString(), BalanceName, Remark, AddTimeStr);
                krpdgList.Rows[krpdgList.Rows.Count - 1].Cells["krpcmPrice"].ReadOnly       = true;
                krpdgList.Rows[krpdgList.Rows.Count - 1].Cells["krpcmBalanceType"].ReadOnly = true;
                krpdgList.Rows[krpdgList.Rows.Count - 1].Cells["krpcmRemark"].ReadOnly      = true;
            }
        }
コード例 #5
0
ファイル: Restore.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        /// 写入备份
        /// </summary>
        internal void WriteBak()
        {
            // 创建路径
            if (string.IsNullOrWhiteSpace(BakFile))
            {
                CreateBakFilePath();
            }

            try
            {
                StringBuilder sb = new StringBuilder();
                // 管理员
                sb.AppendLine(Resources.GetRes().LastLoginAdminNo);

                string temp = sb.ToString();

                if (temp != Last)
                {
                    Last = temp;
                    using (System.IO.StreamWriter sw = new System.IO.StreamWriter(BakFile, false, Encoding.UTF8))
                    {
                        sw.Write(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #6
0
        /// <summary>
        /// 打开某页
        /// </summary>
        /// <param name="pageNo"></param>
        private void OpenPageTo2()
        {
            //获取数据
            var currentResult = payList.OrderByDescending(x => x.TakeoutPayId);

            //添加到数据集中
            krpdgPayList.Rows.Clear();
            foreach (var item in currentResult)
            {
                AddToGrid2("", item.TakeoutPayId.ToString(), GetOrderDetailsState(item.State), item.BalanceId, item.tb_member, item.OriginalPrice, item.RemovePrice, item.BalancePrice, item.AddTime, item.AdminId);
            }

            // 待确认改为红色
            for (int i = 0; i < krpdgPayList.Rows.Count; i++)
            {
                try
                {
                    if (3 == GetOrderDetailsStateNo(krpdgPayList.Rows[i].Cells["krpcmState2"].Value.ToString()))
                    {
                        for (int j = 0; j < krpdgPayList.Rows[i].Cells.Count; j++)
                        {
                            krpdgPayList.Rows[i].Cells[j].Style.ForeColor = krpdgPayList.Rows[i].Cells[j].Style.SelectionForeColor = Color.Gray;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionPro.ExpLog(ex);
                }
            }
        }
コード例 #7
0
ファイル: AboutViewModel.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        /// 发送
        /// </summary>
        private async Task Send(List <long> RoomsId, string ErrMsgName, int SendType, ExtendInfo info, Action success = null)
        {
            IsLoading = true;

            try
            {
                bool result = await OperatesService.Instance.ServiceSend(RoomsId, SendType, JsonConvert.SerializeObject(info));


                // 如果成功则提示
                if (result)
                {
                    QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Information, string.Format(Resources.Instance.GetString("OperateSuccess"), ErrMsgName), MessageBoxMode.Dialog, MessageBoxImageMode.Information, MessageBoxButtonMode.OK, null, null);



                    if (null != success)
                    {
                        success();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                {
                    QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, message, MessageBoxMode.Dialog, MessageBoxImageMode.Error, MessageBoxButtonMode.OK, null, null);
                }), false, string.Format(Resources.Instance.GetString("OperateFaild"), ErrMsgName));
            }

            IsLoading = false;
        }
コード例 #8
0
        /// <summary>
        /// 产品数量更新
        /// </summary>
        /// <param name="toClient"></param>
        internal void ServiceProductCountUpdateNotification(ToClientServiceProductCountUpdateNotification toClient)
        {
            try
            {
                Dictionary <long, ProductWithCount> list = toClient.ProductAndCounts.DeserializeObject <Dictionary <long, ProductWithCount> >();
                // 如果有产品则更新产品
                if (null != list)
                {
                    foreach (var product in list.Values)
                    {
                        Product currentProduct = Resources.GetRes().Products.Where(x => x.ProductId == product.Product.ProductId).FirstOrDefault();
                        currentProduct.UpdateTime   = product.Product.UpdateTime;
                        currentProduct.BalanceCount = Math.Round(currentProduct.BalanceCount + product.CountChange, 3);

                        // 如果支出价格有变动则修改
                        if (null != product.NewCostPrice)
                        {
                            currentProduct.CostPrice = product.NewCostPrice.Value;
                        }
                        // 如果价格有变动,则修改
                        if (null != product.NewPrice)
                        {
                            currentProduct.Price = product.NewPrice.Value;
                        }

                        Notification.Instance.ActionProduct(null, product.Product, null);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #9
0
        /// <summary>
        /// 修改过期时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void krpbChange_Click(object sender, EventArgs e)
        {
            if (krpcbIsNoLimit.Checked)
            {
                ReturnValue  = "";
                DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                DateTime endDateTime = DateTime.Now;

                try
                {
                    endDateTime = krptbExpired.Value;
                }
                catch (Exception ex)
                {
                    KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("PropertyError"), Resources.GetRes().GetString("ExpiredTime")), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ExceptionPro.ExpLog(ex);
                    return;
                }


                ReturnValue  = endDateTime.ToString("yyyy-MM-dd HH:mm");
                DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }
コード例 #10
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="form"></param>
        /// <param name="data"></param>
        internal void Output <T>(Form form, T data)
        {
            try
            {
                string encryptedStr = Encrypt(JsonConvert.SerializeObject(data), "ADGWTDSCSA214235", Encoding.UTF8.GetBytes("OybabCorp8888111"));


                //选择导出位置
                SaveFileDialog saveFileDialog = new SaveFileDialog();

                saveFileDialog.Title    = Resources.GetRes().GetString("OutputData");
                saveFileDialog.Filter   = "Data File(*.dt)|*.dt";
                saveFileDialog.FileName = "file.dt";

                DialogResult result = saveFileDialog.ShowDialog(form);
                if (result != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }



                using (StreamWriter stream = new StreamWriter(saveFileDialog.FileName, false, Encoding.UTF8))
                {
                    stream.Write(encryptedStr);
                }

                KryptonMessageBox.Show(form, Resources.GetRes().GetString("OutputDataSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
                KryptonMessageBox.Show(form, Resources.GetRes().GetString("Exception_OutputData"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #11
0
        /// <summary>
        /// 外卖更新
        /// </summary>
        /// <param name="toClient"></param>
        internal void ServiceTakeoutUpdateNotification(ToClientServiceTakeoutUpdateNotification toClient)
        {
            try
            {
                List <TakeoutNotificationModel> list = toClient.TakeoutNotification.DeserializeObject <List <TakeoutNotificationModel> >();

                foreach (var item in list)
                {
                    // 如果有产品则更新产品
                    if (null != item.ProductsChange)
                    {
                        foreach (var product in item.ProductsChange)
                        {
                            Product currentProduct = Resources.GetRes().Products.Where(x => x.ProductId == product.Key).FirstOrDefault();
                            currentProduct.UpdateTime   = product.Value.Product.UpdateTime;
                            currentProduct.BalanceCount = Math.Round(currentProduct.BalanceCount + product.Value.CountChange, 3);

                            Notification.Instance.ActionProduct(null, product.Value.Product, null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #12
0
ファイル: Restore.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        ///  读取备份(读取完配置文件后)
        /// </summary>
        internal async Task ReadBak()
        {
            try
            {
                string langIndex = await Settings.Instance.GetValueOrDefault(Settings.SettingsLangKey, Settings.Instance.SettingsLangDefault.ToString());

                if (langIndex == "-1")
                {
                    var currentLang = Res.Instance.AllLangList.Where(x => x.Value.Culture.Name == System.Globalization.CultureInfo.CurrentCulture.Name).Select(x => x.Value).FirstOrDefault();
                    if (null != currentLang)
                    {
                        langIndex = currentLang.LangIndex.ToString();
                    }
                    else
                    {
                        langIndex = "2";     // default english
                    }
                }

                Resources.Instance.ReloadResources(int.Parse(langIndex));
                Resources.Instance.LastLoginAdminNo = await Settings.Instance.GetValueOrDefault(Settings.SettingsAdminKey, Settings.Instance.SettingsAdminDefault.ToString());

                Resources.Instance.LastLoginPassword = await Settings.Instance.GetValueOrDefault(Settings.SettingsPasswordKey, Settings.Instance.SettingsPasswordDefault.ToString());

                Resources.Instance.IsSavePassword = bool.Parse(await Settings.Instance.GetValueOrDefault(Settings.SettingsIsSavePassword, Settings.Instance.SettingsIsSavePasswordDefault.ToString()));
                Resources.Instance.SERVER_ADDRESS = await Settings.Instance.GetValueOrDefault(Settings.SettingsIPKey, Settings.Instance.SettingsIPDefault.ToString());
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #13
0
        /// <summary>
        /// 注册热键
        /// </summary>
        private void RegHotKey()
        {
            if (string.IsNullOrWhiteSpace(Resources.GetRes().CashDrawer))
            {
                return;
            }
            try
            {
                hk.KeyCode  = Keys.Z;
                hk.Alt      = true;
                hk.Pressed += delegate
                {
                    Common.GetCommon().OpenCashDrawer();
                };

                if (!hk.GetCanRegister(this))
                {
                    ExceptionPro.ExpErrorLog("Open cash drawer key can't register!");
                }
                else
                {
                    hk.Register(this);
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
コード例 #14
0
ファイル: App.xaml.cs プロジェクト: oybab/TradingSystem
 /// <summary>
 /// 发生所有未捕获异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     ExceptionPro.ExpLog(e.ExceptionObject as Exception, new Action <string>((message) =>
     {
         MessageBox.Show(Application.Current.MainWindow, message, Res.Resources.GetRes().GetString("ErrorBig"), MessageBoxButton.OK, MessageBoxImage.Error);
     }));
 }
コード例 #15
0
        /// <summary>
        /// 关闭当前客户端
        /// </summary>
        /// <param name="service"></param>
        internal void CloseService(Client service)
        {
            try
            {
                // 如果有老的通讯, 先终止掉它
                if (null != service.ClientChannel)
                {
                    ServiceOperate.GetServiceOperate().AbortOldChannel(service.ClientChannel);
                }
                else if (null != service.SignalRClientSessionId)
                {
                    var hub = GlobalHost.ConnectionManager.GetHubContext <ServiceHub>();
                    //hub.Clients.Client(service.SignalRClientSessionId).Close();

                    // SingnalR这个设计....不能手动关闭连接...
                }

                service.Dispose();
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }

            Resources.GetRes().Services.Remove(service);
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: oybab/TradingSystem
 /// <summary>
 /// 处理不可预期的错误
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     ExceptionPro.ExpLog(e.ExceptionObject as Exception, new Action <string>((message) =>
     {
         KryptonMessageBox.Show(Form.ActiveForm, message, Resources.GetRes().GetString("ErrorBig"), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }));
 }
コード例 #17
0
ファイル: Program.cs プロジェクト: oybab/TradingSystem
 /// <summary>
 /// 处理不可预期的错误(WindowUI)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     ExceptionPro.ExpLog(e.Exception, new Action <string>((message) =>
     {
         KryptonMessageBox.Show(Form.ActiveForm, message, Resources.GetRes().GetString("ErrorBig"), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }));
 }
コード例 #18
0
ファイル: Service.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        /// 关闭
        /// </summary>
        private new void Stop()
        {
            try
            {
                // 服务关闭时应该会自动关闭吧
                ////关闭服务
                //if (null != host)
                //{
                //    try
                //    {
                //        host.Close();
                //        host = null;
                //    }
                //    catch (Exception ex)
                //    {
                //        ExceptionPro.ExpLog(ex);
                //    }
                //}

                //关闭线程
                Resources.GetRes().CloseThread();


                ExceptionPro.ExpInfoLog("Service closed successfully.");
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex, null, false, "Service close failed.");
            }
        }
コード例 #19
0
ファイル: Service.cs プロジェクト: oybab/TradingSystem
        /// <summary>
        /// 启动失败是重启
        /// </summary>
        /// <param name="serviceName"></param>
        private void SetRecoveryOptions(string serviceName)
        {
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    int exitCode;
                    using (var process = new Process())
                    {
                        var startInfo         = process.StartInfo;
                        startInfo.FileName    = "sc";
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden;

                        // tell Windows that the service should restart if it fails
                        startInfo.Arguments = string.Format("failure \"{0}\" reset= 0 actions= restart/60000", serviceName);

                        process.Start();
                        process.WaitForExit();

                        exitCode = process.ExitCode;
                    }
                    if (exitCode != 0)
                    {
                        throw new InvalidOperationException("windows service failure return error ! " + exitCode);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionPro.ExpLog(ex);
                }
            });
        }
コード例 #20
0
        /// <summary>
        /// 设置颜色(快到时间检查)
        /// </summary>
        private void SetColor(bool IsAlert, List <long> Rooms = null)
        {
            bool IsFlash = false;

            // 如果是新新部分
            if (null != Rooms)
            {
                // 待确认改为红色
                for (int i = 0; i < RoomLists.Count; i++)
                {
                    try
                    {
                        RoomStateModel model = RoomLists[i] as RoomStateModel;


                        if (Rooms.Contains(model.RoomId))
                        {
                            if (model.RefreshImageState())
                            {
                                IsFlash = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionPro.ExpLog(ex);
                    }
                }
            }
            else
            {
                // 待确认改为红色
                for (int i = 0; i < RoomLists.Count; i++)
                {
                    try
                    {
                        RoomStateModel model = RoomLists[i] as RoomStateModel;

                        if (model.RefreshImageState())
                        {
                            IsFlash = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionPro.ExpLog(ex);
                    }
                }
            }

            // 如果需要闪烁
            if (IsAlert && IsFlash)
            {
                if (null != TimeupAlr)
                {
                    TimeupAlr();
                }
            }
        }
コード例 #21
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string value = "0";

            if (!cbRemove.Checked)
            {
                if (string.IsNullOrWhiteSpace(txtId.Text) || string.IsNullOrWhiteSpace(txtInterval.Text) || string.IsNullOrWhiteSpace(txtZh.Text) || string.IsNullOrWhiteSpace(txtUg.Text) || string.IsNullOrWhiteSpace(txtEn.Text))
                {
                    KryptonMessageBox.Show(this, "请完整输入信息!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Scroll scroll = new Scroll();
                scroll.Interval = int.Parse(txtInterval.Text);
                scroll.MsgZH    = txtZh.Text;
                scroll.MsgUG    = txtUg.Text;
                scroll.MsgEN    = txtEn.Text;



                value = Encrypt(JsonConvert.SerializeObject(scroll), txtId.Text.Trim(), Encoding.UTF8.GetBytes("OybabCorp8888000"));
            }

            StartLoad(this, null);
            Task.Factory.StartNew(() =>
            {
                try
                {
                    string countent = null;

                    bool result = OperatesService.GetOperates().ServiceSetContent(value, out countent, cbRemove.Checked, cbIsRestart.Checked);


                    this.BeginInvoke(new Action(() =>
                    {
                        if (result)
                        {
                            KryptonMessageBox.Show(this, Oybab.Res.Resources.GetRes().GetString("SaveSuccess"), Oybab.Res.Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            KryptonMessageBox.Show(this, Oybab.Res.Resources.GetRes().GetString("SaveFailt"), Oybab.Res.Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }));
                }
                catch (Exception ex)
                {
                    this.BeginInvoke(new Action(() =>
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            KryptonMessageBox.Show(this, message, Oybab.Res.Resources.GetRes().GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }));
                    }));
                }

                StopLoad(this, null);
            });
        }
コード例 #22
0
ファイル: App.xaml.cs プロジェクト: oybab/TradingSystem
 /// <summary>
 /// 发生未捕获错误(UI)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     ExceptionPro.ExpLog(e.Exception, new Action <string>((message) =>
     {
         MessageBox.Show(Application.Current.MainWindow, message, Res.Resources.GetRes().GetString("ErrorBig"), MessageBoxButton.OK, MessageBoxImage.Error);
     }));
     e.Handled = true;
 }
コード例 #23
0
        /// <summary>
        /// 路径合并
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        public static string Combine(params string[] paths)
        {
            try
            {
                if (paths.Length == 0)
                {
                    throw new OybabException("please input path, paths.Length == 0");
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    string        spliter = "\\";

                    string firstPath = paths[0];

                    if (firstPath.StartsWith("HTTP", StringComparison.OrdinalIgnoreCase))
                    {
                        spliter = "/";
                    }

                    if (!firstPath.EndsWith(spliter))
                    {
                        firstPath = firstPath + spliter;
                    }
                    builder.Append(firstPath);

                    for (int i = 1; i < paths.Length; i++)
                    {
                        string nextPath = paths[i];
                        if (nextPath.StartsWith("/") || nextPath.StartsWith("\\"))
                        {
                            nextPath = nextPath.Substring(1);
                        }

                        if (i != paths.Length - 1)//not the last one
                        {
                            if (nextPath.EndsWith("/") || nextPath.EndsWith("\\"))
                            {
                                nextPath = nextPath.Substring(0, nextPath.Length - 1) + spliter;
                            }
                            else
                            {
                                nextPath = nextPath + spliter;
                            }
                        }

                        builder.Append(nextPath);
                    }

                    return(builder.ToString());
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
                return(null);
            }
        }
コード例 #24
0
        private int Count = 0; //错误次数



        /// <summary>
        /// 检测并提示用户(非循环)!
        /// </summary>
        /// <param name="alert"></param>
        /// <param name="close"></param>
        internal async Task CheckAndAlertOnce(Action <string> alert, Action close = null, bool IsAuto = true)
        {
            //连接到服务器检测会话
            bool   IsSuccess = false;
            string message   = null;


            IsSuccess = false;


            try
            {
                IsSuccess = await OperatesService.Instance.ServiceSession(true);
            }
            catch (Exception ex)
            {
                if (ex is OybabException)
                {
                    message = ex.Message;
                }
                ExceptionPro.ExpLog(ex);
            }



            if (OperatesService.Instance.IsExpired || OperatesService.Instance.IsAdminUsing)
            {
                Count = 3;
                Session.Instance.ChangeInterval(false);
            }
            else if (!IsSuccess)
            {
                ++Count;
                Session.Instance.ChangeInterval(false);
            }
            else
            {
                Count = 0;
                Session.Instance.ChangeInterval(true);
            }


            if (Count >= 3)
            {
                if (null != alert)
                {
                    alert(message);
                }
            }
            else
            {
                if (null != close)
                {
                    close();
                }
            }
        }
コード例 #25
0
        /// <summary>
        /// 初始化钱箱设置
        /// </summary>
        private void InitDrawbox()
        {
            krpcbCashDrawer.Items.Clear();
            krpcbCashDrawer.Items.Add(Resources.GetRes().GetString("None"));

            RegistryKey ComReg = null;

            string[] ComList;
            object   ComStr = null;


            try
            {
                ComReg = Registry.LocalMachine.OpenSubKey("HARDWARE\\DEVICEMAP\\SERIALCOMM", false);

                if (null != ComReg)
                {
                    ComList = ComReg.GetValueNames();
                    for (int i = 0; i < ComList.Length; i++)
                    {
                        ComStr = ComReg.GetValue(ComList[i]);
                        if (null != ComStr && (ComStr.ToString() != "") && (("COM").ToLower().CompareTo((ComStr.ToString().Substring(1 - 1, 3)).ToLower()) == 0))
                        {
                            if (!krpcbCashDrawer.Items.Contains(ComStr))
                            {
                                krpcbCashDrawer.Items.Add(ComStr);

                                if (!string.IsNullOrWhiteSpace(Resources.GetRes().CashDrawer) && null != ComStr && !string.IsNullOrWhiteSpace(ComStr.ToString()) && Resources.GetRes().CashDrawer == ComStr.ToString())
                                {
                                    krpcbCashDrawer.SelectedIndex = krpcbCashDrawer.Items.Count - 1;
                                }
                            }
                        }
                    }
                }


                const string local = "System";
                krpcbCashDrawer.Items.Add(local);

                if (!string.IsNullOrWhiteSpace(Resources.GetRes().CashDrawer) && Resources.GetRes().CashDrawer == local)
                {
                    krpcbCashDrawer.SelectedIndex = krpcbCashDrawer.Items.Count - 1;
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }

            if (krpcbCashDrawer.SelectedIndex == -1)
            {
                krpcbCashDrawer.SelectedIndex = 0;
            }
        }
コード例 #26
0
        /// <summary>
        /// 初始化卡片阅读器
        /// </summary>
        private void InitCardReader()
        {
            resultCardList.Clear();
            this.CardList.Children.Clear();

            RoomStateModel nullRoomStateModel = new RoomStateModel()
            {
                RoomNo = Resources.GetRes().GetString("None")
            };

            resultCardList.Add(nullRoomStateModel);


            try
            {
                KeyboardHook hook             = new KeyboardHook();
                var          availbleScanners = hook.GetKeyboardDevices();
                if (null != availbleScanners && availbleScanners.Count > 0)
                {
                    foreach (var item in availbleScanners.Distinct())
                    {
                        RoomStateModel model = new RoomStateModel()
                        {
                            RoomNo = String.Format("{0:X}", item.GetHashCode())
                        };


                        if (String.Format("{0:X}", item.GetHashCode()) == Resources.GetRes().CardReader)
                        {
                            model.UseState = true;
                        }

                        if (resultCardList.Where(x => x.RoomNo == model.RoomNo).Count() == 0)
                        {
                            resultCardList.Add(model);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }

            foreach (var item in resultCardList)
            {
                AddCardItem(item);
            }

            if (resultCardList.Where(x => x.UseState).Count() == 0)
            {
                nullRoomStateModel.UseState = true;
            }
        }
コード例 #27
0
        private int Count = 0; //错误次数

        /// <summary>
        /// 检测并提示用户!
        /// </summary>
        /// <param name="alert"></param>
        /// <param name="close"></param>
        public void CheckAndAlert(Action <string> alert, Action close = null)
        {
            do
            {
                //链接到服务器检测会话
                bool   IsSuccess = false;
                string message   = null;

                try
                {
                    IsSuccess = Res.Server.OperatesService.GetOperates().ServiceSession(true);
                }
                catch (Exception ex)
                {
                    if (ex is OybabException)
                    {
                        message = ex.Message;
                    }
                    ExceptionPro.ExpLog(ex);
                }

                if (OperatesService.GetOperates().IsExpired || OperatesService.GetOperates().IsAdminUsing)
                {
                    Count = 3;
                    Session.Instance.ChangeInterval(false);
                }
                else if (!IsSuccess)
                {
                    ++Count;
                    Session.Instance.ChangeInterval(false);
                }
                else
                {
                    Count = 0;
                    Session.Instance.ChangeInterval(true);
                }

                if (Count >= 3)
                {
                    if (null != alert)
                    {
                        alert(message);
                    }
                }
                else
                {
                    if (null != close)
                    {
                        close();
                    }
                    break;
                }
            } while (1 == 1);
        }
コード例 #28
0
        internal T Import <T>(Form form)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();

                openFileDialog.Multiselect = false;
                openFileDialog.Title       = Resources.GetRes().GetString("InputData");
                openFileDialog.Filter      = "Data File(*.dt)|*.dt";
                openFileDialog.FileName    = "file.dt";

                DialogResult result = openFileDialog.ShowDialog(form);
                if (result != System.Windows.Forms.DialogResult.OK)
                {
                    return(default(T));
                }

                if (!openFileDialog.CheckFileExists)
                {
                    return(default(T));
                }


                string encryptedStr = "";

                using (System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog.FileName, Encoding.UTF8))
                {
                    encryptedStr = sr.ReadToEnd();
                }

                string decryptedstring = Decrypt(encryptedStr, "ADGWTDSCSA214235", Encoding.UTF8.GetBytes("OybabCorp8888111"));

                T model = JsonConvert.DeserializeObject <T>(decryptedstring);

                if (null == model)
                {
                    KryptonMessageBox.Show(form, Resources.GetRes().GetString("Exception_InputReadData"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    KryptonMessageBox.Show(form, Resources.GetRes().GetString("InputDataSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                return(model);
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
                KryptonMessageBox.Show(form, Resources.GetRes().GetString("Exception_InputData"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(default(T));
            }
        }
コード例 #29
0
        /// <summary>
        /// 导出条码秤数据
        /// </summary>
        /// <param name="form"></param>
        /// <param name="data"></param>
        internal void OutputScalesData(Form form, List <Product> products)
        {
            try
            {
                if (null == products || products.Count == 0)
                {
                    KryptonMessageBox.Show(form, Resources.GetRes().GetString("NotFoundAnyRecords"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                //选择导出位置
                SaveFileDialog saveFileDialog = new SaveFileDialog();

                saveFileDialog.Title    = Resources.GetRes().GetString("OutputData");
                saveFileDialog.Filter   = "Data File(*.txt)|*.txt";
                saveFileDialog.FileName = "file.txt";

                DialogResult result = saveFileDialog.ShowDialog(form);
                if (result != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }



                using (StreamWriter stream = new StreamWriter(saveFileDialog.FileName, false, Encoding.Default))
                {
                    foreach (var item in products.OrderBy(x => x.Barcode))
                    {
                        // 输出DHBZ5格式
                        // plu号 4位 + 商品编码 4位, 跟PLU号一样    + 5位价格信息                                                                      +模式0+有效期 + 店号 + 皮重 +   + "特殊信息+A 分隔符" + 产品名和分隔符B +
                        //string code = item.Barcode.Substring(1,4) + item.Barcode.PadLeft(6, '0') + string.Format("{0:0.00}", item.Price).Replace(".", "").PadLeft(5, '0') + "0" + "000" + "22" + "00000" + "0A" + new string(item.ProductNameZH.Replace("A", "").Replace("B", "").Take(9).ToArray()) + "B";


                        // 输出DHTMA07
                        //*分隔符1P(0位)+ PLU编号,分隔符A(4位)   + 商品编号(7位) + 单价(6位) + 模式(1位) +  特殊信息1(2位) +  特殊信息2(2位) +  特殊信息3(2位) + 有效期(3位) + 店号(2位) + *(2位) + 13位码 + 皮重(5位) + 标签号(2位) + * (26位分隔符##) + 品名(0位分隔符##) + 备注A(0位分隔符##)

                        string code = "1P" + item.Barcode.Substring(1, 4) + "A" + item.Barcode.PadLeft(7, '0') + string.Format("{0:0.00}", item.Price).Replace(".", "").PadLeft(6, '0') + "0" + "00" + "00" + "00" + "000" + "22" + "00" + "0000000000000" + "00000" + "00" + "00000000000000000000000000##" + new string(item.ProductName0.Replace("#", "").Take(9).ToArray()) + "##" + "##";
                        stream.WriteLine(code);
                    }
                }

                KryptonMessageBox.Show(form, Resources.GetRes().GetString("OutputDataSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
                KryptonMessageBox.Show(form, Resources.GetRes().GetString("Exception_OutputData"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #30
0
ファイル: RegTimeWindow.cs プロジェクト: oybab/TradingSystem
 private void krpbHelp_Click(object sender, EventArgs e)
 {
     try
     {
         if (System.IO.File.Exists(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "help.chm")))
         {
             System.Diagnostics.Process.Start(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "help.chm"), "联系我们.htm");
         }
     }
     catch (Exception ex)
     {
         ExceptionPro.ExpLog(ex);
     }
 }