private void InitUI() { txtMonth.Text = date.Month.ToString() + "月"; txtDay.Text = date.Day.ToString(); txtWeek.Text = DateTool.DayOfWeek(date); if (date.Date == DateTime.Today) { DateSP.Background = ColorTool.HexColorToBrush("#c5f3ff"); RoomGrid.Background = ColorTool.HexColorToBrush("#53a9ba"); } Task.Factory.StartNew(() => { //改成用DispatcherPriority,因為如果快速換月份 //一直跑UI,馬上又丟棄太浪費資源 //改成有空閒再跑會議房間就好 this.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(() => //this.Dispatcher.BeginInvoke(new Action(() => { //meetingList.ForEach(item => foreach (UserMeeting item in meetingList) { var room = new MeetingRoom(UserID, UserPWD, item, this.Home_Change2MeetingDataCT_Event, NewAddMeetingID); MeetingRoomWP.Children.Add(room); } //); })); }); }
private void ParsePageJson() { // {"scale":null,"animations":null,"bookmark":null,"animation":null,"bookId":"cAF40-V","execTime":"1406304980594","actionTime":"00:00:30.697","pageIndex":null,"annotation":null,"spline":null,"hide":null,"page":null,"action":"pause","y":null,"x":null} Dictionary <string, object> dictPageJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(pageJson); Dictionary <string, object> dictMsg = JsonConvert.DeserializeObject <Dictionary <string, object> >(dictPageJson["msg"].ToString()); //play、pause、stop string action = dictMsg["action"].ToString(); string execTime = dictMsg["execTime"].ToString(); string actionTime = dictMsg["actionTime"].ToString(); switch (action) { case "play": long ec = long.Parse(execTime); long nowServerTime = 0; //快慢無所謂,減掉DeltaUTC,就是Server現在時間 nowServerTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC; long playTime = nowServerTime - ec; mediaPlayer.Position = TimeSpan.Parse(actionTime) + new TimeSpan(0, 0, 0, 0, (int)playTime); mediaPlayer.Play(); IsAlwaysShowHeaderFooter = false; break; case "pause": mediaPlayer.Play(); mediaPlayer.Position = TimeSpan.Parse(actionTime); mediaPlayer.Pause(); IsAlwaysShowHeaderFooter = true; break; } }
public async Task <UserDataDto> AddAsync(UserDto user) { var isValidEmail = EmailTool.IsValidEmail(user.Email); if (!isValidEmail) { throw new Exception("Email is not valid"); } var userAge = DateTool.GetAge(user.BirthDate); if (userAge < 18) { throw new Exception("You must be of legal age to register"); } var emailExist = await this._unitOfWork.Repositories.Users .QueryableBy(x => x.Email == user.Email) .AnyAsync(); if (emailExist) { throw new Exception("You email already exists"); } var phoneNumberExist = await this._unitOfWork.Repositories.Users .QueryableBy(x => x.PhoneNumber == user.PhoneNumber) .AnyAsync(); if (phoneNumberExist) { throw new Exception("You phone number already exists"); } var password = StringTool.GetRandomString(20); var encryptedPassword = EncryptedTool.EncryptToMD5(password); var entity = new User { Name = user.Name, LastName = user.LastName, SecondLastName = user.SecondLastName, Email = user.Email, BirthDate = user.BirthDate, PhoneNumber = user.PhoneNumber, Genre = user.Genre, Password = encryptedPassword }; this._unitOfWork.Repositories.Users.Add(entity); await this._unitOfWork.SaveAsync(); return(new UserDataDto { Id = entity.Id, Email = entity.Email, Password = password }); }
private void ParsePageJson() { Dictionary <string, object> dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(pageJson); Dictionary <string, object> dictionary2 = JsonConvert.DeserializeObject <Dictionary <string, object> >(dictionary["msg"].ToString()); string text = dictionary2["action"].ToString(); string s = dictionary2["execTime"].ToString(); string s2 = dictionary2["actionTime"].ToString(); switch (text) { case "play": { long num = long.Parse(s); long num2 = 0L; num2 = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC; long num3 = num2 - num; mediaPlayer.Position = TimeSpan.Parse(s2) + new TimeSpan(0, 0, 0, 0, (int)num3); mediaPlayer.Play(); IsAlwaysShowHeaderFooter = false; break; } case "pause": mediaPlayer.Play(); mediaPlayer.Position = TimeSpan.Parse(s2); mediaPlayer.Pause(); IsAlwaysShowHeaderFooter = true; break; } }
public Dictionary <DateCycleTypeEnum, Sum_StudyFactDateCycle> FetchOrCreateCycleData(int studentId, int classId, DateTime asOfDate) { Dictionary <DateCycleTypeEnum, Sum_StudyFactDateCycle> dic = new Dictionary <DateCycleTypeEnum, Sum_StudyFactDateCycle>(); SumStudentBll bll = new SumStudentBll(); List <Sum_StudyFactDateCycle> cycles = bll.GetCycleDatasByStudent(studentId, classId); Sum_StudyFactDateCycle totalCycle = cycles.FirstOrDefault(x => x.Sdc_CycleType == (int)DateCycleTypeEnum.Total); if (totalCycle == null) { totalCycle = new Sum_StudyFactDateCycle(); totalCycle.ForceAudit(); totalCycle.Sdc_CycleType = (int)DateCycleTypeEnum.Total; totalCycle.Sdc_Date = new DateTime(1900, 1, 1); } dic[DateCycleTypeEnum.Total] = totalCycle; Sum_StudyFactDateCycle yearCycle = cycles.FirstOrDefault(x => x.Sdc_CycleType == (int)DateCycleTypeEnum.Year); if (yearCycle == null || yearCycle.Sdc_Date != DateTool.FirstDayOfYear(asOfDate)) { int id = yearCycle == null ? 0 : yearCycle.Sdc_Id; yearCycle = new Sum_StudyFactDateCycle(); yearCycle.ForceAudit(); yearCycle.Sdc_Id = id; yearCycle.Sdc_CycleType = (int)DateCycleTypeEnum.Year; yearCycle.Sdc_Date = DateTool.FirstDayOfYear(asOfDate); } dic[DateCycleTypeEnum.Year] = yearCycle; Sum_StudyFactDateCycle monthCycle = cycles.FirstOrDefault(x => x.Sdc_CycleType == (int)DateCycleTypeEnum.Month); if (monthCycle == null || monthCycle.Sdc_Date != DateTool.FirstDayOfMonth(asOfDate)) { int id = monthCycle == null ? 0 : monthCycle.Sdc_Id; monthCycle = new Sum_StudyFactDateCycle(); monthCycle.ForceAudit(); monthCycle.Sdc_Id = id; monthCycle.Sdc_CycleType = (int)DateCycleTypeEnum.Month; monthCycle.Sdc_Date = DateTool.FirstDayOfMonth(asOfDate); } dic[DateCycleTypeEnum.Month] = monthCycle; Sum_StudyFactDateCycle weekCycle = cycles.FirstOrDefault(x => x.Sdc_CycleType == (int)DateCycleTypeEnum.Week); if (weekCycle == null || weekCycle.Sdc_Date != DateTool.FirstDayOfWeek(asOfDate)) { int id = weekCycle == null ? 0 : weekCycle.Sdc_Id; weekCycle = new Sum_StudyFactDateCycle(); weekCycle.ForceAudit(); weekCycle.Sdc_Id = id; weekCycle.Sdc_CycleType = (int)DateCycleTypeEnum.Week; weekCycle.Sdc_Date = DateTool.FirstDayOfWeek(asOfDate); } dic[DateCycleTypeEnum.Week] = weekCycle; return(dic); }
public void raid_create(Context ctx) { //Get the default timezone offset var offset = DateTool.GetDefaultTimezone(); //Pass on this.raid_create(ctx, "today", 20, 00, offset, "W1-4"); }
public ScheduleDtoProfile() { CreateMap <WOrder_Schedule, ScheduleDto>() .ForMember(u => u.UserName, opts => opts.MapFrom(p => p.User.UserName)) .ForMember(u => u.AreaName, opts => opts.MapFrom(p => p.User.AreaName)) .ForMember(u => u.WorkMode, opts => opts.MapFrom(p => p.User.WorkMode)) .ForMember(u => u.Week, opts => opts.MapFrom(p => DateTool.GetWeekZN(p.ClassDate.DayOfWeek))); }
private void _003CMeetingRoom_Loaded_003Eb__0() { InitSelectDB(); base.Dispatcher.BeginInvoke(new Action(_003CMeetingRoom_Loaded_003Eb__1)); if (DateTool.IsSameDate(DateTime.Parse(userMeeting.BeginTime), DateTime.Now)) { PreLoadMeeting(); } }
public void TestDate() { DateTime x = DateTool.FirstDayOfWeek(DateTime.Now); DateTime y = DateTool.FirstDayOfMonth(DateTime.Now); DateTime z = DateTool.FirstDayOfYear(DateTime.Now); x = DateTool.FirstDayOfWeek(new DateTime(2019, 10, 28)); x = DateTool.FirstDayOfWeek(new DateTime(2019, 11, 3)); y = DateTool.FirstDayOfMonth(new DateTime(2019, 10, 1)); y = DateTool.FirstDayOfMonth(new DateTime(2019, 10, 31)); //z = DateTool.FirstDayOfMonth(new DateTime(2019, 11, 3)); }
private void InitUI() { txtMonth.Text = date.Month + "月"; txtDay.Text = date.Day.ToString(); txtWeek.Text = DateTool.DayOfWeek(date); if (date.Date == DateTime.Today) { DateSP.Background = ColorTool.HexColorToBrush("#c5f3ff"); RoomGrid.Background = ColorTool.HexColorToBrush("#53a9ba"); } Task.Factory.StartNew(new Action(_003CInitUI_003Eb__3)); }
public void raid_create(Context ctx, uint day, uint month, uint hours, uint minutes, int offset, [RegexParameter(@"[\S\s]+")] string description) { //Derive the year var year = DateTool.GetDefaultYear((int)day, (int)month); //Validate our inputs Precondition.Assert(DateTool.IsValidDate((int)day, (int)month, year), "Invalid date!"); Precondition.Assert(hours < 24, "Invalid hours!"); Precondition.Assert(minutes < 60, "Invalid minutes!"); Precondition.Assert(Math.Abs(offset) <= 12, "Invalid offset!"); //Pass on to the implementation this.raid_create_impl(ctx, (int)day, (int)month, year, (int)hours, (int)minutes, offset, description); }
private void GetUserData_DoAction(User user, DateTime date) { // 先判斷是否要invoke if (this.Dispatcher.CheckAccess() == false) { // 這裡是下載事件處理,優先權設定為ContextIdle => 列舉值為 3。 幕後作業完成後,會處理作業。 this.Dispatcher.BeginInvoke(new Action <User, DateTime>(GetUserData_DoAction), user, date); } else { if (user != null) { //if (user.MeetingList.Length < 1) // txtNothing.Visibility = Visibility.Visible; InitUI(user.MeetingList, date); DataTable dt = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2" , user.ID , DateTool.MonthFirstDate(date).ToString("yyyyMMdd")); if (dt.Rows.Count > 0) { MSCE.ExecuteNonQuery(@"UPDATE [UserData] SET [ListDate] = @1 ,[UserJson] = @2 where UserID = @3 and ListDate =@4" , DateTool.MonthFirstDate(date).ToString("yyyyMMdd") , JsonConvert.SerializeObject(user) , user.ID , DateTool.MonthFirstDate(date).ToString("yyyyMMdd")); } else { MSCE.ExecuteNonQuery(@"INSERT INTO [UserData] ([UserID],[ListDate],UserJson) VALUES (@1,@2,@3)" , user.ID , DateTool.MonthFirstDate(date).ToString("yyyyMMdd") , JsonConvert.SerializeObject(user)); } // 會議列表的上下一頁不要複寫Buton的JSON了 // HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList); } else { AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); } MouseTool.ShowArrow(); } }
private void SentToOther(string function) { _003C_003Ec__DisplayClass22 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass22(); _003C_003Ec__DisplayClass.function = function; _003C_003Ec__DisplayClass._003C_003E4__this = this; _003C_003Ec__DisplayClass.ecTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC; if (IsInSync && IsSyncOwner) { _003C_003Ec__DisplayClass24 _003C_003Ec__DisplayClass2 = new _003C_003Ec__DisplayClass24(); _003C_003Ec__DisplayClass2.CS_0024_003C_003E8__locals23 = _003C_003Ec__DisplayClass; _003C_003Ec__DisplayClass2.mydate = new DateTime(mediaPlayer.Position.Ticks); Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass2._003CSentToOther_003Eb__21)); } }
/// <summary> /// 获取格式化后的时间格式 /// </summary> /// <param name="timeStamp">10位时间戳(不填默认当前时间戳)</param> public static string getFormatTime(long timeStamp = -1) { DateTime dateTime = new DateTime(); if (timeStamp == -1) { // 当前时间(10wei) timeStamp = DateTool.GetNowTime(); dateTime = UnixToDataTime(timeStamp); } else { // 指定的时间 dateTime = DateTool.UnixToDataTime(timeStamp); } return(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); }
private void SentToOther(string function) { long ecTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC; if (IsInSync == true && IsSyncOwner == true) { DateTime mydate = new DateTime(mediaPlayer.Position.Ticks); Task.Factory.StartNew(() => { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true); if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.broadcast("{\"execTime\":" + ecTime.ToString() + ",\"action\":\"" + function + "\",\"actionTime\":\"" + mydate.ToString("HH:mm:ss.fff") + "\",\"cmd\":\"R.SV\"}"); } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); } }
public static void AsyncPOST(string UserID, string UserPWD, DateTime date, Action <User, DateTime> DoAction, Action ErrorAction = null) { Action <HttpWebResponse> action = null; Action action2 = null; _003C_003Ec__DisplayClass4 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass4(); _003C_003Ec__DisplayClass.date = date; _003C_003Ec__DisplayClass.DoAction = DoAction; _003C_003Ec__DisplayClass.ErrorAction = ErrorAction; try { string url = WsTool.GetUrl(); string format = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><UserPW><![CDATA[{1}]]></UserPW><UserDevice>1</UserDevice><UserDateBegin>{2}</UserDateBegin><UserDateEnd>{3}</UserDateEnd></UserInfo>"; format = string.Format(format, UserID, UserPWD, DateTool.MonthFirstDate(_003C_003Ec__DisplayClass.date).ToString("yyyyMMdd"), DateTool.MonthLastDate(_003C_003Ec__DisplayClass.date).ToString("yyyyMMdd")); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["XmlDoc"] = format; HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/UserData", "POST", dictionary); if (action == null) { action = new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0); } Action <HttpWebResponse> responseAction = action; if (action2 == null) { action2 = new Action(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__1); } HttpTool.DoWithResponse(httpWebRequest, responseAction, action2); } catch (Exception ex) { if (_003C_003Ec__DisplayClass.ErrorAction != null) { _003C_003Ec__DisplayClass.ErrorAction(); } AutoClosingMessageBox.Show(ex.Message); LogTool.Debug(ex); } }
//private void meetingDayList_MouseEnter(object sender, MouseEventArgs e) //{ // MeetingDayList item = (MeetingDayList)sender; // //foreach(MeetingDayList item in MeetingDaySP.Children.OfType<MeetingDayList>()) // //{ // // How to scroll the uiElement to the mouse position? // //var sv = (ScrollViewer)Template.FindName("PART_MyScrollViewer", this); // If you do not already have a reference to it somewhere. // //var ip = (ItemsPresenter)SV.Content; // var point = item.TranslatePoint(new Point() - (Vector)e.GetPosition(SV), ip); // SV.ScrollToVerticalOffset(point.Y + (item.ActualHeight / 2)); // //break; // //} //} private Dictionary <DateTime, List <UserMeeting> > GetUserMeetingDict_ByOrder(UserMeeting[] userMeetingAry, bool IsReverse) { Dictionary <DateTime, List <UserMeeting> > dict = new Dictionary <DateTime, List <UserMeeting> >(); if (IsReverse == true) { dict = userMeetingAry .OrderBy(item => DateTool.StringToDate(item.BeginTime)) .GroupBy(item => DateTool.StringToDate(item.BeginTime).Date) .Reverse() // 倒著排序,最新的在最上面 .ToDictionary(IGrouping => IGrouping.Key, IGrouping => IGrouping.ToList()); } else { dict = userMeetingAry .OrderBy(item => DateTool.StringToDate(item.BeginTime)) .GroupBy(item => DateTool.StringToDate(item.BeginTime).Date) //.Reverse() // 倒著排序,最新的在最上面 .ToDictionary(IGrouping => IGrouping.Key, IGrouping => IGrouping.ToList()); } return(dict); }
private void MeetingRoom_Loaded(object sender, RoutedEventArgs e) { Task.Factory.StartNew(() => { InitSelectDB(); // 這裡為 日期列表畫面 下的 會議房間畫面,優先權設定為Background => 列舉值為 4。 所有其他非閒置作業都完成之後,就會處理作業。 //this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.Dispatcher.BeginInvoke(new Action(() => { InitUI(); // 有下載UI相關的把事件放到主線成 InitEvent(); })); // 正在開會議的會議 //if (DateTime.Parse(userMeeting.BeginTime) <= DateTime.Now && DateTime.Now < DateTime.Parse(userMeeting.EndTime)) if (DateTool.IsSameDate(DateTime.Parse(userMeeting.BeginTime), DateTime.Now)) { //預載會議資料 PreLoadMeeting(); } }); }
private void CallLigon() { canLogin = false; MouseTool.ShowLoading(); try { string UserID = tbUserID.Text.Trim(); string UserPWD = tbUserPWD.Password.Trim(); string UserDateBegin = DateTool.MonthFirstDate(DateTime.Today).ToString("yyyyMMdd"); //"20190101"; string UserDateEnd = DateTool.MonthFirstDate(DateTime.Today.AddMonths(1)).ToString("yyyyMMdd"); //"20190101"; //Network.HttpRequest hr = new Network.HttpRequest(); if (NetworkTool.CheckNetwork() > 0) { string url = WsTool.GetUrl(); string xmlData = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><UserPW><![CDATA[{1}]]></UserPW><UserDevice>1</UserDevice><UserDateBegin>{2}</UserDateBegin><UserDateEnd>{3}</UserDateEnd></UserInfo>"; xmlData = string.Format(xmlData, UserID, UserPWD, UserDateBegin, UserDateEnd); Dictionary <string, string> postData = new Dictionary <string, string>(); postData["XmlDoc"] = xmlData; //LogTool.Debug(xmlData); HttpWebRequest request = HttpTool.GetHttpWebRequest(url + "/UserData", "POST", postData); // init your request...then: //lambda //呼叫方法,第二個是lambda匿名方法 DoWithResponse(request, (response) => { //這裡面是不同的執行序; User user = null; try { string data = new StreamReader(response.GetResponseStream()).ReadToEnd(); //LogTool.Debug(data); user = XmlHelper.XmlDeserialize <User>(data, Encoding.UTF8); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { AutoClosingMessageBox.Show("登入失敗,請重新登入"); })); LogTool.Debug(ex); } this.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user); }); } else { //DB查詢登入 DataTable dt = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", UserID); if (dt.Rows.Count > 0) { dt = MSCE.GetDataTable("select UserJson from LoginInfo where UserID =@1 and UserPWD=@2" , UserID , UserPWD); if (dt.Rows.Count > 0) { User user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString()); string HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList); string UTC = user.UTC.ToString(); long deltaUTC = 0; try { deltaUTC = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(UTC); } catch (Exception ex) { LogTool.Debug(ex); } string SQL = @"Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8"; int success = MSCE.ExecuteNonQuery(SQL , user.ID , user.Name , tbUserPWD.Password.Trim() , HomeUserButtonAryJSON , user.Email , DateTool.GetCurrentTimeInUnixMillis().ToString() , deltaUTC.ToString() , cbRemeberLogin.IsChecked == true ? "true" : "false"); if (success < 1) { LogTool.Debug(new Exception(@"DB失敗: " + SQL)); return; } this.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user); } else { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("您的密碼錯誤"); canLogin = true; } } else { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入"); canLogin = true; } } } catch (Exception ex) { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("登入失敗"); canLogin = true; } }
private void GetNewMeeting_DoAction(string dataString) { // 先判斷是否要invoke if (this.Dispatcher.CheckAccess() == false) { // 這裡是下載事件處理,優先權設定為ContextIdle => 列舉值為 3。 幕後作業完成後,會處理作業。 this.Dispatcher.BeginInvoke(new Action <string>(GetNewMeeting_DoAction), dataString); } else { try { string CourseOrMeeting_String = PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String; XDocument xml = null; string State = ""; try { xml = XDocument.Parse(dataString); State = xml.Element("User").Attribute("State").Value.Trim(); } catch (Exception ex) { LogTool.Debug(ex); } switch (State) { case "0": string NewAddMeetingID = xml.Element("User").Element("MeetingData").Attribute("ID").Value.Trim(); string BeginTime = xml.Element("User").Element("MeetingData").Attribute("BeginTime").Value.Trim(); DateTime date = DateTime.Now; bool IsValid = DateTime.TryParse(BeginTime, out date); if (IsValid == false) { date = DateTime.Now; } // 先做UI,再把按鈕的JSON存下來 //string SQL = @"update NowLogin Set MeetingListDate=@1,NewAddMeetingID=@2";//,HomeUserButtonAryJSON=@2 //int success = MSCE.ExecuteNonQuery(SQL, date.ToString("yyyy/MM/dd"),NewAddMeetingID);//, HomeUserButtonAryJSON); //if (success < 1) // LogTool.Debug(new Exception(@"DB失敗: " + SQL)); this.NewAddMeetingID = NewAddMeetingID; // 非同步POST方法 MouseTool.ShowLoading(); //GetUserData.AsyncPOST(UserID, UserPWD // , date // , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime)); if (NetworkTool.CheckNetwork() > 0) { GetUserData.AsyncPOST(UserID, UserPWD , date , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime)); } else { //DB查詢日期 DataTable dt = MSCE.GetDataTable("select UserJson from UserData where UserID =@1 and ListDate=@2" , UserID , DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd")); User user = new User(); if (dt.Rows.Count > 0) { user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString()); } else { dt = MSCE.GetDataTable("select top 1 UserJson from UserData where UserID =@1" , UserID); if (dt.Rows.Count > 0) { user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString()); } user.MeetingList = new UserMeeting[0]; } GetUserData_DoAction(user, MeetingListDate); } AutoClosingMessageBox.Show(string.Format("成功加入{0}", CourseOrMeeting_String)); //重整列表 break; case "1": //AutoClosingMessageBox.Show(string.Format("該機關非{0}人員", CourseOrMeeting_String)); AutoClosingMessageBox.Show(string.Format("本{0}未邀請貴機關單位參與", CourseOrMeeting_String)); //AutoClosingMessageBox.Show("該機關非與會人員"); break; case "2": AutoClosingMessageBox.Show("已加入過"); break; case "3": AutoClosingMessageBox.Show(string.Format("{0}不存在", CourseOrMeeting_String)); break; case "4": AutoClosingMessageBox.Show(string.Format("{0}尚未發佈", CourseOrMeeting_String)); break; case "5": AutoClosingMessageBox.Show("無此使用者"); break; case "6": AutoClosingMessageBox.Show("加入失敗"); break; case "7": AutoClosingMessageBox.Show("機密會議"); break; case "8": AutoClosingMessageBox.Show("會議已取消"); break; default: AutoClosingMessageBox.Show("新增錯誤,請聯絡系統管理人員"); break; } } catch (Exception ex) { AutoClosingMessageBox.Show("新增錯誤,請聯絡系統管理人員"); LogTool.Debug(ex); } txtPinCode.Text = ""; MouseTool.ShowArrow(); } }
private void CheckLogin(User user) { try { if (user != null) { switch (user.State) { case "0": { string text = JsonConvert.SerializeObject(user.EnableButtonList); string text2 = (user.UTC == null) ? DateTool.GetCurrentTimeInUnixMillis().ToString() : user.UTC.ToString(); long num = 0L; try { num = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(text2); } catch (Exception ex) { LogTool.Debug(ex); } string text3 = "Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8"; string[] array = new string[8] { user.ID, user.Name, tbUserPWD.Password.Trim(), text, user.Email, text2, num.ToString(), null }; bool?isChecked = cbRemeberLogin.IsChecked; array[7] = ((isChecked.GetValueOrDefault() && isChecked.HasValue) ? "true" : "false"); int num2 = MSCE.ExecuteNonQuery(text3, array); if (num2 < 1) { LogTool.Debug(new Exception("DB失敗: " + text3)); return; } try { DataTable dataTable = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", user.ID); if (dataTable.Rows.Count > 0) { MSCE.ExecuteNonQuery("UPDATE [LoginInfo] SET \r\n [UserID] = @1\r\n\t\t ,[UserPWD] = @2\r\n ,UserJson = @3\r\n\t\t where UserID=@4", user.ID, tbUserPWD.Password.Trim(), JsonConvert.SerializeObject(user), user.ID); } else { MSCE.ExecuteNonQuery("INSERT INTO [LoginInfo] ([UserID],[UserPWD],UserJson)\r\n VALUES (@1,@2,@3)", user.ID, tbUserPWD.Password.Trim(), JsonConvert.SerializeObject(user)); } dataTable = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2", user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")); if (dataTable.Rows.Count > 0) { MSCE.ExecuteNonQuery("UPDATE [UserData] SET \r\n [ListDate] = @1\r\n\t\t ,[UserJson] = @2\r\n\t\t where UserID = @3 and ListDate =@4", DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"), JsonConvert.SerializeObject(user), user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")); } else { MSCE.ExecuteNonQuery("INSERT INTO [UserData] ([UserID],[ListDate],UserJson)\r\n VALUES (@1,@2,@3)", user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"), JsonConvert.SerializeObject(user)); } } catch (Exception ex2) { LogTool.Debug(ex2); } Hide(); Home home = new Home(user, tbUserPWD.Password.Trim()); home.Show(); Close(); break; } case "1": AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入"); break; case "2": AutoClosingMessageBox.Show("帳號密碼錯誤或帳號已被鎖定"); break; } } } catch (Exception ex3) { LogTool.Debug(ex3); } canLogin = true; MouseTool.ShowArrow(); }
// private void btnLastNext_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { SV.ScrollToVerticalOffset(1); Image img = sender as Image; if (img.Name.Equals("btnLast")) { MeetingListDate = MeetingListDate.AddMonths(-1); } else { MeetingListDate = MeetingListDate.AddMonths(1); } // 非同步POST方法 MouseTool.ShowLoading(); //檢查是否有網路連線 Network.HttpRequest hr = new Network.HttpRequest(); if (NetworkTool.CheckNetwork() > 0) { Task.Factory.StartNew(() => { //無快取機制 //GetUserData.AsyncPOST(UserID, UserPWD // , MeetingListDate // , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime)); //有快取機制 if (PreLoadLastNextMonthDict.ContainsKey(MeetingListDate) == true) { GetUserData_DoAction(PreLoadLastNextMonthDict[MeetingListDate], MeetingListDate); //預載上一個月和下一個月 PreLoadLastNextMonth(); } else { GetUserData.AsyncPOST(UserID, UserPWD , MeetingListDate , (userObj, dateTime) => { GetUserData_DoAction(userObj, dateTime); //預載上一個月和下一個月 PreLoadLastNextMonth(); }); } }); //}).ContinueWith(task => //{ // //預載上一個月 // //Thread.Sleep(100); // //GetUserData.AsyncPOST(UserID, UserPWD // // , MeetingListDate.AddMonths(-1) // // , (userObj, dateTime) => { LastNextDict[dateTime] = userObj; }); //}).ContinueWith(task => //{ // //預載下一個月 // //Thread.Sleep(100); // //GetUserData.AsyncPOST(UserID, UserPWD // // , MeetingListDate.AddMonths(1) // // , (userObj, dateTime) => { LastNextDict[dateTime] = userObj; }); //}); } else { //DB查詢日期 DataTable dt = MSCE.GetDataTable("select UserJson from UserData where UserID =@1 and ListDate=@2" , UserID , DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd")); User user = new User(); if (dt.Rows.Count > 0) { user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString()); } else { dt = MSCE.GetDataTable("select top 1 UserJson from UserData where UserID =@1" , UserID); if (dt.Rows.Count > 0) { user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString()); } user.MeetingList = new UserMeeting[0]; } GetUserData_DoAction(user, MeetingListDate); } //, () => { this.Dispatcher.BeginInvoke(new Action(() => { AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); })); }); #region 步POST方法 //User user=GetUserData.POST(UserID, UserPWD, // DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd"), // DateTool.MonthLastDate(MeetingListDate).ToString("yyyyMMdd")); //if (user != null) //{ // if (user.MeetingList.Length < 1) // txtNothing.Visibility = Visibility.Visible; // InitUI(user.MeetingList, MeetingListDate); // // 會議列表的上下一頁不要複寫Buton的JSON了 // // HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList); //} //else //{ // AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); //} #endregion // 先做UI,再把按鈕的JSON存下來 string SQL = @"update NowLogin Set MeetingListDate=@1"; //,HomeUserButtonAryJSON=@2 int success = MSCE.ExecuteNonQuery(SQL, MeetingListDate.ToString("yyyy/MM/dd")); //, HomeUserButtonAryJSON); if (success < 1) { LogTool.Debug(new Exception(@"DB失敗: " + SQL)); } }
private void InitUI(UserMeeting[] userMeetingAry, DateTime date) { string CourseOrMeeting_String = PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String; txtNothing.Text = string.Format("本月無{0}", CourseOrMeeting_String); txtPinCodeHint.Text = string.Format("請輸入{0}識別碼", CourseOrMeeting_String); btnAddHint.Text = string.Format("加入{0}", CourseOrMeeting_String); btnAddHint.Visibility = Visibility.Visible; if (userMeetingAry.Length > 0) { txtNothing.Visibility = Visibility.Collapsed; } else { txtNothing.Visibility = Visibility.Visible; } MeetingListDate = date; txtCount.Text = string.Format("共 {0} 個{1}", userMeetingAry.Length.ToString(), CourseOrMeeting_String); txtDate.Text = date.ToString("yyyy年MM月"); if (PaperLess_Emeeting.Properties.Settings.Default.IsNewMeeting_PopupDialog == false) { txtPinCodeHint.Visibility = Visibility.Visible; txtPinCode.Visibility = Visibility.Visible; } Task.Factory.StartNew(() => { Dictionary <DateTime, List <UserMeeting> > dict = new Dictionary <DateTime, List <UserMeeting> >(); //dict = GetUserMeetingDict_ByOrder(userMeetingAry, PaperLess_Emeeting.Properties.Settings.Default.UserMeeting_Reverse); if (PaperLess_Emeeting.Properties.Settings.Default.UserMeeting_Reverse == true) { dict = userMeetingAry .OrderBy(item => DateTool.StringToDate(item.BeginTime)) .GroupBy(item => DateTool.StringToDate(item.BeginTime).Date) .Reverse() // 倒著排序,最新的在最上面 .ToDictionary(IGrouping => IGrouping.Key, IGrouping => IGrouping.ToList()); } else { dict = userMeetingAry .OrderBy(item => DateTool.StringToDate(item.BeginTime)) .GroupBy(item => DateTool.StringToDate(item.BeginTime).Date) //.Reverse() // 倒著排序,最新的在最上面 .ToDictionary(IGrouping => IGrouping.Key, IGrouping => IGrouping.ToList()); } //改成用DispatcherPriority,因為如果快速換月份 //一直跑UI,馬上又丟棄太浪費資源 //改成有空閒再跑會議日期就好 //不過後來想一想,會議日期先跑出來 //會有馬上就撈到資料的感覺,停頓感比較小,所以再改回去。 //this.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(() => this.Dispatcher.BeginInvoke(new Action(() => { try { MeetingDaySP.Children.Clear(); ////添加一些空白會議 //dict.Add(new DateTime(2001 ,1 ,1), new List<UserMeeting>()); //dict.Add(new DateTime(2002 ,1 ,1), new List<UserMeeting>()); //dict.Add(new DateTime(2003, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2004, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2005, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2006, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2007, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2008, 1, 1), new List<UserMeeting>()); //dict.Add(new DateTime(2009, 1, 1), new List<UserMeeting>()); if (PaperLess_Emeeting.Properties.Settings.Default.UserMeeting_Reverse == false) { foreach (KeyValuePair <DateTime, List <UserMeeting> > item in dict) { MeetingDayList meetingDayList = new MeetingDayList(UserID, UserPWD, item.Key, item.Value as List <UserMeeting>, this.Home_Change2MeetingDataCT_Event, new MeetingList_Show_HiddenMeetingDayList_Function(Show_HiddenMeetingDayList), NewAddMeetingID); MeetingDaySP.Children.Add(meetingDayList); } } else { bool HasToday = dict.Any(x => x.Key.Day == DateTime.Now.Day); int NearByTodayIndex = 0; if (MeetingListDate.Month == DateTime.Now.Month) { if (HasToday == true) { NearByTodayIndex = dict.ToList().FindIndex(x => x.Key.Day == DateTime.Now.Day); } else { //if (NearByTodayIndex > 0) // NearByTodayIndex--; Dictionary <DateTime, List <UserMeeting> > tempDict = new Dictionary <DateTime, List <UserMeeting> >(dict); tempDict.Add(DateTime.Now, new List <UserMeeting>()); NearByTodayIndex = tempDict.OrderBy((x) => x.Key.Day).ToList().FindIndex(x => x.Key.Day == DateTime.Now.Day); //if (NearByTodayIndex == dict.Count - 1) //{ // NearByTodayIndex--; //} } } MeetingDayList MeetingDayList_ToScroll = null; int i = 0; //Button btnShowMeetingRooms = null; foreach (KeyValuePair <DateTime, List <UserMeeting> > item in dict) { MeetingDayList meetingDayList = new MeetingDayList(UserID, UserPWD, item.Key, item.Value as List <UserMeeting>, this.Home_Change2MeetingDataCT_Event, new MeetingList_Show_HiddenMeetingDayList_Function(Show_HiddenMeetingDayList), NewAddMeetingID); MeetingDaySP.Children.Add(meetingDayList); if (i == NearByTodayIndex || NearByTodayIndex == dict.Count - 1 || int.Parse(meetingDayList.date.ToString("yyyyMMdd")) <= int.Parse(DateTime.Now.ToString("yyyyMMdd"))) { MeetingDayList_ToScroll = meetingDayList; } else if (MeetingDayList_ToScroll == null) { meetingDayList.Visibility = Visibility.Collapsed; if (btnShowMeetingRooms == null) { btnShowMeetingRooms = new Button() { Content = "^", Height = 0, //現在已經隱藏起來了,需要的話把高度調高 BorderThickness = new Thickness(0), Background = new SolidColorBrush(Colors.Yellow) }; btnShowMeetingRooms.Margin = new Thickness(12, 0, 12, 0); btnShowMeetingRooms.Click += (sender, e) => { //AutoClosingMessageBox.Show("xxx"); btnShowMeetingRooms.Visibility = Visibility.Collapsed; Show_HiddenMeetingDayList(); }; btnShowMeetingRooms.MouseEnter += (sender, e) => { btnShowMeetingRooms.Visibility = Visibility.Collapsed; Show_HiddenMeetingDayList(); }; MeetingDaySP.Children.Add(btnShowMeetingRooms); } } i++; } //double height = System.Windows.SystemParameters.PrimaryScreenHeight; Rectangle rect = new Rectangle(); rect.Height = 1080; //rect.Height = height - MeetingDaySP.Children.Count * 125; rect.Margin = new Thickness(12, 0, 12, 0); rect.Fill = new SolidColorBrush(Colors.Transparent); MeetingDaySP.Children.Add(rect); } } catch (Exception ex) { LogTool.Debug(ex); } })); }); }
private void CheckLogin(User user) { try { if (user != null) { switch (user.State) { case "0": string HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList); string UTC = user.UTC == null?DateTool.GetCurrentTimeInUnixMillis().ToString() : user.UTC.ToString(); long deltaUTC = 0; try { deltaUTC = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(UTC); } catch (Exception ex) { LogTool.Debug(ex); } string SQL = @"Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8"; int success = MSCE.ExecuteNonQuery(SQL , user.ID , user.Name , tbUserPWD.Password.Trim() , HomeUserButtonAryJSON , user.Email , UTC , deltaUTC.ToString() , cbRemeberLogin.IsChecked == true ?"true":"false"); if (success < 1) { LogTool.Debug(new Exception(@"DB失敗: " + SQL)); return; } try { //DB操作更新 DataTable dt = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1" , user.ID); if (dt.Rows.Count > 0) { MSCE.ExecuteNonQuery(@"UPDATE [LoginInfo] SET [UserID] = @1 ,[UserPWD] = @2 ,UserJson = @3 where UserID=@4" , user.ID , tbUserPWD.Password.Trim() , JsonConvert.SerializeObject(user) , user.ID); } else { MSCE.ExecuteNonQuery(@"INSERT INTO [LoginInfo] ([UserID],[UserPWD],UserJson) VALUES (@1,@2,@3)" , user.ID , tbUserPWD.Password.Trim() , JsonConvert.SerializeObject(user)); } dt = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2" , user.ID , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")); if (dt.Rows.Count > 0) { MSCE.ExecuteNonQuery(@"UPDATE [UserData] SET [ListDate] = @1 ,[UserJson] = @2 where UserID = @3 and ListDate =@4" , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd") , JsonConvert.SerializeObject(user) , user.ID , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")); } else { MSCE.ExecuteNonQuery(@"INSERT INTO [UserData] ([UserID],[ListDate],UserJson) VALUES (@1,@2,@3)" , user.ID , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd") , JsonConvert.SerializeObject(user)); } } catch (Exception ex) { LogTool.Debug(ex); } this.Hide(); Home f2 = new Home(user, tbUserPWD.Password.Trim()); f2.Show(); App.IsChangeWindow = true; this.Close(); break; case "1": AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入"); break; case "2": AutoClosingMessageBox.Show("帳號密碼錯誤或帳號已被鎖定"); break; } } } catch (Exception ex) { LogTool.Debug(ex); } canLogin = true; MouseTool.ShowArrow(); }
private void CallLigon() { Action <HttpWebResponse> action = null; canLogin = false; MouseTool.ShowLoading(); try { string text = tbUserID.Text.Trim(); string text2 = tbUserPWD.Password.Trim(); string text3 = DateTool.MonthFirstDate(DateTime.Today).ToString("yyyyMMdd"); string text4 = DateTool.MonthFirstDate(DateTime.Today.AddMonths(1)).ToString("yyyyMMdd"); if (NetworkTool.CheckNetwork() > 0) { string url = WsTool.GetUrl(); string format = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><UserPW><![CDATA[{1}]]></UserPW><UserDevice>1</UserDevice><UserDateBegin>{2}</UserDateBegin><UserDateEnd>{3}</UserDateEnd></UserInfo>"; format = string.Format(format, text, text2, text3, text4); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["XmlDoc"] = format; HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/UserData", "POST", dictionary); if (action == null) { action = new Action <HttpWebResponse>(_003CCallLigon_003Eb__10); } DoWithResponse(httpWebRequest, action); } else { DataTable dataTable = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", text); if (dataTable.Rows.Count > 0) { dataTable = MSCE.GetDataTable("select UserJson from LoginInfo where UserID =@1 and UserPWD=@2", text, text2); if (dataTable.Rows.Count > 0) { User user = JsonConvert.DeserializeObject <User>(dataTable.Rows[0]["UserJson"].ToString()); string text5 = JsonConvert.SerializeObject(user.EnableButtonList); string s = user.UTC.ToString(); long num = 0L; try { num = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(s); } catch (Exception ex) { LogTool.Debug(ex); } string text6 = "Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8"; string[] array = new string[8] { user.ID, user.Name, tbUserPWD.Password.Trim(), text5, user.Email, DateTool.GetCurrentTimeInUnixMillis().ToString(), num.ToString(), null }; bool?isChecked = cbRemeberLogin.IsChecked; array[7] = ((isChecked.GetValueOrDefault() && isChecked.HasValue) ? "true" : "false"); int num2 = MSCE.ExecuteNonQuery(text6, array); if (num2 < 1) { LogTool.Debug(new Exception("DB失敗: " + text6)); } else { base.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user); } } else { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("您的密碼錯誤"); canLogin = true; } } else { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入"); canLogin = true; } } } catch (Exception) { MouseTool.ShowArrow(); AutoClosingMessageBox.Show("登入失敗"); canLogin = true; } }
public void Refresh() { int year = DateTime.Now.Year; int month = DateTime.Now.Month; if (CBYear.SelectedValue != null && CBMonth.SelectedValue != null) { year = (int)CBYear.SelectedValue; month = (int)CBMonth.SelectedValue; } if (LoadTask == null || LoadTask.IsCompleted) LoadTask = Task.Factory.StartNew(() => { var datas = WakaAnalyzer.Month.Report(year, month); if (ListTool.HasElements(datas)) { var first = datas.FirstOrDefault(); if (first != null && ListTool.HasElements(first.Item2)) { List<DateTime> dt = first.Item2.OrderBy(x => x.Item1).Select(x => x.Item1).ToList(); List<string> lb = new List<string>(); dt.ForEach(x => { lb.Add(x.ToString("dd日")); }); var career = WakaAnalyzer.Month.Career(year, month); var careerFmt = DateTimeTool.ToHMS(career); var avgFmt = DateTimeTool.ToHMS(career / DateTool.MonthDays(year, month)); App.Current.Dispatcher.Invoke((Action)(() => { Labels = lb.ToArray(); TimeDesc = $"{year} 年 {month} 月,共计:{careerFmt.Item1} 时 {careerFmt.Item2} 分,日均:{avgFmt.Item1} 时 {avgFmt.Item2} 分"; })); } App.Current.Dispatcher.Invoke(() => { Formatter = value => { if (value > 0) { StringBuilder sb = new StringBuilder(); var time = DateTimeTool.ToHMS(value); if (time.Item1 > 0) sb.Append($"{time.Item1} 小时"); if (time.Item2 > 0) sb.Append($" {time.Item2} 分钟"); return sb.ToString(); } return null; }; }); SeriesCollection = new SeriesCollection(); datas.ForEach(x => { string title = x.Item1; double[] values = x.Item2.OrderBy(y => y.Item1).Select(y => y.Item2).ToArray(); App.Current.Dispatcher.Invoke((Action)(() => { SeriesCollection.Add( new StackedColumnSeries { Title = title, Values = new ChartValues<double>(values), StackMode = StackMode.Values }); })); }); } }); }
private void button5_Click(object sender, EventArgs e)//测试创建pid { //解析cookie中用于参数的字段 CookieContainer cookieCollectionByString = MyCookie.GetCookieCollectionByString(DT.Cookie, "pub.alimama.com"); StringBuilder header = new StringBuilder(); header.Append("User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36\r\n"); header.Append("Content-Type:application/x-www-form-urlencoded; charset=UTF-8\r\n"); header.Append("Accept:application/json, text/javascript, */*; q=0.01\r\n"); header.Append("Accept-Encoding:gzip, deflate\r\n"); header.Append("Accept-Language:zh-CN,zh;q=0.8\r\n"); header.Append("Host: pub.alimama.com\r\n"); header.Append("Origin:http://pub.alimama.com\r\n"); header.Append("X-Requested-With:XMLHttpRequest\r\n"); header.Append("Cookie:" + DT.Cookie); Wininet wininet = new Wininet(); StringBuilder postData = new StringBuilder("tag=29&gcid=0&siteid=40968507&selectact=add&newadzonename=test&t=" + DateTool.GetCurrentTimeStamp() + "&_tb_token_=" + MyCookie.GetCookie("_tb_token_", cookieCollectionByString)); Console.WriteLine("当前post数据:" + postData.ToString()); String responseBody = wininet.PostData("http://pub.alimama.com/common/adzone/selfAdzoneCreate.json", postData.ToString(), header); Console.WriteLine("响应内容:" + responseBody); }
//复制机器码按钮 private void button2_Click(object sender, EventArgs e) { // Clipboard.SetDataObject(this.textBox1.Text); Clipboard.SetText(this.textBox1.Text); this.label3.Text = "复制成功,操作时间:" + DateTool.getCurrentTimeStr(); }