コード例 #1
0
        private List <Actions> GetActionsListForCheckedAnalise(string checkedAnaliseTitle)
        {
            List <Actions> tempList = new List <Actions>();

            List <string> actionsTitles = new List <string>();
            List <int>    actionsTimes  = new List <int>();

            using (var db = new SQLiteConnection(localSettings.Values["OldAnalisesDBPath"] as string))
            {
                var         analisesListFromDB = from an in db.Table <OldAnalises>() where an.Title == checkedAnaliseTitle select an;
                OldAnalises analise            = analisesListFromDB.FirstOrDefault();
                string[]    actionsStringArray = analise.ActionsList.Split(';');
                for (int a = 0; a < actionsStringArray.Length - 1; a++)
                {
                    actionsTitles.Add(actionsStringArray[a]);
                }
                string[] actionsTimesStringArray = analise.TimesForActions.Split(';');
                for (int a = 0; a < actionsTimesStringArray.Length - 1; a++)
                {
                    int temp;
                    int.TryParse(actionsTimesStringArray[a], out temp);
                    actionsTimes.Add(temp);
                }
                for (int c = 0; c < actionsTitles.Count; c++)
                {
                    tempList.Add(new Actions()
                    {
                        Title = actionsTitles[c], SpendedTimeInSeconds = actionsTimes[c]
                    });
                }
                return(tempList);
            }
        }
コード例 #2
0
        private void SaveThisAnaliseToBaseOfAnalises()
        {
            string allActionsOfThisAnalise      = "";
            string allTimesPeriodsOfThisAnalise = "";

            using (var dbActions = new SQLite.SQLiteConnection(localSettings.Values["ActionsDBPath"] as string))
            {
                var allActions = dbActions.Query <Actions>("SELECT * FROM Actions");
                foreach (Actions iter in allActions)
                {
                    allActionsOfThisAnalise      += iter.Title + ";";
                    allTimesPeriodsOfThisAnalise += iter.SpendedTimeInSeconds.ToString() + ";";
                }
            }
            string analiseName = FormStringOfAnaliseNameFromCurrentDate();

            using (var db = new SQLite.SQLiteConnection(localSettings.Values["OldAnalisesDBPath"] as string))
            {
                var analise = new OldAnalises()
                {
                    Title = analiseName.ToString(), ActionsList = allActionsOfThisAnalise, TimesForActions = allTimesPeriodsOfThisAnalise, DateTimeOfSave = DateTime.Now
                };
                db.Insert(analise);
            }
        }