Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            List <Record> records = new List <Record>();

            using (var context = new TSMContext())
            {
                records = context.Records.Where(r => r.IsActive == true && r.IsDeleted == false).ToList();
            }


            return;

            ImportRecords importRecords = new ImportRecords();

            importRecords.Import();

            //using (var context = new TSMContext())
            //{
            //    var sectors = from s in  context.Sectors.Include("Sector_Languages").Include("InternationalNomenclature").Include("ITCNomenclature")
            //                  join sl in context.Sector_Languages
            //                  on s.ID equals sl.ID
            //                  where sl.LanguageID =
            //}


            /*
             * Content content = new Content();
             * content.Type = ContentType.Search;
             * content.IsActive = true;
             * content.IsPublic = true;
             * content.URL = "/search";
             * content.CreatedBy = new Guid("BB02F113-54E3-4BC1-B41B-D10C366353F0");
             * content.CreatedDate = DateTime.Now;
             *
             *
             * content.Content_Languages = new List<Content_Language>();
             * Content_Language contentLanguage = new Content_Language();
             * contentLanguage.ID = content.ID;
             * contentLanguage.LanguageID = new Guid("9BB8D909-6ED8-4591-91CF-CB7FD190F162");
             * contentLanguage.Title = "Demo Title";
             * contentLanguage.SubTitle = "Demo SubTitle";
             * contentLanguage.Summary = "Demo Summary";
             * contentLanguage.PageTitle = "Demo PageTitle";
             * contentLanguage.PageKeywords = "Demo PageKeywords";
             * contentLanguage.PageMetadata = "Demo PageMetadata";
             *
             * List<PageContent> contents = new List<PageContent>();
             * contents.Add(new PageContent { Title = "Demo Title", HTML = "<p>Demo HTML</p>" });
             *
             * JavaScriptSerializer serializer = new JavaScriptSerializer();
             * string json = serializer.Serialize(contents);
             *
             * contentLanguage.Description = json;
             * contentLanguage.RightSection = json;
             *
             * content.Content_Languages.Add(contentLanguage);
             *
             * ContentService.Save(content);*/
        }
Ejemplo n.º 2
0
        public SectorType INTGetType(string sitcCode)
        {
            var SectorData = new TSMSector();

            using (var context = new TSMContext())
            {
                SectorData = context.TSMSector.Where(u => u.Code == sitcCode && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.ITC).FirstOrDefault();
            }
            var type = SectorData.Type;

            return(type);
        }
Ejemplo n.º 3
0
        public Guid GetITCSectorIDByName(string name, SectorType secType)
        {
            var ITC_Nom = new TSMSector();

            //string name = name.Trim();
            using (var context = new TSMContext())
            {
                ITC_Nom = context.TSMSector.Where(u => u.Name == name && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.ITC && u.Type == secType).FirstOrDefault();
            }
            Guid itcID = Guid.Empty;

            if (ITC_Nom != null)
            {
                itcID = ITC_Nom.ID;
            }
            return(itcID);
        }
Ejemplo n.º 4
0
        //GET ID by Code
        public Guid GetINTSectorID(string sitcCode, SectorType secType)
        {
            var    INT_Nom = new TSMSector();
            string code    = sitcCode.Trim();

            using (var context = new TSMContext())
            {
                INT_Nom = context.TSMSector.Where(u => u.Code == sitcCode && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.International && u.Type == secType).FirstOrDefault();
            }
            Guid intID = Guid.Empty;

            if (INT_Nom != null)
            {
                intID = INT_Nom.ID;
            }
            return(intID);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add Priority Sector
        /// </summary>
        /// <param name="dt"></param>
        ///

        private List <Sector> AddPrioritySector(DataTable dt, DataRow[] drSectorList)
        {
            List <Sector> sectors    = new List <Sector>();
            List <string> strategies = new List <string>();
            // List<string> names = new List<string>();
            List <SectorNameCode> listSecData = new List <SectorNameCode>();

            foreach (DataRow dr in drSectorList)
            {
                SectorNameCode secData = new SectorNameCode();

                string siteName = dr["priority_sector"].ToString().Trim();
                string sitcCode = dr["sitc2"].ToString().Trim();

                if (!string.IsNullOrEmpty(siteName) && !listSecData.Exists(n => n.Name == siteName && n.Code == sitcCode))
                {
                    //if (!string.IsNullOrEmpty(sitcCode) && !listSecData.Exists(n => n.Code == sitcCode))
                    //{
                    secData.Code = sitcCode;
                    secData.Name = siteName;
                    listSecData.Add(secData);

                    //names.Add(siteName);
                    Sector sector = new Sector();
                    sector.ID = Guid.NewGuid();

                    //GET TYPE
                    if (!string.IsNullOrEmpty(siteName) && !string.IsNullOrEmpty(sitcCode))
                    {
                        //sector.Type = ITCGetType(sitcCode);
                        sector.Type = SectorType.Product;
                    }
                    else
                    {
                        //sector.Type = INTGetType(sitcCode);
                        sector.Type = SectorType.Service;
                    }


                    Guid intNId = GetINTSectorID(sitcCode, sector.Type);

                    if (intNId == Guid.Empty)
                    {
                        intNId = GetINTSectorIDByName(siteName, sector.Type);
                    }

                    Guid itcNid = GetITCSectorID(sitcCode, sector.Type);
                    if (itcNid == Guid.Empty)
                    {
                        itcNid = GetITCSectorIDByName(siteName, sector.Type);
                    }

                    //GET ITC AND INT ID
                    if (itcNid == Guid.Empty)
                    {
                        sector.ITC_NomenclatureID = null;
                    }
                    else
                    {
                        sector.ITC_NomenclatureID = itcNid;
                    }

                    if (intNId == Guid.Empty)
                    {
                        sector.International_NomenclatureID = null;
                    }
                    else
                    {
                        sector.International_NomenclatureID = intNId;
                    }

                    sector.CreatedBy   = new Guid("BB02F113-54E3-4BC1-B41B-D10C366353F0");
                    sector.CreatedDate = DateTime.UtcNow;
                    sector.IsActive    = true;
                    sector.IsDeleted   = false;



                    //SECTOR LANGUAGE
                    sector.Sector_Languages = new List <Sector_Language>();
                    sector.Sector_Languages.Add(new Sector_Language
                    {
                        ID         = sector.ID,
                        LanguageID = new Guid("9BB8D909-6ED8-4591-91CF-CB7FD190F162"),
                        Name       = siteName,
                        Label      = siteName
                    });

                    sectors.Add(sector);



                    // }
                }
            }
            if (sectors.Count > 0)
            {
                using (TSMContext context = new TSMContext())
                {
                    context.Sectors.AddRange(sectors);
                    context.SaveChanges();
                }
            }

            return(sectors);
        }