Exemplo n.º 1
0
        private bool WriteRomensEnt(string MedCode, string EntCode, string EntName, string YXQFlag, string YXQ)
        {
            try
            {
                string enString = "[医保类型列表],[企业365账号],[企业365名称],[有效期标志],[有效期]";
                enString = enString.Replace("[企业365账号]", EntCode);
                enString = enString.Replace("[企业365名称]", EntName);
                enString = enString.Replace("[医保类型列表]", MedCode.Replace(",", "@#"));
                enString = enString.Replace("[有效期标志]", YXQFlag);
                enString = enString.Replace("[有效期]", YXQ);
                string cryptString = "";
                if (DESCrypt.GetInstance().Init(EntKey) == false)
                {
                    FhJson = "{\"errmsg\":\"" + DESCrypt.GetInstance().ErrorMsg + "\",\"errcode\":1}";
                    return(false);
                }
                if (DESCrypt.GetInstance().EncryptData(enString, ref cryptString) == false)
                {
                    FhJson = "{\"errmsg\":\"" + DESCrypt.GetInstance().ErrorMsg + "\",\"errcode\":1}";
                    return(false);
                }
                FileName = "";
                if (this.DirPathFlag.Equals("0"))
                {
                    SaveFileDialog dlg = new SaveFileDialog();
                    dlg.InitialDirectory = Environment.SpecialFolder.MyComputer.ToString();
                    dlg.Filter           = "RomensEntYBK(*.lic)|*.lic";
                    dlg.FilterIndex      = 1;
                    if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return(false);
                    }
                    FileName = dlg.FileName;
                }
                else
                {
                    FileName = this.DirPath;
                    if (FileName.EndsWith(@"\") == false)
                    {
                        FileName = string.Concat(FileName, @"\");
                    }
                    ssssname = string.Concat(EntCode + "_" + EntName + "_" + "RomensEntYBK.lic");
                    FileName = string.Concat(FileName, EntCode + "_" + EntName + "_" + "RomensEntYBK.lic");
                }

                using (StreamWriter swStream = new StreamWriter(FileName, false, Encoding.UTF8))
                {
                    swStream.Write(cryptString);
                    swStream.Flush();
                    swStream.Close();
                }
                FhJson = "{\"errmsg\":\"写入文件成功\",\"errcode\":0}";
                return(true);
            }
            catch (Exception EXMessage)
            {
                FhJson = "{\"errmsg\":\"写入文件失败:" + EXMessage.Message + "\",\"errcode\":1}";
                return(false);
            }
        }
Exemplo n.º 2
0
 public static DESCrypt GetInstance()
 {
     if (uniqueIns == null)
     {
         lock (lockRes)
         {
             uniqueIns = new DESCrypt();
             return(uniqueIns);
         }
     }
     else
     {
         return(uniqueIns);
     }
 }