Exemple #1
0
        public void ChangeDbUnban(
            int AdminID,
            int UserID,
            string Reason,
            int ChannelMessageID = 0
            )
        {
            Temp.bannedUsers.Remove(UserID);
            BanHistory banHistory = new BanHistory
            {
                UserID           = UserID,
                Ban              = 1,
                Level            = 1,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = 0,
                AdminID          = AdminID,
                BanTime          = GetTime.GetUnixTime(),
                Reason           = Reason,
                Expires          = 0
            };

            using (var db = new BlacklistDatabaseContext())
            {
                db.BanHistorys.Add(banHistory);
                var bannedUser = db.BanUsers
                                 .Single(users => users.UserID == UserID);
                db.Remove(bannedUser);
                db.SaveChanges();
            }

            new UnBanCaller().UnBanCallerThread(UserID);
        }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        Cursor.visible = true;
        //Resolution[] resolutions = Screen.resolutions;f

        Screen.SetResolution((int)(Screen.currentResolution.height * 9.0f / 16.0f), Screen.currentResolution.height, true);
        bgmAS = transform.Find("Bgm").GetComponent <AudioSource>();
        //instance = this;
        bool isday = GetTime.IsDay();

        if (filp)
        {
            isday = !isday;
        }

        if (isday)
        {
            bgmAS.clip = bgm;
            daylight.gameObject.SetActive(true);
            nightlight.gameObject.SetActive(false);
            pondcamera.GetComponent <Camera>().backgroundColor = new Color(0.89f, 0.92f, 0.1f);
        }
        else
        {
            daylight.gameObject.SetActive(false);
            nightlight.gameObject.SetActive(true);
            bgmAS.clip = nightBgm;
            pondcamera.GetComponent <Camera>().backgroundColor = new Color(0.17f, 0.16f, 0.46f);
        }

        bgmAS.Play();
    }
Exemple #3
0
        public async Task DBDStats(string steamId)
        {
            PullPlayerStats PullStats = new PullPlayerStats();
            SaveStatsToJson Save      = new SaveStatsToJson();
            ReadStatsFiles  ReadFiles = new ReadStatsFiles();
            DateTime        Time      = GetTime.CurrentTime();

            DaylightStatModel.Playerstats PlayerStats = ReadFiles.ReadIndividualPlayerFile(steamId);
            if (PlayerStats == null || Time.AddHours(-24) > PlayerStats.LastUpdated)
            {
                PlayerStats = PullStats.PlayerStats(steamId);
            }
            if (PlayerStats.SteamId != "1")
            {
                //File Write
                AccessDropbox LinkToStatsDownload = new AccessDropbox();
                GetCheckDirectory.CheckDirectory();
                Save.WriteToFile(PlayerStats);
                var BuildOutput = EmbedOutput.BuildDBDStats(PlayerStats, LinkToStatsDownload.SCreateDBoxClient(PlayerStats).Result);
                await Context.Channel.SendMessageAsync("", false, BuildOutput.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync("", false, EmbedOutput.DBDAPIFailure(PlayerStats.SteamId).Build());
            }
        }
Exemple #4
0
    private void Start()
    {
        string path = "player.log";

        GetTime.LogPlay(path);
        bool isday = GetTime.IsDay();

        if (filp)
        {
            isday = !isday;
        }

        if (isday)
        {
            bgmAS.clip = bgm;
            daylight.gameObject.SetActive(true);
            nightlight.gameObject.SetActive(false);
            foreach (Transform t in lights)
            {
                t.gameObject.SetActive(false);
            }
        }
        else
        {
            daylight.gameObject.SetActive(false);
            nightlight.gameObject.SetActive(true);
            bgmAS.clip = nightBgm;
            foreach (Transform t in lights)
            {
                t.gameObject.SetActive(true);
            }
        }
        bgmAS.Play();
    }
Exemple #5
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="get_time">time getter delegate (time in seconds)</param>
 /// <param name="view_rect"></param>
 /// <param name="view"></param>
 public ModelSpinningControls(GetTime get_time, GetViewRect view_rect, GetMatrix view)
 {
     this._get_time      = get_time;
     this._get_view_rect = view_rect;
     this._get_view_mat  = view;
     this._drag_start_T  = this._rotate_start_T = this.time;
 }
        public string GetBanMessage()
        {
            string msg = "未被封禁";

            if (Ban == 0)
            {
                msg = "已被封禁";
                if (Level == 0)
                {
                    msg += ",封禁等级为: 0 (严重)";
                }
                else if (Level == 1)
                {
                    msg += ",封禁等级为: 1 (警告)";
                }
                else
                {
                    msg += ",封禁等级为: " + Level + " (未知)";
                }
                msg += ",该记录将于 " + GetTime.GetExpiresTime(Expires) + " 后失效";
                msg += "\n\n原因是:\n" + Reason;
                if (ChannelMessageID != 0)
                {
                    msg += "\n\n参见: https://t.me/" + Temp.MainChannelName + "/" + ChannelMessageID;
                }
            }
            return(msg);
        }
//	private int i;


	void Start () 
	{
		//data getting
		SecondScriptToAccess = wall_2.GetComponent<GetTime> ();
		IntoInt ();
		ItemsList ();
	}
    protected void registerToRespawn(long initialRespawnTime = long.MaxValue)
    {
        long gameTimeMilliseconds = Service.Get <INetworkServicesManager>().GameTimeMilliseconds;

        if (!(RewardDef != null))
        {
            return;
        }
        List <CollectibleRewardDefinition> definitions = RewardDef.GetDefinitions <CollectibleRewardDefinition>();

        if (definitions.Count <= 0)
        {
            return;
        }
        long respawnTime;

        if (definitions[0].Collectible.SpawnCategory == SpawnCategory.ElapsedTime)
        {
            if (initialRespawnTime != long.MaxValue)
            {
                respawnTime = initialRespawnTime;
            }
            else
            {
                long num = GetTime.SecondsToMS(definitions[0].Collectible.RespawnSeconds);
                respawnTime = gameTimeMilliseconds + num;
            }
        }
        else
        {
            respawnTime = long.MaxValue;
        }
        ClubPenguin.SceneRefs.CollectibleController.RegisterRespawn(this, respawnTime);
    }
Exemple #9
0
        private void UpdateUserClientTime()
        {
            GetTime gt = new GetTime();

            byte[] buffer = new byte[1024];
            Array.Clear(buffer, 0, buffer.Length);
            Packet.Serialize(gt).CopyTo(buffer, 0);
        }
Exemple #10
0
        public void ChangeDbBan(
            int AdminID,
            int UserID,
            int Level,
            long Expires,
            string Reason,
            int ChannelMessageID = 0,
            int ReasonMessageID  = 0
            )
        {
            BanUser baninfo = new BanUser
            {
                UserID           = UserID,
                Ban              = 0,
                Level            = Level,
                Reason           = Reason,
                HistoryID        = 0,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = ReasonMessageID,
                Expires          = Expires
            };

            Temp.bannedUsers[UserID] = baninfo;
            BanHistory banHistory = new BanHistory
            {
                UserID           = UserID,
                Ban              = 0,
                Level            = Level,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = ReasonMessageID,
                AdminID          = AdminID,
                BanTime          = GetTime.GetUnixTime(),
                Reason           = Reason,
                Expires          = Expires
            };

            using (var db = new BlacklistDatabaseContext())
            {
                db.BanHistorys.Add(banHistory);
                try
                {
                    db.BanUsers.Add(baninfo);
                    db.SaveChanges();
                }
                catch (SqliteException)
                {
                    db.BanUsers.Update(baninfo);
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    db.BanUsers.Update(baninfo);
                    db.SaveChanges();
                }
            }

            new SubscribeBanListCaller().CallGroupsInThread(baninfo);
        }
        private void get_time()
        {
            (var authGroup, var key, var value, var now) = GetTime.getTime();
            comboBox1.DataSource    = authGroup;
            comboBox1.DisplayMember = key;
            comboBox1.ValueMember   = value;

            label3.Text = now.ToString("MM/dd HH:mm");
        }
Exemple #12
0
 static void Main(string[] args)
 {
     ValidateUserSelection.userChoice1Actions       += new UserChoiceHandler(UserChoice1);
     ValidateUserSelection.userChoice2Actions       += new UserChoiceHandler(UserChoice2);
     ValidateUserSelection.userChoice3Actions       += new UserChoiceHandler(UserChoice3);
     ValidateUserSelection.wrongInputActions        += new UserChoiceHandler(WrongInput);
     Validate_Correct_Folder_Input.wrongFolderInput += new UserChoiceHandler(wrongFolderInput);
     GetFiles.showFoundPathAndFileActions           += new FoundPathAndFileHandler(ShowFoundPathAndFile);
     Console.WriteLine(GetTime.SendWelcome());
     StartApp();
 }
Exemple #13
0
        /// <summary>
        /// 工作开始后的操作
        /// </summary>
        public static void Start()
        {
            GetTime.GetSelectedTime();
            string Lock = "工作开始时间:";

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(GlobalVariables.SavePath + "/log.txt", true))
            {
                file.WriteLine(Lock + NowTime.FullTime);
                file.Close();
            }
        }
Exemple #14
0
 /// <summary>
 /// 添加在职员工信息 (在完成员工申请 经 审批通过后)
 /// </summary>
 /// <param name="staff"></param>
 /// <returns></returns>
 public bool addStarffInfo(Staff staff)
 {
     staff.CreateTime = DateTime.Now;
     staff.IsLaunch   = 0;
     staff.IsHSEGroup = "是";
     staff.OrgID      = 1;
     staff.Statusd    = "待入职";
     staff.NoN        = staff.Name;
     staff.Passwords  = GetTime.randomPwd();
     return(_staffResposit.AddCreateInfo(staff) > 0);
 }
    void Start()
    {
        SecondScriptToAccess = wall_1.GetComponent <GetTime> ();

        DataList.Add(SecondScriptToAccess.wall_1_timeLooked);
        DataList.Add(SecondScriptToAccess.wall_2_timeLooked);
        DataList.Add(SecondScriptToAccess.wall_3_timeLooked);
        DataList.Add(SecondScriptToAccess.wall_4_timeLooked);
        DataList.Add(SecondScriptToAccess.ball_1_timeLooked);
        DataList.Add(SecondScriptToAccess.ball_2_timeLooked);
        DataList.Add(SecondScriptToAccess.ball_3_timeLooked);
        DataList.Add(SecondScriptToAccess.ball_4_timeLooked);
    }
Exemple #16
0
        public string GetBanMessageMarkdown()
        {
            string msg = "未封鎖";

            if (Ban == 0)
            {
                string ExpTime = GetTime.GetExpiresTime(Expires);
                msg = "處分 : `";
                if (Level == 0)
                {
                    msg += "封鎖";
                }
                else if (Level == 1)
                {
                    msg += "警告";
                }
                else
                {
                    msg += " : " + Level + " (未知)";
                }

                msg += "`";

                if (ExpTime != "永久封鎖")
                {
                    msg += "\n時效至 : `" + GetTime.GetExpiresTime(Expires) + "`";
                }
                else
                {
                    msg += "\n時效 : `永久`";
                }

                if (Reason.Contains("`"))
                {
                    msg += "\n原因 : " + Reason;
                }
                else
                {
                    msg += "\n原因 : " + RAPI.escapeMarkdown(Reason);
                }

                if (ChannelMessageID != 0 && Config.MainChannelName != null)
                {
                    msg += "\n\n參考 : https://t.me/" + RAPI.escapeMarkdown(Config.MainChannelName) + "/" + ChannelMessageID;
                }
            }

            return(msg);
        }
Exemple #17
0
        public List <GetTime> GetListTimeByRoom(int id)
        {
            List <GetTime> listTime = new List <GetTime>();

            string    query = "SELECT b.DateCheckIn , b.DateCheckOut ,b.idRoom, DATEDIFF(Minute ,b.DateCheckIn, b.DateCheckOut) as time1, hm.price, (hm.price/60)*DATEDIFF(Minute ,b.DateCheckIn, b.DateCheckOut) as totalPrice FROM dbo.Bill AS b , dbo.HourMoney AS hm WHERE b.idRoom =  " + id;
            DataTable data  = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                GetTime time = new GetTime(item);
                listTime.Add(time);
            }

            return(listTime);
        }
Exemple #18
0
        protected virtual void LogBoostUsed(ITimeBoost boost)
        {
            var log = new StringBuilder();

            log.AppendLine();
            log.AppendLine("UI: '{0}' : '{1}' : '{2}'", Title, SubTitle, SummaryText);
            log.AppendLine("User: {0}", User);
            log.AppendLine("Boost: {0}", boost);
            log.AppendLine("Get: {0}", GetTime.Trace(false));
            log.AppendLine("Set: {0}", SetTime.Trace(false));
            log.AppendLine("Time: {0} > {1}", OldTime, Time);
            log.AppendLine();

            log.Log("/TimeBoosts/" + DateTime.Now.ToDirectoryName() + "/" + boost + ".log");
        }
Exemple #19
0
    void Start()
    {
        //data getting
        SecondScriptToAccess = wall_2.GetComponent <GetTime> ();
        IntoInt();
        ItemsList();

        prefabObjects[0] = prefab1;
        prefabObjects[1] = prefab2;
        prefabObjects[2] = prefab3;
        prefabObjects[3] = prefab4;
        prefabObjects[4] = prefab5;
        prefabObjects[5] = prefab6;
        prefabObjects[6] = prefab7;
        prefabObjects[7] = prefab8;
    }
        /// <summary>
        /// 生成一张员工在职表(如果改员工被同意入职)
        /// </summary>
        /// <param name="RefOrderId"></param>
        public void AddStaffInfo(int RefOrderId)
        {
            //根据记录表中关联的入职信息id 查询到申请人信息
            Entrys entrys = _entrysResposit.FindAll().FirstOrDefault(x => x.Id == RefOrderId);

            //生成一张员工在职表(如果改员工被同意入职)

            #region 生成工号 (后期性能差)
            bool   isoks = true;
            string non   = "";
            while (isoks)
            {
                non = "CH" + GetTime.GetTimeStamp() + GetTime.GetRandom();
                Staff staffNon = _staffResposit.FindAll().FirstOrDefault(x => x.NoN == non);

                if (staffNon == null)
                {
                    isoks = false;
                }
            }
            #endregion

            #region 审批同意后需要生成正式员工表的信息
            Staff staffIn = null;
            staffIn = new Staff()
            {
                JobId       = entrys.JobId,
                BirthDay    = entrys.BirthDay,
                Name        = entrys.StaffName,
                NoN         = non,
                CreateTime  = DateTime.Now,
                RoleId      = entrys.JobId,
                Passwords   = "123456", // 初始密码
                Sex         = entrys.Sex == 1 ? "男" : "女",
                Tel         = entrys.Tel,
                Email       = entrys.Email,
                Statusd     = "入职",
                IsHSEGroup  = "是",
                IsLaunch    = 0,
                OrgID       = 1,
                Addressd    = entrys.Addressd,
                NativePlace = "待定",
            };
            //添加
            _staffResposit.AddInfo(staffIn);
            #endregion
        }
Exemple #21
0
        public string NewNoN()
        {
            bool   isok = true;
            string non  = "";

            while (isok)
            {
                non = GetTime.randomPwd() + GetTime.randomPwd() + GetTime.randomPwd();
                var list = (from pr in _processStepRecordResposit.FindAll()
                            where non == pr.NoN
                            select new { }).ToList();
                if (list.Count == 0)
                {
                    isok = false;
                }
            }
            return(non);
        }
Exemple #22
0
        private void GetUserTime()
        {
            try
            {
                byte[] buffer = new byte[1024 * 4];

                // 1. connect to server
                //TcpClient client = new TcpClient("10.63.60.79", 9999);

                if (!clientSocket.Client.Connected)
                {
                    clientSocket.Connect(serverAddr, 9999);
                }

                NetworkStream stream = clientSocket.GetStream();

                // 2. send the packet
                GetTime gt = new GetTime();
                gt.packet_Type = (int)PacketType.GetTime;
                gt.id_str      = myid;
                gt.timeleft    = "";

                Packet.Serialize(gt).CopyTo(buffer, 0);

                stream.Write(buffer, 0, buffer.Length);
                //  receive the packet
                Array.Clear(buffer, 0, buffer.Length);

                //int bytesRead = stream.Read(buffer, 0, buffer.Length);
                //GetTime time = (GetTime)Packet.Deserialize(buffer);

                //char delimiter = ':';
                //String[] substrings = time.timeleft.Split(delimiter);
                //TimeLeft.hour = Convert.ToInt32(substrings[0]);
                //TimeLeft.min = Convert.ToInt32(substrings[1]);
                //TimeLeft.sec = Convert.ToInt32(substrings[2]);
                //TimeLeft.allTimeValue = TimeLeft.hour * 3600 + TimeLeft.min * 60 + TimeLeft.sec;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message); //MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #23
0
        public BanUser GetUserBanStatus(int uid)
        {
            BanUser banuser = null;

            banuser = Temp.bannedUsers.GetValueOrDefault(uid, null);
            if (banuser != null)
            {
                if (GetTime.GetIsExpired(banuser.Expires))
                {
                    banuser.Ban           = 1;
                    Temp.bannedUsers[uid] = banuser;
                }

                return(banuser);
            }

            using (var db = new BlacklistDatabaseContext())
            {
                BanUser bannedUser;
                try
                {
                    bannedUser = db.BanUsers
                                 .Single(users => users.UserID == uid);
                    Temp.bannedUsers.TryAdd(uid, bannedUser);
                }
                catch (InvalidOperationException)
                {
                    bannedUser = new BanUser {
                        Ban = 1
                    };
                    Temp.bannedUsers.TryAdd(uid, bannedUser);
                    return(bannedUser);
                }

                if (GetTime.GetIsExpired(bannedUser.Expires))
                {
                    bannedUser.Ban = 1;
                    db.BanUsers.Update(bannedUser);
                }

                return(bannedUser);
            }
        }
        public string GetBanMessage_ESCMD()
        {
            string msg = "未封鎖";

            if (Ban == 0)
            {
                string ExpTime = GetTime.GetExpiresTime(Expires);
                msg = "處分 : ";
                if (Level == 0)
                {
                    msg += "封鎖";
                }
                else if (Level == 1)
                {
                    msg += "警告";
                }
                else
                {
                    msg += " : " + Level + " (未知)";
                }

                if (ExpTime != "永久封鎖")
                {
                    msg += "\n時效至 : " + GetTime.GetExpiresTime(Expires);
                }
                else
                {
                    msg += "\n時效 : 永久";
                }

                msg += "\n原因 : " + Reason;

                if (ChannelMessageID != 0 && Temp.MainChannelName != null)
                {
                    msg += "\n\n參考 : https://t.me/" + Temp.MainChannelName + "/" + ChannelMessageID;
                }

                msg = RAPI.escapeMarkdown(msg);
            }

            return(msg);
        }
    private RespawnResponse getRespawnState(Collectible scriptObj)
    {
        string text = scriptObj.Path;

        if (scriptObj.GetType() == typeof(SceneryCollectible) || scriptObj.GetType() == typeof(RewardCollectible))
        {
            text = scriptObj.InteractionPath;
        }
        RewardDefinition rewardDef = scriptObj.RewardDef;
        List <CollectibleRewardDefinition> list = null;

        if (rewardDef != null)
        {
            list = rewardDef.GetDefinitions <CollectibleRewardDefinition>();
        }
        if (rewardDef == null || list.Count < 1)
        {
            Log.LogErrorFormatted(scriptObj, "{0} has no CollectibleDefinition", text);
            return(new RespawnResponse(RespawnState.NOT_AVAILABLE, 0L));
        }
        if (!currentRoomState.HasBeenCollected(text))
        {
            return(new RespawnResponse(RespawnState.READY_FOR_PICKUP, 0L));
        }
        if (list[0].Collectible.SpawnCategory == SpawnCategory.Daily)
        {
            return(new RespawnResponse(RespawnState.NOT_AVAILABLE, 0L));
        }
        long respawnTime          = currentRoomState.GetRespawnTime(text);
        long num                  = GetTime.SecondsToMS(list[0].Collectible.RespawnSeconds);
        long num2                 = respawnTime + num;
        long gameTimeMilliseconds = Service.Get <INetworkServicesManager>().GameTimeMilliseconds;

        if (num2 < gameTimeMilliseconds)
        {
            return(new RespawnResponse(RespawnState.READY_FOR_PICKUP, 0L));
        }
        return(new RespawnResponse(RespawnState.WAITING_TO_RESPAWN, num2));
    }
        ///< summary >
        /// API Call to Steam's API and storing the call within the < see cref = "DaylightStatModel" /> data model.
        /// </ summary >
        ///
        public DaylightStatModel.Playerstats PlayerStats(string _steamID)
        {
            DaylightStatModel.Playerstats obj = new DaylightStatModel.Playerstats();
            using (var web = new WebClient())
            {
                try
                {
                    var _url =
                        string.Format($"http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid={StaticDetails.AppID}&key={StaticDetails.SteamAPIKey}&steamid={_steamID}&format=json");
                    _downloadNews = web.DownloadString(_url);
                }
                catch (WebException msg)
                {
                    obj.SteamId = "1";
                    return(obj);
                }
                //Store downloaded stats into memory.
                var DownloadedStats = JsonConvert.DeserializeObject <DaylightStatModel>(_downloadNews);
                obj             = DownloadedStats.PlayerStats;
                obj.LastUpdated = GetTime.CurrentTime();

                return(obj);
            }
        }
Exemple #27
0
        static void Main(string[] args)
        {
            int[,] H10Cords = new int[2, 2] {
                { 2, 8 }, { 2, 6 }
            };
            int[,] H1Coords = new int[4, 2] {
                { 4, 8 }, { 4, 6 }, { 4, 4 }, { 4, 2 }
            };
            int[,] M10Coords = new int[3, 2] {
                { 6, 8 }, { 6, 6 }, { 6, 4 }
            };
            int[,] M1Coords = new int[4, 2] {
                { 8, 8 }, { 8, 6 }, { 8, 4 }, { 8, 2 }
            };
            int[,] S10Coords = new int[3, 2] {
                { 10, 8 }, { 10, 6 }, { 10, 4 }
            };
            int[,] S1Coords = new int[4, 2] {
                { 12, 8 }, { 12, 6 }, { 12, 4 }, { 12, 2 }
            };

            int H10 = SplitTime(true, DateTime.Now.Hour);
            int H1  = SplitTime(false, DateTime.Now.Hour);
            int M10 = SplitTime(true, DateTime.Now.Minute);
            int M1  = SplitTime(false, DateTime.Now.Minute);
            int S10 = SplitTime(true, DateTime.Now.Second);
            int S1  = SplitTime(false, DateTime.Now.Second);

            Console.CursorVisible   = false;
            Console.BackgroundColor = ConsoleColor.White;
            Console.Clear();

            ShowClock.Draw(H10Cords, GetTime.GetHour10());
            ShowClock.Draw(H1Coords, GetTime.GetHour1());
            ShowClock.Draw(M10Coords, GetTime.GetMin10());
            ShowClock.Draw(M1Coords, GetTime.GetMin1());
            ShowClock.Draw(S10Coords, GetTime.GetSec10());
            ShowClock.Draw(S1Coords, GetTime.GetSec1());

            do
            {
                while (!Console.KeyAvailable)
                {
                    if (H10 != SplitTime(true, DateTime.Now.Hour))
                    {
                        ShowClock.Draw(H10Cords, GetTime.GetHour10());
                        H10 = SplitTime(true, DateTime.Now.Hour);
                    }
                    if (H1 != SplitTime(false, DateTime.Now.Hour))
                    {
                        ShowClock.Draw(H1Coords, GetTime.GetHour1());
                        H1 = SplitTime(false, DateTime.Now.Hour);
                    }
                    if (M10 != SplitTime(true, DateTime.Now.Minute))
                    {
                        ShowClock.Draw(M10Coords, GetTime.GetMin10());
                        M10 = SplitTime(true, DateTime.Now.Minute);
                    }
                    if (M1 != SplitTime(false, DateTime.Now.Minute))
                    {
                        ShowClock.Draw(M1Coords, GetTime.GetMin1());
                        M1 = SplitTime(false, DateTime.Now.Minute);
                    }
                    if (S10 != SplitTime(true, DateTime.Now.Second))
                    {
                        ShowClock.Draw(S10Coords, GetTime.GetSec10());
                        S10 = SplitTime(true, DateTime.Now.Second);
                    }
                    if (S1 != SplitTime(false, DateTime.Now.Second))
                    {
                        SoundPlayer sound = new SoundPlayer();
                        ShowClock.Draw(S1Coords, GetTime.GetSec1());
                        S1 = SplitTime(false, DateTime.Now.Second);
                        if (S1 % 2 == 0)
                        {
                            sound.SoundLocation = Environment.CurrentDirectory + "/Tick.wav";
                            sound.Play();
                        }
                        else
                        {
                            sound.SoundLocation = Environment.CurrentDirectory + "/Tock.wav";
                            sound.Play();
                        }
                    }
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);

            TheLastStuff();
        }
Exemple #28
0
        private void AnalyzePacket(byte[] buffer)
        {
            Packet packet = (Packet)Packet.Deserialize(buffer);

            if (packet == null)
            {
                return;
            }

            switch ((int)packet.packet_Type)
            {
            case (int)PacketType.Login_RESULT:
                // 3. receive the packet
                //int bytesRead = stream.Read(buffer, 0, buffer.Length);
                LoginResult loginResult = (LoginResult)Packet.Deserialize(buffer);

                if (loginResult.result)
                {
                    myid = loginResult.reason;
                    //MessageBox.Show(loginResult.reason, "클라이언트 확인", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    setLog("login success");
                    isLogined = true;
                    ChangePanel(isLogined);
                    GetUserTime();
                    StartTimer();
                }
                else
                {
                    setLog("login failed" + loginResult.reason);
                    MessageBox.Show(loginResult.reason, "클라이언트 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                break;

            case (int)PacketType.Member_REGISTER_RESULT:
                MemberRegisterResult mrResult = (MemberRegisterResult)Packet.Deserialize(buffer);

                if (mrResult.result)
                {
                    setLog("succeed register");// MessageBox.Show(mrResult.reason, "클라이언트 확인", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    setLog("failed register");
                    //MessageBox.Show(mrResult.reason, "클라이언트 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;


            case (int)PacketType.GetTime:    // get time

                GetTime time = (GetTime)Packet.Deserialize(buffer);

                char     delimiter  = ':';
                String[] substrings = time.timeleft.Split(delimiter);
                TimeLeft.hour         = Convert.ToInt32(substrings[0]);
                TimeLeft.min          = Convert.ToInt32(substrings[1]);
                TimeLeft.sec          = Convert.ToInt32(substrings[2]);
                TimeLeft.allTimeValue = TimeLeft.hour * 3600 + TimeLeft.min * 60 + TimeLeft.sec;
                break;
            }
            //stream.Close();
        }
Exemple #29
0
        internal bool Ban(TgMessage RawMessage, string JsonMessage, string Command)
        {
            int banSpace = RawMessage.text.IndexOf(" ");

            if (banSpace == -1)
            {
                TgApi.getDefaultApiConnection().sendMessage(
                    RawMessage.GetMessageChatInfo().id,
                    Strings.BAN_HELP_MESSAGE,
                    RawMessage.message_id
                    );
                return(true);
            }

            int      BanUserId        = 0;
            long     ExpiresTime      = 0;
            int      Level            = 0;
            string   Reason           = "";
            UserInfo BanUserInfo      = null;
            string   value            = RawMessage.text.Substring(banSpace + 1);
            int      valLen           = value.Length;
            bool     notCommonBan     = true;
            int      commandBanLength = 0;
            int      banDay           = 0;

            if (valLen > 3)
            {
                if (valLen == 4)
                {
                    if (value.Substring(0, 4) == "spam")
                    {
                        commandBanLength = 4;
                        Reason           = Strings.SPAM;
                        banDay           = Config.DefaultSpamBanDay;
                        notCommonBan     = false;
                    }

                    //if (value.Substring(0, 4) == "coin")
                    //{
                    //    commandBanLength = 4;
                    //    Reason = Strings.COIN;
                    //    banDay = Config.DefaultCoinBanDay;
                    //    notCommonBan = false;
                    //}
                }

                if (valLen == 5)
                {
                    if (value.Substring(0, 5) == "halal")
                    {
                        commandBanLength = 5;
                        Reason           = Strings.HALAL;
                        banDay           = Config.DefaultHalalBanDay;
                        notCommonBan     = false;
                    }
                }

                //if(valLen == 6)
                //    if (value.Substring(0, 6) == "innsfw")
                //    {
                //        commandBanLength = 6;
                //        Reason = Strings.INNSFW;
                //        banDay = Config.DefaultInNsfwBanDay;
                //        notCommonBan = false;
                //    }

                //if (valLen == 7)
                //{
                //    if (value.Substring(0, 7) == "spammer")
                //    {
                //        commandBanLength = 7;
                //        Reason = Strings.SPAMMER;
                //        banDay = Config.DefaultSpammerBanDay;
                //        notCommonBan = false;
                //    }

                //    if (value.Substring(0, 7) == "outnsfw")
                //    {
                //        commandBanLength = 7;
                //        Reason = Strings.OUTNSFW;
                //        banDay = Config.DefaultOutNsfwBanDay;
                //        notCommonBan = false;
                //    }

                //    if (value.Substring(0, 7) == "crawler")
                //    {
                //        commandBanLength = 7;
                //        Reason = Strings.CRAWLER;
                //        banDay = Config.DefaultCrawlerBanDay;
                //        notCommonBan = false;
                //    }
                //}

                if (banDay > 0)
                {
                    ExpiresTime = GetTime.GetUnixTime() + (banDay * 86400);
                }
            }

            if (!notCommonBan)
            {
                if (valLen > (commandBanLength + 1))
                {
                    if (value[commandBanLength] != ' ')
                    {
                        TgApi.getDefaultApiConnection().sendMessage(
                            RawMessage.GetMessageChatInfo().id,
                            Strings.BAN_ERROR_MESSAGE + " err_a1",
                            RawMessage.message_id
                            );
                        return(true);
                    }

                    UserInfo tmpUinfo =
                        new GetValues().GetByTgMessage(
                            new Dictionary <string, string> {
                        { "from", value.Substring(6) }
                    }, RawMessage);
                    if (tmpUinfo == null)
                    {
                        return(true);                  // 如果没拿到使用者信息则代表出现了异常
                    }
                    BanUserId = tmpUinfo.id;
                    if (tmpUinfo.language_code != null && tmpUinfo.language_code != "__CAN_NOT_GET_USERINFO__")
                    {
                        BanUserInfo = tmpUinfo;
                    }
                }
                else
                {
                    UserInfo tmpUinfo =
                        new GetValues().GetByTgMessage(new Dictionary <string, string>(), RawMessage);
                    if (tmpUinfo == null)
                    {
                        return(true);                  // 如果没拿到使用者信息则代表出现了异常
                    }
                    BanUserId = tmpUinfo.id;
                    if (tmpUinfo.language_code != null)
                    {
                        if (tmpUinfo.language_code != "__CAN_NOT_GET_USERINFO__")
                        {
                            BanUserInfo = tmpUinfo;
                        }
                    }
                    else
                    {
                        BanUserInfo = tmpUinfo;
                    }
                }
            }



            if (notCommonBan)
            {
                try
                {
                    Dictionary <string, string> banValues = CommandDecoder.cutKeyIsValue(value);
                    string tmpString = "";

                    // 获取使用者信息
                    UserInfo tmpUinfo = new GetValues().GetByTgMessage(banValues, RawMessage);
                    if (tmpUinfo == null)
                    {
                        return(true);                  // 如果没拿到使用者信息则代表出现了异常
                    }
                    BanUserId = tmpUinfo.id;
                    if (tmpUinfo.language_code != null)
                    {
                        if (tmpUinfo.language_code != "__CAN_NOT_GET_USERINFO__")
                        {
                            BanUserInfo = tmpUinfo;
                        }
                    }
                    else
                    {
                        BanUserInfo = tmpUinfo;
                    }

                    // 获取 ExpiresTime
                    long tmpExpiresTime = new GetValues().GetBanUnixTime(banValues, RawMessage);
                    if (tmpExpiresTime == -1)
                    {
                        return(true);                      // 如果过期时间是 -1 则代表出现了异常
                    }
                    ExpiresTime = tmpExpiresTime;

                    // 获取 Level
                    tmpString = banValues.GetValueOrDefault("l", "__invalid__");
                    if (tmpString == "__invalid__")
                    {
                        tmpString = banValues.GetValueOrDefault("level", "0");
                    }
                    if (!int.TryParse(tmpString, out Level))
                    {
                        TgApi.getDefaultApiConnection().sendMessage(
                            RawMessage.GetMessageChatInfo().id,
                            Strings.BAN_ERROR_MESSAGE + " err8",
                            RawMessage.message_id
                            );
                        return(true);
                    }

                    // 获取 Reason
                    Reason = new GetValues().GetReason(banValues, RawMessage);
                    if (Reason == null)
                    {
                        return(true);                // 如果 Reason 是 null 则代表出现了异常
                    }
                    if (Reason.ToLower() == "halal")
                    {
                        Reason = Strings.HALAL;
                    }
                    if (Reason.ToLower() == "spam")
                    {
                        Reason = Strings.SPAM;
                    }
                    // if (Reason.ToLower() == "spammer") Reason = Strings.SPAMMER;
                    // if (Reason.ToLower() == "innsfw") Reason = Strings.INNSFW;
                    // if (Reason.ToLower() == "outnsfw") Reason = Strings.OUTNSFW;
                    // if (Reason.ToLower() == "coin") Reason = Strings.COIN;
                    // if (Reason.ToLower() == "crawler") Reason = Strings.CRAWLER;
                }
                catch (DecodeException)
                {
                    TgApi.getDefaultApiConnection().sendMessage(
                        RawMessage.GetMessageChatInfo().id,
                        Strings.BAN_ERROR_MESSAGE + " err10",
                        RawMessage.message_id
                        );
                    return(true);
                }
            }

            if (Config.GetIsInWhiteList(BanUserId))
            {
                TgApi.getDefaultApiConnection().sendMessage(
                    RawMessage.GetMessageChatInfo().id,
                    Strings.EXEC_FAIL + Strings.BAN_ERROR_USER_IN_WHITELIST,
                    RawMessage.message_id
                    );
                return(false);
            }

            int AdminID = RawMessage.GetSendUser().id;

            if (RawMessage.GetMessageChatInfo().id == Config.InternGroupID)
            {
                AdminID = 1;
            }

            bool status;

            if (BanUserInfo == null)
            {
                status = Config.GetDatabaseManager().BanUser(
                    AdminID,
                    BanUserId,
                    Level,
                    ExpiresTime,
                    RAPI.escapeMarkdown(Reason)
                    );
            }
            else if (RawMessage.GetReplyMessage().new_chat_member != null)
            {
                status = Config.GetDatabaseManager().BanUser(
                    AdminID,
                    BanUserId,
                    Level,
                    ExpiresTime,
                    RAPI.escapeMarkdown(Reason),
                    0,
                    0,
                    BanUserInfo
                    );
            }
            else
            {
                status = Config.GetDatabaseManager().BanUser(
                    AdminID,
                    BanUserId,
                    Level,
                    ExpiresTime,
                    RAPI.escapeMarkdown(Reason),
                    RawMessage.GetMessageChatInfo().id,
                    RawMessage.GetReplyMessage().message_id,
                    BanUserInfo
                    );
            }
            //if (status)
            //{
            TgApi.getDefaultApiConnection().sendMessage(
                RawMessage.GetMessageChatInfo().id,
                Strings.EXEC_OK,
                RawMessage.message_id
                );
            return(true);
            //}
            //else
            //{
            //    TgApi.getDefaultApiConnection().sendMessage(
            //        RawMessage.GetMessageChatInfo().id,
            //        "操作成功。\n\n請注意 : 轉發使用者訊息到頻道或是發送使用者訊息到頻道失敗,請您手動發送至 @" + Config.MainChannelName + " 。 err11",
            //        RawMessage.message_id
            //        );
            //    return true;
            //}
            //return false;
        }
Exemple #30
0
        /// <summary>
        /// 增添订单
        /// </summary>
        /// <param name="oilMaterialOrderDto"></param>
        /// <returns></returns>
        public bool AddOilMatOrder(OilMaterialOrderDto oilMaterialOrderDto, ref string rem)
        {
            Staff staff = _staffResposit.FindAll().Where(x => x.NoN == oilMaterialOrderDto.StaffNoN).FirstOrDefault();

            if (staff == null)
            {
                rem = "未找到这个用户!!!";
                return(false);
            }
            int num = 0;

            //开启事务
            _oilMaterialOrderResposit.StatrAffairs(() =>
            {
                int OrderId = _oilMaterialOrderResposit.AddCreateInfo(new OilMaterialOrder
                {
                    StaffNoN   = oilMaterialOrderDto.StaffNoN,
                    NoN        = GetTime.GetTimeAll() + GetTime.GetTimeStamp() + "_" + GetTime.GetRandom(),
                    ApplyDate  = DateTime.Now,
                    Remark     = oilMaterialOrderDto.Remark,
                    IsDel      = 0,
                    CreateTime = DateTime.Now,
                    IsPanke    = 0,
                    IsLaunch   = 0
                });
                _oilMaterialOrderDetailResposit.AddInfo(new OilMaterialOrderDetail
                {
                    OrderId    = OrderId,
                    CreateTime = DateTime.Now,
                    DayAvg     = oilMaterialOrderDto.DayAvg,
                    IsDel      = 0,
                    NeedAmount = oilMaterialOrderDto.NeedAmount,
                    OilSpec    = oilMaterialOrderDto.OilSpec,
                    Surplus    = oilMaterialOrderDto.Surplus,
                    Volume     = oilMaterialOrderDto.Volume
                });

                ProcessStepRecord processStepRecord = new ProcessStepRecord();

                //根据申请油料的多少决定有谁来审批
                if (oilMaterialOrderDto.NeedAmount <= 1000)
                {
                    processStepRecord.OilStation = 1;
                }
                else if (oilMaterialOrderDto.NeedAmount > 1000 && oilMaterialOrderDto.NeedAmount <= 10000)
                {
                    processStepRecord.GeneralManagerOfPerson = 1;
                }
                else if (oilMaterialOrderDto.NeedAmount > 10000 && oilMaterialOrderDto.NeedAmount <= 50000)
                {
                    processStepRecord.GeneralManagerOfPerson = 1;
                    processStepRecord.GeneralManager         = 1;
                }
                else if (oilMaterialOrderDto.NeedAmount > 50000)
                {
                    processStepRecord.ChiefInspector = 1;
                }

                processStepRecord.Typed         = ProcessType.油料申请审批流程.ToString();
                processStepRecord.RecordRemarks = oilMaterialOrderDto.Remark;
                processStepRecord.NoN           = NewNoN();
                processStepRecord.RefOrderId    = OrderId; //申请油料订单的id
                _processStepRecordResposit.AddInfo(processStepRecord);
                num++;
            });
            return(num > 0);
        }