コード例 #1
0
        private string GetPhaseValueText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder();

            foreach (var phase in alert.ModelRiskAlertPhases)
            {
                returnText.Append(phase.Phase.Title + "<br/>");
            }
            return(returnText.ToString());
        }
コード例 #2
0
 /// <summary>
 /// Delete the ModelRiskAlert.
 /// </summary>
 /// <param name="modelRiskAlert"></param>
 public static void Delete(ModelRiskAlert modelRiskAlert)
 {
     using (IdeaContext context = ContextManager.GetNewDataContext())
     {
         ModelRiskAlert mra =
             context.ModelRiskAlerts.FirstOrDefault(
                 mra2 => mra2.IDModelRiskAlert == modelRiskAlert.IDModelRiskAlert);
         context.ModelRiskAlerts.Remove(mra);
         context.SaveChanges();
     }
 }
コード例 #3
0
        /// <summary>
        /// Make a validation for ModelRiskAlert
        /// </summary>
        /// <param name="modelRiskAlert"></param>
        /// <returns></returns>
        public static bool Validate(ModelRiskAlert modelRiskAlert)
        {
            // TODO: Santiago: MAke a validation for ModelRiskAlert

            /*
             * if (string.IsNullOrEmpty(modelRiskAlert.Title))
             *  throw new ArgumentException("ModelRiskAlert title cannot be null or empty.");
             * */

            return(true);
        }
コード例 #4
0
 private bool IsAlertInList(ModelRiskAlert alert, List <ModelRiskAlert> modelRiskAlertDistinctIDsList)
 {
     foreach (ModelRiskAlert mra in modelRiskAlertDistinctIDsList)
     {
         if (mra.IDModelRiskAlert == alert.IDModelRiskAlert)
         {
             return(true);
         }
     }
     modelRiskAlertDistinctIDsList.Add(alert);
     return(false);
 }
コード例 #5
0
        private string GetPhaseValueText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder();
            List <ModelRiskAlertPhase> modelRiskAlertPhases = ModelRiskAlertHelper.GetPhases(alert);

            foreach (var modelRiskAlertPhase in modelRiskAlertPhases)
            {
                Phase phase = PhaseHelper.Get(modelRiskAlertPhase.IDPhase);
                returnText.Append(phase.Title + "<br/>");
            }
            return(returnText.ToString());
        }
コード例 #6
0
 public static List <Region> GetRegions(ModelRiskAlert modelRiskAlert)
 {
     using (IdeaContext context = ContextManager.GetNewDataContext())
     {
         return
             (context.Regions.Where(
                  r =>
                  context.ModelRiskAlertRegions.Where(
                      mrar => mrar.IDModelRiskAlert == modelRiskAlert.IDModelRiskAlert)
                  .Select(mrar2 => mrar2.IDRegion)
                  .Contains(r.IDRegion)).ToList());
     }
 }
コード例 #7
0
        /// <summary>
        /// Save the ModelRiskAlert.
        /// </summary>
        /// <param name="modelRiskAlert"></param>
        public static ModelRiskAlert Save(ModelRiskAlert modelRiskAlert)
        {
            if (modelRiskAlert.Code == string.Empty)
            {
                modelRiskAlert.Code = SystemParameterManager.GetNextCode();
                SystemParameterManager.SaveLastCode(Convert.ToInt32(modelRiskAlert.Code));
            }

            using (IdeaContext context = ContextManager.GetNewDataContext())
            {
                context.ModelRiskAlerts.AddOrUpdate(modelRiskAlert);
                context.SaveChanges();
                return(modelRiskAlert);
            }
        }
コード例 #8
0
        private string GetAccessText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder("<div align='left'><ul>");

            foreach (ModelRiskAlertPhase alertFase in alert.ModelRiskAlertPhases)
            {
                returnText.Append("<li>");
                returnText.Append("<a href='../../PMM/" + alertFase.Phase.IDPhase.ToString() + "-AP.htm'>");
                returnText.Append(alertFase.Phase.Title);
                returnText.Append("</a>");
                returnText.AppendLine("</li>");
            }

            returnText.AppendLine("</ul></div>");

            return(returnText.ToString());
        }
コード例 #9
0
        private string GetRegionsValueText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder();
            List <Region> regions    = ModelRiskAlertHelper.GetRegions(alert);

            foreach (var region in regions)
            {
                returnText.Append(region.RegionName.Trim() + ",");
            }
            string retVal = returnText.ToString();

            if (retVal.Length > 0)
            {
                return(retVal.Substring(0, retVal.Length - 1));
            }
            return(string.Empty);
        }
コード例 #10
0
        private void CopyAttachmentFilesToDir(ModelRiskAlert alert)
        {
            // Delete all files on attachment directory:
            string        folder = DirectoryAndFileHelper.ClientAppDataFolder + ConfigurationManager.AppSettings["RARDocumentsFolder"];
            DirectoryInfo downloadedMessageInfo = new DirectoryInfo(folder);

            foreach (FileInfo file in downloadedMessageInfo.GetFiles())
            {
                file.Delete();
            }

            // Generate the files for the attachments:
            foreach (ModelRiskAlertAttachment attachment in alert.ModelRiskAlertAttachments)
            {
                string path = folder + attachment.IDModelRiskAlertAttachment + "-" + attachment.AttachmentFile;
                File.WriteAllBytes(path, Convert.FromBase64String(attachment.Content));
            }
        }
コード例 #11
0
        private string GetAlertText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder("<div align='left'><table>");

            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Code"), alert.Code.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Title"), alert.Title.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Model"), alert.Model.Name.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("DateFrom"), alert.DateFrom.ToString("d", CultureInfo.InstalledUICulture)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("DateTo"), alert.DateTo.ToString("d", CultureInfo.InstalledUICulture)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Regions"), GetRegionsValueText(alert)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("RiskDescription"), alert.RiskDescription.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Action"), alert.Action.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Result"), alert.Result.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Status"), alert.Active ? ResourceHelper.GetResourceText("Active") : ResourceHelper.GetResourceText("Inactive")));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Phases"), GetPhaseValueText(alert)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Analysis"), GetAttachmentText(alert)));

            returnText.AppendLine("</table></div>");

            return(returnText.ToString());
        }
コード例 #12
0
        private string GetAlertText(ModelRiskAlert alert, List <ModelRiskAlertAttachment> alertAttachments)
        {
            StringBuilder returnText = new StringBuilder("<div align='left'><table>");
            Model         model      = ModelHelper.GetModel(alert.IDModel);

            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Code"), alert.Code.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Title"), alert.Title.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Model"), model.Name.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("DateFrom"), alert.DateFrom.ToString("d", GeneralHelper.GetDateFormat())));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("DateTo"), alert.DateTo.ToString("d", GeneralHelper.GetDateFormat())));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Regions"), GetRegionsValueText(alert)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("RiskDescription"), alert.RiskDescription.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Action"), alert.Action.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Result"), alert.Result.Trim()));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Status"), alert.Active ? ResourceHelper.GetResourceText("Active") : ResourceHelper.GetResourceText("Inactive")));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Phases"), GetPhaseValueText(alert)));
            returnText.Append(GetAlertPropertyText(ResourceHelper.GetResourceText("Analysis"), GetAttachmentText(alertAttachments)));

            returnText.AppendLine("</table></div>");

            return(returnText.ToString());
        }
コード例 #13
0
 public List <ModelRiskAlertAttachment> GetModelRiskAlertAttachments(ModelRiskAlert modelRiskAlert)
 {
     return(ModelRiskAlertAttachmentManager.GetByModelRiskAlertID(modelRiskAlert.IDModelRiskAlert));
 }
コード例 #14
0
 public List <ModelRiskAlertRegion> GetModelRiskAlertRegions(ModelRiskAlert modelRiskAlert)
 {
     return(ModelRiskAlertRegionManager.GetByModelRiskAlertID(modelRiskAlert.IDModelRiskAlert));
 }
コード例 #15
0
 public List <ModelRiskAlertPhase> GetPhases(ModelRiskAlert modelRiskAlert)
 {
     return(ModelRiskAlertManager.GetPhases(modelRiskAlert));
 }
コード例 #16
0
 public List <Region> GetRegions(ModelRiskAlert modelRiskAlert)
 {
     return(ModelRiskAlertManager.GetRegions(modelRiskAlert));
 }
コード例 #17
0
 public void Delete(ModelRiskAlert modelRiskAlert)
 {
     ModelRiskAlertManager.Delete(modelRiskAlert);
 }
コード例 #18
0
 public static List <ModelRiskAlertAttachment> GetModelRiskAlertAttachments(ModelRiskAlert modelRiskAlert)
 {
     return(GetService().GetModelRiskAlertAttachments(modelRiskAlert));
 }
コード例 #19
0
 public static List <ModelRiskAlertRegion> GetModelRiskAlertRegions(ModelRiskAlert modelRiskAlert)
 {
     return(GetService().GetModelRiskAlertRegions(modelRiskAlert));
 }
コード例 #20
0
 public static List <ModelRiskAlertPhase> GetPhases(ModelRiskAlert modelRiskAlert)
 {
     return(GetService().GetPhases(modelRiskAlert));
 }
コード例 #21
0
 private string GetAccessTitle(ModelRiskAlert alert)
 {
     return("Prevention and mitigation electoral cycle for " + alert.Code + " - " + alert.Title);
 }
コード例 #22
0
        private void btnSaveRiskAndAction_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                // Save data:
                Model model = ERMTSession.Instance.CurrentModel;
                _alert.IDModel         = model.IDModel;
                _alert.Code            = tbCode.Text;
                _alert.Title           = tbTitle.Text;
                _alert.DateFrom        = Convert.ToDateTime(dtpDateFrom.Value);
                _alert.DateTo          = Convert.ToDateTime(dtpDateTo.Value);
                _alert.RiskDescription = tbDescription.Text;
                _alert.Action          = tbAction.Text;
                _alert.Result          = tbResult.Text;
                _alert.Active          = rbStatusActive.Checked;

                List <ModelRiskAlertPhase> modelRiskAlertPhaseListToSave = new List <ModelRiskAlertPhase>();
                ModelRiskAlertPhase        modelRiskAlertPhase           = null;
                List <ModelRiskAlertPhase> modelRiskAlertPhaseList       = ModelRiskAlertHelper.GetPhases(_alert);
                foreach (var lbPhase in lbElectoralPhases.Items)
                {
                    bool found = false;
                    foreach (ModelRiskAlertPhase oPhase in modelRiskAlertPhaseList)
                    {
                        if (((ComboBoxItemFace)lbPhase).IFase.IDPhase == oPhase.IDPhase)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        modelRiskAlertPhase         = new ModelRiskAlertPhase();
                        modelRiskAlertPhase.IDPhase = ((ComboBoxItemFace)lbPhase).IFase.IDPhase;
                        modelRiskAlertPhaseListToSave.Add(modelRiskAlertPhase);
                    }
                }

                List <ModelRiskAlertRegion> modelRiskAlertRegionList      = ModelRiskAlertHelper.GetModelRiskAlertRegions(_alert);
                List <ModelRiskAlertRegion> modelRiskAlertRegionsToDelete = GetModelRiskAlertRegionsToDelete(modelRiskAlertRegionList);
                List <int> regionIDsToAdd = GetRegionIDsToAdd(modelRiskAlertRegionList);

                // Add new attachments:
                foreach (Control control in analysisPanel.Controls)
                {
                    if (control is Updater)
                    {
                        if (((Updater)control).HasFile && ((Updater)control).Id == 0)
                        {
                            ModelRiskAlertAttachment att = new ModelRiskAlertAttachment();
                            att.IDModelRiskAlert = _alert.IDModelRiskAlert;
                            att.AttachmentFile   = ((Updater)control).FileName; // Nombre del archivo, sin el ID adelante.
                            att.Content          = Convert.ToBase64String(((Updater)control).Content);

                            ModelRiskAlertHelper.SaveAttachment(att);
                        }
                    }
                }

                // Save the Alert:
                _alert = ModelRiskAlertHelper.Save(_alert);
                if (modelRiskAlertPhaseListToSave.Count > 0)
                {
                    foreach (ModelRiskAlertPhase mrap in modelRiskAlertPhaseListToSave)
                    {
                        mrap.IDModelRiskAlert = _alert.IDModelRiskAlert;
                        ModelRiskAlertHelper.SavePhase(mrap);
                    }
                }
                if (regionIDsToAdd.Count > 0)
                {
                    foreach (int regionID in regionIDsToAdd)
                    {
                        ModelRiskAlertRegion mrar = new ModelRiskAlertRegion();
                        mrar.IDModelRiskAlert = _alert.IDModelRiskAlert;
                        mrar.IDRegion         = regionID;
                        ModelRiskAlertHelper.SaveRegion(mrar);
                    }
                }
                if (modelRiskAlertRegionsToDelete.Count > 0)
                {
                    foreach (ModelRiskAlertRegion mrar in modelRiskAlertRegionsToDelete)
                    {
                        ModelRiskAlertHelper.DeleteRegion(mrar);
                    }
                }


                this.Close();
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RiskAlertSaved"));
            }
        }
コード例 #23
0
 public EditRiskAndAction(ModelRiskAlert alert)
 {
     InitializeComponent();
     _alert = alert;
 }
コード例 #24
0
 /// <summary>
 /// Saves the ModelRiskAlert (service).
 /// </summary>
 /// <param name="modelRiskAlert"></param>
 public static ModelRiskAlert Save(ModelRiskAlert modelRiskAlert)
 {
     return(GetService().Save(modelRiskAlert));
 }
コード例 #25
0
 private string GetAlertTitle(ModelRiskAlert alert)
 {
     return("Alert " + alert.Code.Trim() + " - " + alert.Title.Trim());
 }
コード例 #26
0
 public ModelRiskAlert Save(ModelRiskAlert modelRiskAlert)
 {
     return(ModelRiskAlertManager.Save(modelRiskAlert));
 }
コード例 #27
0
 public EditRiskAndAction()
 {
     InitializeComponent();
     _alert = ModelRiskAlertHelper.GetNew();
 }
コード例 #28
0
 public static void Delete(ModelRiskAlert alert)
 {
     GetService().Delete(alert);
 }