Beispiel #1
0
        /// <summary>
        /// Opens a new report.
        /// </summary>
        public int Open(IUser user, OverloadNode overload, ReportBody info, ReportTag tag)
        {
            Reports.Add(new Report(CaseCount, overload, user, info, tag));
            int id = CaseCount;

            CaseCount++;
            return(id);
        }
Beispiel #2
0
 private Report(int id, string commandId, string title, string content, ReportTag tag)
 {
     Id        = id;
     CommandId = commandId;
     Author    = new Author(OriGlobal.ClientName);
     Title     = title;
     Content   = content;
     Tag       = tag;
 }
Beispiel #3
0
 internal Report(int id, OverloadNode overload, IUser user, ReportBody reportInfo, ReportTag tag)
 {
     Id        = id;
     CommandId = overload.Id;
     Author    = new Author(user);
     CreatedAt = DateTime.UtcNow;
     Title     = reportInfo.Title;
     Content   = reportInfo.Content;
     ImageUrl  = reportInfo.ImageUrl;
     Tag       = tag;
     State     = ReportState.Open;
     Votes     = new List <VoteInfo>();
 }
Beispiel #4
0
 internal Report(int id, string commandId, Author author, DateTime createdAt,
                 DateTime?editedAt, string title, string content, string imageUrl, ReportBody lastInfo, ReportState status,
                 List <VoteInfo> votes, ReportTag tag)
 {
     Id        = id;
     CommandId = commandId;
     Author    = author;
     CreatedAt = createdAt;
     EditedAt  = editedAt;
     Title     = title;
     Content   = content;
     ImageUrl  = imageUrl;
     LastInfo  = lastInfo;
     Tag       = tag;
     State     = status;
     Votes     = votes ?? new List <VoteInfo>();
 }
        public string GetReportTagDescription()
        {
            ReportTag tag           = GetReportTag();
            Return    returnForYear = organisation.GetReturn(ReportingYear);

            switch (tag)
            {
            case ReportTag.Overdue:
                return("This report was due on " + GetReportingDeadline().ToGDSDate().FullStartDate);

            case ReportTag.Submitted:
            case ReportTag.SubmittedLate:
                return("Reported on " + returnForYear.Modified.ToGDSDate().FullStartDate);

            default:
                return(null);
            }
        }
Beispiel #6
0
        public UserIDWithAllReport GetAllBussinessDistricReport(string sessionId)
        {
            UserInformation user = GetSession(sessionId).userInformation;

            if (user == null)
            {
                return(null);
            }
            UserIDWithAllReport result = new UserIDWithAllReport();
            ReportTag           tag    = new ReportTag();

            tag.date      = DateTime.Now;
            tag.reportId  = 100;
            result.userId = user.userId;
            result.allReports.Add(tag);
            result.allReports.Add(tag);
            return(result);
        }
Beispiel #7
0
        private void FillBasicListView(TreeNode[] FormatCellNode)
        {
            string opentag  = ReportTag.StrOpen;
            string closetag = ReportTag.StrClose;
            string septag   = ReportTag.DbSeparator;

            string strOpenParen  = ReportTag.StrOpenParen.ToString();
            string strSepArg     = ReportTag.ParamDelim.ToString();
            string strCloseParen = ReportTag.StrCloseParen.ToString();

            tvFields.Nodes.Clear();
            #region SysTag
            TreeNode Config = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strConfig));
            Config.ImageIndex         = imgConfig;
            Config.SelectedImageIndex = Config.ImageIndex;

            TreeNode ConfigSheet = Config.Nodes.Add(FldMessages.GetString(FldMsg.strConfig));
            ConfigSheet.ImageIndex         = imgFullConfig;
            ConfigSheet.SelectedImageIndex = ConfigSheet.ImageIndex;

            foreach (ConfigTagEnum tag in Enum.GetValues(typeof(ConfigTagEnum)))
            {
                string   s         = ReportTag.ConfigTag(tag);
                TreeNode n         = Config.Nodes.Add(s.ToUpper());
                string   ParamList = ReportTag.ConfigTagParams(tag);
                string[] sc        = { n.Text + ParamList, n.Text };
                n.ImageIndex         = imgConfigTag;
                n.SelectedImageIndex = n.ImageIndex;
                n.Tag = sc;
            }

            TreeNode Extras = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strExtras));
            Extras.ImageIndex         = imgExtras;
            Extras.SelectedImageIndex = Extras.ImageIndex;


            foreach (string s in ReportTag.TagTableKeys)
            {
                TreeNode n         = Extras.Nodes.Add(s.ToLower());
                string   ParamList = string.Empty;
                int      ParamCount;
                if (ReportTag.TryGetTagParams(s, out ParamCount))
                {
                    if (ParamCount > 0)
                    {
                        ParamList = strOpenParen.PadRight(strOpenParen.Length + ParamCount - 1, strSepArg[0]) + strCloseParen;
                    }
                }
                string[] sc = { opentag + n.Text + ParamList + closetag, n.Text };
                n.ImageIndex         = imgOneExtra;
                n.SelectedImageIndex = n.ImageIndex;
                n.Tag = sc;
                TValueType TagDef;
                if (ReportTag.TryGetTag(s, out TagDef))
                {
                    if (TagDef == TValueType.IF)
                    {
                        FillIfListView(n);
                    }
                    if (TagDef == TValueType.FormatCell && FormatCellNode != null)
                    {
                        FormatCellNode[0] = n;
                    }
                }
            }
            #endregion
            #region My Tags

            //DataSet
            TreeNode root = tvFields.Nodes.Add("DataSet");
            root.ImageIndex         = imgDataset;
            root.SelectedImageIndex = root.ImageIndex;

            foreach (dData dt in _xlsConfig.Data)
            {
                TreeNode rdt = root.Nodes.Add(dt.TableName);
                rdt.ImageIndex         = imgTable;
                rdt.SelectedImageIndex = rdt.ImageIndex;
                foreach (dField f in dt.Fields)
                {
                    TreeNode temp = rdt.Nodes.Add(f.Name);
                    temp.Text               = f.Name;
                    temp.ImageIndex         = imgColumn;
                    temp.SelectedImageIndex = temp.ImageIndex;
                    string[] sc = { f.TableName, f.Name, temp.Text };
                    temp.Tag = sc;
                }
                TreeNode tempcount = rdt.Nodes.Add("ROWCOUNT");
                tempcount.Text               = "ROWCOUNT";
                tempcount.ImageIndex         = imgColumn;
                tempcount.SelectedImageIndex = tempcount.ImageIndex;
                string[] scx = new string[] { dt.TableName, "#ROWCOUNT", "#ROWCOUNT" };
                tempcount.Tag = scx;

                TreeNode temppos = rdt.Nodes.Add("ROWPOS");
                temppos.Text               = "ROWPOS";
                temppos.ImageIndex         = imgColumn;
                temppos.SelectedImageIndex = temppos.ImageIndex;
                scx         = new string[] { dt.TableName, "#ROWPOS", "#ROWPOS" };
                temppos.Tag = scx;
            }
            //Expression
            TreeNode rootExp = tvFields.Nodes.Add("Expressions");
            rootExp.ImageIndex         = imgReportExpList;
            rootExp.SelectedImageIndex = rootExp.ImageIndex;

            foreach (dExpressions dt in _xlsConfig.Expression)
            {
                TreeNode rdt = rootExp.Nodes.Add(dt.Name);
                rdt.ImageIndex         = imgReportExp;
                rdt.SelectedImageIndex = rdt.ImageIndex;
                string[] sc = { dt.Name };
                rdt.Tag = sc;
            }
            //Variables
            TreeNode rootVal = tvFields.Nodes.Add("Variables");
            rootVal.ImageIndex         = imgReportVarList;
            rootVal.SelectedImageIndex = rootVal.ImageIndex;

            foreach (dReportVariables dt in _xlsConfig.ReportVariable)
            {
                TreeNode rdt = rootVal.Nodes.Add(dt.Name);
                rdt.ImageIndex         = imgReportVar;
                rdt.SelectedImageIndex = rdt.ImageIndex;
                string[] sc = { dt.Name };
                rdt.Tag = sc;
            }

            //Format
            TreeNode rootFor = tvFields.Nodes.Add("Formats");
            rootFor.ImageIndex         = imgReportFormatList;
            rootFor.SelectedImageIndex = rootFor.ImageIndex;

            foreach (dFormat dt in _xlsConfig.Format)
            {
                TreeNode rdt = rootFor.Nodes.Add(dt.Name);
                rdt.ImageIndex         = imgReportFormat;
                rdt.SelectedImageIndex = rdt.ImageIndex;
                string[] sc = { dt.Value };
                rdt.Tag = sc;
            }

            /*
             #region DataField
             * TreeNode root = tvFields.Nodes.Add("DataField");
             * root.ImageIndex = imgDataset;
             * root.SelectedImageIndex = root.ImageIndex;
             *
             * if (dt_list != null)
             * {
             *  foreach (DataRow row in dt_list.Rows)
             *  {
             *      TreeNode temp = root.Nodes.Add(row["Code"].ToString());
             *      temp.Text = row["Name"].ToString();
             *      temp.ImageIndex = imgColumn;
             *      temp.SelectedImageIndex = temp.ImageIndex;
             *      string[] sc = { dt_list.TableName, row["Code"].ToString(), temp.Text };
             *      temp.Tag = sc;
             *  }
             *  TreeNode tmp = root.Nodes.Add("#ROWPOS");
             *  tmp.Text = "#ROWPOS";
             *  tmp.ImageIndex = imgColumn;
             *  tmp.SelectedImageIndex = tmp.ImageIndex;
             *  string[] src = new string[] { dt_list.TableName, tmp.Text, tmp.Text };
             *  tmp.Tag = src;
             *
             *  tmp = root.Nodes.Add("#ROWCOUNT");
             *  tmp.Text = "#ROWCOUNT";
             *  tmp.ImageIndex = imgColumn;
             *  tmp.SelectedImageIndex = tmp.ImageIndex;
             *  src = new string[] { dt_list.TableName, tmp.Text, tmp.Text };
             *  tmp.Tag = src;
             * }
             *
             *
             #endregion DataField
             *
             #region Params
             * TreeNode rootParams = tvFields.Nodes.Add("DataParams");
             * rootParams.ImageIndex = imgDataset;
             * rootParams.SelectedImageIndex = rootParams.ImageIndex;
             *
             * if (dt_Params != null)
             * {
             *  foreach (DataRow row in dt_Params.Rows)
             *  {
             *      TreeNode temp = rootParams.Nodes.Add(row["Code"].ToString());
             *      temp.Text = row["Name"].ToString();
             *      temp.ImageIndex = imgColumn;
             *      temp.SelectedImageIndex = temp.ImageIndex;
             *      string[] sc = { dt_Params.TableName, row["Code"].ToString(), temp.Text };
             *      temp.Tag = sc;
             *  }
             *
             *  TreeNode tmp = rootParams.Nodes.Add("#ROWPOS");
             *  tmp.Text = "#ROWPOS";
             *  tmp.ImageIndex = imgColumn;
             *  tmp.SelectedImageIndex = tmp.ImageIndex;
             *  string[] src = new string[] { dt_Params.TableName, tmp.Text, tmp.Text };
             *  tmp.Tag = src;
             *
             *  tmp = rootParams.Nodes.Add("#ROWCOUNT");
             *  tmp.Text = "#ROWCOUNT";
             *  tmp.ImageIndex = imgColumn;
             *  tmp.SelectedImageIndex = tmp.ImageIndex;
             *  src = new string[] { dt_Params.TableName, tmp.Text, tmp.Text };
             *  tmp.Tag = src;
             * }
             #endregion
             */
            #region Function

            TreeNode root1 = tvFields.Nodes.Add("Functions");
            root1.ImageIndex         = imgUserDefined;
            root1.SelectedImageIndex = root1.ImageIndex;
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(Properties.Resources.MyFunc);
            XmlElement element = xmlDoc.DocumentElement;
            foreach (XmlElement node in element.ChildNodes)
            {
                string   code = node.GetAttribute("Code");
                TreeNode tmp  = root1.Nodes.Add(code);
                tmp.ImageIndex         = imgUserDefinedColumn;
                tmp.SelectedImageIndex = tmp.ImageIndex;
                tmp.Text = node.GetAttribute("Code");
                string[] src = new string[] { "", node.GetAttribute("Value"), tmp.Text };
                tmp.Tag = src;
            }

            #endregion Function

            /*
             #region Parameter
             * TreeNode rootfilter = tvFields.Nodes.Add("Parameter");
             * rootfilter.ImageIndex = imgReportExpList;
             * rootfilter.SelectedImageIndex = rootfilter.ImageIndex;
             * if (dt_Filter != null)
             * {
             *  foreach (DataRow row in dt_Filter.Rows)
             *  {
             *      TreeNode tmp = rootfilter.Nodes.Add(row["Code"].ToString());
             *      tmp.ImageIndex = imgReportExp;
             *      tmp.SelectedImageIndex = tmp.ImageIndex;
             *      tmp.Text = row["Name"].ToString();
             *      string[] src = new string[] { row["Code"].ToString() };
             *      tmp.Tag = src;
             *  }
             * }
             *
             #endregion Parameter
             */
            #endregion My Tags
        }
Beispiel #8
0
        /// <summary>
        ///     Writes all the properties that are part of the <see cref="Email"/> object either as <see cref="CFStorage"/>'s
        ///     or <see cref="CFStream"/>'s to the <see cref="CompoundFile.RootStorage"/>
        /// </summary>
        internal void WriteToStorage()
        {
            var rootStorage = CompoundFile.RootStorage;

            if (Class == MessageClass.Unknown)
            {
                Class = MessageClass.IPM_Note;
            }

            MessageSize += Recipients.WriteToStorage(rootStorage);
            MessageSize += Attachments.WriteToStorage(rootStorage);

            var recipientCount  = Recipients.Count;
            var attachmentCount = Attachments.Count;

            TopLevelProperties.RecipientCount   = recipientCount;
            TopLevelProperties.AttachmentCount  = attachmentCount;
            TopLevelProperties.NextRecipientId  = recipientCount;
            TopLevelProperties.NextAttachmentId = attachmentCount;

            TopLevelProperties.AddProperty(PropertyTags.PR_ENTRYID, Mapi.GenerateEntryId());
            TopLevelProperties.AddProperty(PropertyTags.PR_INSTANCE_KEY, Mapi.GenerateInstanceKey());
            TopLevelProperties.AddProperty(PropertyTags.PR_STORE_SUPPORT_MASK, StoreSupportMaskConst.StoreSupportMask, PropertyFlags.PROPATTR_READABLE);
            TopLevelProperties.AddProperty(PropertyTags.PR_STORE_UNICODE_MASK, StoreSupportMaskConst.StoreSupportMask, PropertyFlags.PROPATTR_READABLE);
            TopLevelProperties.AddProperty(PropertyTags.PR_ALTERNATE_RECIPIENT_ALLOWED, true, PropertyFlags.PROPATTR_READABLE);
            TopLevelProperties.AddProperty(PropertyTags.PR_HASATTACH, attachmentCount > 0);

            if (TransportMessageHeaders != null)
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_TRANSPORT_MESSAGE_HEADERS_W, TransportMessageHeaders.ToString());

                if (!string.IsNullOrWhiteSpace(TransportMessageHeaders.MessageId))
                {
                    TopLevelProperties.AddProperty(PropertyTags.PR_INTERNET_MESSAGE_ID_W, TransportMessageHeaders.MessageId);
                }

                if (TransportMessageHeaders.References.Any())
                {
                    TopLevelProperties.AddProperty(PropertyTags.PR_INTERNET_REFERENCES_W, TransportMessageHeaders.References.Last());
                }

                if (TransportMessageHeaders.InReplyTo.Any())
                {
                    TopLevelProperties.AddProperty(PropertyTags.PR_IN_REPLY_TO_ID_W, TransportMessageHeaders.InReplyTo.Last());
                }
            }

            if (!string.IsNullOrWhiteSpace(InternetMessageId))
            {
                TopLevelProperties.AddOrReplaceProperty(PropertyTags.PR_INTERNET_MESSAGE_ID_W, InternetMessageId);
            }

            if (!string.IsNullOrWhiteSpace(InternetReferences))
            {
                TopLevelProperties.AddOrReplaceProperty(PropertyTags.PR_INTERNET_REFERENCES_W, InternetReferences);
            }

            if (!string.IsNullOrWhiteSpace(InReplyToId))
            {
                TopLevelProperties.AddOrReplaceProperty(PropertyTags.PR_IN_REPLY_TO_ID_W, InReplyToId);
            }

            var messageFlags = MessageFlags.MSGFLAG_UNMODIFIED;

            if (attachmentCount > 0)
            {
                messageFlags |= MessageFlags.MSGFLAG_HASATTACH;
            }

            TopLevelProperties.AddProperty(PropertyTags.PR_INTERNET_CPID, Encoding.UTF8.CodePage);

            TopLevelProperties.AddProperty(PropertyTags.PR_BODY_W, BodyText);

            if (!string.IsNullOrEmpty(BodyHtml) && !Draft)
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_HTML, BodyHtml);
                TopLevelProperties.AddProperty(PropertyTags.PR_RTF_IN_SYNC, false);
            }
            else if (string.IsNullOrWhiteSpace(BodyRtf) && !string.IsNullOrWhiteSpace(BodyHtml))
            {
                BodyRtf           = Strings.GetEscapedRtf(BodyHtml);
                BodyRtfCompressed = true;
            }

            if (!string.IsNullOrWhiteSpace(BodyRtf))
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_RTF_COMPRESSED, new RtfCompressor().Compress(Encoding.ASCII.GetBytes(BodyRtf)));
                TopLevelProperties.AddProperty(PropertyTags.PR_RTF_IN_SYNC, BodyRtfCompressed);
            }

            if (MessageEditorFormat != MessageEditorFormat.EDITOR_FORMAT_DONTKNOW)
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_MSG_EDITOR_FORMAT, MessageEditorFormat);
            }

            if (!SentOn.HasValue)
            {
                SentOn = DateTime.UtcNow;
            }

            if (ReceivedOn.HasValue)
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_MESSAGE_DELIVERY_TIME, ReceivedOn.Value.ToUniversalTime());
            }

            TopLevelProperties.AddProperty(PropertyTags.PR_CLIENT_SUBMIT_TIME, SentOn.Value.ToUniversalTime());
            TopLevelProperties.AddProperty(PropertyTags.PR_ACCESS, MapiAccess.MAPI_ACCESS_DELETE | MapiAccess.MAPI_ACCESS_MODIFY | MapiAccess.MAPI_ACCESS_READ);
            TopLevelProperties.AddProperty(PropertyTags.PR_ACCESS_LEVEL, MapiAccess.MAPI_ACCESS_MODIFY);
            TopLevelProperties.AddProperty(PropertyTags.PR_OBJECT_TYPE, MapiObjectType.MAPI_MESSAGE);

            SetSubject();
            TopLevelProperties.AddProperty(PropertyTags.PR_SUBJECT_W, Subject);
            TopLevelProperties.AddProperty(PropertyTags.PR_NORMALIZED_SUBJECT_W, SubjectNormalized);
            TopLevelProperties.AddProperty(PropertyTags.PR_SUBJECT_PREFIX_W, SubjectPrefix);
            TopLevelProperties.AddProperty(PropertyTags.PR_CONVERSATION_TOPIC_W, SubjectNormalized);

            // http://www.meridiandiscovery.com/how-to/e-mail-conversation-index-metadata-computer-forensics/
            // http://stackoverflow.com/questions/11860540/does-outlook-embed-a-messageid-or-equivalent-in-its-email-elements
            //propertiesStream.AddProperty(PropertyTags.PR_CONVERSATION_INDEX, Subject);

            // TODO: Change modification time when this message is opened and only modified
            var utcNow = DateTime.UtcNow;

            TopLevelProperties.AddProperty(PropertyTags.PR_CREATION_TIME, utcNow);
            TopLevelProperties.AddProperty(PropertyTags.PR_LAST_MODIFICATION_TIME, utcNow);
            TopLevelProperties.AddProperty(PropertyTags.PR_PRIORITY, Priority);
            TopLevelProperties.AddProperty(PropertyTags.PR_IMPORTANCE, Importance);
            TopLevelProperties.AddProperty(PropertyTags.PR_MESSAGE_LOCALE_ID, CultureInfo.CurrentCulture.LCID);

            if (Draft)
            {
                messageFlags |= MessageFlags.MSGFLAG_UNSENT;
                IconIndex     = MessageIconIndex.UnsentMail;
            }

            if (ReadRecipient)
            {
                TopLevelProperties.AddProperty(PropertyTags.PR_READ_RECEIPT_REQUESTED, true);
                var reportTag = new ReportTag {
                    ANSIText = Subject
                };
                TopLevelProperties.AddProperty(PropertyTags.PR_REPORT_TAG, reportTag.ToByteArray());
            }

            TopLevelProperties.AddProperty(PropertyTags.PR_MESSAGE_FLAGS, messageFlags);
            TopLevelProperties.AddProperty(PropertyTags.PR_ICON_INDEX, IconIndex);

            Sender?.WriteProperties(TopLevelProperties);
            Receiving?.WriteProperties(TopLevelProperties);
            Representing?.WriteProperties(TopLevelProperties);
            ReceivingRepresenting?.WriteProperties(TopLevelProperties);

            if (recipientCount > 0)
            {
                var displayTo  = new List <string>();
                var displayCc  = new List <string>();
                var displayBcc = new List <string>();

                foreach (var recipient in Recipients)
                {
                    switch (recipient.RecipientType)
                    {
                    case RecipientType.To:
                        if (!string.IsNullOrWhiteSpace(recipient.DisplayName))
                        {
                            displayTo.Add(recipient.DisplayName);
                        }
                        else if (!string.IsNullOrWhiteSpace(recipient.Email))
                        {
                            displayTo.Add(recipient.Email);
                        }
                        break;

                    case RecipientType.Cc:
                        if (!string.IsNullOrWhiteSpace(recipient.DisplayName))
                        {
                            displayCc.Add(recipient.DisplayName);
                        }
                        else if (!string.IsNullOrWhiteSpace(recipient.Email))
                        {
                            displayCc.Add(recipient.Email);
                        }
                        break;

                    case RecipientType.Bcc:
                        if (!string.IsNullOrWhiteSpace(recipient.DisplayName))
                        {
                            displayBcc.Add(recipient.DisplayName);
                        }
                        else if (!string.IsNullOrWhiteSpace(recipient.Email))
                        {
                            displayBcc.Add(recipient.Email);
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                TopLevelProperties.AddProperty(PropertyTags.PR_DISPLAY_TO_W, string.Join(";", displayTo), PropertyFlags.PROPATTR_READABLE);
                TopLevelProperties.AddProperty(PropertyTags.PR_DISPLAY_CC_W, string.Join(";", displayCc), PropertyFlags.PROPATTR_READABLE);
                TopLevelProperties.AddProperty(PropertyTags.PR_DISPLAY_BCC_W, string.Join(";", displayBcc), PropertyFlags.PROPATTR_READABLE);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Entrada de dados genéricos de Relatório
        /// </summary>
        /// <param name="data">Informações no formato Json</param>
        /// <param name="applicationCode"></param>
        /// <param name="logControlId"></param>
        /// <param name="tags"></param>
        /// <param name="reportTypeCode"></param>
        /// <returns></returns>
        public bool AddEntry(string data, string applicationCode, string logControlId, List <string> tags, string reportTypeCode)
        {
            Report report = new Report();

            report.NewId();
            report.Data = data;

            report.Application = db.Applications
                                 .SingleOrDefault(x => x.Code == applicationCode);


            if (report.Application == null)
            {
                report.Application = new Application();
                report.Application.NewId();
                report.Application.Code = applicationCode;
            }

            report.LogControl = db.LogControls
                                .SingleOrDefault(x => x.Id == logControlId);
            if (report.LogControl == null)
            {
                report.LogControl = new LogControl();
                report.LogControl.NewId();
            }

            report.Type = db.ReportTypes
                          .SingleOrDefault(x => x.Name == reportTypeCode);
            if (report.Type == null)
            {
                report.Type = new ReportType();
                report.Type.NewId();
                report.Type.Code = reportTypeCode;
            }

            db.Reports.Add(report);
            db.SaveChanges();

            List <ReportTag> listReportTags = new List <ReportTag>();

            foreach (string tag in tags)
            {
                ReportTag reportTag = new ReportTag();
                reportTag.Report = report;

                Tag newTag = db.Tags.Where(x => x.Name == tag).FirstOrDefault();

                if (newTag == null)
                {
                    newTag      = new Tag();
                    newTag.Name = tag;
                    newTag.NewId();
                    db.Add(newTag);
                    db.SaveChanges();
                }

                reportTag.Tag = newTag;
                listReportTags.Add(reportTag);
            }

            db.AddRange(listReportTags);
            db.SaveChanges();


            return(true);
        }