예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        //Verifie si le gameObject rentré en collision avec la PianoHitBox est une note
        if (collision.gameObject.tag == "Note")
        {
            MNote note = collision.gameObject.GetComponent <MNote>();
            if (note.played != true)
            {
                Renderer rend = note.GetComponent <Renderer>();

                note.midiFilePlayer.MPTK_PlayNote(note.note);
                note.played = true;

                if (gameManager.keyManager.getActiveKey().Contains(note.note.Midi - 20))
                {
                    rend.material.SetColor("_Color", Color.green);
                    note.startHit = true;
                    score         = 300;
                }
                else
                {
                    rend.material.SetColor("_Color", Color.yellow);
                    gameManager.combo.setCombo(0);
                    score = 150;
                }
            }
        }
    }
예제 #2
0
파일: Note.cs 프로젝트: 152056139/gnote
        //笔记列表
        public MySqlDataReader listNote()
        {
            MNote           mnote  = new MNote();
            MySqlDataReader reader = mnote.list_note();

            return(reader);
        }
예제 #3
0
    //Create the Note that needs to be played
    public void NotesToPlay(List <MidiNote> notes)
    {
        foreach (MidiNote note in notes)
        {
            //Check for note in piano's range (88 keys from 21 to 109)
            if (note.Midi > 20 && note.Midi < 110 && sliders != null)
            {
                MNote n = Instantiate(NoteDisplay);
                DontDestroyOnLoad(n);

                //Set the corresponding slider as the parent
                //Set rotation and position to the parent.
                GameObject slider = sliders[(note.Midi - 20)];
                n.transform.SetParent(slider.transform);

                //Trick because if your parent object is non-uniformly scaled (cf: the slider isn't),
                //there is no reliable way to avoid that child objects get scaled or skewed.
//                n.transform.localScale = new Vector3(1.5F, 150F, 0.0125F * ((float)note.Duration / 100F));

                n.transform.rotation = slider.transform.rotation;
                n.transform.position = new Vector3(slider.transform.position.x, slider.transform.position.y,
                                                   slider.transform.position.z + (slider.transform.localScale.z / 2F) + (n.transform.localScale.z / 2));


                n.gameObject.SetActive(true);
                n.midiFilePlayer = midiFilePlayer;
                n.note           = note;
                n.note.Midi      = note.Midi;
                n.gameObject.GetComponent <Renderer>().material = n.NewNote;

                /*  MPTKNote mptkNote = new MPTKNote() { Delay = 0, Drum = false, Duration = 0.2f, Note = 60, Patch = 10, Velocity = 100 };
                 * mptkNote.Play(midiStreamPlayer);*/
            }
        }
    }
예제 #4
0
    void CreateRightMNote(double myTime)
    {
        MNote thisNote = Instantiate <MNote>(mNote, right, Quaternion.identity);

        rightMNoteQ.Enqueue(thisNote);
        thisNote.transform.parent = track.transform;
    }
예제 #5
0
    void CreateMiddleMNote(double myTime)
    {
        MNote thisNote = Instantiate <MNote>(mNote, middle, Quaternion.identity);

        middleMNoteQ.Enqueue(thisNote);
        thisNote.transform.parent = track.transform;
    }
        private void SendNotice(string message, int AD_User_ID, int AD_Org_ID, int Ad_Client_ID)
        {
            MNote note = new MNote(GetCtx(), "VIS_InterOfficeMemo", AD_User_ID, Ad_Client_ID, AD_Org_ID, null);            //  Reference

            note.SetReference(ToString());
            // Text
            note.SetTextMsg(message);
            note.Save();
        }
예제 #7
0
    public void OnCollisionExit(Collision collision)
    {
        if (collision.gameObject.tag == "Note")
        {
            MNote    note = collision.gameObject.GetComponent <MNote>();
            Renderer rend = note.GetComponent <Renderer>();

            Destroy(collision.gameObject);
        }
    }
예제 #8
0
        public void DeleteNoteByID(MNote objNote)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("delete from tb_note where ID=@ID");
            SqlParameter[] param =
            {
                SQLDbHelper.GetParameter("@ID", SqlDbType.Int, 4, "ID", objNote.ID)
            };
            SQLDbHelper.ExecuteSql(sb.ToString(), param);
        }
예제 #9
0
        public DataTable SelectAllNotesByNotePerson(MNote objNote)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select * from tb_note where notePerson =@NotePerson order by noteTime desc");
            SqlParameter[] param =
            {
                SQLDbHelper.GetParameter("@NotePerson", SqlDbType.VarChar, 20, "notePerson", objNote.NotePerson)
            };
            DataTable dt = SQLDbHelper.ExecuteDt(sb.ToString(), param);

            return(dt);
        }
예제 #10
0
        public DataTable SelectNoteByUserName(MNote objNote)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select * from tb_note where notePerson =@NotePerson order by noteTime desc");
            OleDbParameter[] param =
            {
                OleDbHelper.GetParameter("@NotePerson", OleDbType.VarWChar, 20, "notePerson", objNote.NotePerson)
            };
            DataTable dt = OleDbHelper.ExecuteDt(sb.ToString(), param);

            return(dt);
        }
예제 #11
0
파일: Note.cs 프로젝트: 152056139/gnote
 public MySqlDataReader listNote(int notebook_no, string type)
 {
     if (type == "notebook")
     {
         MNote           mnote  = new MNote();
         MySqlDataReader reader = mnote.list_note_notenook(notebook_no);
         return(reader);
     }
     else// if (type == "label")
     {
         MNote           mnote  = new MNote();
         MySqlDataReader reader = mnote.list_note_label(notebook_no);
         return(reader);
     }
 }
예제 #12
0
파일: Note.cs 프로젝트: 152056139/gnote
 public MySqlDataReader listNote(string type)
 {
     if (type == "trash")
     {
         MNote           mnote  = new MNote();
         MySqlDataReader reader = mnote.list_note_trash();
         return(reader);
     }
     else// if (type == "favourite")
     {
         MNote           mnote  = new MNote();
         MySqlDataReader reader = mnote.list_note_favourite();
         return(reader);
     }
 }
예제 #13
0
        }       //	processAlert

        /**
         *  Send Email / Notice
         *  @param AD_User_ID user
         *	@param alert alert
         *	@param message message text
         *	@return true if sent (or previously sent)
         */
        private bool SendInfo(int AD_User_ID, MAlert alert, String message)
        {
            if (m_recipients.Contains(AD_User_ID))
            {
                return(false);
            }
            m_recipients.Add(AD_User_ID);
            //
            bool   success          = false;
            MUser  to               = MUser.Get(alert.GetCtx(), AD_User_ID);
            String NotificationType = to.GetNotificationType();

            if (Util.IsEmpty(NotificationType))
            {
                NotificationType = X_AD_User.NOTIFICATIONTYPE_EMail;
            }
            //	Send Mail
            if (X_AD_User.NOTIFICATIONTYPE_EMail.Equals(NotificationType) ||
                X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType))
            {
                success = m_client.SendEMail(AD_User_ID, alert.GetAlertSubject(), message, null);
                if (!success)
                {
                    log.Warning("EMail failed: " + to);
                    NotificationType = X_AD_User.NOTIFICATIONTYPE_Notice;
                }
            }
            //	Send Note
            if (X_AD_User.NOTIFICATIONTYPE_Notice.Equals(NotificationType) ||
                X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType))
            {
                int   AD_Message_ID = 1040;     //	AlertNotice
                MNote note          = new MNote(alert.GetCtx(), AD_Message_ID, AD_User_ID,
                                                X_AD_Alert.Table_ID, alert.GetAD_Alert_ID(),
                                                alert.GetAlertSubject(), message, null);
                success = note.Save();
            }
            return(success);
        }       //	sendInfo
예제 #14
0
        public bool InsertIntoNote(MNote objNote)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO tb_note (title, noteContent, noteTime, notePerson)VALUES(@Title,@NoteContent,@NoteTime,@NotePerson)");
            SqlParameter[] param =
            {
                SQLDbHelper.GetParameter("@Title",       SqlDbType.VarChar,             50, "title",              objNote.Title),
                SQLDbHelper.GetParameter("@NoteContent", SqlDbType.Text,     "noteContent", objNote.NoteContent),
                SQLDbHelper.GetParameter("@NoteTime",    SqlDbType.DateTime, "noteTime",    objNote.NoteTime),
                SQLDbHelper.GetParameter("@NotePerson",  SqlDbType.VarChar,             20, "notePerson",         objNote.NotePerson)
            };
            bool is_succeed = SQLDbHelper.ExecuteSql(sb.ToString(), param);

            if (is_succeed)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #15
0
    public void OnCollisionStay(Collision collision)
    {
        if (collision.gameObject.tag == "Note")
        {
            MNote    note = collision.gameObject.GetComponent <MNote>();
            Renderer rend = note.GetComponent <Renderer>();

            if (gameManager.keyManager.getActiveKey().Contains(note.note.Midi - 20))
            {
                if (note.startHit == true)
                {
                    gameManager.combo.addCombo(1);
                }
                note.stayHit = true;
            }
            else
            {
                score = 0;
                rend.material.SetColor("_Color", Color.red);
                gameManager.combo.setCombo(0);
            }
        }
    }
예제 #16
0
 public bool InsertIntoNote(MNote objNote)
 {
     return(notes.InsertIntoNote(objNote));
 }
예제 #17
0
        /// <summary>
        /// this method actually send mail, both static and dynamic.... and save info in MailAttachment....
        /// </summary>
        /// <param name="mails"></param>
        /// <param name="AD_User_ID"></param>
        /// <param name="AD_Client_ID"></param>
        /// <param name="AD_Org_ID"></param>
        /// <param name="attachment_ID"></param>
        /// <param name="fileNames"></param>
        /// <param name="fileNameForOpenFormat"></param>
        /// <param name="mailFormat"></param>
        /// <param name="notify"></param>
        /// <returns></returns>
        public string SendMailstart(List <NewMailMessage> mails, int AD_User_ID, int AD_Client_ID, int AD_Org_ID, int attachment_ID, List <string> fileNames, List <string> fileNameForOpenFormat, string mailFormat, bool notify, VAdvantage.Utility.EMail sendmails, List <int> documentID)
        {
            if (ctx == null)
            {
                return(null);
            }


            UserInformation userinfo = new UserInformation();
            SMTPConfig      config   = null;

            config = MailConfigMethod.GetUSmtpConfig(AD_User_ID, ctx);
            // var config = "";
            if (config == null)
            {
                MClient client = new MClient(ctx, AD_Client_ID, null);
                userinfo.Email = client.GetRequestEMail();
            }
            else
            {
                //Add user info to list..
                userinfo.Email = config.Email;
            }

            string[] to = null;
            string[] bc = null;

            string[] cc      = null;
            string   sub     = null;
            string   message = null;
            // int _record_id = 0;
            int _table_id = 0;

            string[] records = null;

            StringBuilder res = new StringBuilder();

            List <NewMailMessage> mail = mails.GetRange(0, mails.Count);

            for (int j = 0; j < mails.Count; j++)
            {
                VAdvantage.Utility.EMail sendmail = new VAdvantage.Utility.EMail(ctx, "", "", "", "", "", "",
                                                                                 true, false);

                to = mails[j].To.Split(';');
                bc = mails[j].Bcc;
                cc = mails[j].Cc.Split(';');
                StringBuilder bcctext = new StringBuilder();
                sub     = mails[j].Subject;
                message = mailFormat;
                if (mails[j].Body != null && mails[j].Body.Count > 0)
                {
                    List <string> keysss = mails[j].Body.Keys.ToList();
                    for (int q = 0; q < keysss.Count; q++)
                    {
                        message = message.Replace(keysss[q], mails[j].Body[keysss[q]]);
                    }
                }

                if (mails[j].Recordids != null)          //in case of static mail
                {
                    records = mails[j].Recordids.Split(',');
                }

                _table_id = Convert.ToInt32(mail[j].TableID);

                VAdvantage.Model.MMailAttachment1 _mAttachment = new VAdvantage.Model.MMailAttachment1(ctx, 0, null);



                if (sub == null || sub.Length == 0 || sub == "")
                {
                    sendmail.SetSubject(".");   //	pass validation
                }
                else
                {
                    sendmail.SetSubject(sub);
                }
                sendmail.SetMessageHTML(message);


                //used to get attachments uploaded by user.....
                if (mail[j].AttachmentFolder != null && mail[j].AttachmentFolder.Trim().Length > 0)
                {
                    string storedAttachmentPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, AttachmentsUploadFolderName + "\\" + mail[j].AttachmentFolder);
                    if (Directory.Exists(storedAttachmentPath))
                    {
                        DirectoryInfo info = new DirectoryInfo(storedAttachmentPath);
                        if (info.GetFiles().Length > 0)
                        {
                            FileInfo[] files = info.GetFiles();

                            for (int a = 0; a < files.Length; a++)
                            {
                                if (fileNames.Contains(files[a].Name))
                                {
                                    FileStream   attachmentStream = File.OpenRead(files[a].FullName);
                                    BinaryReader binary           = new BinaryReader(attachmentStream);
                                    byte[]       buffer           = binary.ReadBytes((int)attachmentStream.Length);
                                    sendmail.AddAttachment(buffer, files[a].Name);
                                    _mAttachment.AddEntry(files[a].Name, buffer);
                                }
                            }
                        }
                    }
                }

                //used to get attachments of saved formats.. Currently not Supporting......
                if (attachment_ID > 0)
                {
                    VAdvantage.Model.MMailAttachment1 _mAttachment1 = new VAdvantage.Model.MMailAttachment1(ctx, attachment_ID, null);
                    if (_mAttachment1.GetEntryCount() > 0)
                    {
                        MAttachmentEntry[] entries = _mAttachment1.GetEntries();
                        for (int m = 0; m < entries.Count(); m++)
                        {
                            //if (fileNameForOpenFormat.Contains(entries[m].GetName()))
                            //{
                            byte[] buffer = entries[m].GetData();
                            sendmail.AddAttachment(buffer, entries[m].GetName());
                            _mAttachment.AddEntry(entries[m].GetName(), buffer);
                            //}
                        }
                    }
                }

                if (documentID != null || documentID.Count > 0)
                {
                    for (int i = 0; i < documentID.Count; i++)
                    {
                        try
                        {
                            int attachmentID = AttachmentID(documentID[i]);
                            //MAttachment objAttachment = new MAttachment(ctx, attachmentID, null, Common.GetPassword(), ctx.GetAD_Client_ID());
                            //objAttachment.Force = false;
                            ////objAttachment.AD_Client_ID = ctx.GetAD_Client_ID();
                            //byte[] fileByte = objAttachment.GetEntryData(0);
                            //string fileName = objAttachment.GetEntryName(0);
                            List <AttachedFileInfo> lstAttchments = GetBytes(ctx, attachmentID, "");
                            sendmail.AddAttachment(lstAttchments[0].FileBytes, lstAttchments[0].FileName);
                        }
                        catch (Exception ex)
                        {
                            res.Append(Msg.GetMsg(ctx, "VADMS_AttachmentNotFound for : " + documentID[i]) + ex.Message);
                        }
                    }
                }



                if (to != null)
                {
                    for (int i = 0; i < to.Length; i++)
                    {
                        if (to[i].ToString() != "")
                        {
                            sendmail.AddTo(to[i].ToString(), "");
                            // totext.Append(to[i].ToString() + ",");
                        }
                    }
                }

                if (bc != null)
                {
                    for (int i = 0; i < bc.Length; i++)
                    {
                        if (bc[i].ToString() != "")
                        {
                            sendmail.AddBcc(bc[i].ToString(), "");
                            bcctext.Append(bc[i].ToString() + ",");
                        }
                    }
                }

                if (cc != null)
                {
                    for (int i = 0; i < cc.Length; i++)
                    {
                        if (cc[i].ToString() != "")
                        {
                            sendmail.AddCc(cc[i].ToString(), "");
                            ///  cctext.Append(cc[i].ToString() + ",");
                        }
                    }
                }

                string res1 = sendmail.Send();

                if (records != null && records.Length > 0)//save entery in MailAttachment......
                {
                    for (int k = 0; k < records.Length; k++)
                    {
                        if (records[k] == null || records[k] == "" || records[k] == "0")
                        {
                            continue;
                        }
                        if (res1 != "OK")
                        {
                            _mAttachment.SetIsMailSent(false);
                        }
                        else
                        {
                            _mAttachment.SetIsMailSent(true);
                        }
                        int AD_Client_Id = ctx.GetAD_Client_ID();
                        int iOrgid       = ctx.GetAD_Org_ID();

                        _mAttachment.SetAD_Client_ID(AD_Client_Id);
                        _mAttachment.SetAD_Org_ID(iOrgid);
                        _mAttachment.SetAD_Table_ID(_table_id);
                        _mAttachment.IsActive();
                        _mAttachment.SetMailAddress(bcctext.ToString());
                        _mAttachment.SetAttachmentType("M");

                        _mAttachment.SetRecord_ID(Convert.ToInt32(records[k]));

                        _mAttachment.SetTextMsg(message);
                        _mAttachment.SetTitle(sub);

                        _mAttachment.SetMailAddressBcc(bcctext.ToString());
                        _mAttachment.SetMailAddress(mails[j].To);
                        _mAttachment.SetMailAddressCc(mails[j].Cc);
                        _mAttachment.SetMailAddressFrom(userinfo.Email);
                        if (_mAttachment.GetEntries().Length > 0)
                        {
                            _mAttachment.SetIsAttachment(true);
                        }
                        else
                        {
                            _mAttachment.SetIsAttachment(false);
                        }
                        _mAttachment.NewRecord();
                        if (_mAttachment.Save())
                        {
                        }
                        else
                        {
                            // log.SaveError(Msg.GetMsg(Env.GetCtx(), "RecordNotSaved"), "");
                        }
                    }
                }

                if (res1 != "OK")           // if mail not sent....
                {
                    if (res1 == "AuthenticationFailed.")
                    {
                        res.Append("AuthenticationFailed");
                        return(res.ToString());
                    }
                    else if (res1 == "ConfigurationIncompleteOrNotFound")
                    {
                        res.Append("ConfigurationIncompleteOrNotFound");
                        return(res.ToString());
                    }
                    else
                    {
                        res.Append(" " + Msg.GetMsg(ctx, "MailNotSentTo") + ": " + mails[j].To + " " + bcctext + " " + mails[j].Cc);
                    }
                }
                else
                {
                    {
                        if (!res.ToString().Contains("MailSent"))
                        {
                            res.Append("MailSent");
                        }
                    }
                }
                bcctext = null;
            }

            if (notify)             //  make an entry in Notice window.....
            {
                MNote note = new MNote(ctx, "SentMailNotice", AD_User_ID,
                                       AD_Client_ID, AD_Org_ID, null);
                //  Reference
                note.SetReference(ToString());  //	Document
                //	Text
                note.SetTextMsg(res.ToString());
                note.Save();
            }

            userinfo = null;
            cc       = null;
            bc       = null;
            to       = null; records = null;
            sub      = null; message = null;
            records  = null;
            return(res.ToString());
        }
예제 #18
0
 public DataTable SelectAllNotesByNotePerson(MNote objNote)
 {
     return(notes.SelectAllNotesByNotePerson(objNote));
 }
        public void SendEmailOrNotification(Ctx ctx, int userID, bool isEmail, bool isNotification, bool isBoth, int tableid, StringBuilder strBuilder, string message, int recordID, string searchKey)
        {
            //******************Temporary Commented******************
            // VAdvantage.Classes.Context ctx = new VAdvantage.Classes.Context(ctxmap);

            string emailID = Convert.ToString(DB.ExecuteScalar("SELECT EMAIL FROM AD_USER WHERE AD_USER_ID=" + userID));

            message += " (" + searchKey + ")";

            try
            {
                if (isEmail)
                {
                    //  log.Log(Level.SEVERE, "SendOnlyEmailToSubscribeUser");
                    //  VAdvantage.Logging.VLogger.Get().Info("SendOnlyEmailToSubscribeUser");
                    // VAdvantage.Utility.EMail objEmail = new VAdvantage.Utility.EMail(ctx, string.Empty, string.Empty, string.Empty, string.Empty, Msg.GetMsg(ctx, "VADMS_FolderSubscriptionNotification"), message,false,true);
                    VAdvantage.Utility.EMail objEmail = new EMail(ctx, string.Empty, string.Empty, string.Empty, string.Empty, "AttachEmailNotification", message, false, true);
                    if (emailID.IndexOf(";") > -1)
                    {
                        string[] eIDS = emailID.Split(';');

                        for (int k = 0; k < eIDS.Length; k++)
                        {
                            objEmail.AddTo(eIDS[k], "");
                        }
                    }
                    else
                    {
                        objEmail.AddTo(emailID, "");
                    }
                    objEmail.SetMessageText(message);
                    objEmail.SetSubject("AttachEmailNotification");
                    string resu = objEmail.Send();
                }
                else if (isNotification)
                {
                    //  log.Log(Level.SEVERE, "SendOnlyNoticeToSubscribeUser");

                    MNote note = new MNote(ctx, 0, null);
                    note.SetAD_User_ID(userID);
                    // changes done by Bharat on 22 May 2018 to set Organization to * on Notification as discussed with Mukesh Sir.
                    //note.SetClientOrg(ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID());
                    note.SetClientOrg(ctx.GetAD_Client_ID(), 0);
                    note.SetTextMsg(message);
                    note.SetDescription(Msg.GetMsg(ctx, "AttachEmailNotification"));
                    note.SetRecord(tableid, recordID); // point to this
                    note.SetAD_Message_ID(859);        //Workflow
                    if (!note.Save())
                    {
                        // CreateMessage(strBuilder, Convert.ToString(recordID));
                    }
                }
                else if (isBoth)
                {
                    // log.Log(Level.SEVERE, "SendOnlyEmailAndNoticeToSubscribeUser");

                    VAdvantage.Utility.EMail objEmail = new VAdvantage.Utility.EMail(ctx, string.Empty, string.Empty, string.Empty, string.Empty, Msg.GetMsg(ctx, "AttachEmailNotification"), message, false, true);
                    // VAdvantage.Utility.EMail objEmail = new EMail(ctx, string.Empty, string.Empty, emailID, string.Empty, Msg.GetMsg(ctx, "VADMS_FolderSubscriptionNotification"), message, false, true);
                    if (emailID.IndexOf(";") > -1)
                    {
                        string[] eIDS = emailID.Split(';');

                        for (int k = 0; k < eIDS.Length; k++)
                        {
                            objEmail.AddTo(eIDS[k], "");
                        }
                    }
                    else
                    {
                        objEmail.AddTo(emailID, "");
                    }
                    objEmail.SetMessageText(message);
                    objEmail.SetSubject(Msg.GetMsg(ctx, "AttachEmailNotification"));
                    objEmail.Send();
                    MNote note = new MNote(ctx, 0, null);
                    note.SetAD_User_ID(userID);
                    // changes done by Bharat on 22 May 2018 to set Organization to * on Notification as discussed with Mukesh Sir.
                    //note.SetClientOrg(ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID());
                    note.SetClientOrg(ctx.GetAD_Client_ID(), 0);
                    note.SetTextMsg(message);
                    note.SetDescription(Msg.GetMsg(ctx, "AttachEmailNotification"));
                    note.SetRecord(tableid, recordID); // point to this
                    note.SetAD_Message_ID(859);        //Workflow
                    if (!note.Save())
                    {
                        // CreateMessage(strBuilder, Convert.ToString(recordID));
                    }
                }
            }
            catch (Exception ex)
            {
                VAdvantage.Logging.VLogger.Get().Info(ex.Message);
                log.Severe("SendEmailOrNotification Error : " + ex.Message);
            }

            //***************************************
        }
예제 #20
0
 public void DeleteNoteByID(MNote objNote)
 {
     notes.DeleteNoteByID(objNote);
 }
예제 #21
0
        /// <summary>
        /// Send notice to users.
        /// </summary>
        /// <param name="list"> List of columns changed.</param>
        protected void SendNotices(List <String> list)
        {
            bool          isEmailSent = false;
            StringBuilder finalMsg    = new StringBuilder();

            finalMsg.Append(Msg.Translate(GetCtx(), "R_Request_ID") + ": " + _req.GetDocumentNo()).Append("\n").Append(Msg.Translate(GetCtx(), "R_NotificSent"));
            //	Subject
            if (mailText_ID == 0)
            {
                subject = Msg.Translate(GetCtx(), "R_Request_ID")
                          + " " + Msg.GetMsg(GetCtx(), "Updated", true) + ": " + _req.GetDocumentNo() + " (●" + MTable.Get_Table_ID(Table_Name) + "-" + _req.GetR_Request_ID() + "●) " + Msg.GetMsg(GetCtx(), "DoNotChange");
            }
            //	Message

            //		UpdatedBy: Joe
            int   UpdatedBy = GetCtx().GetAD_User_ID();
            MUser from      = MUser.Get(GetCtx(), UpdatedBy);

            FileInfo pdf = CreatePDF();

            log.Finer(message.ToString());

            //	Prepare sending Notice/Mail
            MClient client = MClient.Get(GetCtx(), GetAD_Client_ID());

            //	ReSet from if external
            if (from.GetEMailUser() == null || from.GetEMailUserPW() == null)
            {
                from = null;
            }
            _success = 0;
            _failure = 0;
            _notices = 0;

            /** List of users - aviod duplicates	*/
            List <int> userList = new List <int>();
            String     sql      = "SELECT u.AD_User_ID, u.NotificationType, u.EMail, u.Name, MAX(r.AD_Role_ID) "
                                  + "FROM RV_RequestUpdates_Only ru"
                                  + " INNER JOIN AD_User u ON (ru.AD_User_ID=u.AD_User_ID)"
                                  + " LEFT OUTER JOIN AD_User_Roles r ON (u.AD_User_ID=r.AD_User_ID) "
                                  + "WHERE ru.R_Request_ID= " + _req.GetR_Request_ID()
                                  + " GROUP BY u.AD_User_ID, u.NotificationType, u.EMail, u.Name";

            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                while (idr.Read())
                {
                    int    AD_User_ID       = Utility.Util.GetValueOfInt(idr[0]);
                    String NotificationType = Util.GetValueOfString(idr[1]); //idr.GetString(1);
                    if (NotificationType == null)
                    {
                        NotificationType = X_AD_User.NOTIFICATIONTYPE_EMail;
                    }
                    String email = Util.GetValueOfString(idr[2]);// idr.GetString(2);

                    if (String.IsNullOrEmpty(email))
                    {
                        continue;
                    }

                    String Name = Util.GetValueOfString(idr[3]);//idr.GetString(3);
                    //	Role
                    int AD_Role_ID = Utility.Util.GetValueOfInt(idr[4]);
                    if (idr == null)
                    {
                        AD_Role_ID = -1;
                    }

                    //	Don't send mail to oneself
                    //		if (AD_User_ID == UpdatedBy)
                    //			continue;

                    //	No confidential to externals
                    if (AD_Role_ID == -1 &&
                        (_req.GetConfidentialTypeEntry().Equals(X_R_Request.CONFIDENTIALTYPE_Internal) ||
                         _req.GetConfidentialTypeEntry().Equals(X_R_Request.CONFIDENTIALTYPE_PrivateInformation)))
                    {
                        continue;
                    }

                    if (X_AD_User.NOTIFICATIONTYPE_None.Equals(NotificationType))
                    {
                        log.Config("Opt out: " + Name);
                        continue;
                    }
                    if ((X_AD_User.NOTIFICATIONTYPE_EMail.Equals(NotificationType) ||
                         X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType)) &&
                        (email == null || email.Length == 0))
                    {
                        if (AD_Role_ID >= 0)
                        {
                            NotificationType = X_AD_User.NOTIFICATIONTYPE_Notice;
                        }
                        else
                        {
                            log.Config("No EMail: " + Name);
                            continue;
                        }
                    }
                    if (X_AD_User.NOTIFICATIONTYPE_Notice.Equals(NotificationType) &&
                        AD_Role_ID >= 0)
                    {
                        log.Config("No internal User: "******"\n").Append(user.GetName()).Append(".");
                    isEmailSent = true;
                }

                idr.Close();
                // Notification For Role
                List <int> _users = SendRoleNotice();
                for (int i = 0; i < _users.Count; i++)
                {
                    MUser  user             = new MUser(GetCtx(), _users[i], null);
                    int    AD_User_ID       = user.GetAD_User_ID();
                    String NotificationType = user.GetNotificationType(); //idr.GetString(1);
                    if (NotificationType == null)
                    {
                        NotificationType = X_AD_User.NOTIFICATIONTYPE_EMail;
                    }
                    String email = user.GetEMail();// idr.GetString(2);

                    if (String.IsNullOrEmpty(email))
                    {
                        continue;
                    }

                    String Name = user.GetName(); //idr.GetString(3);
                                                  //	Role

                    if (X_AD_User.NOTIFICATIONTYPE_None.Equals(NotificationType))
                    {
                        log.Config("Opt out: " + Name);
                        continue;
                    }

                    //
                    SendNoticeNow(_users[i], NotificationType,
                                  client, from, subject, message.ToString(), pdf);
                    finalMsg.Append("\n").Append(user.GetName()).Append(".");
                    isEmailSent = true;
                }

                if (!isEmailSent)
                {
                    finalMsg.Clear();
                    finalMsg.Append(Msg.Translate(GetCtx(), "R_Request_ID") + ": " + _req.GetDocumentNo()).Append("\n").Append(Msg.Translate(GetCtx(), "R_NoNotificationSent"));
                }

                int   AD_Message_ID = 834;
                MNote note          = new MNote(GetCtx(), AD_Message_ID, GetCtx().GetAD_User_ID(),
                                                X_R_Request.Table_ID, _req.GetR_Request_ID(),
                                                subject, finalMsg.ToString(), Get_TrxName());
                if (note.Save())
                {
                    log.Log(Level.INFO, "ProcessFinished", "");
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }


            //	New Sales Rep (may happen if sent from beforeSave
            if (!userList.Contains(_req.GetSalesRep_ID()))
            {
                SendNoticeNow(_req.GetSalesRep_ID(), null,
                              client, from, subject, message.ToString(), pdf);
            }
        }
예제 #22
0
        /// <summary>
        /// Send notice to user
        /// </summary>
        /// <param name="AD_User_ID">Id of user</param>
        /// <param name="NotificationType"> Notification type</param>
        /// <param name="client"> Tenant object</param>
        /// <param name="from"> From user notice</param>
        /// <param name="subject">Subject of notice.</param>
        /// <param name="message">Message to be sent to user</param>
        /// <param name="pdf"> Attachment</param>
        private void SendNoticeNow(int AD_User_ID, String NotificationType,
                                   MClient client, MUser from, String subject, String message, FileInfo pdf)
        {
            MUser to = MUser.Get(GetCtx(), AD_User_ID);

            if (NotificationType == null)
            {
                NotificationType = to.GetNotificationType();
            }
            //	Send Mail
            if (X_AD_User.NOTIFICATIONTYPE_EMail.Equals(NotificationType) ||
                X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType))
            {
                VAdvantage.Model.MMailAttachment1 _mAttachment = new VAdvantage.Model.MMailAttachment1(GetCtx(), 0, null);
                _mAttachment.SetAD_Client_ID(GetCtx().GetAD_Client_ID());
                _mAttachment.SetAD_Org_ID(GetCtx().GetAD_Org_ID());
                _mAttachment.SetAD_Table_ID(MTable.Get_Table_ID(Table_Name));
                _mAttachment.IsActive();
                _mAttachment.SetMailAddress("");
                _mAttachment.SetAttachmentType("M");
                _mAttachment.SetRecord_ID(_req.GetR_Request_ID());
                _mAttachment.SetTextMsg(message);
                _mAttachment.SetTitle(subject);
                _mAttachment.SetMailAddress(to.GetEMail());

                if (from != null && !string.IsNullOrEmpty(from.GetEMail()))
                {
                    _mAttachment.SetMailAddressFrom(from.GetEMail());
                }
                else
                {
                    _mAttachment.SetMailAddressFrom(client.GetRequestEMail());
                }

                _mAttachment.NewRecord();

                if (client.SendEMail(from, to, subject, message.ToString(), pdf))
                {
                    _success++;
                    if (_emailTo.Length > 0)
                    {
                        _emailTo.Append(", ");
                    }
                    _emailTo.Append(to.GetEMail());
                    _mAttachment.SetIsMailSent(true);
                }
                else
                {
                    log.Warning("Failed: " + to);
                    _failure++;
                    NotificationType = X_AD_User.NOTIFICATIONTYPE_Notice;
                    _mAttachment.SetIsMailSent(false);
                }

                _mAttachment.Save();
            }

            //	Send Note
            if (X_AD_User.NOTIFICATIONTYPE_Notice.Equals(NotificationType) ||
                X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType))
            {
                int   AD_Message_ID = 834;
                MNote note          = new MNote(GetCtx(), AD_Message_ID, AD_User_ID,
                                                X_R_Request.Table_ID, _req.GetR_Request_ID(),
                                                subject, message.ToString(), Get_TrxName());
                if (note.Save())
                {
                    _notices++;
                }
            }
        }
예제 #23
0
 public DataTable SelectNoteByUserName(MNote objNote)
 {
     return(notes.SelectNoteByUserName(objNote));
 }