public static List <ElementDTO> getUserElements(string user_id, string isEnabled)
        {
            List <ElementDTO> elements = new List <ElementDTO>();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_userElements", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@user_id", SqlDbType.Int);
                command.Parameters["@user_id"].Value = user_id;
                command.Parameters.Add("@isEnabled", SqlDbType.Bit);
                command.Parameters["@isEnabled"].Value = isEnabled;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    ElementDTO element = new ElementDTO();
                    element.id_element = rdr["id_element"].ToString();
                    element.name       = rdr["name"].ToString();
                    element.type       = rdr["type"].ToString();
                    elements.Add(element);
                }
            };
            return(elements);
        }
Exemple #2
0
        private async void GetRowsForEachTable(ElementDTO element)
        {
            try
            {
                InnonAnalyticsEngineEntities _dbContext2 = new InnonAnalyticsEngineEntities();
                this.EventLog.WriteEntry("Start For Table " + element.Source_Element_Name_History, EventLogEntryType.Information);
                IRawDataRepository _rawDataRepository = new RawDataRepository();
                //IList<RawDataDTO> rawdata =
                Point_Measure_Fact_Service point_measure_fact_service;
                await Task.Run(() => _rawDataRepository.GetRowData(element.Source_Element_Name_History, Convert.ToDateTime("2013-05-16 05:45:00"), Convert.ToDateTime("2013-05-16 05:45:00"), _dto_connector, _dbContext2))
                .ContinueWith((x) =>
                {
                    this.EventLog.WriteEntry("Get Rows for Table " + element.Source_Element_Name_History + " - " + x.Result.Count(), EventLogEntryType.Information);

                    point_measure_fact_service = new Point_Measure_Fact_Service();

                    try
                    {
                        point_measure_fact_service.Save_Point_Measure_Fact_Service(x.Result, element);
                    }
                    catch (Exception ex)
                    {
                        this.EventLog.WriteEntry("Error " + ex + " -----  " + element.ElementSourceName);
                    }
                });

                //this.EventLog.WriteEntry("Get Rows for Table " + element.Source_Element_Name_History + " - " + rawdata.Count(), EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                this.EventLog.WriteEntry("Error while getting the GetRowsForEachTable with table " + element.Source_Element_Name_History + " Connection " + _dto_connector.DatabaseName + " - Error" + ex.Message + " - Inner exception " + ex.InnerException, EventLogEntryType.Error);
            }
        }
        //start of interface implementation
        public void AddNewWeapon(WeaponDTO model)
        {
            System.Diagnostics.Debug.WriteLine("inside Add new weapon of WeaponService");
            bool hasElement = false;

            if (model.Element.ToLower() != "none")
            {
                hasElement = true;
            }
            //check if weapon has element
            //find element id
            //add new Equipment_element
            if (ValidateWeaponAttributes(model))
            {
                _weaponRepo.AddNewWeaponToDb(model);
            }


            if (hasElement)
            {
                //int weaponId = _weaponRepo.GetWeapon(model.Name).WeaponId;
                ElementDTO equipElement = new ElementDTO();

                if (ValidateElementProperty(0, model.Element, model.ElementDamage, equipElement))
                {
                    _equipmentElementRepo.AddNewEquipmentElement(0, equipElement);
                }
            }
            //check is weapon has element and if element name exists
            //find if  element name exists in element DB

            // _equipmentElementRepo.AddNewEquipmentElement(model.Name, model.Element, model.ElementDamage);
        }
        private IList <ElementDTO> SelectAll_Element_By_ElementIDs(IList <Point> points)
        {
            IEnumerable <long> ElementIDs = points.Select(n => n.ElementId);
            List <tblElement>  elements   = _dbcontext.tblElements.Where(c => ElementIDs.Contains(c.ID)).ToList();

            return(ElementDTO.ConvertTableListToDTOList(elements));
        }
Exemple #5
0
        // ----------------------------------------------------- Updates --------------------------------------
        public static bool updateRoleElement(ElementDTO pElementDTO)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_update_roleElement", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add("@element_id", SqlDbType.Int);
                command.Parameters["@element_id"].Value = pElementDTO.id_element;

                command.Parameters.Add("@role_permission_id", SqlDbType.Int);
                command.Parameters["@role_permission_id"].Value = pElementDTO.role_permission_id;

                command.Parameters.Add("@isEnabled", SqlDbType.Bit);
                command.Parameters["@isEnabled"].Value = pElementDTO.isEnabled;

                command.Connection.Open();
                int result = command.ExecuteNonQuery();
                if (result != 0)
                {
                    return(true);
                }
                return(false);
            };
        }
Exemple #6
0
        public ElementDTO UpdateElement(ElementDTO elementDto)
        {
            if (elementDto == null)
            {
                throw new ElementException(Resources.ElementPointNotFound);
            }

            tblElement element = _dbcontext.tblElements.SingleOrDefault(e => e.ID == elementDto.ID);

            if (element != null)
            {
                try
                {
                    ElementDTO.ConvertDTOToTable(elementDto, ref element);
                    _dbcontext.SaveChanges();

                    //Refresh dbcontext
                    _dbcontext             = new InnonAnalyticsEngineEntities();
                    element                = _dbcontext.tblElements.SingleOrDefault(e => e.ID == elementDto.ID);
                    element.tblTagElements = element.tblTagElements.Where(d => d.Is_Deleted == false).ToList();
                    return(ElementDTO.ConvertTableToDTO(element));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                throw new ElementException(Resources.ElementPointNotFound);
            }
        }
Exemple #7
0
        public static List <ElementDTO> getElements(string id_rolePermission)
        {
            List <ElementDTO> modules = new List <ElementDTO>();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_Elements", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@role_permission_id", SqlDbType.Int);
                command.Parameters["@role_permission_id"].Value = id_rolePermission;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    ElementDTO elementDTO = new ElementDTO();
                    elementDTO.role_permission_id = rdr["role_permission_id"].ToString();
                    elementDTO.name       = rdr["name"].ToString();
                    elementDTO.isEnabled  = rdr["isEnabled"].ToString();
                    elementDTO.type       = rdr["type"].ToString();
                    elementDTO.id_element = rdr["element_id"].ToString();
                    modules.Add(elementDTO);
                }
            };
            return(modules);
        }
Exemple #8
0
        // Recupera os objetos "element" pertencentes ao workflow especificado
        public List <ElementDTO> RetrieveElements(int workflowId)
        {
            List <ElementDTO> elementList = new List <ElementDTO>();

            String          query      = "SELECT * FROM `flowManager`.`element` WHERE owner=" + workflowId;
            MySqlCommand    command    = new MySqlCommand(query, this.mySqlConnection);
            MySqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                ElementDTO element = new ElementDTO();
                element.id          = (int)dataReader["id"];
                element.owner       = (int)dataReader["owner"];
                element.name        = (String)dataReader["name"];
                element.enabled     = (Boolean)dataReader["enabled"];
                element.elementType = (String)dataReader["elementType"];
                element.left        = (int)dataReader["left"];
                element.top         = (int)dataReader["top"];
                element.width       = (int)dataReader["width"];
                element.height      = (int)dataReader["height"];

                elementList.Add(element);
            }
            dataReader.Close();

            return(elementList);
        }
Exemple #9
0
        public IActionResult Post([FromForm] ElementDTO el)
        //public IActionResult Post([FromForm] IFormCollection el)
        {
            tblelement element = new tblelement();

            try
            {
                // 上传图片到七牛云
                string  fileName    = Guid.NewGuid().ToString() + ".png";
                dynamic type        = (new Program()).GetType();
                string  imgTempPath = Path.GetDirectoryName(type.Assembly.Location) + "\\" + fileName;

                //var photoBytes = Convert.FromBase64String(image);
                System.IO.File.WriteAllBytes(imgTempPath, el.file);

                //Bitmap imgFile = Base64StringToImage(el.file);
                //imgFile.Save(imgTempPath,ImageFormat.Png);
                //var stream = new FileStream(imgTempPath, FileMode.CreateNew);
                //el.Files[0].CopyTo(stream);
                //stream.Dispose();
                HttpResult res = UploadFile(imgTempPath, fileName);
                if (res.Code != 200)
                {
                    return(Ok(new ApiResultMutilObject <tblelement>()
                    {
                        code = EnumError.NET_FRE_UPLOADQINIU_ERROR,
                        message = "NET_FRE_UPLOADQINIU_ERROR"
                    }));
                }

                // 保存记录

                element.mtitle = el.title;
                element.mdesc  = el.desc;
                element.mhtml  = el.html;
                element.mcss   = el.css;
                element.mtype  = el.type;
                element.userid = el.userid;
                element.mimg   = fileName;

                MElementRepository.AddElement(element);
                System.IO.File.Delete(imgTempPath);
            }
            catch (Exception ex)
            {
                return(Ok(new ApiResultSingleObject <tblelement>()
                {
                    code = EnumError.NET_FRE_UNKNOWN_ERROR,
                    message = "NET_FRE_UNKNOWN_ERROR",
                }));
            }

            return(Ok(new ApiResultSingleObject <tblelement>()
            {
                code = EnumError.SUCCESS,
                message = "SUCCESS",
                data = element
            }));
        }
 public IHttpActionResult updateRoleElement(ElementDTO pElementDTO)
 {
     if (!RolesData.updateRoleElement(pElementDTO))
     {
         return(BadRequest());
     }
     return(Ok());
 }
Exemple #11
0
        public IList <ElementDTO> GetElementByConnectionID(int connectionID)
        {
            ICollection <tblElement> elements = (from e in _dbcontext.tblElements
                                                 where e.Connector_History_ID == connectionID || e.Connector_Live_ID == connectionID
                                                 select e).ToList();

            return(ElementDTO.ConvertTableListToDTOList(elements));
        }
Exemple #12
0
        public IList <ElementDTO> GetElementsByID(long?elementID)
        {
            ICollection <tblElement> elements = (from e in _dbcontext.tblElements
                                                 where (elementID.HasValue ? e.Parent_Element_ID == elementID : e.Parent_Element_ID == null)
                                                 select e).ToList();

            return(ElementDTO.ConvertTableListToDTOList(elements));
        }
Exemple #13
0
 private Element ElementMapper(ElementDTO model)
 {
     return(new Element()
     {
         ElementId = model.ElementId,
         Name = model.Name
     });
 }
Exemple #14
0
        public void AddNewElement(ElementDTO model)
        {
            if (model != null && model.Name != "")
            {
                GetAllElements().Where(x => x.Name == model.Name);
            }

            _db.Elements.Add(ElementMapper(model));
        }
        public ActionResult SubmitForm(FormCollection form)
        {
            string ico = (string)Session["ico"];
            string id  = (string)Session["id"];
            List <SpecifiedElementDTO> specified_elements = (List <SpecifiedElementDTO>)Session["specified_elements"];

            if (String.IsNullOrEmpty(ico))
            {
                return(new HttpUnauthorizedResult("Access denied."));
            }
            if (String.IsNullOrEmpty(id))
            {
                return(new HttpUnauthorizedResult("Access denied."));
            }
            if (specified_elements == null)
            {
                Session["id"] = null;
                return(RedirectToAction("Buildings"));
            }

            List <string> names = new List <string>();

            specified_elements.ForEach(element => names.Add(element.Name));

            List <ElementDTO> elementDTOs = new List <ElementDTO>();

            foreach (string element_name in names)
            {
                ElementDTO elementDTO = new ElementDTO()
                {
                    Name               = element_name,
                    State              = Request.Form[element_name + "_state"],
                    NeedOfInvestment   = Request.Form[element_name + "_need of investment"],
                    AmountOfInvestment = Request.Form[element_name + "_amount of investment"],
                    Notes              = Request.Form[element_name + "_notes"]
                };
                elementDTOs.Add(elementDTO);
            }

            PasportDTO pasport = new PasportDTO()
            {
                FinalInspection = form["final_inspection"],
                ID       = id,
                Elements = elementDTOs
            };

            Session["id"] = null;
            Session["specified_elements"] = null;
            int state;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                state = Database.InsertPasport(pasport, connection);
            }
            return(RedirectToAction("FormSent", new { state = state }));
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element_tag_type">This is enum,   site =1, equip = 2, point=3,       extendedpoint=4, // Extended Point is not belongs to haystake, this our extended Tag type department = 5, floor = 6,  utilities = 7,  zone = 8</param>
        /// <param name="Is_Disabled">If is Is_Disabled is true it mean return all the disabled elements </param>
        /// <returns></returns>
        public IList <ElementDTO> Get_Element_By_Element_Tag_Type(TagType element_tag_type, bool Is_Disabled)
        {
            ICollection <tblElement> elements = _dbcontext.tblElements.Include("tblTagElements").Where(element => element.Element_Tag_Type == element_tag_type.ToString() && element.Is_Disabled == Is_Disabled).ToList();

            //Filter TagElement Table only not deleted
            foreach (var element in elements)
            {
                element.tblTagElements = element.tblTagElements.Where(d => d.Is_Deleted == false).ToList();
            }
            return(ElementDTO.ConvertTableListToDTOList(elements));
        }
Exemple #17
0
        public void Add(ElementDTO element)
        {
            var elementDb = new Element {
                Id     = element.Id,
                Active = element.Active,
                Code   = element.Code,
                Name   = element.Name
            };

            _dbContext.Set <Element>().Add(elementDb);
            _dbContext.SaveChanges();
        }
Exemple #18
0
 private static IList <RawDataDTO> GetRawData(ElementDTO element, DateTime fromdate, DateTime ToDate, ConnectorDTO _dto_connector, InnonAnalyticsEngineEntities _dbcontext)
 {
     try
     {
         IRawDataRepository _rawDataRepository = new RawDataRepository();
         return(_rawDataRepository.GetRowData(element.Source_Element_Name_History, Convert.ToDateTime(fromdate.ToString("yyyy-MM-dd HH:mm:ss.fff")), Convert.ToDateTime(ToDate.ToString("yyyy-MM-dd HH:mm:ss.fff")), _dto_connector, _dbcontext));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #19
0
        public IList <ElementDTO> GetElement()
        {
            ICollection <tblElement> elements = (from e in _dbcontext.tblElements.Include("tblTagElements")
                                                 select e).ToList();

            //Filter TagElement Table get not deleted tagselement
            foreach (var element in elements)
            {
                element.tblTagElements = element.tblTagElements.Where(d => d.Is_Deleted == false).ToList();
            }

            return(ElementDTO.ConvertTableListToDTOList(elements));
        }
        public ActionResult _UpdateRoleElement(string role_permission_id, string id_element, string isEnabled)
        {
            ElementDTO elementDTO = new ElementDTO();

            elementDTO.role_permission_id = role_permission_id;
            elementDTO.id_element         = id_element;
            elementDTO.isEnabled          = isEnabled;
            if (roleProvider.putRoleElement(elementDTO).Result)
            {
                return(new HttpStatusCodeResult(200));
            }
            return(new HttpStatusCodeResult(404, "Can't find that"));
        }
Exemple #21
0
        /// <summary>
        /// This function is used for generating the missing data when the data is not in the Datasource, for prevent the spikes
        /// This function only when the data 15 mins difference
        /// </summary>
        private static IList <RawDataDTO> GenerateMissingData(ElementDTO element)
        {
            IList <RawDataDTO> rawdata = new List <RawDataDTO>();

            InnonAnalyticsWarehouseEntities ctx = new InnonAnalyticsWarehouseEntities();

            ctx.Database.CommandTimeout = 300;
            double   days = double.Parse(ConfigurationManagerHelper.AppSettings["missing_data_days"].ToString());
            DateTime dt   = DateTime.Now.AddDays(-days);
            List <Point_Measure_Fact> point_measure_fact = ctx.Point_Measure_Fact.Where(point_measure_Fact =>
                                                                                        point_measure_Fact.Point_ID == element.ID && point_measure_Fact.Timestamp_From >= dt).OrderBy(order => order.Timestamp_From).ToList();
            TimeSpan ts;
            DateTime Previous_DateTime;
            DateTime Current_DateTime;
            int      External_ID;
            double   minute_difference = 0;

            for (int i = 0; i < point_measure_fact.Count; i++)
            {
                if (i > 0)
                {
                    ts = point_measure_fact[i].Timestamp_From.Subtract(point_measure_fact[i - 1].Timestamp_From);
                    minute_difference = Math.Truncate(ts.TotalMinutes);
                    if (minute_difference > 15)
                    {
                        //Get the previous record from the point_measure_fact table and add "minus sign" with ID to make it unique.
                        External_ID       = -point_measure_fact[i - 1].ID; //We need unique External ID (In normal case External_ID is the ID from the Datasource Table ID, But here we are generating the missing data we need Unique External ID).
                        Previous_DateTime = new DateTime(point_measure_fact[i - 1].Timestamp_From.Year, point_measure_fact[i - 1].Timestamp_From.Month, point_measure_fact[i - 1].Timestamp_From.Day, point_measure_fact[i - 1].Timestamp_From.Hour, point_measure_fact[i - 1].Timestamp_From.Minute, 0);
                        Current_DateTime  = new DateTime(point_measure_fact[i].Timestamp_From.Year, point_measure_fact[i].Timestamp_From.Month, point_measure_fact[i].Timestamp_From.Day, point_measure_fact[i].Timestamp_From.Hour, point_measure_fact[i].Timestamp_From.Minute, 0);

                        for (DateTime dtfrom = Previous_DateTime.AddMinutes(15); dtfrom < Current_DateTime; dtfrom = dtfrom.AddMinutes(15))
                        {
                            if (element.Value_Type == DataValueType.Totalised)
                            {
                                rawdata.Add(new RawDataDTO {
                                    ID = External_ID--, STATUS_TAG = "{fault,down,stale}", TIMESTAMP = dtfrom, VAL = 0, VALUE = point_measure_fact[i - 1].Raw_Value
                                });
                            }
                            else
                            {
                                rawdata.Add(new RawDataDTO {
                                    ID = External_ID--, STATUS_TAG = "{fault,down,stale}", TIMESTAMP = dtfrom, VAL = point_measure_fact[i - 1].Raw_Value, VALUE = point_measure_fact[i - 1].Raw_Value
                                });
                            }
                        }
                    }
                }
            }

            return(rawdata);
        }
Exemple #22
0
        public void AddNewEquipmentElement(int weaponId, ElementDTO element)
        {
            System.Diagnostics.Debug.WriteLine("insdie add new element");
            System.Diagnostics.Debug.WriteLine(element.ElementId);
            System.Diagnostics.Debug.WriteLine(element.ElementDamage);
            System.Diagnostics.Debug.WriteLine(weaponId);

            //_db.EquipmentElement.Add(new EquipmentElement()
            //{
            //    WeaponId = weaponId,
            //    ElementId = element.ElementId,
            //    ElementDamange = element.ElementDamage
            //});
        }
Exemple #23
0
        private static tblDatawareHouseMigrationLog SaveDataMigrationLog(ElementDTO element, DateTime default_from_dt)
        {
            InnonAnalyticsEngineEntities _dbcontext2      = new InnonAnalyticsEngineEntities();
            tblDatawareHouseMigrationLog tblDataMigration = _dbcontext2.tblDatawareHouseMigrationLogs.Add(
                new tblDatawareHouseMigrationLog
            {
                Element_ID         = element.ID,
                Last_Run_Start     = System.DateTime.Now,
                Total_Record_Fetch = 0,
                Timestamp_From     = default_from_dt,
            });

            _dbcontext2.SaveChanges();
            return(tblDataMigration);
        }
Exemple #24
0
 private static void Delete_Duplicate(ElementDTO element)
 {
     try
     {
         Console.WriteLine("delete duplicate data " + element.ID + "--" + element.Source_Element_Name_History);
         DatawarehouseConnectionContext ctx_delete_duplicate = new DatawarehouseConnectionContext();
         ctx_delete_duplicate.Database.CommandTimeout = 300;
         ctx_delete_duplicate.Database.ExecuteSqlCommand("EXEC Delete_Duplicate_Data " + element.ID);
         ctx_delete_duplicate.Database.Connection.Close();
     }
     catch (Exception ex)
     {
         Helper.WriteToFile(" [ " + System.DateTime.Now + " ] remove duplicate data from error " + ex.Message + " -- " + element.ID + "--" + element.Source_Element_Name_History);
     }
 }
Exemple #25
0
 private static void Delete_Duplicate(ElementDTO element)
 {
     try
     {
         Console.WriteLine("Delete duplicate data " + element.ID + "--" + element.Source_Element_Name_History);
         InnonAnalyticsWarehouseEntities ctx_delete_duplicate = new InnonAnalyticsWarehouseEntities();
         ctx_delete_duplicate.Database.CommandTimeout = 300;
         ctx_delete_duplicate.Database.ExecuteSqlCommand("EXEC Delete_Duplicate_Data " + element.ID);
         ctx_delete_duplicate.Database.Connection.Close();
         Console.WriteLine("Finished delete duplicate data ");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #26
0
 public async Task <bool> putRoleElement(ElementDTO pElementDTO)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(_BaseAddress);
         var         userJson    = new JavaScriptSerializer().Serialize(pElementDTO);
         HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json");
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
         HttpResponseMessage response = client.PutAsync("api/roles/role/element/", contentPost).Result;
         if (response.IsSuccessStatusCode)
         {
             return(true);
         }
         return(false);
     }
 }
Exemple #27
0
        public void Store()
        {
            DataConnector dataConnector = new DataConnector();

            dataConnector.OpenConnection("mySql");

            WorkflowDAO workflowDAO = new WorkflowDAO(dataConnector.MySqlConnection);
            ElementDAO  elementDAO  = new ElementDAO(dataConnector.MySqlConnection);
            RelationDAO relationDAO = new RelationDAO(dataConnector.MySqlConnection);

            WorkflowDTO workflowDTO = new WorkflowDTO();

            workflowDTO.id   = this.id;
            workflowDTO.name = this.name;
            if (this.startElement != null)
            {
                workflowDTO.startElement = this.startElement.id;
            }
            if (this.finishElement != null)
            {
                workflowDTO.finishElement = this.finishElement.id;
            }
            this.id = (int)workflowDAO.StoreWorkflow(workflowDTO);

            foreach (FlowElement element in elements)
            {
                ElementDTO elementDTO = new ElementDTO();
                elementDTO.id          = element.id;
                elementDTO.owner       = this.id;
                elementDTO.name        = element.name;
                elementDTO.enabled     = element.enabled;
                elementDTO.elementType = element.elementType;

                elementDAO.StoreElement(elementDTO);
            }

            foreach (Relation relation in relations)
            {
                RelationDTO relationDTO = new RelationDTO();
                relationDTO.origin      = relation.origin.id;
                relationDTO.destinarion = relation.destination.id;

                relationDAO.StoreRelation(relationDTO);
            }

            dataConnector.CloseConnection();
        }
Exemple #28
0
 private static IList <RawDataDTO> GetRawMissingData(ElementDTO element, ConnectorDTO _dto_connector)
 {
     try
     {
         //Checking the missing data
         InnonAnalyticsWarehouseEntities ctx = new InnonAnalyticsWarehouseEntities();
         ctx.Database.CommandTimeout = 300;
         IList <RawDataDTO> rawdata = ctx.Database.SqlQuery <RawDataDTO>("EXEC GetRawMissingData '" + _dto_connector.ServerOrIP + "', '" +
                                                                         _dto_connector.ServerUserName + "' , '" + _dto_connector.ServerPassword + "', '" + _dto_connector.DatabaseName + "' , '" + element.Source_Element_Name_History + "' ,'" + Convert.ToDateTime(System.DateTime.Now.AddYears(-1).ToShortDateString() + " 00:00:00").ToString("yyyy-MM-dd HH:mm:ss.fff") + "','" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'," + element.ID).ToList();
         ctx.Database.Connection.Close();
         return(rawdata);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #29
0
        private IEnumerable <ElementDTO> ElementDTOMapper(IEnumerable <Element> modelList)
        {
            List <ElementDTO> newList = new List <ElementDTO>();

            ElementDTO tempElement;

            foreach (Element ele in modelList)
            {
                tempElement = new ElementDTO()
                {
                    ElementId = ele.ElementId,
                    Name      = ele.Name
                };

                newList.Add(tempElement);
            }

            return(newList.AsEnumerable <ElementDTO>());
        }
Exemple #30
0
        public Int64 StoreElement(ElementDTO element)
        {
            String commandText = "INSERT INTO `flowManager`.`element` VALUES(null, " + element.owner + ", '" + element.name + "', " + element.enabled + ", '" + element.elementType + "', " + element.left + ", " + element.top + ", " + element.width + ", " + element.height + ")";

            if (element.id != 0)
            {
                commandText = "UPDATE `flowManager`.`element` SET owner = " + element.owner + ", name = '" + element.name + "',enabled = " + element.enabled + ",  elementType = '" + element.elementType + "', `left` = " + element.left + ", top = " + element.top + ", width = " + element.width + ", height = " + element.height + " WHERE id = " + element.id;
            }
            commandText = commandText + ';' + Environment.NewLine + "SELECT LAST_INSERT_ID()";

            MySqlCommand command  = new MySqlCommand(commandText, this.mySqlConnection);
            Int64        insertId = (Int64)command.ExecuteScalar();

            if (element.id != 0)
            {
                insertId = element.id;
            }

            return(insertId);
        }