示例#1
0
 public void Compare(CatalogObject source, CatalogObject current)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine(vhoNumber + " : " + "AltCode : " + source.AltCode + "(" + source.AltCode.Length + ")");
     Console.ForegroundColor = ConsoleColor.White;
     List <Variance> rt = source.DetailedCompare(current);
 }
示例#2
0
        /// <summary>
        /// For a given VHO #, add any new unique AltCodes into our member vho
        /// When completed a VHO, cache this in the DB
        /// </summary>
        /// <param name="vhoNumber"></param>
        public async Task <bool> AddUniqueFromVHOAsync(MongoDB.Driver.IMongoCollection <CatalogObject> collection)
        {
            Dictionary <string, CatalogObject> vho = new Dictionary <string, CatalogObject>();

            string path = GetTemplate(vhoNumber, "d:\\img\\img\\", new DateTime(2015, 7, 21));

            if (path != string.Empty)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Processing VHO : " + vhoNumber);
                Console.ForegroundColor = ConsoleColor.White;
                try
                {
                    String tempFile = Decompress(path);
                    using (StreamReader file = new System.IO.StreamReader(tempFile, Encoding.UTF8))
                    {
                        string line;
                        while ((line = await file.ReadLineAsync()) != null)
                        {
                            CatalogObject json = JsonConvert.DeserializeObject <CatalogObject>(line);

                            if ((json.AltCode == string.Empty))//blank AltCode, prob single screen
                            {
                                if (singleScreen)
                                {
                                    //Use the PID PAID since the AltCode is missing
                                    json.AltCode = json.ProviderID + ":" + json.ProviderAssetID.Substring(4);
                                    await AddMediaAsync(collection, json);
                                }
                            }
                            else if (multiScreen)
                            {
                                await AddMediaAsync(collection, json);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception caught opening file :" + ex.Message);
                }
            }
            //and Upsert the vho!
            //await collection.InsertManyAsync(vho.Values);
            return(true);
        }
示例#3
0
        public async Task AddMediaAsync(MongoDB.Driver.IMongoCollection <CatalogObject> collection, CatalogObject json)
        {
            try
            {
                //var found = vho.TryGetValue(json.AltCode, out r);
                var filter = Builders <CatalogObject> .Filter.Eq("AltCode", json.AltCode);

                var found = await collection.Find(filter).ToListAsync();

                if (found.Count > 0)
                {
                    //check to see if its an exact copy, if it is then skip
                    var r = found[0];
                    if (r.GetHashCode() != json.GetHashCode())
                    {
                        if (json.IsHD)//only add values/updates from the HD version
                        {
                            //vho[json.AltCode] = json;
                            if (null != collection.Find(json.AltCode))
                            {
                                await collection.ReplaceOneAsync(x => x.AltCode == json.AltCode, json);
                            }
                            else
                            {
                                await collection.InsertOneAsync(json);
                            }
                            Compare(r, json);
                        }
                        else
                        {
                            //need to Add Avails data for nonHD here which requires making the private fields into a list of...
                        }
                    }
                }
                else
                {
                    //Not this is unusual and an error
                    //So possible outcome here is we have same content but first four chars dont match, but content is same
                    //var dict = vho.Where(kvp => json.ProviderAssetID.Substring(4)).SelectMany(kvp => kvp.Value);
                    //var dict = vho.SelectMany(m => m).Where(k => vho.Keys.Contains(json.ProviderAssetID.Substring(4)));

                    /*var selectValues = (from keyValuePair in vho
                     *                  where keyValuePair.Key.Contains(json.ProviderAssetID.Substring(4))
                     *                  select keyValuePair.Value).ToList();
                     * if (selectValues.Count > 1)
                     *  Console.WriteLine(vhoNumber + " : " + json.AltCode);
                     */
                    //vho[json.AltCode] = json;
                    if (null == collection.Find(json.AltCode))
                    {
                        await collection.ReplaceOneAsync(x => x.AltCode == json.AltCode, json);
                    }
                    else
                    {
                        await collection.InsertOneAsync(json);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#4
0
        public async Task AddMediaAsync(MongoDB.Driver.IMongoCollection<CatalogObject> collection, CatalogObject json)
        {
            try
            {
                //var found = vho.TryGetValue(json.AltCode, out r);
                var filter = Builders<CatalogObject>.Filter.Eq("AltCode", json.AltCode);
                var found = await collection.Find(filter).ToListAsync();

                if (found.Count > 0)
                {
                    //check to see if its an exact copy, if it is then skip
                    var r = found[0];
                    if (r.GetHashCode() != json.GetHashCode())
                    {
                        if (json.IsHD)//only add values/updates from the HD version
                        {
                            //vho[json.AltCode] = json;
                            if (null != collection.Find(json.AltCode))
                            {
                                await collection.ReplaceOneAsync(x => x.AltCode == json.AltCode, json);
                            }
                            else
                            {
                                await collection.InsertOneAsync(json);
                            }
                            Compare(r, json);
                        }
                        else
                        {
                            //need to Add Avails data for nonHD here which requires making the private fields into a list of...
                        }
                    }
                }
                else
                {
                    //Not this is unusual and an error
                    //So possible outcome here is we have same content but first four chars dont match, but content is same
                    //var dict = vho.Where(kvp => json.ProviderAssetID.Substring(4)).SelectMany(kvp => kvp.Value);
                    //var dict = vho.SelectMany(m => m).Where(k => vho.Keys.Contains(json.ProviderAssetID.Substring(4)));
                    /*var selectValues = (from keyValuePair in vho
                                        where keyValuePair.Key.Contains(json.ProviderAssetID.Substring(4))
                                        select keyValuePair.Value).ToList();
                    if (selectValues.Count > 1)
                        Console.WriteLine(vhoNumber + " : " + json.AltCode);
                    */
                    //vho[json.AltCode] = json;
                    if (null == collection.Find(json.AltCode))
                    {
                        await collection.ReplaceOneAsync(x => x.AltCode == json.AltCode, json);
                    }
                    else
                    {
                        await collection.InsertOneAsync(json);
                    }
                    
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }    
示例#5
0
 public void Compare(CatalogObject source, CatalogObject current)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine(vhoNumber + " : " + "AltCode : " + source.AltCode + "(" + source.AltCode.Length + ")");
     Console.ForegroundColor = ConsoleColor.White;
     List<Variance> rt = source.DetailedCompare(current);
 }