예제 #1
0
파일: Program.cs 프로젝트: skachcz/dt-utils
        static void Main(string[] args)
        {
            DtLib.ArgsData data = new ArgsData(args);

            string format = "{0:yyyy-MM-dd-HH-mm}";

            if (data.NamedArgs.ContainsKey("format"))
            {
                format = data.NamedArgs["format"].Value;
            }

            if (String.IsNullOrEmpty(format))
            {
                Console.WriteLine(Messages.getText(Messages.ERR_ARG_INVALID_VALUE,
                                                   new object[] { "-format (" + format + ")", "Visit: https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx" }));
                return;
            }

            try
            {
                Console.WriteLine(String.Format(format, DateTime.Now));
            }

            catch (System.FormatException exc)
            {
                Console.WriteLine(Messages.getText(Messages.ERR_ARG_INVALID_VALUE,
                                                   new object[] { "-format", "Visit: https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx" }));
            }

            // Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            //Oss clongame-slg-patches /Users/cc/github/UploadCloud/TestFile/version.moe TestFile/version.bytes
            // args = new string[] {
            //     "Oss",
            //     "clongame-slg-patches",
            //     "/Users/cc/github/UploadCloud/TestFile",
            //     "TestFile"
            // };

            // Console.WriteLine (System.Environment.CurrentDirectory);

            if (args.Length == 1)
            {
                ArgsData data = JsonConvert.DeserializeObject <ArgsData> (args[0]);
                Start(data);
            }
            else if (args.Length > 1)
            {
                ArgsData argsData = new ArgsData();
                if (argsData.TryParseLine(args))
                {
                    System.Console.WriteLine(JsonConvert.SerializeObject(argsData, Formatting.Indented));
                    Start(argsData);
                }
            }
            else
            {
                Log.Content = new ArgsData();
                Log.l(ArgsData.GetTips());
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: skachcz/dt-utils
        static void Main(string[] args)
        {
            ArgsData data = new ArgsData(args);

            setAttributes(data);

            // Console.WriteLine("press key");
            // Console.ReadLine();
        }
예제 #4
0
        private ArgsData InitData()
        {
            var data = new ArgsData();

            foreach (var type in ((KArgType[])Enum.GetValues(typeof(KArgType))).Distinct())
            {
                data[type] = new Dictionary <string, string>();
            }
            return(data);
        }
예제 #5
0
        public static OssInit GetDefault(ArgsData data)
        {
            var ossInit = JsonConvert.DeserializeObject <OssInit> (File.ReadAllText("Config/OssConfig.json"));

            ossInit.LocalRootPath = data.LocalPath;
            if (File.Exists(ossInit.LocalRootPath))
            {
                ossInit.LocalRootPath = string.Empty;
            }
            ossInit.UploadFolder = data.UploadPath;
            ossInit.BucketName   = data.OssBucketName;
            return(ossInit);
        }
예제 #6
0
        static void Main(string[] args)
        {
            ArgsData data = new ArgsData(args);

            processAttributes(data);

            if (IsError)
            {
                printHelp();
            }

            // Console.WriteLine("press key");
            // Console.ReadLine();
        }
예제 #7
0
        static void Main(string[] args)
        {
            //  test json
            // string jsonStr = "{\"ExcelPath\":\"../../../excel\",\"DesPath\":\"../../../lua\",\"SelectFile\":false,\"Jenkins\":true,\"CustomConvert\":{\"LanguageSetting\":\"LanguageSplit\"},\"Test\":1}";
            // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ArgsData> (jsonStr);
            // Console.WriteLine(JsonConvert.SerializeObject(tempData));
            // return ;
            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(args));
            Console.WriteLine(System.IO.Directory.GetCurrentDirectory());
            TestControl ctl = new TestControl();

            if (args.Length > 0)
            {
                ArgsData data = null;
                try
                {
                    data = JsonConvert.DeserializeObject <ArgsData>(args[0]);
                    SystemUtil.Content = data;
                }
                catch (System.Exception)
                {
                    SystemUtil.Abend(string.Format("参数解析失败(路径不能有\\)\n{0}", args[0]));
                }
                data.ConvertEvent = ctl;
                Assembly assembly = Assembly.GetExecutingAssembly();
                var      type     = Type.GetType("ConvertCmd.Core.Convert." + data.ConvertName);
                var      ins      = assembly.CreateInstance("ConvertCmd.Core.Convert." + data.ConvertName, true);
                type.GetMethod("StartConvert").Invoke(ins, new object[] { data });
            }
            else
            {
                MoeConvertControl moeConvertCtl = new MoeConvertControl();
                var      currentFolder          = System.IO.Directory.GetCurrentDirectory();
                ArgsData data = new ArgsData();
                data.ConvertEvent  = ctl;
                data.Jenkins       = false;
                data.ExcelPath     = "../@ExcelTest";
                data.DesPath       = "../@OutputLua";
                data.CustomConvert = new System.Collections.Generic.Dictionary <string, string>();
                data.CustomConvert.Add("LanguageSetting", "LanguageSplit");
                // data.ExcelPath = "/Users/cc/Documents/eyu/slg/xfiles/number/excel";
                // data.DesPath = "/Users/cc/Documents/eyu/slg/xfiles/number/lua";
                SystemUtil.Content = data;

                moeConvertCtl.StartConvert(data);
            }
        }
예제 #8
0
        static void Start(ArgsData data)
        {
            Log.Content = data;
            if (data.CheckContent())
            {
                data.NormalPath();

                //  阿里云
                if (data.Type == UploadType.Oss)
                {
                    var ossInit  = OssInit.GetDefault(data);
                    var ossAgent = new OssAgent(ossInit);
                    ossAgent.Connect();
                    ossAgent.StartUpload(data.GetUploadPaths());
                }
            }
            else
            {
                Log.Kill("参数异常.");
            }
        }
예제 #9
0
        internal KArgs(string[] raw)
        {
            if (raw == null)
            {
                throw new ArgumentNullException(nameof(raw));
            }

            Data = InitData();

            foreach (string arg in raw)
            {
                if (AddMSBuildArgTo(KArgType.Targets, arg, "target:", "t:") ||
                    AddMSBuildArgTo(KArgType.Properties, arg, "property:", "p:") ||
                    AddMSBuildArgTo(KArgType.Loggers, arg, "logger:", "l:"))
                {
                    continue;
                }

                if (!string.IsNullOrWhiteSpace(arg))
                {
                    Data[KArgType.Common][arg] = null;
                }
            }
        }
예제 #10
0
 public ArgsTest()
 {
     this._invalidArgs = new ArgsData(new string[] { "EKTR4", "EKTR4" });
     this._validArgs   = new ArgsData(new string[] { "EKTR4", "22,1", "22,1" });
 }
예제 #11
0
파일: Program.cs 프로젝트: skachcz/dt-utils
        static void setAttributes(ArgsData argd)
        {
            if (argd.ValueArgs.Count != 3)
            {
                msg(Messages.getText(Messages.ERR_ARG_WRONG_NUMBER, new object[] { "Use: <dirpath> <filemask> <datetime> -set=<attributes> Optional: -offset=<offset>" }));
                return;
            }

            string path = argd.ValueArgs[0].Value;
            string mask = argd.ValueArgs[1].Value;

            DateTime newDate;
            bool     dateIsOk = DateTime.TryParse(argd.ValueArgs[2].Value, out newDate);

            if (dateIsOk)
            {
                try
                {
                    DateDirectory dr = new DateDirectory(path, mask);

                    dr.SetDate = newDate;

                    #region set parameter
                    if (argd.NamedArgs.ContainsKey("set"))
                    {
                        string atts = argd.NamedArgs["set"].Value;

                        // only allowed characters
                        if (atts.All(c => "acm".Contains(c)))
                        {
                            if (atts.Contains("a"))
                            {
                                dr.SetDateAccessed = true;
                            }

                            if (atts.Contains("c"))
                            {
                                dr.SetDateCreated = true;
                            }

                            if (atts.Contains("m"))
                            {
                                dr.SetDateModified = true;
                            }
                        }
                        else
                        {
                            msg(Messages.getText(Messages.ERR_ARG_INVALID_VALUE, new object[] { "-set",
                                                                                                "Allowed values: acm" }));
                            return;
                        }
                        #endregion

                        #region offset parameter

                        if (argd.NamedArgs.ContainsKey("offset"))
                        {
                            try {
                                dr.SetOffset = argd.NamedArgs["offset"].Value;
                            }

                            catch (ArgumentException exc)
                            {
                                msg(Messages.getText(Messages.ERR_ARG_INVALID_VALUE, new object[] { "-offset",
                                                                                                    "Examples: +5s -10h +3M -1Y" }));
                                return;
                            }
                        }
                        #endregion

                        dr.WriteDateAttributes(true);
                    }
                    else
                    {
                        msg(Messages.getText(Messages.ERR_ARG_IS_MANDATORY, new object[] { "-set",
                                                                                           "Allowed values: acm" }));
                    }
                }

                catch (System.IO.FileNotFoundException exc)
                {
                    msg(Messages.getText(Messages.ERR_FILE_NOT_FOUND, new object[] { path }));
                }
            }
        }
예제 #12
0
        static void processAttributes(ArgsData argd)
        {
            if (argd.ValueArgs.Count != 2)
            {
                msg(Messages.getText(Messages.ERR_ARG_WRONG_NUMBER, new object[] { "Use: <filepath> <datetime> -set=<attributes>" }));
                IsError = true;
                return;
            }

            string path = argd.ValueArgs[0].Value;

            DateTime newDate;
            bool     dateIsOk = DateTime.TryParse(argd.ValueArgs[1].Value, out newDate);

            if (argd.NamedArgs.ContainsKey("quiet"))
            {
                NoOutput = true;
            }

            if (dateIsOk)
            {
                try {
                    DateFile dt = new DateFile(path);

                    if (argd.NamedArgs.ContainsKey("set"))
                    {
                        string atts = argd.NamedArgs["set"].Value;

                        // only allowed characters
                        if (atts.All(c => "acm".Contains(c)))
                        {
                            if (atts.Contains("a"))
                            {
                                dt.DateAccessed = newDate;
                            }

                            if (atts.Contains("c"))
                            {
                                dt.DateCreated = newDate;
                            }

                            if (atts.Contains("m"))
                            {
                                dt.DateModified = newDate;
                            }

                            dt.WriteDateAttributes();
                        }
                        else
                        {
                            msg(Messages.getText(Messages.ERR_ARG_INVALID_VALUE, new object[] { "-set",
                                                                                                "Allowed values: acm" }));
                            IsError = true;
                        }
                    }
                    else
                    {
                        msg(Messages.getText(Messages.ERR_ARG_IS_MANDATORY, new object[] { "-set",
                                                                                           "Allowed values: acm" }));
                        IsError = true;
                    }
                }

                catch (System.IO.FileNotFoundException exc)
                {
                    msg(Messages.getText(Messages.ERR_FILE_NOT_FOUND, new object[] { path }));
                    IsError = true;
                }
            }
        }