示例#1
0
 public bool createNewClass(string pClassName, string pCaption, string pClass_type
                            , string pSpatialRefrence, bool?RequieredPhoto)
 {
     try
     {
         Classes oClass = _DbContext.Classes.Create();
         oClass.Caption         = pCaption;
         oClass.Class_name      = pClassName;
         oClass.Class_type      = pClass_type;
         oClass.SpatialRefrence = pSpatialRefrence;
         oClass.Scale           = 5;
         oClass.FillColor       = "#4287f5";
         oClass.StrokColor      = "#2858a6";
         oClass.StrokWidth      = 2;
         oClass.Width           = 5;
         oClass.HasFlow         = false;
         oClass.RequieredPhoto  = RequieredPhoto;
         _DbContext.Classes.Add(oClass);
         _DbContext.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#2
0
        public bool insertSetting(SettingParameters pset_name, object value, string userName)
        {
            string set_name = pset_name.ToString();
            string type     = null;
            string set_val  = value.ToString();

            if (value.GetType() == typeof(string))
            {
                type = typeof(string).ToString();
            }
            else if (value.GetType() == typeof(DateTime))
            {
                type    = typeof(DateTime).ToString();
                set_val = ((DateTime)value).ToString("yyyyMMdd-H:mm:ss");
            }
            else if (value.GetType() == typeof(double))
            {
                type = typeof(double).ToString();
            }
            else if (value.GetType() == typeof(int))
            {
                type = typeof(int).ToString();
            }
            else if (value.GetType() == typeof(bool))
            {
                type = typeof(bool).ToString();
            }
            if (string.IsNullOrEmpty(type))
            {
                return(false);
            }

            try
            {
                if (_DbContext.TB_Setting.Where(a => a.SET_Key.ToUpper() == set_name.ToUpper() && (a.User_name == "SYSTEM" || a.User_name == userName.ToUpper())).Count() > 0)
                {
                    TB_Setting setting = _DbContext.TB_Setting.Where(a => a.SET_Key.ToUpper() == set_name.ToUpper()).First();
                    setting.Value     = _Cryptor.Encrypt(set_val);
                    setting.SET_Type  = type;
                    setting.User_name = userName.ToUpper();
                    _DbContext.SaveChanges();
                }
                else
                {
                    TB_Setting setting = new TB_Setting();
                    setting.Value     = _Cryptor.Encrypt(set_val);
                    setting.SET_Type  = type;
                    setting.SET_Key   = set_name.ToUpper();
                    setting.User_name = userName.ToUpper();
                    _DbContext.TB_Setting.Add(setting);
                    _DbContext.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#3
0
        public void LogError(Exception ex, string message)
        {
            var entity = new ErrorLogg();

            entity.DateOf   = DateTime.Now;
            entity.LogLevel = "Error";
            entity.Message  = message;
            entity.Stack    = ex.ToString();
            _Context.Set <ErrorLogg>().Add(entity);
            _Context.SaveChanges();
        }
示例#4
0
        public bool DeleteUniqueStyles(int pID)
        {
            try
            {
                UniqueStyle delStyle = new UniqueStyle()
                {
                    ID = pID
                };
                _DbContext.UniqueStyles.Attach(delStyle);
                _DbContext.UniqueStyles.Remove(delStyle);
                _DbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            { return(false); }
        }
示例#5
0
        public void InsertFeaturePic(string fileName,
                                     string userName,
                                     string caption,
                                     string className,
                                     int objectid
                                     )
        {
            Feature_Pic pic = _DbContext.Feature_Pic.Create();

            pic.Save_ID    = fileName;
            pic.USER_NAME  = userName;
            pic.Name_Of    = caption;
            pic.DateOf     = DateTime.Now;
            pic.Class_name = className;
            pic.Feature_ID = objectid;
            _DbContext.Feature_Pic.Add(pic);
            _DbContext.SaveChanges();
        }
示例#6
0
        public int createNewFields(int?Class_ID, string FIELD_Name,
                                   string FIELD_Type, string FIELD_Caption,
                                   int?Domain_ID, double?MAX_VALUE, double?MIN_VALUE, int?ORDER, bool?REQUIERD, string pDefVal)
        {
            Fields newField = _DbContext.Fields.Create();

            newField.Class_ID      = Class_ID;
            newField.FIELD_Name    = FIELD_Name;
            newField.FIELD_Type    = FIELD_Type;
            newField.FIELD_Caption = FIELD_Caption;
            newField.Domain_ID     = Domain_ID;
            newField.MAX_VALUE     = MAX_VALUE;
            newField.MIN_VALUE     = MIN_VALUE;
            newField.ORDER         = ORDER;
            newField.REQUIERD      = REQUIERD;
            newField.DEF_VAL       = pDefVal;
            _DbContext.Fields.Add(newField);
            _DbContext.SaveChanges();
            return(newField.ID);
        }
示例#7
0
        public bool LogUserLocation(string userName, double[] coords)
        {
            try
            {
                User_location userLocation = _DbContext.User_location.Create();
                userLocation.DateTime   = DateTime.Now;
                userLocation.User_name  = userName;
                userLocation.Coordinate = System.Data.Entity.Spatial.DbGeometry.FromText(string.Format("POINT({0} {1})", coords[0], coords[1]), 4326);
                _DbContext.User_location.Add(userLocation);
                _DbContext.SaveChanges();

                return(true);
            }
            catch { return(false); }
        }
示例#8
0
        public ActionResult Create(DataCollectorApp.Models.Enquete mClass)
        {
            //if (ModelState.IsValid)
            //{
            using (var ctx = new DataCollectorContext())
            {
                mClass.enCibleEnqueteID = 1;

                ctx.Enquete.Add(mClass);

                ctx.SaveChanges();
            }
            //}

            return(RedirectToAction("Liste"));
        }
示例#9
0
        public bool Log(string userName, string className, int objectid, string pActionOf, string pDataOf)
        {
            try
            {
                Update_Log log = _DbContext.Update_Log.Create();
                log.DateTime   = DateTime.Now;
                log.User_NAME  = userName;
                log.Class_name = className;
                log.Feature_ID = objectid;
                log.ActionOf   = pActionOf;
                log.DataOf     = pDataOf;
                _DbContext.Update_Log.Add(log);
                _DbContext.SaveChanges();

                return(true);
            }
            catch { return(false); }
        }
示例#10
0
        public int AddValueToDomain(string pDomainValue, int?pDomainId)
        {
            int oID = -1;

            try
            {
                Domain oDomain = _DbContext.Domain.Where(a => a.ID == pDomainId).First();
                if (oDomain != null)
                {
                    DomainValue oDomainValue = _DbContext.DomainValue.Create();
                    oDomainValue.Domain_ID = pDomainId;
                    oDomainValue.Value     = pDomainValue;
                    _DbContext.DomainValue.Add(oDomainValue);
                    oID = oDomainValue.ID;
                }
                _DbContext.SaveChanges();
            }
            catch
            {
                oID = -1;
            }
            return(oID);
        }