/// <summary>
        /// Deletes the specified journal.
        /// </summary>
        /// <param name="journal_id">The journal_id is the identifier of the journal.</param>
        /// <returns>System.String.<br></br>The success message is "The selected journal entry has been deleted."</returns>
        public string Delete(string journal_id)
        {
            string url      = baseAddress + "/" + journal_id;
            var    responce = ZohoHttpClient.delete(url, getQueryParameters());

            return(JournalParser.getMessage(responce));
        }
Example #2
0
        public string CommentSave(int journalId, string comment)
        {
            try
            {
                var ci = new CommentInfo {
                    JournalId = journalId, Comment = HttpUtility.UrlDecode(comment)
                };
                if (ci.Comment.Length > 2000)
                {
                    ci.Comment = ci.Comment.Substring(0, 1999);
                    ci.Comment = Utilities.RemoveHTML(ci.Comment);
                }
                ci.UserId = UserInfo.UserID;
                InternalJournalController.Instance.SaveComment(ci);

                var ji = JournalController.Instance.GetJournalItem(PortalSettings.PortalId, UserInfo.UserID, journalId);
                var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo);
                return(jp.GetCommentRow(ci));
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return(string.Empty);
            }
        }
        /// <summary>
        /// Gets the details of specified journal.
        /// </summary>
        /// <param name="journal_id">The journal_id is the identifier of the journal.</param>
        /// <returns>Journal object.</returns>
        public Journal Get(string journal_id)
        {
            string url      = baseAddress + "/" + journal_id;
            var    responce = ZohoHttpClient.get(url, getQueryParameters());

            return(JournalParser.getJournal(responce));
        }
Example #4
0
		public static FS2JournalItem ReadItem(DeviceConfiguration deviceConfiguration, Device device, int i, byte journalType)
		{
			for (int j = 0; j < 15; j++)
			{
				var response = USBManager.Send(device, "Чтение конкретной записи в журнале", 0x01, 0x20, journalType, BitConverter.GetBytes(i).Reverse());
				if (response != null)
				{
					lock (Locker)
					{
						var journalParser = new JournalParser();
						try
						{
							var fsJournalItem = journalParser.Parce(deviceConfiguration, device, response.Bytes, journalType);
							if (fsJournalItem != null)
							{
								return fsJournalItem;
							}
						}
						catch
						{
							return null;
						}
					}
				}
			}
			return null;
		}
        public HttpResponseMessage CommentSave(CommentSaveDTO postData)
        {
            try
            {
                var comment = Utilities.RemoveHTML(HttpUtility.UrlDecode(postData.Comment));

                IDictionary <string, UserInfo> mentionedUsers = new Dictionary <string, UserInfo>();
                var originalComment = comment;
                comment = ParseMentions(comment, postData.Mentions, ref mentionedUsers);
                var ci = new CommentInfo {
                    JournalId = postData.JournalId, Comment = comment
                };
                ci.UserId      = UserInfo.UserID;
                ci.DisplayName = UserInfo.DisplayName;
                JournalController.Instance.SaveComment(ci);

                var ji = JournalController.Instance.GetJournalItem(ActiveModule.OwnerPortalID, UserInfo.UserID, postData.JournalId);
                var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo);

                SendMentionNotifications(mentionedUsers, ji, originalComment, "Comment");

                return(Request.CreateResponse(HttpStatusCode.OK, jp.GetCommentRow(ji, ci), "text/html"));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        /// <summary>
        /// Gets the journal list.
        /// </summary>
        /// <param name="parameters">The parameters is the Dictionary object which contains the filters in the form of key,value pairs.<br></br>The possible filters are listed below<br></br>
        /// <table>
        /// <tr><td>entry_number</td><td>Search journals by journal entry number.<br></br>Variants: <i>entry_number_startswith</i> and <i>entry_number_contains</i></td></tr>
        /// <tr><td>reference_number</td><td>Search journals by journal reference number.<br></br>Variants: <i>reference_number_startswith</i> and <i>reference_number_contains</i></td></tr>
        /// <tr><td>date</td><td>Search journals by journal date.<br></br>Variants: <i>date_start, date_end, date_before</i> and <i>date_after</i></td></tr>
        /// <tr><td>notes</td><td>Search journals by journal notes.<br></br>Variants: <i>notes_startswith</i> and <i>notes_contains</i></td></tr>
        /// <tr><td>total</td><td>Search journals by journal total.<br></br>Variants: <i>total_less_than, total_less_equals, total_greater_than</i> and <i>total_greater_equals</i></td></tr>
        /// <tr><td>filter_by</td><td>Filter journals by journal date.<br></br>Allowed Values: <i>JournalDate.All, JournalDate.Today, JournalDate.ThisWeek, JournalDate.ThisMonth, JournalDate.ThisQuarter</i> and <i>JournalDate.ThisYear</i></td></tr>
        /// <tr><td>sort_column</td><td>Sort journal list.<br></br>Allowed Values: <i>journal_date, entry_number, reference_number</i> and <i>total</i></td></tr>
        /// </table>
        /// </param>
        /// <returns>JournalsList object.</returns>
        public JournalList GetJournals(Dictionary <object, object> parameters)
        {
            string url      = baseAddress;
            var    responce = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(JournalParser.getJournalList(responce));
        }
Example #7
0
        public HttpResponseMessage CommentSave(CommentSaveDTO postData)
        {
            try
            {
                var ci = new CommentInfo {
                    JournalId = postData.JournalId, Comment = HttpUtility.UrlDecode(postData.Comment)
                };
                if (ci.Comment.Length > 2000)
                {
                    ci.Comment = ci.Comment.Substring(0, 1999);
                    ci.Comment = Utilities.RemoveHTML(ci.Comment);
                }
                ci.UserId = UserInfo.UserID;
                JournalController.Instance.SaveComment(ci);

                var ji = JournalController.Instance.GetJournalItem(ActiveModule.OwnerPortalID, UserInfo.UserID, postData.JournalId);
                var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo);

                return(Request.CreateResponse(HttpStatusCode.OK, jp.GetCommentRow(ci), "text/html"));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Example #8
0
        private static void Main(string[] args)
        {
            var savedGames           = Shell32.SHGetKnownFolderPath(Shell32.KNOWNFOLDERID.FOLDERID_SavedGames);
            var defaultJournalFolder = Path.Combine(
                savedGames, "Frontier Developments", "Elite Dangerous"
                );

            var defaultConfig = new Dictionary <string, string>
            {
                ["JournalFolder"] = defaultJournalFolder,
                ["LogPattern"]    = "Journal.*.log",
                ["LiveFilenames"] = "Status.json;Market.json;Outfitting.json;Shipyard.json;NavRoute.json;ModulesInfo.json;Cargo.json"
            };

            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(defaultConfig)
                         .AddCommandLine(args)
                         .Build();

            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
            Log.Info("Started");

            // Subscribe to loggable events we might be interested in
            SubEthaLog.LogEvent += SubEthaLog_LogEvent;

            var parser   = new JournalParser(true); // Use strict parsing
            var basePath = config["JournalFolder"];

            // Instead of using the full monitor, just enumerate files and parse them one by one
            var logPattern = config["LogPattern"];
            var logFiles   = Directory.EnumerateFiles(basePath, logPattern, SearchOption.TopDirectoryOnly);

            foreach (var file in logFiles)
            {
                Log.Info($"Checking file '{file}'...");
                var reader = new LogJournalReader(new FileInfo(file), parser);
                // Read all entries from all files
                reader.ReadLines().ToList().ForEach(l => Validate(l.Line, parser));
            }

            // Get all the live files (that get replaced as they are updated)
            var liveFiles = config["LiveFilenames"].Split(';').Select(x => Path.Combine(basePath, x.Trim()));

            foreach (var file in liveFiles)
            {
                Log.Info($"Checking file '{file}'...");
                var reader = new LiveJournalReader(new FileInfo(file), parser);
                // Read entry from each file
                Validate(reader.ReadCurrent().Line, parser);
            }

            // Unsub from loggable events
            SubEthaLog.LogEvent -= SubEthaLog_LogEvent;
        }
        /// <summary>
        /// Updates the journal with given information.
        /// </summary>
        /// <param name="journal_id">The journal_id is the identifier of the journal.</param>
        /// <param name="update_info">The update_info is the Journal object which contains the updation information of specifed journal.</param>
        /// <returns>Journal object.</returns>
        public Journal Update(string journal_id, Journal update_info)
        {
            string url        = baseAddress + "/" + journal_id;
            var    json       = JsonConvert.SerializeObject(update_info);
            var    jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var responce = ZohoHttpClient.put(url, getQueryParameters(jsonstring));

            return(JournalParser.getJournal(responce));
        }
Example #10
0
        /// <summary>
        ///     Creates a journal.
        /// </summary>
        /// <param name="new_journal_info">
        ///     The new_journal_info is the Journal object with journal_date,amount,debit_or_credit as
        ///     mandatory attributes.
        /// </param>
        /// <returns>Journal object.</returns>
        public Journal Create(Journal new_journal_info)
        {
            var url        = baseAddress;
            var json       = JsonConvert.SerializeObject(new_journal_info);
            var jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var responce = ZohoHttpClient.post(url, getQueryParameters(jsonstring));

            return(JournalParser.getJournal(responce));
        }
Example #11
0
 protected override void Render(HtmlTextWriter output)
 {
     if (Enabled)
     {
         if (CurrentIndex < 0)
         {
             CurrentIndex = 0;
         }
         JournalParser jp = new JournalParser(portalSettings, ModuleId, ProfileId, SocialGroupId, userInfo);
         output.Write(jp.GetList(CurrentIndex, PageSize));
     }
 }
Example #12
0
 public HttpResponseMessage GetListForProfile(GetListForProfileDTO postData)
 {
     try
     {
         var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, postData.ProfileId, postData.GroupId, UserInfo);
         return(Request.CreateResponse(HttpStatusCode.OK, jp.GetList(postData.RowIndex, postData.MaxRows), "text/html"));
     }
     catch (Exception exc)
     {
         Logger.Error(exc);
         throw new HttpException(500, exc.Message);
     }
 }
Example #13
0
 private static void Validate(string line, JournalParser parser)
 {
     Log.Debug(line);
     try
     {
         var _ = parser.Parse(line);
     }
     catch (Exception ex) when(ex is UnrecognizedJournalException || ex is JournalParseException)
     {
         Log.Warn(line);
         Log.Warn(ex.Message);
     }
 }
Example #14
0
 public string GetListForProfile(int profileId, int groupId, int rowIndex, int maxRows)
 {
     try
     {
         var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, profileId, groupId, UserInfo);
         return(jp.GetList(rowIndex, maxRows));
     }
     catch (Exception exc)
     {
         DnnLog.Error(exc);
         return(string.Empty);
     }
 }
Example #15
0
        protected override void Render(HtmlTextWriter output)
        {
            if (this.Enabled)
            {
                if (this.CurrentIndex < 0)
                {
                    this.CurrentIndex = 0;
                }

                JournalParser jp = new JournalParser(this.portalSettings, this.ModuleId, this.ProfileId, this.SocialGroupId, this.userInfo)
                {
                    JournalId = this.JournalId
                };
                output.Write(jp.GetList(this.CurrentIndex, this.PageSize));
            }
        }
Example #16
0
 public ActionResult CommentLike(int journalId, int commentId)
 {
     try
     {
         InternalJournalController.Instance.LikeComment(journalId, commentId, UserInfo.UserID, UserInfo.DisplayName);
         var ji       = JournalController.Instance.GetJournalItem(PortalSettings.PortalId, UserInfo.UserID, journalId);
         var jp       = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo);
         var isLiked  = false;
         var likeList = jp.GetLikeListHTML(ji, ref isLiked);
         likeList = Utilities.LocalizeControl(likeList);
         return(Json(new { LikeList = likeList, Liked = isLiked }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exc)
     {
         DnnLog.Error(exc);
         return(Json(new { Result = "error" }));
     }
 }
Example #17
0
 public HttpResponseMessage Like(JournalIdDTO postData)
 {
     try
     {
         JournalController.Instance.LikeJournalItem(postData.JournalId, UserInfo.UserID, UserInfo.DisplayName);
         var ji       = JournalController.Instance.GetJournalItem(ActiveModule.OwnerPortalID, UserInfo.UserID, postData.JournalId);
         var jp       = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo);
         var isLiked  = false;
         var likeList = jp.GetLikeListHTML(ji, ref isLiked);
         likeList = Utilities.LocalizeControl(likeList);
         return(Request.CreateResponse(HttpStatusCode.OK, new { LikeList = likeList, Liked = isLiked }));
     }
     catch (Exception exc)
     {
         Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }