Example #1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(180);
            GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);

            if (Membership.GetUser(Helper.Admin.Defaults.UserName) == null)
            {
                MembershipBLL memberShip = new MembershipBLL();
                MembershipCreateStatus objStatus;
                memberShip.RegisterMember(Helper.Admin.Defaults.UserName, Helper.Admin.Defaults.Password, Helper.Admin.Defaults.Email, Helper.Admin.Defaults.Question, Helper.Admin.Defaults.Answer, out objStatus);
            }

            timerTricks = 0;
            System.Timers.Timer scheduleTimer = new System.Timers.Timer();
            scheduleTimer.Interval = 1000 * 60 * 5; //5 minutes
            scheduleTimer.AutoReset = true;
            scheduleTimer.Elapsed += new System.Timers.ElapsedEventHandler(scheduleTimer_Elapsed);
            scheduleTimer.Enabled = true;

               /* System.Timers.Timer scheduleTimerForMailAds = new System.Timers.Timer();
            scheduleTimerForMailAds.Interval = 1000 * 60 * 60; //60 minutes (1 hour)
            scheduleTimerForMailAds.AutoReset = true;
            scheduleTimerForMailAds.Elapsed += new System.Timers.ElapsedEventHandler(scheduleTimerForMailAds_Elapsed);
            scheduleTimerForMailAds.Enabled = true;*/
        }
        protected void uiLinkButtonSaveMember_Click(object sender, EventArgs e)
        {
            int type = Convert.ToInt32(uiRadioButtonListTypes.SelectedValue);
            BLL.MemberTypeSpecDuration bllSpec = new MemberTypeSpecDuration();
            if (!bllSpec.LoadByMemberTypeSpecID(type))
                return;
            int val = 0;//Convert.ToInt32(bllSpec.Points);
            if (BLL.Member.CurrentMember.Credit_Point < val)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "balanceError", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                return;
            }

            Member member = new Member();
            if (!member.LoadByPrimaryKey(Convert.ToInt32(hdnMember.Value)))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "NoacountError", @"$(document).ready(function () { notify('error', 'حدث خطأ . لا يوجد حساب بهذا الإسم.'); });", true);
                return;
            }

            BLL.MembershipBLL membership = new BLL.MembershipBLL();
            string msg;
            string oldname = member.Name;
            if (!string.IsNullOrEmpty(uiTextBoxNewName.Text))
            {
                if (membership.ChangeUsername(oldname, uiTextBoxNewName.Text, Membership.ApplicationName, out msg))
                {
                    member.Name = uiTextBoxNewName.Text;
                    member.Save();
                }
                else
                {
                    uiTextBoxNewName.Text = oldname;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "changeName", @"$(document).ready(function () { notify('error', 'حدث خطأ ." + msg + ".'); });", true);
                    return;
                }
            }
            member.MemberType.MemberTypeSpecDurationID = bllSpec.ID;
            member.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
            member.MemberType.StartDate = DateTime.Now;
            member.MemberType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(uiDropDownListTypeDuration.SelectedValue));
            member.MemberType.OldName = oldname;
            member.MemberType.Save();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الإسم بنجاح.'); });", true);

            uiPanelUpgradeSuccess.Visible = true;
            uiPanelUpgrade.Visible = false;
            clearUpgradeFields();

            BLL.MemberLog log = new BLL.MemberLog();
            log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeMemberType() { MemberName = member.Name,OldName=oldname, NewTypeName = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = member.MemberType.EndDate, Points = val }, member.MemberID, null);

            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, type);
            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, member.UserName);
        }