Exemple #1
0
        /// <summary>
        /// Function that runs a case statement to run a function depending on state
        /// </summary>
        private void StateFunctions()
        {
            switch (gm.GenFSM.CurrentState.ToUpper())
            {
            case "INIT":
                HelpText();
                gm.turnManager.ToStartUp();
                gm.GenFSM.CurrentState = "idle";
                break;

            case "IDLE":
                gm.turnManager.ToIdle();
                gm.GenFSM.CurrentState = "turn";
                break;

            case "TURN":
                gm.turnManager.ToChoosePlayer();
                gm.GenFSM.CurrentState = "atk";
                break;

            case "ATK":
                gm.turnManager.ToCombat();
                gm.GenFSM.CurrentState = "endturn";
                break;

            case "ENDTURN":
                gm.turnManager.ToEndTurn();
                gm.GenFSM.CurrentState = "idle";
                break;
            }
            TextLog.SelectionStart = TextLog.Text.Length;
            TextLog.ScrollToCaret();
        }
Exemple #2
0
 void Awake()
 {
     Balance      = 1500;
     _player      = gameObject.GetComponentInParent <Player>();
     _textLog     = GameObject.Find("TextLog").GetComponent <TextLog>();
     _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
 }
Exemple #3
0
 public static void ClearHPassLogThread()
 {
     while (Global.bRun)
     {
         try
         {
             WFHttpWebResponse web = new WFHttpWebResponse();
             web.CreateGetHttpResponse(@"http://192.168.0.158/");
             web.CreatePostHttpResponse(@"http://192.168.0.158/login", "username=root&password=root");
             HttpWebResponse hr  = web.CreateGetHttpResponse(@"http://192.168.0.158/m1_user_search_get_status");
             m1_Status[]     ret = WFJSON.JsonDeserializeBySingleData <m1_Status[]>(web.Content);
             foreach (m1_Status m1 in ret)
             {
                 m1.updatedAt = m1.updatedAt.Replace('T', ' ');
                 m1.updatedAt = m1.updatedAt.Replace("Z", "");
                 DateTime dt = Convert.ToDateTime(m1.updatedAt);
                 if (m1.progress == 100 && dt.AddMinutes(30) < DateTime.Now)
                 {
                     web.CreateGetHttpResponse(@"http://192.168.0.158/m1_search_user_remove?request_id=" + m1.id);
                 }
                 //http://192.168.0.158/m1_search_user_remove?request_id=484
             }
             Thread.Sleep(30 * 60 * 1000);
         }
         catch (System.Exception ex)
         {
             TextLog.AddTextLog("Unkown:" + ex.Message, Global.txtLogFolder + "ClearHPassLog.txt", true);
         }
     }
 }
Exemple #4
0
    public void GenerateInjuries()
    {
        textLog          = FindObjectOfType <TextLog>();
        bodyPartManager  = FindObjectOfType <BodyPartManager>();
        unlockTracker    = FindObjectOfType <UnlockTracker>();
        gameSetupTracker = FindObjectOfType <GameSetupScenarioTracker>();

        EasyInjuries(gameSetupTracker.easyInjuries);
        MediumInjuries(gameSetupTracker.mediumInjuries);
        HardInjuries(gameSetupTracker.hardInjuries);
        randomIndex = 0;
        randomNumbersReturned.Add(77777);

        try
        {
            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene")
            {
                GameObject.FindObjectOfType <BodyPartSelectorManager>().ResetSelectors();
                GameObject.FindObjectOfType <EmbeddedObjectSelectorManager>().ResetSelectors();
            }
        }
        catch (System.Exception e)
        {
            Debug.LogError($"PhysicalInjuryGenertor: Error resetting selectors: {e}");
        }
    }
Exemple #5
0
 public void DisplayLog(LogWrapper log)
 {
     if (log == null)
     {
         return;
     }
     try
     {
         var content = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)}] [{log.LogLevel.ToString()}] {log.FormattedString}";
         var ex      = log.Exception;
         while (ex != null)
         {
             content += $"\n Error: [{ex.GetType().FullName}] {ex.Message}\n Stack Trace: {ex.StackTrace}";
             if (ex.InnerException != null)
             {
                 content += "\n ==== INNER EXCEPTION ====";
             }
             ex = ex.InnerException;
         }
         TextLog.AppendText(content + "\n");
     }
     catch
     {
     }
 }
        private void CreateBackUpDir_Click(object sender, EventArgs e)
        {
            CreateBackupDir CBU = new CreateBackupDir();

            CBU.CreateDir(TextLog);
            TextLog.AppendText("--------------------------------------------------------------------------\r\n");
        }
Exemple #7
0
        public void TextLog_Basic()
        {
            string  folder = Path.GetTempPath() + Helper.NewGuid().ToString();
            TextLog log    = null;

            try
            {
                log = new TextLog(folder, 128);

                for (int i = 0; i < 10; i++)
                {
                    log.Log("category", "title", "details " + i.ToString());
                }

                Thread.Sleep(2000);

                for (int i = 10; i < 20; i++)
                {
                    log.Log("category", "title", "details " + i.ToString());
                }

                // $todo(jeff.lill): For now, you need to set a breakpoint and
                //               manually verify that this worked.
            }
            finally
            {
                if (log != null)
                {
                    log.Dispose();
                }

                Helper.DeleteFile(folder, true);
            }
        }
Exemple #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var tl = new TextLog(Application.StartupPath + "direct.txt");

            _sr.WorkFlowCompleted += sr_OnWorkEnd;
            _sr.OnUrlError        += (s) =>
            {
                this.Invoke(new MethodInvoker(() =>
                {
                    listBox1.Items.Add(s);
                    tl.Write(s);
                }));
            };
            _sr.WorkFlowCompleted += sr_OnWorkComplete;
            _sr.ProcessStopped    += sr_OnStop;
            _sr.SpeedReported      = (a, b, c) =>
            {
                this.Invoke(new MethodInvoker(() =>
                {
                    label6.Text = a.ToString();
                    label8.Text = b + "/" + c;
                }));
            };
            _database = new SqlWorkUnit(@"D:\spy\spy\bin\Release\GPUBenchmark.mdf", @".\SQLEXPRESS");
        }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                WFHttpWebResponse WebResponse = new WFHttpWebResponse();
                string            url;
                byte[]            ss = StringsFunction.strToHexByte(textBox1.Text, " ");
                url = "http://www.mercedes-tool.com:9999/" + "AdminAPI/RegTE.aspx?ID=" + StringsFunction.byteToHexStr(ss, "");
                url = url + "&HexVer=" + textBox2.Text;

                HttpWebResponse hr  = WebResponse.CreateGetHttpResponse(url);
                string          ret = WebResponse.Content;
                if (ret == "ok")
                {
                    TextLog.AddTextLog(StringsFunction.byteToHexStr(ss, ""), System.Windows.Forms.Application.StartupPath + "\\regLog.txt", false);
                    MessageBox.Show("注册成功");
                }
                else if (ret == "reged")
                {
                    MessageBox.Show("已经注册");
                }
                else
                {
                    MessageBox.Show("注册失败:" + ret);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CP1616_NoAddr_Packet.bVerify = false;
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            mcuClientContext      = null;
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;

            fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
        }
Exemple #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);


            mcuClientContext = null;
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;
            string   filePT, fileMS, fileTC, fileLA;

            filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), filePT, false);
            fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileMS, false);
            fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileTC, false);
            fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileLA, false);
        }
Exemple #12
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
         {
             MessageBox.Show("输入的端口号格式有问题!!");
             return;
         }
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         DateTime dt = DateTime.Now;
         fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
         //this.Text = tcpAsyncServer.TCPServerName + ":" + tcpAsyncServer.TCPServerPort;
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         mcuClientContext = null;
         timer1.Enabled   = false;
     }
 }
Exemple #13
0
/*************************
 * [C#]
 * string ConnString = Utils.GetConnString();
 * string SqlString = "Select * From Contacts Where FirstName = ? And LastName = ?";
 * using (OleDbConnection conn = new OleDbConnection(ConnString))
 * {
 * using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
 * {
 *  cmd.CommandType = CommandType.Text;
 *  cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text);
 *  cmd.Parameters.AddWithValue("LastName", txtLastName.Text);
 *
 *  conn.Open();
 *  using (OleDbDataReader reader = cmd.ExecuteReader())
 *  {
 *    while (reader.Read())
 *    {
 *      Response.Write(reader["FirstName"].ToString() + " " + reader["LastName"].ToString());
 *    }
 *  }
 * }
 * }
 * *****************************************/
        public DataTable SearchFor(string match, Boolean inNotes, string stop)
        {
            string    str     = string.Empty;
            string    orderby = string.Empty;
            DataSet   DS      = new DataSet();
            DataTable DT      = new DataTable();

            match = "%" + match + "%";
            stop  = "#" + stop + "#";
            if (inNotes)
            {
                str     = string.Format("Select date, Notes from 2002 where [date] > {0} AND Notes like ?", stop);
                orderby = " order by [date] desc";
            }
            else
            {
                str     = string.Format("Select ToDoDesc, Notes,Priority from ToDo where LastActivity > {0} AND Notes like ?", stop);
                orderby = " order by Created desc";
            }
            //str += '"' + "%" + match + "%" + '"' + orderby;
            str += orderby;
            try
            {
                using (OleDbCommand cmd = new OleDbCommand(str, conn))
                {
                    cmd.CommandType = CommandType.Text;

                    //if (inNotes)
                    //    cmd.Parameters.AddWithValue("[date]", stop);
                    // HACK Can't get the [date] parameter to not error
                    cmd.Parameters.AddWithValue("Notes", match);
                    if (conn.State != ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    using (OleDbDataAdapter DA = new OleDbDataAdapter(cmd))
                    {
                        DA.Fill(DS);
                        if (DS.Tables.Count > 0)
                        {
                            DT = DS.Tables[0];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TextLog.LogErr(ex.ToString());
                throw;
            }
            finally
            {
                if (DS != null)
                {
                    DS = null;
                }
                closeConn();
            }
            return(DT);
        }
Exemple #14
0
        public string mostRecentTask()
        {
            string str = string.Empty;

            try
            {
                dr = getDataReader("SELECT TOP 1 ToDo.ToDoDesc, ToDo.Created FROM ToDo ORDER BY ToDo.Created DESC;");
                if (dr.HasRows)
                {
                    dr.Read();
                    str = dr[0].ToString();
                }
            }
            catch (Exception ex)
            {
                TextLog.LogErr(ex.ToString());
                str = ex.ToString();
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(str);
            //return "This is a test";
            //SELECT TOP 1 ToDo.ToDoDesc, ToDo.Created FROM ToDo ORDER BY ToDo.Created DESC;
        }
Exemple #15
0
 void Start()
 {
     GameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     Owner       = null;
     IsMortgage  = false;
     _textLog    = GameObject.Find("TextLog").GetComponent <TextLog>();
 }
Exemple #16
0
        private void ApppendLogsTo(string logFileName, LogEventArg e)
        {
            if (logFileName.IsBlank())
            {
                return;
            }
            switch (e.Level)
            {
            case L4j.Off:                   //
            case L4j.Debug:                 //  ignore these levels
            case L4j.Trace: return;         //
            }
            if (e.ShowAs != ShowLogAs.Normal)
            {
                return;
            }

            if (_logFile == null)
            {
                _logFile = _fs.File(_fs.GetAssemblyDir().Bslash(logFileName));
            }

            var line = L.f + TextLog.Format(e.Title, e.Message);

            _logFile.Write(line, EncodeAs.UTF8, false, false);
        }
Exemple #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string queueID;
            string ret = "-2000";

            try
            {
                queueID = Request.QueryString["queueID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(queueID))//没有这两个变量
                {
                    ret = "-1";
                    Response.Write(ret);
                    return;
                }
                KeyDataQueueData kd = new KeyDataQueueData();
                kd.ID = int.Parse(queueID);
                KeyDataQueueDataDBOption.delete(kd);
                ret = "1";
                Response.Write(ret);
                return;
            }
            catch (System.Exception ex)
            {
                ret = "-100," + ex.Message;
                TextLog.AddTextLog("Cancel_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
            }
            Response.Write(ret);
        }
Exemple #18
0
        public static string near(string str, string keyWord, Int32 padding)
        {
            /// Will search the string for a key word and return padding characters on each side
            ///
            Int32         location = 0;
            StringBuilder sb       = new StringBuilder();

            try
            {
                //  get the first location of keyword
                location = str.IndexOf(keyWord, StringComparison.CurrentCultureIgnoreCase);
                while (location >= 0)
                {
                    // adjust what will be displayed to whole words
                    Int32 starting = nextWhiteSpace(ref str, location - 10, false);
                    Int32 ending   = nextWhiteSpace(ref str, location + padding, true);

                    sb.AppendLine(str.Substring(starting, (ending - starting)) + "..."); // get full words now

                    location = str.IndexOf(keyWord, (++ending > str.Length) ? str.Length : ending, StringComparison.CurrentCultureIgnoreCase);
                }
                if (sb.Length > 0)
                {
                    str = sb.ToString();
                }
            }
            catch (Exception ex)
            {
                TextLog.LogErr(String.Format("Error in Function near string:{0}, keyword: {1}, \n padding:{2}. \n {3}", str, keyWord, padding, ex.ToString()));
            }
            //TextLog.Logit(string.Format("Function near returning string of {0} length.", str.Length));
            return(str);
        }
Exemple #19
0
        public static Int32 calcHoursToday(daily d)
        {
            // if start of day is midnight return
            // if start of day is valid and start lunch is entered
            //morning can be calculated
            //if end of lunch is entered and end of day is entered
            //  afternoon can be calculated
            // if all 4 times or begin and end of day are entered then you can calculate the day
            Int32 fullDay = 0;
            Int32 lunch   = 0;

            try
            {
                if ((d.start_day != null) && (d.end_day != null))
                {
                    fullDay = timeElapsed(d.start_day, d.end_day);
                }
                lunch = d.lunchDuration;
                if (fullDay != 0.0 && lunch != 0.0)
                {
                    fullDay -= lunch;
                }
            }
            catch (Exception)
            {
                TextLog.LogErr(string.Format("Error in calcHoursToday, start {0}, lunchDuration{1}, DayEnd{2}", d.start_day, d.lunchDuration, d.end_day));
            }

            return(fullDay);
        }
Exemple #20
0
        private void DumpInstanceDefinition(InstanceDefinition instanceDefinition, ref TextLog dump, bool isRoot)
        {
            if (instanceDefinition != null && !instanceDefinition.IsDeleted)
            {
                string node = isRoot ? "─" : "└";
                dump.Print(string.Format("{0} Instance definition {1} = {2}\n", node, instanceDefinition.Index, instanceDefinition.Name));

                if (instanceDefinition.ObjectCount > 0)
                {
                    dump.PushIndent();
                    for (int i = 0; i < instanceDefinition.ObjectCount; i++)
                    {
                        var obj = instanceDefinition.Object(i);
                        if (obj == null)
                        {
                            continue;
                        }
                        if (obj is InstanceObject)
                        {
                            DumpInstanceDefinition((obj as InstanceObject).InstanceDefinition, ref dump, false); // Recursive...
                        }
                        else
                        {
                            dump.Print("\u2514 Object {0} = {1}\n", i, obj.ShortDescription(false));
                        }
                    }
                    dump.PopIndent();
                }
            }
        }
Exemple #21
0
        private void StartAgents(Dictionary <String, Object> connectorConf)
        {
            TextLog.Log("PluginStarter", "{" + plugin.GetPluginId().AbsoluteUri + "} Starting agent thread...");

            try
            {
                LogEvent log = new LogEvent(delegate(Object sender, PluginLogType type, String text)
                {
                    TextLog.Log("PluginStarter", "{" + ((PluginBase)sender).GetPluginId().AbsoluteUri + "}>Log1> " + type + ", " + text);
                });

                LogEvent2 log2 = new LogEvent2(delegate(Object sender, PluginLogType type, Int64 entityId, Int64 identityId, String text, String additionalData)
                {
#if DEBUG
                    TextLog.Log("PluginStarter", "{" + ((PluginBase)sender).GetPluginId().AbsoluteUri + "}>Log2> Type: " + type + ", Entity Id: " + entityId + ", Identity Id: " + identityId + ", Data: " + text + additionalData);
#endif

                    logProxy.AddLog(LogKey.Plugin_Event, "Proxy", 0, "0", ((PluginBase)sender).GetPluginId().AbsoluteUri, (UserLogLevel)((Int32)type), entityId, identityId, text, additionalData);
                    logProxy.SaveToSend("agentlog");
                });

                plugin.Log  += log;
                plugin.Log2 += log2;

                plugin.Start(connectorConf);
            }
            catch (Exception ex)
            {
                logProxy.AddLog(LogKey.Proxy_Event, "Proxy", 0, "", plugin.GetPluginId().AbsoluteUri, UserLogLevel.Error, 0, 0, "Erro on agent thread: " + ex.Message, "");
                throw ex;
            }
        }
Exemple #22
0
        private void SaveToSend(JsonGeneric data, String prefix)
        {
            if ((data.data == null) || (data.data.Count == 0))
            {
                return;
            }

            Byte[] jData = data.ToJsonBytes();

            using (CryptApi cApi = new CryptApi(CATools.LoadCert(Convert.FromBase64String(config.server_cert)), jData))
            {
                DirectoryInfo dirTo = new DirectoryInfo(Path.Combine(basePath, "Out"));
                if (!dirTo.Exists)
                {
                    dirTo.Create();
                }

                FileInfo f = new FileInfo(Path.Combine(dirTo.FullName, DateTime.Now.ToString("yyyyMMddHHmss-ffffff") + "-" + prefix) + ".iamdat");

                File.WriteAllBytes(f.FullName, cApi.ToBytes());

                TextLog.Log("PluginStarter", "File to send created " + f.Name + " (" + data.data.Count + ")");

                data.data.Clear();
            }
        }
Exemple #23
0
        public static async void Load()
        {
            await LoadLibrary(Settings.LibraryDirectory);

            TextLog.Write($"[Title Database] Loaded {await GetCount()} entries");
            Database.DatabaseCount++;
        }
Exemple #24
0
        private async void InitDatabase()
        {
            var doUpdate = Settings.LastPackDbUpdate < DateTime.Now.AddDays(-7);

            if (doUpdate || Settings.CacheDatabase || Count < 1)
            {
                TextLog.Write("[Graphic Packs] Building database...");

                LiteDatabase.DropCollection(CollectionName);

                MapleList <GraphicPack> db;
                if ((db = await Create()) == null || db.Count <= 0)
                {
                    TextLog.Write("[Graphic Packs] Error: Not available");
                    return;
                }

                foreach (var item in db)
                {
                    if (Col.Find(x => x.Name == item.Name).Any())
                    {
                        continue;
                    }

                    Col.Insert(item);
                    Col.EnsureIndex(x => x.Name);
                }

                Settings.LastPackDbUpdate = DateTime.Now;
            }

            TextLog.Write($"[Graphic Packs] Loaded {Count} entries");
            Database.DatabaseCount++;
        }
Exemple #25
0
        private static void LoadLibrary(string titleDirectory)
        {
            if (string.IsNullOrEmpty(titleDirectory))
            {
                throw new DirectoryNotFoundException($"TitleDirectory: '{titleDirectory}' cannot be null or empty");
            }

            if (titleDirectory.FilePathHasInvalidChars())
            {
                throw new DirectoryNotFoundException($"TitleDirectory: '{titleDirectory}' is an invalid directory path");
            }

            var xmlFiles = Directory.GetFiles(titleDirectory, "meta.xml", SearchOption.AllDirectories);

            foreach (var xmlFile in xmlFiles)
            {
                var rootDir = Path.GetFullPath(Path.Combine(xmlFile, "../../"));
                var titleID = Helper.XmlGetStringByTag(xmlFile, "title_id");

                Title title;
                if ((title = SearchById(titleID)) == null)
                {
                    TextLog.Write($"Could not find title using ID {titleID}");
                    continue;
                }

                title.FolderLocation = rootDir;
                title.MetaLocation   = xmlFile;
                TitleDb.AddOnUI(title);
            }
        }
Exemple #26
0
        public void Dispose()
        {
            if (log != null)
            {
                log.Dispose(); log = null;
            }

            ks.Dispose();
            if (Matcher != null)
            {
                Matcher.OnBeforeMatch     -= matcher_OnBeforeMatch;
                Matcher.OnFinish          -= matcher_OnFinish;
                Matcher.OnPositionChanged -= matcher_OnPositionChanged;
                Matcher.OnPartialFinish   -= matcher_OnPartialFinish;
                Matcher.OnDeal            -= Matcher_OnDeal;
                Matcher.Dispose(); Matcher = null;
            }
            if (Model != null)
            {
                Model.Dispose(); Model = null;
            }
            if (Executor != null)
            {
                Executor.Dispose(); Executor = null;
            }
        }
Exemple #27
0
 public static void DBTimeTaking(string msg)
 {
     if (ShopConfig.GetConfig("ERRORLOG_DBTIME").GetBoolean())
     {
         TextLog.Debug("", "DBTimeTaking", msg);
     }
 }
Exemple #28
0
        public static int CheckSession(string sessionId, int teamid, int userid)
        {
            int      iRes       = 2;
            string   senderName = "DBActions.CheckSession";
            string   procName   = "SPCHAT_SIGNALR_SESSION_CHK_V1";
            string   ConnDB     = "DSN_CHAT";
            DateTime sTime      = Tools.GetTimeZoneDateTime();
            DateTime eTime      = sTime;

            try
            {
                using (DBFactory objDB = new DBFactory(ConnDB))
                {
                    objDB.AddInParam("sessionid", SqlType.VarChar, sessionId);
                    objDB.AddInParam("userid", SqlType.Int, userid);
                    objDB.AddInParam("teamid", SqlType.Int, teamid);
                    objDB.AddInParam("reqtime", SqlType.DateTime, Tools.GetTimeZoneDateTime());
                    objDB.AddOutParam("retval", SqlType.Int, 10);
                    objDB.RunProc(procName);
                    iRes = objDB.GetOutValue("retval").ToString().IsNumeric() ? Convert.ToInt32(objDB.GetOutValue("retval").ToString()) : -1;
                }
                eTime = Tools.GetTimeZoneDateTime();

                // Send Connectivity Success Trap
                SNMPMonitor.Send(SNMPCodes.DB_EXCEPTION, eTrapLevel.Clear, eSingalrTrap.DB_Connectivity.GetHashCode(), "SUCCESS");

                // Send execution Success Trap
                SNMPMonitor.Send(SNMPCodes.DB_EXCEPTION, eTrapLevel.Clear, eSingalrTrap.CheckSession.GetHashCode(),
                                 TrapList.GetMessageDB(senderName, procName, "SUCCESS"));
            }
            catch (Exception ex)
            {
                if (ex.Message.ToUpper().IndexOf("DB_CONNECTIVITY_FAILURE") > -1)
                {
                    // Connectivity Issue, Send failure Trap
                    SNMPMonitor.Send(SNMPCodes.DB_EXCEPTION, eTrapLevel.Critical, eSingalrTrap.DB_Connectivity.GetHashCode(), "Failed to Connect Database " + ConnDB);
                }
                else
                {
                    // send Procedure execution failure Trap
                    SNMPMonitor.Send(SNMPCodes.DB_EXCEPTION, eTrapLevel.Critical, eSingalrTrap.CheckSession.GetHashCode(),
                                     TrapList.GetMessageDB(senderName, procName, "Exception::" + ex.Message));
                }
                TextLog.DBError("", "Database", senderName + "|" + procName + "|Exception>>" + ex.ToString());
            }
            finally
            {
                #region finally
                // write log with time taking
                DBTimeTaking(string.Format("{0}|{1}|{2}|{3}|{4}",
                                           sTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                                           sessionId,
                                           Math.Round(eTime.Subtract(sTime).TotalMilliseconds).ToString(),
                                           senderName,
                                           procName));
                #endregion
            }
            return(iRes);
        }
Exemple #29
0
        private void ImportDelete(ProxyConfig config, JsonGeneric jData, FileInfo f, JSONRequest req, IAMDatabase db)
        {
            Int32 resourceCol = jData.GetKeyIndex("resource");

            Int32 sourceCol     = jData.GetKeyIndex("source");
            Int32 uriCol        = jData.GetKeyIndex("uri");
            Int32 entityIdCol   = jData.GetKeyIndex("entityid");
            Int32 identityIdCol = jData.GetKeyIndex("identityid");

            if (resourceCol == -1)
            {
                TextLog.Log("Inbound", "\t[ImportDelete] Erro on find column 'resource' in " + f.Name + " enterprise " + req.enterpriseid + " and proxy " + req.host);
                return;
            }

            if (sourceCol == -1)
            {
                TextLog.Log("Inbound", "\t[ImportDelete] Erro on find column 'source' in " + f.Name + " enterprise " + req.enterpriseid + " and proxy " + req.host);
                return;
            }


            if (uriCol == -1)
            {
                TextLog.Log("Inbound", "\t[ImportDelete] Erro on find column 'uri' in " + f.Name + " enterprise " + req.enterpriseid + " and proxy " + req.host);
                return;
            }


            if (entityIdCol == -1)
            {
                TextLog.Log("Inbound", "\t[ImportDelete] Erro on find column 'entityId' in " + f.Name + " enterprise " + req.enterpriseid + " and proxy " + req.host);
                return;
            }

            if (identityIdCol == -1)
            {
                TextLog.Log("Inbound", "\t[ImportDelete] Erro on find column 'identityId' in " + f.Name + " enterprise " + req.enterpriseid + " and proxy " + req.host);
                return;
            }


            DateTime date = DateTime.Now;

            foreach (String[] dr in jData.data)
            {
                try
                {
                    db.ExecuteNonQuery("update [identity] set deleted = 1, deleted_date = '" + date.ToString("o") + "' where id = " + dr[identityIdCol], CommandType.Text, null);
                }
                catch { }
            }

#if DEBUG
            TextLog.Log("Inbound", "\t[ImportDelete] Changed " + jData.data.Count + " identities for deleted status in enterprise " + req.enterpriseid + " and proxy " + req.host);
#endif

            jData = null;
        }
Exemple #30
0
    public static void CreateTextLogAssetFile()
    {
        TextLog asset = CustomAssetUtility.CreateAsset <TextLog>();

        asset.SheetName     = "겨울 저택";
        asset.WorksheetName = "TextLog";
        EditorUtility.SetDirty(asset);
    }
        public virtual ActionResult Upgrade()
        {
            var writer = new StringWriter();
            var log = new TextLog(writer);
            var result = Database.PerformUpgrade(Extensions, log);
            UpgradeDetector.Reset();

            var upgradeModel = new UpgradeModel(result, writer.ToString());

            if (settingsProvider.GetSettings<SqlAuthSettings>().SqlAuthenticationEnabled && upgradeModel.Results.All(x => x.Successful))
            {
                // We have upgraded and now we must sign back in as as sql user!
                federatedAuthenticationService.Logout();
            }

            return View("UpgradeReport", upgradeModel);
        }
        public virtual ActionResult Upgrade()
        {
            var writer = new StringWriter();
            var log = new TextLog(writer);
            var result = Database.PerformUpgrade(Extensions, log);
            UpgradeDetector.Reset();

            return View("UpgradeReport", new UpgradeModel(result, writer.ToString()));
        }