コード例 #1
0
 public UCReportEmployeeClem(FRMMain mFRM)
 {
     InitializeComponent();
     fRMMain   = mFRM;
     conDB     = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #2
0
 public UCReportEmployeeClem(FRMMain mFRM)
 {
     InitializeComponent();
     fRMMain = mFRM;
     conDB = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #3
0
 public UCAddCompany(FRMMain mFRM)
 {
     InitializeComponent();
     fRMMain   = mFRM;
     conDB     = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #4
0
ファイル: ConvertDateTimeTest.cs プロジェクト: jgshort/SqlDom
 public void ConvertDateTimeConstructorTest1()
 {
     DateTimeTypes dataType = new DateTimeTypes(); // TODO: Initialize to an appropriate value
     Expression expression = null; // TODO: Initialize to an appropriate value
     ConvertDateTime target = new ConvertDateTime(dataType, expression);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
コード例 #5
0
ファイル: UCAddCompany.cs プロジェクト: ruxchuk/A-Team_Clem
 public UCAddCompany(FRMMain mFRM)
 {
     InitializeComponent();
     fRMMain = mFRM;
     conDB = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #6
0
        private async Task <BaseResponse <object> > SendInfoMessageBySms(InfoUserSms info, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                if (string.IsNullOrEmpty(info.PhoneNumber))
                {
                    info.ErrorString   = "No Phone Number";
                    info.IsSendSuccess = 1;
                    return(Result(info));
                }

                var requestContent = new StringContent("", Encoding.UTF8, "application/json");

                using (var httpClient = new HttpClient())
                {
                    httpClient.DefaultRequestHeaders.ConnectionClose = true;
                    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json");
                    var putUriPath = SendSmsUri
                                     + $"?secret-key={info.SecretKey}&customer-id={info.CustomerId}&user-id={info.UserId}&phone-number={info.PhoneNumber}&person-id={info.UserId}&language-id={info.LanguageId}";

                    using (var httpResponse = await httpClient.PostAsync(new Uri(putUriPath), requestContent, cancellationToken).ConfigureAwait(false))
                    {
                        // Convert response content to string data
                        var serverResponse = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        if (serverResponse.Contains("OK"))
                        {
                            info.IsSendSuccess = 1;
                        }

                        // Result
                        var data = JsonConvert.DeserializeObject <object>(serverResponse);
                        return(Result(data));
                    }
                }
            }
            catch (TaskCanceledException tEx)
            {
                Debug.WriteLine(tEx);
                info.ErrorString   = "Request Timeout: " + tEx;
                info.IsSendSuccess = 0;
                return(Result(info));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                info.ErrorString   = ex.ToString();
                info.IsSendSuccess = 0;
                return(Result(info));
            }
            finally
            {
                // Save MongoDB
                Logger?.Info($"Insert value to DB");
                info.DateSend = ConvertDateTime.GetDateTimeNowUtc();
                _connect.InsertMessageDocumentAsync(info);
                Logger?.Info($"Value insert DB: {JsonConvert.SerializeObject(info)}");
            }
        }
コード例 #7
0
 public UCAddCustomer(FRMMain fRMMain)
 {
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     InitializeComponent();
     conDB     = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #8
0
 public UCAddProductType(FRMMain fRMMain)
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     conDB        = new ConMySql();
     convertDT    = new ConvertDateTime();
 }
コード例 #9
0
 public UCAddProductType(FRMMain fRMMain)
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     conDB = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #10
0
ファイル: UCAddCustomer.cs プロジェクト: ruxchuk/A-Team_Clem
 public UCAddCustomer(FRMMain fRMMain)
 {
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     InitializeComponent();
     conDB = new ConMySql();
     convertDT = new ConvertDateTime();
 }
コード例 #11
0
        public static DateTime GetRemanderDate(Event eventToEdit)
        {
            // ReSharper disable once PossibleInvalidOperationException
            var remanderDateUtc = TimeZoneInfo.ConvertTimeToUtc((DateTime)eventToEdit.ReminderDate);

            var remainderDate = ConvertDateTime.ToSwissTimezone(remanderDateUtc);

            return(remainderDate);
        }
コード例 #12
0
        public bool EventHasNotPassed(Event eventForInvitation)
        {
            var todaysDate   = ConvertDateTime.ToSwissTimezone(DateTime.UtcNow);
            var compareDates = eventForInvitation.StartDate.GetValueOrDefault().CompareTo(todaysDate);

            bool notPassed = compareDates >= 0;

            return(notPassed);
        }
コード例 #13
0
ファイル: UCAddEmployee.cs プロジェクト: ruxchuk/A-Team_Clem
 public UCAddEmployee(FRMMain fRMMain)
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     conDB = new ConMySql();
     convertDT = new ConvertDateTime();
     dtStart.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
     dtStart.Properties.Mask.EditMask = fRMMain.formatDate;
 }
コード例 #14
0
 public UCAddEmployee(FRMMain fRMMain)
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.fRMMain = fRMMain;
     conDB        = new ConMySql();
     convertDT    = new ConvertDateTime();
     dtStart.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
     dtStart.Properties.Mask.EditMask = fRMMain.formatDate;
 }
コード例 #15
0
ファイル: UCAddProduct.cs プロジェクト: ruxchuk/A-Team_Clem
        public UCAddProduct(FRMMain fRMMain)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.fRMMain = fRMMain;
            conDB        = new ConMySql();
            convertDT    = new ConvertDateTime();

            price.Properties.Mask.MaskType = MaskType.Numeric;
            price.Properties.Mask.EditMask = "n";
        }
コード例 #16
0
ファイル: Core.cs プロジェクト: Literal92/jewellery-Nop
 public static string GetStringShortShamsiCurrentData()
 {
     try
     {
         return(ConvertDateTime.ToShorShamsi(GetCurrentDate()));
     }
     catch (Exception ee)
     {
         return("0/0/0");
     }
 }
コード例 #17
0
ファイル: UCAddProduct.cs プロジェクト: ruxchuk/A-Team_Clem
        public UCAddProduct(FRMMain fRMMain)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.fRMMain = fRMMain;
            conDB = new ConMySql();
            convertDT = new ConvertDateTime();

            price.Properties.Mask.MaskType = MaskType.Numeric;
            price.Properties.Mask.EditMask = "n";
        }
コード例 #18
0
        public string GetProcessIdList(string UserIds, string StartDate, string EndDate)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add(Constants.PROCESS_CODE, process_code);
            dic.Add(Constants.START_TIME, ConvertDateTime.ConvertDateTimeInt(Convert.ToDateTime(StartDate)));
            dic.Add(Constants.ENDDATE, ConvertDateTime.ConvertDateTimeInt(Convert.ToDateTime(EndDate)));
            dic.Add(Constants.USERID_LIST, UserIds);
            string result = _dingDingHelper.CommonFunctions(dic, Constants.LISTIDS + "?" + _dingdingSeriver.ConvertDictionaryToString(_dingdingSeriver.GetAccessTokenToDicObject()));

            return(result);
        }
コード例 #19
0
        /// <summary>
        /// 请求AccessToken
        /// </summary>
        /// <param name="credentials">xml的credential凭证列表</param>
        private Credential RequestAccessToken(List <Credential> credentials)
        {
            //获取要请求的Credential类(公众号还是企业号类型)
            Credential credential = GetCredentialsFromXmlByType();

            //请求
            //HttpWebRequest webRequest;
            string strUrl = credential.RequestInfo.Url;

            if (credential.RequestInfo.RequestType.ToLower() == "get")
            {
                string strParams = string.Empty;
                //组装参数到url上
                foreach (string str in credential.RequestInfo.QueryParam)
                {
                    string[] strKeyValue = str.Split(':');
                    if (strKeyValue.Length > 1)
                    {
                        strParams += strKeyValue[0] + "=" + strKeyValue[1] + "&";
                    }
                    else
                    {
                        strParams += strKeyValue[0] + "=" + strKeyValue[0] + "&";
                    }
                }
                strUrl += "?" + strParams.TrimEnd('&');
            }
            //请求
            HttpItem hi = new HttpItem();

            hi.URL    = strUrl;
            hi.Method = credential.RequestInfo.RequestType;
            if (credential.RequestInfo.ProtocolType.ToLower() == "https")
            {
                hi.IsTrustCertificate = true;
            }
            hi.Encoding = Encoding.UTF8;
            HttpHelper hh         = new HttpHelper();
            HttpResult hr         = hh.GetHtml(hi);
            string     strContext = hr.Html;
            //转换返回结果为实体
            WxAccessToken wxat = JsonConvert.DeserializeObject <WxAccessToken>(strContext);

            //写入xml
            this.WriteXmlAccessToken(wxat);
            //写入cache
            Credential c         = GetCredentialsFromXmlByType();
            DateTime   dtExpired = new ConvertDateTime().String2DataTime(c.TokenInfo.GetTokenDateTime).AddSeconds(double.Parse(c.TokenInfo.ExpiresIn) - double.Parse(c.TokenInfo.EarlyEnd));

            CacheHelper.SetCache(c.WxPlatFormType, c, dtExpired);
            //返回Credential
            return(c);
        }
コード例 #20
0
        public UCAddEmployeeClem(FRMMain fRMMain)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            InitializeComponent();
            // TODO: Complete member initialization
            this.fRMMain = fRMMain;
            conDB = new ConMySql();
            convertDT = new ConvertDateTime();

            //set รูปแบบวันที่
            dtProductEndDate.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
            dtProductEndDate.Properties.Mask.EditMask = fRMMain.formatDate;
        }
コード例 #21
0
        public UCAddEmployeeClem(FRMMain fRMMain)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            InitializeComponent();
            // TODO: Complete member initialization
            this.fRMMain = fRMMain;
            conDB        = new ConMySql();
            convertDT    = new ConvertDateTime();

            //set รูปแบบวันที่
            dtProductEndDate.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
            dtProductEndDate.Properties.Mask.EditMask = fRMMain.formatDate;
        }
コード例 #22
0
        public UCAddCustomerClem(FRMMain mFRM)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            InitializeComponent();
            fRMMain = mFRM;
            conDB = new ConMySql();
            convertDT = new ConvertDateTime();

            //set รูปแบบวันที่
            dtProductEndDate.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
            dtProductEndDate.Properties.Mask.EditMask = fRMMain.formatDate;

            textEditChargebacks.Properties.Mask.MaskType = MaskType.Numeric;
            textEditChargebacks.Properties.Mask.EditMask = "n";
        }
コード例 #23
0
        public UCAddCustomerClem(FRMMain mFRM)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            InitializeComponent();
            fRMMain   = mFRM;
            conDB     = new ConMySql();
            convertDT = new ConvertDateTime();

            //set รูปแบบวันที่
            dtProductEndDate.Properties.DisplayFormat.FormatString = fRMMain.formatDate;
            dtProductEndDate.Properties.Mask.EditMask = fRMMain.formatDate;

            textEditChargebacks.Properties.Mask.MaskType = MaskType.Numeric;
            textEditChargebacks.Properties.Mask.EditMask = "n";
        }
コード例 #24
0
        /// <summary>
        /// 获取凭证
        /// </summary>
        /// <returns></returns>
        private Credential GetCredential()
        {
            //1.获取缓存
            //2.如果为null则获取xml
            //3.如果xml中过期则根据Credential重新获取AccessToken
            Credential        credential     = null;
            List <Credential> listCredential = new List <Credential>();

            if (CacheHelper.GetCache(this._wxPlatFormTypeEnum.ToString()) == null)
            {
                listCredential = GetCredentialsFromXml();
                //将xml中没有过期的Credential写入Cache
                if (listCredential.Count > 0)
                {
                    foreach (Credential c in listCredential)
                    {
                        if (c.WxPlatFormType == this._wxPlatFormTypeEnum.ToString())
                        {
                            //判断是否过期
                            if (!c.TokenInfo.IsExpired)
                            {
                                DateTime dtExpired = new ConvertDateTime().String2DataTime(c.TokenInfo.GetTokenDateTime).AddSeconds(double.Parse(c.TokenInfo.ExpiresIn) - double.Parse(c.TokenInfo.EarlyEnd));
                                //设置cache过期时间
                                CacheHelper.SetCache(c.WxPlatFormType, c, dtExpired);
                            }
                            break;
                        }
                    } //end for foreach
                }     //end for if
            }
            object objCredential = CacheHelper.GetCache(this._wxPlatFormTypeEnum.ToString());

            //从xml中也为找到AccessToken则需要请求获取
            if (objCredential == null)
            {
                //获取后写入xml,cache 并返回credential
                credential = RequestAccessToken(listCredential);
            }
            else
            {
                credential = ( Credential )objCredential;
            }
            return(credential);
        }
コード例 #25
0
        public ActionResult CopyEvent(
            [Bind(Include = "Title,Location,Description,StartDate,EndDate")] Event @event)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", @event));
            }
            // ReSharper disable once PossibleInvalidOperationException
            ConvertDateTime.ToSwissTimezone(TimeZoneInfo.ConvertTimeToUtc((DateTime)@event.StartDate));

            /*
             * Todo: the line below is only for debugging purposes:
             *       Its to log current time to see if the application is using client or server machine
             *       local time
             */
            ErrorSignal.FromCurrentContext().Raise(new Exception(String.Format("The current Event Date(local swiss time) is: {0}.  - (From Events controller)", @event.StartDate)));

            _service.SaveEvent(@event);
            return(RedirectToAction("SendEventsInvitation", "Invitation", new { id = @event.Id }));
        }
コード例 #26
0
ファイル: PassiveProcess.cs プロジェクト: jackjet870/xlwx
        //加密
        public bool SetEncryptionContent(string sRespData, ref string sEncryptMsg)
        {
            //如果为公众平台且未使用加密
            if (this._wxPlatType == WxPlatFormTypeEnum.GZ)
            {
                WXGZConfigEntity gzConfig = XmlToEntity.GetGZConfig();
                if (string.IsNullOrEmpty(gzConfig.EncodingAESKey))
                {
                    sEncryptMsg = sRespData;
                    return(true);
                }
            }
            int ret = this._wxcpt.EncryptMsg(sRespData, ConvertDateTime.GetTimeStamp(), new Random().Next(100000000, 999999999).ToString(), ref sEncryptMsg);

            if (ret != 0)
            {
                //System.Console.WriteLine( "ERR: EncryptMsg Fail, ret: " + ret );
                return(false);
            }
            return(true);
        }
コード例 #27
0
ファイル: TablePage.xaml.cs プロジェクト: aminakhtar/LFU
        private void btnDateTime_Click(object sender, RoutedEventArgs e)
        {
            Status("Converting the date and time started...please wait.");
            ConvertDateTime windDateTime = new ConvertDateTime(Dgv.FieldNamesAsDisplayed);

            windDateTime.ShowDialog();

            if (windDateTime.DialogResult == true)
            {
                List <string> ErrorList = Db.Connect.UpdateDateTime(this.TableName,
                                                                    windDateTime.cmbInputColumn.SelectedItem.ToString(),
                                                                    windDateTime.cmbOutputColumn.SelectedItem.ToString(),
                                                                    windDateTime.cmbInputFormat.SelectedItem.ToString(),
                                                                    windDateTime.cmbOutputFormat.SelectedItem.ToString());

                if (ErrorList.Count != 0)
                {
                    WindError WE = new WindError(ErrorList);
                    WE.ShowDialog();
                }
            }
            Status("Converting the date and time is done.please refresh your window.");
        }
コード例 #28
0
        private void InitComponent()
        {
            weekIndex = ConvertDateTime.GetWeekIndex(DateTime.Now.ToString());
            string departmentId = Request.QueryString["DepartmentID"];

            using (WXOADataContext db = new WXOADataContext())
            {
                var entity = db.TE_Departments.FirstOrDefault(d => d.ID == int.Parse(departmentId));
                if (entity != null)
                {
                    departmentName = entity.Name;
                    content        = entity.Content;
                }
                var query1 = db.TU_Users.Where(u => u.DepartmentID == int.Parse(departmentId)).OrderBy(u => u.State).Select(u => new
                {
                    u.RealName,
                    PositionName = db.TE_DutyDetails.FirstOrDefault(d => d.ID == Convert.ToInt64(u.DutyId)).Name,
                    u.Grade
                });
                this.Repeater1.DataSource = query1;
                this.Repeater1.DataBind();
            }
        }
コード例 #29
0
        private async Task <BaseResponse <object> > PushNotifyToClient(InfoUserSms info, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                // Push to Firebase
                // TODO
                return(null);
            }
            catch (TaskCanceledException tEx)
            {
                Debug.WriteLine(tEx);
                if (!cancellationToken.IsCancellationRequested)
                {
                    throw;
                }

                info.ErrorString   = "Request Timeout: " + tEx;
                info.IsSendSuccess = 0;
                return(null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                info.ErrorString   = ex.ToString();
                info.IsSendSuccess = 0;
                return(null);
            }
            finally
            {
                // Save MongoDB
                Logger?.Info($"Insert value to DB");
                info.DateSend = ConvertDateTime.GetDateTimeNowUtc();
                _connect.InsertMessageDocumentAsync(info);
                Logger?.Info($"Value insert DB: {JsonConvert.SerializeObject(info)}");
            }
        }
コード例 #30
0
        private void InitComponent()
        {
            currentWeekIndex = ConvertDateTime.GetWeekIndex(DateTime.Now);
            string departmentId = Request.QueryString["DepartmentID"];
            string weekIndex    = Request.QueryString["WeekIndex"];

            using (WXOADataContext db = new WXOADataContext())
            {
                var entity = db.TE_Departments.FirstOrDefault(d => d.ID == int.Parse(departmentId));
                if (entity != null)
                {
                    this.ltlDepartmentName.Text = entity.Name;
                    this.ltlDateTime.Text       = String.Format("第{0}周", weekIndex);
                }
                string   dtStart   = ConvertDateTime.GetWeekRange(int.Parse(weekIndex)).Split('~')[0];
                string   dtEnd     = ConvertDateTime.GetWeekRange(int.Parse(weekIndex)).Split('~')[1];
                DateTime startTime = Convert.ToDateTime(dtStart).AddDays(-1);
                DateTime stopTime  = Convert.ToDateTime(dtEnd).AddDays(-1);
                var      plan      = db.PLAN_Plans.FirstOrDefault(pp => pp.DepartmentID == int.Parse(departmentId) && pp.Starttime == startTime && pp.Stoptime == stopTime && pp.Type == 2 && pp.RangeType == 2);
                if (plan != null)
                {
                    this.txtTitle.Text    = plan.Title;
                    this.txtTotal.Text    = plan.Total.ToString();
                    this.txtCurrent.Text  = plan.Current.ToString();
                    this.txtContent.Value = plan.Content;
                    this.txtSummary.Value = plan.Summary;
                    var comments = db.PLAN_Appraises.Join(db.TU_Users, o => o.UserID, i => i.UserID, (o, i) => new
                    {
                        o.PlanID,
                        o.Appraise,
                        o.Content,
                        o.AddTime,
                        i.RealName
                    }).ToList().Where(a => a.PlanID == plan.id).Select(a => new
                    {
                        a.PlanID,
                        a.Appraise,
                        Content  = new DepartmentMonthPlan().SplitString(a.Content, 4),
                        Content1 = a.Content,
                        AddTime  = a.AddTime.Value.ToString("yyyy-MM-dd"),
                        a.RealName
                    });
                    this.Repeater1.DataSource = comments;
                    this.Repeater1.DataBind();
                }
                var users = db.TU_Users.Where(u => u.DepartmentID == int.Parse(departmentId) && u.State != 40).Select(u => new
                {
                    u.RealName,
                    u.UserID,
                    WeekFlag = String.Format("{0}周({1})", weekIndex, ConvertDateTime.GetWeekRange(int.Parse(weekIndex))),
                    title    = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? "" : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).Title,
                    total    = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? 0 : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).Total,
                    current  = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? 0 : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).Current,
                    content  = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? "" : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).Content,
                    summary  = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? "" : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).Summary,
                    PlanID   = db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime) == null ? 0 : db.PLAN_Plans.FirstOrDefault(p => p.UserID == u.UserID && p.Starttime == startTime && p.Stoptime == stopTime).id
                });
                this.Repeater2.DataSource = users;
                this.Repeater2.DataBind();
            }
        }
コード例 #31
0
        public ActionResult SendEventsInvitation([Bind(Include =
                                                           "ParticipantsEmails,EventDate,EventId,SendRemainder,ReminderDate,ListDate")] InvitationViewModel model)
        {
            var id = model.EventId;

            if (!ModelState.IsValid)
            {
                return(View(ReturnInvitationModel(id)));
            }

            //ToDo: change list and remainder dates to swiss time to be used for sending email

            // get event from database
            var eventForInvitation = GetEvent(id);

            eventForInvitation.ListDate =
                // ReSharper disable once PossibleInvalidOperationException
                ConvertDateTime.ToSwissTimezone(TimeZoneInfo.ConvertTimeToUtc((DateTime)model.ListDate));

            if (model.ReminderDate != null)
            {
                eventForInvitation.ReminderDate = ConvertDateTime.ToSwissTimezone(TimeZoneInfo.ConvertTimeToUtc((DateTime)model.ReminderDate));
                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("{ From Invitation controller sending invitation } Remainder date is on " + eventForInvitation.ReminderDate));
            }

            /*
             * This is used to check time on the server
             * when this is deployed
             */

            Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("{ From Invitation controller sending invitation } List date is on " + eventForInvitation.ListDate));


            //Check if invitations can still be sent
            var notPassed = _service.EventHasNotPassed(eventForInvitation);

            if (!notPassed)
            {
                return(View("_CantInvite", eventForInvitation));
            }



            var unsavedContacts        = new UnsavedContactViewModel();
            EmailInformation emailInfo = null;
            var allSaved = false;
            var contacts = new List <Contact>();
            var emails   = new List <EmailInformation>();

            //loop through emails
            var emailList = model.ParticipantsEmails.Split(',').ToList();

            foreach (var participantEmail in emailList)
            {
                var email = _service.RemoveBrackets(participantEmail);

                //save new participant
                SaveParticipantInDb(email, eventForInvitation);


                #region Create and send Email

                emailInfo = ComposeEmailInfo(eventForInvitation, email);
                emails.Add(emailInfo);

                //Send Invitation Email
                try
                {
                    PostalEmailManager.SendEmail(emailInfo, new InvitationEmail());

                    //todo: this is to be removed before deployment for production
                    Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Email sent to " + emailInfo.ParticipantEmail));

                    if (model.SendRemainder)
                    {
                        var remainderDate = Service.GetRemanderDate(eventForInvitation);
                        JobManager.ScheduleRemainderEmail(emails, remainderDate);

                        //todo: this is to be removed before deployment for production
                        Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("remainder is set at " + remainderDate));
                    }
                }
                catch (Exception exception)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(exception);
                    return(RedirectToAction("Error"));
                }


                #endregion

                #region after sending email, save unsaved contacts

                var contactEmails = _contactsController.GetUserContacts(UserId);
                allSaved = contactEmails.Any(c => c.Email == email);

                if (allSaved)
                {
                    continue;
                }
                var contact = new Contact {
                    Email = email
                };
                contacts.Add(contact);
                unsavedContacts.Contacts = contacts;

                #endregion
            }

            #region Scheduling List email

            // start participant list summary scheduler
            var listDate = Service.GetListDate(eventForInvitation);
            JobManager.ScheduleParticipantListEmail(emailInfo, listDate);

            #endregion

            //redirect to details if all contacts are saved
            if (allSaved)
            {
                Response.Cookies.Add(new HttpCookie("successCookie", "Action is completed successfully"));

                return(RedirectToAction("Details", "Events", new { id }));
            }

            //Let user save his contacts return view with list of unsaved contacts
            unsavedContacts.EventId = eventForInvitation.Id;
            TempData["model"]       = unsavedContacts;     //Pass list to SaveEmails action
            return(RedirectToAction("SaveEmails"));
        }
コード例 #32
0
ファイル: JSSDKHelper.cs プロジェクト: jackjet870/xlwx
 /// <summary>
 /// 获取TimesTamp
 /// </summary>
 /// <returns></returns>
 public static string GetTimesTamp()
 {
     return(ConvertDateTime.GetTimeStamp());
 }
コード例 #33
0
        private void InitComponent()
        {
            string userId = Request.QueryString["UserID"];
            string type   = Request.QueryString["type"];

            switch (type)
            {
            case "1":
                string dateTime = Request.QueryString["DateTime"];
                this.Calendar1.TodaysDate = DateTime.Parse(dateTime);
                this.Image1.ImageUrl      = "/images/rtype3.png";
                this.Image2.ImageUrl      = "/images/type1.png";
                this.Image2.ToolTip       = "日计划";
                this.ltlPlanType.Text     = "日计划";
                using (WXOADataContext db = new WXOADataContext())
                {
                    var entity = db.TU_Users.FirstOrDefault(U => U.UserID == Guid.Parse(userId));
                    if (entity != null)
                    {
                        this.ltlPersonName.Text = entity.RealName;
                        this.ltlDateTime.Text   = dateTime;
                        var plan = db.PLAN_Plans.FirstOrDefault(p => p.UserID == Guid.Parse(userId) && p.Starttime == DateTime.Parse(dateTime) && p.Type == 1 && p.RangeType == 1);
                        if (plan != null)
                        {
                            this.txtTitle.Value   = plan.Title;
                            this.txtTotal.Value   = plan.Total.ToString();
                            this.txtCurrent.Value = plan.Current.ToString();
                            this.txtContent.Value = plan.Content;
                            this.txtSummary.Value = plan.Summary;

                            var appraises = db.PLAN_Appraises.Join(db.TU_Users, o => o.UserID, i => i.UserID, (o, i) => new
                            {
                                o.PlanID,
                                o.Appraise,
                                o.Content,
                                o.AddTime,
                                i.RealName
                            }).ToList().Where(pa => pa.PlanID == plan.id).Select(pa => new
                            {
                                pa.PlanID,
                                pa.Appraise,
                                Content  = new DepartmentMonthPlan().SplitString(pa.Content, 4),
                                Content1 = pa.Content,
                                pa.RealName,
                                AddTime = pa.AddTime.Value.ToString("yyyy-MM-dd")
                            });
                            this.Repeater1.DataSource = appraises;
                            this.Repeater1.DataBind();
                        }
                    }
                }
                break;

            case "3":
                string year  = Request.QueryString["Year"];
                string month = Request.QueryString["Month"];
                this.Image1.ImageUrl  = "/images/rtype3.png";
                this.Image2.ImageUrl  = "/images/type3.png";
                this.Image2.ToolTip   = "月计划";
                this.ltlPlanType.Text = "月计划";
                using (WXOADataContext db = new WXOADataContext())
                {
                    var entity = db.TU_Users.FirstOrDefault(U => U.UserID == Guid.Parse(userId));
                    if (entity != null)
                    {
                        this.ltlPersonName.Text = entity.RealName;
                        this.ltlDateTime.Text   = String.Format("{0}年{1}月", year, month);
                        DateTime startTime = Convert.ToDateTime(String.Format("{0}-{1}-{2}", year, month, "01"));
                        DateTime stopTime  = ConvertDateTime.GetLastDayOfMonth(startTime);
                        var      plan      = db.PLAN_Plans.FirstOrDefault(p => p.UserID == Guid.Parse(userId) && p.Starttime == startTime && p.Stoptime == stopTime);
                        if (plan != null)
                        {
                            this.txtTitle.Value       = plan.Title;
                            this.txtTotal.Value       = plan.Total.ToString();
                            this.txtCurrent.Value     = plan.Current.ToString();
                            this.txtContent.Value     = plan.Content;
                            this.txtSummary.Value     = plan.Summary;
                            this.Calendar1.TodaysDate = plan.Addtime.Value;
                            var appraises = db.PLAN_Appraises.Join(db.TU_Users, o => o.UserID, i => i.UserID, (o, i) => new
                            {
                                o.PlanID,
                                o.Appraise,
                                o.Content,
                                o.AddTime,
                                i.RealName
                            }).ToList().Where(pa => pa.PlanID == plan.id).Select(pa => new
                            {
                                pa.PlanID,
                                pa.Appraise,
                                Content  = new DepartmentMonthPlan().SplitString(pa.Content, 4),
                                Content1 = pa.Content,
                                pa.RealName,
                                AddTime = pa.AddTime.Value.ToString("yyyy-MM-dd")
                            });
                            this.Repeater1.DataSource = appraises;
                            this.Repeater1.DataBind();
                        }
                    }
                }
                break;
            }
        }