Example #1
0
 public response SendToInvolvedParties()
 {
     try
     {
         response     toReturn    = new response(true, "", null, null, new List <Error>());
         Dosar        d           = (Dosar)this.GetDosar().Result;
         Utilizator[] utilizatori = (Utilizator[])d.GetInvolvedParties().Result;
         foreach (Utilizator utilizator in utilizatori)
         {
             MesajUtilizator mesajUtilizator = new MesajUtilizator(authenticatedUserId, connectionString)
             {
                 ID_UTILIZATOR = Convert.ToInt32(utilizator.ID), ID_MESAJ = Convert.ToInt32(this.ID)
             };
             response r = mesajUtilizator.Insert();
             if (!r.Status)
             {
                 toReturn.AddResponse(r);
             }
         }
         return(toReturn);
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
Example #2
0
        private ActionResult InternalTokenLogin(string _token, string _url, Utilizator u)
        {
            string conStr = HttpContext.Server.MapPath("~").ToLower().IndexOf("test") > 0 ? CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString_test"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()) : CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()); // separam socisa de socisa_test

            HttpContext.Session["TOKEN"] = _token;
            TempData.Clear();

            string[] separator = { "|" };
            string[] token     = _token.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            int      id        = Convert.ToInt32(token[1]);
            Dosar    d         = new Dosar(Convert.ToInt32(u.ID), conStr, id);

            HttpContext.Session["conStr"]         = conStr;
            HttpContext.Session["CURENT_USER_ID"] = u.ID;
            HttpContext.Session["CURENT_USER"]    = u;
            FormsAuthentication.SetAuthCookie(u.USER_NAME, true);
            //System.Web.Security.FormsAuthentication.SetAuthCookie("", false);
            NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), conStr);
            Nomenclator             n  = (Nomenclator)nr.Find("TIP_UTILIZATORI", Convert.ToInt32(u.ID_TIP_UTILIZATOR)).Result;

            HttpContext.Session["CURENT_USER_TYPE"]     = n;
            HttpContext.Session["CURENT_USER_RIGHTS"]   = (Drept[])u.GetDrepturi().Result;
            HttpContext.Session["CURENT_USER_ACTIONS"]  = (SOCISA.Models.Action[])u.GetActions().Result;
            HttpContext.Session["CURENT_USER_SETTINGS"] = (Setare[])u.GetSetari().Result;
            HttpContext.Session["CURENT_USER_SOCIETATI_ADMINISTRATE"] = (SocietateAsigurare[])u.GetSocietatiAdministrate().Result;

            HttpContext.Session["ID_SOCIETATE"] = d.ID_SOCIETATE_CASCO;
            SocietateAsigurare sa = new SocietateAsigurare(Convert.ToInt32(u.ID_SOCIETATE), conStr, Convert.ToInt32(d.ID_SOCIETATE_CASCO));

            HttpContext.Session["SOCIETATE_ASIGURARE"] = sa;
            //return Redirect(String.Format("/Dashboard/IndexMain/{0}", Token));
            return(Redirect(String.Format("{0}{1}", HttpUtility.UrlDecode(_url), _token)));
        }
Example #3
0
        public ProcesStadiuView(int _CURENT_USER_ID, string conStr, int _ID, string _tip_id)
        {
            StadiiRepository sr = new StadiiRepository(_CURENT_USER_ID, conStr);

            this.Stadii = (StadiuCombo[])sr.GetCombo().Result;
            //SentinteRepository senr = new SentinteRepository(_CURENT_USER_ID, conStr);
            //this.Sentinte = (Sentinta[])senr.GetAll().Result;
            ProcesStadiu[] pss = null;
            switch (_tip_id)
            {
            case "proces":
                this.ID_PROCES = _ID;
                this.ID_DOSAR  = null;
                Proces p = new Proces(_CURENT_USER_ID, conStr, _ID);
                pss = (ProcesStadiu[])p.GetStadii().Result;
                break;

            case "dosar":
                this.ID_PROCES = null;
                this.ID_DOSAR  = _ID;
                Dosar d = new Dosar(_CURENT_USER_ID, conStr, _ID);
                pss = (ProcesStadiu[])d.GetStadii().Result;
                break;
            }
            this.ProceseStadii = new ProcesStadiuExtended[pss.Length];
            for (int i = 0; i < pss.Length; i++)
            {
                this.ProceseStadii[i] = new ProcesStadiuExtended(pss[i]);
            }
            this.CurProcesStadiu = new ProcesStadiuExtended(new ProcesStadiu());
        }
Example #4
0
 public response Avizare(bool _avizat)
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_Avizare", new object[] { new MySqlParameter("_ID", this.ID), new MySqlParameter("_AVIZAT", _avizat) });
         response   r  = da.ExecuteUpdateQuery();
         if (r.Status)
         {
             try
             {
                 MesajeRepository mr          = new MesajeRepository(authenticatedUserId, connectionString);
                 string           partial_sub = String.Format("DOCUMENT {0}", _avizat ? "NOU" : "ELIMINAT DIN DOSAR");
                 string           subiect     = String.Format("{0} ({1})", partial_sub, ((Nomenclator) new NomenclatoareRepository(authenticatedUserId, connectionString).Find("tip_document", Convert.ToInt32(this.ID_TIP_DOCUMENT)).Result).DENUMIRE);
                 Dosar            d           = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_DOSAR));
                 if (d.IsAvizat())
                 {
                     mr.GenerateAndSendMessage(this.ID_DOSAR, DateTime.Now, subiect, subiect, partial_sub, authenticatedUserId, (int)Importanta.Low);
                 }
             }
             catch { }
         }
         return(new response(true, null, r, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
Example #5
0
 public response GetDosareNeoperate(int id_societate)
 {
     try
     {
         DataAccess      da    = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOSAREsp_GetAllNeoperate", new object[] { new MySqlParameter("_ID_SOCIETATE", id_societate), new MySqlParameter("_EXPIRATION_DAYS", 15) });
         MySqlDataReader r     = da.ExecuteSelectQuery();
         ArrayList       aList = new ArrayList();
         while (r.Read())
         {
             Dosar d = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(r["ID"]));
             aList.Add(d);
         }
         r.Close(); r.Dispose();
         Dosar[] toReturn = new Dosar[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (Dosar)aList[i];
         }
         return(new response(true, Newtonsoft.Json.JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
Example #6
0
        /// <summary>
        /// Metoda pentru inserarea relatiei Dosar-stadiu curenta
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Insert()
        {
            response toReturn = Validare();

            if (!toReturn.Status)
            {
                return(toReturn);
            }

            /*
             * if (this.Stadiu != null)
             * {
             *  response toReturnS = this.Stadiu.Insert();
             *  if (toReturnS.Status && toReturnS.InsertedId != null)
             *      this.ID_STADIU = Convert.ToInt32(toReturnS.InsertedId);
             * }
             */

            PropertyInfo[] props       = this.GetType().GetProperties();
            ArrayList      _parameters = new ArrayList();
            var            col         = CommonFunctions.table_columns(authenticatedUserId, connectionString, "procese_stadii");

            foreach (PropertyInfo prop in props)
            {
                if (col != null && col.ToUpper().IndexOf(prop.Name.ToUpper()) > -1) // ca sa includem in Array-ul de parametri doar coloanele tabelei, nu si campurile externe si/sau alte proprietati
                {
                    string propName  = prop.Name;
                    string propType  = prop.PropertyType.ToString();
                    object propValue = prop.GetValue(this, null);
                    propValue = propValue == null ? DBNull.Value : propValue;
                    if (propType != null)
                    {
                        if (propName.ToUpper() != "ID") // il vom folosi doar la Edit!
                        {
                            _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                        }
                    }
                }
            }
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PROCESE_STADIIsp_insert", _parameters.ToArray());

            toReturn = da.ExecuteInsertQuery();
            if (toReturn.Status)
            {
                this.ID = toReturn.InsertedId;
                try
                {
                    if (toReturn.Status)
                    {
                        Proces p = new Proces(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_PROCES));
                        p.ChangeStadiuCurent(Convert.ToInt32(((ProcesStadiu)p.GetStadiuCurent().Result).ID));
                        Dosar d = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(p.ID_DOSAR));
                        d.SetDataUltimeiModificari(DateTime.Now);
                    }
                }
                catch { }
            }
            return(toReturn);
        }
Example #7
0
        public ActionResult eShow(string token)
        {
            string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;

            string[] t = token.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            Dosar    d = new Dosar(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr, Convert.ToInt32(t[1]));

            return(PartialView("_DosareNavigator", new DosarView(Convert.ToInt32(Session["CURENT_USER_ID"]), Convert.ToInt32(Session["ID_SOCIETATE"]), d, conStr)));
        }
Example #8
0
 public MesajJson(Mesaj m, Dosar dos, Utilizator s, Utilizator[] us, Nomenclator n, DateTime?d)
 {
     this.Mesaj      = m;
     this.Dosar      = dos;
     this.Sender     = s;
     this.Receivers  = us;
     this.TipMesaj   = n;
     this.DataCitire = d;
 }
Example #9
0
        public ProcesView(int _CURENT_USER_ID, string conStr, int?_ID_DOSAR, int?_ID_PROCES)
        {
            NomenclatoareRepository tpr = new NomenclatoareRepository(_CURENT_USER_ID, conStr);

            this.TipuriProcese = (Nomenclator[])tpr.GetAll("tip_procese").Result;
            this.Instante      = (Nomenclator[])tpr.GetAll("instante").Result;
            this.Complete      = (Nomenclator[])tpr.GetAll("complete").Result;
            //ContracteRepository cr = new ContracteRepository(_CURENT_USER_ID, conStr);
            //this.Contracte = (Contract[])cr.GetAll().Result;
            ProceseRepository pr = new ProceseRepository(_CURENT_USER_ID, conStr);

            this.TipDocumenteScanateProcese = (string[])pr.GetTipDocumenteScanatePocese().Result;
            //PartiRepository par = new PartiRepository(_CURENT_USER_ID, conStr);
            //this.Parti = (Parte[])par.GetAll().Result;
            this.Calitati = (Nomenclator[])tpr.GetAll("calitati").Result;
            ////Utilizator u = new Utilizator(_CURENT_USER_ID, conStr, _CURENT_USER_ID);
            ////this.Societate = (SocietateAsigurare)u.GetSocietatiAsigurare().Result;
            this.Societate = new SocietateAsigurare(_CURENT_USER_ID, conStr, Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]));
            StadiiRepository sr = new StadiiRepository(_CURENT_USER_ID, conStr);

            this.Stadii = (StadiuCombo[])sr.GetCombo().Result;

            this.CurProces  = new ProcesExtended(new Proces());
            this.procesJson = new ProcesJson();
            if (_ID_DOSAR != null && _ID_PROCES == null)
            {
                this.ID_DOSAR  = Convert.ToInt32(_ID_DOSAR);
                this.ID_PROCES = null;
                Dosar d = new Dosar(_CURENT_USER_ID, conStr, Convert.ToInt32(_ID_DOSAR));
                //this.Dosar = d;
                this.Procese = (Proces[])d.GetProcese().Result;

                /*
                 * Proces[] ps = (Proces[])d.GetProcese().Result;
                 * this.Procese = new ProcesExtended[ps.Length];
                 * for (int i = 0; i < ps.Length; i++)
                 * {
                 *  this.Procese[i] = new ProcesExtended(ps[i]);
                 * }
                 */
                this.procesJson          = new ProcesJson();
                this.procesJson.Calitate = d.ID_SOCIETATE_CASCO == Societate.ID ? "RECLAMANT" : "PARAT";
                SocietateAsigurare cealaltaSocietate = new SocietateAsigurare(_CURENT_USER_ID, conStr, Convert.ToInt32(d.ID_SOCIETATE_CASCO == Societate.ID ? d.ID_SOCIETATE_RCA : d.ID_SOCIETATE_CASCO));
                this.procesJson.Reclamant = d.ID_SOCIETATE_CASCO == Societate.ID ? Societate.DENUMIRE : cealaltaSocietate.DENUMIRE;
                this.procesJson.Parat     = d.ID_SOCIETATE_CASCO == Societate.ID ? cealaltaSocietate.DENUMIRE : Societate.DENUMIRE;
                this.procesJson.Tert      = "";
            }
            if (_ID_DOSAR == null && _ID_PROCES != null)
            {
                this.ID_PROCES = Convert.ToInt32(_ID_PROCES);
                this.ID_DOSAR  = null;

                this.procesJson.Reclamant = "";
                this.procesJson.Parat     = "";
                this.procesJson.Tert      = "";
            }
        }
Example #10
0
        public JsonResult GetInvolvedParties(int?id)        // id_dosar
        {
            string   conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int      uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);
            Dosar    d      = new Dosar(uid, conStr, Convert.ToInt32(id));
            response r      = d.GetInvolvedParties();

            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Example #11
0
        public JsonResult GetUtilizatoriAsignati(int id_dosar)
        {
            string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int    uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);
            Dosar  d      = new Dosar(uid, conStr, id_dosar);

            Utilizator[] us = (Utilizator[])d.GetUtilizatori().Result;
            return(Json(us, JsonRequestBehavior.AllowGet));
        }
Example #12
0
 public void UpdateDosareAfterCompensare()
 {
     foreach (Edge e in this.Edges)
     {
         if (e.Weight == 0)
         {
             foreach (int id_dosar in e.IduriDosare)
             {
                 //update compensare si status dosar = "compensat"
                 Dosar      d          = new Dosar(authenticatedUserId, connectionString, id_dosar);
                 Compensare compensare = new Compensare(authenticatedUserId, connectionString);
                 compensare.ID_DOSAR = id_dosar;
                 compensare.DATA     = DateTime.Now.Date;
                 compensare.SUMA     = d.VALOARE_REGRES;
                 compensare.REST     = 0;
                 response r = compensare.Insert();
                 if (r.Status)
                 {
                     d.ChangeStatus("COMPENSAT");
                 }
             }
         }
         else
         {
             double sum = 0;
             foreach (int id_dosar in e.IduriDosare)
             {
                 Dosar d = new Dosar(authenticatedUserId, connectionString, id_dosar);
                 sum += Convert.ToDouble(d.VALOARE_REGRES);
                 Compensare compensare = new Compensare(authenticatedUserId, connectionString);
                 compensare.ID_DOSAR = id_dosar;
                 compensare.DATA     = DateTime.Now.Date;
                 string _status = "";
                 if (e.InitialWeight - sum > e.Weight)
                 {
                     //update compensare si status dosar = "compensat"
                     compensare.SUMA = d.VALOARE_REGRES;
                     compensare.REST = 0;
                     _status         = "COMPENSAT";
                 }
                 else
                 {
                     //update compensare cu rest si status dosar = "compensat partial" - TO DO
                     compensare.SUMA = e.InitialWeight - (sum - d.VALOARE_REGRES);
                     compensare.REST = d.VALOARE_REGRES - compensare.SUMA;
                     _status         = "COMPENSAT_PARTIAL";
                 }
                 response r = compensare.Insert();
                 if (r.Status)
                 {
                     d.ChangeStatus(_status);
                 }
             }
         }
     }
 }
Example #13
0
        private static void SincronizareTermenePortal()
        {
            string            conStr = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString(), CommonFunctions.StringCipher.RetrieveKey());
            int               id     = 1;
            ProceseRepository pr     = new ProceseRepository(id, conStr);

            Proces[] procese = (Proces[])pr.GetFiltered(null, null, " PROCESE.NR_DOSAR_INSTANTA LIKE '%/%' ", null).Result;
            List <SOCISA.Models.SedintaPortal> lst = new List <SedintaPortal>();
            QuerySoapClient ws = new QuerySoapClient();

            for (int i = 0; i < procese.Length; i++)
            {
                try
                {
                    int    id_dosar  = Convert.ToInt32(procese[i].ID_DOSAR);
                    Dosar  d         = new Dosar(id, conStr, id_dosar);
                    int    id_proces = Convert.ToInt32(procese[i].ID);
                    string nr_dosar  = procese[i].NR_DOSAR_INSTANTA;

                    socisaV2.PortalWS.Dosar dosar = ws.CautareDosare2(nr_dosar, null, null, null, null, null, null, null)[0];
                    for (int j = 0; j < dosar.sedinte.Length; j++)
                    {
                        bool gasit = false;
                        for (int k = 0; k <= 7; k++)
                        {
                            if (dosar.sedinte[j].data.Date == DateTime.Now.Date.AddDays(k).Date)
                            {
                                SedintaPortal dsp = new SedintaPortal(id, conStr);
                                dsp.ID_DOSAR = id_dosar;
                                try
                                {
                                    dsp.NR_DOSAR_CASCO = d.NR_DOSAR_CASCO;
                                }
                                catch { }
                                dsp.ID_PROCES         = id_proces;
                                dsp.NR_DOSAR_INSTANTA = procese[i].NR_DOSAR_INSTANTA;
                                dsp.DATA         = DateTime.Now.Date;
                                dsp.DATA_SEDINTA = dosar.sedinte[j].data;
                                dsp.INSTANTA     = dosar.institutie.ToString();
                                dsp.COMPLET      = dosar.sedinte[j].complet;
                                dsp.ORA          = dosar.sedinte[j].ora;
                                dsp.MONITORIZARE = true;
                                dsp.Insert();
                                gasit = true;
                                break;
                            }
                        }
                        if (gasit)
                        {
                            break;
                        }
                    }
                }
                catch (Exception exp) { exp.ToString(); }
            }
        }
Example #14
0
        public void WhenUpdatingNonExistingNoExceptionIsThrown()
        {
            var database = CreateTestTarget();

            var expected = new Dosar {
                Id = 1, Code = "PI13232555", Description = "Dosar intern 1555"
            };

            database.Update(expected);
        }
Example #15
0
        public response Update()
        {
            Plata    originalPlata = new Plata(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID)); // ne trebuie ca sa actualizam rezerva dauna din dosar
            response toReturn      = Validare();

            if (!toReturn.Status)
            {
                return(toReturn);
            }
            PropertyInfo[] props       = this.GetType().GetProperties();
            ArrayList      _parameters = new ArrayList();
            var            col         = CommonFunctions.table_columns(authenticatedUserId, connectionString, "plati");

            foreach (PropertyInfo prop in props)
            {
                if (col != null && col.ToUpper().IndexOf(prop.Name.ToUpper()) > -1) // ca sa includem in Array-ul de parametri doar coloanele tabelei, nu si campurile externe si/sau alte proprietati
                {
                    string propName  = prop.Name;
                    string propType  = prop.PropertyType.ToString();
                    object propValue = prop.GetValue(this, null);
                    propValue = propValue ?? DBNull.Value;
                    if (propType != null)
                    {
                        _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                    }
                }
            }
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_update", _parameters.ToArray());

            toReturn = da.ExecuteUpdateQuery();
            if (toReturn.Status)
            {
                try
                {
                    Dosar d = new Dosar(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.REZERVA_DAUNA -= (this.SUMA - originalPlata.SUMA);
                    d.GetNewStatus(false);
                    response r = d.Update();
                    if (!r.Status)
                    {
                        toReturn = r;
                    }
                }
                catch (Exception exp)
                {
                    toReturn = new response(false, exp.ToString(), null, null, new List <Error>()
                    {
                        new Error(exp)
                    });
                    LogWriter.Log(exp);
                }
            }
            return(toReturn);
        }
Example #16
0
        public PlataView(int _CURENT_USER_ID, int _ID_DOSAR, string conStr)
        {
            this.ID_DOSAR = _ID_DOSAR;
            NomenclatoareRepository tpr = new NomenclatoareRepository(_CURENT_USER_ID, conStr);

            this.TipuriPlati = (Nomenclator[])tpr.GetAll("tip_plata").Result;

            Dosar d = new Dosar(_CURENT_USER_ID, conStr, _ID_DOSAR);

            this.Plati = (Plata[])d.GetPlati().Result;
        }
Example #17
0
 /// <summary>
 /// Metoda pt. popularea Dosarului la care este atasat mesajul
 /// </summary>
 /// <returns>SOCISA.DosareJson</returns>
 public response GetDosar()
 {
     try
     {
         Dosar toReturn = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_DOSAR));
         return(new response(true, Newtonsoft.Json.JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
Example #18
0
 public DosarExtended(Dosar d, bool _selected)
 {
     this.Dosar          = d;
     this.AsiguratCasco  = (Asigurat)d.GetAsiguratCasco().Result;
     this.AsiguratRca    = (Asigurat)d.GetAsiguratRca().Result;
     this.AutoCasco      = (Auto)d.GetAutoCasco().Result;
     this.AutoRca        = (Auto)d.GetAutoRca().Result;
     this.Intervenient   = (Intervenient)d.GetIntervenient().Result;
     this.SocietateCasco = (SocietateAsigurare)d.GetSocietateCasco().Result;
     this.SocietateRca   = (SocietateAsigurare)d.GetSocietateRca().Result;
     this.TipDosar       = (Nomenclator)d.GetTipDosar().Result;
     this.selected       = _selected;
 }
Example #19
0
        public JsonResult GetMessages(int?id, int?_START_LIMIT, int?_END_LIMIT)    // id_dosar
        {
            MesajView mv     = new MesajView();
            string    conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int       uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);
            Mesaj     mesaj  = new Mesaj(uid, conStr);

            Utilizator[] us = (Utilizator[])mesaj.GetReceivers().Result;
            Utilizator   s  = (Utilizator)mesaj.GetSender().Result;
            Nomenclator  n  = (Nomenclator)mesaj.GetTipMesaj().Result;
            DateTime?    da = (DateTime?)mesaj.GetMessageReadDate(uid).Result;
            Dosar        d  = new Dosar(uid, conStr, Convert.ToInt32(id));

            mv.MesajJson       = new MesajJson(mesaj, d, s, us, n, da);
            mv.InvolvedParties = (Utilizator[])d.GetInvolvedParties().Result;
            mv.TipuriMesaj     = (Nomenclator[])(new NomenclatoareRepository(uid, conStr).GetAll("tip_mesaje").Result);
            List <MesajJson> ls = new List <MesajJson>();

            Mesaj[] ms = null;

            if (id != null)
            {
                d  = new Dosar(uid, conStr, Convert.ToInt32(id));
                ms = (Mesaj[])d.GetMesaje().Result;
            }
            else
            {
                Utilizator u = (Utilizator)Session["CURENT_USER"];
                ms = (Mesaj[])u.GetMesaje(_START_LIMIT, _END_LIMIT).Result;
            }

            /*
             * foreach(Mesaj m in ms)
             * {
             *  //ls.Add(new MesajJson(m, (Dosar)m.GetDosar().Result, (Utilizator)m.GetSender().Result, (Utilizator[])m.GetReceivers().Result, (Nomenclator)m.GetTipMesaj().Result, (DateTime?)m.GetMessageReadDate(uid).Result));
             *  MesajJson mj = new MesajJson(m);
             *  mj.DataCitire = (DateTime?)m.GetMessageReadDate(uid).Result;
             *  ls.Add(mj);
             * }
             * mv.MesajeJson = ls.ToArray();
             */
            mv.MesajeJson = new MesajJson[ms.Length];
            for (int i = 0; i < ms.Length; i++)
            {
                mv.MesajeJson[i]            = new MesajJson(ms[i]);
                mv.MesajeJson[i].DataCitire = (DateTime?)ms[i].GetMessageReadDate(uid).Result;
            }

            //return PartialView("_MesajeView", mv);
            return(Json(mv, JsonRequestBehavior.AllowGet));
        }
Example #20
0
        public void WhenInsertingTwoIdenticalKeysWegetException()
        {
            var database = CreateTestTarget();

            var input1 = new Dosar {
                Id = 1, Code = "PI13232", Description = "Dosar intern 1"
            };
            var input2 = new Dosar {
                Id = 1, Code = "XXXX", Description = "XXXX1"
            };

            database.Insert(input1);
            database.Insert(input2);
        }
Example #21
0
        public void WhenDeletingWeRetrieveNull()
        {
            var database = CreateTestTarget();

            var input = new Dosar {
                Id = 1, Code = "PI13232", Description = "Dosar intern 1"
            };

            database.Insert(input);
            database.Delete(input.Id);

            var actual = database.Get <Dosar>(input.Id);

            Assert.IsNull(actual);
        }
Example #22
0
        public void WhenInsertingWeCanRetrieveSameProperties()
        {
            var database = CreateTestTarget();

            var expected = new Dosar {
                Id = 1, Code = "PI13232", Description = "Dosar intern 1"
            };

            database.Insert(expected);

            var actual = database.Get <Dosar>(expected.Id);

            Assert.IsNotNull(actual);
            actual.AssertAllPropertiesAreEqual(expected);
        }
Example #23
0
        public void WhenInsertingTwoDosareWeGetAllCount2()
        {
            var database = CreateTestTarget();

            var input1 = new Dosar {
                Id = 1, Code = "PI13232", Description = "Dosar intern 1"
            };
            var input2 = new Dosar {
                Id = 2, Code = "XXXX", Description = "XXXX1"
            };

            database.Insert(input1);
            database.Insert(input2);

            var actualAll = database.GetAll <Dosar>();

            Assert.AreEqual(2, actualAll.Count);
        }
Example #24
0
        /// <summary>
        /// Metoda pentru stergerea Documentului scanat curent
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Delete()
        {
            DocumentScanat tmp = new DocumentScanat(authenticatedUserId, connectionString, Convert.ToInt32(this.ID));

            response  toReturn    = new response(false, "", null, null, new List <Error>());;
            ArrayList _parameters = new ArrayList();

            _parameters.Add(new MySqlParameter("_ID", this.ID));
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_soft_delete", _parameters.ToArray());

            toReturn = da.ExecuteDeleteQuery();

            /*
             * if (toReturn.Status && _deleteFile)
             *  FileManager.DeleteFile(this.CALE_FISIER, this.DENUMIRE_FISIER, this.EXTENSIE_FISIER);
             */
            if (toReturn.Status)
            {
                try
                {
                    ThumbNails.DeleteThumbNail(tmp);
                    tmp = null;
                }
                catch { }
            }
            if (toReturn.Status)
            {
                /*
                 * try
                 * {
                 *  if (System.Web.HttpContext.Current.Request.Params["SEND_MESSAGE"] != null && Convert.ToBoolean(System.Web.HttpContext.Current.Request.Params["SEND_MESSAGE"]))
                 *      Mesaje.GenerateAndSendMessage(this.ID, DateTime.Now, "Document sters", Convert.ToInt32(System.Web.HttpContext.Current.Session["AUTHENTICATED_ID"]), (int)Mesaje.Importanta.Low);
                 * }
                 * catch { }
                 */
                try
                {
                    Dosar d = new Dosar(authenticatedUserId, connectionString, this.ID_DOSAR);
                    d.UpdateCounterDocumente(-1);
                }
                catch (Exception exp) { LogWriter.Log(exp); }
            }
            return(toReturn);
        }
Example #25
0
        public JsonResult GetNewMessages(string j, int?_START_LIMIT, int?_END_LIMIT)
        {
            dynamic x      = JsonConvert.DeserializeObject(j);
            string  conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int     uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);

            if (x.id_dosar != null)
            {
                DosareRepository dr = new DosareRepository(uid, conStr);
                Dosar            d  = (Dosar)dr.Find(Convert.ToInt32(x.id_dosar)).Result;
                //return Json(d.GetNewMesaje(Convert.ToDateTime(x.last_refresh)), JsonRequestBehavior.AllowGet);
                return(Json(d.GetNewMesaje(DateTime.ParseExact(Convert.ToString(x.last_refresh), CommonFunctions.DATE_TIME_FORMAT, System.Globalization.CultureInfo.InvariantCulture)), JsonRequestBehavior.AllowGet));
            }
            else
            {
                Utilizator u = (Utilizator)Session["CURENT_USER"];
                return(Json(u.GetNewMesaje(DateTime.ParseExact(Convert.ToString(x.last_refresh), CommonFunctions.DATE_TIME_FORMAT, System.Globalization.CultureInfo.InvariantCulture), _START_LIMIT, _END_LIMIT), JsonRequestBehavior.AllowGet));
            }
        }
Example #26
0
        public response MovePendingToOk()
        {
            response toReturn = new response(false, "", null, null, new List <Error>());;

            try
            {
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_MovePendingToOk", new object[] { new MySqlParameter("_PENDING_ID", ID) });
                toReturn = da.ExecuteInsertQuery();
                if (toReturn.Status && Convert.ToInt32(toReturn.InsertedId) > 0)
                {
                    Plata newPlata = new Plata(authenticatedUserId, connectionString, Convert.ToInt32(toReturn.InsertedId));
                    Dosar d        = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(newPlata.ID_DOSAR));
                    d.REZERVA_DAUNA -= this.SUMA;
                    d.GetNewStatus(false);
                    response r = d.Update();
                }
            }
            catch { }
            return(toReturn);
        }
Example #27
0
        public JsonResult Edit(UtilizatorDosar[] UtilizatoriDosare)
        {
            response toReturn       = new response(true, "", null, null, new List <Error>());
            string   conStr         = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int      curent_user_id = Convert.ToInt32(Session["CURENT_USER_ID"]);

            foreach (UtilizatorDosar udP in UtilizatoriDosare)
            {
                Dosar           d  = new Dosar(curent_user_id, conStr, udP.ID_DOSAR);
                UtilizatorDosar ud = new UtilizatorDosar(curent_user_id, conStr);
                ud.ID_UTILIZATOR = udP.ID_UTILIZATOR;
                ud.ID_DOSAR      = udP.ID_DOSAR;
                response r = ud.Insert();
                if (!r.Status)
                {
                    toReturn.AddResponse(r);
                }
                else
                {
                    Mesaj    m  = new Mesaj(curent_user_id, conStr, ud.ID_DOSAR, DateTime.Now, String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), "DOSAR NOU", curent_user_id, (int)Importanta.Low);
                    response rm = m.Insert();
                    if (rm.Status && rm.InsertedId != null)
                    {
                        m.ID = rm.InsertedId;
                        MesajUtilizator mu = new MesajUtilizator(curent_user_id, conStr);
                        mu.ID_MESAJ      = Convert.ToInt32(m.ID);
                        mu.ID_UTILIZATOR = ud.ID_UTILIZATOR;
                        response rmu = mu.Insert();
                        if (!rmu.Status)
                        {
                            toReturn.AddResponse(rmu);
                        }
                    }
                    else
                    {
                        toReturn.AddResponse(rm);
                    }
                }
            }
            return(Json(toReturn, JsonRequestBehavior.AllowGet));
        }
Example #28
0
        public void WhenUpdatingWeRetrieveSameThing()
        {
            var database = CreateTestTarget();

            var initialInput = new Dosar {
                Id = 1, Code = "PI13232", Description = "Dosar intern 1"
            };

            database.Insert(initialInput);

            var expected = new Dosar {
                Id = 1, Code = "PI13232555", Description = "Dosar intern 1555"
            };

            database.Update(expected);

            var actual = database.Get <Dosar>(expected.Id);

            Assert.IsNotNull(actual);
            actual.AssertAllPropertiesAreEqual(expected);
        }
Example #29
0
        public response Delete()
        {
            response  toReturn    = new response(false, "", null, null, new List <Error>());;
            ArrayList _parameters = new ArrayList();

            _parameters.Add(new MySqlParameter("_ID", this.ID));
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_soft_delete", _parameters.ToArray());

            toReturn = da.ExecuteDeleteQuery();
            if (toReturn.Status)
            {
                try
                {
                    Dosar d = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.UpdateCounterPlati(-1);
                }
                catch (Exception exp) { LogWriter.Log(exp); }

                try
                {
                    Dosar d = new Dosar(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.REZERVA_DAUNA += this.SUMA;
                    d.GetNewStatus(false);
                    response r = d.Update();
                    if (!r.Status)
                    {
                        toReturn = r;
                    }
                }
                catch (Exception exp)
                {
                    toReturn = new response(false, exp.ToString(), null, null, new List <Error>()
                    {
                        new Error(exp)
                    });
                    LogWriter.Log(exp);
                }
            }
            return(toReturn);
        }
Example #30
0
 public response GetBucketList(int _idGiver, int _idReceiver, DateTime _data) // Giver = societatea RCA / Receiver = societatea CASCO
 {
     try
     {
         DataAccess            da         = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "COMPENSARIsp_GetBucketDosare", new object[] { new MySqlParameter("_ID_SOCIETATE_CASCO", _idReceiver), new MySqlParameter("_ID_SOCIETATE_RCA", _idGiver), new MySqlParameter("_DATA", _data) });
         List <BucketListItem> BucketList = new List <BucketListItem>();
         MySqlDataReader       r          = da.ExecuteSelectQuery();
         while (r.Read())
         {
             Dosar          d    = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(r["ID_DOSAR"]));
             double         suma = Convert.ToDouble(r["SUMA"]);
             BucketListItem bli  = new BucketListItem(d, suma);
             BucketList.Add(bli);
         }
         r.Close(); r.Dispose(); da.CloseConnection();
         return(new response(true, JsonConvert.SerializeObject(BucketList, CommonFunctions.JsonSerializerSettings), BucketList, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }