//ATTENZIONE!!! Attualmente si possono inserire solo gruppi e uffici interni a organizzazioni
 public void Insert(RubricaEntita r)
 {
     using (RubrEntitaSQLDb dao = new RubrEntitaSQLDb())
     {
         dao.Insert(r);
     }
 }
 public void Update(RubricaEntita r)
 {
     using (RubrEntitaSQLDb dao = new RubrEntitaSQLDb())
     {
         dao.Update(r);
     }
 }
Beispiel #3
0
        public List <RubricaEntita> LoadEntitaByName(IList <EntitaType> tEnt, string name)
        {
            List <RubricaEntita> lEnt = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    var query = dbcontext.RUBR_ENTITA.Where(x => x.RAGIONE_SOCIALE.ToUpper().Contains(name.ToUpper()) || x.COGNOME.ToUpper().Contains(name.ToUpper()) || x.NOME.ToUpper().Contains(name.ToUpper()));
                    if (tEnt != null && tEnt.Count != 0 && !tEnt.Contains(EntitaType.ALL))
                    {
                        string[] wherees = tEnt.Select(e => e.ToString()).ToArray();
                        query.Where(x => wherees.Contains(x.REFERRAL_TYPE));
                    }
                    var entities = query.ToList();
                    foreach (var e in entities)
                    {
                        RubricaEntita ent = AutoMapperConfiguration.MapToRubrEntita(e);
                        lEnt.Add(ent);
                    }
                }
            }
            catch
            {
                throw;
            }

            return(lEnt);
        }
        internal static RUBR_ENTITA MapToRubrEntita(RubricaEntita e, bool isInsert)
        {
            RUBR_ENTITA r = new RUBR_ENTITA();

            r.AFF_IPA     = e.AffIPA;
            r.COD_FIS     = e.CodiceFiscale;
            r.COGNOME     = e.Cognome;
            r.DISAMB_POST = e.DisambPost;
            r.DISAMB_PRE  = e.DisambPre;
            r.FLG_IPA     = e.IsIPA.ToString();
            r.NOTE        = e.Note;
            r.NOME        = (string.IsNullOrEmpty(e.Nome)) ? e.Ufficio : e.Nome;
            r.P_IVA       = e.PartitaIVA;
            r.SITO_WEB    = e.SitoWeb;
            if (!isInsert)
            {
                r.ID_REFERRAL = (decimal)e.IdReferral;
            }
            else
            {
                r.ID_PADRE        = e.IdPadre;
                r.REFERRAL_TYPE   = e.ReferralType.ToString();
                r.RAGIONE_SOCIALE = e.RagioneSociale;
                r.REF_ID_ADDRESS  = e.RefIdAddress;
                r.FLG_IPA         = Convert.ToInt16(e.IsIPA).ToString();
                r.UFFICIO         = e.Ufficio;
                r.IPA_DN          = e.IPAdn;
                r.IPA_ID          = e.IPAId;
                r.DISAMB_PRE      = e.DisambPre;
                r.DISAMB_POST     = e.DisambPost;
                r.REF_ORG         = e.RefOrg;
                r.AFF_IPA         = e.AffIPA;
            }
            return(r);
        }
Beispiel #5
0
        public List <RubricaEntita> LoadEntitaByPartitaIVA(string partitaIVA)
        {
            // V_Rubr_Contatti_Obj obj = new V_Rubr_Contatti_Obj(this.context);
            // List<RubricaEntita> re = obj.GetEntitaByPartitaIVA(partitaIVA).Cast<RubricaEntita>().ToList(); ;
            List <RubricaEntita> lEnt = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    var query    = dbcontext.RUBR_ENTITA.Where(x => x.P_IVA.ToUpper().Contains(partitaIVA.ToUpper()));
                    var entities = query.ToList();
                    foreach (var e in entities)
                    {
                        RubricaEntita ent = AutoMapperConfiguration.MapToRubrEntita(e);
                        lEnt.Add(ent);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(lEnt);
        }
        protected void btnTreeNode_Click(object sender, EventArgs e)
        {
            long id = -1;
            Item item;

            try
            {
                item = Newtonsoft.Json.JsonConvert.DeserializeObject <Item>(hfSelectedTreeNode.Value);
            }
            catch
            {
                return;
            }
            string nodeId = item.Id;

            if (nodeId.Contains('@'))
            {
                nodeId = nodeId.Substring(nodeId.IndexOf('@') + 1);
            }

            if (long.TryParse(nodeId, out id))
            {
                pnlDettagli.Visible = true;
                RubricaEntitaService rus = new RubricaEntitaService();
                RubricaEntita        r   = rus.GetRubricaEntitaCompleteById(id);
                UCEntiViewer.EntFormViewDataSource = r;
                pnlDownPage.Update();
            }
        }
Beispiel #7
0
 //ATTENZIONE!!! Attualmente si possono inserire solo gruppi e uffici interni a organizzazioni
 public void Insert(RubricaEntita r)
 {
     using (IRubricaEntitaDao dao = getDaoContext().DaoImpl.RubricaEntitaDao)
     {
         dao.Insert(r);
     }
 }
Beispiel #8
0
 public void Update(RubricaEntita r)
 {
     using (IRubricaEntitaDao dao = getDaoContext().DaoImpl.RubricaEntitaDao)
     {
         dao.Update(r);
     }
 }
Beispiel #9
0
        private OracleParameter[] MapEntityToParams(RubricaEntita e, bool isInsert)
        {
            List <OracleParameter> op = new List <OracleParameter>();

            op.Add(new OracleParameter("p_UFF", e.Ufficio));
            op.Add(new OracleParameter("p_SITO", e.SitoWeb));
            op.Add(new OracleParameter("p_COG", e.Cognome));
            op.Add(new OracleParameter("p_NOME", e.Nome));
            op.Add(new OracleParameter("p_NOTE", e.Note));
            op.Add(new OracleParameter("p_COD_FIS", e.CodiceFiscale));
            op.Add(new OracleParameter("p_P_IVA", e.PartitaIVA));

            if (!isInsert)
            {
                op.Add(new OracleParameter("p_ID", e.IdReferral));
            }
            else
            {
                op.Add(new OracleParameter("p_ID_PADRE", e.IdPadre));
                op.Add(new OracleParameter("p_REF_TYPE", e.ReferralType.ToString()));
                op.Add(new OracleParameter("p_RAG_SOC", e.RagioneSociale));
                op.Add(new OracleParameter("p_REF_ID_ADD", e.RefIdAddress));
                op.Add(new OracleParameter("p_FLG_IPA", Convert.ToInt16(e.IsIPA).ToString()));
                op.Add(new OracleParameter("p_IPA_DN", e.IPAdn));
                op.Add(new OracleParameter("p_IPA_ID", e.IPAId));
                op.Add(new OracleParameter("p_DIS_PRE", e.DisambPre));
                op.Add(new OracleParameter("p_DIS_POST", e.DisambPost));
                op.Add(new OracleParameter("p_REF_ORG", e.RefOrg));
                op.Add(new OracleParameter("p_AFF_IPA", e.AffIPA));
                op.Add(new OracleParameter("p_ID", OracleDbType.Decimal, ParameterDirection.Output));
            }
            return(op.ToArray());
        }
Beispiel #10
0
        //funzione per visualizzare i dati dell'ente ricercato
        private void GetGridResult()
        {
            CurrentFvState = FormViewMode.Edit;

            //metto l'oggetto in sessione
            if (EntFormViewDataSource == null)
            {
                return;
            }

            if (EntFormViewDataSource.RefOrg.HasValue)
            {
                RubricaEntitaService S       = new RubricaEntitaService();
                RubricaEntita        DataOrg = S.GetRubricaEntitaCompleteById(EntFormViewDataSource.RefOrg.Value);
                OrgDen = DataOrg.RagioneSociale;
            }
            else
            {
                OrgDen = null;
            }

            EntFormView.DataBind();
            FormView1.Visible = true;

            if (EntFormViewDataSource.Contatti == null)
            {
                List <RubricaContatti> lrc = new List <RubricaContatti>();
                EntFormViewDataSource.Contatti = lrc;
            }

            switch (EntFormViewDataSource.Contatti.Count)
            {
            case 0:
                gvContacts.Visible       = true;
                ContactsFormView.Visible = true;

                gvContacts.DataBind();

                ContactsFormView.DataBind();
                break;
            //case 1:
            //hfCurrentID = EntFormViewDataSource.Contatti[0].IdContact;
            //DataContactView(EntFormViewDataSource.Contatti[0].IdContact);

            //    gvContacts.Visible = true;
            //    ContactsFormView.Visible = true;
            //    break;
            default:
                gvContacts.Visible       = true;
                ContactsFormView.Visible = false;

                OnContactsPagerIndexChanged("", 0);

                if (EntFormViewDataSource.Contatti.Count <= PagerSize)
                {
                    gvContacts.BottomPagerRow.Visible = false;
                }
                break;
            }
        }
        internal static RubricaEntita MapToRubricaEntita(IDataRecord dr)
        {
            RubricaEntita re = new RubricaEntita();

            re.IdReferral     = (Nullable <Int64>)dr.GetValue("ID_REFERRAL");
            re.IdPadre        = (Nullable <Int64>)dr.GetValue("ID_PADRE");
            re.ReferralType   = (EntitaType)Enum.Parse(typeof(EntitaType), dr.GetString("REFERRAL_TYPE"));
            re.Cognome        = dr.GetString("COGNOME");
            re.Nome           = dr.GetString("NOME");
            re.CodiceFiscale  = dr.GetString("COD_FIS");
            re.PartitaIVA     = dr.GetString("P_IVA");
            re.RagioneSociale = dr.GetString("RAGIONE_SOCIALE");
            re.Ufficio        = dr.GetString("UFFICIO");
            re.Note           = dr.GetString("NOTE");
            re.RefIdAddress   = (Nullable <Int64>)dr.GetValue("REF_ID_ADDRESS");
            re.IsIPA          = (dr.IsDBNull("FLG_IPA") ? false : Convert.ToBoolean(int.Parse(dr.GetString("FLG_IPA"))));
            re.IPAdn          = dr.GetString("IPA_DN");
            re.IPAId          = (string)dr.GetValue("IPA_ID");
            re.DisambPre      = dr.GetString("DISAMB_PRE");
            re.DisambPost     = dr.GetString("DISAMB_POST");
            re.RefOrg         = (Nullable <Int64>)dr.GetValue("REF_ORG");
            re.SitoWeb        = dr.GetString("SITO_WEB");
            re.AffIPA         = (Nullable <Int16>)dr.GetValue("AFF_IPA");
            return(re);
        }
Beispiel #12
0
        protected void odsEntita_Updating(object sender, ObjectDataSourceMethodEventArgs e)
        {
            RubricaEntita rubEnt = e.InputParameters[0] as RubricaEntita;
            //metodo per l'update
            RubricaEntitaService s = new RubricaEntitaService();

            s.Update(rubEnt);
            EntFormViewDataSource = s.GetRubricaEntitaCompleteById(rubEnt.IdReferral.Value);
            ((BasePage)this.Page).info.AddMessage("Ente modificato", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
        }
Beispiel #13
0
        //click sulla ddl per la paginazione dei contatti (fa il databind della gridview)
        protected void OnContactsPagerIndexChanged(string s, int pag)
        {
            int           da     = pag + 1;
            RubricaEntita rubEnt = (RubricaEntita)Session["EntSession"];

            gvContacts.Visible    = true;
            gvContacts.DataSource = rubEnt.Contatti.Skip(pag * PagerSize).Take(PagerSize).ToList();

            gvContacts.DataBind();
            gvContacts.BottomPagerRow.Visible = true;
            ucpag.configureControl(da.ToString(), PagerSize.ToString(), rubEnt.Contatti.Count.ToString());
        }
        public RubricaEntitaType(RubricaEntita re)
            : base(re)
        {
            if (re == null || re.IsValid == false)
            {
                this.m_IsNull = true;
                return;
            }

            this.m_AFF_IPAIsNull        = !re.AffIPA.HasValue;
            this.m_ID_PADREIsNull       = !re.IdPadre.HasValue;
            this.m_ID_REFERRALIsNull    = !re.IdReferral.HasValue;
            this.m_REF_ID_ADDRESSIsNull = !re.RefIdAddress.HasValue;
            this.m_REF_ORGIsNull        = !re.RefOrg.HasValue;

            this.m_FLG_IPA = Convert.ToInt32(re.IsIPA).ToString();
            if (re.Address is RubricaAddressType)
            {
                this.m_RUBR_ADDRESS = re.Address as RubricaAddressType;
            }
            else
            {
                this.m_RUBR_ADDRESS = new RubricaAddressType(re.Address);
            }

            RubricaContattiListType rubrContList;

            if (re.Contatti == null)
            {
                rubrContList = RubricaContattiListType.Null;
            }
            else
            {
                rubrContList = new RubricaContattiListType();
                rubrContList.RubricaContatti = re.Contatti.Select(c =>
                {
                    if (c is RubricaContattiType)
                    {
                        return(c as RubricaContattiType);
                    }
                    else
                    {
                        return(new RubricaContattiType(c));
                    }
                }).ToArray();
            }

            this.m_REFERRAL_TYPE = re.ReferralType.ToString();
        }
Beispiel #15
0
        //metodo per il controllo dei contatti già presenti
        public bool ContactControls(long?TidContact)
        {
            RubricaEntita TrubEnt = Session["EntSession"] as RubricaEntita;

            if (!string.IsNullOrEmpty(Convert.ToString(TidContact))) //nel caso di update
            {
                var lCont = TrubEnt.Contatti.Where(x => x.IdContact != TidContact);

                if (lCont.Any(x => x.Mail == (ContactsFormView.FindControl("TextMail") as TextBox).Text) && (ContactsFormView.FindControl("TextMail") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Email già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }

                if (lCont.Any(x => x.Telefono == (ContactsFormView.FindControl("TextTelefono") as TextBox).Text) && (ContactsFormView.FindControl("TextTelefono") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Telefono già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }

                if (lCont.Any(x => x.Fax == (ContactsFormView.FindControl("TextFax") as TextBox).Text) && (ContactsFormView.FindControl("TextFax") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Fax già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }
            }

            else  //nel caso di insert
            {
                if (TrubEnt.Contatti.Exists(x => x.Mail == (ContactsFormView.FindControl("TextMail") as TextBox).Text) && (ContactsFormView.FindControl("TextMail") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Email già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }

                if (TrubEnt.Contatti.Exists(x => x.Telefono == (ContactsFormView.FindControl("TextTelefono") as TextBox).Text) && (ContactsFormView.FindControl("TextTelefono") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Telefono già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }

                if (TrubEnt.Contatti.Exists(x => x.Fax == (ContactsFormView.FindControl("TextFax") as TextBox).Text) && (ContactsFormView.FindControl("TextFax") as TextBox).Text != string.Empty)
                {
                    ((BasePage)this.Page).info.AddMessage("Operazione impossibile: Fax già presente nei contatti", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return(false);
                }
            }
            return(true);
        }
Beispiel #16
0
        public ResultList <RubricaEntita> LoadEntitaByMailDomain(IList <EntitaType> tEnt, string mail, int da, int per)
        {
            ResultList <RubricaEntita> r = new ResultList <RubricaEntita>();

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    var query = dbcontext.RUBR_ENTITA.AsQueryable();
                    query = dbcontext.RUBR_CONTATTI.Where(x => x.MAIL.ToUpper().Contains(mail.ToUpper())).Select(z => z.RUBR_ENTITA).AsQueryable();
                    if (tEnt != null && tEnt.Count != 0 && !tEnt.Contains(EntitaType.ALL))
                    {
                        string[] wherees = tEnt.Select(e => e.ToString()).ToArray();
                        query.Where(x => wherees.Contains(x.REFERRAL_TYPE));
                    }
                    int tot = Convert.ToInt32(query.Count());
                    r.Da     = ((da == 0) ? ++da : da);
                    r.Per    = ((tot < per) ? tot : per);
                    r.Totale = tot;
                    var entities = query.Skip(r.Da).Take(r.Per).ToList();
                    r.List = new List <RubricaEntita>();
                    foreach (var e in entities)
                    {
                        RubricaEntita ent = AutoMapperConfiguration.MapToRubrEntita(e);
                        r.List.Add(ent);
                    }
                }
            }
            catch (Exception excp)
            {
                r.List = null;
                if (excp.GetType() != typeof(ManagedException))
                {
                    ManagedException mEx = new ManagedException(excp.Message,
                                                                "RUB_ORA001",
                                                                string.Empty,
                                                                string.Empty,
                                                                excp);
                    ErrorLogInfo er = new ErrorLogInfo(mEx);
                    log.Error(er);
                    throw mEx;
                }
                else
                {
                    throw excp;
                }
            }
            return(r);
        }
Beispiel #17
0
        public SendMail.Model.RubricaMapping.RubricaEntita GetById(long id)
        {
            RubricaEntita re = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    var r = dbcontext.RUBR_ENTITA.Where(x => x.ID_REFERRAL == id).First();
                    re = AutoMapperConfiguration.MapToRubrEntita(r);
                }
            }
            catch
            {
            }

            return(re);
        }
Beispiel #18
0
        //click sul bottone per creare un contatto nuovo
        protected void ContactsFormView_InsertCommand(object sender, EventArgs e)
        {
            hidInsertType.Value = ((ImageButton)sender).CommandName;
            if (gvContacts.Rows.Count == 0)      //serve per nascondere la scritta
            {
                gvContacts.Visible = false;      //dell'empty data template della gv
            }
            RubricaEntita rubEnt = EntFormViewDataSource;

            if (rubEnt.Contatti.Count == 1)
            {
                OnContactsPagerIndexChanged("", 0);
                gvContacts.BottomPagerRow.Visible = false;
            }
            ContactsFormView.Visible = true;
            CurrentFvState           = FormViewMode.Insert;
            ContactsFormView.DataBind();
        }
        internal static RubricaEntita MapIPAToRubricaEntita(IDataRecord dr)
        {
            RubricaEntita re = new RubricaEntita();

            re.IdReferral     = (Nullable <Int64>)dr.GetDecimal("ID_RUB");
            re.Cognome        = dr.GetString("COGNOME");
            re.Nome           = dr.GetString("NOME");
            re.CodiceFiscale  = dr.GetString("CODFIS");
            re.PartitaIVA     = dr.GetString("PIVA");
            re.ReferralType   = ModelHelper.ParseEnum <EntitaType>(dr.GetString("REFERRAL_TYPE"));
            re.RagioneSociale = dr.GetString("RAGIONESOCIALE");
            re.Ufficio        = dr.GetString("UFFICIO");
            if (!dr.IsDBNull("MAIL") || !dr.IsDBNull("FAX") || !dr.IsDBNull("TELEFONO"))
            {
                re.Contatti = new List <RubricaContatti>();
                re.Contatti.Add(new RubricaContatti
                {
                    Mail     = dr.GetString("MAIL"),
                    Fax      = dr.GetString("FAX"),
                    Telefono = dr.GetString("TELEFONO")
                });
            }
            if (!dr.IsDBNull("STATO") || !dr.IsDBNull("PROVINCIA") || !dr.IsDBNull("CITTA") ||
                !dr.IsDBNull("VIA") || !dr.IsDBNull("NUMERO") || !dr.IsDBNull("LETTERA") ||
                !dr.IsDBNull("CAP"))
            {
                re.Address = new RubricaAddress
                {
                    Cap            = dr.GetString("CAP"),
                    Civico         = dr.GetString("NUMERO") + dr.GetString("LETTERA"),
                    CodIsoStato    = dr.GetString("STATO"),
                    Comune         = dr.GetString("CITTA"),
                    Indirizzo      = string.Format("{0} {1}", dr.GetString("SEDIME"), dr.GetString("VIA")),
                    SiglaProvincia = dr.GetString("PROVINCIA")
                };
            }
            re.IPAId   = dr.GetString("COD_UNIVOCO");
            re.Note    = dr.GetString("NOTE");
            re.IsIPA   = true;
            re.IPAdn   = dr.GetString("DN");
            re.IdPadre = (Nullable <Int64>)dr.GetDecimal("ID_PADRE");
            return(re);
        }
Beispiel #20
0
        //metodo per il binding dei contatti
        public void DataContactView(long?idContact)
        {
            if (idContact.HasValue && idContact > 0)
            {
                //rubEnt = (RubricaEntita)Session["EntSession"];
                RubricaEntita rubEnt = EntFormViewDataSource;

                List <RubricaContatti> l1 = new List <RubricaContatti>();
                l1.Add(rubEnt.Contatti.SingleOrDefault(x => x.IdContact == Convert.ToInt32(idContact)));

                ContactsFormView.DataSource = l1;
                ContactsFormView.DataBind();

                ContactsFormView.Visible = true;
            }
            else
            {
                ContactsFormView.Visible = false;
            }
        }
Beispiel #21
0
        /// NON SO SE SERVE
        //public ResultList<RubricaEntita> LoadSimilarityEntitaByParams(IList<SendMail.Model.EntitaType> tEnt,
        //    IDictionary<SendMail.Model.FastIndexedAttributes, IList<string>> pars, int da, int per)
        //{
        //    if (pars == null || pars.Count == 0) return null;

        //    if (tEnt == null) { tEnt = new List<SendMail.Model.EntitaType>(); }
        //    if (tEnt.Count == 0) { tEnt.Add(SendMail.Model.EntitaType.ALL); }

        //    if (pars.Any(x => x.Value == null))
        //    {
        //        throw new ArgumentException("Parametri non validi");
        //    }

        //    ResultList<RubricaEntita> res = new ResultList<RubricaEntita>();
        //    res.Da = da;
        //    res.Per = per;

        //    int tot = pars.SelectMany(c => c.Value).Count();
        //    string[] matchPars = new string[tot];
        //    string utlBase = "utl_match.jaro_winkler_similarity('{0}', {1})";
        //    string orderby = null;

        //    for (int i = 0; i < pars.Count; i++)
        //    {
        //        KeyValuePair<SendMail.Model.FastIndexedAttributes, IList<string>> p = pars.ElementAt(i);
        //        if (p.Value == null || p.Value.Count == 0)
        //        {
        //            throw new ArgumentException("Parametri non validi");
        //        }

        //        string qPar = null;

        //        switch (p.Key)
        //        {
        //            case SendMail.Model.FastIndexedAttributes.COGNOME:
        //                qPar = "nvl2(cognome, lower(cognome||' '||nome), lower(nome))";
        //                break;

        //            case SendMail.Model.FastIndexedAttributes.RAGIONE_SOCIALE:
        //                qPar = "nvl2(disamb_pre, lower(disamb_pre||' '||ragione_sociale||' '||disamb_post), lower(ragione_sociale))";
        //                break;

        //            case SendMail.Model.FastIndexedAttributes.UFFICIO:
        //                qPar = "ufficio";
        //                break;

        //            default:
        //                throw new NotImplementedException("Tipo di rircerca non implementato");
        //        }

        //        for (int j = 0; j < p.Value.Count; j++)
        //        {
        //            int idx = Array.FindIndex<string>(matchPars, x => String.IsNullOrEmpty(x));
        //            if (idx != -1)
        //            {
        //                matchPars[idx] = String.Format(utlBase, p.Value[j], qPar);
        //                if (String.IsNullOrEmpty(orderby))
        //                {
        //                    orderby += String.Format("{0} desc", (idx + 1));
        //                }
        //                else
        //                {
        //                    orderby += String.Format(", {0} desc", (idx + 1));
        //                }
        //            }
        //        }
        //    }

        //    string where = null;
        //    if (!(tEnt.Contains(SendMail.Model.EntitaType.UNKNOWN)))
        //    {
        //        where = "WHERE REFERRAL_TYPE IN (" + String.Join(", ", tEnt.Select(c => String.Format("'{0}'", c.ToString())).ToArray()) + ")";
        //    }

        //    string query = String.Format(selectSimilarityEntitaBaseQuery,
        //        String.Join(", ", matchPars), where, orderby);

        //    string complOrderBy = null;
        //    switch (tEnt[0])
        //    {
        //        case SendMail.Model.EntitaType.ALL:
        //        case SendMail.Model.EntitaType.PA:
        //        case SendMail.Model.EntitaType.PA_SUB:
        //        case SendMail.Model.EntitaType.AZ_PRI:
        //        case SendMail.Model.EntitaType.AZ_PS:
        //            complOrderBy = " order by ragione_sociale asc nulls last";
        //            break;
        //        case SendMail.Model.EntitaType.PA_UFF_PF:
        //        case SendMail.Model.EntitaType.AZ_UFF_PF:
        //        case SendMail.Model.EntitaType.AZ_PF:
        //        case SendMail.Model.EntitaType.PA_PF:
        //        case SendMail.Model.EntitaType.PF:
        //        case SendMail.Model.EntitaType.PG:
        //            complOrderBy = " order by cognome, nome asc nulls last";
        //            break;
        //        case SendMail.Model.EntitaType.PA_UFF:
        //        case SendMail.Model.EntitaType.AZ_UFF:
        //            complOrderBy = " order by ufficio asc nulls last";
        //            break;
        //        case SendMail.Model.EntitaType.GRP:
        //        case SendMail.Model.EntitaType.UNKNOWN:
        //            break;
        //        default:
        //            throw new ArgumentException("Caso non implementato");
        //    }

        //    try
        //    {
        //        using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
        //        {
        //            if (per > 0)
        //            {
        //                oCmd.CommandText = OrderedTOracleDB.GetOrderedQuery(query, da, per);
        //            }
        //            else
        //            {
        //                oCmd.CommandText = query;
        //            }

        //            oCmd.CommandText += complOrderBy;

        //            using (OracleDataReader r = oCmd.ExecuteReader())
        //            {
        //                if (r.HasRows)
        //                {
        //                    res.List = new List<RubricaEntita>();

        //                    while (r.Read())
        //                    {
        //                        res.List.Add(DaoOracleDbHelper.MapToRubricaEntita(r));
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch
        //    {
        //        res = null;
        //        throw;
        //    }

        //    return res;
        //}

        public SendMail.Model.RubricaMapping.RubricaEntita LoadEntitaCompleteById(long idEntita)
        {
            RubricaEntita res = null;

            using (var dbcontext = new FAXPECContext())
            {
                try
                {
                    var entita = dbcontext.RUBR_ENTITA.Where(x => x.ID_REFERRAL == idEntita).First();
                    res = AutoMapperConfiguration.MapToRubrEntita(entita);
                    ContattoSQLDb d  = new ContattoSQLDb();
                    long          id = res.IdReferral.Value;
                    res.Contatti = d.LoadContattiOrgByOrgId(id, false, true, false, true);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(res);
        }
        protected void btnShowEntita_OnClick(object sender, EventArgs e)
        {
            pnlDettagli.Visible = true;
            if (ucEntiSearcher.EnteSelected == null)
            {
                return;
            }
            Item item = ucEntiSearcher.EnteSelected;
            long id   = default(long);

            string[] itemIds = item.Id.Split(';');
            string   itemId  = itemIds[0].Split('#')[0];

            if (long.TryParse(itemId, out id))
            {
                try
                {
                    RubricaEntitaService rus = new RubricaEntitaService();
                    RubricaEntita        r   = rus.GetRubricaEntitaCompleteById(id);
                    UCEntiViewer.EntFormViewDataSource = r;
                }
                catch (Exception ex)
                {
                    if (ex.GetType() != typeof(ManagedException))
                    {
                        ManagedException mEx = new ManagedException(ex.Message,
                                                                    "ERR_125",
                                                                    string.Empty,
                                                                    string.Empty,
                                                                    ex);
                        ErrorLogInfo er = new ErrorLogInfo(mEx);
                        log.Error(er);
                    }
                    pnlDettagli.Visible = false;//* ATT.947493
                    (this.Page as BasePage).info.AddMessage("Errore nel caricamento dell'entità. Riprovare", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                }
            }

            pnlDownPage.Update();
        }
Beispiel #23
0
        public SendMail.Model.RubricaMapping.RubricaEntita GetById(long id)
        {
            RubricaEntita re = null;

            try
            {
                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = "SELECT * FROM RUBR_ENTITA WHERE ID_REFERRAL = " + id;
                    using (OracleDataReader r = oCmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            re = DaoOracleDbHelper.MapToRubricaEntita(r);
                        }
                    }
                }
            }
            catch
            {
            }

            return(re);
        }
Beispiel #24
0
        //click sul bottone della formview dei contatti: gestisce update ed inserimento
        protected void ContactsFormView_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            RubricaEntita        rubEnt      = Session["EntSession"] as RubricaEntita;
            RubricaContatti      contact     = new RubricaContatti();
            RubricaEntitaService rubrService = new RubricaEntitaService();


            #region "Gestione Inseret/update contatto"
            if (e.CommandName.Equals("Update"))
            {
                int idCnt = Int32.Parse(((HiddenField)ContactsFormView.FindControl("hfIdContact")).Value);
                contact = rubEnt.Contatti.SingleOrDefault(x => x.IdContact == idCnt);
            }


            if ((e.CommandName.Equals("Insert") && hidInsertType.Value.Equals("Insert_c")) || e.CommandName.Equals("Update"))
            {
                if ((e.CommandName.Equals("Insert")))
                {
                    contact.RefIdReferral = rubEnt.IdReferral;
                }

                //funzione per il controllo di inserimento di contatti già inseriti
                if (contact != null && ContactControls(contact.IdContact) == false) //caso in cui non supera i controlli
                {
                    if (e.CommandName == "Update")                                  //ricarico i dati precedenti in caso di update
                    {
                        DataContactView(Int32.Parse(((HiddenField)ContactsFormView.FindControl("hfIdContact")).Value));
                    }
                    else //svuoto i campi in caso di insert
                    {
                        (ContactsFormView.FindControl("TextMail") as TextBox).Text     = "";
                        (ContactsFormView.FindControl("TextTelefono") as TextBox).Text = "";
                        (ContactsFormView.FindControl("TextFax") as TextBox).Text      = "";
                    }
                    return;
                }

                try
                {
                    contact.Telefono   = ((TextBox)ContactsFormView.FindControl("TextTelefono")).Text;
                    contact.Mail       = ((TextBox)ContactsFormView.FindControl("TextMail")).Text;
                    contact.Fax        = ((TextBox)ContactsFormView.FindControl("TextFax")).Text;
                    contact.ContactRef = ((TextBox)ContactsFormView.FindControl("TextRef")).Text;
                    contact.Note       = ((TextBox)ContactsFormView.FindControl("TextNote")).Text;
                    contact.IsPec      = ((CheckBox)ContactsFormView.FindControl("chkPec")).Checked;
                    contact.AffIPA     = 0;
                    if (contact.IsPec == false)
                    {
                        foreach (MailPecForCheck val in Enum.GetValues(typeof(MailPecForCheck)))
                        {
                            if (contact.Mail.Contains("@" + val.ToString() + "."))
                            {
                                contact.IsPec = true;
                            }
                        }
                    }
                }
                catch
                {
                    ((BasePage)this.Page).info.AddMessage("Attenzione: si è verificato un errore", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }

                if (contact.Telefono == "" && contact.Mail == "" && contact.Fax == "")
                {
                    ((BasePage)this.Page).info.AddMessage("Inserire almeno un parametro", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }

                if (contact.Mail == "" && contact.IsPec == true)
                {
                    ((BasePage)this.Page).info.AddMessage("Inserire indirizzo email valido", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    contact.IsPec = false;
                    return;
                }

                if (contact.Telefono == "")
                {
                    contact.Telefono = null;
                }
                if (contact.Mail == "")
                {
                    contact.Mail = null;
                }
                if (contact.Fax == "")
                {
                    contact.Fax = null;
                }
                if (contact.ContactRef == "")
                {
                    contact.ContactRef = null;
                }
                if (contact.Note == "")
                {
                    contact.Note = null;
                }

                if (e.CommandName == "Update")
                {
                    try
                    {
                        //metodo per l'update
                        ContattoService contattoService = new ContattoService();
                        contattoService.UpdateRubrContatti(contact, false);
                    }
                    catch (Exception)
                    {
                        ((BasePage)this.Page).info.AddMessage("Aggiornamento non riuscito: Errore in banca dati", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                        return;
                    }
                    ((BasePage)this.Page).info.AddMessage("Contatto modificato", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                }
                else if (e.CommandName == "Insert")
                {
                    try
                    {
                        //metodo per l'insert
                        ContattoService contattoService = new ContattoService();
                        contattoService.InsertRubrContatti(contact, false);
                    }
                    catch (Exception ex)
                    {
                        ((BasePage)this.Page).info.AddMessage("Inserimento non riuscito: Errore in banca dati dettagli: " + ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                        return;
                    }
                    ((BasePage)this.Page).info.AddMessage("Contatto inserito", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                }
            }
            #endregion


            #region "Insert di un nuovo gruppo o di un nuovo ufficio"

            if ((e.CommandName.Equals("Insert") && hidInsertType.Value.Equals("Insert_u")))
            {
                RubricaEntita newEnt = new RubricaEntita();
                newEnt.Ufficio = ((TextBox)ContactsFormView.FindControl("TextUfficio")).Text;
                newEnt.IdPadre = rubEnt.IdReferral;
                newEnt.RefOrg  = (rubEnt.RefOrg == null ? rubEnt.IdReferral : rubEnt.RefOrg);
                if (rubEnt.ReferralType.ToString().StartsWith("PA"))
                {
                    newEnt.ReferralType = EntitaType.PA_UFF;
                }
                else if (rubEnt.ReferralType.ToString().StartsWith("AZ"))
                {
                    newEnt.ReferralType = EntitaType.AZ_UFF;
                }
                try
                {
                    //metodo per l'insert
                    rubrService.Insert(newEnt);
                }
                catch (Exception e0)
                {
                    ((BasePage)this.Page).info.AddMessage("Inserimento non riuscito: " + e0.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }
                ((BasePage)this.Page).info.AddMessage("Gruppo inserito", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "reload_local_tree", "ShowTree(config.tree);", true);
            }
            else if ((e.CommandName.Equals("Insert") && hidInsertType.Value.Equals("Insert_g")))
            {
                RubricaEntita newEnt = new RubricaEntita();

                newEnt.Ufficio = ((TextBox)ContactsFormView.FindControl("TextGruppo")).Text;
                newEnt.IdPadre = rubEnt.IdReferral;
                newEnt.RefOrg  = (rubEnt.RefOrg == null ? rubEnt.IdReferral : rubEnt.RefOrg);
                if (rubEnt.ReferralType.ToString().StartsWith("PA"))
                {
                    newEnt.ReferralType = EntitaType.PA_GRP;
                }
                else if (rubEnt.ReferralType.ToString().StartsWith("AZ"))
                {
                    newEnt.ReferralType = EntitaType.AZ_GRP;
                }
                try
                {
                    //metodo per l'insert
                    rubrService.Insert(newEnt);
                }
                catch (Exception e1)
                {
                    ((BasePage)this.Page).info.AddMessage("Inserimento non riuscito: " + e1.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }
                ((BasePage)this.Page).info.AddMessage("Ufficio inserito", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "reload_local_tree", "ShowTree();", true);
            }


            #endregion
            hfCurrentID = contact.IdContact ?? -1;
            long idEntita = long.Parse((EntFormView.FindControl("hfIdEntita") as HiddenField).Value);
            EntFormViewDataSource = rubrService.GetRubricaEntitaCompleteById(idEntita);
            rubEnt = EntFormViewDataSource;
            switch (rubEnt.Contatti.Count)
            {
            case 0:
                gvContacts.Visible = true;
                gvContacts.DataBind();
                ContactsFormView.DataBind();
                break;

            default:
                if (hfCurrentID == -1)
                {
                    OnContactsPagerIndexChanged("", 0);
                }
                else
                {
                    int index = rubEnt.Contatti.IndexOf(rubEnt.Contatti.First(x => x.IdContact == hfCurrentID));
                    OnContactsPagerIndexChanged("", index / PagerSize);
                }
                if (rubEnt.Contatti.Count <= PagerSize)
                {
                    gvContacts.BottomPagerRow.Visible = false;
                }
                break;
            }
            ContactsFormView.Visible = false;
        }