Esempio n. 1
0
        }                                               // 参照时间点

        /// <summary>
        /// 找到最近的参照时间点
        /// </summary>
        protected void GetReferenceTime()
        {
            // 找到参照时间点(在最小间隔外,推算时间点)
            DateTime time = BeginDate.CompareTo(DateTime.Now) > 0 ? BeginDate : DateTime.Now;

            referenceTime = time.AddSeconds(MinInterval);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            int hashcode = BeginDate.GetHashCode();

            hashcode = 31 * hashcode + CompanyId.GetHashCode();
            return(hashcode);
        }
Esempio n. 3
0
 protected void AutomaticLoadingData()
 {
     if (IsAutomatic)
     {
         foreach (UploadDataOption option in UploadDataOptions)
         {
             lock (LockObject)
             {
                 option.Id             = Id;
                 option.OperatingRange = BeginDate.ToString("yyyy-MM-dd");
                 _dataService.GetData(option, (itemes, error) =>
                 {
                     if (error != null)
                     {
                         return;
                     }
                     foreach (var item in itemes)
                     {
                         UploadEnities.Add(item);
                     }
                 });
                 Id = Id + 1;
             }
         }
     }
 }
 public override string ToString()
 {
     if (EndDate == default)
     {
         return(Name + ": " + BeginDate.ToShortDateString());
     }
     else
     {
         return(Name + ": " + BeginDate.ToShortDateString() + "until " + EndDate.ToShortDateString());
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 输出日期间隔
 /// </summary>
 /// <param name="inputString">输出格式化字符串</param>
 /// <param name="dateString">日期格式化字符串</param>
 /// <returns>日期间隔</returns>
 public string GetDateString(string inputString, string dateString)
 {
     if (string.IsNullOrEmpty(inputString) || string.IsNullOrEmpty(dateString))
     {
         return(null);
     }
     try {
         return(string.Format(inputString, BeginDate.ToString(dateString), EndDate.ToString(dateString)));
     }
     catch (Exception ex) {
         return(ex.Message);
     }
 }
        public new void AsCsvRow(CsvWriter writer, bool bulk = true)
        {
            base.AsCsvRow(writer, bulk);
            writer.WriteField(IMSClassId);
            writer.WriteField(SchoolOrgId);
            writer.WriteField(UserId);
            writer.WriteField(Role);
            writer.WriteField(Primary == null ? Primary.ToString() : "");
            writer.WriteField(BeginDate.ToString("yyyy-MM-dd"));
            writer.WriteField(EndDate.ToString("yyyy-MM-dd"));

            writer.NextRecord();
        }
Esempio n. 7
0
        public void AddNewTaskComman()
        {
            CurrentNum = CurrentNum + 1;
            DataCell dataCell = new DataCell()
            {
                Id = this.CurrentNum, Name = "用户基本资料", Total = new Random().Next(1000, 10000), UploadedTotal = 0, BusinessDate = BeginDate.ToString("yyyy-MM-dd"), Complated = false
            };

            BeginDate = BeginDate.AddDays(1);
            lock (lockobject)
            {
                this.DataCells.Add(dataCell);
            }
        }
Esempio n. 8
0
        public void OpenExcel()
        {
            DownloadEnabled = false;
            DownloadContent = "Loading...";

            var foodDictionary = new Dictionary <Food, List <float> >();

            var builder   = new FilterDefinitionBuilder <BsonDocument>();
            var filter    = builder.Gte("_submission_time", BeginDate.ToString("o")) & builder.Lte("_submission_time", EndDate.ToString("o"));
            var jsonQuery = filter.RenderToBsonDocument().ToJson();

            FormData data = api.GetData(SelectedForm.Formid, jsonQuery);

            if (data.Lines.Count() == 0)
            {
                MessageBox.Show("No data available");

                DownloadEnabled = true;
                DownloadContent = "Download Nutval";

                return;
            }

            foreach (FormLine line in data.Lines)
            {
                if (!foodDictionary.ContainsKey(line.Food))
                {
                    foodDictionary.Add(line.Food, new List <float>());
                    foodDictionary[line.Food].Add(0);
                }

                foodDictionary[line.Food][0] += line.PeopleNbr;
                foodDictionary[line.Food].Add(line.Amount);
            }

            List <FoodAmount> foodList = new List <FoodAmount>();

            foreach (KeyValuePair <Food, List <float> > line in foodDictionary)
            {
                foodList.Add(new FoodAmount(line.Key, (line.Value.Sum() - line.Value.First()) / line.Value.First()));
            }

            Excel excel = new Excel("NutVal.xlsm");

            excel.WriteData(foodList, SelectedForm.Title);
            excel.ReleaseObjects();

            DownloadEnabled = true;
            DownloadContent = "Download Nutval";
        }
Esempio n. 9
0
 public void Filter()
 {
     try
     {
         _selectRoad = new DataRoad {
             SelectbeginDate = BeginDate.ToString(), SelectendDate = EndDate.ToString()
         };
         var startstop = new ReadStartStop(_selectRoad.SelectbeginDate, _selectRoad.SelectendDate);
         _startStops = startstop.GetMassurm3();
         Get();
     }
     catch (Exception)
     {
         MessageBox.Show(@"Выберите дату", @"Ошибка выбора даты", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
Esempio n. 10
0
        public new void AsJson(JsonWriter writer, string baseUrl)
        {
            writer.WriteStartObject();
            base.AsJson(writer, baseUrl);

            if (User != null)
            {
                writer.WritePropertyName("user");
                User.AsJsonReference(writer, baseUrl);
            }

            if (IMSClass != null)
            {
                writer.WritePropertyName("class");
                IMSClass.AsJsonReference(writer, baseUrl);
            }

            if (School != null)
            {
                writer.WritePropertyName("school");
                School.AsJsonReference(writer, baseUrl);
            }

            writer.WritePropertyName("role");
            writer.WriteValue(Enum.GetName(typeof(RoleType), Role));

            if (Primary != null)
            {
                writer.WritePropertyName("primary");
                writer.WriteValue(Primary.ToString());
            }

            if (BeginDate != null)
            {
                writer.WritePropertyName("beginDate");
                writer.WriteValue(BeginDate.ToString("yyyy-MM-dd"));
            }

            if (EndDate != null)
            {
                writer.WritePropertyName("endDate");
                writer.WriteValue(EndDate.ToString("yyyy-MM-dd"));
            }

            writer.WriteEndObject();
            writer.Flush();
        }
Esempio n. 11
0
        /// <summary>
        /// Updates module settings.
        /// </summary>
        public void Update()
        {
            var controller = new ModuleController();
            {
                controller.UpdateModuleSetting(_moduleId, "PortalId", PortalId.ToString());

                string showPaging = ShowPaging.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "ShowPaging", showPaging);
                }

                if (!String.IsNullOrEmpty(TemplateDirectory))
                {
                    controller.UpdateModuleSetting(_moduleId, "TemplateDirectory", TemplateDirectory.ToString());
                }

                string pageSize = PageSize.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "PageSize", pageSize);
                }

                string showDateFilter = ShowDateFilter.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "ShowDateFilter", showDateFilter);
                }

                string learnerModuleId = LearnerModuleId.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "LearnerModuleId", learnerModuleId);
                }

                string beginDate = BeginDate.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "BeginDate", beginDate);
                }

                string endDate = EndDate.ToString();
                {
                    controller.UpdateModuleSetting(_moduleId, "EndDate", endDate);
                }

                string dateRange = DateRange;
                {
                    controller.UpdateModuleSetting(_moduleId, "DateRange", dateRange);
                }
            }
        }
Esempio n. 12
0
        public override string ToString()
        {
            string str = "";

            str += "&idserver=\"" + IDServer.ToString() + "\"";

            if (IDUser != -1)
            {
                str += "&iduser=\"" + IDUser.ToString() + "\"";
            }
            if (BeginDate != null)
            {
                str += "&begindate=\"" + BeginDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }
            if (EndDate != null)
            {
                str += "&enddate=\"" + EndDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }
            if (Price != 0)
            {
                str += "&price=\"" + Price.ToString() + "\"";
            }
            if (IsActive != 0)
            {
                str += "&isactive=\"" + IsActive.ToString() + "\"";
            }
            if (Trncode != null && !Trncode.Equals(""))
            {
                str += "&trncode=\"" + Trncode + "\"";
            }
            if (Deleted != 0)
            {
                str += "&deleted=\"" + Deleted.ToString() + "\"";
            }
            if (InsertDate != null)
            {
                str += "&insertdate=\"" + InsertDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }
            if (UpdateDate != null)
            {
                str += "&updatedate=\"" + UpdateDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }

            return(str.Substring(1));
        }
        public override object Execute()
        {
            using (var db = new Db())
            {
                EndDate   = EndDate.AddDays(1);
                BeginDate = BeginDate.AddDays(-1);
                //处理排序
                var query = db.AfterSaleRecords.Where(o => o.ServiceDate >= BeginDate && o.ServiceDate <= EndDate); //过滤一下

                Pager.RecordCount = query.Count();                                                                  //处理总录条数

                query = query.OrderByDescending(d => d.CreateTime);
                var records = query
                              .Skip((Pager.Index - 1) * Pager.Size)
                              .Take(Pager.Size)
                              .ToArray();
                return(records);
            }
        }
Esempio n. 14
0
        public override string toFullString()
        {
            StringBuilder _sb = new StringBuilder();

            _sb.Append(BeginDate.ToShortDateString());
            _sb.Append(" begin - ");
            _sb.Append(EndDate.ToShortDateString());
            _sb.Append(" end; ");
            _sb.Append(Code);
            _sb.Append(Environment.NewLine);
            _sb.Append(_customer.ID);
            _sb.Append(Environment.NewLine);
            foreach (Product _product in ProductsToMove)
            {
                _sb.Append(_product.toFullString());
                _sb.Append(Environment.NewLine);
            }

            return(_sb.ToString());
        }
Esempio n. 15
0
 public void SetEndDate(DateTime date)
 {
     if (numberOfCrops == 0)
     {
         if (date != endDate)
         {
             if (NotSavedEvent != null)
             {
                 NotSavedEvent();
             }
         }
         if (BeginDate.AddMonths(3) < date)
         {
             date = date.AddMonths(3);
         }
         endDate    = date;
         totalWeeks = GetNumberOfWeeks();
         dateChanged();
     }
 }
Esempio n. 16
0
        private void buttonAddOrder_Click(object sender, EventArgs e)
        {
            //string drivID, string route, string from, string to, string dep, string arr, string cap, string vol
            if (ProperValues())
            {
                string drID   = Driver.DriverID.ToString();
                string route  = textBoxRouteLength.Text;
                string from   = textBoxRouteFrom.Text;
                string to     = textBoxRouteTo.Text;
                string format = "yyyy-MM-dd HH:mm:ss";
                string dep    = EndDate.ToString(format);
                string arr    = BeginDate.ToString(format);
                string cap    = labelFreeCValue.Text;
                string vol    = labelFreeVValue.Text;
                if (CreateOrder(drID, route, from, to, dep, arr, cap, vol, addedProducts))
                {
                    dateTimePickerBegin.Value    = DateTime.Now;
                    dateTimePickerEnd.Value      = DateTime.Now;
                    labelDriverIDValue.Text      = "0";
                    labelDriverNameValue.Text    = "";
                    labelDriverSurnameValue.Text = "";
                    labelCapacityValue.Text      = "-";
                    labelVolumeValue.Text        = "-";
                    textBoxRouteFrom.Clear();
                    textBoxRouteTo.Clear();
                    textBoxRouteLength.Clear();
                    comboBoxDrivers.Items.Clear();
                    comboBoxProducts.Items.Clear();
                    labelFreeCValue.Text = "-";
                    labelFreeVValue.Text = "-";
                    listBoxProducts.Items.Clear();


                    MessageBox.Show("Dodano rekord!");
                }
            }
        }
Esempio n. 17
0
 public override string ToString()
 {
     return(Name + " " + BeginDate.ToString("yyyy-MM-dd") + " " + EndDate.ToString("yyyy-MM-dd"));
 }
 public override string ToString()
 {
     return(BeginDate.ToString() + " - " + EndDate.ToString());
 }
Esempio n. 19
0
        /// <summary>
        /// 创建访客记录
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>

        private string CreateVisitor(DataRow row)
        {
            try
            {
                #region 获取参数并简单校验
                string Mobile = string.Empty;
                if (row.Table.Columns.Contains("Mobile"))
                {
                    Mobile = row["Mobile"].ToString();
                }
                if (string.IsNullOrEmpty(Mobile))
                {
                    return(new WxResponse(0, "用户不存在", null).toJson());
                }
                if (Mobile.Length != 11)
                {
                    return(new WxResponse(0, "用户不存在", null).toJson());
                }
                if (!row.Table.Columns.Contains("UserID") || !int.TryParse(row["UserID"].ToString(), out int UserID))
                {
                    return(new WxResponse(0, "用户不存在", null).toJson());
                }
                string MemberName = string.Empty;
                if (row.Table.Columns.Contains("MemberName"))
                {
                    MemberName = row["MemberName"].ToString();
                }
                if (string.IsNullOrEmpty(MemberName))
                {
                    return(new WxResponse(0, "访客姓名不能为空", null).toJson());
                }
                string MemberMobile = string.Empty;
                if (row.Table.Columns.Contains("MemberMobile"))
                {
                    MemberMobile = row["MemberMobile"].ToString();
                }
                if (string.IsNullOrEmpty(MemberMobile))
                {
                    return(new WxResponse(0, "访客电话不能为空", null).toJson());
                }
                if (MemberMobile.Length != 11)
                {
                    return(new WxResponse(0, "访客电话不正确", null).toJson());
                }
                if (!row.Table.Columns.Contains("MemberType") || !int.TryParse(row["MemberType"].ToString(), out int MemberType))
                {
                    return(new WxResponse(0, "请选择访客类型", null).toJson());
                }
                if (MemberType != 0 && MemberType != 1 && MemberType != 2)
                {
                    return(new WxResponse(0, "访客类型不正确", null).toJson());
                }
                if (!row.Table.Columns.Contains("BeginDate") || !DateTime.TryParse(row["BeginDate"].ToString(), out DateTime BeginDate))
                {
                    return(new WxResponse(0, "请选择来访时间", null).toJson());
                }
                if (!row.Table.Columns.Contains("EndDate") || !DateTime.TryParse(row["EndDate"].ToString(), out DateTime EndDate))
                {
                    return(new WxResponse(0, "请选择来访时间", null).toJson());
                }
                DateTime DateNow = DateTime.Now;
                if (DateNow.CompareTo(BeginDate) > 0)
                {
                    return(new WxResponse(0, "请重新选择正确的来访时间", null).toJson());
                }
                if (BeginDate.CompareTo(EndDate) > 0)
                {
                    return(new WxResponse(0, "请重新选择正确的来访时间", null).toJson());
                }
                string CommID = string.Empty;
                if (row.Table.Columns.Contains("CommID"))
                {
                    CommID = row["CommID"].ToString();
                }
                if (string.IsNullOrEmpty(CommID))
                {
                    return(new WxResponse(0, "请选择默认房屋(1001)", null).toJson());
                }
                string RoomID = string.Empty;
                if (row.Table.Columns.Contains("RoomID"))
                {
                    RoomID = row["RoomID"].ToString();
                }
                if (string.IsNullOrEmpty(RoomID))
                {
                    return(new WxResponse(0, "请选择默认房屋(1002)", null).toJson());
                }
                #endregion

                using (IDbConnection erpConn = new SqlConnection(erpConnStr))
                {
                    erpConn.Open();
                    var trans = erpConn.BeginTransaction();
                    try
                    {
                        dynamic RoomInfo = erpConn.QueryFirstOrDefault("SELECT CommName, RoomSign, RoomName FROM view_HSPR_Room_Filter WITH(NOLOCK) WHERE ISNULL(IsDelete, 0) = 0 AND CommID = @CommID AND RoomID = @RoomID", new { CommID, RoomID }, trans);
                        if (null == RoomInfo)
                        {
                            return(new WxResponse(0, "请选择默认房屋(1003)", null).toJson());
                        }
                        string CommName = Convert.ToString(RoomInfo.CommName);
                        string RoomSign = Convert.ToString(RoomInfo.RoomSign);
                        string RoomName = Convert.ToString(RoomInfo.RoomName);
                        string RecordID = Guid.NewGuid().ToString();
                        // 只负责保存到数据库以及发送短信,剩下的群组创建由同步程序执行
                        if (erpConn.Execute("INSERT INTO Tb_HSPR_Entrance_Group_Visitor_Record(CommID, RoomID, MemberName, MemberMobile, MemberType, BeginDate, EndDate, RecordID) VALUES(@CommID, @RoomID, @MemberName, @MemberMobile, @MemberType, @BeginDate, @EndDate, @RecordID)", new { CommID, RoomID, MemberName, MemberMobile, MemberType, BeginDate, EndDate, RecordID }, trans) <= 0)
                        {
                            trans.Rollback();
                            return(new WxResponse(0, "保存失败,请重试", null).toJson());
                        }
                        string Content = $"(访客预约)尊敬的{MemberName},{CommName}-{RoomSign}欢迎您于{BeginDate:MM月dd日HH时mm分}来访,点击http://wx.hoppowy.com/moredian/invite/{RecordID}上传人脸";
                        int    result  = SendShortMessage(MemberMobile, Content, out string errMsg, Convert.ToInt32(CorpID));
                        if (result != 0)
                        {
                            trans.Rollback();
                            GetLog().Warn($"短信发送失败(Mobile={MemberMobile},Content={Content},msg={errMsg})");
                            return(new WxResponse(0, "操作失败,请重试", null).toJson());
                        }
                        GetLog().Warn($"短信发送成功(Mobile={MemberMobile},Content={Content})");
                        trans.Commit();
                        return(new WxResponse(200, "操作成功", null).toJson());
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        GetLog().Error(ex.Message + Environment.CommandLine + ex.StackTrace);
                        return(new WxResponse(0, "操作失败,请重试", null).toJson());
                    }
                }
            }
            catch (Exception ex)
            {
                GetLog().Error(ex.Message + Environment.CommandLine + ex.StackTrace);
                return(new WxResponse(0, "响应异常", null).toJson());
            }
        }
Esempio n. 20
0
 /// <summary>
 /// 输出第几周和日期间隔
 /// <para>默认格式:</para>
 /// <para>第几周,从2012年12月21日至2112年12月21日。</para>
 /// </summary>
 /// <returns>第几周和日期间隔</returns>
 public override string ToString()
 {
     return(string.Format("第{0}周,从{1}至{2}。", Number, BeginDate.ToString("yyyy年MM月dd日"), EndDate.ToString("yyyy年MM月dd日")));
 }
Esempio n. 21
0
        //Haalt de data (verlofaanvraag) op uit de View, geeft het door aan de controller
        public VacationRequest ToVacationRequest(VacationRequest vacreq = null)
        {
            if (vacreq == null)
            {
                vacreq                 = new VacationRequest();
                vacreq.UserID          = SecurityHelper.GetUserId();
                vacreq.ReasonRejection = "";
                vacreq.DateSubmission  = DateTime.Now;
                vacreq.IsRejected      = false;
                vacreq.IsApproved      = false;
                vacreq.IsInTreatment   = true;
                vacreq.IsActive        = true;
                vacreq.DateCreated     = DateTime.Now;
                vacreq.DateChanged     = DateTime.Now;
                vacreq.CreateUser      = SecurityHelper.GetUserId();
                vacreq.ChangeUser      = SecurityHelper.GetUserId();
                vacreq.IsTotalDays     = CompleteDays;
            }

            //Wanneer de checkbox "hele dagen" is aangevinkt, wordt er uitgegaan van 8 uur verlof per opgegeven dag. De begintijd en eindtijd wordt vastgezet
            if (CompleteDays == true)
            {
                TimeSpan BeginTime = new TimeSpan(9, 00, 0);

                vacreq.BeginDate = BeginDate.Add(BeginTime);


                TimeSpan EndTime = new TimeSpan(17, 00, 0);

                vacreq.EndDate    = EndDate.Add(EndTime);
                vacreq.BeginOfDay = BeginDate;
                vacreq.EndOfDay   = EndDate;
            }

            //De tijd wordt toegevoegd aan de datetime die zal worden opgeslagen
            else
            {
                BeginDate        = BeginDate.Add(BeginTime);
                vacreq.BeginDate = BeginDate;

                EndDate        = EndDate.Add(EndTime);
                vacreq.EndDate = EndDate;

                vacreq.BeginOfDay = BeginDate.Date.Add(UserBeginTime);
                vacreq.EndOfDay   = EndDate.Date.Add(UserEndTime);
            }

            //Verschil in dagen wordt berekend
            TimeSpan DifferenceDayInHours = UserEndTime - UserBeginTime;

            if (DifferenceDayInHours.TotalMinutes > 480)
            {
                int minutesoverload = (DifferenceDayInHours.Minutes % 480) * -1;
                UserEndTime = UserEndTime.Add(new TimeSpan(0, minutesoverload, 0));
            }
            TimeSpan differencehours = EndTime - BeginTime;

            if (differencehours.TotalMinutes > 480)
            {
                int minutesoverload = (differencehours.Minutes % 480) * -1;
                EndTime = EndTime.Add(new TimeSpan(0, minutesoverload, 0));
            }
            TimeSpan DifferenceInDays = EndDate - BeginDate;
            int      TotalDays        = DifferenceInDays.Days;

            if (DifferenceInDays.Hours == 8)
            {
                TotalDays = TotalDays + 1;
            }

            if (CompleteDays == true)
            {
                TotalDays = TotalDays + 1;
            }

            //Het totaal aantal minuten in de verlofaanvraag worden berekend (als checkbox "hele dagen" is aangevinkt).
            if (CompleteDays == true)
            {
                int      CountHours = 0;
                DateTime t          = BeginDate;
                for (int i = 1; i <= TotalDays; i++)
                {
                    if (t.DayOfWeek == DayOfWeek.Monday || t.DayOfWeek == DayOfWeek.Tuesday || t.DayOfWeek == DayOfWeek.Wednesday || t.DayOfWeek == DayOfWeek.Thursday || t.DayOfWeek == DayOfWeek.Friday)
                    {
                        CountHours = CountHours + 8;
                    }

                    if (t.DayOfWeek == DayOfWeek.Saturday || t.DayOfWeek == DayOfWeek.Sunday)
                    {
                        CountHours = CountHours + 0;
                    }
                    t = t.AddDays(1);
                }
                int TotalMinutes = CountHours * 60;
                vacreq.TotalMinutes = TotalMinutes;
            }

            if (CompleteDays == false)
            {
                DifferenceInDays = EndDate.Date - BeginDate.Date;


                if (DifferenceInDays.Days < 1)
                {
                    int DifferenceHours   = 0;
                    int DifferenceMinutes = 0;

                    if (BeginTime < EndTime)
                    {
                        DifferenceHours = EndTime.Hours - BeginTime.Hours;

                        if (EndTime.Minutes == BeginTime.Minutes)
                        {
                            DifferenceMinutes = 0;
                        }

                        if (BeginTime.Minutes < EndTime.Minutes)
                        {
                            DifferenceMinutes = EndTime.Minutes - BeginTime.Minutes;
                        }

                        if (BeginTime.Minutes > EndTime.Minutes)
                        {
                            if (EndTime.Minutes == 0)
                            {
                                DifferenceMinutes = 60 - BeginTime.Minutes;
                                DifferenceHours   = DifferenceHours - 1;
                            }

                            if (BeginTime.Minutes > EndTime.Minutes && EndTime.Minutes != 0)
                            {
                                DifferenceMinutes = 60 - (BeginTime.Minutes - EndTime.Minutes);
                                DifferenceHours   = DifferenceHours - 1;
                            }
                        }


                        vacreq.TotalMinutes = (DifferenceHours * 60) + DifferenceMinutes;
                    }

                    if (vacreq.TotalMinutes > 480)
                    {
                        vacreq.TotalMinutes = 480;
                    }
                }

                if (DifferenceInDays.Days >= 1 && DifferenceInDays.Days < 2)
                {
                    int DifferenceHours   = 0;
                    int DifferenceMinutes = 0;
                    int MinutesFirstDay   = 0;
                    int MinutesSecondDay  = 0;

                    DifferenceHours = (UserEndTime.Hours - BeginTime.Hours) + (EndTime.Hours - UserBeginTime.Hours);

                    if (UserEndTime.Minutes == BeginTime.Minutes)
                    {
                        MinutesFirstDay = 0;
                    }

                    if (UserEndTime.Minutes > BeginTime.Minutes)
                    {
                        MinutesFirstDay = (UserEndTime.Minutes - BeginTime.Minutes);
                    }

                    if (UserEndTime.Minutes < BeginTime.Minutes)
                    {
                        if (UserEndTime.Minutes == 0)
                        {
                            MinutesFirstDay = 60 - BeginTime.Minutes;
                            DifferenceHours = DifferenceHours - 1;
                        }

                        if (UserEndTime.Minutes != 0)
                        {
                            MinutesFirstDay = 60 - (BeginTime.Minutes - UserEndTime.Minutes);
                            DifferenceHours = DifferenceHours - 1;
                        }
                    }

                    if (EndTime.Minutes == UserBeginTime.Minutes)
                    {
                        MinutesSecondDay = 0;
                    }

                    if (EndTime.Minutes > UserBeginTime.Minutes)
                    {
                        MinutesSecondDay = (EndTime.Minutes - UserBeginTime.Minutes);
                    }

                    if (EndTime.Minutes < UserBeginTime.Minutes)
                    {
                        if (EndTime.Minutes == 0)
                        {
                            MinutesSecondDay = 60 - UserBeginTime.Minutes;
                            DifferenceHours  = DifferenceHours - 1;
                        }

                        if (EndTime.Minutes != 0)
                        {
                            MinutesSecondDay = 60 - (UserBeginTime.Minutes - EndTime.Minutes);
                            DifferenceHours  = DifferenceHours - 1;
                        }
                    }

                    DifferenceMinutes = MinutesFirstDay + MinutesSecondDay;
                    if (DifferenceMinutes > 59)
                    {
                        DifferenceHours   = DifferenceHours + 1;
                        DifferenceMinutes = DifferenceMinutes - 60;
                    }

                    vacreq.TotalMinutes = (DifferenceHours * 60) + DifferenceMinutes;
                }

                if (DifferenceInDays.Days >= 2)
                {
                    int      totaldaysbetween = 0;
                    DateTime startDate        = BeginDate;
                    for (int i = 1; i <= DifferenceInDays.Days; i++)
                    {
                        if (startDate.DayOfWeek == DayOfWeek.Monday || startDate.DayOfWeek == DayOfWeek.Tuesday || startDate.DayOfWeek == DayOfWeek.Wednesday || startDate.DayOfWeek == DayOfWeek.Thursday || startDate.DayOfWeek == DayOfWeek.Friday)
                        {
                            totaldaysbetween = totaldaysbetween + 1;
                        }

                        startDate = startDate.AddDays(1);
                    }

                    totaldaysbetween = totaldaysbetween - 1;


                    int DifferenceHours   = 0;
                    int DifferenceMinutes = 0;
                    int MinutesFirstDay   = 0;
                    int MinutesSecondDay  = 0;

                    DifferenceHours = (UserEndTime.Hours - BeginTime.Hours) + (EndTime.Hours - UserBeginTime.Hours);

                    if (UserEndTime.Minutes == BeginTime.Minutes)
                    {
                        MinutesFirstDay = 0;
                    }

                    if (UserEndTime.Minutes > BeginTime.Minutes)
                    {
                        MinutesFirstDay = (UserEndTime.Minutes - BeginTime.Minutes);
                    }

                    if (UserEndTime.Minutes < BeginTime.Minutes)
                    {
                        if (UserEndTime.Minutes == 0)
                        {
                            MinutesFirstDay = 60 - BeginTime.Minutes;
                            DifferenceHours = DifferenceHours - 1;
                        }

                        if (UserEndTime.Minutes != 0)
                        {
                            MinutesFirstDay = 60 - (BeginTime.Minutes - UserEndTime.Minutes);
                            DifferenceHours = DifferenceHours - 1;
                        }
                    }

                    if (EndTime.Minutes == UserBeginTime.Minutes)
                    {
                        MinutesSecondDay = 0;
                    }

                    if (EndTime.Minutes > UserBeginTime.Minutes)
                    {
                        MinutesSecondDay = (EndTime.Minutes - UserBeginTime.Minutes);
                    }

                    if (EndTime.Minutes < UserBeginTime.Minutes)
                    {
                        if (EndTime.Minutes == 0)
                        {
                            MinutesSecondDay = 60 - UserBeginTime.Minutes;
                            DifferenceHours  = DifferenceHours - 1;
                        }

                        if (EndTime.Minutes != 0)
                        {
                            MinutesSecondDay = 60 - (UserBeginTime.Minutes - EndTime.Minutes);
                            DifferenceHours  = DifferenceHours - 1;
                        }
                    }

                    DifferenceMinutes = MinutesFirstDay + MinutesSecondDay;
                    if (DifferenceMinutes > 59)
                    {
                        DifferenceHours   = DifferenceHours + 1;
                        DifferenceMinutes = DifferenceMinutes - 60;
                    }

                    var      totalhoursindays       = DifferenceHours;
                    TimeSpan DifferenceBeginEndTime = (new TimeSpan(vacreq.EndOfDay.Value.Hour, vacreq.EndOfDay.Value.Minute, 00)) - (new TimeSpan(vacreq.BeginOfDay.Value.Hour, vacreq.BeginOfDay.Value.Minute, 00));
                    if (DifferenceBeginEndTime.TotalMinutes > 480)
                    {
                        var minutesoverload = (DifferenceBeginEndTime.TotalMinutes % 480) * -1;
                        DifferenceBeginEndTime = DifferenceBeginEndTime.Add(new TimeSpan(0, Convert.ToInt32(minutesoverload), 0));
                    }

                    vacreq.TotalMinutes = (totalhoursindays * 60) + DifferenceMinutes + (Convert.ToInt32(DifferenceBeginEndTime.TotalMinutes) * totaldaysbetween);
                }
            }

            vacreq.Reason = Reason;
            if (vacreq.IsTotalDays == true)
            {
                vacreq.BeginDate = BeginDate.Add(new TimeSpan(08, 00, 00));
                vacreq.EndDate   = EndDate.Add(new TimeSpan(18, 00, 00));
            }
            vacreq.HasDeadlines   = HasDeadlines;
            vacreq.IsCommunicated = IsCommunicated;

            return(vacreq);
        }
Esempio n. 22
0
        //var model = new ValidationViewModel
        //modle
        public string this[string columnName]
        {
            get
            {
                string result = null;
                if (columnName == "FirstName")
                {
                    if (string.IsNullOrEmpty(FirstName))
                    {
                        result = "FirstName is a mandatory field!";
                    }
                }
                if (columnName == "LastName")
                {
                    if (string.IsNullOrEmpty(LastName))
                    {
                        result = "LastName is a mandatory field!";
                    }
                }

                if (columnName == "Email")
                {
                    if (string.IsNullOrEmpty(Email))
                    {
                        result = "Email a mandatory field!";
                    }
                    else if (!EmailValidation.IsValidEmailAddress(Email))
                    {
                        result = "The emails address is not valid!!";
                    }
                }

                if (columnName == "Phone")
                {
                    if (string.IsNullOrEmpty(Phone))
                    {
                        result = "Phone is a mandatory field!";
                    }
                }

                if (columnName == "Dob")
                {
                    DateTime hundredYearsPast = DateTime.Now.AddYears(-100);

                    if (Dob.Equals(null))
                    {
                        result = "Dob is a mandatory field!";
                    }

                    else if (Dob.CompareTo(DateTime.Now) > 0)
                    {
                        result = "Dob should be in the past!";
                    }
                    //else if(DateTime.Compare(hundredYearsPast, DateTime.Now.AddYears(-100))< 1)
                    else if (Dob < hundredYearsPast)
                    {
                        result = "Dob not should be in the 100+ years past";
                    }
                }

                if (columnName == "WorkDate")
                {
                    DateTime tenYearsPast = DateTime.Now.AddYears(-10);

                    if (WorkDate.Equals(null))
                    {
                        result = "WorkDate is a mandatory field!";
                    }

                    else if (WorkDate.CompareTo(DateTime.Now) >= 0)
                    {
                        result = "WorkDate should be in the past or Today!";
                    }
                    //else if(DateTime.Compare(hundredYearsPast, DateTime.Now.AddYears(-100))< 1)
                    else if (WorkDate < tenYearsPast)
                    {
                        result = "WorkDate should not be in 10+ year past";
                    }
                }

                if (columnName == "Hours")
                {
                    if (Hours <= 0 || Hours > 24)
                    {
                        result = "Hours must be between 0 and 24";
                    }
                }

                if (columnName == "BeginDate")
                {
                    DateTime tenYearsPast = DateTime.Now.AddYears(-10);

                    if (BeginDate.Equals(null))
                    {
                        result = "BeginDate is a mandatory field to Calculate TotalHours for the period!";
                    }

                    else if (BeginDate.CompareTo(DateTime.Now) >= 0)
                    {
                        result = "BeginDate should be in the past or Today!";
                    }
                    //else if(DateTime.Compare(hundredYearsPast, DateTime.Now.AddYears(-100))< 1)
                    else if (BeginDate < tenYearsPast)
                    {
                        result = "BeginDate should not be in 10+ year past";
                    }
                }

                if (columnName == "EndDate")
                {
                    DateTime tenYearsPast = DateTime.Now.AddYears(-10);

                    if (EndDate.Equals(null))
                    {
                        result = "EndDate is a mandatory field to Calculate TotalHours for the period!";
                    }

                    else if (EndDate.CompareTo(DateTime.Now) >= 0)
                    {
                        result = "EndDate should be in the past or Today!";
                    }
                    //else if(DateTime.Compare(hundredYearsPast, DateTime.Now.AddYears(-100))< 1)
                    else if (EndDate < tenYearsPast)
                    {
                        result = "EndDate should not be in 10+ year past";
                    }
                }

                return(result);
            }
        }
Esempio n. 23
0
 public PromotionQueryModel()
 {
     BeginDate           = DateTime.Now.Date;
     EndDate             = BeginDate.AddMonths(1);
     PromotionStatusType = -1;
 }
Esempio n. 24
0
        OpenFlashChart.OpenFlashChart BuildChart()
        {
            OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
            List <double> data1 = new List <double>();

            int maxDot = 0;

            for (double i = 0; i < Days; i++)
            {
                //data1.Add(rand.Next(30));
                DateTime startTime = BeginDate.AddDays(i);
                DateTime endTime   = startTime.AddDays(1);
                int      pv        = PageVisitorHelper.GetVisitorCountByTime(startTime, endTime);
                if (pv > maxDot)
                {
                    maxDot = pv;
                }
                data1.Add(pv);
            }

            OpenFlashChart.Area area = new Area();
            area.Values   = data1;
            area.HaloSize = 0;
            area.Width    = 4;
            //area.DotSize = 2;
            area.FontSize         = 12;
            area.DotStyleType.Tip = "#x_label#<br>访客数:#val#";
            //area.DotStyleType.Type = DotType.ANCHOR;
            area.DotStyleType.Type   = DotType.DOT;
            area.DotStyleType.Colour = "#0077CC";

            area.Tooltip   = "提示:#val#";
            area.Colour    = "#0077CC";
            area.FillColor = "#E6F2FA";
            area.FillAlpha = .5;
            Animation animation = new Animation();

            animation.Cascade    = 1;
            animation.Delay      = 0.5;
            animation.Type       = "pop-up";
            area.OnShowAnimation = animation;
            chart.AddElement(area);
            chart.Y_Legend                = new Legend("");
            chart.Title                   = new Title("");
            chart.Tooltip                 = new ToolTip("#x_label#<br>访客数:#val#");
            chart.Tooltip.MouseStyle      = ToolTipStyle.FOLLOW;
            chart.Tooltip.Shadow          = false;
            chart.Tooltip.BackgroundColor = "#ffffff";
            chart.Tooltip.Rounded         = 3;
            chart.Tooltip.Stroke          = 2;
            chart.Tooltip.Colour          = "#000000";
            chart.Tooltip.BodyStyle       = "color: #000000; font-weight: normal; font-size: 11;";

            maxDot = (int)(maxDot * 1.3);
            chart.Y_Axis.SetRange(0, maxDot, maxDot / 3);
            chart.X_Axis.GridColour = "#eeeeee";
            chart.Y_Axis.GridColour = "#eeeeee";
            chart.X_Axis.Colour     = "#333333";
            chart.Y_Axis.Colour     = "#333333";
            chart.Bgcolor           = "#fbfbfb";

            List <string> data2 = new List <string>();

            for (int i = 0; i < Days; i++)
            {
                data2.Add(BeginDate.AddDays(i).ToString("yyyy年MM月dd日"));
            }

            XAxis x = new XAxis();

            x.GridColour = "#eeeeee";
            x.Stroke     = 1;
            x.Steps      = Steps;
            XAxisLabels xlabels = new XAxisLabels();

            xlabels.Steps    = Steps;
            xlabels.Vertical = false;
            xlabels.SetLabels(data2);
            x.Labels     = xlabels;
            chart.X_Axis = x;

            chart.Tooltip            = new ToolTip("全局提示:#val#");
            chart.Tooltip.Shadow     = true;
            chart.Tooltip.Colour     = "#e43456";
            chart.Tooltip.MouseStyle = ToolTipStyle.CLOSEST;
            return(chart);
        }
Esempio n. 25
0
 private void Plus_Click(object sender, RoutedEventArgs e)
 {
     BeginDate = BeginDate.AddDays(1);
     EndDate   = EndDate.AddDays(1);
 }
Esempio n. 26
0
        public void Print()
        {
            try
            {
                String pdfTemp = CoreUtils.GetSetting(CoreEnums.Settings.Standalone_Signin_FormsDir).ToString() + "Blank_Timesheet.pdf";
                String newFile = CoreUtils.GetSetting(CoreEnums.Settings.Standalone_Signin_OutputDir).ToString() + "Timesheet-" + BeginDate.ToString("MM-dd-yyyy") + "-" + EndDate.ToString("MM-dd-yyyy") + ".pdf";

                pdfReader     = new PdfReader(pdfTemp);
                pdfStamper    = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
                pdfFormFields = pdfStamper.AcroFields;

                pdfFormFields.SetField("EID", Ecode);
                pdfFormFields.SetField("EmpName", Ename);
                pdfFormFields.SetField("PayPeriodEnd", EndDate.ToString("MM-dd-yyyy"));
                pdfFormFields.SetField("Begin1_1", dtBegin1_1.ToString("MM-dd-yyyy"));
                pdfFormFields.SetField("Begin1_2", dtBegin1_2.ToString("MM-dd-yyyy"));
                pdfFormFields.SetField("Begin2_1", dtBegin2_1.ToString("MM-dd-yyyy"));
                pdfFormFields.SetField("Begin2_2", dtBegin2_2.ToString("MM-dd-yyyy"));

                DateTime cBeginDate = BeginDate;

                while (cBeginDate <= EndDate)
                {
                    string RowName = cBeginDate.ToString("dddd") + "_" + WhichWeek(cBeginDate);
                    Double hours   = CalculateHours(cBeginDate);

                    if (cBeginDate <= dtBegin1_2)
                    {
                        TotalHoursWeek1 += hours;
                    }
                    else
                    {
                        TotalHoursWeek2 += hours;
                    }

                    pdfFormFields.SetField(RowName, hours.ToString());
                    cBeginDate = cBeginDate.AddDays(1);
                }

                pdfFormFields.SetField("RegTotal1", Convert.ToString(TotalHoursWeek1));
                pdfFormFields.SetField("RegTotal2", Convert.ToString(TotalHoursWeek2));

                FormattedDataTable.Rows.Add(dtRow);
                pdfStamper.Close();
                CoreUtils.ShowMessage("Sign-In Logs", "PDF Printed", CoreEnums.ErrorType.Notice);
            }
            catch (Exception e)
            {
                CoreUtils.ShowMessage("Sign In Logs", e.Message);
            }
        }
Esempio n. 27
0
        string GetChartXMLFile(string unit)
        {
            string filename = "chart_" + unit + "_" + BeginDate.ToString("yyyyMMdd") + "_" + EndDate.ToString("yyyyMMdd") + ".xml";
            string path     = Server.MapPath("~/_temp/chart");
            string fileUrl  = "";

            if (File.Exists(Path.Combine(path, filename)))
            {
                fileUrl = "/_temp/chart/" + filename;
            }
            else
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string strHead = @"<graph xaxisname=""{0}"" yaxisname=""访问量"" hovercapbg=""DEDEBE"" hovercapborder=""889E6D"" baseFontSize='12' rotateNames=""0""  numdivlines=""9"" divLineColor=""CCCCCC"" divLineAlpha=""80"" decimalPrecision=""0"" showAlternateHGridColor=""1"" AlternateHGridAlpha=""30"" AlternateHGridColor=""CCCCCC""  bgcolor='fbfbfb' caption=""{1}"" subcaption=""{2}"">";
                switch (unit)
                {
                case "hour":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "小时", BeginDate.ToString("yyyy-MM-dd") + "  24小时流量图", ""));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"12\" fontColor=\"000000\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" hoverText=\"{0}点\"/>", i));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(-1).AddHours(i);
                                DateTime endTime   = startTime.AddHours(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(-1).AddHours(i);
                                DateTime endTime   = startTime.AddHours(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;

                case "day":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "天", "流量曲线图", BeginDate.ToString("yyyy-MM-dd") + "  到 " + EndDate.ToString("yyyy-MM-dd")));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"11\" fontColor=\"000000\">");
                            TimeSpan ts   = EndDate - BeginDate;
                            int      days = ts.Days;
                            for (int i = 0; i <= days; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" />", BeginDate.AddDays(i).Day));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= days; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(i);
                                DateTime endTime   = startTime.AddDays(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= days; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(i);
                                DateTime endTime   = startTime.AddDays(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;

                case "month":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "月", "流量曲线图", BeginDate.ToString("yyyy-MM") + "  到 " + EndDate.ToString("yyyy-MM")));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"11\" fontColor=\"000000\">");
                            TimeSpan ts     = EndDate - BeginDate;
                            int      months = (int)(ts.TotalDays / 30);
                            for (int i = 0; i <= months; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" hoverText=\"{0}月\"/>", BeginDate.AddMonths(i).Month));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= months; i++)
                            {
                                DateTime startTime = BeginDate.AddMonths(i);
                                DateTime endTime   = startTime.AddMonths(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= months; i++)
                            {
                                DateTime startTime = BeginDate.AddMonths(i);
                                DateTime endTime   = startTime.AddMonths(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;
                }
            }

            return(fileUrl);
        }
Esempio n. 28
0
 public override string ToString()
 {
     return($"{Name}:\t{BeginDate.ToShortDateString()}\t:\t{(EndDate.HasValue ? EndDate.Value.ToShortDateString() : "Present")}");
 }