Exemplo n.º 1
0
 private Issue OnLoadIssue(int issueId)
 {
     using (var storage = m_Model.OpenStorage(STORAGE_NAME, AccessType_e.Read))
     {
         using (var issueStorage = storage.TryOpenStorage(ISSUES_SUB_STORAGE_NAME, false))
         {
             using (var stream = issueStorage.TryOpenStream(issueId.ToString(), false))
             {
                 var ser = new DataContractSerializer(typeof(Issue));
                 return(ser.ReadObject(stream) as Issue);
             }
         }
     }
 }
Exemplo n.º 2
0
 public static IStorage TryOpenStorage(this IXDocument doc, string name, AccessType_e access)
 {
     try
     {
         return(doc.OpenStorage(name, access));
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        private void SaveToStorage(IXDocument doc)
        {
            var path = SUB_STORAGE_PATH.Split('\\');

            using (var storage = doc.OpenStorage(path[0], AccessType_e.Write))
            {
                using (var subStorage = storage.TryOpenStorage(path[1], true))
                {
                    using (var str = subStorage.TryOpenStream(TIME_STAMP_STREAM_NAME, true))
                    {
                        var buffer = Encoding.UTF8.GetBytes(DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"));
                        str.Write(buffer, 0, buffer.Length);
                    }

                    using (var str = subStorage.TryOpenStream(USER_NAME_STREAM_NAME, true))
                    {
                        var buffer = Encoding.UTF8.GetBytes(System.Environment.UserName);
                        str.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }