예제 #1
0
        public static Usuario VerificarUsuario(string password, int user)
        {
            try
            {
                var usuario = new Usuario();

                using (DBContext db = new DBContext())
                {
                    var check = Encrypt(password);
                    var pass = Decrypt(password);
                    var query = from u in db.Usuario
                                where u.idUsuario == user && u.senhaUsuario == pass
                                select u;
                    foreach (Usuario u in query)
                    {
                        usuario = u;
                    }
                }
                return usuario;
            }
            catch (Exception)
            {
                return null;
            }
        }
예제 #2
0
        public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            //if (graphDBType.IsAbstract)
            //{
            //    #region For abstract types, count all attribute idx of the subtypes

            //    UInt64 count = 0;

            //    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(graphDBType, false))
            //    {
            //        if (!aSubType.IsAbstract)
            //        {
            //            count += aSubType.GetUUIDIndex(dbContext.DBTypeManager).GetValueCount();
            //        }
            //    }

            //    return new Exceptional<IObject>(new DBUInt64(count));

            //    #endregion
            //}
            //else
            //{
                #region Return the count of idx values

                var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);

                return new Exceptional<IObject>(new DBUInt64(attributeIndex.GetValueCount()));

                #endregion
            //}
        }
예제 #3
0
        public static BomoUsuario VerificarUsuarioBomo(string password, string user)
        {
            try
            {
                var usuario = new BomoUsuario();

                DBContext db = new DBContext();

                //var check = Encrypt(password);
                var pass = Encrypt(password);
                var query = from u in db.BomoUsuario
                            where u.bomoCliente.email == user && u.senha == pass
                            select u;
                foreach (BomoUsuario u in query)
                {
                    usuario = u;
                }

                return usuario;
            }
            catch (Exception)
            {
                return null;
            }
        }
        public ActionResult AddBulletin(string packageid, FormCollection form)
        {
            SetMenuSelection("Apps");

            if (Session["UserID"] == null)
                return RedirectToAction("Login", "Home");

            DBContext db = new DBContext();
            ViewData["PackageID"] = packageid;

            if (form.Count > 0)
            {
                //create
                if (form["txtCreateTitle"] == string.Empty)
                {
                    ViewData["CreateStatus"] = "Title is required";
                    return View();
                }

                MetrixBulletinBoardAnnouncement mbba = new MetrixBulletinBoardAnnouncement();
                mbba.Message = form["editorCreate"];
                mbba.PackageID = packageid;
                mbba.Title = form["txtCreateTitle"];
                db.MetrixBulletinBoardAnnouncements.InsertOnSubmit(mbba);
                db.SubmitChanges();

                Response.Redirect("/Apps/Bulletin/" + packageid);
            }

            return View();
        }
예제 #5
0
        public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            if (attributeIndex is UUIDIndex)
            {
                return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true), "Aggregating attribute UUID is not implemented!"));
            }
            else
            {
                var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);

                // HACK: rewrite as soon as we have real attribute index keys
                if (attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count != 1)
                {
                    return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                }

                var typeAttr = graphDBType.GetTypeAttributeByUUID(attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.First());
                ADBBaseObject oneVal = typeAttr.GetADBBaseObjectType(dbContext.DBTypeManager);

                return new Exceptional<IObject>(attributeIndex.GetKeyValues(indexRelatedType, dbContext).AsParallel().Select(kv =>
                {
                    var mul = oneVal.Clone(kv.Key);
                    mul.Mul(oneVal.Clone(kv.Value.Count()));
                    return mul;

                }).Aggregate(oneVal.Clone(), (elem, result) => { result.Add(elem); return result; }));
            }
        }
예제 #6
0
        /// <summary>
        /// <seealso cref=" AAttributeAssignOrUpdate"/>
        /// </summary>
        public override Exceptional<IObject> GetValueForAttribute(DBObjectStream myDBObject, DBContext myDBContext, GraphDBType myGraphDBType)
        {
            if (AttributeIDChain.IsUndefinedAttribute)
            {
                return new Exceptional<IObject>(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value));
            }

            #region Simple value

            var dbType = AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager);
            if (AttributeIDChain.LastAttribute is SpecialTypeAttribute_UUID)
            {
                dbType = myDBContext.DBTypeManager.GetTypeByName(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value).ObjectName);//DBString.Name);
            }
            if (GraphDBTypeMapper.IsAValidAttributeType(dbType, AttributeAssignType, myDBContext, Value))
            {
                return new Exceptional<IObject>(GraphDBTypeMapper.GetGraphObjectFromType(AttributeAssignType, Value)); ;
            }
            else
            {
                return new Exceptional<IObject>(new Error_InvalidAttributeValue(AttributeIDChain.LastAttribute.Name, Value));
            }

            #endregion
        }
예제 #7
0
파일: NotInOperator.cs 프로젝트: Vadi/sones
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var result = myIndex.Contains(lookup, currentType, dbContext);
            if (result.Value)
            {
                var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);

                foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        if (!interestingUUIDs.Contains(aUUID))
                        {
                            yield return aUUID;
                        }
                    }
                }
            }
            else
            {
                foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
예제 #8
0
파일: DBTypeManager.cs 프로젝트: ipbi/sones
        public DBTypeManager(DBTypeManager dBTypeManager)
        {
            _DBContext                                      = dBTypeManager._DBContext;
            _UserID                                         = dBTypeManager._UserID;
            _DatabaseRootPath                               = dBTypeManager._DatabaseRootPath;
            _IGraphFSSession                                = dBTypeManager._IGraphFSSession;
            _ObjectLocationsOfAllUserDefinedDatabaseTypes   = dBTypeManager._ObjectLocationsOfAllUserDefinedDatabaseTypes;

            _SystemTypes                                    = dBTypeManager._SystemTypes;
            _BasicTypes                                     = dBTypeManager._BasicTypes;
            _GUIDTypeAttribute                              = dBTypeManager._GUIDTypeAttribute;

            //TODO: As soon as we have serialized Indices we can recomment these sections
            #region As soon as we have serialized Indices we can recomment these sections

            //_UserDefinedTypes                               = dBTypeManager._UserDefinedTypes;
            //_TypesNameLookUpTable                           = dBTypeManager._TypesNameLookUpTable;

            foreach (GraphDBType ptype in _SystemTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            foreach (GraphDBType ptype in _BasicTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            LoadUserDefinedDatabaseTypes(false);

            #endregion
        }
예제 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext">The TypeManager of the database.</param>
 public CommonUsageGraph(DBContext dbContext)
     : this()
 {
     _DBContext = dbContext;
     _DBObjectCache = _DBContext.DBObjectCache;
     _Levels = new Dictionary<int, IExpressionLevel>();
 }
        public ActionResult Login(FormCollection form)
        {
            if (form.Count > 0)
            {

                DBContext db = new DBContext();
                User u = (from t in db.Users
                          where t.Login == form[0] && t.Password == UtilCommand.GetMD5(form[1])
                          select t).FirstOrDefault();

                if (u == null)
                    return View();

                Session["UserID"] = u.ID;
                Session["UserTypes"] = u.UserUserTypes.ToList();
                Session["License"] = u.SignedLicense;

                if (u.AuthKey == null)
                {
                    if (u.UserUserTypes.Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() > 0)
                        return RedirectToAction("Apps", "Admin");
                    else
                        return RedirectToAction("List", "Apps");
                }
                else
                    return RedirectToAction("Authentication", "Profile");
            }

            return View();
        }
예제 #11
0
        public QueryResult Import(String location, IGraphDBSession graphDBSession, DBContext myDBContext, UInt32 parallelTasks = 1, IEnumerable<string> comments = null, UInt64? offset = null, UInt64? limit = null, VerbosityTypes verbosityType = VerbosityTypes.Errors)
        {
            IEnumerable<String> lines = null;

            #region Read querie lines from location

            try
            {
                if (location.ToLower().StartsWith(@"file:\\"))
                {
                    lines = ReadFile(location.Substring(@"file:\\".Length));
                }
                else if (location.ToLower().StartsWith("http://"))
                {
                    lines = ReadHttpResource(location);
                }
                else
                {
                    return new QueryResult(new Exceptional(new Error_InvalidImportLocation(location, @"file:\\", "http://")));
                }
            }
            catch (Exception ex)
            {
                return new QueryResult(new Exceptional(new Error_ImportFailed(ex)));
            }

            #endregion

            #region Start import using the AGraphDBImport implementation

            return Import(lines, graphDBSession, myDBContext, parallelTasks, comments, offset, limit, verbosityType);

            #endregion
        }
예제 #12
0
파일: ToUNIXDate.cs 프로젝트: TheByte/sones
        public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
        {
            Exceptional<FuncParameter> result = new Exceptional<FuncParameter>();

            if (CallingObject is DBUInt64)
            {
                try
                {
                    var dtValue = new DateTime(System.Convert.ToInt64(((DBUInt64)CallingObject).Value));
                    result.Value = new FuncParameter(new DBInt64(dtValue.ToUnixTimeStamp()));
                }
                catch (Exception e)
                {
                    return new Exceptional<FuncParameter>(new Error_UnknownDBError(e.Message));
                }

                return result;
            }
            else if (CallingObject is DBDateTime)
            {
                result.Value = new FuncParameter(new DBInt64(((DateTime)((DBDateTime)CallingObject).Value).ToUnixTimeStamp()));
            }
            else
            {
                Debug.Assert(false); // this should never happen due to the ValidateWorkingBase method
                return new Exceptional<FuncParameter>(new Error_FunctionParameterTypeMismatch(typeof(DBDateTime), CallingObject.GetType()));
            }

            return result;
        }
예제 #13
0
        public HttpResponseMessage Add(List<Gallery> items)
        {
            try
            {
                foreach (var item in items)
                {
                    List<string> content = item.Content.Split(',').ToList();
                    var bytes = Convert.FromBase64String(content[1]);
                    string mappath = HttpContext.Current.Server.MapPath("~/Assets/img/gallery/");
                    var filepath = Path.Combine(mappath, item.Name);
                    //string filepath = String.Format(mappath + "{0}", item.Name);
                    using (var imageFile = new FileStream(filepath, FileMode.Create))
                    {
                        imageFile.Write(bytes, 0, bytes.Length);
                        imageFile.Flush();
                    }

                    item.Content = String.Format("Assets/img/gallery/{0}", item.Name);
                }
                using (var db = new DBContext())
                {
                    db.Galleries.AddRange(items);
                    db.SaveChanges();
                    return Request.CreateResponse(HttpStatusCode.Accepted);
                }

            }
            catch (Exception ex)
            {
              return  Request.CreateResponse(HttpStatusCode.BadRequest,ex.Message);
            }
        }
예제 #14
0
        public ActionResult About()
        {
            AboutListViewModel aboutListViewModel = new AboutListViewModel();

            //add AboutViewModel
            List<AboutViewModel> listAVM = new List<AboutViewModel>();
            List<About> listAbout = new DBContext().Abouts.Where(a => a.IsDelete != true).OrderBy(a => a.Id).ToList();
            AboutViewModel AboutViewModel;
            foreach (var item in listAbout)
            {
                AboutViewModel = new AboutViewModel();
                AboutViewModel.Title = item.Title;
                AboutViewModel.Content = item.content;
                AboutViewModel.Thumbnail = item.Thumbnails;
                listAVM.Add(AboutViewModel);
            }
            aboutListViewModel.listAboutViewModel = listAVM;

            //Add Welcome
            Welcome welcome = new DBContext().Welcomes.Where(w => w.IsDelete != null).FirstOrDefault();
            if (welcome != null)
            {
                aboutListViewModel.WelcomeTitle = welcome.Title;
                aboutListViewModel.WelcomeContext = welcome.Content;
                aboutListViewModel.WelcomeBackground = welcome.Background;
                aboutListViewModel.WelcomeLinkVideo = welcome.LinkVideo;
            }
            return View(aboutListViewModel);
        }
        protected Exceptional RemoveBackwardEdges(TypeUUID myTypeUUID, Dictionary<AttributeUUID, object> myUserdefinedAttributes, ObjectUUID myObjectUUIDReference, DBContext myDBContext)
        {
            #region get type that carries the attributes

            var aType = myDBContext.DBTypeManager.GetTypeByUUID(myTypeUUID);

            #endregion

            #region process attributes

            foreach (var aUserDefinedAttribute in myUserdefinedAttributes)
            {

                #region Data

                GraphDBType typeOFAttribute = null;
                TypeAttribute attributesOfType = null;

                #endregion

                #region get GraphType of Attribute

                attributesOfType = aType.Attributes[aUserDefinedAttribute.Key];

                typeOFAttribute = myDBContext.DBTypeManager.GetTypeByUUID(attributesOfType.DBTypeUUID);

                #endregion

                IEnumerable<Exceptional<DBObjectStream>> listOfObjects;

                if (aUserDefinedAttribute.Value is IReferenceEdge)
                {
                    listOfObjects = ((IReferenceEdge)aUserDefinedAttribute.Value).GetAllEdgeDestinations(myDBContext.DBObjectCache);
                }
                else
                {
                    listOfObjects = myDBContext.DBObjectCache.LoadListOfDBObjectStreams(typeOFAttribute, (HashSet<ObjectUUID>)aUserDefinedAttribute.Value);
                }

                foreach (var aDBObject in listOfObjects)
                {
                    if (aDBObject.Failed())
                    {
                        return new Exceptional(aDBObject);
                    }

                    var removeExcept = myDBContext.DBObjectManager.RemoveBackwardEdge(aDBObject.Value, myTypeUUID, aUserDefinedAttribute.Key, myObjectUUIDReference);

                    if (removeExcept.Failed())
                    {
                        return new Exceptional(removeExcept);
                    }
                }

            }

            #endregion

            return Exceptional.OK;
        }
예제 #16
0
파일: Exists.cs 프로젝트: TheByte/sones
 public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
 {
     if (CallingObject != null)
         return new Exceptional<FuncParameter>(new FuncParameter(new DBBoolean(true)));
     else
         return new Exceptional<FuncParameter>(new FuncParameter(new DBBoolean(false)));
 }
예제 #17
0
        public ADBBaseObject GetValue(GraphDBType myTypeID, TypeAttribute myAttrID, UUID mySettingUUID, DBContext context)
        {
            if (_TypeAttrSetting.ContainsKey(myTypeID.UUID))
            {
                if (_TypeAttrSetting[myTypeID.UUID].ContainsKey(myAttrID.UUID))
                {
                    if (_TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].ContainsKey(mySettingUUID))
                    {
                        return _TypeAttrSetting[myTypeID.UUID][myAttrID.UUID][mySettingUUID];
                    }
                }
                else
                {
                    _TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
                }
            }
            else
            {
                _TypeAttrSetting.Add(myTypeID.UUID, new Dictionary<AttributeUUID, Dictionary<UUID, ADBBaseObject>>());
                _TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
            }

            //we are here, so we have to add the setting and return it

            var settingValue = context.DBSettingsManager.GetSettingValue(mySettingUUID, context, TypesSettingScope.ATTRIBUTE, myTypeID, myAttrID).Value.Clone();

            _TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].Add(mySettingUUID, settingValue);

            return settingValue;
        }
예제 #18
0
        public override Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var foundFirstMax = false;
            var aggregateResult = myTypeAttribute.GetADBBaseObjectType(myDBContext.DBTypeManager);
            foreach (var dbo in myDBObjects)
            {
                var attrResult = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attrResult.Failed())
                {
                    return attrResult;
                }
                var attr = attrResult.Value;

                if (attr != null && attr is ADBBaseObject && aggregateResult.IsValidValue((attr as ADBBaseObject).Value))
                {
                    if (foundFirstMax == false)
                    {
                        aggregateResult.Value = (attr as ADBBaseObject).Value;
                        foundFirstMax = true;
                    }
                    else
                    {
                        if (aggregateResult.CompareTo((attr as ADBBaseObject).Value) < 0)
                        {
                            aggregateResult.Value = (attr as ADBBaseObject).Value;
                        }
                    }
                }
                else
                {
                    return new Exceptional<IObject>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            return new Exceptional<IObject>(aggregateResult);
        }
예제 #19
0
        public async Task<IEnumerable<CvViewModel>> Get()
        {
            List<CvViewModel> cvs = new List<CvViewModel>();

            DirectoryInfo photoFolder = new DirectoryInfo(this.workingFolder);
            var db = new DBContext();
            var cvList = new List<CvViewModel>();

            await Task.Factory.StartNew(() =>
            {
                cvs = photoFolder.EnumerateFiles()
                                            .Where(fi => new[] { ".doc", ".pdf", ".docx", ".txt", ".rtf", ".odt" }.Contains(fi.Extension.ToLower()))
                                            .Select(fi => new CvViewModel
                                            {
                                                Name = fi.Name,                                                
                                                Created = fi.CreationTime,
                                                Modified = fi.LastWriteTime,
                                                Size = fi.Length / 1024
                                            })
                                            .ToList();
               
                foreach (var item in cvs)
	            {
                    // TODO check if Resume is deleted
                    var resume = db.CVs.FirstOrDefault(f => f.Name.Equals(item.Name, StringComparison.InvariantCultureIgnoreCase));
                    if (resume!= null)
                    {
                        item.Id = resume.Guid;
                        cvList.Add(item);
                    }
	            }
            });

            return cvList;
        }
예제 #20
0
        public override QueryResult Import(IEnumerable<String> myLines, IGraphDBSession myIGraphDBSession, DBContext myDBContext, UInt32 parallelTasks = 1, IEnumerable<String> comments = null, ulong? offset = null, ulong? limit = null, VerbosityTypes verbosityTypes = VerbosityTypes.Errors)
        {
            var gqlQuery = new GraphQLQuery(myDBContext.DBPluginManager);

            #region Evaluate Limit and Offset

            if (offset != null)
            {
                myLines = myLines.SkipULong(offset.Value);
            }
            if (limit != null)
            {
                myLines = myLines.TakeULong(limit.Value);
            }

            #endregion

            var queryResult = new QueryResult();

            #region Import queries

            if (parallelTasks > 1)
            {
                queryResult = ExecuteAsParallel(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, parallelTasks, comments);
            }
            else
            {
                queryResult = ExecuteAsSingleThread(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, comments);
            }

            #endregion

            return queryResult;
        }
예제 #21
0
        public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
        {
            var pResult = new Exceptional<FuncParameter>();

            // The edge we starting of (Friends)
            var typeAttribute = CallingAttribute;

            // Get the source Objects from the CallingObject, if this is not a reference this function is used in a wrong context and return a error
            IEnumerable<ObjectUUID> sourceDBOs = null;
            if (CallingObject is IReferenceEdge)
            {
                sourceDBOs = (CallingObject as ASetOfReferencesEdgeType).GetAllReferenceIDs();
            }
            else
            {
                throw new GraphDBException(new Error_InvalidEdgeType(CallingAttribute.EdgeType.GetType(), typeof(ASetOfReferencesEdgeType), typeof(ASingleReferenceEdgeType)));
            }

            // The destination DBObjects which are passed with the first parameter
            var destDBOs = (myParams[0].Value as DBEdge).GetDBObjects();
            if (destDBOs == null)
            {
                throw new GraphDBException(new Error_InvalidEdgeType(CallingAttribute.EdgeType.GetType(), typeof(ASetOfReferencesEdgeType), typeof(ASingleReferenceEdgeType)));
            }

            // The depth which is passed as the second parameter
            Int64 mayDepth = (myParams[1].Value as DBInt64).GetValue();

            // Call your own implementation of a path function and return the result, in this case it is a list of DB object (uuids)
            var resultOfPathFunction = new List<ObjectUUID>();

            pResult.Value = new FuncParameter(new EdgeTypeSetOfReferences(resultOfPathFunction, CallingAttribute.DBTypeUUID));

            return pResult;
        }
예제 #22
0
파일: AvgAggregate.cs 프로젝트: Vadi/sones
        public override Exceptional<FuncParameter> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var aggregateResult = new DBDouble(0d);
            var total = 0UL;

            foreach (var dbo in myDBObjects)
            {
                var attr = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attr.Failed())
                {
                    return new Exceptional<FuncParameter>(attr);
                }
                if (attr.Value != null && attr.Value is ADBBaseObject && aggregateResult.IsValidValue((attr.Value as ADBBaseObject).Value))
                {
                    aggregateResult.Add((attr.Value as ADBBaseObject));
                    total++;
                }
                else
                {
                    return new Exceptional<FuncParameter>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            aggregateResult.Div(new DBUInt64(total));

            return new Exceptional<FuncParameter>(new FuncParameter(aggregateResult));
        }
예제 #23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="myParams">The parameters which must match the _Parameters list defined in the constructor.</param>
        /// <returns>The Value of the GraphResult is of type FuncParameter. The TypeAttribute of FuncParameter will contain NOT NULL if the TypeOfResult is a DBReference or DBList</returns>
        public virtual Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
        {
            Boolean containsVariableNumOfParams = Parameters.Exists(p => p.VariableNumOfParams);

            #region check number of parameters

            if (Parameters.Count != myParams.Length && (!containsVariableNumOfParams))
            {
                return new Exceptional<FuncParameter>(new Error_FunctionParameterCountMismatch(this, Parameters.Count, myParams.Length));
            }
            else if (containsVariableNumOfParams && myParams.Length == 0)
            {
                return new Exceptional<FuncParameter>(new Error_FunctionParameterCountMismatch(this, Parameters.Count, myParams.Length));
            }

            #endregion

            #region check parameter types

            Int32 definedParamCounter = 0;
            for (Int32 i = 0; i < myParams.Count(); i++)
            {
                if (!Parameters[definedParamCounter].DBType.IsValidValue(((FuncParameter)myParams[i]).Value))
                {
                    return new Exceptional<FuncParameter>(new Error_FunctionParameterTypeMismatch(Parameters[definedParamCounter].DBType.GetType(), myParams[i].GetType()));
                }
                Parameters[definedParamCounter].DBType.SetValue(((FuncParameter)myParams[i]).Value);

                if (!Parameters[definedParamCounter].VariableNumOfParams) definedParamCounter++;
            }

            #endregion

            return new Exceptional<FuncParameter>();
        }
예제 #24
0
        public override IEnumerable<ObjectUUID> IndexOperation(AAttributeIndex myIndex, TupleDefinition myTuple, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            if (myTuple.Count() != 2)
            {
                throw new GraphDBException(new Error_InvalidInRangeInterval(2, myTuple.Count()));
            }

            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            #region As soon as the index supports ranges use them!!

            //limits
            var fromKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(0).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
            var toKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(1).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);

            switch (myTuple.KindOfTuple)
            {
                case KindOfTuple.Inclusive:
                    return myIndex.InRange(fromKey, toKey, true, true, currentType, dbContext);
                case KindOfTuple.LeftExclusive:
                    return myIndex.InRange(fromKey, toKey, false, true, currentType, dbContext);
                case KindOfTuple.RightExclusive:
                    return myIndex.InRange(fromKey, toKey, true, false, currentType, dbContext);
                case KindOfTuple.Exclusive:
                    return myIndex.InRange(fromKey, toKey, false, false, currentType, dbContext);
                default:
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
            }

            #endregion
        }
예제 #25
0
 public IQueryable<CompStore.Model.Employee> GridView1_GetData()
 {
     var db = new DBContext();
     IQueryable<CompStore.Model.Employee> result = from b in db.People.OfType<Employee>()
                                                   select b;
     return result;
 }
예제 #26
0
 public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
 {
     if (CallingObject is ADBBaseObject)
         return new Exceptional<FuncParameter>(new FuncParameter(new DBString((CallingObject as ADBBaseObject).Value.ToString().ToLower())));
     else
         return new Exceptional<FuncParameter>(new Errors.Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
 }
예제 #27
0
        public HttpResponseMessage AddServicosEmpresa([FromBody]JObject model)
        {
            try
            {
                dynamic json = model;
                List<EmpresaServico> listCadastrar = new List<EmpresaServico>();
                DBContext db = new DBContext();
                int idServico = 0;
                int idEmpresa = 0;
                idEmpresa = json.idEmpresa;
                json = model["Servicos"];
                foreach (var s in json)
                {
                    EmpresaServico es = new EmpresaServico();
                    idServico = s.idServico;
                    es.servico = db.Servico.Single(x => x.idServico == idServico);
                    es.empresa = db.Empresa.Single(x => x.idEmpresa == idEmpresa);
                    es.tempoServico = s.tempoServico == null ? 0 : s.tempoServico;
                    es.valorServico = s.valorServico == null ? 0 : s.valorServico;
                    db.EmpresaServico.Add(es);
                }

                db.SaveChanges();
                return Request.CreateResponse(HttpStatusCode.OK);

            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }
예제 #28
0
 public static List<WorkZoneListInfo> GetWorkZoneListSearch(int companyId, string WorkZoneName, string DateMin, string DateMax, string FactoryName,string MachineName)
 {
     if(DateMin==string.Empty)
         DateMin ="1/1/1973";
     if(DateMax ==string.Empty)
         DateMax ="12/31/2999";
     var context = new DBContext();
     return (from w in context.GetTable<WorkZone>()
                  from f in context.GetTable<Factory>()
                  from m in context.GetTable<Machine>()
                  where
                  w.CompanyId == companyId
                  && w.FactoryId == f.FactoryId
                  && w.MachineId == m.MachineId
                  && w.Name.Contains(WorkZoneName)
                  && f.Name.Contains(FactoryName)
                  && m.Name.Contains(MachineName)
                  && w.ProgramDate >= Convert.ToDateTime(DateMin)
                  && w.ProgramDate <= Convert.ToDateTime(DateMax)
                  select new
                  {
                      WorkZoneId = w.WorkZoneId,
                      Name = w.Name,
                      WorkZonePath = w.WorkZonePath,
                      ModelDataProgramer = w.ModelDataProgramer,
                      NCDataProgramer = w.NCDataProgramer,
                      ProgramDate = w.ProgramDate,
                      ModelName = w.ModelName,
                      Parts = w.Parts,
                      PartName = w.PartName,
                      MachiningTimeTotal = w.MachiningTimeTotal,
                      FactoryId = w.FactoryId,
                      FactoryName = f.Name,
                      MachineId = w.MachineId,
                      MachineName = m.Name,
                      Comment = w.Comment,
                      Status = w.Status,
                      ImageFile = w.ImageFile
                  }).AsEnumerable().Select(w => new WorkZoneListInfo
                 {
                     WorkZoneId = w.WorkZoneId,
                     Name = w.Name,
                     WorkZonePath = w.WorkZonePath,
                     ModelDataProgramer = w.ModelDataProgramer,
                     NCDataProgramer = w.NCDataProgramer,
                     ProgramDate = w.ProgramDate,
                     ModelName = w.ModelName,
                     Parts = w.Parts,
                     PartName = w.PartName,
                     MachiningTimeTotal = w.MachiningTimeTotal,
                     FactoryId = w.FactoryId,
                     FactoryName = w.FactoryName,
                     MachineId = w.MachineId,
                     MachineName = w.MachineName,
                     Status = w.Status,
                     Comment = w.Comment,
                     ImageFile = w.ImageFile
                 }).ToList();
 }
예제 #29
0
파일: DBTypeManager.cs 프로젝트: ipbi/sones
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="myIGraphDBSession">The filesystem where the information is stored.</param>
 /// <param name="DatabaseRootPath">The database root path.</param>
 public DBTypeManager(IGraphFSSession myIGraphFS, ObjectLocation myDatabaseRootPath, EntityUUID myUserID, Dictionary<String, ADBSettingsBase> myDBSettings, DBContext dbContext)
 {
     _DBContext = dbContext;
     _UserID = myUserID;
     _DatabaseRootPath                               = myDatabaseRootPath;
     _IGraphFSSession                                = myIGraphFS;
     _ObjectLocationsOfAllUserDefinedDatabaseTypes   = LoadListOfTypeLocations(myDatabaseRootPath);
 }
        protected Exceptional<IDictionary<String, IObject>> LoadUndefAttributes(String myName, DBContext dbContext, DBObjectStream myObjStream)
        {
            var loadExcept = myObjStream.GetUndefinedAttributePayload(dbContext.DBObjectManager);

            if (loadExcept.Failed())
                return new Exceptional<IDictionary<string, IObject>>(loadExcept);

            return new Exceptional<IDictionary<string, IObject>>(loadExcept.Value);
        }
예제 #31
0
 public PersonRepository(IConfiguration configuration, DBContext context)
 {
     _configuration = configuration;
     _context       = context;
 }
예제 #32
0
 public EDI315MsgParsing()
 {
     util    = new Util();
     context = new DBContext();
 }
 public EngineService()
 {
     logFile          = new LogFile();
     edi315MsgParsing = new EDI315MsgParsing();
     context          = new DBContext();
 }
        public JsonResult MonthlyGSTCalculateAmount(string MonthID = "", string ServiceName = "", string Year = "")
        {
            initpage();////
            if (MonthID != null)
            {
                var db       = new DBContext();
                int Monthval = 0;
                int.TryParse(MonthID, out Monthval);

                long serviceid = 0;


                //var serviceId = db.TBL_SERVICE_PROVIDERS.Where(x => x.ID == serviceid).Select(c => c.SERVICE_NAME).FirstOrDefault();

                var GSTValu12e = (from x in db.TBL_ACCOUNTS
                                  where x.MEM_ID == MemberCurrentUser.MEM_ID && x.TRANSACTION_DATE.Month == Monthval && x.DR_CR == "CR" && x.TRANSACTION_TYPE == ServiceName && x.MEMBER_TYPE == "SUPER DISTRIBUTOR" && x.NARRATION == "Commission"
                                  select new
                {
                    MEM_ID = x.MEM_ID,
                    TRANSACTION_TYPE = x.TRANSACTION_TYPE,
                    TRANSACTION_DATE = x.TRANSACTION_DATE,
                    AMOUNT = x.AMOUNT,
                    GST = x.GST,
                    GSTPERCENTAGE = x.GST_PERCENTAGE,
                    TDS = x.TDS,
                    TDSPERCENTAGE = x.TDS_PERCENTAGE,
                }).AsEnumerable().Select(z => new TBL_ACCOUNTS
                {
                    MEM_ID           = z.MEM_ID,
                    TRANSACTION_TYPE = z.TRANSACTION_TYPE,
                    timevalue        = z.TRANSACTION_DATE.ToString(),
                    //TRANSACTION_DATE = z.TRANSACTION_DATE,
                    AMOUNT         = z.AMOUNT,
                    GST            = z.GST,
                    GST_PERCENTAGE = z.GSTPERCENTAGE,
                    TDS            = z.TDS,
                    TDS_PERCENTAGE = z.TDSPERCENTAGE
                }).ToList().Distinct();
                var GSTValue = (from x in db.TBL_ACCOUNTS
                                where x.MEM_ID == MemberCurrentUser.MEM_ID && x.TRANSACTION_DATE.Month == Monthval && x.DR_CR == "CR" && x.TRANSACTION_TYPE == ServiceName && x.MEMBER_TYPE == "SUPER DISTRIBUTOR" && x.NARRATION == "Commission"
                                select new
                {
                    Operator = db.TBL_SERVICE_PROVIDERS.Where(d => d.ID == x.SERVICE_ID).Select(c => c.SERVICE_NAME).FirstOrDefault(),
                    COMMISSIONAMT = x.COMM_AMT
                }).Sum(c => (decimal?)c.COMMISSIONAMT) ?? 0;

                var getListGSTComm = db.TBL_ACCOUNTS.Where(x => x.MEM_ID == MemberCurrentUser.MEM_ID && x.TRANSACTION_DATE.Month == Monthval && x.DR_CR == "CR" && x.TRANSACTION_TYPE == ServiceName && x.MEMBER_TYPE == "SUPER DISTRIBUTOR" && x.NARRATION == "Commission").FirstOrDefault();

                TBL_ACCOUNTS objval = new TBL_ACCOUNTS()
                {
                    MEMBER_TYPE    = ServiceName,
                    COMM_AMT       = GSTValue,
                    timevalue      = DateTime.Now.ToString("dd-MM-yyyy"),
                    GST_PERCENTAGE = 18
                };


                return(Json(objval, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("There is no GST Available in this month", JsonRequestBehavior.AllowGet));
            }
        }
예제 #35
0
 public EreplacedTrainsController(DBContext context)
 {
     _context = context;
 }
예제 #36
0
 public AreaServices(DBContext context)
 {
     this.context = context;
 }
 public EDI315MsgParsing()
 {
     context = new DBContext();
 }
 public EtapTsiTransportOperationalIdentifierController(DBContext context)
 {
     _context = context;
 }
예제 #39
0
 public UserRepository(DBContext context)
 {
     this.db = context;
 }
예제 #40
0
 public EquipmentService(DBContext context)
 {
     _context = context;
 }
예제 #41
0
 public EngineService()
 {
     util             = new Util();
     edi315MsgParsing = new EDI315MsgParsing();
     context          = new DBContext();
 }
        public bool MeesageParsing(string msg_body, int msg_idnum)
        {
            bool result = false;

            try
            {
                #region Initialize values
                string[] msgBody;
                string[] rowLine;
                string   header;

                EDI315                  dbEDI315               = new EDI315();
                EDI315_Detail           dbEDI315_Detail        = new EDI315_Detail();
                List <EDI315_Detail_N9> dbEDI315_Detail_N9List = new List <EDI315_Detail_N9>();
                List <EDI315_Detail_R4> dbEDI315_Detail_R4List = new List <EDI315_Detail_R4>();

                int     convertToInt     = 0;
                decimal convertToDecimal = 0;
                #endregion

                msg_body = Regex.Replace(msg_body, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                msgBody  = msg_body.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

                foreach (string row in msgBody)
                {
                    if (row != null && row.Count() > 0)
                    {
                        rowLine = row.Split('*');

                        header = "";
                        if (EDI315_HEADERS.Any(x => x.ToUpper() == rowLine[0]))
                        {
                            header = rowLine[0];
                        }

                        switch (header)
                        {
                        case "ISA":
                            #region ISA
                            dbEDI315 = new EDI315()
                            {
                                msg_idnum = msg_idnum,
                                ISA_auth_info_qualifier                = rowLine[1] ?? "",
                                ISA_auth_info                          = rowLine[2] ?? "",
                                ISA_security_info_qualifier            = rowLine[3] ?? "",
                                ISA_security_info                      = rowLine[4] ?? "",
                                ISA_interchange_id_qualifier_1         = rowLine[5] ?? "",
                                ISA_interchange_sender_id              = rowLine[6] ?? "",
                                ISA_interchange_id_qualifier_2         = rowLine[7] ?? "",
                                ISA_interchange_receiver_id            = rowLine[8] ?? "",
                                ISA_interchage_date                    = rowLine[9] ?? "",
                                ISA_interchange_time                   = rowLine[10] ?? "",
                                ISA_interchange_control_standards_id   = rowLine[11] ?? "",
                                ISA_interchange_control_version_number = rowLine[12] ?? "",
                                ISA_interchange_control_number         = rowLine[13] ?? "",
                                ISA_ack_requested                      = rowLine[14] ?? "",
                                ISA_usage_indicator                    = rowLine[15] ?? "",
                                ISA_component_element_separator        = rowLine[16] ?? "",
                            };
                            #endregion
                            break;

                        case "GS":
                            // Table EDI315 insert here.
                            #region GS
                            dbEDI315.GS_functional_id_code = rowLine[1] ?? "";
                            dbEDI315.GS_app_sender_code    = rowLine[2] ?? "";
                            dbEDI315.GS_app_receiver_code  = rowLine[3] ?? "";
                            dbEDI315.GS_date = rowLine[4] ?? "";
                            dbEDI315.GS_time = rowLine[5] ?? "";
                            dbEDI315.GS_group_control_number   = rowLine[6] ?? "";
                            dbEDI315.GS_reponsible_agency_code = rowLine[7] ?? "";
                            dbEDI315.GS_industry_id_code       = rowLine[8] ?? "";

                            /* Insert table EDI315 after done with ISA & GS */

                            if (dbEDI315.msg_idnum != 0)
                            {
                                if (dbConnectionCheck())
                                {
                                    using (DBContext context = new DBContext())
                                    {
                                        /* check DB is open */

                                        dbEDI315.created_date = DateTime.Now;
                                        context.EDI315.Add(dbEDI315);
                                        context.SaveChanges();

                                        context.Dispose();
                                    }
                                }
                                else
                                {
                                    // not able to access DB
                                    //return false;
                                }
                            }

                            #endregion
                            break;

                        case "ST":
                            dbEDI315_Detail = new EDI315_Detail();

                            break;

                        case "SE":
                            // insert Table EDI315_Detail, EDI315_Detail_N9, EDI315_Detail_R4 & EDI315_Detail_R4_DTM
                            break;

                        case "B4":
                            #region B4
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            dbEDI315_Detail.B4_SHC = rowLine[1];

                            convertToInt = 0;
                            if (rowLine[2] != null && rowLine[2].Trim() != string.Empty && Int32.TryParse(rowLine[2], out convertToInt))
                            {
                                dbEDI315_Detail.B4_request_number = convertToInt;
                            }

                            dbEDI315_Detail.B4_status_code     = rowLine[3];
                            dbEDI315_Detail.B4_date            = rowLine[4] ?? "";
                            dbEDI315_Detail.B4_status_time     = rowLine[5] ?? "";
                            dbEDI315_Detail.B4_status_location = rowLine[6] ?? "";

                            dbEDI315_Detail.B4_equip_initial     = rowLine[7];
                            dbEDI315_Detail.B4_equip_number      = rowLine[8];
                            dbEDI315_Detail.B4_equip_status_code = rowLine[9];
                            dbEDI315_Detail.B4_equip_type        = rowLine[10];
                            dbEDI315_Detail.B4_location_code     = rowLine[11];
                            dbEDI315_Detail.B4_location_id       = rowLine[12];

                            if (rowLine.Count() > 13)
                            {
                                convertToInt = 0;
                                if (rowLine[13] != null && rowLine[13].Trim() != string.Empty && Int32.TryParse(rowLine[13], out convertToInt))
                                {
                                    dbEDI315_Detail.B4_equip_check_digit = convertToInt;
                                }
                            }
                            #endregion
                            break;

                        case "Q2":
                            #region Q2
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            dbEDI315_Detail.Q2_vessel_code  = rowLine[1];
                            dbEDI315_Detail.Q2_country_code = rowLine[2];
                            dbEDI315_Detail.Q2_date_1       = rowLine[3];
                            dbEDI315_Detail.Q2_date_2       = rowLine[4];
                            dbEDI315_Detail.Q2_date_3       = rowLine[5];

                            convertToInt = 0;
                            if (rowLine[6] != null && rowLine[6].Trim() != string.Empty && Int32.TryParse(rowLine[6], out convertToInt))
                            {
                                dbEDI315_Detail.Q2_lading_quantity = convertToInt;
                            }

                            convertToDecimal = 0;
                            if (rowLine[7] != null && rowLine[7].Trim() != string.Empty && Decimal.TryParse(rowLine[7], out convertToDecimal))
                            {
                                dbEDI315_Detail.Q2_weight = convertToDecimal;
                            }

                            dbEDI315_Detail.Q2_weight_qualifier       = rowLine[8];
                            dbEDI315_Detail.Q2_voyage_number          = rowLine[9];
                            dbEDI315_Detail.Q2_reference_id_qualifier = rowLine[10];
                            dbEDI315_Detail.Q2_reference_id           = rowLine[11];
                            dbEDI315_Detail.Q2_vessel_code_qualifier  = rowLine[12];
                            dbEDI315_Detail.Q2_vessel_name            = rowLine[13];

                            convertToDecimal = 0;
                            if (rowLine[14] != null && rowLine[14].Trim() != string.Empty && Decimal.TryParse(rowLine[14], out convertToDecimal))
                            {
                                dbEDI315_Detail.Q2_volume = convertToDecimal;
                            }

                            dbEDI315_Detail.Q2_volume_unit_qualifier = rowLine[15];
                            dbEDI315_Detail.Q2_weight_unit_code      = rowLine[16];
                            #endregion
                            break;

                        case "N9":
                            #region N9
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_N9 dbTemp = new EDI315_Detail_N9();

                                dbTemp.reference_id_qualifier = rowLine[1];

                                if (rowLine.Count() > 2)
                                {
                                    dbTemp.reference_id = rowLine[2];
                                }

                                if (rowLine.Count() > 3)
                                {
                                    dbTemp.free_form_description = rowLine[3];
                                }

                                if (rowLine.Count() > 4)
                                {
                                    dbTemp.free_form_description = rowLine[4];
                                }

                                if (rowLine.Count() > 5)
                                {
                                    dbTemp.date = rowLine[5];
                                }

                                if (rowLine.Count() > 6)
                                {
                                    dbTemp.time = rowLine[6];
                                }

                                if (rowLine.Count() > 7)
                                {
                                    dbTemp.time_code = rowLine[7];
                                }

                                dbEDI315_Detail_N9List.Add(dbTemp);
                            }
                            #endregion
                            break;

                        case "R4":
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_R4 dbTemp = new EDI315_Detail_R4();

                                dbTemp.Detail_R4_idnum = dbEDI315_Detail_R4List.Count() + 1;

                                dbTemp.port_function_code = rowLine[1];
                                if (rowLine.Count() > 2)
                                {
                                    dbTemp.location_qualifier = rowLine[2];
                                }

                                if (rowLine.Count() > 3)
                                {
                                    dbTemp.location_id = rowLine[3];
                                }

                                if (rowLine.Count() > 4)
                                {
                                    dbTemp.port_name = rowLine[4];
                                }

                                if (rowLine.Count() > 5)
                                {
                                    dbTemp.country_code = rowLine[5];
                                }

                                if (rowLine.Count() > 6)
                                {
                                    dbTemp.terminal_name = rowLine[6];
                                }

                                if (rowLine.Count() > 7)
                                {
                                    dbTemp.pier_number = rowLine[7];
                                }

                                if (rowLine.Count() > 8)
                                {
                                    dbTemp.province_code = rowLine[8];
                                }

                                dbEDI315_Detail_R4List.Add(dbTemp);
                            }
                            break;

                        case "DTM":
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_R4_DTM dbTemp = new EDI315_Detail_R4_DTM();

                                dbTemp.Detail_R4_idnum = dbEDI315_Detail_R4List.Count();

                                convertToInt = 0;
                                if (rowLine[1] != null && rowLine[1].Trim() != string.Empty && Int32.TryParse(rowLine[1], out convertToInt))
                                {
                                    dbEDI315_Detail.Q2_lading_quantity = convertToInt;
                                }
                                dbTemp.datetime_qualifier = rowLine[1];
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
예제 #43
0
 public SessionService(DBContext DbContext)
 {
     this.DbContext = DbContext;
 }
예제 #44
0
 public AudioRepository(DBContext dbctx) : base(dbctx)
 {
 }
예제 #45
0
        /// <summary>
        /// generate EC and other curves for a benchmark
        /// </summary>
        public static async Task <(EquityCurve equityCurve, Dictionary <DateTime, double> benchmarkSeries, List <double> benchmarkReturns)> GetBenchmarkReturns(
            int benchmarkID,
            DBContext context,
            List <DateTime> datesInPeriod,
            IDataSourcer dataSourcer)
        {
            Logger logger = LogManager.GetCurrentClassLogger();

            List <BenchmarkComponent> components = context.BenchmarkComponents.Where(x => x.BenchmarkID == benchmarkID).ToList();

            DateTime earliestDate = datesInPeriod[0].Date;
            DateTime latestDate   = datesInPeriod.Last();

            var data = new Dictionary <int, TimeSeries>();

            foreach (var component in components)
            {
                data.Add(component.QDMSInstrumentID,
                         new TimeSeries(await dataSourcer.GetExternalData(component.QDMSInstrumentID, earliestDate, latestDate).ConfigureAwait(true)));
            }


            Dictionary <int, decimal> weights = components.ToDictionary(x => x.QDMSInstrumentID, x => (decimal)x.Weight);

            var benchmarkSeries  = new Dictionary <DateTime, double>();
            var benchmarkReturns = new List <double>();
            var benchmarkEC      = new EquityCurve(1, null);

            decimal equity = 1;

            bool first = true;

            foreach (DateTime today in datesInPeriod)
            {
                decimal ret = 0;
                foreach (var kvp in data)
                {
                    var ts = kvp.Value;
                    ts.ProgressTo(today);
                    if (ts.CurrentBar > 0)
                    {
                        decimal todayClose = ts[0].AdjClose.HasValue ? ts[0].AdjClose.Value : ts[0].Close;
                        decimal lastClose  = ts[1].AdjClose.HasValue ? ts[1].AdjClose.Value : ts[1].Close;
                        ret += weights[kvp.Key] * (todayClose / lastClose - 1);
#if DEBUG
                        logger.Log(LogLevel.Trace, "Benchmark component: Date: {0} Close: {1} PrevClose: {2} Ret: {3}", today, todayClose, lastClose, ret);
#endif
                    }
                }

                benchmarkEC.AddReturn((double)ret, today);

                if (first)
                {
                    first = false;
                    benchmarkReturns.Add((double)(1 + ret));
                    benchmarkSeries.Add(today, (double)equity);

                    continue;
                }

                equity *= 1 + ret;
                benchmarkReturns.Add((double)(1 + ret));
                benchmarkSeries.Add(today, (double)equity);
            }

            return(benchmarkEC, benchmarkSeries, benchmarkReturns);
        }
예제 #46
0
 public EmailRegRepository(DBContext _context)
 {
     context = _context;
 }
        public static List <tbl_DealItem> getAll()
        {
            RMSEntities db = DBContext.getInstance();

            return(db.tbl_DealItem.ToList());
        }
예제 #48
0
 public InterestController(DBContext context)
 {
     _dBContext = context;
 }
예제 #49
0
 public GreenTemplateController()
     : this(DBContext.Create())
 {
 }
예제 #50
0
        static void Main(string[] args)
        {
            string foo_bar_1   = "foo bar 1";
            string someVersion = "v$12345678";

            var dbContext = new DBContext {
                server = "127.0.0.1", port = 5432, database = "pccrms", userId = "editor", password = "******"
            };

            // ----------------------------------------------------------------------------------------------------------
            // ServiceProvider.Instance.Singleton<Client<Personnel>>(() => new Client<Personnel>(dbContext));
            // var pclient = ServiceProvider.Instance.GetService<Client<Personnel>>();
            // pclient.save("v$12345678", new Personnel { id = "0", name = "abc123", ts = DateTime.Now });
            // var p = pclient.one<Personnel>("v$0", "id", "taoh02");
            // var l = pclient.list("v$0", 0, 10);

            // ----------------------------------------------------------------------------------------------------------
            ServiceProvider.Instance.Singleton <VersionControlManager>(() => new VersionControlManager(dbContext));
            // var vc = ServiceProvider.Instance.GetService<VersionControlManager>();
            // var vcs = vc.getVersionControls();
            // var vcs1 = vc.getVersionControls().Where(d => d.name == foo_bar_1).ToList();
            // vc.createNewVersionControl(foo_bar_1);

            // ----------------------------------------------------------------------------------------------------------
            // Create an Affiliation
            // ServiceProvider.Instance.Singleton<EmpireClient<Empire>>(() => new EmpireClient<Empire>(dbContext));
            // var empireClient = ServiceProvider.Instance.GetService<EmpireClient<Empire>>();
            // var badRoster = new List<Participant>();
            // var empire = new Empire { id = "empire", roster = badRoster, ts = DateTime.Now };
            // empireClient.save(someVersion, empire);
            // Associate something to that affiliation
            // ServiceProvider.Instance.Singleton<DroidClient<Droid>>(() => new DroidClient<Droid>(dbContext));
            // var droidClient = ServiceProvider.Instance.GetService<DroidClient<Droid>>();
            // var droid = new Droid { id = "2-1B", name = "2-1B", ts = DateTime.Now };
            // droidClient.save(someVersion, droid);
            // var empireObj = empireClient.one<Record<Empire>>(someVersion, "id", "empire");
            // empireClient.associate<Participant, Droid>(someVersion, empireObj.id, droid.id);

            // ----------------------------------------------------------------------------------------------------------
            // Create an extended Affiliation
            // ServiceProvider.Instance.Singleton<Client<EmpireExtended>>(() => new Client<EmpireExtended>(dbContext));
            // var empireExtendedClient = ServiceProvider.Instance.GetService<Client<EmpireExtended>>();
            // var badRosterExtended = new List<ParticipantExtended>();
            // var empireExtended = new EmpireExtended { id = "empire", roster = badRosterExtended, ts = DateTime.Now };
            // empireExtendedClient.save(someVersion, empireExtended);
            // Associate something that was also extended to that extended affiliation
            // ServiceProvider.Instance.Singleton<DroidClient<DroidExtended>>(() => new DroidClient<DroidExtended>(dbContext));
            // var droidExtendedClient = ServiceProvider.Instance.GetService<DroidClient<DroidExtended>>();
            // var droidExtended = new DroidExtended { id = "2-1B", name = "2-1B", ts = DateTime.Now, language = "None" };
            // droidExtendedClient.save(someVersion, droidExtended);

            // var empireExtendedObj = empireExtendedClient.one<Record<EmpireExtended>>(someVersion, "id", "empire");
            // empireExtendedClient.associate<ParticipantExtended, DroidExtended>(someVersion, empireExtendedObj.id, droidExtended.id);

            // Passing a "party" Type to an Affiliation and check that the party is a DroidExtended and not a dynamic type
            // empireExtendedObj = empireExtendedClient.one<Record<EmpireExtended>>(someVersion, "id", "empire", typeof(DroidExtended));

            // Associate again 3 times and check for dupes
            // foreach(int i in Enumerable.Range(1, 3)) {
            //   empireExtendedClient.associate<ParticipantExtended, DroidExtended>(someVersion, empireExtendedObj.id, droidExtended.id);
            // }
            // empireExtendedClient.associate<ParticipantExtended, DroidExtended>(someVersion, empireExtendedObj.id, droidExtended.id);

            // Disassociate from an Affiliation
            // empireExtendedClient.disassociate<ParticipantExtended>(someVersion, empireExtendedObj.id, droidExtended.id);

            // ----------------------------------------------------------------------------------------------------------
            // Affiliation should fetch the latest party record.
            ServiceProvider.Instance.Singleton <HumanClient <Human> >(() => new HumanClient <Human>(dbContext));
            ServiceProvider.Instance.Singleton <Client <RebelAlliance> >(() => new Client <RebelAlliance>(dbContext));

            Record <RebelAlliance> currentRebelAlliance = null;
            Human currentLeia = null;

            var humanClient = ServiceProvider.Instance.GetService <HumanClient <Human> >();
            var generalLeia = new Human {
                id = "organa-leia", name = "Leia Organa"
            };

            humanClient.save(someVersion, generalLeia);

            var rebelAllianceClient = ServiceProvider.Instance.GetService <Client <RebelAlliance> >();
            var rebelAlliance       = new RebelAlliance {
                id = "rebel-alliance", name = "The Rebel Alliance", ts = DateTime.Now, roster = { }
            };

            rebelAllianceClient.save(someVersion, rebelAlliance);

            // Associate Leia to Rebel Alliance.
            rebelAllianceClient.associate <Participant, Human>(someVersion, "rebel-alliance", generalLeia.id);

            // Get the latest participants to Rebel Alliance.
            currentRebelAlliance = rebelAllianceClient.one <Record <RebelAlliance> >(someVersion, "id", "rebel-alliance", typeof(Human));

            currentLeia = currentRebelAlliance.current.roster.FirstOrDefault(d => d.id == "organa-leia").party;
            Console.WriteLine(currentLeia.name);

            // Leia married Han. Update Leia's name.
            generalLeia.name = "Leia Organa Solo";
            humanClient.save(someVersion, generalLeia);

            // Get the latest participants to Rebel Alliance.
            currentRebelAlliance = rebelAllianceClient.one <Record <RebelAlliance> >(someVersion, "id", "rebel-alliance", typeof(Human));
            currentLeia          = currentRebelAlliance.current.roster.FirstOrDefault(d => d.id == "organa-leia").party;
            // Name should now be Leia Organa Solo.
            Console.WriteLine(currentLeia.name);

            // ----------------------------------------------------------------------------------------------------------
            // Calling one when version and schema does not exist will not throw
            var           fac          = new Factory <NpgsqlConnection>();
            var           dbConnection = fac.Get(dbContext);
            CommandRunner runner       = new CommandRunner(dbConnection);

            try {
                runner.Transact(new DbCommand[] { runner.BuildCommand("drop schema v$12345678 cascade", null) });
            } catch (Exception err) {
                // Expect -> 3F000: schema "v$12345678" does not exist
                Console.WriteLine(err.Message);
            }
            ServiceProvider.Instance.Singleton <DroidClient <Droid> >(() => new DroidClient <Droid>(dbContext));
            var someDroidClient = ServiceProvider.Instance.GetService <DroidClient <Droid> >();
            var someDroid       = someDroidClient.one <Droid>(someVersion, "id", "R2-D2");

            Console.WriteLine(someDroid == null);

            // ----------------------------------------------------------------------------------------------------------
            // Calling save when version and schema does not exist will not throw
            var newDroid = new Droid {
                id = "2-1B", name = "2-1B", ts = DateTime.Now
            };

            someDroidClient.save("v$12345678", newDroid);
            var fetchNewDroid = someDroidClient.one <Droid>(someVersion, "id", "2-1B");

            Console.WriteLine(fetchNewDroid != null);

            // ----------------------------------------------------------------------------------------------------------
            //Create a Affiliation that is derived from the Empire called FirstOrder
            ServiceProvider.Instance.Singleton <Client <FirstOrder> >(() => new Client <FirstOrder>(dbContext));
            ServiceProvider.Instance.Singleton <Client <DroidExtended> >(() => new Client <DroidExtended>(dbContext));
            var firstOrderClient = ServiceProvider.Instance.GetService <Client <FirstOrder> >();
            var firstOrder       = new FirstOrder {
                id = "first-order", name = "The First Order", ts = DateTime.Now, roster = { }
            };

            firstOrderClient.save <FirstOrder>(someVersion, firstOrder);

            var droidExtendedClient = ServiceProvider.Instance.GetService <Client <DroidExtended> >();
            var droidExtended       = new DroidExtended {
                id = "2-1B", name = "2-1B", ts = DateTime.Now, language = "None"
            };

            droidExtendedClient.save(someVersion, droidExtended);
            firstOrderClient.associate <ParticipantExtended, DroidExtended>(someVersion, "first-order", droidExtended.id);

            // Passing a "party" Type to an derived Affiliation and check that the party is a DroidExtended and not a dynamic type
            var firstOrderObj = firstOrderClient.one <Record <FirstOrder> >(someVersion, "id", "first-order", typeof(DroidExtended));

            // ----------------------------------------------------------------------------------------------------------
            // Create List<IModel> as attribute of Model and associate it with Affiliation
            ServiceProvider.Instance.Singleton <EmpireClient <Empire> >(() => new EmpireClient <Empire>(dbContext));
            var empireClient = ServiceProvider.Instance.GetService <EmpireClient <Empire> >();

            ServiceProvider.Instance.Singleton <DroidClient <Droid> >(() => new DroidClient <Droid>(dbContext));
            var droidClient = ServiceProvider.Instance.GetService <DroidClient <Droid> >();

            // Create an Empire
            var empire = new Empire {
                id = "empire", roster = { }, ts = DateTime.Now
            };

            empireClient.save(someVersion, empire);

            // Get a count
            var count = empireClient.count(someVersion, "id", "empire");

            // Create a Droid
            var droid = new Droid {
                id = "2-1B", name = "2-1B", ts = DateTime.Now
            };

            // Assign an Affiliation to the droid
            droid.alliance.Add(empire);
            droidClient.save(someVersion, droid);

            // Check how many alliances the droid has
            droid = droidClient.one <Droid>(someVersion, "id", "2-1B");
            int allianceCount = 0;

            allianceCount = droid.alliance.Count();

            // Assign the same Affiliation to the droid 3 times and get count
            foreach (int i in Enumerable.Range(1, 3))
            {
                droid          = droidClient.one <Droid>(someVersion, "id", "2-1B");
                droid.alliance = new List <Affiliation <Participant> > {
                    empire
                };
                droidClient.save(someVersion, droid);
            }
            allianceCount = droid.alliance.Count();
            // ----------------------------------------------------------------------------------------------------------

            /**
             * packages\nspec.1.0.13\tools\NSpecRunner.exe C:\cygwin64\home\htao\Store\Store.Storage.Pgsql.Test\bin\Debug\Store.Storage.Pgsql.Test.dll
             */
        }
예제 #51
0
 public TrifoliaImporter()
     : this(DBContext.Create())
 {
 }
        public bool MeesageParsing(string msg_body, int msg_idnum)
        {
            bool result = false;
            
            try
            {
                #region Initialize values
                string[] msgBody;
                string[] rowLine;
                string header;

                EDI315 dbEDI315 = new EDI315();
                EDI315_Detail dbEDI315_Detail = new EDI315_Detail();
                List<EDI315_Detail_N9> dbEDI315_Detail_N9List = new List<EDI315_Detail_N9>();
                List<EDI315_Detail_R4> dbEDI315_Detail_R4List = new List<EDI315_Detail_R4>();
  
                #endregion


                msg_body = Regex.Replace(msg_body, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                msgBody = msg_body.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

                foreach(string row in msgBody)
                {
                    if(row != null && row.Count() > 0)
                    {
                        rowLine = row.Split('*');

                        header = "";
                        if (EDI315_HEADERS.Any(x => x.ToUpper() == rowLine[0]))
                        {
                            header = rowLine[0];
                        }

                        switch (header)
                        {
                            case "ISA":
                                #region ISA
                                dbEDI315 = new EDI315()
                                {
                                    msg_idnum = msg_idnum,
                                    ISA_auth_info_qualifier = rowLine[1] ?? "",
                                    ISA_auth_info = rowLine[2] ?? "",
                                    ISA_security_info_qualifier = rowLine[3] ?? "",
                                    ISA_security_info = rowLine[4] ?? "",
                                    ISA_interchange_id_qualifier_1 = rowLine[5] ?? "",
                                    ISA_interchange_sender_id = rowLine[6] ?? "",
                                    ISA_interchange_id_qualifier_2 = rowLine[7] ?? "",
                                    ISA_interchange_receiver_id = rowLine[8] ?? "",
                                    ISA_interchage_date = rowLine[9] ?? "",
                                    ISA_interchange_time = rowLine[10] ?? "",
                                    ISA_interchange_control_standards_id = rowLine[11] ?? "",
                                    ISA_interchange_control_version_number = rowLine[12] ?? "",
                                    ISA_interchange_control_number = rowLine[13] ?? "",
                                    ISA_ack_requested = rowLine[14] ?? "",
                                    ISA_usage_indicator = rowLine[15] ?? "",
                                    ISA_component_element_separator = rowLine[16] ?? "",
                                };
                                #endregion
                                break;

                            case "GS":
                                #region GS
                                dbEDI315.GS_functional_id_code = rowLine[1] ?? "";
                                dbEDI315.GS_app_sender_code = rowLine[2] ?? "";
                                dbEDI315.GS_app_receiver_code = rowLine[3] ?? "";
                                dbEDI315.GS_date = rowLine[4] ?? "";
                                dbEDI315.GS_time = rowLine[5] ?? "";
                                dbEDI315.GS_group_control_number = rowLine[6] ?? "";
                                dbEDI315.GS_reponsible_agency_code = rowLine[7] ?? "";
                                dbEDI315.GS_industry_id_code = rowLine[8] ?? "";

                                /* Insert table EDI315 after done with ISA & GS */
                                if (dbEDI315.msg_idnum != 0)
                                {
                                    using (DBContext context = new DBContext())
                                    {
                                        /* check DB is open */


                                        dbEDI315.created_date = DateTime.Now;
                                        context.EDI315.Add(dbEDI315);
                                        context.SaveChanges();
                                    }
                                }
                                #endregion
                                break;
                            case "ST":
                                dbEDI315_Detail = new EDI315_Detail();

                                break;
                            case "SE":
                                // insert EDI315_Detail
                                // init. all vaues
                                break;

                            case "B4":
                                if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                                    continue;

                                dbEDI315_Detail.B4_SHC = rowLine[1];
                                if(rowLine[2] != null && rowLine[2].Trim() != string.Empty && Int32.TryParse(rowLine[2])
                                dbEDI315_Detail.B4_request_number = rowLine[2] ?? null : rowLine[2];

                                break;
                        }
                    }
                }
            }
            catch(Exception ex)
            {

                result = false;
            }

            return result;
        }
예제 #53
0
 public SolutionController(DBContext _db, IHostingEnvironment env)
 {
     db = _db;
 }
예제 #54
0
 public PrizeRepository(DBContext context) : base(context)
 {
 }
예제 #55
0
 public OrdersController()
 {
     this.db = new DBContext();
 }
예제 #56
0
 public TcustomerController(DBContext context)
 {
     _context = context;
 }
 public FlowerOrderSqlRepository(DBContext context)
 {
     this.context = context;
 }
예제 #58
0
        public IAsyncEnumerable <Contract> Get()
        {
            DBContext context = new DBContext();

            return(context.Contracts.Include(s => s.Stages).AsAsyncEnumerable());
        }
예제 #59
0
        public bool MeesageParsing(string msg_body, int msg_idnum)
        {
            bool result = false;

            try
            {
                #region Initialize values
                string[] msgBody;
                string[] rowLine;
                string   header;

                EDI315                      dbEDI315                   = new EDI315();
                EDI315_Detail               dbEDI315_Detail            = new EDI315_Detail();
                List <EDI315_Detail_N9>     dbEDI315_Detail_N9List     = new List <EDI315_Detail_N9>();
                List <EDI315_Detail_R4>     dbEDI315_Detail_R4List     = new List <EDI315_Detail_R4>();
                List <EDI315_Detail_R4_DTM> dbEDI315_Detail_R4_DTMList = new List <EDI315_Detail_R4_DTM>();

                int     convertToInt     = 0;
                decimal convertToDecimal = 0;
                #endregion

                msg_body = Regex.Replace(msg_body, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                msgBody  = msg_body.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

                foreach (string row in msgBody)
                {
                    if (row != null && row.Count() > 0)
                    {
                        rowLine = row.Split('*');

                        header = "";
                        if (EDI315_HEADERS.Any(x => x.ToUpper() == rowLine[0]))
                        {
                            header = rowLine[0];
                        }

                        switch (header)
                        {
                        case "ISA":
                            #region ISA
                            dbEDI315 = new EDI315()
                            {
                                msg_idnum = msg_idnum,
                                ISA_auth_info_qualifier                = substringValue(rowLine[1] ?? "", 2),
                                ISA_auth_info                          = substringValue(rowLine[2] ?? "", 10),
                                ISA_security_info_qualifier            = substringValue(rowLine[3] ?? "", 2),
                                ISA_security_info                      = substringValue(rowLine[4] ?? "", 10),
                                ISA_interchange_id_qualifier_1         = substringValue(rowLine[5] ?? "", 2),
                                ISA_interchange_sender_id              = substringValue(rowLine[6] ?? "", 15),
                                ISA_interchange_id_qualifier_2         = substringValue(rowLine[7] ?? "", 2),
                                ISA_interchange_receiver_id            = substringValue(rowLine[8] ?? "", 15),
                                ISA_interchage_date                    = substringValue(rowLine[9] ?? "", 8),
                                ISA_interchange_time                   = substringValue(rowLine[10] ?? "", 4),
                                ISA_interchange_control_standards_id   = substringValue(rowLine[11] ?? "", 1),
                                ISA_interchange_control_version_number = substringValue(rowLine[12] ?? "", 5),
                                ISA_interchange_control_number         = substringValue(rowLine[13] ?? "", 9),
                                ISA_ack_requested                      = substringValue(rowLine[14] ?? "", 1),
                                ISA_usage_indicator                    = substringValue(rowLine[15] ?? "", 1),
                                ISA_component_element_separator        = substringValue(rowLine[16] ?? "", 1),
                            };
                            #endregion
                            break;

                        case "GS":      // insert DB
                            #region GS
                            dbEDI315.GS_functional_id_code = substringValue(rowLine[1] ?? "", 2);
                            dbEDI315.GS_app_sender_code    = substringValue(rowLine[2] ?? "", 15);
                            dbEDI315.GS_app_receiver_code  = substringValue(rowLine[3] ?? "", 15);
                            dbEDI315.GS_date = substringValue(rowLine[4] ?? "", 8);
                            dbEDI315.GS_time = substringValue(rowLine[5] ?? "", 8);
                            dbEDI315.GS_group_control_number   = substringValue(rowLine[6] ?? "", 9);
                            dbEDI315.GS_reponsible_agency_code = substringValue(rowLine[7] ?? "", 2);
                            dbEDI315.GS_industry_id_code       = substringValue(rowLine[8] ?? "", 12);

                            /* Insert table EDI315 after done with ISA & GS */
                            if (dbEDI315.msg_idnum != 0)
                            {
                                if (util.dbConnectionCheck())
                                {
                                    using (DBContext context = new DBContext())
                                    {
                                        dbEDI315.created_date = DateTime.Now;
                                        context.EDI315.Add(dbEDI315);
                                        context.SaveChanges();
                                        context.Dispose();
                                    }
                                }
                                else
                                {
                                    string logMsg = "Function: MeesageParsing - Table EDI315\r\n";
                                    logMsg += "Error Message: Not able to access DB. Process rollbacked.\r\n";
                                    util.insertLog("315", msg_idnum, dbEDI315.EDI315_idnum, 0, logMsg);

                                    rollbackProcess(msg_idnum);
                                    return(false);
                                }
                            }

                            #endregion
                            break;

                        case "ST":
                            #region ST
                            /* Detail start. Init. */
                            dbEDI315_Detail            = new EDI315_Detail();
                            dbEDI315_Detail_N9List     = new List <EDI315_Detail_N9>();
                            dbEDI315_Detail_R4List     = new List <EDI315_Detail_R4>();
                            dbEDI315_Detail_R4_DTMList = new List <EDI315_Detail_R4_DTM>();
                            #endregion
                            break;

                        case "SE":      // inset DB
                            #region SE
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            convertToInt = 0;
                            if (rowLine[1] != null && rowLine[1].Trim() != string.Empty && Int32.TryParse(rowLine[1], out convertToInt))
                            {
                                dbEDI315_Detail.SE_included_segments_number = convertToInt;
                            }

                            dbEDI315_Detail.SE_transaction_set_control_number = rowLine[2];


                            /* insert Table EDI315_Detail, EDI315_Detail_N9, EDI315_Detail_R4 & EDI315_Detail_R4_DTM */
                            if (util.dbConnectionCheck())
                            {
                                using (DBContext context = new DBContext())
                                {
                                    /* EDI315_Detail Insert */
                                    dbEDI315_Detail.EDI315_idnum = dbEDI315.EDI315_idnum;
                                    context.EDI315_Detail.Add(dbEDI315_Detail);
                                    context.SaveChanges();

                                    /* EDI315_Detail_N9 Insert */
                                    dbEDI315_Detail_N9List.ForEach(x => x.EDI315_Detail_idnum = dbEDI315_Detail.EDI315_Detail_idnum);
                                    context.EDI315_Detail_N9.AddRange(dbEDI315_Detail_N9List);
                                    context.SaveChanges();

                                    /* EDI315_Detail_R4 & EDI315_Detail_R4_DTM Insert */
                                    foreach (EDI315_Detail_R4 dbR4Row in dbEDI315_Detail_R4List)
                                    {
                                        List <EDI315_Detail_R4_DTM> dtmList = dbEDI315_Detail_R4_DTMList.Where(x => x.Detail_R4_idnum == dbR4Row.Detail_R4_idnum).ToList();

                                        dbR4Row.EDI315_Detail_idnum = dbEDI315_Detail.EDI315_Detail_idnum;
                                        context.EDI315_Detail_R4.Add(dbR4Row);
                                        context.SaveChanges();

                                        foreach (EDI315_Detail_R4_DTM dtmRow in dtmList)
                                        {
                                            dtmRow.EDI315_Detail_idnum = dbEDI315_Detail.EDI315_Detail_idnum;
                                            dtmRow.Detail_R4_idnum     = dbR4Row.Detail_R4_idnum;
                                        }
                                        context.EDI315_Detail_R4_DTM.AddRange(dtmList);
                                        context.SaveChanges();
                                    }
                                    context.Dispose();
                                }
                            }
                            else
                            {
                                string logMsg = "Function: MeesageParsing - Table EDI315_Detail, EDI315_Detail_N9, EDI315_Detail_R4, EDI315_Detail_R4_DTM\r\n";
                                logMsg += "Error Message: Not able to access DB. Process rollbacked.\r\n";
                                util.insertLog("315", msg_idnum, dbEDI315.EDI315_idnum, dbEDI315_Detail.EDI315_Detail_idnum, logMsg);

                                rollbackProcess(msg_idnum);
                                return(false);
                            }
                            #endregion
                            break;

                        case "B4":
                            #region B4
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            dbEDI315_Detail.B4_SHC = rowLine[1];

                            convertToInt = 0;
                            if (rowLine[2] != null && rowLine[2].Trim() != string.Empty && Int32.TryParse(rowLine[2], out convertToInt))
                            {
                                dbEDI315_Detail.B4_request_number = convertToInt;
                            }

                            dbEDI315_Detail.B4_status_code     = rowLine[3];
                            dbEDI315_Detail.B4_date            = rowLine[4] ?? "";
                            dbEDI315_Detail.B4_status_time     = rowLine[5] ?? "";
                            dbEDI315_Detail.B4_status_location = rowLine[6] ?? "";

                            dbEDI315_Detail.B4_equip_initial     = rowLine[7];
                            dbEDI315_Detail.B4_equip_number      = rowLine[8];
                            dbEDI315_Detail.B4_equip_status_code = rowLine[9];
                            dbEDI315_Detail.B4_equip_type        = rowLine[10];
                            dbEDI315_Detail.B4_location_code     = rowLine[11];
                            dbEDI315_Detail.B4_location_id       = rowLine[12];

                            if (rowLine.Count() > 13)
                            {
                                convertToInt = 0;
                                if (rowLine[13] != null && rowLine[13].Trim() != string.Empty && Int32.TryParse(rowLine[13], out convertToInt))
                                {
                                    dbEDI315_Detail.B4_equip_check_digit = convertToInt;
                                }
                            }
                            #endregion
                            break;

                        case "Q2":
                            #region Q2
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            dbEDI315_Detail.Q2_vessel_code  = rowLine[1];
                            dbEDI315_Detail.Q2_country_code = rowLine[2];
                            dbEDI315_Detail.Q2_date_1       = rowLine[3];
                            dbEDI315_Detail.Q2_date_2       = rowLine[4];
                            dbEDI315_Detail.Q2_date_3       = rowLine[5];

                            convertToInt = 0;
                            if (rowLine[6] != null && rowLine[6].Trim() != string.Empty && Int32.TryParse(rowLine[6], out convertToInt))
                            {
                                dbEDI315_Detail.Q2_lading_quantity = convertToInt;
                            }

                            convertToDecimal = 0;
                            if (rowLine[7] != null && rowLine[7].Trim() != string.Empty && Decimal.TryParse(rowLine[7], out convertToDecimal))
                            {
                                dbEDI315_Detail.Q2_weight = convertToDecimal;
                            }

                            dbEDI315_Detail.Q2_weight_qualifier       = rowLine[8];
                            dbEDI315_Detail.Q2_voyage_number          = rowLine[9];
                            dbEDI315_Detail.Q2_reference_id_qualifier = rowLine[10];
                            dbEDI315_Detail.Q2_reference_id           = rowLine[11];
                            dbEDI315_Detail.Q2_vessel_code_qualifier  = rowLine[12];
                            dbEDI315_Detail.Q2_vessel_name            = rowLine[13];

                            convertToDecimal = 0;
                            if (rowLine[14] != null && rowLine[14].Trim() != string.Empty && Decimal.TryParse(rowLine[14], out convertToDecimal))
                            {
                                dbEDI315_Detail.Q2_volume = convertToDecimal;
                            }

                            dbEDI315_Detail.Q2_volume_unit_qualifier = rowLine[15];
                            dbEDI315_Detail.Q2_weight_unit_code      = rowLine[16];
                            #endregion
                            break;

                        case "N9":
                            #region N9
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_N9 dbTemp = new EDI315_Detail_N9();

                                dbTemp.reference_id_qualifier = rowLine[1];

                                if (rowLine.Count() > 2)
                                {
                                    dbTemp.reference_id = rowLine[2];
                                }

                                if (rowLine.Count() > 3)
                                {
                                    dbTemp.free_form_description = rowLine[3];
                                }

                                if (rowLine.Count() > 4)
                                {
                                    dbTemp.free_form_description = rowLine[4];
                                }

                                if (rowLine.Count() > 5)
                                {
                                    dbTemp.date = rowLine[5];
                                }

                                if (rowLine.Count() > 6)
                                {
                                    dbTemp.time = rowLine[6];
                                }

                                if (rowLine.Count() > 7)
                                {
                                    dbTemp.time_code = rowLine[7];
                                }

                                dbEDI315_Detail_N9List.Add(dbTemp);
                            }
                            #endregion
                            break;

                        case "R4":
                            #region R4
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_R4 dbTemp = new EDI315_Detail_R4();

                                dbTemp.Detail_R4_idnum    = dbEDI315_Detail_R4List.Count() + 1;
                                dbTemp.port_function_code = rowLine[1];

                                if (rowLine.Count() > 2)
                                {
                                    dbTemp.location_qualifier = rowLine[2];
                                }

                                if (rowLine.Count() > 3)
                                {
                                    dbTemp.location_id = rowLine[3];
                                }

                                if (rowLine.Count() > 4)
                                {
                                    dbTemp.port_name = rowLine[4];
                                }

                                if (rowLine.Count() > 5)
                                {
                                    dbTemp.country_code = rowLine[5];
                                }

                                if (rowLine.Count() > 6)
                                {
                                    dbTemp.terminal_name = rowLine[6];
                                }

                                if (rowLine.Count() > 7)
                                {
                                    dbTemp.pier_number = rowLine[7];
                                }

                                if (rowLine.Count() > 8)
                                {
                                    dbTemp.province_code = rowLine[8];
                                }

                                dbEDI315_Detail_R4List.Add(dbTemp);
                            }
                            #endregion
                            break;

                        case "DTM":
                            #region DTM
                            if (dbEDI315 == null || dbEDI315.EDI315_idnum == 0)
                            {
                                continue;
                            }

                            {
                                EDI315_Detail_R4_DTM dbTemp = new EDI315_Detail_R4_DTM();

                                dbTemp.Detail_R4_idnum = dbEDI315_Detail_R4List.Count();

                                convertToInt = 0;
                                if (rowLine[1] != null && rowLine[1].Trim() != string.Empty && Int32.TryParse(rowLine[1], out convertToInt))
                                {
                                    dbTemp.datetime_qualifier = convertToInt;
                                }

                                if (rowLine.Count() > 2)
                                {
                                    dbTemp.date = rowLine[2];
                                }

                                if (rowLine.Count() > 3)
                                {
                                    dbTemp.time = rowLine[3];
                                }

                                if (rowLine.Count() > 4)
                                {
                                    dbTemp.time_code = rowLine[4];
                                }

                                dbEDI315_Detail_R4_DTMList.Add(dbTemp);
                            }
                            #endregion
                            break;
                        }
                    }
                }
                result = true;
            }
            catch (DbEntityValidationException ex)
            {
                string logMsg = "Function: MeesageParsing\r\n";
                logMsg += "Process rollbacked.\r\n";
                logMsg += "Error Message:\r\n";

                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry
                    DbEntityEntry entry          = item.Entry;
                    string        entityTypeName = entry.Entity.GetType().Name;

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        logMsg += string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName) + "\r\n";
                    }
                }
                util.insertLog("315", msg_idnum, 0, 0, logMsg);

                rollbackProcess(msg_idnum);
                result = false;
            }
            catch (Exception ex)
            {
                string logMsg = "Function: MeesageParsing\r\n";
                logMsg += "Process rollbacked.\r\n";
                logMsg += "Error Message: " + ex.ToString();
                util.insertLog("315", msg_idnum, 0, 0, logMsg);

                rollbackProcess(msg_idnum);
                result = false;
            }
            return(result);
        }
 public EDI315MsgParsing()
 {
     logFile = new LogFile();
     context = new DBContext();
 }