Exemplo n.º 1
0
        public static void ApplyRestrictions(Core core, Classifications classification)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            switch (classification)
            {
                case Classifications.Restricted:
                    if (core.Session.LoggedInMember.Profile.Age < 18)
                    {
                        // TODO: Restricted content notice
                        core.Functions.Generate403();
                        return;
                    }
                    break;
                case Classifications.Mature:
                    if (core.Session.LoggedInMember.Profile.Age < 13)
                    {
                        // TODO: Restricted content notice
                        core.Functions.Generate403();
                        return;
                    }
                    else if (core.Session.LoggedInMember.Profile.Age < 15)
                    {
                        // TODO: click-through message for 13/14 year olds
                        // TODO: Restricted content notice
                        core.Functions.Generate403();
                        return;
                    }
                    break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parse the output generated from LexRank Java code
        /// </summary>
        /// <param name="input"></param>
        /// <param name="classification"></param>
        private void ParseOutput(string input, Classifications classification)
        {
            List <string> list = new List <string>(
                input.Split(new string[] { "\r\n" },
                            StringSplitOptions.RemoveEmptyEntries));

            List <string> newList = new List <string>();
            bool          enabled = false;
            int           i       = 0;

            foreach (var item in list)
            {
                if (item.Contains("*** SUMMARY"))
                {
                    enabled = true;
                }
                if (enabled)
                {
                    i++;
                    var temp = i == 1 ? item.Substring(24) : item.Substring(3);
                    newList.Add(temp.StartsWith("-") ? temp.Substring(1) : temp);
                }
            }

            //Check Classification and Add to Model
            if (classification == Classifications.BugReport)
            {
                Model.BugReportSummaryList = newList;
            }
            else if (classification == Classifications.UserRequirements)
            {
                Model.UserRequirementsSummaryList = newList;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Dependent type names of this entity
 /// </summary>
 public void DeleteChildren(DatabaseEntities dbContext)
 {
     foreach (var x in Classifications.ToList())
     {
         x.DeleteFull(dbContext);
     }
 }
Exemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Classifications classifications = db.Classifications.Find(id);

            db.Classifications.Remove(classifications);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Active Dependent type names of this object
        /// </summary>
        public List <string> DependentObjectNames()
        {
            var dependentObjects = new List <string>();

            if (Classifications.Any())
            {
                dependentObjects.Add(typeof(Classification).Name);
            }
            return(dependentObjects.Distinct().ToList());
        }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "ClassificationId,ClassificationCode,Name")] Classifications classifications)
 {
     if (ModelState.IsValid)
     {
         db.Entry(classifications).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(classifications));
 }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "ClassificationId,ClassificationCode,Name")] Classifications classifications)
        {
            if (ModelState.IsValid)
            {
                db.Classifications.Add(classifications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(classifications));
        }
        public ClassificationsPageViewModel(ICommentConfiguration config, IDialogService dialogService)
        {
            Config        = config;
            DialogService = dialogService;

            foreach (var cls in Config.Classifications)
            {
                Classifications.Add(new ClassificationViewModel(cls, this));
            }

            AddCommand = new RelayCommand(ShowNewClassificationDialog);
        }
Exemplo n.º 9
0
        public EtiquetarDocumentoViewModel()
        {
            Classifications.Add(new FO_Item {
                Nombre = "CL1 - MAHLE public", id = 1
            });
            Classifications.Add(new FO_Item {
                Nombre = "CL2 - MAHLE internal", id = 2
            });
            Classifications.Add(new FO_Item {
                Nombre = "CL3 - MAHLE confidential", id = 3
            });
            Classifications.Add(new FO_Item {
                Nombre = "CL4 - MAHLE strictly confidential", id = 4
            });

            Positions.Add(new FO_Item {
                Nombre = "Izquierda - Abajo", id = 1, Descripcion = "/Images/Classification/position1.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Izquierda - Centro", id = 2, Descripcion = "/Images/Classification/position2.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Izquierda - Arriba", id = 3, Descripcion = "/Images/Classification/position3.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Arriba - Izquierda ", id = 4, Descripcion = "/Images/Classification/position4.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Arriba - Centro", id = 5, Descripcion = "/Images/Classification/position5.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Arriba - Derecha", id = 6, Descripcion = "/Images/Classification/position6.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Derecha - Arriba", id = 7, Descripcion = "/Images/Classification/position7.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Derecha - Centro", id = 8, Descripcion = "/Images/Classification/position8.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Derecha - Abajo", id = 9, Descripcion = "/Images/Classification/position9.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Abajo - Izquierda", id = 10, Descripcion = "/Images/Classification/position10.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Abajo - Centro", id = 11, Descripcion = "/Images/Classification/position11.PNG"
            });
            Positions.Add(new FO_Item {
                Nombre = "Abajo - Derecha", id = 12, Descripcion = "/Images/Classification/position12.PNG"
            });
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "ID,ArtWorkID,GenreID")] Classifications classifications)
        {
            if (ModelState.IsValid)
            {
                db.Classifications.Add(classifications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArtWorkID = new SelectList(db.ArtWorks, "ID", "Title", classifications.ArtWorkID);
            ViewBag.GenreID   = new SelectList(db.Genres, "ID", "Name", classifications.GenreID);
            return(View(classifications));
        }
        public void ShowNewClassificationDialog()
        {
            var newCls   = new Classification();
            var newClsVm = new ClassificationViewModel(newCls, this);
            var dialogVm = new ClassificationDetailsDialogViewModel(newClsVm, "New Classification", DialogType.AddNew);

            var isOk = DialogService.OpenDialog(dialogVm);

            if (isOk)
            {
                Classifications.Add(newClsVm);
                Config.Classifications.Add(newCls);
            }
        }
Exemplo n.º 12
0
        // GET: Classifications/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Classifications classifications = db.Classifications.Find(id);

            if (classifications == null)
            {
                return(HttpNotFound());
            }
            return(View(classifications));
        }
Exemplo n.º 13
0
 // Movie object constructor
 public Movie(string title, Genres genre, Classifications classification, string director,
              string starring, int duration, DateTime releaseDate, int numCopies)
 {
     Title          = title;
     Genre          = genre;
     Classification = classification;
     Director       = director;
     Starring       = starring;
     Duration       = duration;
     ReleaseDate    = releaseDate;
     NumAvCopies    = numCopies;
     NumTimesRented = 0;
     RentingUsers   = new ArrayList();
 }
Exemplo n.º 14
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         Classifications classifications = db.Classifications.Find(id);
         db.Classifications.Remove(classifications);
         db.SaveChanges();
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 15
0
        UpdateClassAsync(Classifications objClassification)
        {
            var ExistingClassification = _context.Classifications
                                         .Where(x => x.ClassId == objClassification.ClassId)
                                         .FirstOrDefault();

            if (ExistingClassification != null)
            {
                ExistingClassification.ClassName = objClassification.ClassName;
            }
            else
            {
                return(Task.FromResult(false));
            }
            return(Task.FromResult(true));
        }
Exemplo n.º 16
0
        // GET: Classifications/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Classifications classifications = db.Classifications.Find(id);

            if (classifications == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ArtWorkID = new SelectList(db.ArtWorks, "ID", "Title", classifications.ArtWorkID);
            ViewBag.GenreID   = new SelectList(db.Genres, "ID", "Name", classifications.GenreID);
            return(View(classifications));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Main Logic for Lexrank Algorithm
        /// </summary>
        /// <param name="reviews"></param>
        /// <param name="classification"></param>
        private void PerformLexRank(List <string> reviews, Classifications classification)
        {
            var currDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            // Combine the base folder with your specific folder....
            string specificFolder = System.IO.Path.Combine(currDir, "MARC 3.0");

            // Check if folder exists and if not, create it
            if (!Directory.Exists(specificFolder))
            {
                Directory.CreateDirectory(specificFolder);
            }

            var tempPath = Directory.GetCurrentDirectory().ToString();

            var summarizationInputFile = specificFolder + "\\SummarizeTemp.txt";

            //Copy reviews to a temp file for LexRank to Read it
            using (var sW = new StreamWriter(summarizationInputFile))
            {
                foreach (var item in reviews)
                {
                    sW.WriteLine(item);
                }
            }

            int numberOfReviews = (reviews.Count <= Convert.ToInt32(threshold)) ? reviews.Count : Convert.ToInt32(threshold);

            //Run LexRank on the file
            Process myProcess = new Process();

            myProcess.StartInfo.CreateNoWindow  = true;
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.FileName        = "java";
            var argument = "-jar \"" + specificFolder + "\\SummarizerExecutable.jar\" \"" + summarizationInputFile + "\" LEXRANK \"" + numberOfReviews;

            myProcess.StartInfo.Arguments              = argument;
            myProcess.StartInfo.UseShellExecute        = false;
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.Start();
            string output = myProcess.StandardOutput.ReadToEnd();

            myProcess.WaitForExit();

            //Retrieve data back
            ParseOutput(output, classification);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Returns the count of the expected vs actual classifications
        /// </summary>
        /// <param name="expected">Expected classification label</param>
        /// <param name="actual">Actual classification label</param>
        /// <returns></returns>
        public uint GetCount(string expected, string actual)
        {
            var expectedIndex          = ClassificationTable[expected];
            var expectedClassification = Classifications.FirstOrDefault(c => c.ClassificationIndex == expectedIndex);

            if (expectedClassification != null)
            {
                var actualIndex          = ClassificationTable[actual];
                var actualClassification = expectedClassification.ActualClassifications.FirstOrDefault(c => c.ClassificationIndex == actualIndex);
                if (actualClassification != null)
                {
                    return(actualClassification.Count);
                }
            }

            return(0);
        }
Exemplo n.º 19
0
        public CarMap()
        {
            if (Classifications == null || !Classifications.Any())
            {
                throw new Exception(typeof(CarMap).FullName
                                    + " Classifications prop Need to be initialized before use");
            }

            Map(c => c.Name).Name(nameof(Car.Name));
            Map(c => c.LicensePlate).Name(nameof(Car.LicensePlate));
            Map(c => c.Classification).Name(nameof(Car.LicensePlate));
            Map(c => c.PricePerDay).Name(nameof(Car.PricePerDay));
            Map(c => c.PurchaseDate).Name(nameof(Car.PurchaseDate));
            Map(c => c.NextDrainDate).Name(nameof(Car.NextDrainDate));
            Map(c => c.Description).Name(nameof(Car.Description));
            Map(c => c.Rents).Ignore();
            Map(c => c.Id).Ignore();
            Map(c => c.CarImage).Ignore();
            Map(c => c.Classification).ConvertUsing(row => ReadNested(row.GetField(nameof(Car.Classification))));
        }
Exemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "ID,ArtWorkID,GenreID")] Classifications classifications)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(classifications).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     ViewBag.ArtWorkID = new SelectList(db.ArtWorks, "ID", "Title", classifications.ArtWorkID);
     ViewBag.GenreID   = new SelectList(db.Genres, "ID", "Name", classifications.GenreID);
     return(View(classifications));
 }
Exemplo n.º 21
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            _ = sb.Append("Short name:" + string.Join(",", _shortNameList) + ";");
            _ = sb.Append("Identity:" + Identity + ";");

            if (string.IsNullOrEmpty(GroupIdentity))
            {
                _ = sb.Append("Group:<not set>;");
            }
            else
            {
                _ = sb.Append("Group:" + GroupIdentity + ";");
            }
            if (Precedence != 0)
            {
                _ = sb.Append("Precedence:" + Precedence + ";");
            }
            if (!string.IsNullOrEmpty(Author))
            {
                _ = sb.Append("Author:" + Author + ";");
            }
            if (Classifications.Any())
            {
                _ = sb.Append("Classifications:" + string.Join(",", _classifications) + ";");
            }
            if (_parameters.Any())
            {
                _ = sb.Append("Parameters:" + string.Join(",", _parameters) + ";");
            }
            if (_baselineInfo.Any())
            {
                _ = sb.Append("Baseline:" + string.Join(",", _baselineInfo) + ";");
            }
            if (_tags.Any())
            {
                _ = sb.Append("Tags:" + string.Join(",", _tags.Select(t => t.Key + "(" + t.Value + ")")) + ";");
            }
            return(sb.ToString());
        }
Exemplo n.º 22
0
        public int[] KMeans(double[][] input, int ClustersNumber)
        {
            Classifications clas = new Classifications();

            double[][] data       = clas.Unified(input);
            bool       isModified = true;
            bool       isTrue     = true;

            int[]      clusteringGroups = clas.PreProcessing(data.Length, ClustersNumber, 0);
            double[][] means            = clas.Prepare(ClustersNumber, data[0].Length);
            int        maxCount         = data.Length * 10;
            int        compter          = 0;

            while (isModified == true && isTrue == true && compter < maxCount)
            {
                ++compter;
                isTrue     = clas.MeansUpdate(data, clusteringGroups, means);
                isModified = clas.UpdateClustering(data, clusteringGroups, means);
            }
            return(clusteringGroups);
        }
Exemplo n.º 23
0
        internal async Task AddOrUpdateClassification()
        {
            var service = ServicesManager.SelfService;

            try
            {
                if (CurrentClassification == null || string.IsNullOrEmpty(CurrentClassification.Code) || string.IsNullOrEmpty(CurrentClassification.Model))
                {
                    MainWindow.Instance.AddNotification(new BaseResponse()
                    {
                        Error   = ErrorCode.ValidationError,
                        Message = "Code and Model cannot be empty."
                    });
                    return;
                }

                if (Classifications.Count(x => x.Model == CurrentClassification.Model) > 1)
                {
                    MainWindow.Instance.AddNotification(new BaseResponse()
                    {
                        Error   = ErrorCode.ValidationError,
                        Message = "Internal model already exists."
                    });
                    return;
                }

                var locationsResponse = await service.UpdateClassification(Token, CurrentClassification);

                MainWindow.Instance.AddNotification(locationsResponse ?? new BaseResponse()
                {
                    Error = ErrorCode.InternalError, Message = "Failed to receive response from host."
                });
            }
            catch (ServiceException ex)
            {
                //TODO: HIGH Add logging
                MainWindow.Instance.AddNotification(ex);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <Vehicle> GetVehicleData(string FileName)
        {
            List <Vehicle> returnValue = new List <Vehicle>();
            var            engine      = new FileHelperEngine <VehicleData>();
            string         method      = System.Reflection.MethodBase.GetCurrentMethod().Name;
            var            result      = engine.ReadFile(FileName);

            foreach (VehicleData vd in result)
            {
                Classifications Classification = Classifications.Class1;
                if (vd.VehicleClass.ToLower() == "class 1")
                {
                    Classification = Classifications.Class1;
                }
                if (vd.VehicleClass.ToLower() == "class 2")
                {
                    Classification = Classifications.Class2;
                }
                if (vd.VehicleClass.ToLower() == "class 3")
                {
                    Classification = Classifications.Class3;
                }
                PopulateVehicleClasses();
                Vehicle v = new Vehicle
                {
                    PlateNumber    = vd.PlateNumber,
                    Make           = vd.Make,
                    Model          = vd.Model,
                    Year           = vd.Year,
                    VehicleState   = vd.VehicleState,
                    VehicleStatus  = vd.VehicleStatus,
                    Classification = Classification,
                    VehicleClass   = VehicleClassList.FirstOrDefault(x => x.Classification == Classification)
                };
                returnValue.Add(v);
            }
            return(returnValue);
        }
Exemplo n.º 25
0
        public static string BuildClassificationBox(Core core, Classifications classification)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            Template template = new Template(core.Http.TemplatePath, "std.classifications_box.html");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            switch (classification)
            {
                case Classifications.None:
                    template.Parse("IS_NONE", boxChecked);
                    break;
                case Classifications.Everyone:
                    template.Parse("IS_EVERYONE", boxChecked);
                    break;
                case Classifications.Mature:
                    template.Parse("IS_MATURE", boxChecked);
                    break;
                case Classifications.Restricted:
                    template.Parse("IS_RESTRICTED", boxChecked);
                    break;
            }

            return template.ToString();
        }
Exemplo n.º 26
0
 protected void ParseClassification(Core core, string templateVar, Classifications classification)
 {
     template.ParseRaw(templateVar, Classification.BuildClassificationBox(core, classification));
 }
Exemplo n.º 27
0
 public static GalleryItem Create(Core core, Primitive owner, Gallery parent, string title, ref string slug, string fileName, string contentType, ulong bytes, string description, byte license, Classifications classification, Stream stream, bool highQuality /*int width, int height*/)
 {
     return Create(core, owner, parent, title, ref slug, fileName, contentType, bytes, description, license, classification, stream, highQuality, 0);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Does this object have any dependent objects? (If it does have dependent objects, these would need to be deleted before this object could be deleted.)
 /// </summary>
 /// <returns></returns>
 public bool HasDependentObjects()
 {
     return(Classifications.Any());
 }
Exemplo n.º 29
0
        /// <summary>
        /// Creates a new gallery item
        /// </summary>
        /// <param name="core">Core token</param>
        /// <param name="owner">Owner</param>
        /// <param name="parent">Gallery</param>
        /// <param name="title">Title</param>
        /// <param name="slug">Slug</param>
        /// <param name="fileName">File name</param>
        /// <param name="storageName">Storage name</param>
        /// <param name="contentType">Content type</param>
        /// <param name="bytes">Bytes</param>
        /// <param name="description">Description</param>
        /// <param name="permissions">Permissions mask</param>
        /// <param name="license">License</param>
        /// <param name="classification">Classification</param>
        /// <remarks>Slug is a reference</remarks>
        /// <returns>New gallery item</returns>
        public static GalleryItem Create(Core core, Primitive owner, Gallery parent, string title, ref string slug, string fileName, string contentType, ulong bytes, string description, byte license, Classifications classification, Stream stream, bool highQuality, long applicationId /*int width, int height*/)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (stream == null)
            {
                throw new Exception("The image stream is empty!");
            }

            int width, height;
            stream = OrientImage(stream, out width, out height);

            string storageName = Storage.HashFile(stream);

            /*
             * scale and save
             */
            string storageFilePath = string.Empty;

            if (highQuality || (width <= (int)PictureScale.Ultra && height <= (int)PictureScale.Ultra))
            {
                core.Storage.SaveFile(core.Storage.PathCombine(core.Settings.StorageBinUserFilesPrefix, "_storage"), storageName, stream, contentType);
            }
            else
            {
                int originalWidth = width;
                int originalHeight = height;

                Size newSize = GalleryItem.GetSize(new Size(width, height), new Size((int)PictureScale.Ultra, (int)PictureScale.Ultra));
                width = newSize.Width;
                height = newSize.Height;

                if (Core.IsUnix && WebConfigurationManager.AppSettings["image-method"] == "imagemagick")
                {
                    storageFilePath = System.IO.Path.Combine(core.Settings.ImagemagickTempPath, "_storage", storageName);

                    if (stream is MemoryStream)
                    {
                        MemoryStream ms = (MemoryStream)stream;
                        FileStream ds = new FileStream(storageFilePath, FileMode.Create);
                        ms.WriteTo(ds);
                        ds.Close();
                    }
                    else
                    {
                        stream.Position = 0;
                        byte[] b = new byte[stream.Length];
                        stream.Read(b, 0, (int)stream.Length);
                        FileStream ds = new FileStream(storageFilePath, FileMode.Create);
                        ds.Write(b, 0, b.Length);
                        ds.Close();
                    }
                }

                CreateScaleWithRatioPreserved(core, contentType, stream, storageName, "_storage", (int)PictureScale.Ultra, (int)PictureScale.Ultra);
            }

            /*
             * create thumbnails
             */
            bool tinyExists = false;
            bool thumbExists = false;
            bool mobileExists = false;
            bool displayExists = false;
            bool fullExists = false;
            bool ultraExists = false;

            switch (core.Medium)
            {
                case Forms.DisplayMedium.Desktop:
                    if (width > (int)PictureScale.Display || height > (int)PictureScale.Display)
                    {
                        displayExists = CreateScaleWithRatioPreserved(core, contentType, stream, storageName, DisplayPrefix, (int)PictureScale.Display, (int)PictureScale.Display);
                    }
                    else
                    {
                        // This strips all uploaded images of EXIF data
                        displayExists = CreateScaleWithRatioPreserved(core, contentType, stream, storageName, DisplayPrefix, width, height);
                    }
                    break;
                case Forms.DisplayMedium.Mobile:
                    if (width > (int)PictureScale.Mobile || height > (int)PictureScale.Mobile)
                    {
                        mobileExists = CreateScaleWithRatioPreserved(core, contentType, stream, storageName, MobilePrefix, (int)PictureScale.Mobile, (int)PictureScale.Mobile);
                    }
                    break;
            }

            if (!string.IsNullOrEmpty(storageFilePath))
            {
                if (File.Exists(storageFilePath))
                {
                    try
                    {
                        File.Delete(storageFilePath);
                    }
                    catch (FileNotFoundException)
                    {
                    }
                }
            }

            /*
             * save the image
             */

            Mysql db = core.Db;

            if (owner is User)
            {
                if (owner.Id != core.LoggedInMemberId)
                {
                    throw new Exception("Error, user IDs don't match");
                }
            }

            if (bytes > (ulong)core.Settings.MaxFileSize)
            {
                throw new GalleryItemTooLargeException();
            }

            if (core.Session.LoggedInMember.UserInfo.BytesUsed + bytes > (ulong)core.Settings.MaxUserStorage)
            {
                throw new GalleryQuotaExceededException();
            }

            switch (contentType)
            {
                case "image/png":
                case "image/jpeg":
                case "image/pjpeg":
                case "image/gif":
                    break;
                default:
                    throw new InvalidGalleryItemTypeException();
            }

            title = Functions.TrimStringToWord(title);

            slug = GalleryItem.GetSlugFromFileName(fileName, slug);
            slug = Functions.TrimStringWithExtension(slug);

            if (slug != "image.jpg")
            {
                GalleryItem.EnsureGallerySlugUnique(core, parent, owner, ref slug);
            }

            InsertQuery iQuery = new InsertQuery("gallery_items");
            iQuery.AddField("gallery_item_uri", slug);
            iQuery.AddField("gallery_item_title", title);
            iQuery.AddField("gallery_item_abstract", description);
            iQuery.AddField("gallery_item_date_ut", UnixTime.UnixTimeStamp());
            iQuery.AddField("gallery_item_storage_path", storageName);
            iQuery.AddField("gallery_item_parent_path", parent.FullPath);
            iQuery.AddField("gallery_item_content_type", contentType);
            iQuery.AddField("user_id", core.LoggedInMemberId);
            iQuery.AddField("gallery_item_bytes", bytes);
            iQuery.AddField("gallery_item_license", license);
            iQuery.AddField("gallery_id", parent.GalleryId);
            iQuery.AddField("gallery_item_item_id", owner.Id);
            iQuery.AddField("gallery_item_item_type_id", owner.TypeId);
            iQuery.AddField("gallery_item_classification", (byte)classification);
            iQuery.AddField("gallery_item_icon_exists", false);
            iQuery.AddField("gallery_item_tile_exists", false);
            iQuery.AddField("gallery_item_square_exists", false);
            iQuery.AddField("gallery_item_high_exists", false);
            iQuery.AddField("gallery_item_tiny_exists", tinyExists);
            iQuery.AddField("gallery_item_thumb_exists", thumbExists);
            iQuery.AddField("gallery_item_mobile_exists", mobileExists);
            iQuery.AddField("gallery_item_display_exists", displayExists);
            iQuery.AddField("gallery_item_full_exists", fullExists);
            iQuery.AddField("gallery_item_ultra_exists", ultraExists);
            iQuery.AddField("gallery_item_cover_exists", false);
            iQuery.AddField("gallery_item_mobile_cover_exists", false);
            iQuery.AddField("gallery_item_width", width);
            iQuery.AddField("gallery_item_height", height);
            iQuery.AddField("gallery_item_vcrop", 0);
            iQuery.AddField("gallery_item_hcrop", 0);
            iQuery.AddField("gallery_item_application_id", applicationId);

            // we want to use transactions
            long itemId = db.Query(iQuery);

            if (itemId >= 0)
            {
                // ios uploads anonymously
                if (slug == "image.jpg")
                {
                    slug = string.Format("image-{0}.jpg", itemId);
                    UpdateQuery iosQuery = new UpdateQuery("gallery_items");
                    iosQuery.AddField("gallery_item_uri", slug);
                    iosQuery.AddCondition("gallery_item_id", itemId);

                    db.Query(iosQuery);
                }

                //owner.UpdateGalleryInfo(parent, itemId, 1, (long)bytes);
                //if (owner is User)
                {
                    Gallery.UpdateGalleryInfo(core, parent, itemId, 1, (long)bytes);
                }
                /*parent.Bytes += (long)bytes;
                parent.Items += 1;
                parent.Update();*/

                UpdateQuery uQuery = new UpdateQuery("user_info");
                uQuery.AddField("user_gallery_items", new QueryOperation("user_gallery_items", QueryOperations.Addition, 1));
                uQuery.AddField("user_bytes", new QueryOperation("user_bytes", QueryOperations.Addition, bytes));
                uQuery.AddCondition("user_id", core.LoggedInMemberId);

                if (db.Query(uQuery) < 0)
                {
                    throw new Exception("Transaction failed, panic!");
                }

                GalleryItem newGalleryItem = new GalleryItem(core, owner, itemId);
                core.Db.CommitTransaction();

                core.Search.Index(newGalleryItem);

                if (core.Queue != null)
                {
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_ultra"));
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_full"));
                    switch (core.Medium)
                    {
                        case Forms.DisplayMedium.Desktop:
                            core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_mobile"));
                            break;
                        case Forms.DisplayMedium.Mobile:
                            core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_display"));
                            break;
                    }
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_thumb"));
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_tiny"));

                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_high"));
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_square"));
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_tile"));
                    core.Queue.PushJob(new Job(core.Settings.QueueDefaultPriority, core.CallingApplication.Id, core.LoggedInMemberId, newGalleryItem.ItemKey.TypeId, newGalleryItem.ItemKey.Id, "create_icon"));
                }

                return newGalleryItem;
                //return itemId;
            }

            throw new Exception("Transaction failed, panic!");
        }
Exemplo n.º 30
0
 public int GetEstimatedSize() => Content?.Length * 2 ?? 0
 + Classifications?.GetEstimatedSize() ?? 0
 + SearchReferencesSource?.Select(x => x.GetEstimatedSize()).Sum() ?? 0
 + Definitions?.Select(x => x.GetEstimatedSize()).Sum() ?? 0;
Exemplo n.º 31
0
    private void                                    LoadApplicationSettings()
    {
        string[] strLines                 = null;
        string   AppSettingsFile          = "ApplicationSettings.txt";
        bool     blnOkayToProcessTextFile = false;
        int      intWidth                 = 0;
        int      intHeight                = 0;

        if (!Util.FileExists("", AppSettingsFile))
        {
            Status.Status = "Unable to find file \"" + AppSettingsFile + "\". Using Default Settings.";
        }
        else
        {
            strLines = Util.ReadTextFile("", AppSettingsFile).Split('\n');
            blnOkayToProcessTextFile = strLines != null && strLines.Length > 0;
            Status.Status            = AppSettingsFile + " found. " + strLines.Length.ToString() + " lines Read In.";
        }

        if (blnOkayToProcessTextFile)
        {
            foreach (string st in strLines)
            {
                if (!st.StartsWith("//") && st.Trim() != "" && st.Contains("="))
                {
                    string[] s = st.Trim().Split('=');
                    if (s.Length > 2)
                    {
                        for (int i = 2; i < s.Length; i++)
                        {
                            s[1] += "=" + s[i];
                        }
                    }
                    switch (s[0].Trim().ToUpper())
                    {
                    // APPLICATION MANAGER SETTINGS
                    case "CLASSIFICATION":
                        AppClassification = (Classifications)Util.ConvertToInt(s[1].Trim());
                        break;

                    case "CLASSIFICATION_HEADING":
                        CLASSIFICATION_HEADING = s[1].Trim();
                        break;

                    case "MAX_FPS":
                    case "MAXFPS":
                        MaxFPS = Util.ConvertToInt(s[1].Trim());
                        break;

                    // GAME MANAGER SETTINGS
                    case "DEFAULT_WIDTH":
                        DEFAULT_WIDTH = Util.ConvertToFloat(s[1].Trim());
                        intWidth      = (int)DEFAULT_WIDTH;
                        break;

                    case "DEFAULT_HEIGHT":
                        DEFAULT_HEIGHT = Util.ConvertToFloat(s[1].Trim());
                        intHeight      = (int)DEFAULT_HEIGHT;
                        break;

                    case "DEFAULT_APP_TIMEOUT":
                        DEFAULT_APP_TIMEOUT = Util.ConvertToInt(s[1].Trim());
                        break;
                    }
                }
            }
        }

        // UPDATE BUTTON
        Status.UpdateStatus();
        if (intWidth > 0 && intHeight > 0)
        {
            Screen.fullScreen = false;
            Screen.SetResolution(intWidth, intHeight, false);
        }
    }
Exemplo n.º 32
0
 public void ParseClassification(string templateVar, Classifications classification)
 {
     ParseClassification(core.Template, templateVar, classification);
 }
Exemplo n.º 33
0
 public void ParseClassification(Template template, string templateVar, Classifications classification)
 {
     template.ParseRaw(templateVar, Classification.BuildClassificationBox(core, classification));
 }