public WelcomeViewModel()
 {
     Welcome = new WelcomeModel()
     {
         Introduction = "Hello God!!"
     };
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public WelcomeViewModel()
 {
     Welcome = new WelcomeModel()
     {
         Introduction = "Hello MvvmLight!"
     };
 }
        static void Main(string[] args)
        {
            Console.WriteLine(@"
This a very simple demo of how the NonHttpRunTimeRazorSupport library 
might be used to send emails outside of the context of a running
web application.

This app is configured to drop .eml files in the C:\temp folder (see 
app.config). These files can be viewed in an email client, or on a
web site like http://www.encryptomatic.com/viewer/Default.aspx");
            var settings = new NotificationSettings(new Uri("http://www.facepack.com/"));
            var service  = new EmailNotificationService(settings);

            do
            {
                var from  = new MailAddress("*****@*****.**");
                var to    = new MailAddress("*****@*****.**");
                var model = new WelcomeModel
                {
                    Name = "Dave"
                };
                service.Send(from, to, model);
                Console.WriteLine("Message sent. Press a key to resend, or q to exit");
            } while (Console.ReadKey().KeyChar != 'q');
        }
Example #4
0
 public WelcomeViewModel()
 {
     Welcome = new WelcomeModel()
     {
         Introduction = "My name is Lilith"
     };
 }
Example #5
0
        public IActionResult Index(WelcomeModel model)
        {
            WelcomeModel user = null;

            using (var db = new WelcomeContext()) //использование контекста
            {
                user = db.welcomers.Where(x => x.name == model.name && x.profession == model.profession)
                       .FirstOrDefault();
            }

            if (user == null)
            {
                ViewBag.Message =
                    "Добро пожаловать! Вы автоматически зарегистрированы! Пожалуйста, перед тем, как выйти из здания подойдите к соответствующему окну!";

                using (var db = new WelcomeContext())
                {
                    db.Add(new WelcomeModel {
                        isinbuilding = true, lastin = DateTime.Now,
                        profession   = model.profession, name = model.name
                    });
                    db.SaveChanges();
                }
                return(View());
            }
            ViewBag.Message = "Добро пожаловать!";
            return(View());
        }
        public string ObtenerCotizacion(string id)
        {
            //  "ARS", "USD", "EUR","BRL"
            Dictionary <string, string> misMonedas = new Dictionary <string, string>()
            {
                { "dolar", "USD" },
                { "euro", "EUR" },
                { "real", "BRL" }
            };

            string sigla = misMonedas[id];

            var responseMessage = new HttpResponseMessage();
            var responseModel   = new WelcomeModel();

            using (var cliente = new HttpClient())
            {
                responseMessage = cliente.GetAsync($"https://api.cambio.today/v1/quotes/" + sigla + $"/ARS/json?quantity=1&key=3068|kkQfQg08kWKsQciBEvLY8DcTipsa87dK").Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    string jsonResult = responseMessage.Content.ReadAsStringAsync().Result;
                    responseModel = JsonConvert.DeserializeObject <WelcomeModel>(jsonResult);

                    //  responseModel.Cotizaciones = responseModel..Where(m => misMonedas.Contains(m.Key)).ToDictionary(n => n.Key, n => n.Value);
                }
            }

            return(JsonConvert.SerializeObject(responseModel));

            // Console.WriteLine("Called ConcreteStrategyA.Execute()");
        }
        public IActionResult Logout()
        {
            var employeeId = HttpContext.Session.GetInt32("EmployeeId");

            HttpWebRequest request = _requests.CreateLogoutRequest((int)employeeId);

            using (HttpWebResponse response = request.GetResponseNoException())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    _logic.RemoveUserDetailsFromSession();

                    JObject deserializedResponseBody = _logic.DeserializeResponse(response);

                    var farewellString = deserializedResponseBody.SelectToken("farewell").Value <string>();

                    var farewellMessage = new WelcomeModel()
                    {
                        WelcomeString = farewellString
                    };

                    return(View("LoggedOut", farewellMessage));
                }
            }

            return(View("Error", new ErrorMessage()
            {
                Message = "Unexpected error."
            }));
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 public WelcomeViewModel()
 {
     Welcome = new WelcomeModel()
     {
         Introduction = "Hello World!"
     };
 }
        public void GetWelcomeData(Action <WelcomeModel, Exception> callback)
        {
            // Use this to create design time data

            var item = new WelcomeModel("Welcome to MVVM Light [design]");

            callback(item, null);
        }
        public RootModule()
        {
            var model = new WelcomeModel {
                Name = "Andy"
            };

            Get["/"] = parameters => View["index.html", model];
        }
        public WelcomeModel GetWelcomeModelService()
        {
            var model = new WelcomeModel();
            var data  = new WelcomeRepository().GetWelcomeModelRepository();

            model.Name     = data[0];
            model.DateTime = DateTime.Parse(data[1]);
            return(model);
        }
Example #12
0
 private void AddDataInVisit(WelcomeModel user)
 {
     using (var db = new VisitContext())
     {
         db.Add(new VisitModel {
             timein = user.lastin, userid = user.id, timeout = DateTime.Now
         });
         db.SaveChanges();
     }
 }
Example #13
0
        public WelcomeModel GetWelcomeModel()
        {
            var model = new WelcomeModel();

            var data = _welcomeRepo.GetWelcomeData();

            model.Name = data[0];
            model.Date = DateTime.Parse(data[1]);

            return(model);
        }
        public IActionResult Index()
        {
            var model = new WelcomeModel
            {
                DisplayName      = "Simon Bull",
                LastSeen         = DateTime.Today.AddDays(-1).AddHours(10),
                NumberOfMessages = new Random().Next(5, 10)
            };

            return(View(model));
        }
Example #15
0
        public ActionResult Index()
        {
            TempData["Message"] = "Welcome!";

            var model = new WelcomeModel
            {
                UserName = "******",
                UserAge  = 41
            };

            return(View("Welcome", model));
        }
        public IActionResult AuthenticateUser(LoginModel model)
        {
            HttpWebRequest request = _requests.CreateLoginRequest(model);

            using (HttpWebResponse response = request.GetResponseNoException())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    _logic.AddUserDetailsToSession(model);

                    JObject deserializedResponseBody = _logic.DeserializeResponse(response);

                    var welcomeString = deserializedResponseBody.SelectToken("welcome").Value <string>();

                    var welcomeMessage = new WelcomeModel()
                    {
                        WelcomeString = welcomeString
                    };

                    return(View("Welcome", welcomeMessage));
                }

                if (response.StatusCode == HttpStatusCode.BadRequest)
                {
                    JObject deserializedResponseBody = _logic.DeserializeResponse(response);

                    try
                    {
                        var message = deserializedResponseBody.SelectToken("message").Value <string>();

                        var errorModel = new ErrorMessage()
                        {
                            Message = message
                        };

                        return(View("Error", errorModel));
                    }
                    catch
                    {
                        return(View("Error", new ErrorMessage()
                        {
                            Message = "Unexpected error."
                        }));
                    }
                }
            }

            return(View("Error", new ErrorMessage()
            {
                Message = "Unexpected error."
            }));
        }
Example #17
0
        public ActionResult SaveWelcomeText(WelcomeModel model)
        {
            var userId   = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name.Split('|')[1]);
            var userName = System.Web.HttpContext.Current.User.Identity.Name.Split('|')[0];

            model.UserID    = userId;
            model.UpdatedBy = userName;
            model.CreatedBy = userName;

            var result = _IUserService.UpdateWelcomeMessage(model);

            return(RedirectToAction("WelcomeEdit", new { success = "success" }));
        }
        private static void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                if (fileStream.Length == 0)
                {
                    Printf.warning("[WelcomeXML] O arquivo está vazio: " + path);
                }
                else
                {
                    try
                    {
                        xmlDocument.Load(fileStream);
                        for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                        {
                            if ("list".Equals(xmlNode1.Name))
                            {
                                for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                                {
                                    if ("msg".Equals(xmlNode2.Name))
                                    {
                                        XmlNamedNodeMap xml = xmlNode2.Attributes;

                                        WelcomeModel ev = new WelcomeModel
                                        {
                                            _title = xml.GetNamedItem("title").Value,
                                            _txt   = xml.GetNamedItem("text").Value,
                                            _color = short.Parse(xml.GetNamedItem("color").Value)
                                        };
                                        _welcome.Add(ev);
                                    }
                                }
                            }
                        }
                        if (_welcome.Count == 0)
                        {
                            Printf.warning("[Aviso] Não existe mensagem de boas vindas");
                        }
                    }
                    catch (XmlException ex)
                    {
                        SaveLog.fatal(ex.ToString());
                        Printf.b_danger("[WelcomeXML.Parse] Erro fatal!");
                    }
                }
                fileStream.Dispose();
                fileStream.Close();
            }
        }
Example #19
0
        public IActionResult About(WelcomeModel model)
        {
            WelcomeModel user = null;

            using (var db = new WelcomeContext())
            {
                user         = db.welcomers.Where(x => x.name == model.name && x.profession == model.profession).FirstOrDefault();
                user.lastout = DateTime.Now;
            }
            AddDataInVisit(user);
            using (var db = new VisitContext())
            {
                db.Update(user);
            }
            return(View());
        }
Example #20
0
        public async Task SendCatEmailAsync(WelcomeModel model)
        {
            var assembly = Assembly.GetAssembly(typeof(Mailer));

            using (var stream = assembly.GetManifestResourceStream($"Sample.Core.Email.Resources.GrumpyCat.jpg"))
            {
                if (stream == null)
                {
                    throw new Exception("Grumpy cat picture not found");
                }

                var         attachment = new Attachment(stream, "GrumpyCat.jpg", System.Net.Mime.MediaTypeNames.Image.Jpeg);
                MailMessage email      = _mailerEngine.Create("WelcomeFeline", model, model.Email, "Welcome to my feline application", new[] { attachment });
                await _mailerEngine.SendAsync(email);
            }
        }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     ////if (IsInDesignMode)
     ////{
     ////    // Code runs in Blend --> create design time data.
     ////}
     ////else
     ////{
     ////    // Code runs "for real"
     ////}
     ///
     WelcomeModel = new WelcomeModel()
     {
         WelcomeMsg = "Welcome to MVVMLight World!"
     };
 }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public WelcomeViewModel()
 {
     ////if (IsInDesignMode)
     ////{
     ////    // Code runs in Blend --> create design time data.
     ////}
     ////else
     ////{
     ////    // Code runs "for real"
     ////}
     ///
     WelcomeModel = new WelcomeModel()
     {
         Introduction = "Hello World"
     };
 }
Example #23
0
        /// <summary>
        /// Code change - Added Welcome controller action for editing welcome page
        /// </summary>
        /// <returns></returns>
        public ActionResult WelcomeEdit(string success)
        {
            var          userId  = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name.Split('|')[1]);
            WelcomeModel model   = new WelcomeModel();
            var          content = _IUserService.GetWelcomeNote(userId);

            model.WelcomeNote = content;

            if (success == "success")
            {
                ViewBag.EditWelcomeSuccess = "Welcome message updated successfully.";
            }
            else
            {
                ViewBag.EditWelcomeSuccess = "";
            }

            return(View(model));
        }
        public async Task <IActionResult> Complex()
        {
            MailMessage mailMessage = new MailMessage("*****@*****.**", "*****@*****.**")
            {
                IsBodyHtml = true,
                Subject    = "Complex email"
            };

            var dataModel = new WelcomeModel()
            {
                Title       = "Welcome everyone",
                Body        = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
                WWWRootPath = _webHostEnvironment.WebRootPath
            };

            var mailModel = new MailModel(mailMessage, dataModel, "Report/Complex");
            await _mailSenderClient.SendAsync(mailModel);

            return(View(dataModel));
        }
Example #25
0
        public async Task SendWelcomeTo(WelcomeModel model)
        {
            try
            {
                using (var stream = new StreamReader(File.OpenRead(Directory.GetCurrentDirectory() + templateWelcome)))
                {
                    var template = stream.ReadToEnd();
                    template = template.Replace("{{product_name}}", "Aliseeks");
                    template = template.Replace("{{name}}", model.User);
                    template = template.Replace("{{sender_name}}", "Alex");

                    await sendMail(template, model.Subject, model.Address);
                }
            }
            catch (Exception e)
            {
                var sentry = new SentryEvent(e);
                await raven.CaptureNetCoreEventAsync(sentry);
            }
        }
        public override System.Threading.Tasks.Task OnConnected()
        {
            StringBuilder greetings = new StringBuilder();

            greetings.Append(RuntimeEnvironment.OperatingSystemPlatform);
            greetings.Append($" {System.Environment.MachineName}");
            greetings.Append($" {RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion} {RuntimeEnvironment.RuntimeArchitecture}");
            greetings.Append($" {DateTime.Now}");


            WelcomeModel model = new WelcomeModel();

            model.MachineName = System.Environment.MachineName;
            model.Username    = System.Environment.GetEnvironmentVariable("LOGNAME");
            model.CurrentDir  = System.IO.Directory.GetCurrentDirectory();
            model.Greetings   = greetings.ToString();


            Clients.Client(Context.ConnectionId).onConnect(model);

            return(base.OnConnected());
        }
Example #27
0
        /// <summary>
        /// Code change - method to update or add welcome note by admin
        /// </summary>
        /// <param name="welcomeobj"></param>
        /// <returns></returns>
        public bool UpdateWelcomeMessage(WelcomeModel welcomeobj)
        {
            bool result = false;

            using (IPDEntities ctx = new IPDEntities())
            {
                try
                {
                    var welcomeNoteDetails = ctx.WelcomeNoteDetails.Where(m => m.UserID == welcomeobj.UserID && m.IsDelete != true).FirstOrDefault();
                    if (welcomeNoteDetails != null)
                    {
                        //entry exist
                        welcomeNoteDetails.IsDelete    = true;
                        welcomeNoteDetails.UpdatedDate = DateTime.UtcNow;
                        welcomeNoteDetails.UpdatedBy   = welcomeobj.UpdatedBy;
                        ctx.SaveChanges();
                    }

                    var newWelcomeNoteDetails = new WelcomeNoteDetail();
                    newWelcomeNoteDetails.WelcomeNote = string.IsNullOrEmpty(welcomeobj.WelcomeNote) ? "" : welcomeobj.WelcomeNote;
                    newWelcomeNoteDetails.IsDelete    = false;
                    newWelcomeNoteDetails.UserID      = welcomeobj.UserID;
                    newWelcomeNoteDetails.UpdatedBy   = welcomeobj.UpdatedBy;
                    newWelcomeNoteDetails.UpdatedDate = DateTime.UtcNow;
                    newWelcomeNoteDetails.CreatedBy   = welcomeobj.CreatedBy;
                    newWelcomeNoteDetails.Createddate = DateTime.UtcNow;

                    ctx.WelcomeNoteDetails.Add(newWelcomeNoteDetails);
                    ctx.SaveChanges();

                    result = true;
                }
                catch (Exception ex)
                {
                    result = false;
                }
            }
            return(result);
        }
        public override void Execute(object parameter)
        {
            // Anzeigeeinstellungen, die keiner Logik bedürfen
            var vm = new WelcomeModel
            {
                Title   = "MySamples Next - Labortechnikverwaltung",
                Version = "1.0"
            };

            // Der Presenter verwaltet Logik, die das Model nicht bedienen kann (Auswertung und Anwendung auf UI Elemente)
            view = new WelcomeView(vm);

            // Das Anzeigeeinstellung-Verwalter und Presenter-Akteur, erklärt und berechnet UI Daten, die
            // unbekannt für die View sind.
            var vctrl = new WelcomeViewController(view);

            // Dieser Controller erzeugt neue Fenster für diesen Controller
            // Erschaffung und Observieren von Fensterevents
            var wndController = new WindowController(vctrl);

            // Dieser Controller verwaltet Fenster und starte die Anzeige
            // Sammeln von Fenstern und beauftragt Fenster Parameter, wie Größe, Stil, Position, Art und Sichtbarkeit
            WindowManager.Instance.showWindow(wndController);
        }
Example #29
0
 public ActionResult Order(WelcomeModel welcome) =>
 !ModelState.IsValid
         ? View("Error") as ActionResult
         : RedirectToAction("Order", new { orderId = welcome.OrderId, dateOfBirth = welcome.DateOfBirth });
Example #30
0
 public WelcomeView(WelcomeModel model)
 {
     Model       = model;
     DataContext = Model;
 }