public void Initialize()
        {
            Log = FindObjectOfType <JournalObject>();

            var externalSettingsObject = FindObjectOfType <ExternalSettingsObject>();

            if (externalSettingsObject == null)
            {
                Log.ImmediateWriteAll($"Can't run server because external settings object not available now!", Journal.Contracts.JournalingLevel.Critical);
                return;
            }

            Settings = externalSettingsObject.GetObjectPlaceholder("external-settings:network").As <NetworkSettingsPlaceholder>();
            if (Settings == null)
            {
                Log.ImmediateWriteAll($"Can't initialize server variables because not available network settings placeholder", Journal.Contracts.JournalingLevel.Critical);
                return;
            }

            Address        = Settings.Read <string>("address", "host");
            Port           = Settings.Read <int>("port", "host");
            MaxConnections = Settings.Read <int>("max_connections", "security");

            Service = ServerFactory.CreateTcpServer(Address, Port);
        }
Ejemplo n.º 2
0
 public ActionResult EditJournalSuggestion(JournalObject model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     model.Save();
     return(RedirectToAction("JournalSuggestions"));
 }
Ejemplo n.º 3
0
        public ActionResult EditJournalSuggestion(int?id)
        {
            JournalObject model = new JournalObject();

            if (id.HasValue)
            {
                model = MemoryCache.GetJournalSuggestion(id.Value);
            }
            return(View(model));
        }
        public static CharacterJournalCollection GetCharacterJournalList(Database db, EveApiId id,
                                                                         string CharID, string beforeRefID, bool bAutoWalk, bool bUseCache)
        {
            if (!id.IsFullKey())
            {
                return(new CharacterJournalCollection()); // return empty
            }
            CharacterJournalCollection journal = null;
            long remainder = 0;
            long lastCount = 0;

            do
            {
                string url = String.Format("{0}{1}?userID={2}&characterID={3}&apiKey={4}&accountKey=1000",
                                           ApiSite, CharJournalEntries, id.UserId, CharID, id.Key);
                if (null != beforeRefID && 0 < long.Parse(beforeRefID))
                {
                    url += String.Format("&beforeRefID={0}", beforeRefID);
                }

                string str = CheckRequestCache(db, RequestID.CharacterJournal, id.UserId, url);
                if (null == str)
                {
                    Stream s = openUrl(url);
                    if (null == s)
                    {
                        return((null != journal) ? journal : (new CharacterJournalCollection()));
                    }
                    str = new StreamReader(s).ReadToEnd();
                    WriteRequestCache(db, RequestID.CharacterJournal, id.UserId, url, str);
                }
                else if (!bUseCache)
                {
                    break; // not allowed to use caching
                }

                XmlDocument xmlDoc = GetXml(new StringReader(str));
                if (null == xmlDoc)
                {
                    break;
                }

                if (null == journal)
                {
                    journal = new CharacterJournalCollection(CharID, xmlDoc);
                }
                else
                {
                    journal.AppendList(CharID, xmlDoc);
                }

                if (null == journal)
                {
                    remainder = -1;
                }
                else
                {
                    IDBCollectionContents con = (IDBCollectionContents)journal;
                    if (0 == con.Count())
                    {
                        remainder = -1;
                    }
                    else if (lastCount == con.Count())
                    {
                        remainder = -1;
                    }
                    else
                    {
                        lastCount = con.Count();
                        remainder = con.Count() % 1000;
                        if (0 == remainder)
                        {
                            IDBRecord     rec1 = con.GetRecordInterface(con.Count() - 1000);
                            JournalObject obj1 = (JournalObject)rec1.GetDataObject();
                            IDBRecord     rec2 = con.GetRecordInterface(con.Count() - 1);
                            JournalObject obj2 = (JournalObject)rec2.GetDataObject();
                            beforeRefID = Math.Min(obj1.refID, obj2.refID).ToString();
                            TimeSpan span = (obj2.date > obj1.date) ? obj2.date.Subtract(obj1.date) :
                                            obj1.date.Subtract(obj2.date);
                            if (span.Days >= 7)
                            {
                                remainder = -1; // more than a week, so no more accessable
                            }
                        }
                    }
                }
            } while (0 == remainder && bAutoWalk);

            if (null == journal)
            {
                return(new CharacterJournalCollection()); // create empty
            }
            return(journal);
        }
 public override void Awake()
 {
     ParentJournalObject = ReinterpretObject <JournalObject>(ParentObject);
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            JournalObject journal = new JournalObject();

            Console.WriteLine(journal.journalMessage);
            int    response;
            string rep;

            do
            {
                Console.WriteLine("1) Unlock");
                Console.WriteLine("2) Create Entry");
                Console.WriteLine("3) Read Entry");
                Console.WriteLine("4) Lock");
                Console.WriteLine("5) Quit");
                Console.WriteLine("-----------------------\n");
                response = int.Parse(Console.ReadLine());

                switch (response)
                {
                case 1:
                {
                    Console.WriteLine("Please Enter password:"******"Journal Unlocked");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;

                        Console.WriteLine("Incorrect Password");
                    }
                    break;
                }

                case 2:
                {
                    if (journal.Entry == null)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;

                        Console.WriteLine("Unlock journal first");
                        break;
                    }
                    //Console.WriteLine("okaaaay!!!!");
                    Console.WriteLine("Enter journal text");
                    string journalMessage = Console.ReadLine();

                    journal.Entry.Text = journalMessage;

                    break;
                }

                case 3:
                {
                    if (journal.Entry == null)
                    {
                        Console.WriteLine("Unlock journal first");
                    }
                    else
                    {
                        // Console.WriteLine("We are here");
                        //string thing = journal.Entry.Text;

                        Console.WriteLine(journal.Entry.Text);
                        Console.WriteLine("Last Edit:" + journal.Entry.LastEditTime
                                          .ToShortDateString() + " " + journal.
                                          Entry.LastEditTime.ToLongTimeString());
                    }
                    break;
                }

                case 4:
                {
                    journal.LockJournal();
                    Console.WriteLine("Journal Locked");
                    break;
                }

                case 5:
                {
                    break;
                }
                }
                //Console.ResetColor();
            } while (response != 5);
        }