Exemplo n.º 1
0
        private void Reg_Click(object[] obj)
        {
            ///*****

            string      Phone = obj[0].ToString();
            PasswordBox pwd   = obj[1] as PasswordBox;
            Page        page  = obj[2] as Page;
            string      Pwd   = pwd.Password;
            ///****
            bool bo = Pwd.Length >= 6 ? true : false;

            if (bo)
            {
                RunState = true;
                string  RegCallBack   = account.Regist(Phone, "", Pwd);               //中间参数为注册时送的金额的验证码,可空
                JObject RegCallBackJo = (JObject)JsonConvert.DeserializeObject(RegCallBack);
                if (JObjectHelper.GetStrNum(RegCallBackJo["code"].ToString()) == 200) //注册成功
                {
                    RunState = false;
                    MessageBox.Show("注册成功");
                }
                else
                {
                    RunState = true;
                    MessageBox.Show(RegCallBackJo["message"].ToString());
                }
            }
            else
            {
                MessageBox.Show("密码长度不能小于6位");
            }
        }
Exemplo n.º 2
0
        public void forget_IsExistPhone(string Phone)  //手机号是否已注册
        {
            string  IsExistPhoneStr = account.IsExistPhone(Phone);
            JObject jo = (JObject)JsonConvert.DeserializeObject(IsExistPhoneStr);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) != 200)    //这里和注册时不一样
            {
                string  GetSmsCodeStr = account.GetSmsCode(Phone);
                JObject CodeJo        = (JObject)JsonConvert.DeserializeObject(GetSmsCodeStr);
                if (JObjectHelper.GetStrNum(CodeJo["code"].ToString()) == 200)
                {
                    thread = new Thread(GetCodeBtnText);
                    thread.Start();
                    code = CodeJo["message"].ToString();
                }
                else
                {
                    MessageBox.Show("验证码发送失败");
                }
            }
            else
            {
                MessageBox.Show("该号码还未注册");
            }
        }
Exemplo n.º 3
0
        void FilePrintEvent(List <string> value)
        {
            NameValueCollection data = new NameValueCollection
            {
                { "sourceclient", "PC" }
            };

            Bll.AUFileDocument document = new AUFileDocument();
            string             temVal   = document.AUDiskFilePrint(AccountInfo.Token, value.ToArray(), data);
            JObject            jo       = (JObject)JsonConvert.DeserializeObject(temVal);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                //FileHelper.FileCount = jo["dataList"]["previewImgs"].Count();
                FileHelper.FileCount          = jo["dataList"]["filePageSection"].ToString().Split('-')[1].GetInt();
                FileHelper.FileUrl            = RequestAddress.server + jo["dataList"]["pdfUrl"];
                FileHelper.OrderId            = jo["dataList"]["id"].ToString();
                FileHelper.OrderNo            = jo["dataList"]["orderNo"].ToString();
                FileHelper.OrderState         = JObjectHelper.GetStrNum(jo["dataList"]["orderState"].ToString());
                FileHelper.LocalFileDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "filetemporary");
                FileHelper.LocalFilePath      = Path.Combine(FileHelper.LocalFileDirectory, jo["dataList"]["fileName"].ToString());
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    (new FilePreView()).Show();
                });
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }
            RunState = false;
        }
 /// <summary>
 /// 获取同步文件列表
 /// </summary>
 void GetTrayFileList()
 {
     ThreadPool.QueueUserWorkItem((obj) =>
     {
         RunState    = true;
         EmptyIsShow = false;
         Bll.AUFileDocument document = new AUFileDocument();
         string temVal = document.GetTransferAUDiskFile(AccountInfo.Token, AccountInfo.ID);
         JObject jo    = (JObject)JsonConvert.DeserializeObject(temVal);
         if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 UnDownload.Clear();
                 int index = 0;
                 for (int i = 0; i < jo["dataList"].Count(); i++)
                 {
                     UnDownload.Add(new Model.TrayHistory()
                     {
                         Index        = index + 1,
                         FileUrl      = RequestAddress.server + jo["dataList"][i]["fileUrl"],
                         Id           = jo["dataList"][i]["ID"].ToString(),
                         FileName     = Path.GetFileName(jo["dataList"][i]["fileUrl"].ToString()),
                         CreateDate   = DateTime.Now,
                         CanDownload  = true,
                         DownTextShow = true
                     });
                     index++;
                     EmptyIsShow = false;
                 }
             });
         }
         RunState = false;
     });
 }
Exemplo n.º 5
0
        private void Forget_Click(object[] obj)
        {
            string      Phone = obj[0].ToString();
            PasswordBox pwd   = obj[1] as PasswordBox;
            Page        page  = obj[2] as Page;
            string      Pwd   = pwd.Password;
            bool        bo    = Pwd.Length >= 6 ? true : true;

            if (bo)
            {
                RunState = true;
                string  ForgetCallBack   = account.ReviewPwd(Phone, Pwd);
                JObject ForgetCallBackJo = (JObject)JsonConvert.DeserializeObject(ForgetCallBack);
                if (JObjectHelper.GetStrNum(ForgetCallBackJo["code"].ToString()) == 200)
                {
                    //Button Btn = new Button
                    //{
                    //    Tag = "Login",
                    //};
                    //LoginHelper.LoginNavigate(Btn, page);
                    RunState = false;
                    MessageBox.Show("密码修改成功");
                }
                else
                {
                    RunState = false;
                    MessageBox.Show(ForgetCallBackJo["message"].ToString());
                }
            }
            else
            {
                MessageBox.Show("密码长度不能小于6位");
            }
        }
        /// <summary>
        /// 打开下载目录
        /// </summary>
        void OpenFloder(Object[] obj)
        {
            Button Btn      = obj[0] as Button;
            int    Index    = JObjectHelper.GetStrNum(Btn.Tag.ToString()) - 1;
            string FileName = UnDownload[Index].FileName;

            //打开文件资源管理器并选中文件
            System.Diagnostics.Process.Start("explorer.exe", "/select," + Path.Combine(localDownload, FileName));
        }
Exemplo n.º 7
0
        /// <summary>
        /// CheckBox选中
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="ch"></param>
        public void Check(ObservableCollection <TrayHistory> collection, object[] x)
        {
            CheckBox ch    = x[0] as CheckBox;
            int      Index = JObjectHelper.GetStrNum(ch.Tag.ToString());

            collection[Index - 1].IsChecked = (bool)ch.IsChecked;
            SelectChecked(collection);
            SelectCheckedAll(collection);
        }
Exemplo n.º 8
0
        void UploadFileEvent(List <string> value)
        {
            NameValueCollection data = new NameValueCollection
            {
                { "sourceClient", "PC" },
                { "audiskflag", "audiskpc" }
            };

            Bll.AUFileDocument document = new AUFileDocument();
            string             temVal   = document.AUDiskFilesCloud(AccountInfo.Token, value.ToArray(), data);
            JObject            jo       = (JObject)JsonConvert.DeserializeObject(temVal);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                for (int i = 0; i < value.Count; i++)
                {
                    XElement File = new XElement("File");
                    //File.SetElementValue("Id", UnDownload[Index].Id);
                    File.SetElementValue("FileName", Path.GetFileName(value[i].ToString()));
                    File.SetElementValue("FileUrl", value[i].ToString());
                    //File.SetElementValue("DownLoadPath", Path.Combine(localDownload, UnDownload[Index].FileName));
                    File.SetElementValue("CreateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                    FileOperationHelper.WriteXml(History, File);
                }

                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Delete(LocalTray);
                    var trayUpload = PageTrayHistoryUploadedViewModel.GetInstance();
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        SynchronizationContext.SetSynchronizationContext(
                            new System.Windows.Threading.DispatcherSynchronizationContext(System.Windows
                                                                                          .Application
                                                                                          .Current.Dispatcher));
                        SynchronizationContext.Current.Post(p =>
                        {
                            trayUpload.GetLocalTrayHistoryUploaded();
                        },
                                                            null);
                    });
                });
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }
            RunState = false;
        }
Exemplo n.º 9
0
 /// <summary>
 /// 单方面修改头像
 /// </summary>
 void ImageMouseBtnUp()
 {
     //WinImageClipping winImage=new WinImageClipping();
     //winImage.Show();
     Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
     ofd.Filter = "图像文件|*.jpg;*.png;*.jpeg;*.bmp;*.gif|所有文件|*.*";
     //ofd.InitialDirectory = @"C:\Users\Public\Pictures";
     ofd.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonPictures);
     ofd.Multiselect      = false;
     if (ofd.ShowDialog() == true)
     {
         //此处做你想做的事 ...=ofd.FileName;
         //MessageBox.Show(ofd.FileName);//显示文件完整路径
         ThreadPool.QueueUserWorkItem((obj) =>
         {
             System.Drawing.Image image = new Bitmap(ofd.FileName);
             int minValue  = image.Height > image.Width ? image.Width : image.Height;
             Bitmap bmp    = ThumbnailImage.CutImage(image, minValue, minValue);
             Bitmap bmp_60 = new Bitmap(bmp);
             bmp.Dispose();
             if (!Directory.Exists(Path.GetDirectoryName(SavePath.UserIconEdit)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(SavePath.UserIconEdit));
             }
             bmp_60.Save(SavePath.UserIconEdit, ImageFormat.Png);
             bmp_60.Dispose();
             Bll.Account account = new Account();
             string msg          = account.EditOwnInfo(AccountInfo.Token, new[] { SavePath.UserIconEdit }, null);
             JObject Jo          = (JObject)JsonConvert.DeserializeObject(msg);
             if (JObjectHelper.GetStrNum(Jo["code"].ToString()) == 200)
             {
                 AccountInfo.IconImage = Jo["dataList"]["icon"].ToString();
                 string NewFilePath    = Path.Combine(SavePath.UserInfo,
                                                      Path.GetFileNameWithoutExtension(AccountInfo.IconImage));
                 SavePath.UserIcon_30x30 = Path.Combine(NewFilePath, "_30x30.bmp");
                 if (!Directory.Exists(NewFilePath))
                 {
                     Directory.CreateDirectory(NewFilePath);
                 }
                 File.Copy(SavePath.UserIconEdit, Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage)));
                 System.Drawing.Image _image = new Bitmap(Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage)));
                 Bitmap icon_30x30           = ThumbnailImage.SizeImageWithOldPercent(_image, 30, 30);
                 Bitmap bmp30 = new Bitmap(icon_30x30);
                 icon_30x30.Dispose();
                 bmp30.Save(SavePath.UserIcon_30x30, ImageFormat.Bmp);
                 HeaderPath = Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage));
                 ImagePath  = SavePath.UserIcon_30x30;
             }
         });
     }
 }
Exemplo n.º 10
0
        JObject GotoPay(string begionPage, string endPage, string copies, bool isColor, bool isSingle)
        {
            Bll.OrderList orderList = new OrderList();
            Bll.Account   account   = new Account();
            string        priceVal  = account.GetPrintPrice(AccountInfo.Token);
            JObject       JoPrice   = (JObject)JsonConvert.DeserializeObject(priceVal);

            if (JoPrice["code"].GetInt() == 200)
            {
                //double BlackPrice = Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]);
                //double ColorPrice = Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]);
                int    PageCount = (JObjectHelper.GetStrNum(endPage) - JObjectHelper.GetStrNum(begionPage) + 1) * JObjectHelper.GetStrNum(copies);
                double payMoney  = PageCount * (isColor ? Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]):Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]));
                #region 双面订单金额减半
                if (!isSingle)
                {
                    ///重新计算页数
                    double ReSetTotalPage = Math.Ceiling(Convert.ToDouble((Convert.ToDouble(endPage) - Convert.ToDouble(begionPage) + 1) / 2));
                    payMoney = ReSetTotalPage * copies.GetInt() * (isColor ? Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]) : Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]));
                }

                #endregion
                NameValueCollection data = new NameValueCollection
                {
                    { "orderid", OrderId },
                    { "amount", payMoney.ToString() },
                    { "paymode", "3" },
                    { "homepage", begionPage },
                    { "endpage", endPage },
                    { "iscolor", isColor?"1":"0" },
                    { "printmode", isSingle?"0":"1" },
                    { "copies", copies }
                };
                string temVal = orderList.OrderPay(AccountInfo.Token, data);
                //string temVal = orderList.OrderPayByBusiness(AccountInfo.Token, begionPage, endPage, copies, isColor, OrderNo);
                return((JObject)JsonConvert.DeserializeObject(temVal));
            }
            else
            {
                var RetVal = JsonConvert.SerializeObject(new
                {
                    code    = 404,
                    message = "订单生成失败"
                });
                return((JObject)JsonConvert.DeserializeObject(RetVal));
            }
        }
Exemplo n.º 11
0
        public void Printer(Object[] x)
        {
            int     num1          = JObjectHelper.GetStrNum(x[0].ToString());
            int     num2          = JObjectHelper.GetStrNum(x[1].ToString());
            int     begion        = num1 <= num2 ? num1 : num2;
            int     end           = num1 > num2 ? num1 : num2;
            int     copies        = JObjectHelper.GetStrNum(x[2].ToString());
            bool    isColor       = BooleanHelper.GetBoolean(x[3]) ?? false;
            bool    isSinglePrint = BooleanHelper.GetBoolean(x[4]) ?? false;
            JObject jo            = null;

            switch (OrderState)
            {
            case 0:      //去支付
                jo = GotoPay(begion.ToString(), end.ToString(), copies.ToString(), isColor, isSinglePrint);
                break;

            case 10:     //未打印订单,重新生成一单
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor?"1":"0", isSinglePrint?"0":"1");
                break;

            case 200:     //打印完成,重新生成
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor ? "1" : "0", isSinglePrint?"0":"1");
                break;

            default:
                MessageBox.Show("信息错误");
                return;
            }

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Messenger.Default.Send <string>(OrderId, "ordercreatesuccess");
                });
                MessageBox.Show("订单生成成功");
            }
            else
            {
                MessageBox.Show(jo["message"].ToString());
            }
            //myDocument.ReCreateOrder(AccountInfo.Token, FileId, Path.GetFileName(LocalFilePath));
        }
Exemplo n.º 12
0
        void GetOrderList(int pageSize, int pageIndex, string orderState)
        {
            RunState    = true;
            EmptyIsShow = false;
            Bll.OrderList bllOrderList = new Bll.OrderList();
            string        Str          = bllOrderList.GetOrderList(AccountInfo.Token, pageSize.ToString(), pageIndex.ToString(),
                                                                   orderState);
            JObject jo = (JObject)JsonConvert.DeserializeObject(Str);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                for (int i = 0; i < jo["dataList"].Count(); i++)
                {
                    var order = jo["dataList"][i];
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        OrderListAll.Add(new OrderListAll()
                        {
                            Index          = i + 1,
                            CreateTime     = DateTimeHelper.GetDateTime(order["CreateTime"].ToString()),
                            FileId         = order["FileId"].ToString(),
                            FileName       = order["FileName"].ToString(),
                            FileType       = order["FileType"].ToString(),
                            ID             = order["ID"].ToString(),
                            OrderCateoryId = order["OrderCategoryId"].ToString(),
                            OrderNo        = order["OrderNo"].ToString(),
                            OrderState     = JObjectHelper.GetStrNum(order["OrderState"].ToString()), //获取订单状态
                            PayMode        = order["PayMode"].ToString()
                        });
                    });
                }
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }

            RunState = false;
        }
Exemplo n.º 13
0
        /// <summary>
        /// 单方面修改签名
        /// </summary>
        void EditSignature(object[] x)
        {
            TextBox _nicknameTextBox = x[0] as TextBox;
            string  str = _nicknameTextBox.Text;

            ThreadPool.QueueUserWorkItem((obj) =>
            {
                Bll.Account account      = new Account();
                NameValueCollection data = new NameValueCollection
                {
                    { "signature", str },
                };
                string msg = account.EditOwnInfo(AccountInfo.Token, null, data);
                JObject Jo = (JObject)JsonConvert.DeserializeObject(msg);
                if (JObjectHelper.GetStrNum(Jo["code"].ToString()) == 200)
                {
                    Signature = AccountInfo.Expertise = Jo["dataList"]["expertise"].ToString();
                }
            });
        }
Exemplo n.º 14
0
        private void DelSaveUser(object[] x)
        {
            Button Btn       = x[0] as Button;
            int    _index    = JObjectHelper.GetStrNum(Btn.Tag.ToString()) - 1;
            string UserPhone = LocalUserInfo[_index].Phone;

            LocalUserInfo.RemoveAt(_index);
            //删除本地用户
            XElement xele = XElement.Load(Path.Combine(localUserInfoFilepath, FileName));
            //MessageBox.Show(xele.Element("Phone").Value)
            var item = (from ele in xele.Elements("User")
                        where (string)ele.Element("Phone") == UserPhone
                        select ele).FirstOrDefault();

            if (item != null)
            {
                item.Remove();
            }
            xele.Save(Path.Combine(localUserInfoFilepath, FileName));
            sort();
        }
Exemplo n.º 15
0
        void SelectPhone(object[] x)
        {
            ComboBox    cmbBox   = x[0] as ComboBox;
            Button      phoneBtn = x[1] as Button;
            PasswordBox Psb      = x[2] as PasswordBox;

            Page     loginPage = x[3] as Page;
            CheckBox isKeepPwd = loginPage.FindName("IsKeepPwd") as CheckBox;

            isKeepPwd.IsChecked = true;

            List <WaterMarkTextBox> TextBox = DependencyObjectHelper.FindVisualChild <WaterMarkTextBox>(cmbBox);
            int index = JObjectHelper.GetStrNum(phoneBtn.Tag.ToString()) - 1;

            //cmbBox.Text = LocalUserInfo[index].Phone;
            TextBox[0].Text       = LocalUserInfo[index].Phone;
            cmbBox.IsDropDownOpen = false;
            string[] SplitStr = LocalUserInfo[index].Pwd.Split('*');
            string   _pwd     = RsaHelper.RSADecrypt(SplitStr[0], SplitStr[1]);

            Psb.Password = _pwd;
        }
        void DownLoad(object[] obj)
        {
            Button     Btn  = obj[0] as Button;
            List <int> list = new List <int>(); list.Add(JObjectHelper.GetStrNum(Btn.Tag.ToString()) - 1);

            lock (locker)
            {
                ++DownLink;
                if (DownLink >= MaxDegreeOfParallelism)
                {
                    MessageBox.Show("最多5个下载任务");
                    return;
                }
            }
            DownloadCount(list);
            lock (locker)
            {
                --DownLink;
            }


            //DownloadFile(Index);
            //MessageBox.Show(Index.ToString());
        }
Exemplo n.º 17
0
        /// <summary>
        /// 单方面修改昵称
        /// </summary>
        void EditNickName(object[] x)
        {
            TextBox _nicknameTextBox = x[0] as TextBox;
            string  str = _nicknameTextBox.Text;

            if (string.IsNullOrEmpty(str))
            {
                NickName = AccountInfo.NickName;
                MessageBox.Show("昵称不能为空");
                return;
            }
            NameValueCollection data = new NameValueCollection
            {
                { "nickname", str },
            };
            Account account = new Account();
            string  msg     = account.EditOwnInfo(AccountInfo.Token, null, data);
            JObject Jo      = (JObject)JsonConvert.DeserializeObject(msg);

            if (JObjectHelper.GetStrNum(Jo["code"].ToString()) == 200)
            {
                NickName = AccountInfo.NickName = Jo["dataList"]["nickname"].ToString();
            }
        }
        public void GetOrderDetail(string token, string orderid)
        {
            Bll.OrderList bllOrderList = new Bll.OrderList();
            string        Str          = bllOrderList.GetOrderDetails(token, orderid);
            JObject       jo           = (JObject)JsonConvert.DeserializeObject(Str);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                var order = jo["dataList"];
                #region  知道为毛这样就行

                _orderDetail = new OrderDetail()
                {
                    Index      = 1,
                    ID         = order["id"].ToString(),
                    PdfUrl     = RequestAddress.server + order["pdfUrl"],
                    CreateTime = !string.IsNullOrEmpty(order["createTime"].ToString()) && order["createTime"].ToString().ToUpper() != "NULL" ? DateTimeHelper.GetDateTime(order["createTime"].ToString()) : "暂无",
                    FileType   = order["fileType"].ToString(),
                    OrderId    = order["orderId"].ToString(),
                    FileId     = order["fileId"].ToString(),
                    OrderNo    = order["orderNo"].ToString(),
                    OrderState = JObjectHelper.GetStrNum(order["orderState"].ToString()),
                    //QrCodeUrl = RequestAddress.server + order["qrCodeUrl"],
                    QrCodeUrl       = RequestAddress.HostServer + order["qrCodeUrl"],
                    FilePageSection = order["filePageSection"].ToString(),
                    TotalPage       = JObjectHelper.GetStrNum(order["totalPage"].ToString()),
                    TotalMoney      = order["totalMoney"].ToString(),
                    PayMode         = order["payMode"].ToString(),
                    PayTime         = DateTimeHelper.StringToDateTime(order["payTime"].ToString()),
                    DoneTime        = DateTimeHelper.StringToDateTime(order["doneTime"].ToString()),
                    PrintCode       = order["printCode"].ToString(),
                    Copies          = JObjectHelper.GetStrNum(order["copies"].ToString()),
                    FileName        = order["fileName"].ToString(),
                    //PageCount = order["previewImgs"].Count(),
                    PageCount = order["filePageSection"].ToString().Split('-')[1].GetInt(),
                    IsColor   = (bool)BooleanHelper.GetBoolean(order["isColor"]),
                    IsSingle  = (bool)BooleanHelper.GetBoolean(order["isSingle"])
                };

                switch (_orderDetail.OrderState)
                {
                case 200:
                    Order200 = true;
                    Order0   = !Order200;
                    Order10  = !Order200;
                    break;

                case 10:
                    Order10  = true;
                    Order200 = !Order10;
                    Order0   = !Order10;
                    break;

                case 0:
                    Order0   = true;
                    Order200 = !Order0;
                    Order10  = !Order0;
                    break;

                default:
                    break;
                }

                #endregion
            }
            else
            {
                MessageBox.Show(jo["message"].ToString());
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 检查更新
        /// </summary>
        public static void CheckUpdateStatus()
        {
            string CurrentVersion = ConfigurationManager.AppSettings["CurrentVersion"]; //当前程序的version版本
            string AppId          = ConfigurationManager.AppSettings["AppId"];          //当前程序的AppId,唯一标示

            Bll.AppVersion appVersion = new AppVersion();
            string         tempVal    = appVersion.GetAppVersion();
            //MessageBox.Show(str);
            JObject jo = (JObject)JsonConvert.DeserializeObject(tempVal);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)  //请求成功
            {
                int[] _currentVersion = Array.ConvertAll <string, int>(CurrentVersion.Split('.'), int.Parse);
                int[] _updateVersion  = Array.ConvertAll <string, int>(jo["dataList"]["VersionNo"].ToString().Split('.'), int.Parse);
                int   len             = _currentVersion.Length >= _updateVersion.Length
                    ? _updateVersion.Length
                    : _currentVersion.Length;
                //判断是否需要更新
                bool bo = false;
                for (int i = 0; i < len; i++)
                {
                    if (!bo)
                    {
                        bo = _currentVersion[i] < _updateVersion[i];
                    }
                    else
                    {
                        break;
                    }
                }
                //bo=true可以更新,false不用更新
                if (bo)
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        AutoUpdateInfo autoUpdate = new AutoUpdateInfo();
                        bool?update_bo            = autoUpdate.ShowDialog();
                        if (update_bo == null || update_bo == false)
                        {
                            return;
                        }
                        string appDir        = Path.Combine(Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar)));
                        string updateFileDir = Path.Combine(Path.Combine(appDir.Substring(0, appDir.LastIndexOf(Path.DirectorySeparatorChar))), "temporary");
                        if (!Directory.Exists(updateFileDir))
                        {
                            Directory.CreateDirectory(updateFileDir);
                        }

                        string exePath = Path.Combine(updateFileDir, "Update");

                        if (!Directory.Exists(exePath))
                        {
                            Directory.CreateDirectory(exePath);
                        }
                        //File.Copy(Path.Combine(appDir,"Update"),exePath,true);
                        FileOperationHelper.FileCopy(Path.Combine(appDir, "Update"), exePath, true);
                        //string str= "{\"CurrentVersion\":\"" + CurrentVersion + "\",\"AppId\":\"" + AppId + "\"}";
                        ProcessStartInfo psi      = new ProcessStartInfo();
                        Process ps                = new Process();
                        psi.FileName              = Path.Combine(exePath, "IntoApp.AutoUpdate.exe");
                        psi.Arguments             = tempVal.Replace(" ", "").Replace("\"", "*") + " " + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "IntoApp.exe");
                        psi.UseShellExecute       = false;
                        psi.RedirectStandardError = true;
                        //Process.Start(psi);
                        //ProcessHelper.OpenAdminProcess(psi, ps, "自动更新失败,稍后请手动更新!");
                        ShellExecute(IntPtr.Zero, "runas", @Path.Combine(exePath, "IntoApp.AutoUpdate.exe"), tempVal.Replace(" ", "").Replace("\"", "*") + " " + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "IntoApp.exe"), "", 5);
                        Application.Current.Shutdown();
                    });
                }
            }
            else    //请求失败
            {
            }
        }
Exemplo n.º 20
0
        //private MyCommand _clickCommand;

        //public MyCommand<object[]> LoginCommand
        //{
        //    get
        //    {
        //        return  new MyCommand<object[]>(x=> Login_Click(x));
        //    }
        //}
        //窗口登录操作

        #region 方法
        private void Login_Click(object[] obj)
        {
            #region

            RunState = true;

            UseComboBox             cmb     = obj[0] as UseComboBox;
            List <WaterMarkTextBox> TextBox = DependencyObjectHelper.FindVisualChild <WaterMarkTextBox>(cmb);
            string Phone = TextBox[0].Text;

            PasswordBox pwd    = obj[1] as PasswordBox;
            string      Pwd    = pwd.Password;
            Page        page   = obj[2] as Page;
            Window      window = Window.GetWindow(page);//获取当前页的母窗体(LoginWindow)
            CheckBox    ch     = obj[3] as CheckBox;

            Task.Factory.StartNew(new Action(delegate
            {
                string LoginCallBack    = account.Account_Login(Phone, Pwd);
                JObject LoginCallBackJo = (JObject)JsonConvert.DeserializeObject(LoginCallBack);
                if (JObjectHelper.GetStrNum(LoginCallBackJo["code"].ToString()) == 200)
                {
                    if (LoginCallBackJo["dataList"]["enterpriseUserFlag"].GetInt() == 0)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            RunState = false;
                            MessageBox.Show("您还未进行企业认证,请至移动端申请企业认证后登陆");
                        });
                        return;
                    }
                    Bo = true;
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        if ((bool)ch.IsChecked)
                        {
                            SaveUserLoginInfo(Phone, Pwd);
                        }
                        bool bo = LoginHelper.LoginCallBack(LoginCallBackJo);
                        if (bo)
                        {
                            Bo = true;
                            ViewModelLocator.Win_Content.Show();
                            //new ContentWindow().Show(); //contentwindow打开
                            //var cc= ViewModelLocator.Pipe;
                            Thread thread = new Thread(LoginHelper.AddPrinter);
                            thread.Start();
                            window.Close();
                        }
                    });
                }
                else
                {
                    Bo       = false;
                    RunState = false;
                    DispatcherHelper.CheckBeginInvokeOnUI(() => { MessageBox.Show(LoginCallBackJo["message"].ToString()); });
                }
            }));

            #endregion
        }