예제 #1
0
        public async Task <ResponseUpdate> UpdateRoutingDeal(RequestUpdate data)
        {
            var context  = _httpContext.RequestServices.GetService(typeof(RoutingDao)) as RoutingDao;
            var response = context.UpdateRoutingDeal(data);

            return(await Task.Run(() => response));
        }
예제 #2
0
 private void ProcessAttributeAssignOrUpdateValue(AttributeAssignOrUpdateValue attributeAssignOrUpdateValue,
                                                  ref RequestUpdate result)
 {
     result.UpdateUnknownProperty(attributeAssignOrUpdateValue
                                  .AttributeIDChain.ContentString,
                                  attributeAssignOrUpdateValue.Value);
 }
 /// <summary>
 /// Creates a new pipelineable get vertex request
 /// </summary>
 /// <param name="myGetEdgeTypeRequest">The get vertex request</param>
 /// <param name="mySecurity">The security token of the request initiator</param>
 /// <param name="myTransaction">The transaction token</param>
 public PipelineableUpdateRequest(RequestUpdate myUpdateRequest,
                                  SecurityToken mySecurity,
                                  Int64 myTransaction)
     : base(mySecurity, myTransaction)
 {
     _request = myUpdateRequest;
 }
예제 #4
0
        public async Task <ResponseUpdate> UpdateRoutingDeal(RequestUpdate data)
        {
            var model  = new Deal();
            var result = new ResponseUpdate();

            try
            {
                using (var conn = Get())
                {
                    conn.Open();
                    var cmd    = new MySqlCommand($"update tbl_deal set state={data.State}, url='{data.Url}', template='{data.Template}' where invoicekey = '{data.InvoiceKey}'", conn);
                    var reader = cmd.ExecuteNonQuery();

                    result.Code = 200;
                    result.Data = new UpdateDeal()
                    {
                        InvoiceKey = data.InvoiceKey,
                        State      = true,
                    };
                    result.Message = "OK";
                }
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.Message;
                result.Data    = null;
            }

            return(await Task.Run(() => result));
        }
예제 #5
0
 public ActionResult SendRequeset()
 {
     if (Session["uname"] != null)
     {
         MailModel mailModel = new MailModel();
         mailModel.To      = "Admin";
         mailModel.From    = Session["id"].ToString();
         mailModel.Subject = "Update Request";
         mailModel.Body    = "<a>You Have got an Update Request From " + mailModel.From + "</a>";
         mailModel.Date    = DateTime.Now;
         mailModel.Status  = 1;
         mailModelService.InsertMail(mailModel);
         RequestUpdate requestUpdate = new RequestUpdate();
         requestUpdate.Phone   = Request["PhoneNumber"];
         requestUpdate.NID     = Request["NationalId"];
         requestUpdate.DOB     = Convert.ToDateTime(Request["Birthday"]);
         requestUpdate.Address = Request["Address"];
         requestUpdate.Name    = Request["Name"];
         requestUpdate.Id      = Session["id"].ToString();
         if (requestUpdateService.Get(requestUpdate.Id) != null)
         {
             requestUpdateService.Delete(requestUpdate.Id);
             requestUpdateService.Insert(requestUpdate);
         }
         else
         {
             requestUpdateService.Insert(requestUpdate);
         }
         TempData["Reply"] = "Your request has been sent to the proper authority";
         return(RedirectToAction("EditProfile", "Manager"));
     }
     return(RedirectToAction("Index", "Home"));
 }
예제 #6
0
        public static RequestUpdate MakeRequestUpdateBinary(Int64 myVertexTypeID, Int64 myVertexID, String myPropertyName, Stream myStream)
        {
            var idList = new List <Int64>();

            idList.Add(myVertexID);
            var Request = new RequestUpdate(new RequestGetVertices(myVertexTypeID, idList));

            Request.UpdateBinaryProperty(myPropertyName, myStream);
            return(Request);
        }
예제 #7
0
 private void ProcessUpdate(IVertexType vertexType,
                            GQLPluginManager myPluginManager,
                            IGraphDB myGraphDB,
                            SecurityToken mySecurityToken,
                            Int64 myTransactionToken,
                            AAttributeAssignOrUpdateOrRemove aUpdate,
                            ref RequestUpdate result)
 {
     if (aUpdate is AttributeAssignOrUpdateValue)
     {
         ProcessAttributeAssignOrUpdateValue((AttributeAssignOrUpdateValue)aUpdate, ref result);
     }
     else if (aUpdate is AttributeAssignOrUpdateList)
     {
         ProcessAttributeAssignOrUpdateList(vertexType,
                                            myPluginManager,
                                            myGraphDB,
                                            mySecurityToken,
                                            myTransactionToken,
                                            (AttributeAssignOrUpdateList)aUpdate,
                                            ref result);
     }
     else if (aUpdate is AttributeAssignOrUpdateSetRef)
     {
         ProcessAttributeAssignOrUpdateSetRef(vertexType,
                                              myPluginManager,
                                              myGraphDB,
                                              mySecurityToken,
                                              myTransactionToken,
                                              (AttributeAssignOrUpdateSetRef)aUpdate,
                                              ref result);
     }
     else if (aUpdate is AttributeRemove)
     {
         foreach (var aToBeRemovedAttribute in ((AttributeRemove)aUpdate).ToBeRemovedAttributes)
         {
             result.RemoveAttribute(aToBeRemovedAttribute);
         }
     }
     else if (aUpdate is AttributeRemoveList)
     {
         ProcessAttributeRemoveList(vertexType,
                                    myPluginManager,
                                    myGraphDB,
                                    mySecurityToken,
                                    myTransactionToken,
                                    (AttributeRemoveList)aUpdate,
                                    ref result);
     }
     else
     {
         throw new NotImplementedQLException("");
     }
 }
예제 #8
0
        public override T AlterType(IRequestAlterType myAlterTypeRequest,
                                    Int64 myTransactionToken,
                                    SecurityToken mySecurityToken,
                                    out RequestUpdate myUpdateRequest)
        {
            CheckRequestType(myAlterTypeRequest);

            var type = GetType(myAlterTypeRequest.TypeName, myTransactionToken, mySecurityToken);

            RequestUpdate updateRequest = (myAlterTypeRequest is RequestAlterVertexType) ?
                                          new RequestUpdate(new RequestGetVertices(type.ID))
                                            : new RequestUpdate();

            #region remove stuff

            AlterType_Remove(myAlterTypeRequest,
                             type,
                             myTransactionToken,
                             mySecurityToken,
                             ref updateRequest);

            CleanUpTypes();

            #endregion

            #region add stuff

            AlterType_Add(myAlterTypeRequest,
                          type,
                          myTransactionToken,
                          mySecurityToken,
                          ref updateRequest);

            CleanUpTypes();

            #endregion

            type = GetType(myAlterTypeRequest.TypeName,
                           myTransactionToken,
                           mySecurityToken);

            RenamesAndComment(myAlterTypeRequest,
                              type,
                              myTransactionToken,
                              mySecurityToken);

            CleanUpTypes();

            CallRebuildIndices(myTransactionToken, mySecurityToken);

            myUpdateRequest = updateRequest;

            return(GetType(type.ID, myTransactionToken, mySecurityToken));
        }
예제 #9
0
        public bool StartUpdate()
        {
            try
            {
                var sucess = false;
                sucess = StartDownload().Result;

                if (!sucess)
                {
                    return(false);
                }

                if (RequestUpdate.DefaultExtrationZip)
                {
                    string zipToUnpack     = _DonwloadFilePath;
                    string unpackDirectory = RequestUpdate.PathToExtract;
                    using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
                    {
                        // here, we extract every entry, but we could extract conditionally
                        // based on entry name, size, date, checkbox status, etc.
                        foreach (ZipEntry e in zip1)
                        {
                            e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
                        }
                    }
                }

                if (RequestUpdate.CallFunctionAfterDownload != null)
                {
                    RequestUpdate.CallFunctionAfterDownload(_DonwloadFilePath);
                }

                if (RequestUpdate.ComandLinesToExecutAfterUpdate != null)
                {
                    foreach (var item in RequestUpdate.ComandLinesToExecutAfterUpdate)
                    {
                        var cmd = new Cmd(item);
                        cmd.Run();
                    }
                }


                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Falha no autoUpdate! " + ex.Message);
                Console.ForegroundColor = ConsoleColor.White;
                throw;
            }
        }
        public static Domain.Customer MapToDomain(RequestUpdate update)
        {
            var customer = new Domain.Customer
            {
                CustomerId   = update.CustomerId,
                Forename     = update.Forename,
                Surname      = update.Surname,
                EmailAddress = update.EmailAddress,
                Password     = update.Password
            };

            return(customer);
        }
예제 #11
0
        public TResult Update <TResult>(SecurityToken mySecurityToken,
                                        Int64 myTransactionToken,
                                        RequestUpdate myRequestUpdate,
                                        Converter.UpdateResultConverter <TResult> myOutputconverter)
        {
            var executedRequest =
                _requestManager
                .SynchronExecution(new PipelineableUpdateRequest(myRequestUpdate,
                                                                 mySecurityToken,
                                                                 myTransactionToken));

            return(((PipelineableUpdateRequest)executedRequest)
                   .GenerateRequestResult(myOutputconverter));
        }
예제 #12
0
        /// <summary>
        /// Reads an edge information from the GraphML File and inserts
        /// the edge in the GraphDB by altering the existing source vertex.
        ///
        /// Currently only the "weight" attribute will be considered and
        /// has to be annotated correctly (see class documentation).
        /// </summary>
        /// <param name='myReader'>
        /// XmlReader
        /// </param>
        private void ReadEdge(XmlReader myReader)
        {
            #region read edge data

            var sourceID = ReadVertexID(myReader, GraphMLTokens.SOURCE);
            var targetID = ReadVertexID(myReader, GraphMLTokens.TARGET);

            if (!_VertexIDMapper.ContainsKey(sourceID) || !_VertexIDMapper.ContainsKey(targetID))
            {
                throw new InvalidDataException(String.Format(
                                                   "Source or Target vertexID for edge ({0},{1}) doesn't exist",
                                                   sourceID,
                                                   targetID));
            }

            // get the weight
            var edgeWeight = ReadEdgeWeight(myReader);

            #endregion

            #region create edge (update vertex)

            var hyperEdge = new EdgePredefinition(_EdgeTypeName);
            hyperEdge.AddEdge(new EdgePredefinition()
                              .AddVertexID(_VertexTypeName, _VertexIDMapper[targetID])
                              .AddUnknownProperty(
                                  GraphMLTokens.EDGE_WEIGHT,
                                  Convert.ChangeType(edgeWeight, typeof(String), CultureInfo.GetCultureInfo("en-us"))
                                  ));


            var requestUpdate = new RequestUpdate(new RequestGetVertices(_VertexTypeName, new List <long>()
            {
                _VertexIDMapper[sourceID]
            }));
            requestUpdate.AddElementsToCollection(_EdgeTypeName, hyperEdge);

            // process the update
            _GraphDB.Update <IEnumerable <IVertex> >(
                _SecurityToken,
                _TransactionToken,
                requestUpdate,
                (stats, v) => v
                );

            _EdgeCount++;

            #endregion
        }
예제 #13
0
        public async Task <IActionResult> Update([FromBody] RequestUpdate request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _serviceSpend.Update(request);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result.Message));
            }
            return(Ok(result));
        }
예제 #14
0
        public async Task EchoAsync(RequestUpdate update, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(update.Message.Text) || !(update.Message.Text.Contains("camera1") || update.Message.Text.Contains("camera7")))
            {
                return;
            }

            var url = update.Message.Text.Contains("camera1") ? camera1Url : camera7Url;

            var browser = new ChromiumWebBrowser(url, new BrowserSettings
            {
                FileAccessFromFileUrls      = CefState.Enabled,
                UniversalAccessFromFileUrls = CefState.Enabled,
                Javascript       = CefState.Enabled,
                ApplicationCache = CefState.Disabled
            });

            while (browser.IsLoading)
            {
                await Task.Delay(500, cancellationToken);
            }

            while (!browser.CanExecuteJavascriptInMainFrame)
            {
                await Task.Delay(500, cancellationToken);
            }

            await Task.Delay(1500, cancellationToken);

            browser.ExecuteScriptAsync("$('.b-embed-logo').remove()");
            await Task.Delay(100, cancellationToken);

            browser.ExecuteScriptAsync("$('.b-embed-btn-play-wrapper').remove()");
            await Task.Delay(100, cancellationToken);

            var screenshot = await browser.ScreenshotAsync();

            if (null == screenshot)
            {
                return;
            }
            var memoryStream = new MemoryStream();

            screenshot.Save(memoryStream, ImageFormat.Png);
            memoryStream.Seek(0, SeekOrigin.Begin);
            var photo = new InputOnlineFile(memoryStream);
            await _botService.Client.SendPhotoAsync(update.Message.Chat.Id, photo, cancellationToken : cancellationToken, caption : $"{DateTime.Now:F}");
        }
예제 #15
0
 private void RequestHandler(byte[] obj)
 {
     try
     {
         RequestUpdate UpdatePacket = MyAPIGateway.Utilities.SerializeFromBinary <RequestUpdate>(obj);
         Radar         rad          = GetRadar(UpdatePacket.EntityId);
         if (rad != null)
         {
             RangeUpdate Update = new RangeUpdate(UpdatePacket.EntityId, rad.Range);
             MyAPIGateway.Multiplayer.SendMessageToOthers(RADARMESSAGE, MyAPIGateway.Utilities.SerializeToBinary(UpdatePacket));
         }
     }
     catch
     {
         //failed to sync with server
     }
 }
예제 #16
0
        public async Task <ApiResult <bool> > Update(RequestUpdate request)
        {
            var spend = await _context.Spends.FindAsync(request.Id);

            if (spend == null)
            {
                return(new ApiErrorResult <bool>("Khong tim thay"));
            }
            spend.Name        = request.Name;
            spend.Description = request.Description;
            spend.Img         = request.Img;
            spend.Status      = request.Status;

            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>());
        }
예제 #17
0
 private void ProcessListOfUpdates(IVertexType vertexType,
                                   GQLPluginManager myPluginManager,
                                   IGraphDB myGraphDB,
                                   SecurityToken mySecurityToken,
                                   Int64 myTransactionToken,
                                   ref RequestUpdate result)
 {
     foreach (var aUpdate in _listOfUpdates)
     {
         ProcessUpdate(vertexType,
                       myPluginManager,
                       myGraphDB,
                       mySecurityToken,
                       myTransactionToken,
                       aUpdate,
                       ref result);
     }
 }
        public async Task <ApiResult <bool> > Update(RequestUpdate request)
        {
            var makeMoney = await _context.MakeMoneys.FindAsync(request.Id);

            if (makeMoney == null)
            {
                return(new ApiErrorResult <bool>("Không tìm thấy "));
            }

            makeMoney.Name        = request.Name;
            makeMoney.Description = request.Description;
            makeMoney.Img         = request.Img;
            makeMoney.Status      = request.Status;

            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>());
        }
예제 #19
0
        internal RequestGetVertices CreateGetVerticesRequest(IMetaManager myMetaManager,
                                                             RequestUpdate myRequestUpdate)
        {
            var outEdges = myRequestUpdate.UpdateOutgoingEdgesProperties;

            if (outEdges != null)
            {
                var userdefTypes = myMetaManager
                                   .VertexTypeManager
                                   .ExecuteManager
                                   .GetAllTypes(Int64,
                                                SecurityToken)
                                   .Where(_ => _
                                          .IsUserDefined);

                if (userdefTypes != null && userdefTypes.Count() > 0)
                {
                    var types =
                        userdefTypes
                        .Where(_ => _
                               .GetOutgoingEdgeDefinitions(false)
                               .Any(x => x.EdgeType
                                    .ID
                                    .Equals(outEdges.First().EdgeTypeID) ||
                                    x
                                    .InnerEdgeType
                                    .ID
                                    .Equals(outEdges.First().EdgeTypeID)));

                    if (types != null && types.Count() > 0)
                    {
                        return(new RequestGetVertices(types.FirstOrDefault().ID));
                    }
                }
            }
            else
            {
                throw new TypeDoesNotExistException <IVertexType>(
                          "Empty",
                          "There is no type found to update after alter type.");
            }

            return(null);
        }
 public ActionResult Approve(string id)
 {
     if (Session["uname"] != null)
     {
         RequestUpdate requestUpdate = requestUpdateService.Get(id);
         Employee      empToUpdate   = new Employee();
         empToUpdate.Id          = requestUpdate.Id;
         empToUpdate.Name        = requestUpdate.Name;
         empToUpdate.Birthday    = requestUpdate.DOB;
         empToUpdate.Address     = requestUpdate.Address;
         empToUpdate.PhoneNumber = Convert.ToInt32(requestUpdate.Phone);
         empToUpdate.NationalId  = requestUpdate.NID;
         employeeService.UpdateEmployeeByAdmin(empToUpdate);
         requestUpdateService.Delete(id);
         Session["Count"] = requestUpdateService.getRowCount();
         return(RedirectToAction("Inbox"));
     }
     return(RedirectToAction("Index", "Home"));
 }
예제 #21
0
        static void Main(string[] args)
        {
            var request = new RequestUpdate()
            {
                DefaultExtrationZip            = true,
                LinkDownloadNewApp             = "http://api.yellrek.com.br/resources/data/search.zip",
                PathToExtract                  = @"C:\Users\jonatas.campos\Desktop\searchSmiles",
                ComandLinesToExecutAfterUpdate = new List <string>()
                {
                    @"start C:\Users\jonatas.campos\Desktop\searchSmiles\SmilesAutoSearch.exe"
                }
            };

            var update = new UpdateHandler(request);
            var json   = JsonConvert.SerializeObject(request, Formatting.Indented);

            update.StartUpdate();
            Console.ReadKey();
        }
예제 #22
0
        //@Headers({ "Content-Type: application/json"})
        //@POST("api/v1/data/update")
        //Call<ResponseUpdate> update(@Body RequestUpdate requestUpdate);
        public async Task <ResponseUpdate> UpdateAsync(RequestUpdate requestUpdate)
        {
            var uri = new Uri(baseUri + @"api/v1/data/update");
            // Сформировать JSON данные
            string jsonContent = JsonConvert.SerializeObject(requestUpdate);
            HttpResponseMessage httpResponse = await cmd.PostAsync(uri, jsonContent);

            ResponseUpdate.Results results        = new ResponseUpdate.Results();
            ResponseUpdate         responseRemove = new ResponseUpdate(results);

            if (httpResponse.IsSuccessStatusCode)
            {
                responseRemove = JsonConvert.DeserializeObject <ResponseUpdate>(httpResponse.Content.ToString());
            }
            else
            {
                responseRemove.Error   = true;
                responseRemove.ErrCode = "";
                responseRemove.ErrMsg  = "Ошибка HttpClient.";
            }
            return(responseRemove);
        }
예제 #23
0
        private void ProcessAttributeAssignOrUpdateList(IVertexType vertexType,
                                                        GQLPluginManager myPluginManager,
                                                        IGraphDB myGraphDB,
                                                        SecurityToken mySecurityToken,
                                                        Int64 myTransactionToken,
                                                        AttributeAssignOrUpdateList attributeAssignOrUpdateList,
                                                        ref RequestUpdate result)
        {
            Type myRequestedType;

            switch (attributeAssignOrUpdateList.CollectionDefinition.CollectionType)
            {
            case CollectionType.Set:

                #region set

                if (((TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition).All(_ => _.Value is ValueDefinition))
                {
                    #region base-set

                    //has to be list of comparables
                    SetCollectionWrapper setWrapper = new SetCollectionWrapper();

                    if (vertexType.HasProperty(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
                    {
                        myRequestedType = ((IPropertyDefinition)vertexType.GetAttributeDefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString)).BaseType;
                    }
                    else
                    {
                        myRequestedType = typeof(String);
                    }

                    foreach (var aTupleElement in (TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition)
                    {
                        setWrapper.Add(((ValueDefinition)aTupleElement.Value).Value.ConvertToIComparable(myRequestedType));
                    }

                    result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, setWrapper);

                    #endregion
                }
                else
                {
                    #region edge-set

                    EdgePredefinition edgeDefinition = new EdgePredefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString);

                    if (!vertexType.HasAttribute(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
                    {
                        throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeAssignOrUpdateList.AttributeIDChain.ContentString));
                    }

                    IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString);
                    foreach (var aTupleElement in (TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition)
                    {
                        if (aTupleElement.Value is BinaryExpressionDefinition)
                        {
                            #region BinaryExpressionDefinition

                            var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;

                            foreach (var aVertex in ProcessBinaryExpression(
                                         (BinaryExpressionDefinition)aTupleElement.Value,
                                         myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType))
                            {
                                var inneredge = new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID);

                                foreach (var aStructuredProperty in aTupleElement.Parameters)
                                {
                                    inneredge.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
                                }

                                edgeDefinition.AddEdge(inneredge);
                            }

                            #endregion
                        }
                        else
                        {
                            throw new NotImplementedQLException("TODO");
                        }
                    }

                    if (attributeAssignOrUpdateList.Assign)
                    {
                        result.UpdateEdge(edgeDefinition);
                    }
                    else
                    {
                        result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, edgeDefinition);
                    }

                    #endregion
                }
                #endregion

                return;

            case CollectionType.List:

                #region list

                //has to be list of comparables
                ListCollectionWrapper listWrapper = new ListCollectionWrapper();

                if (vertexType.HasProperty(attributeAssignOrUpdateList.AttributeIDChain.ContentString))
                {
                    myRequestedType = ((IPropertyDefinition)vertexType.GetAttributeDefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString)).BaseType;
                }
                else
                {
                    myRequestedType = typeof(String);
                }

                foreach (var aTupleElement in (TupleDefinition)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition)
                {
                    listWrapper.Add(((ValueDefinition)aTupleElement.Value).Value.ConvertToIComparable(myRequestedType));
                }

                result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, listWrapper);

                #endregion

                return;

            case CollectionType.SetOfUUIDs:

                #region SetOfUUIDs

                EdgePredefinition anotheredgeDefinition = new EdgePredefinition(attributeAssignOrUpdateList.AttributeIDChain.ContentString);

                foreach (var aTupleElement in ((VertexTypeVertexIDCollectionNode)attributeAssignOrUpdateList.CollectionDefinition.TupleDefinition).Elements)
                {
                    foreach (var aVertexIDTuple in aTupleElement.VertexIDs)
                    {
                        var innerEdge = new EdgePredefinition();

                        foreach (var aStructuredProperty in aVertexIDTuple.Item2)
                        {
                            innerEdge.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
                        }

                        innerEdge.AddVertexID(aTupleElement.ReferencedVertexTypeName, aVertexIDTuple.Item1);

                        anotheredgeDefinition.AddEdge(innerEdge);
                    }
                }

                result.AddElementsToCollection(attributeAssignOrUpdateList.AttributeIDChain.ContentString, anotheredgeDefinition);

                #endregion

                return;

            default:
                return;
            }
        }
예제 #24
0
        private void ProcessAttributeAssignOrUpdateSetRef(IVertexType vertexType,
                                                          GQLPluginManager myPluginManager,
                                                          IGraphDB myGraphDB,
                                                          SecurityToken mySecurityToken,
                                                          Int64 myTransactionToken,
                                                          AttributeAssignOrUpdateSetRef attributeAssignOrUpdateSetRef,
                                                          ref RequestUpdate result)
        {
            #region SetRefNode

            var edgeDefinition = new EdgePredefinition(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString);

            if (attributeAssignOrUpdateSetRef.SetRefDefinition.IsREFUUID)
            {
                #region direct vertex ids

                foreach (var aTupleElement in attributeAssignOrUpdateSetRef.SetRefDefinition.TupleDefinition)
                {
                    if (aTupleElement.Value is ValueDefinition)
                    {
                        #region ValueDefinition

                        foreach (var aProperty in aTupleElement.Parameters)
                        {
                            edgeDefinition.AddUnknownProperty(aProperty.Key, aProperty.Value);
                        }

                        edgeDefinition.AddVertexID(
                            attributeAssignOrUpdateSetRef.SetRefDefinition.ReferencedVertexType,
                            Convert.ToInt64(((ValueDefinition)aTupleElement.Value).Value));

                        #endregion
                    }
                    else
                    {
                        throw new NotImplementedQLException("TODO");
                    }
                }

                result.UpdateEdge(edgeDefinition);

                #endregion
            }
            else
            {
                #region expression

                if (!vertexType.HasAttribute(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString))
                {
                    throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString));
                }
                IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeAssignOrUpdateSetRef.AttributeIDChain.ContentString);

                foreach (var aTupleElement in attributeAssignOrUpdateSetRef.SetRefDefinition.TupleDefinition)
                {
                    if (aTupleElement.Value is BinaryExpressionDefinition)
                    {
                        #region BinaryExpressionDefinition

                        var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;

                        var vertexIDs = ProcessBinaryExpression(
                            (BinaryExpressionDefinition)aTupleElement.Value,
                            myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType).ToList();

                        if (vertexIDs.Count > 1)
                        {
                            throw new ReferenceAssignmentExpectedException(String.Format("It is not possible to create a single edge pointing to {0} vertices", vertexIDs.Count));
                        }

                        var inneredge = new EdgePredefinition();

                        foreach (var aStructuredProperty in aTupleElement.Parameters)
                        {
                            edgeDefinition.AddUnknownProperty(aStructuredProperty.Key, aStructuredProperty.Value);
                        }

                        edgeDefinition.AddVertexID(vertexIDs.FirstOrDefault().VertexTypeID, vertexIDs.FirstOrDefault().VertexID);

                        #endregion
                    }
                    else
                    {
                        throw new NotImplementedQLException("");
                    }
                }

                #endregion

                result.UpdateEdge(edgeDefinition);

                return;
            }

            #endregion
        }
예제 #25
0
        private void ProcessAttributeRemoveList(IVertexType vertexType,
                                                GQLPluginManager myPluginManager,
                                                IGraphDB myGraphDB,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken,
                                                AttributeRemoveList attributeRemoveList,
                                                ref RequestUpdate result)
        {
            if (attributeRemoveList.TupleDefinition is VertexTypeVertexIDCollectionNode)
            {
                #region setofUUIDs

                var edgedef = new EdgePredefinition(attributeRemoveList.AttributeName);

                List <EdgePredefinition> toBeRemovedEdges = new List <EdgePredefinition>();

                foreach (var aTupleElement in ((VertexTypeVertexIDCollectionNode)attributeRemoveList.TupleDefinition).Elements)
                {
                    foreach (var aVertexIDTuple in aTupleElement.VertexIDs)
                    {
                        var innerEdge = new EdgePredefinition();

                        innerEdge.AddVertexID(aTupleElement.ReferencedVertexTypeName, aVertexIDTuple.Item1);

                        edgedef.AddEdge(innerEdge);
                    }
                }

                result.RemoveElementsFromCollection(attributeRemoveList.AttributeName, edgedef);

                #endregion
            }
            else if (attributeRemoveList.TupleDefinition is TupleDefinition)
            {
                if (((TupleDefinition)attributeRemoveList.TupleDefinition).All(_ => _.Value is ValueDefinition))
                {
                    #region base-set

                    //has to be list of comparables
                    ListCollectionWrapper listWrapper = new ListCollectionWrapper();
                    Type myRequestedType;
                    if (vertexType.HasProperty(attributeRemoveList.AttributeIDChain.ContentString))
                    {
                        myRequestedType = ((IPropertyDefinition)vertexType.GetAttributeDefinition(attributeRemoveList.AttributeIDChain.ContentString)).BaseType;
                    }
                    else
                    {
                        myRequestedType = typeof(String);
                    }

                    foreach (var aTupleElement in (TupleDefinition)attributeRemoveList.TupleDefinition)
                    {
                        listWrapper.Add(((ValueDefinition)aTupleElement.Value).Value.ConvertToIComparable(myRequestedType));
                    }

                    result.RemoveElementsFromCollection(attributeRemoveList.AttributeIDChain.ContentString, listWrapper);

                    #endregion
                }
                else
                {
                    #region binaryExpression

                    Dictionary <String, EdgePredefinition> toBeRemovedEdges = new Dictionary <String, EdgePredefinition>();

                    foreach (var aTupleElement in ((TupleDefinition)attributeRemoveList.TupleDefinition))
                    {
                        if (aTupleElement.Value is BinaryExpressionDefinition)
                        {
                            #region BinaryExpressionDefinition

                            if (!vertexType.HasAttribute(attributeRemoveList.AttributeName))
                            {
                                throw new InvalidVertexAttributeException(String.Format("The vertex type {0} has no attribute named {1}.", vertexType.Name, attributeRemoveList.AttributeName));
                            }

                            IAttributeDefinition attribute = vertexType.GetAttributeDefinition(attributeRemoveList.AttributeName);

                            var targetVertexType = ((IOutgoingEdgeDefinition)attribute).TargetVertexType;

                            var vertexIDs = ProcessBinaryExpression(
                                (BinaryExpressionDefinition)aTupleElement.Value,
                                myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, targetVertexType).ToList();

                            if (vertexIDs.Count > 1)
                            {
                                throw new ReferenceAssignmentExpectedException(String.Format("It is not possible to create a single edge pointing to {0} vertices", vertexIDs.Count));
                            }

                            EdgePredefinition outValue = null;

                            if (toBeRemovedEdges.TryGetValue(attributeRemoveList.AttributeName, out outValue))
                            {
                                foreach (var aVertex in vertexIDs)
                                {
                                    outValue.AddEdge(new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID));
                                }
                            }
                            else
                            {
                                EdgePredefinition edge = new EdgePredefinition(attributeRemoveList.AttributeName);

                                foreach (var aVertex in vertexIDs)
                                {
                                    edge.AddEdge(new EdgePredefinition().AddVertexID(aVertex.VertexTypeID, aVertex.VertexID));
                                }

                                toBeRemovedEdges.Add(attributeRemoveList.AttributeName, edge);
                            }

                            #endregion
                        }
                        else
                        {
                            throw new NotImplementedQLException("");
                        }
                    }

                    foreach (var item in toBeRemovedEdges)
                    {
                        result.RemoveElementsFromCollection(item.Key, item.Value);
                    }

                    #endregion
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
예제 #26
0
        public static RequestUpdate MakeRequestUpdate(ServiceUpdateChangeset myUpdateChangeset)
        {
            #region PreRequest

            RequestGetVertices PreRequest = null;
            if (myUpdateChangeset.Expression == null)
            {
                if (myUpdateChangeset.VertexTypeName != null)
                {
                    PreRequest = MakeRequestGetVertices(myUpdateChangeset.VertexTypeName, myUpdateChangeset.VertexIDs);
                }
                else
                {
                    PreRequest = MakeRequestGetVertices(myUpdateChangeset.VertexTypeID, myUpdateChangeset.VertexIDs);
                }
            }
            else
            {
                PreRequest = MakeRequestGetVertices(myUpdateChangeset.Expression);
            }

            RequestUpdate Request = new RequestUpdate(PreRequest);

            if (!String.IsNullOrEmpty(myUpdateChangeset.Comment))
            {
                Request.UpdateComment(myUpdateChangeset.Comment);
            }

            if (!String.IsNullOrEmpty(myUpdateChangeset.Edition))
            {
                Request.UpdateEdition(myUpdateChangeset.Edition);
            }

            #endregion


            #region element collection

            if (myUpdateChangeset.AddedElementsToCollectionProperties != null)
            {
                foreach (var element in myUpdateChangeset.AddedElementsToCollectionProperties)
                {
                    Request.AddElementsToCollection(element.Key, element.Value);
                }
            }

            if (myUpdateChangeset.RemovedElementsFromCollectionProperties != null)
            {
                foreach (var element in myUpdateChangeset.RemovedElementsFromCollectionProperties)
                {
                    Request.RemoveElementsFromCollection(element.Key, element.Value);
                }
            }

            if (myUpdateChangeset.AddedElementsToCollectionEdges != null)
            {
                foreach (var element in myUpdateChangeset.AddedElementsToCollectionEdges)
                {
                    Request.AddElementsToCollection(element.Key, element.Value.ToEdgePredefinition());
                }
            }

            if (myUpdateChangeset.RemovedElementsFromCollectionEdges != null)
            {
                foreach (var element in myUpdateChangeset.RemovedElementsFromCollectionEdges)
                {
                    Request.RemoveElementsFromCollection(element.Key, element.Value.ToEdgePredefinition());
                }
            }

            #endregion


            #region Properties

            if (myUpdateChangeset.UpdatedStructuredProperties != null)
            {
                foreach (var item in myUpdateChangeset.UpdatedStructuredProperties)
                {
                    Request.UpdateStructuredProperty(item.Key, item.Value);
                }
            }

            if (myUpdateChangeset.UpdatedUnstructuredProperties != null)
            {
                foreach (var item in myUpdateChangeset.UpdatedUnstructuredProperties)
                {
                    Request.UpdateUnstructuredProperty(item.Key, item.Value);
                }
            }

            if (myUpdateChangeset.UpdatedUnknownProperties != null)
            {
                foreach (var item in myUpdateChangeset.UpdatedUnknownProperties)
                {
                    Request.UpdateUnknownProperty(item.Key, item.Value);
                }
            }

            #endregion


            #region Update Edges

            if (myUpdateChangeset.UpdatedOutgoingEdges != null)
            {
                foreach (var Edge in myUpdateChangeset.UpdatedOutgoingEdges)
                {
                    Request.UpdateEdge(Edge.ToEdgePredefinition());
                }
            }

            if (myUpdateChangeset.UpdateOutgoingEdgesProperties != null)
            {
                foreach (var Edge in myUpdateChangeset.UpdateOutgoingEdgesProperties)
                {
                    Request.UpdateEdge(Edge.ToSingleEdgeUpdateDefinition());
                }
            }

            #endregion

            if (myUpdateChangeset.RemovedAttributes != null)
            {
                foreach (var item in myUpdateChangeset.RemovedAttributes)
                {
                    Request.RemoveAttribute(item);
                }
            }

            return(Request);
        }
예제 #27
0
        private RequestUpdate GenerateUpdateRequest(IGraphDB myGraphDB, GQLPluginManager myPluginManager, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            IEnumerable <IVertex> toBeupdatedVertices = null;
            //prepare
            var vertexType = myGraphDB.GetVertexType <IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_TypeName),
                (stats, vtype) => vtype);

            RequestUpdate result = null;

            if (_vertexIDs == null)
            {
                if (_WhereExpression != null)
                {
                    //validate
                    _WhereExpression.Validate(myPluginManager,
                                              myGraphDB,
                                              mySecurityToken,
                                              myTransactionToken,
                                              vertexType);

                    //calculate
                    var expressionGraph = _WhereExpression.Calculon(myPluginManager,
                                                                    myGraphDB,
                                                                    mySecurityToken,
                                                                    myTransactionToken,
                                                                    new CommonUsageGraph(myGraphDB,
                                                                                         mySecurityToken,
                                                                                         myTransactionToken),
                                                                    false);

                    //extract
                    toBeupdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB,
                                                                              mySecurityToken,
                                                                              myTransactionToken),
                                                                 null, true);

                    result = new RequestUpdate(
                        new RequestGetVertices(toBeupdatedVertices
                                               .Select(_ => _.VertexTypeID)
                                               .FirstOrDefault(),
                                               toBeupdatedVertices.Select(_ => _.VertexID), false));
                }
                else
                {
                    toBeupdatedVertices = myGraphDB.GetVertices <IEnumerable <IVertex> >(
                        mySecurityToken,
                        myTransactionToken,
                        new RequestGetVertices(vertexType.ID),
                        (stats, vertices) => vertices);
                }
            }
            else
            {
                toBeupdatedVertices = _vertexIDs;
            }

            if (result == null)
            {
                result = new RequestUpdate(new RequestGetVertices(vertexType.ID,
                                                                  toBeupdatedVertices
                                                                  .Select(_ => _.VertexID),
                                                                  false));
            }

            ProcessListOfUpdates(vertexType,
                                 myPluginManager,
                                 myGraphDB,
                                 mySecurityToken,
                                 myTransactionToken,
                                 ref result);

            return(result);
        }
예제 #28
0
 public abstract T AlterType(IRequestAlterType myAlterTypeRequest,
                             Int64 myTransactionToken,
                             SecurityToken mySecurityToken,
                             out RequestUpdate myUpdateRequest);
예제 #29
0
 /// <summary>
 /// Updates a set of vertices and returns them.
 /// </summary>
 /// <param name="myUpdate">The request that represents the update.</param>
 /// <param name="Int64">A transaction token for this operation.</param>
 /// <param name="SecurityToken">A security token for this operation.</param>
 /// <returns>The updated vertivess.</returns>
 public abstract IEnumerable <IVertex> UpdateVertices(RequestUpdate myUpdate, Int64 myTransaction, SecurityToken mySecurity);
예제 #30
0
        public async void EditRequest()
        {
            //DateTime SamplingDate = Convert.ToDateTime(Request.samplingDate);
            //string DateToString = SamplingDate.ToString("yyyy-MM-dd HH:mm:ss");
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            if (Request.client == null)
            {
                Value = true;
                return;
            }
            var _biologicalMaterials = new List <BiologicalMaterials>()
            {
                new BiologicalMaterials()
                {
                    barCode = "", description = "external"
                }
            };

            if (Request.requestCatalog == null)
            {
                _request = new Request
                {
                    id                  = Request.id,
                    patient             = Request.patient,
                    client              = Request.client,
                    status              = Request.status,
                    price               = Request.price,
                    branch              = Request.branch,
                    checkDate           = Request.checkDate,
                    code                = Request.code,
                    creationDate        = Request.creationDate,
                    executionDate       = Request.executionDate,
                    icdo                = Request.icdo,
                    instrument          = Request.instrument,
                    room                = Request.room,
                    nomenclatura        = Request.nomenclatura,
                    requestCatalog      = Request.requestCatalog,
                    siapec              = Request.siapec,
                    biologicalMaterials = _biologicalMaterials,
                    groupId             = Request.groupId,
                    billDownloaded      = Request.billDownloaded,
                    isCloned            = Request.isCloned,
                    isHandled           = Request.isHandled,
                    isMaster            = Request.isMaster,
                    isPositive          = Request.isPositive,
                    samplingDate        = Request.samplingDate,
                    doctorNoRef         = Request.doctorNoRef,
                    drugDescription     = Request.drugDescription,
                    createBy            = Request.createBy
                };
            }
            else
            {
                _request = new Request
                {
                    id                  = Request.id,
                    patient             = Request.patient,
                    client              = Request.client,
                    status              = Request.status,
                    price               = Request.price,
                    branch              = Request.requestCatalog.branch,
                    checkDate           = Request.checkDate,
                    code                = Request.code,
                    creationDate        = Request.creationDate,
                    executionDate       = Request.executionDate,
                    icdo                = Request.requestCatalog.icdo,
                    instrument          = Request.instrument,
                    room                = Request.room,
                    nomenclatura        = Request.requestCatalog.nomenclatura,
                    requestCatalog      = Request.requestCatalog,
                    siapec              = Request.requestCatalog.siapec,
                    biologicalMaterials = _biologicalMaterials,
                    groupId             = Request.groupId,
                    billDownloaded      = Request.billDownloaded,
                    isCloned            = Request.isCloned,
                    isHandled           = Request.isHandled,
                    isMaster            = Request.isMaster,
                    isPositive          = Request.isPositive,
                    samplingDate        = Request.samplingDate,
                    doctorNoRef         = Request.doctorNoRef,
                    drugDescription     = Request.drugDescription,
                    createBy            = Request.createBy
                };
            }
            var requestUpdate = new RequestUpdate
            {
                request             = _request,
                biologicalMaterials = _biologicalMaterials
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Put <RequestUpdate>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/request/update",
                res,
                requestUpdate);

            Debug.WriteLine("********responseIn ViewModel*************");
            Debug.WriteLine(response);

            /*if (!response.IsSuccess)
             * {
             *  await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");
             *  return;
             * }*/

            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Request Updated");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }