public ActionResult Create(string Groups, int Type, string Name, string Description, IEnumerable <HttpPostedFileBase> Files, DateTime BeginDate, DateTime EndDate, bool IsBroadcast = false, HttpPostedFileBase imageFile = null) { try { var IdsGroup = GetIdsFromString(Groups); var FilesDTO = GetFiles(Files); HttpFileStream imageFileStream = null; if (imageFile != null) { imageFileStream = new HttpFileStream() { InputStream = imageFile.InputStream, Name = imageFile.FileName }; } ContentService.CreateContent(IdsGroup, null, Type, Name, Description, FilesDTO, BeginDate, EndDate, IsBroadcast, imageFileStream); InternalNotification.Success("Material Created"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Update(int Id, string Adress, string Name, DateTime BirthDate, string Cellphone, string CEP, byte?Gender, int IdGroup, string Phone) { try { UserService.Update(new DAL.Users() { Id = Id, Adress = Adress, Name = Name, BirthDate = BirthDate, Cellphone = Cellphone, CEP = CEP, Gender = Gender, IdGroup = IdGroup, Phone = Phone }); InternalNotification.Success("User updated"); return(RedirectToAction("index")); } catch (Exception ex) { InternalNotification.Error(ex.Message); RedirectToAction("insert"); } return(RedirectToAction("index")); }
private int UnzipFilesToBin(string name, string zipFileLocation, string cultureCode, ref List <InternalNotification> queuedNotifications) { // unzip string languageFolder = GetLanguageFolder(cultureCode); Unzipper.UnZipFiles(zipFileLocation, languageFolder, false); // clean up Utility.WriteDebugInfo(String.Format("Deleteing '{0}' zip file at {1}", name, zipFileLocation)); if (File.Exists(zipFileLocation)) { File.Delete(zipFileLocation); } // notify string text = String.Format(Properties.Resources.LanguageInstaller_LanguageInstalledText, name); if (ApplicationMain.HasProgramLaunchedYet) { text += (" " + Properties.Resources.LanguageInstaller_RestartRequiredText); } InternalNotification n = new InternalNotification(Properties.Resources.LanguageInstaller_LanguageInstalledTitle, Utility.GetResourceString(text), null); queuedNotifications.Add(n); // done Properties.Settings.Default.CultureCode = cultureCode; int cultureCodeHash = cultureCode.GetHashCode(); return(cultureCodeHash); }
public ActionResult Update(int Id, string Name, bool IsActive = false) { try { GroupService.Update(Id, Name, IsActive); InternalNotification.Success("Group updated"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Delete(int Id) { try { GroupService.Delete(Id); InternalNotification.Success("Group Deleted"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Delete(int Id) { try { var Deleted = UserService.Delete(Id); InternalNotification.Success("User deleted"); } catch (Exception ex) { InternalNotification.Error(ex.Message); } return(RedirectToAction("index")); }
public ActionResult Insert() { try { ViewBag.Groups = GroupService.GetAll().Where(x => x.Active); return(View()); } catch (Exception ex) { InternalNotification.Error(ex); return(RedirectToAction("index")); } }
public ActionResult ResendActivationEmail(string Email) { try { UserService.ResendActiveEmail(Email, GetActiveEndPoint()); InternalNotification.Success("The email was sent"); } catch (Exception ex) { InternalNotification.Error(ex.Message); } return(RedirectToAction("index")); }
public ActionResult Update(DAL.Genres genre, int id) { try { genreService.Update(id, genre); InternalNotification.Success("Genre updated"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Edit(int Id) { try { var Group = GroupService.Find(Id); return(View(Group)); } catch (Exception ex) { InternalNotification.Error(ex); return(RedirectToAction("index")); } }
public ActionResult Create(string Name) { try { GroupService.Create(Name); string Message = "Group Created"; InternalNotification.Success(Message); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Edit(int Id) { try { var genre = genreService.Find(Id); ViewBag.Parents = genreService.GetAll(); return(View(genre)); } catch (Exception ex) { InternalNotification.Error(ex); return(RedirectToAction("index")); } }
public ActionResult Delete(int Id) { try { ContentService.Delete(Id); string Message = "Material deleted"; InternalNotification.Success(Message); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Delete(int Id) { try { var genre = genreService.Find(Id); genreService.Delete(genre); InternalNotification.Success("Genre Deleted"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Create(string name, int?idParent) { try { genreService.Create(name, idParent); string Message = "Genre Created"; InternalNotification.Success(Message); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Update(int Id, string Groups, string Name, string Description, IEnumerable <HttpPostedFileBase> Files, DateTime BeginDate, DateTime EndDate, bool IsBroadcast = false) { try { var IdsGroup = GetIdsFromString(Groups); var idsTypes = GetIdsFromString(Groups); var FilesDTO = GetFiles(Files); ContentService.UpdateContent(Id, IdsGroup, idsTypes, Name, Description, FilesDTO, BeginDate, EndDate, IsBroadcast); InternalNotification.Success("Material Updated"); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public ActionResult Insert() { try { var Groups = GroupService.GetAll().Where(x => x.Active == true); var JsonSettings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; ViewBag.Groups = JsonConvert.SerializeObject(Groups, JsonSettings); return(View()); } catch (Exception ex) { InternalNotification.Error(ex); return(RedirectToAction("index")); } }
public ActionResult Authenticate(string Email, string Password) { var AuthResult = AuthService.AuthUser(Email, Password, GlobalParams.ProjectType); if (AuthResult.IsSuccess) { Session[GlobalParams.UserSessionKey] = AuthResult; return(RedirectToAction("Index", "Material")); } else { InternalNotification.Subscribe(new AlertMessage() { Message = "Email or Password incorrect", MessageType = InternalNotificationType.error }); return(View("index")); } }
public ActionResult Edit(int Id) { try { var Content = ContentService.Find(Id); var Groups = GroupService.GetAll().Where(x => x.Active == true); var SelectedGroupIds = Content.GroupContents.Select(x => x.IdGroup); var JsonSettings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; ViewBag.Groups = JsonConvert.SerializeObject(Groups, JsonSettings); ViewBag.SelectedGroupIds = JsonConvert.SerializeObject(SelectedGroupIds, JsonSettings); return(View(Content)); } catch (Exception ex) { InternalNotification.Error(ex); return(RedirectToAction("index")); } }
public ActionResult Create(string Adress, string Name, DateTime BirthDate, string Cellphone, string CEP, string CPF, string Email, byte?Gender, int IdGroup, string Phone, string Password, string PasswordConfirmation) { if (Password != PasswordConfirmation) { InternalNotification.Error("Password does not match"); RedirectToAction("insert"); } try { var CreatedId = UserService.Create(new DAL.Users() { Name = Name, Adress = Adress, BirthDate = BirthDate, Cellphone = Cellphone, CEP = CEP, CPF = CPF, Email = Email, Gender = Gender, IdGroup = IdGroup, Phone = Phone }, Password, GetActiveEndPoint()); if (CreatedId < 1) { throw new Exception("Could not Create User"); } //InternalNotification.Success("User created"); return(RedirectToAction("UserCreated", "Home")); } catch (Exception) { InternalNotification.Error("Ocorreu um erro inesperado, por favor tente mais tarde"); return(RedirectToAction("insert")); } }
public ActionResult CreateUser(string cpf) { if (string.IsNullOrEmpty(cpf)) { InternalNotification.Subscribe(new AlertMessage() { Message = "CPF is requered", MessageType = InternalNotificationType.error }); return(View("index")); } if (UserService.Exists(cpf)) { InternalNotification.Subscribe(new AlertMessage() { Message = "There is already a user for this cpf", MessageType = InternalNotificationType.error }); return(View("index")); } return(RedirectToAction("Insert", "Users")); }
public void CreatingNotificationsUsingFactoryMethodPattern() { var email = EmailNotification.Create("*****@*****.**", "Some cool notification", "Trying out the factory method pattern"); var sms = TextMessageNotification.Create("780-444-3025", "Trying out the factory method pattern"); var notification = InternalNotification.Create(8252, "Some cool notificatio", "Trying out the factory method pattern"); }
public bool LaunchInstaller(string uri, bool appIsAlreadyRunning, ref List<InternalNotification> queuedNotifications) { bool newDisplayLoaded = false; this.uri = uri; this.appIsAlreadyRunning = appIsAlreadyRunning; this.tempFolder = Path.Combine(Utility.UserSettingFolder, TEMP_FOLDER); try { this.wc = new Growl.CoreLibrary.WebClientEx(); wc.Headers.Add("User-Agent", USER_AGENT); byte[] data = wc.DownloadData(this.uri); string definition = Encoding.UTF8.GetString(data).Trim(); DisplayInfo info = DisplayInfo.Parse(definition); if (info != null) { this.InfoLabel.Text = String.Format(Utility.GetResourceString(Properties.Resources.DisplayInstaller_Prompt), info.Name, info.Author, info.Description); this.YesButton.Visible = true; this.NoButton.Visible = true; this.OKButton.Visible = false; /* NOTE: there is a bug that is caused when Growl is launched via protocol handler (growl:) from Opera. * when that happens, the call to ShowDialog hangs. * i could not find any documentation on this or any reason why it would be happening (not on a non-ui thread, windows handle is already created, etc). * the only fix i could find was to Show/Hide the form before calling ShowDialog. i dont even know why this works, but it does. * */ this.Show(); this.Hide(); DialogResult result = this.ShowDialog(); if (result == DialogResult.Yes) { this.InfoLabel.Text = Utility.GetResourceString(Properties.Resources.DisplayInstaller_Installing); this.progressBar1.Value = 0; this.progressBar1.Visible = true; this.YesButton.Enabled = false; this.NoButton.Enabled = false; this.Show(); this.Refresh(); if (Directory.Exists(this.tempFolder)) Directory.Delete(this.tempFolder, true); Directory.CreateDirectory(this.tempFolder); string zipFileName = Path.Combine(this.tempFolder, String.Format("{0}.zip", System.Guid.NewGuid().ToString())); info.LocalZipFileLocation = zipFileName; wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted); StartDownload(info); Utility.WriteDebugInfo(String.Format("Downloading display '{0}' to {1}", info.Name, info.LocalZipFileLocation)); System.Threading.WaitHandle[] handles = new System.Threading.WaitHandle[] { are, mre }; while (System.Threading.WaitHandle.WaitAny(handles) == 0) { lock (this.progress_lock) { this.progressBar1.Value = this.progress.ProgressPercentage; Application.DoEvents(); } } this.progressBar1.Value = 100; Application.DoEvents(); Utility.WriteDebugInfo(String.Format("Finished downloading display '{0}' to {1}", info.Name, info.LocalZipFileLocation)); if (this.errorMessage == null) { // unzip files to the correct location string newDisplayFolder = Path.Combine(DisplayStyleManager.UserDisplayStyleDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(info.Name)); if (!ApplicationMain.HasProgramLaunchedYet || !Directory.Exists(newDisplayFolder)) { Utility.WriteDebugInfo(String.Format("Display '{0}' downloaded - starting unzip.", info.Name)); Unzipper.UnZipFiles(info.LocalZipFileLocation, newDisplayFolder, false); InternalNotification n = new InternalNotification(Properties.Resources.DisplayInstaller_NewDisplayInstalledTitle, String.Format(Utility.GetResourceString(Properties.Resources.DisplayInstaller_NewDisplayInstalledText), info.Name), info.Name); queuedNotifications.Add(n); newDisplayLoaded = true; this.Close(); } else { // display with the same name aleady exists... ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.DisplayInstaller_AlreadyInstalled), info.Name)); } // clean up Utility.WriteDebugInfo(String.Format("Deleteing '{0}' zip file at {1}", info.Name, info.LocalZipFileLocation)); if (File.Exists(info.LocalZipFileLocation)) File.Delete(info.LocalZipFileLocation); } else { Utility.WriteDebugInfo(String.Format("Error downloading display '{0}'.", info.Name)); ShowMessage(errorMessage); } } } else { // definition file was malformed ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.DisplayInstaller_BadDefinitionFile), this.uri)); } } catch (Exception ex) { // error downloading definition file Utility.WriteDebugInfo(String.Format("Error downloading display. {0} - {1}", ex.Message, ex.StackTrace)); ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.DisplayInstaller_NonexistentDefinitionFile), this.uri)); } return newDisplayLoaded; }
public bool LaunchInstaller(string uri, bool appIsAlreadyRunning, ref List <InternalNotification> queuedNotifications, ref int cultureCodeHash) { bool installed = false; this.uri = uri; this.appIsAlreadyRunning = appIsAlreadyRunning; this.tempFolder = Path.Combine(Utility.UserSettingFolder, TEMP_FOLDER); try { this.wc = new Growl.CoreLibrary.WebClientEx(); wc.Headers.Add("User-Agent", USER_AGENT); byte[] data = wc.DownloadData(this.uri); string definition = Encoding.UTF8.GetString(data).Trim(); SubscriberInfo info = SubscriberInfo.Parse(definition); if (info != null) { this.InfoLabel.Text = String.Format(Utility.GetResourceString(Properties.Resources.SubscriberInstaller_Prompt), info.Name, info.Author, info.Description); this.YesButton.Visible = true; this.NoButton.Visible = true; this.OKButton.Visible = false; /* NOTE: there is a bug that is caused when Growl is launched via protocol handler (growl:) from Opera. * * when that happens, the call to ShowDialog hangs. * * i could not find any documentation on this or any reason why it would be happening (not on a non-ui thread, windows handle is already created, etc). * * the only fix i could find was to Show/Hide the form before calling ShowDialog. i dont even know why this works, but it does. * * */ this.Show(); this.Hide(); DialogResult result = this.ShowDialog(); if (result == DialogResult.Yes) { this.InfoLabel.Text = Utility.GetResourceString(Properties.Resources.SubscriberInstaller_Installing); this.progressBar1.Value = 0; this.progressBar1.Visible = true; this.YesButton.Enabled = false; this.NoButton.Enabled = false; this.Show(); this.Refresh(); if (Directory.Exists(this.tempFolder)) { Directory.Delete(this.tempFolder, true); } Directory.CreateDirectory(this.tempFolder); string zipFileName = Path.Combine(this.tempFolder, String.Format("{0}.zip", System.Guid.NewGuid().ToString())); info.LocalZipFileLocation = zipFileName; wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted); StartDownload(info); Utility.WriteDebugInfo(String.Format("Downloading subscriber plugin '{0}' to {1}", info.Name, info.LocalZipFileLocation)); System.Threading.WaitHandle[] handles = new System.Threading.WaitHandle[] { are, mre }; while (System.Threading.WaitHandle.WaitAny(handles) == 0) { lock (this.progress_lock) { this.progressBar1.Value = this.progress.ProgressPercentage; Application.DoEvents(); } } this.progressBar1.Value = 100; Application.DoEvents(); Utility.WriteDebugInfo(String.Format("Finished downloading subscriber plugin '{0}' to {1}", info.Name, info.LocalZipFileLocation)); if (this.errorMessage == null) { // unzip files to the correct location string folder = Path.Combine(SubscriptionManager.UserPluginDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(info.Name)); if (!ApplicationMain.HasProgramLaunchedYet || !Directory.Exists(folder)) { Utility.WriteDebugInfo(String.Format("Subscriber '{0}' downloaded - starting unzip.", info.Name)); Unzipper.UnZipFiles(info.LocalZipFileLocation, folder, false); string text = String.Format(Properties.Resources.SubscriberInstaller_InstalledText, info.Name); InternalNotification n = new InternalNotification(Properties.Resources.SubscriberInstaller_InstalledTitle, Utility.GetResourceString(text), null); queuedNotifications.Add(n); installed = true; this.Close(); } else { // display with the same name aleady exists... ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.SubscriberInstaller_AlreadyInstalled), info.Name), true); } // clean up Utility.WriteDebugInfo(String.Format("Deleteing '{0}' zip file at {1}", info.Name, info.LocalZipFileLocation)); if (File.Exists(info.LocalZipFileLocation)) { File.Delete(info.LocalZipFileLocation); } } else { Utility.WriteDebugInfo(String.Format("Error downloading subscriber plugin '{0}'.", info.Name)); ShowMessage(errorMessage, true); } } } else { // definition file was malformed ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.SubscriberInstaller_BadDefinitionFile), this.uri), true); } } catch (Exception ex) { // error downloading definition file Utility.WriteDebugInfo(String.Format("Error downloading subscriber plugin. {0} - {1}", ex.Message, ex.StackTrace)); ShowMessage(String.Format(Utility.GetResourceString(Properties.Resources.SubscriberInstaller_NonexistentDefinitionFile), this.uri), true); } return(installed); }
private int UnzipFilesToBin(string name, string zipFileLocation, string cultureCode, ref List<InternalNotification> queuedNotifications) { // unzip string languageFolder = GetLanguageFolder(cultureCode); Unzipper.UnZipFiles(zipFileLocation, languageFolder, false); // clean up Utility.WriteDebugInfo(String.Format("Deleteing '{0}' zip file at {1}", name, zipFileLocation)); if (File.Exists(zipFileLocation)) File.Delete(zipFileLocation); // notify string text = String.Format(Properties.Resources.LanguageInstaller_LanguageInstalledText, name); if (ApplicationMain.HasProgramLaunchedYet) text += (" " + Properties.Resources.LanguageInstaller_RestartRequiredText); InternalNotification n = new InternalNotification(Properties.Resources.LanguageInstaller_LanguageInstalledTitle, Utility.GetResourceString(text), null); queuedNotifications.Add(n); // done Properties.Settings.Default.CultureCode = cultureCode; int cultureCodeHash = cultureCode.GetHashCode(); return cultureCodeHash; }