public string reName(string sourcePath) { if (!File.Exists(sourcePath)) { MessageBox.Show("文件生成失败,请稍候重试", "提示"); return(null); } string dirPath = Path.GetDirectoryName(sourcePath); //string fileName = Path.GetFileName(settings["savedPath"]); string newFileName = Path.Combine(dirPath, "未命名.pdf"); int m = 0; for (int i = 1; i <= 100; i++) { if (File.Exists(newFileName)) { m++; newFileName = Path.Combine(dirPath, "未命名(" + i + ").pdf"); } else { break; } } if (m >= 100) { MessageBox.Show("目录" + dirPath + "文件过大,请及时清理"); return(null); } File.Move(sourcePath, newFileName); return(newFileName); }
public string reName(string sourcePath, string pdfName) { if (!File.Exists(sourcePath)) { MessageBox.Show("文件生成失败,请稍候重试", "提示"); return(null); } string dirPath = Path.GetDirectoryName(sourcePath); //string fileName = Path.GetFileName(settings["savedPath"]); string newFileName = Path.Combine(dirPath ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(pdfName) + ".pdf"); int m = 0; for (int i = 1; i <= 100; i++) { if (File.Exists(newFileName)) { m++; newFileName = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(pdfName) + "(" + i + ").pdf"); } else { break; } } if (m >= 100) { MessageBox.Show("目录" + dirPath + "文件过大,请及时清理"); return(null); } File.Move(sourcePath, newFileName); return(newFileName); }
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; }
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位"); } }
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; }
public void WinLoaded(Object[] x) { ThreadPool.QueueUserWorkItem((obj) => { ///找不到为什么第二次打开IsSingleIsChecked变为False IsSingleIsChecked = true; MaxValue = FileHelper.FileCount; LocalFilePath = FileHelper.LocalFilePath; FileUrl = FileHelper.FileUrl; OrderState = FileHelper.OrderState; OrderId = FileHelper.OrderId; OrderNo = FileHelper.OrderNo; switch (OrderState) { case 0: //未支付订单 BtnText = "支付"; break; case 10: BtnText = "重新生成"; break; case 200: BtnText = "再来一单"; break; } bool bo = HttpFile.Download(FileHelper.LocalFilePath, FileHelper.FileUrl); DispatcherHelper.CheckBeginInvokeOnUI(() => { MoonPdfPanel pdfPanel = x[0] as MoonPdfPanel; pdfPanel.MaxZoomFactor = 2.0; pdfPanel.MinZoomFactor = 0.5; //Thread.Sleep(100); if (bo) { pdfPanel.OpenFile(FileHelper.LocalFilePath); _isLoaded = true; } else { MessageBox.Show("文件路径错误或已删除"); } }); }); }
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)); }
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; }
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()); }
/// <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 CsharpCall(int callbackType, int code, [MarshalAs(UnmanagedType.LPStr)] string msg1, [MarshalAs(UnmanagedType.LPStr)] string msg2) { try { Dictionary <string, string> settings = getPrintSettings(msg2); if (callbackType == 1 && code == 1) { #region 用户上传文件 ThreadPool.QueueUserWorkItem((obj) => { string FilePath = ""; string copiesNum = ""; string color = ""; string documentName = ""; string pageCount1 = ""; //string newFileName = reName(settings["savedPath"]); string newFileName = reName(settings["savedPath"], settings["document"]); if (string.IsNullOrEmpty(newFileName)) { return; } /* * 这里用了委托 */ List <string> filePath = new List <string>(); DispatcherHelper.CheckBeginInvokeOnUI(() => { //ModifyNameWindow modify_Window = new ModifyNameWindow(newFileName); ModifyNameWindow modify_Window = new ModifyNameWindow(newFileName, settings["copies"].ToString(), settings["color"] , settings["document"], settings["pageCount"]); //modify_Window.TransfEvent_New += frm_TransfEvent; modify_Window.TransfEvent_New += frm_TransfEvent; bool bo = (bool)modify_Window.ShowDialog(); //string filePath, string copies, string isColor, string documentName //void frm_TransfEvent(string value) void frm_TransfEvent(string filePath1, string copies, string isColor, string fileName, string pageCount) { FilePath = filePath1; copiesNum = copies; color = isColor; documentName = fileName; pageCount1 = pageCount; } if (bo) { string iscolor = "0"; if (settings["color"] == "1") { iscolor = "true"; } else if (settings["color"] == "0") { iscolor = "false"; } #region // Old Pram //NameValueCollection data = new NameValueCollection //{ // { "iscolor", iscolor }, // { "copies", settings["copies"] }, // { "endpage",settings["pageCount"]}, // { "userid", AccountInfo.ID }, // { "printType", "1" } //}; #endregion NameValueCollection dataUpload = new NameValueCollection { { "sourceclient", "PC" } }; var orderList = new OrderList(); var account = new Account(); var myDocument = new Bll.MyDocument(); string msg = myDocument.DocTransCoding(AccountInfo.Token, new[] { FilePath }, dataUpload); //string msg = myDocument.BusinessVirtualPrint(AccountInfo.Token, new[] { FilePath, FilePath }, data); JObject jo = (JObject)JsonConvert.DeserializeObject(msg); if (jo["code"].GetInt() == 200) { string getPrintPrice = account.GetPrintPrice(AccountInfo.Token); JObject JoPrice = (JObject)JsonConvert.DeserializeObject(getPrintPrice); if (JoPrice["code"].GetInt() == 200) { /* * 金额计算 */ double getpayMoney = settings["color"].GetBool() ? Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]) : Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]); //double payMoney = jo["dataList"]["copies"].GetInt() * jo["dataList"]["totalPage"].GetInt() * getpayMoney; double payMoney = settings["copies"].GetInt() * jo["dataList"]["totalPage"].GetInt() * getpayMoney; //MessageBox.Show(settings["copies"] + payMoney); #region 双面打订单金额减半 //settings["duplex"]=1是双面, if (settings["duplex"].GetBool()) { //重新计算张数 double ReSetTotalpage = Math.Ceiling(Convert.ToDouble(jo["dataList"]["totalPage"]) / 2); //重新计算金额 payMoney = settings["copies"].GetInt() * ReSetTotalpage * getpayMoney; } #endregion string orderID = jo["dataList"]["orderId"].ToString(); string homePage = jo["dataList"]["filePageSection"].ToString().Split('-')[0]; string endPage = jo["dataList"]["filePageSection"].ToString().Split('-')[1]; NameValueCollection dataPay = new NameValueCollection { { "orderid", orderID }, { "paymode", "3" }, { "homepage", homePage }, { "endpage", endPage }, { "iscolor", settings["color"] }, { "printmode", settings["duplex"] }, { "copies", settings["copies"] }, { "amount", payMoney.ToString(CultureInfo.InvariantCulture) } }; string temVal = orderList.OrderPay(AccountInfo.Token, dataPay); JObject JoPay = (JObject)JsonConvert.DeserializeObject(temVal); if (JoPay["code"].GetInt() == 200) { MessageBox.Show("您的订单已生成", "提示"); } else { MessageBox.Show(JoPay["msg"].ToString(), "提示"); } } else { MessageBox.Show("用户支付金额获取失败,已生成未支付订单", "提示"); } } else { DispatcherHelper.CheckBeginInvokeOnUI(() => { MessageBox.Show("订单生成失败2", "提示"); }); } } }); }); #endregion } } catch (Exception e) { MessageBox.Show(e.Message); } }
//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 }
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()); } }