Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all 1350 articles
Browse latest View live

beginner gremlin.net cosmos db questions

$
0
0

Hi

I ammore used to using entity framework wheremuch is done for you so have a few questions.

I am having trouble finding out how to input a complex model as a graph, eg it starts with a vertex has an edge to an existing vertex and 3 edges to new vertex and the 3 new vertexs.

all the examples i see all add an id manually (which i would prefer not to do), while i know if I don't add one manually it will do so for me, I don't know how i will reference it to run multiple since queries toadd all the elements.

this is because all the examples i find all run single line queries for each element eg a vertex or and edge, is it possible to run one big command which will do do this all together?

Any thoughts would be appriciated


Filtering mongodb data

$
0
0

Hi All,

I used mongodb in my backend to store some customer personal information and i need to fetch the user who ages 30, 32 and 35.

I tried below ways to get but it returns zero results and i used MongoDB.Driver

Age = new string[] { "26-30", "31-35" }
DateTime today = DateTime.Today;var filter = Builders<Customer>.Filter.Empty;
foreach (var item in searchFilterBlock.Age)
 {
    var ageBetween = item.Split('-');
    int.TryParse(ageBetween[0], out int startYear);
    int.TryParse(ageBetween[1], out int endYear);
    var start = today.AddYears(-startYear);
    var end = today.AddYears(-endYear); filter = filter & (Builders<Customer>.Filter.Gte(x => x.Dob, start)& Builders<Customer>.Filter.Lte(x=>x.Dob, end));
 }
// te execute the filter
var searchResult = _context.Customer.Find(filter).ToList(); // it return 0 result

Thanks,

Attempt to load Oracle client libraries threw BadImageFormatException.

$
0
0

Dear all,
i was working on 32 bit OS, with 32 bit Oracle client installed and Visual Studio 2015. for some
reasons i have to change my laptop. now i have 64 bit OS, with 32 bit oracle client (only this should be
used for some reasons). i am using entityspaces as orm (both 32 and 64bit). after successfuly installation in new laptop when
i ran my VS solution i found following error

inner exception "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"

error message "Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."

i have tested following solutions but failed.

1) go to Tools > Options > Projects and Solutions > Web Projects > check the option that says: Use the 64 bit version of IIS Express for Websites and Projects

2) Project, properties, Build TAB, select platform target : x86
Project, clean build, ReBuild solution

when i changed platform target to x86 my wcf project throwed error and hence cant update the service
when i changed platform target to x64 my wcf project updated successfully but got abovementioned error on
application execution.


=> what i have is, 64 bit OS, 32 bit oracle client [bound to use this only], VS 2015, entityspaces 32 or 64 bit
what should i do so that i can run my application without any errors from visual studio 2015. As i am unable to
fetch data from oracle at all (using entityspaces).

i am looking for the solution for 4 days but failed.

Please give me solution or point out where i am wrong.


with many thanks

Help with parameterized MySQL query

$
0
0

Could you solve my problem converting my concenate code into the parameter one?

I tried this one bu it didn't work (

            var LaboratuvarIdParam = new MySqlParameter("LaboratuvarIdParam", BirimlerId);
            var ArananNumuneSahibiParam = new MySqlParameter("ArananNumuneSahibiParam", ArananNumuneSahibi);
            var PageSizeParam = new MySqlParameter("PageSizeParam", PageSize);
            var AtlanacakSiraParam = new MySqlParameter("AtlanacakSiraParam", AtlanacakSira);
            IQueryable NumuneSahiplerininBulunduguEvraklar = _context.Evraklar.FromSql("select evraklar.* from `numune_sahipleri` join `evraklar` on `numune_sahipleri`.`evraklar_id`= evraklar.`evraklar_id` join `sevkedilen_lablar` on `evraklar`.`evraklar_id`=`sevkedilen_lablar`.`evraklar_id` where birimler_id ="+ " @LaboratuvarIdParam and `numune_sahipleri`.adisoyadi like('%@ArananNumuneSahibiParam%') order by evraklar_id desc LIMIT @PageSizeParam  OFFSET @AtlanacakSiraParam ", LaboratuvarIdParam, ArananNumuneSahibiParam, PageSizeParam, AtlanacakSiraParam);

From xml to oracle

$
0
0

If I get the file in xml format. How can I insert into oracle database. Appreciate the help

Open XML document unreadable after adding footer

$
0
0

I am trying to add footer in a word document by using the below code. The file is getting generated, but when I try to open the file it is showing the message that the document is unreadable. I don't know what I am doing wrong here.

WordprocessingDocument doc;
    Body docBody;
    public void Insert()
    {
        doc = WordprocessingDocument.Create(@"d:\report1.docx", WordprocessingDocumentType.Document);
        docBody = new Body();
        MainDocumentPart mainPart = doc.AddMainDocumentPart();
        mainPart.Document = new Document();
        mainPart.Document.Body = docBody;
        ApplyFooter();
        doc.Save();

    }


    public void ApplyFooter()
    {
        // Get the main document part.
        MainDocumentPart mainDocPart = doc.MainDocumentPart;

        FooterPart footerPart1 = mainDocPart.AddNewPart<FooterPart>("r98");



        Footer footer1 = new Footer();

        Paragraph paragraph1 = new Paragraph() { };



        Run run1 = new Run();
        Text text1 = new Text();
        text1.Text = "Footer stuff";

        run1.Append(text1);

        paragraph1.Append(run1);


        footer1.Append(paragraph1);

        footerPart1.Footer = footer1;



        SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants<SectionProperties>().FirstOrDefault();
        if (sectionProperties1 == null)
        {
            sectionProperties1 = new SectionProperties() { };
            mainDocPart.Document.Body.Append(sectionProperties1);
        }
        FooterReference footerReference1 = new FooterReference() { Type = DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues.Default, Id = "r98" };


        sectionProperties1.InsertAt(footerReference1, 0);

    }

To deploy Oracle Report in .net

$
0
0

I have an Oracle RDF Report with report name, which i require to deploy through asp.net and display it through  a web application.

The Oracle RDF Report is on a different server and the web application on another server

Does anyone know the query in .net for the same ?

EPPLUS - Issue with formulas

$
0
0

I am using the excellent EPPLUS library to add a record to an excel spreadsheet.

worksheet.Cells[rowCount + 1, addressCol].Formula = "=IF(AND(ISNUMBER(RC[-3]),ISNUMBER(RC[-5])),RC[-5]-RC[-3],\"NA\")"

The code works and the spreadsheet is successfully saved, but when I open the spreadsheet again, Excel throws an error message about unreadable content in part of the xml related to a formula.

It works without issue if I am just updating an existing row.


.net core 2.1 - Linq to SQL : character mismatch error - Oracle database

$
0
0

Hi,

I'm using Oracle 11g.  I'm trying to have an if then else statement in the select clause of linq-to-sql connecting to Oracle database.

Database Table:

CREATE TABLE "ISSUE_TRANSACTION"
   ( "ISSUE_ID" NUMBER(15,0) NOT NULL ENABLE,
 "ISSUE_TRANSACTION_ID" NUMBER(15,0) NOT NULL ENABLE,
 "INVENTORY_ID" NUMBER(15,0) NOT NULL ENABLE,
 "REQ_EMPLOYEE_NUM" VARCHAR2(6 BYTE) NOT NULL ENABLE,
 "REQ_SUPERVISOR_EMP_NUM" VARCHAR2(6 BYTE) NOT NULL ENABLE,
 "ISSUE_TO_TYPE" VARCHAR2(3 BYTE) NOT NULL ENABLE,
 "ISSUE_TO_ID" VARCHAR2(10 BYTE) NOT NULL ENABLE,
 "REASON_CODE" VARCHAR2(6 BYTE),
 "QUANTITY" NUMBER(9,0) NOT NULL ENABLE,
 "ISSUE_DATE" DATE NOT NULL ENABLE,
 "CREATED_BY" VARCHAR2(6 BYTE) NOT NULL ENABLE,
 "CREATED_DT" TIMESTAMP (6) NOT NULL ENABLE,
 "INACTIVE_BY" VARCHAR2(6 BYTE),
 "INACTIVE_DT" TIMESTAMP (6)) 

Model

    public class IssuedItemsByTransactionId
    {
        public long IssueId { get; set; }
        public long IssueTransactionId { get; set; }
        public string MaterialCode { get; set; }
        public string PropertyId { get; set; }
        public string MaterialDescription { get; set; }
        public string IssueType { get; set; }
        public string AssignToType { get; set; }
        public string AssignedToVeh { get; set; }
        public EmployeeViewModel  AssignedToEmployee{ get; set; }
        public ddlItems AssignedToFacility { get; set; }
        public ddlItems AssignedToJob { get; set; }
        public string IssueReason { get; set; }
        public int Quantity{ get; set; }

    }

SQL

List<IssuedItemsByTransactionId> list = (from it in dbViews.IssueTransaction
                                                     join i in dbViews.Inventory on it.InventoryId equals i.InventoryId
                                                     join m in dbViews.Material on i.MaterialCode equals m.MaterialCode
                                                     where it.IssueTransactionId == alTransactionId
                                                     select new IssuedItemsByTransactionId
                                                     {
                                                         IssueId = it.IssueId,
                                                         IssueTransactionId = it.IssueTransactionId,
                                                         MaterialCode = m.MaterialCode,
                                                         PropertyId = i.PropertyId,
                                                         MaterialDescription = m.MaterialDescription,
                                                         IssueType = null
                                                         AssignToType = it.IssueToType,
                                                         AssignedToVeh = (it.IssueToType.Equals("VEH"))  ? it.IssueToId : "",
                                                         AssignedToFacility = null,  
                                                         AssignedToJob = null,       
                                                         IssueReason = it.ReasonCode,
                                                         Quantity = it.Quantity
                                                     }).ToList();

Code is having an error in the line AssignedToVeh = (it.IssueToType.Equals(AssignToType.VEH.ToString()))  ? it.IssueToId : "".

If I remove the (it.IssueToType.Equals("VEH"))  and just change the line to AssignedToVeh = it.IssueToId, code works fine.

Error:

OracleException: ORA-12704: character set mismatch

OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(out int cursorId, bool bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, int arrayBindCount, ref OracleException exceptionForArrayBindDML, out bool hasMoreRowsInDB, bool bFirstIterationDone)


OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(string commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, ref OracleDataReaderImpl rdrImpl, int longFetchSize, long clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, long[] scnForExecution, out long[] scnFromExecution, out OracleParameterCollection bindByPositionParamColl, ref bool bBindParamPresent, ref long internalInitialLOBFS, out OracleException exceptionForArrayBindDML, OracleConnection connection, ref OracleLogicalTransaction oracleLogicalTransaction, IEnumerable<OracleLpStatement> adrianParsedStmt, bool isDescribeOnly, bool isFromEF)

Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(bool requery, bool fillRequest, CommandBehavior behavior)
Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory+OracleRelationalCommandBuilder+OracleRelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary<string, object> parameterValues)

Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary<string, object> parameterValues)

Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable<T>+Enumerator.BufferlessMoveNext(DbContext _, bool buffer)

Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.Execute<TState, TResult>(TState state, Func<DbContext, TState, TResult> operation, Func<DbContext, TState, ExecutionResult<TResult>> verifySucceeded)

Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable<T>+Enumerator.MoveNext()

Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider+ExceptionInterceptor<T>+EnumeratorExceptionInterceptor.MoveNext()

System.Collections.Generic.List<T>.AddEnumerable(IEnumerable<T> enumerable)

System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)

ToolsOracle.Business.Repository.IssueRepository.searchByTransactionId(long alTransactionId) in IssueRepository.cs
+

257.            List<IssuedItemsByTransactionId> list = (from it in dbViews.IssueTransaction

ToolsOracle.Business.Service.IssueService.searchByTransactionId(long lTransactionId) in IssueService.cs
+

83.            return _issueRepository.searchByTransactionId(lTransactionId); //, Boolean bMode

ToolsOracle.Controllers.IssueController.GetAllTransactions(long TransactionId) in IssueController.cs
+

119.            List<IssuedItemsByTransactionId> list = _issueService.searchByTransactionId(TransactionId);//, Boolean bMode

ToolsOracle.Controllers.IssueController.NewCreate(IssueTransactionDTO issueDTO) in IssueController.cs
+

257.            GetAllTransactions(issueDTO.IssueTransactionId.Value);

lambda_method(Closure , object , object[] )

Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters)

Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Please advise.

Thanks,

tinac99

Need help help writing Postgre stored procedures.

$
0
0

I was previously using Mysql now I ported to Postgres dbms. This means I have to port like 5 SP scripts to postgresql. I have been fighting with the first one for 48 hours. I am getting frustrated already. Please can some one help me here. Cos if I cant resolve it. I would have to stay with Mysql.

CREATE OR REPLACE PROCEDURE Countit()
LANGUAGE SQL
AS $$
BEGIN
	SELECT COUNT(*) FROM "Banks";
END$$;



ERROR:  syntax error at or near "SELECT"
LINE 5:  SELECT COUNT(*) FROM "Banks";
         ^
SQL state: 42601
Character: 65



Please note that the table Banks already exits and I am running the script in the right database

Optimizing InnoDBTable increased its size!!!

$
0
0

Hi all, 
I wanted to shrink my db to reduce the size of it. 
As a part of shrink operation, I deleted 12 fields from a table (table size didn't reduce !) and then I optimized that table which even increased the size of it from 25mb to 27mb) 
What kind of situation is this? 
It is really awkward

IBM.Data.Informix with Mvc core

$
0
0

Hi
I am using IBM.Data.Informix with mvc core to connect to Informix and it is going to sleep mode when i try to connect without any exception, i am unable to connect

After it reach to this place it goes in sleep mode without responding, even not giving exception as i have try catch block

  IfxConnection conn =
                    new IfxConnection(
                     UccxConnectionString
                    );

Regards

ORA-12154 TNS couldn't resolve connection identifier specified

$
0
0
Hi all,
I've an application which connects to Oracle DB.
It connects to DB perfectly thru IIS.
But when i try run the application in visual studio 2015 it shown the error..
I'm trying both these ways in the same machines.

Pls direct me on what I'm missing..

Sorting column value of excel using c# console application

$
0
0

Hi All,

How to apply sorting on column value of excel using c# console application ?

sorting can be acceding or descending order.

Thanks in advance.

Data TIme value is null?

$
0
0

Hi 

I need to verify if one field on my database (mysql database connected with datasource) is null

I try it with code like:

 if (string.IsNullOrEmpty(row["data_nascimento"].ToString()))
            {

            }           
            else
            {
                TextBox data_nascimento = (TextBox)this.socios.FindControl("txtAlteraDataNascimento");
                data_nascimento.Text = System.Convert.ToDateTime(row["data_nascimento"]).ToString("yyyy-MM-dd");
            }

or 

 if (row["data_liquidacao"]!= null) {
                TextBox data_liquidacao = (TextBox)this.socios.FindControl("txtDataLiquidacao");
                data_liquidacao.Text = System.Convert.ToDateTime(row["data_liquidacao"]).ToString("yyyy-MM-dd");
            }

none of them work. If the data is NULL I get

The object can't be converted DBNull other types.

How can I detected if the field is null?

Thank you


IIS crash with ntdll

$
0
0

I have a problem with Entity Framework connect to Oracle Database. I'm using DebugDiag to get the dump file.

mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.
Threading.ContextCallback, System.Object, Boolean) 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threadin
g.ContextCallback, System.Object, Boolean) 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threadin
g.ContextCallback, System.Object) 
[[GCFrame] 
[[ContextTransitionFrame] 
mscorlib_ni!System.Threading.SemaphoreSlim.WaitUntilCountOrTimeout(Int32, UInt32, System.Threading.C
ancellationToken) 
mscorlib_ni!System.Threading.SemaphoreSlim.Wait(Int32, System.Threading.CancellationToken) 
System_ni!System.Collections.Concurrent.BlockingCollection`1[[System.__Canon, mscorlib]].TryTakeWith
NoTimeValidation(System.__Canon ByRef, Int32, System.Threading.CancellationToken, System.Threading.C
ancellationTokenSource) 
mscorlib_ni!System.Threading.Tasks.Task.Execute() 
mscorlib_ni!System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) 
mscorlib_ni!System.Threading.Tasks.Task.ExecuteEntry(Boolean) 
mscorlib_ni!System.Threading.ThreadHelper.ThreadStart(System.Object) 
[[HelperMethodFrame_1OBJ] (System.Threading.Monitor.ObjWait)] System.Threading.Monitor.ObjWait(Boole
an, Int32, System.Object 
Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.RollingFlatFileSink.WriteEntries() 
mscorlib_ni!System.Threading.Thread.Sleep(Int32) 
OracleInternal.SelfTuning.OracleTuner.DoScan() 
OracleInternal.SelfTuning.OracleTunerBase.TuningFunction() 
OracleInternal.SelfTuning.OracleTuner.TuningFunction() 
mscorlib_ni!System.Threading.ThreadHelper.ThreadStart() 
[[HelperMethodFrame] (System.Threading.Thread.SleepInternal)] System.Threading.Thread.SleepInternal(
Int32

Hope someone knows a solution or can get me started?

Regards,

Phong

Best way to create a timeline feed using mongodb with different event types

$
0
0

I'm trying to build an event timeline using a mongo database. But I don't know exactly how to solve this.

The timeline can contain several different event types. It can be a post, uploaded photos in albums, children born .. Each timeline item can contain images, which child is affected by the event, information about the event, date and which blog it belongs to.

I have started a solution (see below) but I do not know how to handle the various events, how these can be saved in the database?

  • When the user updates an avatar / name for a child, you need to update all records with the same information in the timeline database.

  • An event should only exist once, for example, a post. If you update the heading of the post, this heading should also be updated and if the record does not exist, this event should be created.

  • If a user deletes an image, then that image should be removed from all events in the timeline database.

Instead of using a common property that can contain different types of events, is it better to create a typed property for every possible event in the Timeline class?

TimelineItem is the main Timeline object:

namespace TimelineTest.Models
{
    public class TimelineItem
    {
        public enum EventTypes
        {
            BlogPost = 10,

            AlbumMedia = 20,

            ChildBirth = 30,
            ChildEvent = 31,
            ChildSize = 32,

            OwnEvent = 40
        }

        [BsonId]
        [DataMember]
        public ObjectId Id { get; set; }

        public int BlogNr { get; set; }
        public EventTypes EventType { get; set; }

        public DateTime EventDate { get; set; }
        public DateTime CreateDate { get; set; }
        public DateTime LastEditDate { get; set; }
        public bool IsDeleted { get; set; }
        public BsonDocument EventData { get; set; } // ??? What type??

        [BsonIgnoreIfNull]
        public Child Child { get; set; }

        [BsonIgnoreIfNull]
        public List<Media> Media { get; set; }
    }

    public class Child
    {
        public int ChildNr { get; set; }
        public string Name { get; set; }
        public string Avatar { get; set; }
    }

    public class Media
    {
        public int MediaNr { get; set; }
        public string Title { get; set; }
        public string ThumbUrl { get; set; }
        public string MainUrl { get; set; }
    }
}

Then different event types(data)

namespace TimelineTest.Models.EventData
{
    public class BlogPost
    {
        public int PostNr { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
    }

    public class AlbumMedia
    {
        public int AlbumNr { get; set; }
        public string Title { get; set; }
    }

    public class ChildEvent
    {
        public int EventNr { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
    }

    public class ChildSize
    {
        public int SizeNr { get; set; }
        public double Length { get; set; }
        public double Weight { get; set; }
        public string LengthFormat { get; set; }
        public string WeightFormat { get; set; }
        public string Note { get; set; }
    }

    public class OwnEvent
    {
        public string Title { get; set; }
        public string Content { get; set; }
    }
}

And my Repository

namespace TimelineTest.Repository
{
    public class TimelineDb
    {
        private static IMongoCollection<TimelineItem> GetCollection()
        {
            return Connection.Database.GetCollection<TimelineItem>("TimelineTest");
        }

        public static void CreateBlogPostEvent(int blogNr, BlogPost post)
        {
            var item = new TimelineItem();
            item.BlogNr = blogNr;
            item.EventType = TimelineItem.EventTypes.BlogPost;
            item.CreateDate = DateTime.UtcNow;
            item.EventDate = DateTime.UtcNow;
            item.EventData = ???? post;

            var db = GetCollection();

            var existingPost = db.Find(p => p.BlogNr == blogNr && item.EventData ???? == post.PostNr);

            if (existingPost != null)
            {
                db.ReplaceOne(p => p.Id == existingPost.Id, item);
            }
            else
            {
                db.InsertOne(item);
            }
        }

        public static void CreateAlbumEvent(int blogNr, AlbumMedia album, List<Media> medias)
        {
            var item = new TimelineItem();
            item.BlogNr = blogNr;
            item.EventType = TimelineItem.EventTypes.AlbumMedia;
            item.CreateDate = DateTime.UtcNow;
            item.EventDate = DateTime.UtcNow;
            item.EventData = ???? album;
            item.Media = medias;

            var db = GetCollection();

            var existingPost = db.Find(p =>
                p.BlogNr == blogNr && item.EventData.AlbumNr == album.AlbumNr &&  // item.EventData.AlbumNr  ???
                item.EventDate.ToString("yyyy-MM-dd") == p.EventDate.ToString("yyyy-MM-dd"));

            if (existingPost != null)
            {
                foreach (var media in existingPost.Media)
                {
                    item.Media.Add(media);
                }

                item.Media = item.Media.Take(5).ToList();
                db.ReplaceOne(p => p.Id == existingPost.Id, item);
            }
            else
            {
                db.InsertOne(item);
            }
        }

        public static List<TimelineItem> GetGlobalEvents(int blogNr)
        {
            return GetCollection().Find(p => p.BlogNr == blogNr && p.IsDeleted == false).ToList();
        }

        public static List<TimelineItem> GetChildrenEvents(int blogNr, int childNr)
        {
            return GetCollection().Find(p => p.BlogNr == blogNr && p.Child.ChildNr == childNr && p.IsDeleted == false).ToList();
        }

        public static void UpdateChild(int blogNr, Child child)
        {
            GetCollection().UpdateMany(p => p.BlogNr == blogNr && p.Child.ChildNr == child.ChildNr, Builders<TimelineItem>.Update.Set(p => p.Child, child), new UpdateOptions { IsUpsert = false });
        }

        public static void ChildDeleted(int blogNr, int childNr)
        {
            var db = GetCollection();
            db.DeleteMany(p => p.BlogNr == blogNr && p.Child.ChildNr == childNr);
        }

        public static void MediaDeleted(int blogNr, int mediaNr)
        {
            var db = GetCollection();
            db.DeleteMany(p => p.BlogNr == blogNr && p.Media)// How to find and delete all media items with mediaNr?;
        }

        public static string GetEventHeader(TimelineItem item)
        {
            if (item.EventType == TimelineItem.EventTypes.OwnEvent)
                return item.EventData.Title; // EventData should be of OwnEvent type/class.
            else if (item.EventType == TimelineItem.EventTypes.ChildBirth)
                return $"{item.Child.Name} was born this day";
            else if (item.EventType == TimelineItem.EventTypes.ChildSize)
                return $"{item.Child.Name} length is {item.EventData.Length} {item.EventData.LengthFormat} and weight {item.EventData.Weight} {item.EventData.WeightFormat}";   // item.EventData should be ChildSize type/class
        }
    }
}

Convert firestore data to datatable

$
0
0

I have an Android app connected to firestore and an asp.net app connected to the same firestore repo, for adminstrative tasks, using the Google.Cloud.Firestore library.

Getting back a QuerySnapshot I can loop it and construct a datatable column by column, row by row, but I was wondering if there was a faster way to do this (tried qsnapshot.Cast<DataTable> but it didn't work).

Anyone here done this before?

MySQL Scheduled Event (recurring)

$
0
0

Hi guys. I wanna create a recurring event (every 15minutes) in MySQL Database to delete transaction which is status = 'Pending' and created_date is <= current DateTime.

Below is my sql statement. Is every looked fine?

CREATE EVENT hotelBookingEvent
ON SCHEDULE EVERY 15 MINUTE
STARTS CURRENT_TIMESTAMP
ENDS CURRENT_TIMESTAMP + INTERVAL 9999 HOUR
DO
   DELETE FROM room_booking WHERE ROUND(TIME_TO_SEC(TIMEDIFF(created_date, now())) / 60) <= -15 AND status = 'Pending'

/////////////////////////////////

SET GLOBAL event_scheduler = ON;

how to replace a pilcrow symbol (¶) in MYSQL?

$
0
0

Hi,

I have tried the following but failed. Any idea?

UPDATE table1 
SET  myfield = REPLACE(myfield, CHAR(182), '<br><br>') 
UPDATE table1 
SET  myfield = REPLACE(myfield, '¶', '<br><br>') 




Viewing all 1350 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>