Пример #1
0
        public bool Save(ISrcUrl isu, string grouptag, byte[] data)
        {
            string fileName = fileName = getDate() + "_" + getTime() + "." + isu.IAW.DAT.ToString().ToLower();
            string filePath = basePath + isu.IAW.TAG + "\\" + isu.TAG + "\\";

            if (!String.IsNullOrEmpty(grouptag))
            {
                filePath = filePath + grouptag + "\\";
            }

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            return(FileReadSaveUtil.Save(data, filePath + fileName));
        }
Пример #2
0
        private void Email(object obj)
        {
            try
            {
                string mailSubject = "";
                string mailBody    = "";

                if (obj == null)
                {
                    mailSubject = "AQISet日志";
                    mailBody    = FileReadSaveUtil.ReadText(this.getLogFile());
                }
                else if (obj is IStatus)
                {
                    IStatus s = (obj as IStatus);
                    mailSubject = "AQISet状态_" + s.Name;
                    mailBody    = s.GetInfo();
                }

                EmailHelper emh = new EmailHelper();
                emh.mailFrom    = AqiManage.Setting["AqiRemind.EmailFrom"];                //发送人的邮箱地址
                emh.mailPwd     = AqiManage.Setting["AqiRemind.EmailPwd"];                 //发送人邮箱的密码
                emh.mailSubject = mailSubject;                                             //邮件主题;
                emh.mailBody    = mailBody;                                                //邮件内容;
                emh.isbodyHtml  = true;                                                    //是否是HTML
                emh.host        = AqiManage.Setting["AqiRemind.EmailHost"];                //服务器
                emh.mailToArray = new string[] { AqiManage.Setting["AqiRemind.EmailTo"] }; //接收者邮件集合
                if (emh.Send())
                {
                    AqiManage.Remind.Log_Error("Email发送成功", tag);
                }
                else
                {
                    AqiManage.Remind.Log_Error("Email发送失败", tag);
                }
            }
            catch (System.Exception ex)
            {
                Beep();
                AqiManage.Remind.Log_Error("Email生成失败", ex, tag);
            }
        }
Пример #3
0
        public bool Save(ISrcUrl isu, AqiParam param, byte[] data)
        {
            try
            {
                string str;
                if (data == null)
                {
                    data = new byte[0];
                    if (!this.saveEmpty)
                    {
                        return(false);
                    }
                }
                //目录
                string path = this.basePath + isu.IAW.Tag + @"\" + isu.Tag + @"\";
                //分组
                string grouptag = "";
                //文件名
                string nameFile = this.getDate() + "_" + this.getTime();

                if (param != null)
                {
                    grouptag = param.Name;
                    if (param.Unique)
                    {
                        nameFile = grouptag;
                    }
                    else
                    {
                        path = path + grouptag + @"\";
                    }
                }

                //扩展名
                string nameExtension = "." + isu.IAW.DAT.ToString().ToLower();
                if (isu is IDataType)
                {
                    IDataType idt = (isu as IDataType);
                    if (idt.DAT == AqiConstant.DataType.NONE)
                    {
                        nameExtension = "";
                    }
                    else
                    {
                        nameExtension = "." + idt.DAT.ToString().ToLower();
                    }
                }
                str = nameFile + nameExtension;

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                AqiManage.Remind.Log_Debug("保存路径为" + path + str, new string[] { this.Name });
                return(FileReadSaveUtil.Save(data, path + str));
            }
            catch (Exception exception)
            {
                AqiManage.Remind.Log_Error("保存失败", exception, new string[] { this.Name });
                return(false);
            }
        }