public IHttpActionResult UpdateReport(ReportUpdate report)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequestError(ModelState));
            }
            DataSet data = DBConnection.GetQuery(@"update [ReportServer].[dbo].[Report] set [query] = '" + report.query.Replace("'", "''") + "', [sourceid] = " + report.source.id + " where [id] = " + report.id);

            if (data == null)
            {
                return(BadRequest("Not connect to DB"));
            }
            data = DBConnection.GetQuery(@"update [ReportServer].[dbo].[Urls] set [url] = '" + report.reportName + "' where [reportId] =" + report.id);
            if (data == null)
            {
                return(BadRequest("Not connect to DB"));
            }
            return(Ok());
        }
示例#2
0
        public async Task <ActionResult> Update([Bind(Include = "ReportId,Update")] int ReportId, string Update)
        {
            ReportUpdate rptUpdate = new ReportUpdate();

            rptUpdate.ReportId     = ReportId;
            rptUpdate.Update       = Update;
            rptUpdate.AdviseStatus = false;
            rptUpdate.UserId       = User.Identity.GetUserId();
            rptUpdate.DateCreated  = DateTime.UtcNow;
            if (ModelState.IsValid)
            {
                _applicationDbContext.ReportUpdates.Add(rptUpdate);
                await _applicationDbContext.SaveChangesAsync();

                var iD = Guid.NewGuid().ToString();
                var getReportByReportId = _applicationDbContext.Reports.SingleOrDefault(rId => rId.ReportId == rptUpdate.ReportId);
                return(RedirectToAction("ReportDetails", new { Controller = "Report", action = "ReportDetails", title = getReportByReportId.Title, page = rptUpdate.ReportId, id = iD }));
            }

            return(View());
        }
示例#3
0
        public static void DownloadFileOnMainWindow(object risks)
        {
            string      msg      = "Обновление прошло успешно.";
            bool        flag     = true;
            List <Risk> newRisks = new List <Risk>();
            List <Risk> oldRisks = (List <Risk>)risks;

            Dictionary <int, int> updatelistRisks = new Dictionary <int, int>();

            try
            {
                newRisks = Utils.GetRisks();

                if (oldRisks.Count == 0 && newRisks.Count != 0)
                {
                    for (int i = 0; i < newRisks.Count; i++)
                    {
                        updatelistRisks.Add(i, -1);
                    }
                }
                else if (newRisks.Count != 0 && !oldRisks.SequenceEqual(newRisks))
                {
                    for (int i = 0; i < newRisks.Count; i++)
                    {
                        bool foundInOldRisk = false;
                        for (int j = 0; j < oldRisks.Count; j++)
                        {
                            if (newRisks[i].Id == oldRisks[j].Id)
                            {
                                foundInOldRisk = true;
                                if (!newRisks[i].Equals(oldRisks[j]))
                                {
                                    updatelistRisks.Add(i, j);
                                }
                            }
                        }
                        if (!foundInOldRisk)
                        {
                            updatelistRisks.Add(i, -1);
                        }
                    }
                }
            }
            catch (WebException)
            {
                msg  = "Ошибка! Проверьте подключение к интернету или повторите опрерацию позднее.";
                flag = false;
            } catch (Exception e)
            {
                msg  = "Ошибка! Что-то пошло не так:(";
                flag = false;
            }
            lock (locker)
            {
                if (updatelistRisks.Count != 0)
                {
                    Utils.SaveDataInJson(newRisks, BaseInicialize.basePathSave, BaseInicialize.nameSaveFile);
                }
                ReportUpdate reportUpdate = new ReportUpdate(flag, msg, updatelistRisks, newRisks, oldRisks);
                reportUpdate.ShowDialog();
            }
        }