private static void FileThumbItem(ThumbItem thumbItem, Nds item)
 {
     thumbItem.Added       = item.AddedDate;
     thumbItem.Cover       = item.Cover;
     thumbItem.Deleted     = item.IsDeleted;
     thumbItem.Description = item.Description;
     if (item.Cover != null)
     {
         thumbItem.HasCover = true;
     }
     else
     {
         thumbItem.Cover    = Util.CreateCover(item.Title);
         thumbItem.HasCover = false;
     }
     thumbItem.IsComplete  = item.IsComplete;
     thumbItem.Media       = item.Media.Name;
     thumbItem.Name        = item.Title;
     thumbItem.MyRating    = item.MyRating / 4;
     thumbItem.ReleaseDate = item.ReleaseDate;
     thumbItem.Seen        = item.Watched;
     thumbItem.ToBeDeleted = item.ToBeDeleted;
     thumbItem.ToBuy       = item.IsWhish;
     thumbItem.ToWatch     = item.ToWatch;
 }
Exemple #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (total_ != null)
            {
                hash ^= Total.GetHashCode();
            }
            if (zap_ != null)
            {
                hash ^= Zap.GetHashCode();
            }
            if (nds_ != null)
            {
                hash ^= Nds.GetHashCode();
            }
            if (deb_ != null)
            {
                hash ^= Deb.GetHashCode();
            }
            if (fin_ != null)
            {
                hash ^= Fin.GetHashCode();
            }
            if (mon_ != null)
            {
                hash ^= Mon.GetHashCode();
            }
            if (oth_ != null)
            {
                hash ^= Oth.GetHashCode();
            }
            return(hash);
        }
        public static void Clean(Nds objItem)
        {
            foreach (Genre genre in objItem.Genres)
            {
                genre.IsOld = true;
            }

            foreach (Links link in objItem.Links)
            {
                link.IsOld = true;
            }

            foreach (Ressource ressource in objItem.Ressources)
            {
                ressource.IsOld = true;
            }

            objItem.RemoveCover = true;
            objItem.Cover       = null;

            objItem.BarCode      = string.Empty;
            objItem.Comments     = string.Empty;
            objItem.Description  = string.Empty;
            objItem.Rated        = null;
            objItem.MyRating     = null;
            objItem.ReleaseDate  = null;
            objItem.Language     = null;
            objItem.IsComplete   = false;
            objItem.PublicRating = null;
        }
Exemple #4
0
 private void LoadItem()
 {
     _objItem = new NdsServices().Get(Id) as Nds;
     if (_objItem != null)
     {
         DataContext = _objItem;
         Bind();
     }
 }
Exemple #5
0
        private void AddNds(string[] strTemp, string strTitle, string strFileName, string strFilePath)
        {
            Media objMedia = MediaServices.Get(_strMediaName.Trim(), _mediaType, _path,
                                               _cleanTitle, _entityType, _patternType, _useSubFolder, _bGetImage, _bParseNfo, true);

            Nds objNds = new Nds();

            objNds.Ressources = new List <Ressource>();
            objNds.Title      = strTitle;
            objNds.AddedDate  = DateTime.Now;
            #region File

            objNds.FileName = strFileName;
            objNds.FilePath = strFilePath;

            #endregion
            if (_mapping != null)
            {
                string strLanguage = Util.ConstructString(strTemp, (string[])_mapping["Language"], _nbrBaseParsing);
                objNds.Language = LanguageServices.GetLanguage(strLanguage, true);
            }
            objNds.Media = objMedia;
            #region Cover
            if (_bGetImage == true)
            {
                RessourcesServices.AddImage(Util.GetLocalImage(objNds.FilePath, objNds.FileName, _bFile), objNds, true);
            }
            #endregion
            if (string.IsNullOrEmpty(objNds.Title) == false)
            {
                bool bExist = false;
                if (Dal.GetInstance.GetNdss(objNds.Media.Name, objNds.FilePath, objNds.FileName) != null)
                {
                    bExist = true;
                }

                if (bExist == false)
                {
                    #region ParseNfo

                    if (_bParseNfo == true)
                    {
                        string errorMessage;
                        NdsServices.ParseNfo(objNds, out errorMessage);
                    }

                    #endregion
                    Dal.GetInstance.AddNds(objNds);
                    _intAddedItem++;
                }
                else
                {
                    _intNotAddedItem++;
                }
            }
        }
        public static void SetToBeDeleted(IList lstSelectedItems)
        {
            foreach (ThumbItem item in lstSelectedItems)
            {
                switch (item.EType)
                {
                case EntityType.Apps:
                    Apps objApps = Dal.GetInstance.GetApps(item.Id);
                    objApps.ToBeDeleted = true;
                    Dal.GetInstance.AddApps(objApps);
                    break;

                case EntityType.Books:
                    Books objBooks = Dal.GetInstance.GetBooks(item.Id);
                    objBooks.ToBeDeleted = true;
                    Dal.GetInstance.AddBook(objBooks);
                    break;

                case EntityType.Games:
                    Gamez objGamez = Dal.GetInstance.GetGames(item.Id);
                    objGamez.ToBeDeleted = true;
                    Dal.GetInstance.AddGame(objGamez);
                    break;

                case EntityType.Movie:
                    Movie objMovie = Dal.GetInstance.GetMovies(item.Id);
                    objMovie.ToBeDeleted = true;
                    Dal.GetInstance.AddMovie(objMovie);
                    break;

                case EntityType.Music:
                    Music objMusic = Dal.GetInstance.GetMusics(item.Id);
                    objMusic.ToBeDeleted = true;
                    Dal.GetInstance.AddMusic(objMusic);
                    break;

                case EntityType.Nds:
                    Nds objNds = Dal.GetInstance.GetNdss(item.Id);
                    objNds.ToBeDeleted = true;
                    Dal.GetInstance.AddNds(objNds);
                    break;

                case EntityType.Series:
                    SeriesSeason objSeriesSeason = Dal.GetInstance.GetSeries_Seasons(item.Id);
                    objSeriesSeason.ToBeDeleted = true;
                    Dal.GetInstance.AddSeriesSeason(objSeriesSeason);
                    break;

                case EntityType.XXX:
                    XXX objXxx = Dal.GetInstance.GetXxXs(item.Id);
                    objXxx.ToBeDeleted = true;
                    Dal.GetInstance.AddXxx(objXxx);
                    break;
                }
            }
        }
        public static void SetClean(IList lstSelectedItem)
        {
            foreach (ThumbItem item in lstSelectedItem)
            {
                switch (item.EType)
                {
                case EntityType.Apps:
                    Apps objApps = Dal.GetInstance.GetApps(item.Id);
                    AppServices.Clean(objApps);
                    Update(objApps);
                    break;

                case EntityType.Books:
                    Books objBooks = Dal.GetInstance.GetBooks(item.Id);
                    BookServices.Clean(objBooks);
                    Update(objBooks);
                    break;

                case EntityType.Games:
                    Gamez objGamez = Dal.GetInstance.GetGames(item.Id);
                    GameServices.Clean(objGamez);
                    Update(objGamez);
                    break;

                case EntityType.Movie:
                    Movie objMovie = Dal.GetInstance.GetMovies(item.Id);
                    MovieServices.Clean(objMovie);
                    Update(objMovie);
                    break;

                case EntityType.Music:
                    Music objMusic = Dal.GetInstance.GetMusics(item.Id);
                    MusicServices.Clean(objMusic);
                    Update(objMusic);
                    break;

                case EntityType.Nds:
                    Nds objNds = Dal.GetInstance.GetNdss(item.Id);
                    NdsServices.Clean(objNds);
                    Update(objNds);
                    break;

                case EntityType.Series:
                    SeriesSeason objSeriesSeason = Dal.GetInstance.GetSeries_Seasons(item.Id);
                    SerieServices.Clean(objSeriesSeason);
                    Update(objSeriesSeason);
                    break;

                case EntityType.XXX:
                    XXX objXxx = Dal.GetInstance.GetXxXs(item.Id);
                    XxxServices.Clean(objXxx);
                    Update(objXxx);
                    break;
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Получает строку Цена (С НДС/Без НДС)
        /// </summary>
        public static string GetNdsString(Nds nds)
        {
            switch (nds)
            {
            case Nds.Any: return("Не выбрано");

            case Nds.IsIncluded: return("С НДС");

            case Nds.IsNotIncluded: return("Без НДС");

            default: throw new NotImplementedException();
            }
        }
        // GET: Counterparties/Create
        public ActionResult Create()
        {
            Nds        Nds             = new Nds();
            List <Nds> NdsVariantsList = new List <Nds>();

            NdsVariantsList.Add(new Nds()
            {
                Value = 0, Text = "Нет"
            });
            NdsVariantsList.Add(new Nds()
            {
                Value = 1, Text = "Да"
            });
            SelectList nds = new SelectList(NdsVariantsList, "Value", "Text");

            ViewBag.nds = nds;
            return(View());
        }
        public static bool IsComplete(Nds objEntity)
        {
            if (objEntity.Ressources.Any() == false)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(objEntity.Description))
            {
                return(false);
            }
            if (objEntity.ReleaseDate == null)
            {
                return(false);
            }
            if (objEntity.Genres.Any() == false)
            {
                return(false);
            }

            objEntity.IsComplete = true;

            return(true);
        }
Exemple #11
0
        protected override void DoTaskForFile(string pPath, IVgmtWorkerStruct pMk2sfStruct, DoWorkEventArgs e)
        {
            this.progressStruct.Clear();
            this.progressStruct.GenericMessage = String.Format("Processing: [{0}]{1}", pPath, Environment.NewLine);
            this.ReportProgress(this.progress, this.progressStruct);

            NdsTo2sfStruct workingStruct      = (NdsTo2sfStruct)pMk2sfStruct;
            string         ndsTo2sfOutputPath = Path.Combine(Path.GetDirectoryName(pPath), String.Format("{0}{1}", Path.GetFileNameWithoutExtension(pPath), XsfUtil.NDSTO2SF_FOLDER_SUFFIX));

            // Build Nds object
            Nds ndsFile = new Nds();

            using (FileStream ndsStream = File.OpenRead(pPath))
            {
                ndsFile.Initialize(ndsStream, pPath);
            }

            //------------------------
            // extract 2SFs and STRMs
            //------------------------
            bool filesWereRipped = XsfUtil.NdsTo2sf(pPath, TESTPACK_FULL_PATH, workingStruct.UseSmapNames);

            // output info
            this.progressStruct.Clear();

            if (!filesWereRipped)
            {
                this.progressStruct.GenericMessage = String.Format("  No extractable SSEQ/STRM/SWAR data found.{0}", Environment.NewLine);
            }
            else
            {
                this.progressStruct.GenericMessage = String.Format("  SSEQ/STRM/SWAR Data extracted.{0}", Environment.NewLine);
            }

            this.ReportProgress(this.progress, this.progressStruct);

            //---------------
            // extract SWAVs
            //---------------
            this.progressStruct.Clear();
            this.progressStruct.GenericMessage = String.Format("  Searching for SWAVs{0}", Environment.NewLine);
            this.ReportProgress(this.progress, this.progressStruct);

            string swavMessages = String.Empty;

            FindOffsetStruct findOffsetStruct = new FindOffsetStruct();

            findOffsetStruct.CutFile                = true;
            findOffsetStruct.SearchString           = "53574156FFFE";
            findOffsetStruct.TreatSearchStringAsHex = true;
            findOffsetStruct.SearchStringOffset     = "0";
            findOffsetStruct.OutputFileExtension    = ".swav";
            findOffsetStruct.IsCutSizeAnOffset      = true;
            findOffsetStruct.CutSize                = "8";
            findOffsetStruct.CutSizeOffsetSize      = "4";
            findOffsetStruct.IsLittleEndian         = true;
            findOffsetStruct.OutputFolder           = Path.Combine(ndsTo2sfOutputPath, "SWAV");

            ParseFile.FindOffsetAndCutFile(pPath, findOffsetStruct, out swavMessages, false, false);

            //--------------
            // extract ADXs
            //--------------
            this.progressStruct.Clear();
            this.progressStruct.GenericMessage = String.Format("  Searching for ADXs{0}", Environment.NewLine);
            this.ReportProgress(this.progress, this.progressStruct);

            string adxMessages = String.Empty;

            CriUtil.ExtractAdxStreams(pPath, ndsFile.GameSerial, Path.Combine(ndsTo2sfOutputPath, "ADX"), out adxMessages);
        }
Exemple #12
0
        private void worker_DoWork_XML(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

                foreach (XElement node in _selectedItems)
                {
                    //exit if the user cancels
                    if (_isCancelationPending == true)
                    {
                        return;
                    }

                    Nds nds = new Nds();
                    nds.Title       = Util.GetElementValue(node, "Title");
                    nds.BarCode     = Util.GetElementValue(node, "BarCode");
                    nds.Comments    = Util.GetElementValue(node, "Comments");
                    nds.Description = Util.GetElementValue(node, "Description");
                    nds.FileName    = Util.GetElementValue(node, "FileName");
                    nds.FilePath    = Util.GetElementValue(node, "FilePath");

                    DateTime dateValue;

                    if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true)
                    {
                        nds.AddedDate = dateValue;
                    }

                    if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true)
                    {
                        nds.ReleaseDate = dateValue;
                    }

                    #region Bool
                    bool boolValue;

                    if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true)
                    {
                        nds.IsComplete = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true)
                    {
                        nds.IsDeleted = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsTested"), out boolValue) == true)
                    {
                        nds.Watched = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true)
                    {
                        nds.IsWhish = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true)
                    {
                        nds.ToBeDeleted = boolValue;
                    }

                    #endregion
                    #region Long
                    long longValue;

                    if (long.TryParse(Util.GetElementValue(node, "Rated"), out longValue) == true)
                    {
                        nds.Rated = longValue.ToString(CultureInfo.InvariantCulture);
                    }

                    #endregion

                    int intValue;

                    if (int.TryParse(Util.GetElementValue(node, "Rating"), out intValue) == true)
                    {
                        nds.MyRating = intValue;
                    }

                    #region Media
                    var query = from item in node.Descendants("Media")
                                select item;

                    XElement[] mediaNode = query.ToArray();

                    foreach (XElement media in mediaNode)
                    {
                        Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true);
                        newMedia.Path = Util.GetElementValue(media, "Path");
                        nds.Media     = newMedia;
                    }
                    #endregion
                    #region Links
                    query = from item in node.Descendants("Link")
                            select item;

                    XElement[] linksNode = query.ToArray();

                    foreach (XElement link in linksNode)
                    {
                        LinksServices.AddLinks(Util.GetElementValue(link, "Path"), nds, true);
                    }

                    #endregion
                    #region Types
                    query = from item in node.Descendants("Type")
                            select item;

                    XElement[] typekNode = query.ToArray();

                    foreach (XElement type in typekNode)
                    {
                        GenreServices.AddGenres(new[] { Util.GetElementValue(type, "RealName") }, nds, true);
                    }
                    #endregion
                    #region Image
                    query = from item in node.Descendants("Ressource")
                            select item;

                    XElement[] imagesNode = query.ToArray();

                    foreach (XElement images in imagesNode)
                    {
                        if (Util.GetElementValue(images, "ResourcesType") == "Image")
                        {
                            bool   isDefault = bool.Parse(Util.GetElementValue(images, "IsDefault"));
                            byte[] cover     = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddImage(cover, nds, isDefault);
                            }
                        }
                        if (Util.GetElementValue(images, "ResourcesType") == "Background")
                        {
                            byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddBackground(cover, nds);
                            }
                        }
                    }
                    #endregion
                    #region Editor
                    query = from item in node.Descendants("Editor")
                            select item;

                    XElement[] editorNode = query.ToArray();

                    foreach (XElement editor in editorNode)
                    {
                        bool isNew;
                        nds.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(editor, "Name"), out isNew, "App_Editor");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("App_Editor", nds.Publisher);
                        }
                    }
                    #endregion
                    #region Language
                    query = from item in node.Descendants("Language")
                            select item;

                    XElement[] languageNode = query.ToArray();

                    foreach (XElement languages in languageNode)
                    {
                        nds.Language = LanguageServices.GetLanguage(Util.GetElementValue(languages, "DisplayName"), true);
                    }
                    #endregion
                    Dal.GetInstance.AddNds(nds);
                    _intAddedItem++;

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
        public static void ParseNfo(Nds objEntity, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (string.IsNullOrWhiteSpace(objEntity.FilePath))
            {
                errorMessage = "Nfo File not found";
            }
            else
            {
                string strFilePath;
                if (objEntity.FilePath.EndsWith(@"\", StringComparison.OrdinalIgnoreCase) == true)
                {
                    strFilePath = objEntity.FilePath + objEntity.FileName;
                }
                else
                {
                    strFilePath = objEntity.FilePath + @"\" + objEntity.FileName;
                }

                //FIX 2.82.0
                if (Directory.Exists(strFilePath))
                {
                    DirectoryInfo objFolder = new DirectoryInfo(strFilePath);

                    FileInfo[] lstFile = objFolder.GetFiles("*.nfo", SearchOption.AllDirectories);

                    if (lstFile.Any())
                    {
                        Hashtable objNfoValue = Dal.ParseNfo(lstFile[0].FullName);
                        #region Publisher

                        if (objEntity.Publisher == null)
                        {
                            if (objNfoValue.ContainsKey("Editor") == true)
                            {
                                Publisher objEditor = Dal.GetInstance.GetPublisher(objNfoValue["Editor"].ToString().Trim(), "App_Editor", "Name");
                                if (objEditor == null)
                                {
                                    objEditor      = new Publisher();
                                    objEditor.Name = objNfoValue["Editor"].ToString().Trim();
                                }
                                objEntity.Publisher = objEditor;
                            }
                        }

                        #endregion
                        #region Language

                        if (objEntity.Language == null)
                        {
                            if (objNfoValue.ContainsKey("Language") == true)
                            {
                                objEntity.Language = LanguageServices.GetLanguage(objNfoValue["Language"].ToString().Trim(), false);
                            }
                        }

                        #endregion
                        #region GamezType

                        if (objEntity.Genres == null || objEntity.Genres.Count == 0)
                        {
                            if (objNfoValue.ContainsKey("Type") == true)
                            {
                                Genre objGamezType = Dal.GetInstance.GetGenre(objNfoValue["Type"].ToString().Trim(), "GamezType");
                                if (objGamezType == null)
                                {
                                    objGamezType = new Genre(objNfoValue["Type"].ToString().Trim(), objNfoValue["Type"].ToString().Trim());
                                }

                                if (objEntity.Genres == null)
                                {
                                    objEntity.Genres = new List <Genre>();
                                }

                                objEntity.Genres.Add(objGamezType);
                            }
                        }

                        #endregion
                        #region Links
                        if (objNfoValue.ContainsKey("Links"))
                        {
                            LinksServices.AddLinks(objNfoValue["Links"].ToString().Trim(), objEntity, false);
                        }
                        #endregion
                        #region Released

                        if (objEntity.ReleaseDate == null)
                        {
                            if (objNfoValue.ContainsKey("Released") == true)
                            {
                                string strTempDate = objNfoValue["Released"].ToString().Trim();
                                if (strTempDate.Length == 8)
                                {
                                    strTempDate = strTempDate.Insert(2, @"/");
                                    strTempDate = strTempDate.Insert(5, @"/");
                                }
                                DateTime objDate;
                                if (DateTime.TryParse(strTempDate, out objDate) == true)
                                {
                                    objEntity.ReleaseDate = objDate;
                                }
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        errorMessage = "Nfo File not found : " + strFilePath;
                    }
                }
                else
                {
                    errorMessage = "Nfo File not found : " + strFilePath;
                }
            }
        }
        public void GetInfoFromWeb(IMyCollectionsData item)
        {
            Nds objEntity = item as Nds;

            if (objEntity == null)
            {
                return;
            }

            bool bFind = false;

            if (objEntity.IsComplete == false)
            {
                string strSearch = objEntity.Title;

                if (MySettings.CleanTitle == true)
                {
                    strSearch = Util.CleanExtensions(strSearch);
                }

                string search = strSearch;
                Task.Factory.StartNew(() => Util.NotifyEvent("getInfoFromWeb: NDS : " + search));
                Hashtable objResults = null;
                #region TheGamesDB
                if (MySettings.EnableGamesDBNds == true)
                {
                    Collection <PartialMatche> results = TheGamesDbServices.Search(strSearch, GamesPlateform.Nds);

                    if (results != null && results.Any())
                    {
                        objResults = TheGamesDbServices.Parse(results[0].Link);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region JeuxVideo
                if (bFind == false && MySettings.EnableJeuxVideoNds == true)
                {
                    Collection <PartialMatche> results = JeuxVideoComServices.Search(strSearch, "nintendo-ds");

                    if (results != null && results.Any())
                    {
                        objResults = JeuxVideoComServices.Parse(results[0].Link, strSearch);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon US
                if (bFind == false && MySettings.EnableAmazonNds == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.com, AmazonBrowserNode.DSUs);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.com, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon FR
                if (bFind == false && MySettings.EnableAmazonFrNds == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.fr, AmazonBrowserNode.DSFr);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.fr, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon DE
                if (bFind == false && MySettings.EnableAmazonDeNds == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.de, AmazonBrowserNode.DSDe);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.de, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon IT
                if (bFind == false && MySettings.EnableAmazonItNds == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.it, AmazonBrowserNode.DSIt);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.it, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon ES
                if (bFind == false && MySettings.EnableAmazonSpNds == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.es, AmazonBrowserNode.DSEs);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.es, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion

                CommonServices.Update(objEntity);
            }
        }
        public static Nds Fill(Hashtable objResults, Nds objEntity, ref bool bAllfind)
        {
            try
            {
                bAllfind = true;

                if (objResults != null)
                {
                    #region Background
                    if (objResults.ContainsKey("Background"))
                    {
                        if (objResults["Background"] != null)
                        {
                            RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity);
                        }
                    }
                    #endregion
                    #region BarCode
                    if (objResults.ContainsKey("BarCode"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.BarCode) == true)
                        {
                            objEntity.BarCode = objResults["BarCode"].ToString().Trim();
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.BarCode) == true)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Comments
                    if (objResults.ContainsKey("Comments"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Comments))
                        {
                            objEntity.Comments = objResults["Comments"].ToString().Trim();
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Comments) == true)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Description
                    if (objResults.ContainsKey("Description"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Description) == true)
                        {
                            objEntity.Description = objResults["Description"].ToString().Trim();
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Description) == true)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Image
                    int index;
                    if (objResults.ContainsKey("Image"))
                    {
                        if (objResults["Image"] != null)
                        {
                            if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                            {
                                byte[] objImage     = Util.GetImage(objResults["Image"].ToString());
                                byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                                if (objImage != null)
                                {
                                    if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength)
                                    {
                                        if (objResults["Image"] != null)
                                        {
                                            RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true);
                                            objEntity.RemoveCover = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Language
                    if (objResults.ContainsKey("Language"))
                    {
                        if (objEntity.Language == null)
                        {
                            objEntity.Language = LanguageServices.GetLanguage(objResults["Language"].ToString().Trim(), false);
                        }
                    }
                    if (objEntity.Language == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Links
                    if (objResults.ContainsKey("Links"))
                    {
                        LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false);
                    }
                    if (objEntity.Links.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Rating
                    if (objResults.ContainsKey("Rating"))
                    {
                        if (objEntity.PublicRating == null)
                        {
                            objEntity.PublicRating = Convert.ToInt32(objResults["Rating"], CultureInfo.InvariantCulture);
                        }
                    }
                    if (objEntity.PublicRating == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Released
                    if (objResults.ContainsKey("Released"))
                    {
                        if (objEntity.ReleaseDate == null &&
                            objResults["Released"].ToString().Trim().IndexOf("inconnue",
                                                                             StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            string strDate = objResults["Released"].ToString().Trim();
                            if (strDate.Length < 10)
                            {
                                if (strDate.Length == 4)
                                {
                                    DateTime objTemp =
                                        new DateTime(Convert.ToInt32(strDate, CultureInfo.InvariantCulture), 1, 1);
                                    objEntity.ReleaseDate = objTemp;
                                }
                                else
                                {
                                    DateTime objTmp;
                                    if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                    {
                                        objEntity.ReleaseDate = objTmp;
                                    }
                                }
                            }
                            else
                            {
                                DateTime objTmp;
                                if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                {
                                    objEntity.ReleaseDate = objTmp;
                                }
                            }
                        }
                    }
                    if (objEntity.ReleaseDate == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Title
                    if (objResults.ContainsKey("Title") && (string.IsNullOrWhiteSpace(objEntity.Title) || MySettings.RenameFile == true))
                    {
                        objEntity.Title = objResults["Title"].ToString();
                        if (MySettings.RenameFile == true && string.IsNullOrWhiteSpace(objEntity.FileName) == false)
                        {
                            objEntity.FileName = Util.RenameFile(objEntity.Title, objEntity.FileName, objEntity.FilePath);
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Title))
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Type
                    if (objResults.ContainsKey("Types"))
                    {
                        if (objResults["Types"].GetType() == typeof(List <string>))
                        {
                            GenreServices.AddGenres((IList <string>)objResults["Types"], objEntity, false);
                        }
                        else
                        {
                            GenreServices.AddGenres((IList <Genre>)objResults["Types"], objEntity, false);
                        }
                    }
                    if (objEntity.Genres.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                }
                else
                {
                    bAllfind = false;
                }

                objEntity.IsComplete = bAllfind;
                return(objEntity);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(objEntity);
            }
        }
        public static void Delete(string id)
        {
            Nds item = Dal.GetInstance.GetNdss(id);

            Dal.GetInstance.PurgeNds(item);
        }
Exemple #17
0
        public virtual void Calculate(Settings settings)
        {
            if (Waybill.Status == DocStatus.Posted)
            {
                return;
            }
            if (ServerRetailCost != null)
            {
                RetailCost = ServerRetailCost;
                if (ServerRetailMarkup != null)
                {
                    _retailMarkup     = ServerRetailMarkup;
                    _realRetailMarkup = ServerRetailMarkup;
                }
                else
                {
                    UpdateMarkups(ServerRetailMarkup);
                }
                NotifyRetailCostChanged();
                return;
            }

            if (!IsCalculable())
            {
                _retailCost        = null;
                _retailMarkup      = null;
                _realRetailMarkup  = null;
                _maxSupplierMarkup = null;
                MaxRetailMarkup    = null;
                NotifyRetailCostChanged();
                return;
            }

            var markupType = GetMarkupType();
            var sourceCost = markupType == MarkupType.Over || markupType == MarkupType.Nds18
                                ? SupplierCost.GetValueOrDefault()
                                : SupplierCostWithoutNds.GetValueOrDefault();

            if (markupType == MarkupType.VitallyImportant)
            {
                sourceCost = ProducerCost.GetValueOrDefault();
                if (RegistryCost.GetValueOrDefault() > 0 && (sourceCost == 0 || sourceCost > RegistryCost.GetValueOrDefault()))
                {
                    sourceCost = RegistryCost.GetValueOrDefault();
                }
                if (settings.UseSupplierPriceWithNdsForMarkup)
                {
                    sourceCost = sourceCost * (1 + (decimal)Nds.GetValueOrDefault() / 100);
                }
            }

            if (sourceCost == 0)
            {
                return;
            }
            if (!Waybill.IsAddressExists())
            {
                return;
            }
            if (!(SupplierCost != 0 && TaxFactor != 0 &&
                  (markupType == MarkupType.VitallyImportant && ProducerCost != 0
                   ||
                   markupType != MarkupType.VitallyImportant && SupplierCostWithoutNds != 0)))
            {
                return;
            }
            var markup = MarkupConfig.Calculate(settings.Markups, markupType, sourceCost, Waybill.Address);

            if (markup == null)
            {
                return;
            }

            MaxRetailMarkup    = markup.MaxMarkup;
            _maxSupplierMarkup = markup.MaxSupplierMarkup;
            //пересчет производится при каждом входе в накладную что бы отобразить актуальные данные если наценки были изменены
            //для позиций которые редактировал пользователь пересчитывать ничего не нужно иначе данные могут измениться
            //в результате ошибок округления
            if (Edited && !Waybill.IsCreatedByUser)
            {
                return;
            }

            _retailMarkup = markup.Markup;
            decimal?rawCost;

            _retailCost = CalculateRetailCost(RetailMarkup, out rawCost);
            //это лишено смысла но тем не менее analitf считает наценку от не округленной цены
            //что бы получить все выглядело идентично делаем тоже самое
            //тк RetailCost может быть округлена до большего то и наценка может увеличиться и превысить значение наценки которое
            //применялась в расчетах
            //наверное правильно всегда округлять до меньшего но analitf делает не так, делаем тоже что analitf
            UpdateMarkups(rawCost);
            NotifyRetailCostChanged();
        }
        private void ExportNds(string path, string separator, string newline)
        {
            try
            {
                IList items = NdsServices.Gets();

                for (int i = 0; i < items.Count; i++)
                {
                    Nds entity = items[i] as Nds;

                    CommonServices.GetChild(entity);
                    if (_isCancelationPending == true)
                    {
                        break;
                    }

                    StringBuilder row = new StringBuilder();
                    row.Append("Nds" + separator);
                    if (entity != null)
                    {
                        row.Append(entity.Title + separator);

                        if (entity.Publisher != null)
                        {
                            row.Append(entity.Publisher.Name + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + separator);
                        }

                        if (entity.ReleaseDate != null)
                        {
                            row.Append(entity.ReleaseDate.Value.ToShortDateString() + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + separator);
                        }

                        if (entity.MyRating != null)
                        {
                            row.Append(entity.MyRating + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + separator);
                        }

                        //FIX 2.8.9.0
                        string description = string.Empty;
                        if (entity.Comments != null)
                        {
                            description = entity.Description.Replace(separator, " ");
                        }

                        row.Append(description + separator);

                        StringBuilder types = new StringBuilder();
                        foreach (Genre item in entity.Genres)
                        {
                            if (types.Length == 0)
                            {
                                types.Append(item.DisplayName);
                            }
                            else
                            {
                                types.Append("," + item.DisplayName);
                            }
                        }

                        row.Append(types + separator);
                        row.Append(entity.AddedDate.ToShortDateString() + separator);

                        if (entity.Media != null)
                        {
                            row.Append(entity.Media.Name + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + separator);
                        }
                        row.Append(entity.FilePath + separator);
                        row.Append(entity.FileName + separator);
                    }

                    File.AppendAllText(path, row + newline, Encoding.UTF8);

                    _intAddedItem++;
                    Current++;
                    items[i] = null;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }
Exemple #19
0
 public void MergeFrom(ActiveData other)
 {
     if (other == null)
     {
         return;
     }
     if (other.total_ != null)
     {
         if (total_ == null)
         {
             total_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Total.MergeFrom(other.Total);
     }
     if (other.zap_ != null)
     {
         if (zap_ == null)
         {
             zap_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Zap.MergeFrom(other.Zap);
     }
     if (other.nds_ != null)
     {
         if (nds_ == null)
         {
             nds_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Nds.MergeFrom(other.Nds);
     }
     if (other.deb_ != null)
     {
         if (deb_ == null)
         {
             deb_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Deb.MergeFrom(other.Deb);
     }
     if (other.fin_ != null)
     {
         if (fin_ == null)
         {
             fin_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Fin.MergeFrom(other.Fin);
     }
     if (other.mon_ != null)
     {
         if (mon_ == null)
         {
             mon_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Mon.MergeFrom(other.Mon);
     }
     if (other.oth_ != null)
     {
         if (oth_ == null)
         {
             oth_ = new global::Grpc.Business.ExpressService.Pair();
         }
         Oth.MergeFrom(other.Oth);
     }
 }
Exemple #20
0
        private void ExportNds(Document doc)
        {
            try
            {
                WriteChapter(doc, "Nds");
                IList items = NdsServices.Gets();

                PdfPTable mainTable = new PdfPTable(1);

                for (int i = 0; i < items.Count; i++)
                {
                    Nds entity = items[i] as Nds;

                    CommonServices.GetChild(entity);
                    if (_isCancelationPending == true)
                    {
                        break;
                    }

                    if (entity != null)
                    {
                        Ressource cover = entity.Ressources.FirstOrDefault(x => x.IsDefault == true);
                        byte[]    image = null;

                        if (cover != null)
                        {
                            image = cover.Value;
                        }

                        PdfPTable table = WriteCover(image, entity.Title, true);

                        string editorName = string.Empty;
                        if (entity.Publisher != null)
                        {
                            editorName = entity.Publisher.Name;
                        }

                        PdfPTable text = WriteFirstRow(entity.Title, string.Empty, editorName);

                        DateTime releasedate = DateTime.MinValue;
                        if (entity.ReleaseDate != null)
                        {
                            releasedate = (DateTime)entity.ReleaseDate;
                        }

                        int rating = 0;
                        if (entity.MyRating != null)
                        {
                            rating = (int)entity.MyRating;
                        }

                        WriteSecondRow(releasedate, rating, text);
                        WriteDescription(entity.Description, text);

                        StringBuilder types = new StringBuilder();
                        foreach (Genre item in entity.Genres)
                        {
                            if (types.Length == 0)
                            {
                                types.Append(item.DisplayName);
                            }
                            else
                            {
                                types.Append("," + item.DisplayName);
                            }
                        }

                        WriteTypeRow(types.ToString(), entity.AddedDate.ToShortDateString(), text);

                        string media = string.Empty;
                        if (entity.Media != null)
                        {
                            media = entity.Media.Name;
                        }

                        WriteMediaInfo(media, entity.FilePath, entity.FileName, text);

                        table.AddCell(text);
                        table.SplitRows = false;

                        PdfPCell cell = new PdfPCell(table);
                        cell.Border      = 0;
                        cell.BorderColor = iTextSharp.text.BaseColor.WHITE;

                        mainTable.AddCell(cell);
                    }

                    _intAddedItem++;
                    Current++;
                    items[i] = null;
                }
                doc.Add(mainTable);

                doc.NewPage();
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }