Example #1
0
        /// <summary>
        /// Create new user.
        /// </summary>
        /// <param name="user"></param>
        public int CreateUser(User user)
        {
            CanonDataContext db = Cdb.Instance;

            if (Business.User.IsLoginExists(user.UserName))
            {
                throw new LoginExistsException(user.UserName);
            }

            string cleanPassword = string.Empty;

            //insert a new user
            user.IsForbidden = false;
            cleanPassword    = user.Password;
            user.Password    = EncodePassword(cleanPassword);
            db.Users.InsertOnSubmit(user);
            db.SubmitChanges();

            if (!string.IsNullOrEmpty(user.Email))
            {
                EmailGateway.Send(
                    String.Empty,
                    user.Email,
                    Utilities.GetResourceString("Common", "EmailCredentialsSubject"),
                    String.Format(Utilities.GetResourceString("Common", "EmailCredentialsText"), user.UserName, cleanPassword),
                    new List <Attachment>());
            }

            return(user.UserId);
        }
Example #2
0
        public static List <string> ConvertImportErrorsToStrings(List <ImportErrorMessage> list)
        {
            List <string> res = new List <string>(20);

            foreach (ImportErrorMessage iem in list)
            {
                string message = Utilities.GetResourceString("Validators", iem.Id);
                if (iem.Parameters.Count > 0)
                {
                    message = string.Format(message, iem.Parameters.ToArray());
                }
                res.Add(message);
            }
            return(res);
        }
Example #3
0
File: User.cs Project: radtek/canon
        /// <summary>
        /// Change email with the password to the user.
        /// </summary>
        /// <param name="email"></param>
        public static bool SendRemindPasswordEmail(string email)
        {
            Canon.Data.User user = GetUserByEmail(email);

            if (user != null)
            {
                string password = ((CanonMembershipProvider)Membership.Provider).ChangePassword(user.UserId);

                string changePasswordUrl = String.Concat(
                    HttpContext.Current.Request.Url.Scheme,
                    "://",
                    HttpContext.Current.Request.Url.Host,
                    ":",
                    HttpContext.Current.Request.Url.Port,
                    HttpContext.Current.Request.ApplicationPath,
                    "/Default.aspx?changepassword=yes");

                try
                {
                    EmailGateway.Send(
                        String.Empty,
                        email,
                        Utilities.GetResourceString("Common", "EmailRemindEmailSubject"),
                        String.Format(Utilities.GetResourceString("Common", "EmailRemindEmailText"), password, changePasswordUrl, user.UserName),
                        new List <Attachment>(),
                        true);
                }
                catch
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Example #4
0
        /// <summary>
        /// Change password.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <returns></returns>
        public void ChangePassword(int userID, string oldPassword, string newPassword)
        {
            CanonDataContext db = Cdb.Instance;

            var user = (from u in db.Users
                        where u.UserId == userID
                        select u).Single();

            if (!CheckPassword(oldPassword, user.Password))
            {
                throw new InvalidOldPasswordException(userID, oldPassword);
            }

            user.Password = EncodePassword(newPassword);

            db.SubmitChanges();

            EmailGateway.Send(
                String.Empty,
                user.Email,
                Utilities.GetResourceString("Common", "EmailPasswordChangingSubject"),
                String.Format(Utilities.GetResourceString("Common", "EmailPasswordChangingText"), newPassword),
                new List <Attachment>());
        }
Example #5
0
 protected void Localize()
 {
     deStartDate.CalendarProperties.TodayButtonText  = Utilities.GetResourceString("Common", "Today");
     deFinishDate.CalendarProperties.TodayButtonText = Utilities.GetResourceString("Common", "Today");
 }
Example #6
0
        public void Bind()
        {
            List <int>         channels = this.Channels;
            List <int>         products = this.Products;
            CanonDataContext   db       = Cdb.Instance;
            List <MainMonitor> list     = CanonMainMonitor.GetValuesForChart(deStartDate.Date,
                                                                             deFinishDate.Date, channels, products);

            foreach (int productId in products)
            {
                Product product = db.Products.Where(p => p.ProductId == productId).FirstOrDefault();
                if (product == null)
                {
                    continue;
                }
                WebChartControl chart = new WebChartControl();
                chart.EnableViewState = false;
                ChartTitle title = new ChartTitle();
                title.Text = string.Format(Utilities.GetResourceString("Common", "ChartHeader"),
                                           product.ProductName, deStartDate.Date.ToString("dd.MM.yyyy"),
                                           deFinishDate.Date.ToString("dd.MM.yyyy"));
                title.Font = new System.Drawing.Font("Tahoma", 10);
                chart.Titles.Add(title);
                chart.FillStyle.FillMode = FillMode.Solid;
                Dictionary <int, Series> series = new Dictionary <int, Series>();
                Series s0 = new Series("Recommended price", ViewType.Line);
                s0.ValueScaleType    = ScaleType.Numerical;
                s0.ArgumentScaleType = ScaleType.DateTime;
                series.Add(0, s0);
                foreach (int channelId in channels)
                {
                    Channel channel = db.Channels.Where(c => c.ChannelId == channelId).FirstOrDefault();
                    if (channel == null)
                    {
                        continue;
                    }
                    Series s = new Series(channel.ChannelName, ViewType.Line);
                    s.ValueScaleType    = ScaleType.Numerical;
                    s.ArgumentScaleType = ScaleType.DateTime;
                    series.Add(channelId, s);
                }
                foreach (MainMonitor mm in list)
                {
                    if (mm.ProductId != productId)
                    {
                        continue;
                    }
                    series[mm.ChannelId].Points.Add(new SeriesPoint(mm.CalcDate, new double[] { (double)mm.ChannelPrice }));
                    series[0].Points.Add(new SeriesPoint(mm.CalcDate, new double[] { (double)mm.RecommendedPrice }));
                }
                foreach (KeyValuePair <int, Series> serie in series)
                {
                    chart.Series.Add(serie.Value);
                }
                //diagram
                DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram();
                xyDiagram.AxisY.Title.Font               = new System.Drawing.Font("Tahoma", 8);
                xyDiagram.AxisY.Title.Text               = "CZK";
                xyDiagram.AxisY.Label.Staggered          = false;
                xyDiagram.AxisY.Title.Visible            = true;
                xyDiagram.AxisY.Range.SideMarginsEnabled = true;
                xyDiagram.AxisY.Interlaced               = true;

                xyDiagram.AxisX.Title.Font               = new System.Drawing.Font("Tahoma", 8);
                xyDiagram.AxisX.Label.Staggered          = true;
                xyDiagram.AxisX.Range.SideMarginsEnabled = true;
                xyDiagram.AxisX.Tickmarks.MinorVisible   = false;
                chart.Diagram = xyDiagram;
                chart.Width   = 700;
                chart.Height  = 500;
                chart.DataBind();
                panelPics.Controls.Add(chart);

                this.FilesToSave.Add(this.SaveChartIntoFile(product.ProductName, chart));
            }
        }