Esempio n. 1
0
 /// <summary>
 /// 打开专案文件
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static OpenPlot Open(string pFileName)
 {
     try
     {
         using (FileStream sFileStream = new FileStream(pFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             byte[] sData = new byte[sFileStream.Length];
             sFileStream.Read(sData, 0, sData.Length);
             if (sData[0] == 2)
             {
                 byte[] sDat = new byte[sData.Length - 1];
                 Array.Copy(sData, 1, sDat, 0, sDat.Length);
                 sData = SecurityProvider.ZipDecrypt(sDat);  //解密
             }
             MemoryStream  sReader        = new MemoryStream(sData);
             XmlSerializer sXmlSerializer = new XmlSerializer(typeof(OpenPlot));
             OpenPlot      sPlot          = (OpenPlot)sXmlSerializer.Deserialize(sReader);
             sPlot.FileName = pFileName;
             return(sPlot);
         }
     }
     catch (Exception E)
     {
         return(null);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 创建新的专案
        /// </summary>
        /// <param name="pNo"></param>
        /// <returns></returns>
        public static OpenPlot CreatePlot()
        {
            OpenPlot sPlot = new OpenPlot();

            sPlot.Key        = new Int128(Guid.NewGuid().ToByteArray());
            sPlot.CreateTime = DateTime.Now;
            return(sPlot);
        }
Esempio n. 3
0
 /// <summary>
 /// 将专案添加到专案缓冲池子
 /// </summary>
 /// <param name="pPlot"></param>
 public static void AddPlot2Pool(OpenPlot pPlot)
 {
     lock (mLocker)
     {
         if (pPlot.Key.IsZero) { pPlot.Key = new Int128(Guid.NewGuid().ToByteArray()); }
         OpenPlot sTmpPlot;
         if (mPlotPool.TryGetValue(pPlot.Key, out sTmpPlot) == false)
         {
             pPlot.Prepare();
             mPlotPool[pPlot.Key] = pPlot;
             PlotList.Add(pPlot);
         }
         else if (sTmpPlot != pPlot) //重Key对象
         {
             pPlot.Key = new Int128(Guid.NewGuid().ToByteArray());
             pPlot.Prepare();
             mPlotPool[pPlot.Key] = pPlot;
             PlotList.Add(pPlot);
         }
     }
 }
Esempio n. 4
0
 public static bool SaveAs(string pFileName, OpenPlot pPlot)
 {
     try
     {
         using (FileStream sFileStream = new FileStream(pFileName, FileMode.Create, FileAccess.Write, FileShare.Read))
         {
             MemoryStream  sMemoryStream  = new MemoryStream();
             StreamWriter  sStream        = new StreamWriter(sMemoryStream, Encoding.UTF8);
             XmlSerializer sXmlSerializer = new XmlSerializer(typeof(OpenPlot));
             sXmlSerializer.Serialize(sStream, pPlot);
             byte[] sData = SecurityProvider.ZipEncrypt(sMemoryStream.ToArray());
             sFileStream.WriteByte(2);
             sFileStream.Write(sData, 0, sData.Length);
             pPlot.FileName = pFileName.ToLower();
         }
         return(true);
     }
     catch (Exception E)
     {
         //MessageBox.Show(E.Message);
         return(false);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 将专案添加到专案缓冲池子
 /// </summary>
 /// <param name="pPlot"></param>
 public static void AddPlot2Pool(OpenPlot pPlot)
 {
     lock (mLocker)
     {
         if (pPlot.Key.IsZero)
         {
             pPlot.Key = new Int128(Guid.NewGuid().ToByteArray());
         }
         OpenPlot sTmpPlot;
         if (mPlotPool.TryGetValue(pPlot.Key, out sTmpPlot) == false)
         {
             pPlot.Prepare();
             mPlotPool[pPlot.Key] = pPlot;
             PlotList.Add(pPlot);
         }
         else if (sTmpPlot != pPlot) //重Key对象
         {
             pPlot.Key = new Int128(Guid.NewGuid().ToByteArray());
             pPlot.Prepare();
             mPlotPool[pPlot.Key] = pPlot;
             PlotList.Add(pPlot);
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 创建新的专案
 /// </summary>
 /// <param name="pNo"></param>
 /// <returns></returns>
 public static OpenPlot CreatePlot()
 {
     OpenPlot sPlot = new OpenPlot();
     sPlot.Key = new Int128(Guid.NewGuid().ToByteArray());
     sPlot.CreateTime = DateTime.Now;
     return sPlot;
 }
Esempio n. 7
0
 public static bool SaveAs(string pFileName, OpenPlot pPlot)
 {
     try
     {
         using (FileStream sFileStream = new FileStream(pFileName, FileMode.Create, FileAccess.Write, FileShare.Read))
         {
             MemoryStream sMemoryStream = new MemoryStream();
             StreamWriter sStream = new StreamWriter(sMemoryStream, Encoding.UTF8);
             XmlSerializer sXmlSerializer = new XmlSerializer(typeof(OpenPlot));
             sXmlSerializer.Serialize(sStream, pPlot);
             byte[] sData = SecurityProvider.ZipEncrypt(sMemoryStream.ToArray());
             sFileStream.WriteByte(2);
             sFileStream.Write(sData, 0, sData.Length);
             pPlot.FileName = pFileName.ToLower();
         }
         return true;
     }
     catch (Exception E)
     {
         //MessageBox.Show(E.Message);
         return false;
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 保存专案
 /// </summary>
 /// <returns></returns>
 public static bool Save(OpenPlot pPlot)
 {
     return SaveAs(pPlot.FileName, pPlot);
 }
Esempio n. 9
0
 public FrmPlotInfo(OpenPlot pPlot, bool pNew)
 {
     InitializeComponent();
     mPlot = pPlot;
     mIsNew = pNew;
 }
Esempio n. 10
0
 /// <summary>
 /// 保存专案
 /// </summary>
 /// <returns></returns>
 public static bool Save(OpenPlot pPlot)
 {
     return(SaveAs(pPlot.FileName, pPlot));
 }