public void AddProductKeyword(int productId, string keyword)
        {
            ProductEntity p = new ProductEntity(productId);
            KeywordCollection keywords = new KeywordCollection();
            keywords.GetMulti(null);

            if (keywords.Any(pr => pr.Keyword == keyword))
            {
                int keywordId = keywords.Where<KeywordEntity>(f => f.Keyword == keyword).FirstOrDefault().Id;

                ProductKeywordEntity productKeyword = new ProductKeywordEntity();
                productKeyword.KeywordId = keywordId;
                productKeyword.ProductId = productId;
                productKeyword.Save();
            }
            else
            {
                KeywordEntity k = new KeywordEntity();
                k.Keyword = keyword;
                k.Save();

                ProductKeywordEntity newProductKeyword = new ProductKeywordEntity();
                newProductKeyword.KeywordId = k.Id;
                newProductKeyword.ProductId = productId;
                newProductKeyword.Save();

            }
        }
Ejemplo n.º 2
0
 public void DllTest()
 {
     Assembly a = Assembly.LoadFrom(@"F:\Prog\gnutella2\bin\Debug\gnutella2.dll");
     Type type = a.GetType("ActionInnocence.P2PScan.ProtocolPlugin");
     IProtocol protocol = (IProtocol)Activator.CreateInstance(type, new string[] { @"F:\Prog\gnutella2\bin\Debug\", "192.168.1.38" });
     protocol.NewResult += new SearchResultHandler(protocol_NewResult);
     protocol.Connect();
     Thread.Sleep(1000 * 2);
     Keyword w = new Keyword("gnutella2","madonna");
     KeywordCollection coll = new KeywordCollection();
     coll.Add(w);
     protocol.SearchKeyword(new SearchTransaction("1", coll, 1, null));
     System.Threading.Thread.Sleep(1000 * 30);
     protocol.Disconnect();
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "MAIN G2 thread";
            ProtocolPlugin protocol = new ProtocolPlugin(Directory.GetCurrentDirectory(), "88.88.88.88");
            protocol.NewResult += new SearchResultHandler(NewResult);
            protocol.Connect();
            Thread.Sleep(10 * 1000);
            KeywordCollection coll = new KeywordCollection();
            //coll.Add(new Keyword(protocol.GetProtocolName(), "phtc"));
            coll.Add(new Keyword(protocol.GetProtocolName(), "madonna"));
            protocol.SearchKeyword(new SearchTransaction("1", coll, 1, null));

            Console.WriteLine("Sleeping ................................");
            Console.Read();
        }
        public string GetKeywordListPrefix(string prefix)
        {
            KeywordCollection keywords = new KeywordCollection();
            PredicateExpression filter = new PredicateExpression();

            filter.Add(new FieldLikePredicate(KeywordFields.Keyword, null, prefix + "%"));

            keywords.GetMulti(filter);

            StringBuilder sb = new StringBuilder();

            foreach (var item in keywords)
            {
                sb.Append(item.Keyword).Append(Environment.NewLine);
            }

            return sb.ToString();
        }
Ejemplo n.º 5
0
        public void SearchKeyword(SearchTransaction searchTransaction)
        {
            queueKeywords = new System.Collections.Queue();

            try
            {

                //pour chaque keyword on lance le search dans un thread séparé
                foreach (Keyword k in searchTransaction.Keywords)
                {
                    KeywordCollection keyword = null;
                    SearchTransaction searchTrans = null;
                    keyword = new KeywordCollection();
                    keyword.Add(k);
                    searchTrans = new SearchTransaction(searchTransaction.IdTransaction, keyword, searchTransaction.MinFileFromPeerFilter, searchTransaction.IpAcceptRangeCollection);
                    queueKeywords.Enqueue(searchTrans);
                }

                // regrouping of results for this transaction
                // will raise the CompletResultHandler event when we received one results for each keyword
                G2SearchResultRegrouping searchRegrouping = new G2SearchResultRegrouping(searchTransaction, searchTransaction.Keywords.Count, false);
                searchRegrouping.CompletResult += new CompletResultHandler(searchRegrouping_CompletResult);
                searchResultRegroupingKeyword_.Add(searchRegrouping);

                while (queueKeywords.Count > 0)
                {

                    SearchTransaction srchTrans = (SearchTransaction)queueKeywords.Dequeue();

                    G2Log.Write("Starting Transaction - Keyword :" + srchTrans.Keywords[0].KeywordName.ToString());
                    searchManager.NewSearch(srchTrans);

                    // on attends 30sec ?????????????????????????
                    //System.Threading.Thread.Sleep(30000);
                }
            }
            catch
            {
               G2Log.Write("Erreur niveau manager.....");
            }
        }
Ejemplo n.º 6
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;

            string name = _nameTextBox.Text;
            var keywords = new KeywordCollection();
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox1.Text)) keywords.Add(_keywordsComboBox1.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox2.Text)) keywords.Add(_keywordsComboBox2.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox3.Text)) keywords.Add(_keywordsComboBox3.Text);
            keywords = new KeywordCollection(new HashSet<string>(keywords));
            var digitalSignature = _signatureComboBox.SelectedItem as DigitalSignature;

            foreach (var seed in _seeds)
            {
                lock (seed.ThisLock)
                {
                    if (!_nameTextBox.IsReadOnly)
                    {
                        seed.Name = name;
                    }

                    lock (seed.Keywords.ThisLock)
                    {
                        seed.Keywords.Clear();
                        seed.Keywords.AddRange(keywords);
                    }

                    if (digitalSignature == null)
                    {
                        seed.CreateCertificate(null);
                    }
                    else
                    {
                        seed.CreateCertificate(digitalSignature);
                    }
                }
            }

            Settings.Instance.Global_UploadKeywords.Clear();
            Settings.Instance.Global_UploadKeywords.AddRange(keywords);
        }
Ejemplo n.º 7
0
        public static PassDescriptor GenerateMotionVectors(bool supportLighting, bool supportForward)
        {
            return(new PassDescriptor
            {
                // Definition
                displayName = "MotionVectors",
                referenceName = "SHADERPASS_MOTION_VECTORS",
                lightMode = "MotionVectors",
                useInPreview = false,

                // Collections
                requiredFields = CoreRequiredFields.LitFull,
                renderStates = GenerateRenderState(),
                defines = GenerateDefines(),
                pragmas = CorePragmas.DotsInstancedInV2Only,
                keywords = GenerateKeywords(),
                includes = GenerateIncludes(),
            });

            DefineCollection GenerateDefines()
            {
                if (!supportLighting)
                {
                    return(null);
                }

                var defines = new DefineCollection
                {
                    { RayTracingNode.GetRayTracingKeyword(), 0 },
                };

                //  #define WRITE_NORMAL_BUFFER for forward
                if (supportForward)
                {
                    defines.Add(CoreKeywordDescriptors.WriteNormalBuffer, 1);
                }

                return(defines);
            }

            RenderStateCollection GenerateRenderState()
            {
                var renderState = new RenderStateCollection();

                renderState.Add(CoreRenderStates.MotionVectors);

                if (!supportLighting)
                {
                    renderState.Add(RenderState.ColorMask("ColorMask [_ColorMaskNormal] 1"));
                    renderState.Add(RenderState.ColorMask("ColorMask 0 2"));
                }

                return(renderState);
            }

            KeywordCollection GenerateKeywords()
            {
                var keywords = new KeywordCollection
                {
                    { CoreKeywords.HDBase },
                    { CoreKeywordDescriptors.WriteMsaaDepth },
                    { CoreKeywordDescriptors.AlphaToMask, new FieldCondition(Fields.AlphaToMask, true) },
                };

                // #pragma multi_compile _ WRITE_NORMAL_BUFFER for deferred
                if (supportLighting && !supportForward)
                {
                    keywords.Add(CoreKeywordDescriptors.WriteNormalBuffer);
                }

                return(keywords);
            }

            IncludeCollection GenerateIncludes()
            {
                var includes = new IncludeCollection();

                includes.Add(CoreIncludes.CorePregraph);
                if (supportLighting)
                {
                    includes.Add(CoreIncludes.kNormalSurfaceGradient, IncludeLocation.Pregraph);
                }
                includes.Add(CoreIncludes.kPassPlaceholder, IncludeLocation.Pregraph);
                includes.Add(CoreIncludes.CoreUtility);
                if (supportLighting)
                {
                    includes.Add(CoreIncludes.kDecalUtilities, IncludeLocation.Pregraph);
                    includes.Add(CoreIncludes.kPostDecalsPlaceholder, IncludeLocation.Pregraph);
                }
                includes.Add(CoreIncludes.kShaderGraphFunctions, IncludeLocation.Pregraph);
                includes.Add(CoreIncludes.kPassMotionVectors, IncludeLocation.Postgraph);

                return(includes);
            }
        }
Ejemplo n.º 8
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;

            string name = _nameTextBox.Text;
            var keywords = new KeywordCollection();
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox1.Text)) keywords.Add(_keywordsComboBox1.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox2.Text)) keywords.Add(_keywordsComboBox2.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox3.Text)) keywords.Add(_keywordsComboBox3.Text);
            keywords = new KeywordCollection(new HashSet<string>(keywords));
            string comment = string.IsNullOrWhiteSpace(_commentTextBox.Text) ? null : _commentTextBox.Text;
            var digitalSignatureComboBoxItem = _signatureComboBox.SelectedItem as DigitalSignatureComboBoxItem;
            DigitalSignature digitalSignature = digitalSignatureComboBoxItem == null ? null : digitalSignatureComboBoxItem.Value;

            if (!_isShare)
            {
                _amoebaManager.Upload(_filePath,
                    name,
                    keywords,
                    comment,
                    digitalSignature,
                    3);
            }
            else
            {
                _amoebaManager.Share(_filePath,
                    name,
                    keywords,
                    comment,
                    digitalSignature,
                    3);
            }

            Settings.Instance.Global_UploadKeywords.Clear();
            Settings.Instance.Global_UploadKeywords.AddRange(keywords);
        }
Ejemplo n.º 9
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;

            string name = _nameTextBox.Text;
            var keywords = new KeywordCollection();
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox1.Text)) keywords.Add(_keywordsComboBox1.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox2.Text)) keywords.Add(_keywordsComboBox2.Text);
            if (!string.IsNullOrWhiteSpace(_keywordsComboBox3.Text)) keywords.Add(_keywordsComboBox3.Text);
            keywords = new KeywordCollection(new HashSet<string>(keywords));
            var digitalSignature = _signatureComboBox.SelectedItem as DigitalSignature;

            Task.Run(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                try
                {
                    if (!_isShare)
                    {
                        _amoebaManager.Upload(_filePath,
                                name,
                                keywords,
                                digitalSignature,
                                3);
                    }
                    else
                    {
                        _amoebaManager.Share(_filePath,
                                name,
                                keywords,
                                digitalSignature,
                                3);
                    }
                }
                catch (Exception)
                {

                }
            });

            Settings.Instance.Global_UploadKeywords.Clear();
            Settings.Instance.Global_UploadKeywords.AddRange(keywords);
        }
Ejemplo n.º 10
0
 public ZipOptionsItem()
 {
     Keywords = new KeywordCollection();
     DefaultSaveFolder = Settings.SaveFolder;
     SavesSameImagesFolder = true;
 }
Ejemplo n.º 11
0
        public static void TestRegressSplit()
        {
            Matrix3d          ucs   = Tools.GetAcadEditor().CurrentUserCoordinateSystem;
            double            r2Min = 0.5d;
            KeywordCollection keys  = new KeywordCollection();

            keys.Add("R2", "R2", "R2", true, true);
            Func <PromptEntityResult, PromptStatus> promptAction = pr =>
            {
                switch (pr.StringResult)
                {
                case "R2":
                {
                    PromptDoubleOptions pdo = new PromptDoubleOptions("\nУкажите R^2: ");
                    pdo.AllowNegative   = false;
                    pdo.UseDefaultValue = true;
                    pdo.DefaultValue    = r2Min;

                    var res = Tools.GetAcadEditor().GetDouble(pdo);
                    if (res.Status != PromptStatus.OK)
                    {
                        return(PromptStatus.Cancel);
                    }
                    r2Min = res.Value;
                    return(PromptStatus.OK);
                }
                }

                return(PromptStatus.Error);
            };
            Curve curve;

            if (!ObjectCollector.TrySelectAllowedClassObject(out curve, keys, promptAction))
            {
                return;
            }
            Line line = null;

            Tools.StartTransaction(() =>
            {
                Polyline pline    = curve.ConvertToPolyline();
                var points        = pline.GetPoints3d();
                Line regressTotal = stat.LinearRegression(pline);
                regressTotal.SaveToDatebase();

                int start = 0;
                for (int i = 1; i < pline.NumberOfVertices; i++)
                {
                    double r2;
                    stat.LinearRegression(pline, start, i + 1, out r2);
                    r2 = double.IsNaN(r2) ? 1d : r2;
                    if (Math.Abs(r2 - r2Min) < Tolerance.Global.EqualVector)
                    {
                        line  = new Line(pline.GetPoint3dAt(start), pline.GetPoint3dAt(i - 1));
                        start = i - 1;
                        line.SaveToDatebase();
                    }
                }
                line = new Line(pline.GetPoint3dAt(start), pline.EndPoint);
                line.SaveToDatebase();
            });
        }
Ejemplo n.º 12
0
        public static void DrawSlopeLinesCmd()
        {
            Matrix3d            ucs       = Tools.GetAcadEditor().CurrentUserCoordinateSystem;
            SlopeLinesGenerator mainBlock = new SlopeLinesGenerator(ucs);
            KeywordCollection   keywords  = new KeywordCollection();

            keywords.Add("SlopeMode", "МЕТод", "МЕТод построения", true, true);
            keywords.Add("Step", "ШАГ", "ШАГ линий", true, true);
            mainBlock.AddKeywords(keywords);
            mainBlock.PromptKeywordAction = (pres) =>
            {
                switch (pres.StringResult)
                {
                case "SlopeMode":
                {
                    var res = mainBlock.PromptSlopeLineMode();
                    return(res);
                }

                case "Step":
                {
                    var res = mainBlock.PromptStep();
                    return(res);
                }

                case "AllLineLength":
                {
                    mainBlock._startPoint         = mainBlock.BaseCurve.StartPoint;
                    mainBlock._startPointComplete = true;
                    mainBlock._endPoint           = mainBlock.BaseCurve.EndPoint;
                    mainBlock._endPointComplete   = true;
                    Tools.StartTransaction(() =>
                        {
                            mainBlock._entitiesInMemory.Clear();
                            var slopeLines = mainBlock.Calculate(mainBlock._slopeMode);
                            if (slopeLines != null && slopeLines.Count > 1)
                            {
                                mainBlock._entitiesInMemory.AddRange(slopeLines);
                                mainBlock.SaveAtBlock();
                            }
                        });
                    goto case "Exit";
                }

                case "Exit":
                {
                    return(PromptStatus.Cancel);
                }
                }
                return(PromptStatus.Cancel);
            };

            Tools.StartTransaction(() =>
            {
                if (mainBlock.PromptBaseLine() != PromptStatus.OK)
                {
                    return;
                }
                if (mainBlock.PromptDestinationLine() != PromptStatus.OK)
                {
                    return;
                }

                while (mainBlock._baseLine.Id == mainBlock._destinationLine.Id)
                {
                    Tools.GetAcadEditor().WriteMessage("\nЛинии должны отличаться, укажите другую линию");
                    if (mainBlock.PromptDestinationLine() != PromptStatus.OK)
                    {
                        return;
                    }
                }

                keywords.Add("AllLineLength", "ВсяЛиния", "ВсяЛиния", true, true);

                try
                {
                    if (!mainBlock.PromptStartPoint(keywords, mainBlock.PromptKeywordAction))
                    {
                        return;
                    }
                    if (mainBlock.PromptEndPoint())
                    {
                        mainBlock.SaveAtBlock();
                    }
                }
                catch (Exception ex)
                {
                    Application.ShowAlertDialog("\nОшибка. \n" + ex.Message);
                }
            });
        }
Ejemplo n.º 13
0
        public PromptStatus EditCreatedSlopeLines()
        {
            KeywordCollection keywords = new KeywordCollection();

            keywords.Add("Exit", "ВЫХод", "ВЫХод", true, true);
            Func <PromptNestedEntityResult, PromptStatus> promptActon = (pr) =>
            {
                switch (pr.StringResult)
                {
                case "Exit":
                {
                    return(PromptStatus.Cancel);
                }
                }
                return(PromptStatus.Cancel);
            };

            PromptNestedEntityResult pner;

            if (PromptSlopeInsideBlock(out pner, keywords, promptActon) != PromptStatus.OK)
            {
                return(PromptStatus.Cancel);
            }

            PromptResult res = null;

            Matrix3d brMat = Matrix3d.Identity;

            Tools.StartTransaction(() =>
            {
                var conts = pner.GetContainers();
                foreach (var brId in conts)
                {
                    var br = brId.GetObjectForRead <BlockReference>(false);
                    if (br != null)
                    {
                        brMat = brMat.PreMultiplyBy(br.BlockTransform);
                    }
                }

                Line slopeLine = pner.ObjectId.GetObjectForWrite <Line>(false);
                slopeLine.TransformBy(brMat);

                MoveSlopeLineJig moveJig = new MoveSlopeLineJig(slopeLine);
                res = Tools.GetAcadEditor().Drag(moveJig);
                if (res.Status == PromptStatus.OK)
                {
                    slopeLine.TransformBy(brMat.Inverse());

                    // Open each of the containers and set a property so that
                    // they each get regenerated
                    foreach (var id in conts)
                    {
                        var ent = id.GetObjectForWrite <Entity>();
                        if (ent != null)
                        {
                            // We might also have called this method:
                            // ent.RecordGraphicsModified(true);
                            // but setting a property works better with undo
                            ent.Visible = ent.Visible;
                        }
                    }
                }
            });
            return(res.Status);
        }
Ejemplo n.º 14
0
        public void _drawGridCartogramma2()
        {
            _step = _dataHost.Read("step", 20d);
            KeywordCollection keywords = new KeywordCollection();

            keywords.Add("Step", "Шаг", "Шаг сетки", true, true);
            keywords.Add("View", "Список", "Список поверхностей", true, true);
            Func <PromptEntityResult, PromptStatus> promptStep = per =>
            {
                switch (per.StringResult)
                {
                case "Step":
                {
                    PromptDoubleOptions pdo = new PromptDoubleOptions("\nУкажите шаг сетки картограммы: ");
                    pdo.UseDefaultValue = true;
                    pdo.DefaultValue    = _step;
                    pdo.AllowZero       = false;
                    pdo.AllowNegative   = false;
                    pdo.AllowNone       = false;

                    var pdr = Tools.GetAcadEditor().GetDouble(pdo);
                    if (pdr.Status == PromptStatus.OK)
                    {
                        _step = pdr.Value;
                        _dataHost.Write("step", _step);
                    }
                    return(pdr.Status);
                }
                }

                return(PromptStatus.Error);
            };

            Autodesk.Civil.DatabaseServices.TinVolumeSurface surface;
            if (!ObjectCollector.TrySelectAllowedClassObject(out surface, keywords, promptStep))
            {
                return;
            }


            Polyline polygon = null;

            Tools.StartTransaction(() =>
            {
                surface = surface.Id.GetObjectForRead <CivilSurface>() as Autodesk.Civil.DatabaseServices.TinVolumeSurface;
                if (surface == null)
                {
                    return;
                }

                polygon = surface.ExtractBorders().ConvertToPolyline();
            });

            Matrix3d ucs = Tools.GetAcadEditor().CurrentUserCoordinateSystem;

            polygon.TransformBy(ucs);
            Extents3d bounds = polygon.Bounds.Value;

            Vector3d hVector = Matrix3d.Identity.CoordinateSystem3d.Xaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).X);
            Vector3d vVector = Matrix3d.Identity.CoordinateSystem3d.Yaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).Y);

            ObjectId btrId = ObjectId.Null;
            ObjectId brId  = ObjectId.Null;

            List <Entity>    rectgs        = null;
            CartogrammLabels labelsFactory = null;

            gride         = new SimpleGride(bounds.MinPoint, vVector, hVector, _step, _step);
            labelsFactory = new CartogrammLabels(gride);

            int rowsCount   = SimpleGride.CalculateCeilingCount(vVector, _step);
            int columnCount = SimpleGride.CalculateCeilingCount(hVector, _step);

            rectgs = new List <Entity>(rowsCount * columnCount);
            for (int r = 0; r < rowsCount; r++)
            {
                for (int c = 0; c < columnCount; c++)
                {
                    Polyline line = gride.CalculateRectagle(r, c, polygon, true);
                    if (line != null)
                    {
                        line.TransformBy(ucs.Inverse());
                        rectgs.Add(line);
                    }
                }
            }

            labelsFactory.CreateTeble(columnCount);

            Tools.StartTransaction(() =>
            {
                rectgs.AddRange(labelsFactory.CreateGridLabels(rectgs.Cast <Polyline>(), surface));
            });

            rectgs.AddRange(labelsFactory.Entities.Select(x => x.GetTransformedCopy(ucs.Inverse())));

            btrId = AcadBlocks.BlockTools.CreateBlockTableRecord("*U", bounds.MinPoint.TransformBy(ucs.Inverse()), rectgs.Cast <Entity>(), AnnotativeStates.NotApplicable, false);
            brId  = AcadBlocks.BlockTools.AppendBlockItem(bounds.MinPoint.TransformBy(ucs.Inverse()), btrId, null);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Workspace"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public Workspace(KbContext context)
 {
     Keywords   = new KeywordCollection(context);
     UserFiles  = new UserFileCollection(KbContext.CurrentUserId, context);
     Categories = new CategoriesCollection(context);
 }