コード例 #1
0
ファイル: Job.cs プロジェクト: tgiqfe/MdJob
 /// <summary>
 /// CodeTitleからCodeOptionをセット
 /// </summary>
 public void SetCodeOption()
 {
     if (!string.IsNullOrEmpty(CodeTitle) && CodeTitle.Contains(":"))
     {
         _option = Enum.TryParse(
             CodeTitle.Substring(CodeTitle.IndexOf(":") + 1), true, out CodeOption tempOption) ?
                   tempOption :
                   CodeOption.None;
     }
 }
コード例 #2
0
ファイル: NutritionStandards.cs プロジェクト: igprog/ppweb
    public string Init(string lang)
    {
        try {
            Data resp = new Data();
            resp.nutritionStandards = new List <CodeTitle>();
            resp.modules            = new List <NewModule>();
            string[] translations = T.Translations(lang);
            string   sql          = null;
            lang = string.IsNullOrEmpty(lang) ? "hr" : lang;
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + appDataBase))) {
                connection.Open();

                /***** Nutrition Standards *****/
                sql = string.Format(@"SELECT code, title FROM nutritionStandards WHERE country = '{0}' ORDER BY listOrder", lang);
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    using (SQLiteDataReader reader = command.ExecuteReader()) {
                        while (reader.Read())
                        {
                            CodeTitle x = new CodeTitle();
                            x.code  = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
                            x.title = reader.GetValue(1) == DBNull.Value ? null : T.Tran(reader.GetString(1), translations, lang);
                            resp.nutritionStandards.Add(x);
                        }
                    }
                }
                /***** Nutrition Standards *****/

                /***** Modules *****/
                sql = @"SELECT code, title, description, meals, perc, country FROM modules";
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    using (SQLiteDataReader reader = command.ExecuteReader()) {
                        while (reader.Read())
                        {
                            NewModule x = new NewModule();
                            x.code    = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
                            x.title   = reader.GetValue(1) == DBNull.Value ? null : T.Tran(reader.GetString(1), translations, lang);
                            x.desc    = reader.GetValue(2) == DBNull.Value ? null : T.Tran(reader.GetString(2), translations, lang);
                            x.meals   = JsonConvert.DeserializeObject <List <Meals.NewMeal> >(reader.GetValue(3) == DBNull.Value ? null : reader.GetString(3));
                            x.meals   = TranslateMeals(x.meals, lang);
                            x.perc    = reader.GetValue(4) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(4));
                            x.country = reader.GetValue(5) == DBNull.Value ? null : reader.GetString(5);
                            resp.modules.Add(x);
                        }
                    }
                }
                /***** Modules *****/
            }
            return(JsonConvert.SerializeObject(resp, Formatting.None));
        } catch (Exception e) {
            L.SendErrorLog(e, null, null, "NutritionStandards", "Init");
            return(JsonConvert.SerializeObject(e.Message, Formatting.None));
        }
    }
コード例 #3
0
 public void Insert(CodeTitle codeTitle)
 {
     try
     {
         if (codeTitle.Id == Guid.Empty)
         {
             codeTitle.Id = Guid.NewGuid();
         }
         this.Table.Add(codeTitle);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
コード例 #4
0
        public void Delete(CodeTitle entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                this.Table.Remove(entity);
                this.SubmitChanges();
            }
            catch
            {
                throw;
            }
        }