Example #1
0
 public void GetData()
 {
     foreach (XElement CategoryElement in xdoc.Element("Db").Elements("Category"))
     {
         XAttribute nameAttribute = CategoryElement.Attribute("name");
         Category   bufCategory   = new Category();
         bufCategory.Name = nameAttribute.Value;
         List <Product> bufProducts = new List <Product>();
         foreach (XElement ProductElement in CategoryElement.Elements("Product"))
         {
             Product  bufProduct      = new Product();
             XElement nameElement     = ProductElement.Element("Name");
             XElement GrammsElement   = ProductElement.Element("Gramms");
             XElement ProteinElement  = ProductElement.Element("Protein");
             XElement FatsElement     = ProductElement.Element("Fats");
             XElement CarbsElement    = ProductElement.Element("Carbs");
             XElement CaloriesElement = ProductElement.Element("Calories");
             bufProduct.Name     = nameElement.Value;
             bufProduct.Gramms   = int.Parse(GrammsElement.Value);
             bufProduct.Protein  = double.Parse(ProteinElement.Value);
             bufProduct.Fats     = double.Parse(FatsElement.Value);
             bufProduct.Carbs    = double.Parse(CarbsElement.Value);
             bufProduct.Calories = double.Parse(CaloriesElement.Value);
             bufProducts.Add(bufProduct);
         }
         bufCategory.products = bufProducts;
         resultCategories.Add(bufCategory);
     }
 }
    void AddIndividualCategory(Category newCat)
    {
        CategoryElement newCategoryElement = Instantiate(categoryElement.gameObject, categoryGrid.transform).GetComponent <CategoryElement> ();

        newCategoryElement.PopulateData(newCat);
        availableCategories.Add(newCat);
        categoryElementsGenerated.Add(newCategoryElement);
    }
 void PopulateCategories()
 {
     // DeleteAllCategoriesGeneratedElements();
     for (int i = 0; i < availableCategories.Count; i++)
     {
         CategoryElement newCategoryElement = Instantiate(categoryElement.gameObject, categoryGrid.transform).GetComponent <CategoryElement> ();
         newCategoryElement.PopulateData(availableCategories[i]);
     }
 }
Example #4
0
        public ActionResult AddtoDB(string catId)
        {
            //string cn = submit.Substring(4, submit.Length-4);
            int  uid         = (int)Session["uid"];
            User currentUser = db.Users.Where(user => user.UserId == uid).FirstOrDefault();

            //Category category = db.Categories.Where(cat => cat.Title == cn).FirstOrDefault();
            string[] dbCategories = currentUser.Categories.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (!dbCategories.Contains(catId))
            {
                string allCategories = currentUser.Categories + "," + catId /*category.CategoryId*/;
                currentUser.Categories = allCategories;
                db.Users.Attach(currentUser);
                var entry = db.Entry(currentUser);
                entry.Property(e => e.Categories).IsModified = true;
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "Account", CategoryElement.GetElementsFromFile(Server.MapPath(@"~/App_Data/Categories.xml")).Cast <MainCategory>()));
        }
 public ActionResult Index()
 {
     return(View(CategoryElement.GetElementsFromFile(Server.MapPath(@"~/App_Data/Categories.xml"), "Categories", "Category")));
 }
Example #6
0
 public ActionResult Index()
 {
     return(View(CategoryElement.GetElementsFromFile(Server.MapPath(@"~/App_Data/Activities.xml"), "Activities", "Activity").Cast <MainCategory>()));
 }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as AdverseEvent;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (CategoryElement != null)
            {
                dest.CategoryElement = (Code <Hl7.Fhir.Model.AdverseEvent.AdverseEventCategory>)CategoryElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (DateElement != null)
            {
                dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
            }
            if (Reaction != null)
            {
                dest.Reaction = new List <Hl7.Fhir.Model.ResourceReference>(Reaction.DeepCopy());
            }
            if (Location != null)
            {
                dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy();
            }
            if (Seriousness != null)
            {
                dest.Seriousness = (Hl7.Fhir.Model.CodeableConcept)Seriousness.DeepCopy();
            }
            if (Outcome != null)
            {
                dest.Outcome = (Hl7.Fhir.Model.CodeableConcept)Outcome.DeepCopy();
            }
            if (Recorder != null)
            {
                dest.Recorder = (Hl7.Fhir.Model.ResourceReference)Recorder.DeepCopy();
            }
            if (EventParticipant != null)
            {
                dest.EventParticipant = (Hl7.Fhir.Model.ResourceReference)EventParticipant.DeepCopy();
            }
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (SuspectEntity != null)
            {
                dest.SuspectEntity = new List <Hl7.Fhir.Model.AdverseEvent.SuspectEntityComponent>(SuspectEntity.DeepCopy());
            }
            if (SubjectMedicalHistory != null)
            {
                dest.SubjectMedicalHistory = new List <Hl7.Fhir.Model.ResourceReference>(SubjectMedicalHistory.DeepCopy());
            }
            if (ReferenceDocument != null)
            {
                dest.ReferenceDocument = new List <Hl7.Fhir.Model.ResourceReference>(ReferenceDocument.DeepCopy());
            }
            if (Study != null)
            {
                dest.Study = new List <Hl7.Fhir.Model.ResourceReference>(Study.DeepCopy());
            }
            return(dest);
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DeviceMetric;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Unit != null)
            {
                dest.Unit = (Hl7.Fhir.Model.CodeableConcept)Unit.DeepCopy();
            }
            if (Source != null)
            {
                dest.Source = (Hl7.Fhir.Model.ResourceReference)Source.DeepCopy();
            }
            if (Parent != null)
            {
                dest.Parent = (Hl7.Fhir.Model.ResourceReference)Parent.DeepCopy();
            }
            if (OperationalStatusElement != null)
            {
                dest.OperationalStatusElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricOperationalStatus>)OperationalStatusElement.DeepCopy();
            }
            if (ColorElement != null)
            {
                dest.ColorElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricColor>)ColorElement.DeepCopy();
            }
            if (CategoryElement != null)
            {
                dest.CategoryElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricCategory>)CategoryElement.DeepCopy();
            }
            if (MeasurementPeriod != null)
            {
                dest.MeasurementPeriod = (Hl7.Fhir.Model.Timing)MeasurementPeriod.DeepCopy();
            }
            if (Calibration != null)
            {
                dest.Calibration = new List <Hl7.Fhir.Model.DeviceMetric.CalibrationComponent>(Calibration.DeepCopy());
            }
            return(dest);
        }
Example #9
0
        /// <summary>
        /// 是否显示该属性
        /// </summary>
        /// <param name="categoryElement">界面元素</param>
        /// <returns>是/否</returns>
        public bool IsShowElement(CategoryElement categoryElement)
        {
            var val = string.Format(",{0},", Convert.ToInt32(categoryElement));

            return(Menu.HtmlType.Contains(val));
        }
Example #10
0
        internal static void ReadFromFile()
        {
            string userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            string configPath        = userProfileFolder + @"\wei-outlook-add-in\config.xml";

            if (File.Exists(configPath) == false)
            {
                throw new Exception("config.xml not exist");
            }
            XDocument xmlDocument = XDocument.Load(configPath);

            XElement AutoBackupEmailFromMeElement = xmlDocument.Root.Element("AutoBackupEmailFromMe");

            if (AutoBackupEmailFromMeElement != null)
            {
                if (AutoBackupEmailFromMeElement.Value == "false")
                {
                    AutoBackupEmailFromMe = false;
                }
            }
            if (AutoBackupEmailFromMe == true)
            {
                XElement MyEmailAddressElement = xmlDocument.Root.Element("MyEmailAddress");
                if (MyEmailAddressElement == null)
                {
                    throw new Exception("MyEmailAddress not set");
                }
                MyEmailAddress = MyEmailAddressElement.Value;
                if (MyEmailAddress == "")
                {
                    throw new Exception("MyEmailAddress not set");
                }
            }

            XElement EmailBackupPathElement = xmlDocument.Root.Element("EmailBackupPath");

            if (EmailBackupPathElement == null)
            {
                throw new Exception("EmailBackupPath not set");
            }
            EmailBackupPath = EmailBackupPathElement.Value;
            if (Directory.Exists(EmailBackupPath) == false)
            {
                Directory.CreateDirectory(EmailBackupPath);
            }

            XElement AttachmentBackupPathElement = xmlDocument.Root.Element("AttachmentBackupPath");

            if (AttachmentBackupPathElement == null)
            {
                throw new Exception("AttachmentBackupPath not set");
            }
            AttachmentBackupPath = AttachmentBackupPathElement.Value;
            if (Directory.Exists(AttachmentBackupPath) == false)
            {
                Directory.CreateDirectory(AttachmentBackupPath);
            }

            XElement EnableAutoBccElement = xmlDocument.Root.Element("EnableAutoBcc");

            if (EnableAutoBccElement != null)
            {
                if (EnableAutoBccElement.Value == "true")
                {
                    EnableAutoBcc = true;

                    XElement AutoBccEmailAddressElement = xmlDocument.Root.Element("AutoBccEmailAddress");
                    if (AutoBccEmailAddressElement == null)
                    {
                        throw new Exception("AutoBccEmailAddress not set");
                    }
                    AutoBccEmailAddress = AutoBccEmailAddressElement.Value;
                    if (AutoBccEmailAddress == "")
                    {
                        throw new Exception("AutoBccEmailAddress not set");
                    }
                }
            }

            if (xmlDocument.Root.Element("Zoom") == null ||
                Int32.TryParse(xmlDocument.Root.Element("Zoom").Value, out Zoom) == false)
            {
                Zoom = 150;
            }

            IEnumerable <XElement> CategoryElements = xmlDocument.Root.Elements("Category");

            foreach (XElement CategoryElement in CategoryElements)
            {
                XAttribute        label = CategoryElement.Attribute("label");
                XAttribute        color = CategoryElement.Attribute("color");
                CategoryUtil.Data data  = new CategoryUtil.Data {
                    label = label.Value,
                    color = CategoryUtil.GetColor(color.Value)
                };
                Categories.Add(data);
            }

            IEnumerable <XElement> FixedReplyElements = xmlDocument.Root.Elements("FixedReply");

            foreach (XElement FixedReplyElement in FixedReplyElements)
            {
                XAttribute          label = FixedReplyElement.Attribute("label");
                XAttribute          text  = FixedReplyElement.Attribute("text");
                FixedReplyUtil.Data data  = new FixedReplyUtil.Data {
                    label = label.Value,
                    text  = text.Value
                };
                FixedReplies.Add(data);
            }

            XElement DefaultChineseElement = xmlDocument.Root.Element("DefaultChinese");

            if (DefaultChineseElement == null)
            {
                throw new Exception("DefaultChinese not set");
            }
            string DefaultChineseStr = DefaultChineseElement.Value;

            switch (DefaultChineseStr)
            {
            case "Simplified": DefaultChinese = ConvertChineseUtil.ChineseType.SimplifiedChinese; break;

            case "Traditional": DefaultChinese = ConvertChineseUtil.ChineseType.TraditionalChinese; break;

            default: throw new Exception("DefaultChinese not set to Simplified or Traditional");
            }

            IEnumerable <XElement> SimplifiedChineseDeptsElements = xmlDocument.Root.Elements("SimplifiedChineseDept");

            foreach (XElement SimplifiedChineseDeptsElement in SimplifiedChineseDeptsElements)
            {
                XAttribute startsWith = SimplifiedChineseDeptsElement.Attribute("startsWith");
                SimplifiedChineseDepts.Add(startsWith.Value);
            }

            IEnumerable <XElement> TraditionalChineseDeptsElements = xmlDocument.Root.Elements("TraditionalChineseDept");

            foreach (XElement TraditionalChineseDeptsElement in TraditionalChineseDeptsElements)
            {
                XAttribute startsWith = TraditionalChineseDeptsElement.Attribute("startsWith");
                TraditionalChineseDepts.Add(startsWith.Value);
            }
        }
Example #11
0
        public ActionResult Index()
        {
            ViewBag.Title = "My profile";
            ViewBag.Id    = Session["uid"];
            int           uid         = (int)Session["uid"];
            User          currentUser = db.Users.Where(user => user.UserId == uid).FirstOrDefault();
            List <string> categories  = currentUser.Categories?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            //List<int> categoriesId = new List<int>();
            List <string> catTitles = new List <string>();

            if (categories == null)
            {
                ViewBag.ActivityTitles = new List <string>();
                return(View(catTitles));
            }
            var categoriesXml = CategoryElement.GetElementsFromFile(Server.MapPath(@"~/App_Data/Categories.xml"), "Categories", "Category").Cast <MainCategory>();

            //for (int i = 0; i<categories.Count; i++)
            //      {
            //       categoriesId.Add(Convert.ToInt32(categories[i]));
            //      }
            //categories.Clear();
            foreach (var category in categoriesXml.Select(c => c.Elements).SelectMany(i => i))
            {
                foreach (var dbCats in categories)
                {
                    if (dbCats == category.Id)
                    {
                        catTitles.Add(category.Title);
                    }
                }
                //var categoryId = db.Categories.Where(cat => cat.CategoryId == categoryId).FirstOrDefault();
            }

            List <string> activities = currentUser.Activities?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            //List<int> categoriesId = new List<int>();
            List <string> actTitles = new List <string>();

            if (activities == null)
            {
                ViewBag.ActivityTitles = actTitles;
                return(View(catTitles));
            }
            var activitiesXml = CategoryElement.GetElementsFromFile(Server.MapPath(@"~/App_Data/Activities.xml"), "Activities", "Activity").Cast <MainCategory>();

            //for (int i = 0; i<categories.Count; i++)
            //      {
            //       categoriesId.Add(Convert.ToInt32(categories[i]));
            //      }
            //categories.Clear();
            foreach (var activity in activitiesXml.Select(c => c.Elements).SelectMany(i => i))
            {
                foreach (var dbActs in activities)
                {
                    if (dbActs == activity.Id)
                    {
                        catTitles.Add(activity.Title);
                    }
                }
                //var categoryId = db.Categories.Where(cat => cat.CategoryId == categoryId).FirstOrDefault();
            }
            ViewBag.ActivityTitles = actTitles;
            return(View(catTitles));
        }
Example #12
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (CategoryElement != null)
                {
                    result.AddRange(CategoryElement.Validate());
                }
                if (Code != null)
                {
                    result.AddRange(Code.Validate());
                }
                if (StatusElement != null)
                {
                    result.AddRange(StatusElement.Validate());
                }
                if (ProhibitedElement != null)
                {
                    result.AddRange(ProhibitedElement.Validate());
                }
                if (Timing != null)
                {
                    result.AddRange(Timing.Validate());
                }
                if (Location != null)
                {
                    result.AddRange(Location.Validate());
                }
                if (Performer != null)
                {
                    Performer.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (Product != null)
                {
                    result.AddRange(Product.Validate());
                }
                if (DailyAmount != null)
                {
                    result.AddRange(DailyAmount.Validate());
                }
                if (Quantity != null)
                {
                    result.AddRange(Quantity.Validate());
                }
                if (DetailsElement != null)
                {
                    result.AddRange(DetailsElement.Validate());
                }
                if (ActionTaken != null)
                {
                    ActionTaken.ForEach(elem => result.AddRange(elem.Validate()));
                }
                if (NotesElement != null)
                {
                    result.AddRange(NotesElement.Validate());
                }

                return(result);
            }
    public override IDeepCopyable CopyTo(IDeepCopyable other)
    {
      var dest = other as AllergyIntolerance;

      if (dest == null)
      {
        throw new ArgumentException("Can only copy to an object of the same type", "other");
      }

      base.CopyTo(dest);
      if(Identifier != null) dest.Identifier = new List<Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
      if(ClinicalStatus != null) dest.ClinicalStatus = (Hl7.Fhir.Model.CodeableConcept)ClinicalStatus.DeepCopy();
      if(VerificationStatus != null) dest.VerificationStatus = (Hl7.Fhir.Model.CodeableConcept)VerificationStatus.DeepCopy();
      if(TypeElement != null) dest.TypeElement = (Code<Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceType>)TypeElement.DeepCopy();
      if(CategoryElement != null) dest.CategoryElement = new List<Code<Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceCategory>>(CategoryElement.DeepCopy());
      if(CriticalityElement != null) dest.CriticalityElement = (Code<Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceCriticality>)CriticalityElement.DeepCopy();
      if(Code != null) dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
      if(Patient != null) dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
      if(Encounter != null) dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy();
      if(Onset != null) dest.Onset = (Hl7.Fhir.Model.Element)Onset.DeepCopy();
      if(RecordedDateElement != null) dest.RecordedDateElement = (Hl7.Fhir.Model.FhirDateTime)RecordedDateElement.DeepCopy();
      if(Recorder != null) dest.Recorder = (Hl7.Fhir.Model.ResourceReference)Recorder.DeepCopy();
      if(Asserter != null) dest.Asserter = (Hl7.Fhir.Model.ResourceReference)Asserter.DeepCopy();
      if(LastOccurrenceElement != null) dest.LastOccurrenceElement = (Hl7.Fhir.Model.FhirDateTime)LastOccurrenceElement.DeepCopy();
      if(Note != null) dest.Note = new List<Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
      if(Reaction != null) dest.Reaction = new List<Hl7.Fhir.Model.AllergyIntolerance.ReactionComponent>(Reaction.DeepCopy());
      return dest;
    }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as AllergyIntolerance;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (OnsetElement != null)
                {
                    dest.OnsetElement = (Hl7.Fhir.Model.FhirDateTime)OnsetElement.DeepCopy();
                }
                if (RecordedDateElement != null)
                {
                    dest.RecordedDateElement = (Hl7.Fhir.Model.FhirDateTime)RecordedDateElement.DeepCopy();
                }
                if (Recorder != null)
                {
                    dest.Recorder = (Hl7.Fhir.Model.ResourceReference)Recorder.DeepCopy();
                }
                if (Patient != null)
                {
                    dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
                }
                if (Reporter != null)
                {
                    dest.Reporter = (Hl7.Fhir.Model.ResourceReference)Reporter.DeepCopy();
                }
                if (Substance != null)
                {
                    dest.Substance = (Hl7.Fhir.Model.CodeableConcept)Substance.DeepCopy();
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceStatus>)StatusElement.DeepCopy();
                }
                if (CriticalityElement != null)
                {
                    dest.CriticalityElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceCriticality>)CriticalityElement.DeepCopy();
                }
                if (TypeElement != null)
                {
                    dest.TypeElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceType>)TypeElement.DeepCopy();
                }
                if (CategoryElement != null)
                {
                    dest.CategoryElement = (Code <Hl7.Fhir.Model.AllergyIntolerance.AllergyIntoleranceCategory>)CategoryElement.DeepCopy();
                }
                if (LastOccurenceElement != null)
                {
                    dest.LastOccurenceElement = (Hl7.Fhir.Model.FhirDateTime)LastOccurenceElement.DeepCopy();
                }
                if (Note != null)
                {
                    dest.Note = (Hl7.Fhir.Model.Annotation)Note.DeepCopy();
                }
                if (Reaction != null)
                {
                    dest.Reaction = new List <Hl7.Fhir.Model.AllergyIntolerance.ReactionComponent>(Reaction.DeepCopy());
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Example #15
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as CarePlanActivitySimpleComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (CategoryElement != null)
                    {
                        dest.CategoryElement = (Code <Hl7.Fhir.Model.CarePlan.CarePlanActivityCategory>)CategoryElement.DeepCopy();
                    }
                    if (Code != null)
                    {
                        dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
                    }
                    if (Timing != null)
                    {
                        dest.Timing = (Hl7.Fhir.Model.Element)Timing.DeepCopy();
                    }
                    if (Location != null)
                    {
                        dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy();
                    }
                    if (Performer != null)
                    {
                        dest.Performer = new List <Hl7.Fhir.Model.ResourceReference>(Performer.DeepCopy());
                    }
                    if (Product != null)
                    {
                        dest.Product = (Hl7.Fhir.Model.ResourceReference)Product.DeepCopy();
                    }
                    if (DailyAmount != null)
                    {
                        dest.DailyAmount = (Hl7.Fhir.Model.Quantity)DailyAmount.DeepCopy();
                    }
                    if (Quantity != null)
                    {
                        dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
                    }
                    if (DetailsElement != null)
                    {
                        dest.DetailsElement = (Hl7.Fhir.Model.FhirString)DetailsElement.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }