Пример #1
0
        /// <summary>
        /// 保存信息
        /// </summary>
        /// <returns></returns>
        public static bool Save(string path, List <Annual> an)
        {
            try
            {
                string str = null;

                if (an != null &&
                    an.Count > 0)
                {
                    foreach (Annual a in an)
                    {
                        str += a.ToString() + "*";
                    }

                    File_Operate.SaveToTextFile(path, str);

                    return(true);
                }

                return(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 载入数据,设置对象失败返回false,对象将为null
        /// </summary>
        /// <returns></returns>
        public static bool Load(string path, out List <Annual> an)
        {
            try
            {
                an = null;

                //拆分为多个annual_target.toString()数据
                if (!File.Exists(path))
                {
                    return(false);
                }

                string[] temp = File_Operate.LoadFromTextFile(path);

                if (temp == null)
                {
                    return(false);
                }

                string[] infos = temp[0].Split("*".ToArray(), StringSplitOptions.RemoveEmptyEntries);

                if (infos.Length > 0)
                {
                    //创建对象
                    an = new List <Annual>();

                    for (int i = 0; i < infos.Length; i++)
                    {
                        Annual a = new Annual();

                        GetAnnualDetailsFromStrings(infos[i].Split('#'), a);

                        an.Add(a);
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                an = null;

                return(false);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// 从指定路径中读取内容,设置本实例的各个字段
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public bool Load(string path)
        {
            string[] strs = File_Operate.LoadFromHiddenTextFile(path, Encoding.Default);

            bool res = false;

            if (strs != null)
            {
                string[] ss = strs[0].Split('$');

                string[] s = ss[0].Split('#');

                if (s.Length >= 6)
                {
                    this.author      = s[0];
                    this.contactInfo = s[1];
                    this.copyright   = s[2];
                    this.description = s[3];
                    this.productName = s[4];
                    res = VersionMananger.TryParse(s[5], '*', out this.version);
                }

                for (int i = 1; i < ss.Length; i++)
                {
                    s = ss[i].Split('*');

                    if (s.Length >= 2)
                    {
                        VersionAbstract a = new VersionAbstract();

                        a.Version     = s[0];
                        a.Description = s[1];

                        this.historyInfoCollection.Add(a);
                    }
                }
            }

            return(res);
        }
Пример #4
0
        private void ImportOpMsgs()
        {
            Import.Import import = new Import.Import();
            Import.Filter f      = new Import.Filter();

            import.filters.Clear();

            //f.msg = "账户余额信息(*.mon)";
            //f.ftr = "*.mon";
            //import.AddFilter(f);

            f.msg = "操作日志文件(*.msg)";
            f.ftr = "*.msg";
            import.AddFilter(f);

            import.extension = ".msg";

            import.fileNames.Clear();
            //import.fileNames.Add("m.mon");
            //import.fileNames.Add("mg.msg");

            //import.fileNames.Add("logcat.log");

            //import.destination = loginedUser.UserFolder;

            import.SelectItem();

            string[] dess = import.source.ToArray();
            //string[] srcs = import.source.ToArray();
            string des;

            string[] src;

            if (dess != null && dess.Length > 0)
            {
                des = dess[0];
                src = File_Operate.LoadFromHiddenTextFile(des, Encoding.Default);

                HistoryWin h = new HistoryWin(src);

                h.ShowDialog();
            }
            else
            {
                MessageBox.Show("未能找到匹配项,无法导入!");
            }

            //for (int index = 0; index < dess.Length; index++)
            //{
            //    des = import.destination + "\\" + dess[index];
            //    src = import.GetCorrespondingItem("*.msg");

            //    if (src != null)
            //    {
            //        import.ImportItem(des, src, Import.Import.ImportOptions.APPENDSTART);
            //    }
            //    else
            //    {
            //        MessageBox.Show("未能找到匹配项,无法导入!");
            //        break;//选择文件格式不正确
            //    }
            //}
        }
Пример #5
0
 /// <summary>
 /// 将实例保存在指定的路径,并返回保存结果
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public bool Save(string path)
 {
     return(File_Operate.SaveToTextFileAndHideFile(path, this.ToString(), Encoding.Default));
 }