Exemplo n.º 1
0
        public ActionResult Create(TaggingGroup tagginggroup)
        {
            if (ModelState.IsValid)
            {
                tagginggroup.Owner     = User.Identity.Name;
                tagginggroup.CreatedAt = DateTime.Now;

                db.TaggingGroups.Add(tagginggroup);
                db.SaveChanges();

                var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new UserDbContext()));

                var user = new ApplicationUser()
                {
                    UserName = tagginggroup.UserName
                };
                var result = userManager.Create(user, tagginggroup.Password);

                user = userManager.FindByName(tagginggroup.UserName);
                userManager.AddToRole(user.Id, AccountController.RoleTagger);

                return(RedirectToAction("Index"));
            }

            ViewBag.ArtworkPoolId = new SelectList(db.ArtworkPools, "ArtworkPoolId", "Name", tagginggroup.ArtworkPoolId);
            return(View(tagginggroup));
        }
Exemplo n.º 2
0
        public ActionResult Create(ArtworkLibrary artworklibrary)
        {
            if (ModelState.IsValid)
            {
                db.ArtworkLibraries.Add(artworklibrary);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(artworklibrary));
        }
Exemplo n.º 3
0
        public ActionResult Create(CopyrightOwner copyrightowner)
        {
            if (ModelState.IsValid)
            {
                db.CopyrightOwners.Add(copyrightowner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(copyrightowner));
        }
        public ActionResult Create(TaggingOrg model)
        {
            var db = new TagDbContext();

            if (ModelState.IsValid)
            {
                db.TaggingOrgs.Add(model);
                db.SaveChanges();

                var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new UserDbContext()));

                var user = new ApplicationUser()
                {
                    UserName = model.UserName
                };
                var result = userManager.Create(user, model.Password);

                user = userManager.FindByName(model.UserName);
                userManager.AddToRole(user.Id, AccountController.RoleTagger);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemplo n.º 5
0
        public static void ImportVTI(int vti, string tagname)
        {
            var context = new TagDbContext();
            Tag tag     = context.Tags.Where(t => t.TagName == tagname).First();

            var values = context.TagValues
                         .Where(t => t.Tag.TagName == tagname)
                         .OrderByDescending(t => t.DateTime)
                         .Select(t => t.DateTime);
            DateTime date = values.Count() > 0 ? values.First() : new DateTime(2012, 10, 1);//DateTime.Today; // <---- заменить DateTime на Today

            using (SqlConnection sql = new SqlConnection(ConfigurationManager.ConnectionStrings["SourceDB"].ConnectionString))
            {
                sql.Open();
                using (SqlCommand cmdClear = new SqlCommand("ep_AskVTIdata", sql))
                {
                    cmdClear.CommandType = System.Data.CommandType.StoredProcedure;
                    cmdClear.Parameters.AddWithValue("@cmd", "Clear");
                    cmdClear.Parameters.AddWithValue("@idReq", 60000);

                    cmdClear.ExecuteNonQuery();
                }

                using (SqlCommand cmdSelect = new SqlCommand("ep_AskVTIdata", sql))
                {
                    cmdSelect.CommandType = System.Data.CommandType.StoredProcedure;
                    cmdSelect.Parameters.AddWithValue("@cmd", "ListAdd");
                    cmdSelect.Parameters.AddWithValue("@idVTI", vti);
                    cmdSelect.Parameters.AddWithValue("@TimeStart", date);
                    cmdSelect.Parameters.AddWithValue("@ShiftBeg", 60);
                    cmdSelect.Parameters.AddWithValue("@idReq", 60000);

                    cmdSelect.ExecuteNonQuery();
                }

                string query = @"SELECT v1.TimeSQL, v1.idVTI, v1.ValueFl+ v2.ValueFl as Value
                                FROM VTIdataList v1
                                INNER JOIN VTIdataList v2 ON v1.TimeSQL = DATEADD(minute, 30, v2.TimeSQL)
                                                             and DATEPART(minute, v1.TimeSQL) != 30
                                                             and v1.idVTI = v2.idVTI
                                WHERE v1.idVTI=@vti and v1.idReq=@idReq and v1.ValueFl IS NOT NULL and v2.ValueFl IS NOT NULL";
                using (SqlCommand cmdGetData = new SqlCommand(query, sql))
                {
                    cmdGetData.Parameters.AddWithValue("@vti", vti);
                    cmdGetData.Parameters.AddWithValue("@idReq", 60000);

                    var reader = cmdGetData.ExecuteReader();
                    while (reader.Read())
                    {
                        context.TagValues.Add(new TagValue()
                        {
                            DateTime = (DateTime)reader["TimeSQL"], TagID = tag.TagID, Value = (double)reader["Value"]
                        });
                    }
                    context.SaveChanges();
                }
            };
        }
Exemplo n.º 6
0
        public ActionResult Create(ArtworkPool imagepool)
        {
            if (ModelState.IsValid)
            {
                db.ArtworkPools.Add(imagepool);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(imagepool));
        }
        public PartialViewResult AddGroup(int orgid, string groupname)
        {
            var db = new TagDbContext();

            var org   = db.TaggingOrgs.SingleOrDefault(o => o.TaggingOrgId == orgid);
            var group = db.TaggingGroups.SingleOrDefault(g => g.Name.Equals(groupname));

            if (org != null && group != null)
            {
                org.Groups.Add(group);
                db.SaveChanges();
            }

            return(PartialView("_GroupList", org));
        }
        public ActionResult DisableTagging(int orgid, int groupid)
        {
            var db = new TagDbContext();

            var org   = db.TaggingOrgs.SingleOrDefault(o => o.TaggingOrgId == orgid);
            var group = db.TaggingGroups.SingleOrDefault(g => g.TaggingGroupId == groupid);

            if (org != null && group != null)
            {
                group.CreatedAt = DateTime.Now.AddSeconds(-1);
                db.SaveChanges();
            }

            return(RedirectToAction("Start", new { id = org.TaggingOrgId }));
        }
        public PartialViewResult RemoveGroup(int orgid, int groupid)
        {
            var db = new TagDbContext();

            var org   = db.TaggingOrgs.SingleOrDefault(o => o.TaggingOrgId == orgid);
            var group = db.TaggingGroups.SingleOrDefault(g => g.TaggingGroupId == groupid);

            if (org != null && group != null)
            {
                org.Groups.Remove(group);
                db.SaveChanges();
            }

            return(PartialView("_EmptyRow"));
        }
Exemplo n.º 10
0
 private static void ExportToDB(string tag_name, Dictionary <DateTime, double> solution, TagDbContext context)
 {
     foreach (DateTime key in solution.Keys)
     {
         var value = context.TagValues.Where(v => v.Tag.TagName == tag_name && v.DateTime == key).FirstOrDefault();
         if (value != null)
         {
             value.Value = Math.Round(solution[key], 2);
         }
         else
         {
             Tag tag = context.Tags.Where(t => t.TagName == tag_name).First();
             value = new TagValue()
             {
                 DateTime = key, Tag = tag, Value = Math.Round(solution[key], 2)
             };
             context.TagValues.Add(value);
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public void InitDemoPool(string homeDir)
        {
            var pool = _context.ArtworkPools.SingleOrDefault(p => p.Name.Equals("Demo"));

            if (pool != null)
            {
                return;
            }

            InitCatalogData();

            pool = new ArtworkPool()
            {
                Name        = "Demo",
                Description = "Demodateien",
            };

            _context.ArtworkPools.Add(pool);
            _context.SaveChanges();

            var lines = File.ReadAllLines(Path.Combine(homeDir, "Index.csv"), Encoding.Default);

            foreach (var line in lines)
            {
                var elem = line.Split(';');

                var libName = elem[6];
                var cpName  = elem[7];

                var library = _context.ArtworkLibraries.SingleOrDefault(l => l.ShortName.Equals(libName));
                var copy    = _context.CopyrightOwners.SingleOrDefault(c => c.ShortName.Equals(cpName));

                var artwork = new Artwork()
                {
                    ArtworkPoolId  = pool.ArtworkPoolId,
                    Artist         = elem[1],
                    Title          = elem[2],
                    Dating         = elem[3],
                    Technique      = elem[4],
                    Dimensions     = elem[5],
                    ArtworkLibrary = library,
                    CopyrightOwner = copy,
                };

                _context.Artworks.Add(artwork);

                var imageFile = Path.Combine(homeDir, elem[0]);

                var image = new ArtworkImage
                {
                    ImageFileType = "image/" + Path.GetExtension(imageFile).Remove(0, 1),
                    Artwork       = artwork,
                    ImageData     = File.ReadAllBytes(imageFile),
                };

                _context.Images.Add(image);
                _context.SaveChanges();
            }

            _context.SaveChanges();
        }
Exemplo n.º 12
0
        public PartialViewResult SendTag(TagModel model)
        {
            var sessionControl = GetSessionControl();

            var idm = sessionControl.GetCurrentImage();


            var tag = new ArtworkTag()
            {
                ArtworkId      = idm.ImageEntryID,
                Tag            = model.Tag,
                TaggingTime    = DateTime.Now,
                TaggingGroupId = sessionControl.Group.TaggingGroupId
            };

            db.Taggings.Add(tag);
            db.SaveChanges();

            // Jetzt noch in der Session ablegen
            idm.Tags.Add(tag);

            // Tamino: Aktuellen Status von der DB abfragen. Alle Tags des Bildes in eine Liste schreiben
            ICollection <ArtworkTag> taggings = null;

            taggings = db.Taggings.Include("Artwork").Include("TaggingGroup")
                       .Where(t => t.TaggingGroupId == sessionControl.Group.TaggingGroupId && t.ArtworkId == idm.ImageEntryID).ToList();

            // Tamino: Nach anzahl der tags und verischidenen tags auswerten

            var _image = new TagAnalysisImage {
                ArtworkID           = idm.ImageEntryID,
                numberTags          = 0,
                numberDifferentTags = 0,
            };

            var tagList = new List <TagList>();

            foreach (ArtworkTag _tag in taggings)
            {
                var tam = new TagList
                {
                    Tag    = _tag.Tag,
                    Anzahl = 1,
                };

                if (tagList.Exists(x => x.Tag == tam.Tag))
                {
                    tagList.Find(x => x.Tag == tam.Tag).Anzahl++;
                    _image.numberTags++;
                }
                else
                {
                    tagList.Add(tam);
                    _image.numberTags++;
                    _image.numberDifferentTags++;
                }
            }

            // Tamino: string für das Update bauen
            var writer = new StringBuilder();

            writer.Append("<table class='table-condensed table-striped col-sm-12'>");
            foreach (TagList tags in tagList)
            {
                writer.Append("<tr><td class='col-sm-6'>" + tags.Tag +
                              "</td><td class='col-sm-6' style='text-align: right;'>" + tags.Anzahl +
                              "</td></tr>");
            }
            writer.Append("</table><div id='ImageId' style='display: none;'>" + idm.ImageEntryID + "</div>");

            string[] pageUpdate = new string[] { _image.ArtworkID.ToString(), _image.numberTags.ToString(),
                     _image.numberDifferentTags.ToString(), writer.ToString() };

            // Tamino: Tags auf det Statusseite aktualisieren

            TaggingHub.UpdateTags(pageUpdate, HttpContext.User.Identity.Name);

            // Das Modell für die Anzeige der Liste aktualisieren
            return(PartialView("_TagList", idm));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Функция расичтывает показатели и записывает в БД
        /// </summary>
        /// <param name="in_sum">список входящих тэгов, которые будут суммироваться</param>
        /// <param name="in_div">список входящих тэгов, на сумму которых будут делить</param>
        /// <param name="outtag">тэг, по которому будет записан результат</param>
        public static void CalculateAndExport_v2(string[] in_sum, string[] in_div, string outtag)
        {
            TagDbContext context = new TagDbContext();

            Tag tag    = context.Tags.Where(t => t.TagName == outtag).First();
            var values = context.TagValues
                         .Where(t => t.Tag.TagName == outtag)
                         .OrderByDescending(t => t.DateTime)
                         .Select(t => t.DateTime);
            DateTime date = values.Count() > 0 ? values.First() : new DateTime(2012, 10, 1);//DateTime.Today; // <---- заменить DateTime на Today

            string query1 = string.Format("SELECT DateTime, SUM(Value) as Value FROM dbo.AnalogHistory WHERE TagName in ( '{0}' ) AND DateTime > @date AND Quality = 0 AND wwRetrievalMode = 'Cyclic' AND wwResolution=3600000 GROUP BY DateTime", string.Join("','", in_sum));
            string query2 = string.Format("SELECT DateTime, SUM(Value) as Value FROM dbo.AnalogHistory WHERE TagName in ( '{0}' ) AND DateTime > @date AND Quality = 0 AND wwRetrievalMode = 'Cyclic' AND wwResolution=3600000 GROUP BY DateTime", string.Join("','", in_div));

            List <TagValue> data1 = new List <TagValue>();
            List <TagValue> data2 = new List <TagValue>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SourceDB"].ConnectionString))
            {
                conn.Open();
                using (SqlCommand command = new SqlCommand(query1, conn))
                {
                    command.CommandTimeout = 240000;
                    command.Parameters.AddWithValue("@date", date);
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        DateTime d = reader.GetDateTime(0);
                        data1.Add(new TagValue()
                        {
                            DateTime = reader.GetDateTime(0), Value = reader.GetDouble(1)
                        });
                    }
                    reader.Close();
                }

                using (SqlCommand command = new SqlCommand(query2, conn))
                {
                    command.CommandTimeout = 240000;
                    command.Parameters.AddWithValue("@date", date);
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        data2.Add(new TagValue()
                        {
                            DateTime = reader.GetDateTime(0), Value = reader.GetDouble(1)
                        });
                    }
                    reader.Close();
                }
            }

            var data_out = data1
                           .Join(data2,
                                 d1 => d1.DateTime,
                                 d2 => d2.DateTime,
                                 (d1, d2) => new { DateTime = d1.DateTime, Value = (d2.Value == 0 ? 0 : d1.Value / d2.Value) });

            foreach (var row in data_out)
            {
                TagValue value = new TagValue()
                {
                    DateTime = row.DateTime, Tag = tag, Value = row.Value
                };
                context.TagValues.Add(value);
            }
            context.SaveChanges();
        }