Пример #1
0
        internal static bool SaveNewNote(PNote note)
        {
            try
            {
                var sb = new StringBuilder();
                note.DateSaved = DateTime.Now;

                sb.Append("INSERT INTO NOTES (ID, NAME, GROUP_ID, PREV_GROUP_ID, OPACITY, VISIBLE, FAVORITE, PROTECTED, COMPLETED, PRIORITY, PASSWORD_STRING, PINNED, TOPMOST, ROLLED, DOCK_STATUS, DOCK_ORDER, SEND_RECEIVE_STATUS, DATE_CREATED, DATE_SAVED, DATE_SENT, DATE_RECEIVED, DATE_DELETED, SIZE, LOCATION, EDIT_SIZE, REL_X, REL_Y, SENT_TO, RECEIVED_FROM, PIN_CLASS, PIN_TEXT, SCRAMBLED, RECEIVED_IP) VALUES('");
                sb.Append(note.ID);
                sb.Append("', '");
                sb.Append(note.Name.Replace("'", "''"));
                sb.Append("', ");
                sb.Append(note.GroupID);
                sb.Append(", ");
                sb.Append(note.GroupID);   //as prev png
                sb.Append(", ");
                sb.Append(note.Opacity.ToString(PNStatic.CultureInvariant));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Visible));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Favorite));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Protected));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Completed));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Priority));
                sb.Append(", '");
                sb.Append(note.PasswordString.Replace("'", "''"));
                sb.Append("', ");
                sb.Append(Convert.ToInt32(note.Pinned));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Topmost));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Rolled));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.DockStatus));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.DockOrder));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.SentReceived));
                sb.Append(", '");
                sb.Append(note.DateCreated.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateSaved.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateSent.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateReceived.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateDeleted.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                var sc = new SizeConverter();
                sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteSize));
                sb.Append("', '");
                var pc = new PointConverter();
                sb.Append(pc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteLocation));
                sb.Append("', '");
                var scd = new System.Drawing.SizeConverter();
                sb.Append(scd.ConvertToString(null, PNStatic.CultureInvariant, note.EditSize));
                sb.Append("', ");
                var factors = getRelationalFactors(note);
                sb.Append(factors[0].ToString(PNStatic.CultureInvariant));
                sb.Append(", ");
                sb.Append(factors[1].ToString(PNStatic.CultureInvariant));
                sb.Append(", '");
                sb.Append(note.SentTo.Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.ReceivedFrom.Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.PinClass);
                sb.Append("', '");
                sb.Append(note.PinText);
                sb.Append("', ");
                sb.Append(Convert.ToInt32(note.Scrambled));
                sb.Append(", '");
                sb.Append(note.ReceivedIp);
                sb.Append("'");
                sb.Append(")");
                using (var oData = new SQLiteDataObject(PNData.ConnectionString))
                {
                    oData.Execute(sb.ToString());
                }
                note.FromDB = true;
                if (note.Skinless != null)
                {
                    SaveNoteSkinless(note);
                }
                return true;
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
                return false;
            }
        }
Пример #2
0
 internal static void SaveNoteSize(PNote note, Size size, System.Drawing.Size editSize)
 {
     try
     {
         note.NoteSize = size;
         note.EditSize = editSize;
         if (note.FromDB)
         {
             var sc = new SizeConverter();
             var scd = new System.Drawing.SizeConverter();
             var sb = new StringBuilder();
             sb.Append("UPDATE NOTES SET SIZE = '");
             sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteSize));
             sb.Append("', EDIT_SIZE = '");
             sb.Append(scd.ConvertToString(null, PNStatic.CultureInvariant, note.EditSize));
             sb.Append("' WHERE ID = '");
             sb.Append(note.ID);
             sb.Append("'");
             using (var oData = new SQLiteDataObject(PNData.ConnectionString))
             {
                 oData.Execute(sb.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Пример #3
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof (string)) return base.ConvertTo(context, culture, value, destinationType);
            var note = value as PNote;
            if (note == null) return "";
            var bt = new StringBuilder();
            var dtc = new DateTimeConverter();
            var szc = new SizeConverter();
            var scd = new System.Drawing.SizeConverter();
            var ptc = new PointConverter();
            var scv = new ScheduleConverter();
            var skc = new SkinlessConverter();
            var sb = new StringBuilder();

            sb.Append(note.Changed);
            sb.Append(DEL_NOTE);
            sb.Append(note.Completed);
            sb.Append(DEL_NOTE);
            sb.Append(note.CustomOpacity);
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateCreated));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateDeleted));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateReceived));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateSaved));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateSent));
            sb.Append(DEL_NOTE);
            sb.Append((int)note.DockStatus);
            sb.Append(DEL_NOTE);
            sb.Append(scd.ConvertToString(null, PNStatic.CultureInvariant, note.EditSize));
            sb.Append(DEL_NOTE);
            sb.Append(note.Favorite);
            sb.Append(DEL_NOTE);
            sb.Append(note.FromDB);
            sb.Append(DEL_NOTE);
            sb.Append(note.GroupID);
            sb.Append(DEL_NOTE);
            sb.Append(note.ID);
            sb.Append(DEL_NOTE);
            foreach (var s in note.LinkedNotes)
            {
                bt.Append(s);
                bt.Append(DEL_INNER);
            }
            if (bt.Length > 0)
                bt.Length -= 1;
            sb.Append(bt);
            sb.Append(DEL_NOTE);
            sb.Append(note.Name);
            sb.Append(DEL_NOTE);
            sb.Append(ptc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteLocation));
            sb.Append(DEL_NOTE);
            sb.Append(szc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteSize));
            sb.Append(DEL_NOTE);
            sb.Append(note.Opacity.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.PasswordString);
            sb.Append(DEL_NOTE);
            sb.Append(note.Pinned);
            sb.Append(DEL_NOTE);
            sb.Append(note.PrevGroupID);
            sb.Append(DEL_NOTE);
            sb.Append(note.Priority);
            sb.Append(DEL_NOTE);
            sb.Append(note.Protected);
            sb.Append(DEL_NOTE);
            sb.Append(note.ReceivedFrom);
            sb.Append(DEL_NOTE);
            sb.Append(note.Rolled);
            sb.Append(DEL_NOTE);
            sb.Append(scv.ConvertToString(note.Schedule));
            sb.Append(DEL_NOTE);
            sb.Append((int)note.SentReceived);
            sb.Append(DEL_NOTE);
            sb.Append(note.SentTo);
            sb.Append(DEL_NOTE);
            sb.Append(note.Skin != null ? note.Skin.SkinName : "");
            sb.Append(DEL_NOTE);
            sb.Append(note.Skinless != null ? skc.ConvertToString(note.Skinless) : "");
            sb.Append(DEL_NOTE);
            bt = new StringBuilder();
            foreach (var s in note.Tags)
            {
                bt.Append(s);
                bt.Append(DEL_INNER);
            }
            if (bt.Length > 0)
                bt.Length -= 1;
            sb.Append(bt);
            sb.Append(DEL_NOTE);
            sb.Append(note.Topmost);
            sb.Append(DEL_NOTE);
            sb.Append(note.Visible);
            sb.Append(DEL_NOTE);
            sb.Append(note.XFactor.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.YFactor.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.PinClass);
            sb.Append(DEL_NOTE);
            sb.Append(note.PinText);
            return sb.ToString();
        }