Exemplo n.º 1
0
        private void CRMForm_Load(object sender, EventArgs e)
        {
            // Initialise license and stores directory location
            Configuration.Register();

            //create a unique store name
            var storeName = "CRM_Ontology";

            //connection string to the BrightstarDB service
            string connectionString =
                string.Format(@"Type=embedded;storesDirectory={0};StoreName={1};", Configuration.StoresDirectory,
                              storeName);

            dataContext = new CRMOntologyContext(connectionString);
            client      = BrightstarService.GetClient(connectionString);

            //getPredicates
            XDocument xDoc = dataContext.ExecuteQuery("SELECT DISTINCT ?predicate WHERE {  ?x ?predicate ?y.}");

            foreach (var sparqlResultRow in xDoc.SparqlResultRows())
            {
                string result = sparqlResultRow.GetColumnValue("predicate").ToString();
                //beautify
                if (result.IndexOf(URI) >= 0)
                {
                    treeViewOntology.Nodes[0].Nodes[0].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", ""));
                    treeViewOntology.Nodes[0].Nodes[1].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", ""));
                }
            }
        }
Exemplo n.º 2
0
        public static object GetCustomerSegment(int ObjectTypeCode, Guid ObjectId, CRMOntologyContext DataContext)
        {
            //sales modules needs to apply to calculate segmentation
            //rules are;
            //each sales order has 2 coin and each invoice has 4 coins and each quote has 1 coin
            //FullfillLevel.high = 100 coin or FullfillLevel.low = 20 coin or FullfillLevel.medium = 50 coin
            //if total number between 501 - 1001, segment will be GOLD
            //if total number above 1001, segment will be PREMIUM
            //if total number between 1 - 500, segment will be SILVER
            Random random = new Random();

            switch (random.Next(1, 3))
            {
            case 1:
                return(DataContext.Golds.Create());;

            case 2:
                return(DataContext.Silvers.Create());

            case 3:
                return(DataContext.Premiums.Create());

            default: return(null);
            }
        }
Exemplo n.º 3
0
        private void listViewResult_SelectedIndexChanged(object sender, EventArgs e)
        {
            ////set loading animated gif to richtext field
            //LoadingDataForm dataForm = new LoadingDataForm();
            //dataForm.Location = new Point(Convert.ToInt32(richTextBox1.Location.X * 1.25),Convert.ToInt32(richTextBox1.Location.Y * 1.25));
            //dataForm.Show(this);

            richTextBoxObject.Text  = "";
            richTextBoxSubject.Text = "";

            CRMOntology.DataAccessLayer.CRMOntology_StagingEntities SQLServerContext = new DataAccessLayer.CRMOntology_StagingEntities();
            // Initialise license and stores directory location
            Configuration.Register();

            //create a unique store name
            var storeName = "CRM_Ontology";

            //connection string to the BrightstarDB service
            string connectionString =
                string.Format(@"Type=embedded;storesDirectory={0};StoreName={1};", Configuration.StoresDirectory,
                              storeName);

            OWLTransfer transfer = new OWLTransfer();

            CRMOntologyContext OntologyContext = new CRMOntologyContext(connectionString);

            for (int i = 0; i < listViewResult.SelectedItems.Count; i++)
            {
                string strObject  = listViewResult.SelectedItems[i].Text;
                string strSubject = listViewResult.SelectedItems[i].SubItems.Count == 3 ? listViewResult.SelectedItems[i].SubItems[2].Text : "";

                string[] strSplit = strObject.Split('#');
                if (strSplit != null && strSplit.Length == 2)
                {
                    //Object
                    richTextBoxObject.AppendText(string.Format("Object {0} - {1}", strSplit[0], Environment.NewLine));
                    DataSet ds = transfer.RetrieveRecordFromMapOWL(SQLServerContext, OntologyContext, Guid.Parse(strSplit[1]), strSplit[0]);
                    if (ds != null)
                    {
                        foreach (DataTable dt in ds.Tables)
                        {
                            foreach (DataRow drow in dt.Rows)
                            {
                                foreach (DataColumn dc in dt.Columns)
                                {
                                    richTextBoxObject.AppendText(string.Format("{0} = {1}{2}", dc.ColumnName, drow[dc].ToString(), Environment.NewLine));
                                }
                            }
                        }
                    }
                    else
                    {
                        richTextBoxObject.AppendText(string.Format("No Record found... {0}", Environment.NewLine));
                    }
                }
                else
                {
                    richTextBoxSubject.AppendText(string.Format("Subject {0}{1}", strObject, Environment.NewLine));
                }

                strSplit = strSubject.Split('#');
                if (strSplit != null && strSplit.Length == 2)
                {
                    //Subject
                    richTextBoxSubject.AppendText(string.Format("Subject {0}{1}", strSplit[0], Environment.NewLine));
                    DataSet ds = transfer.RetrieveRecordFromMapOWL(SQLServerContext, OntologyContext, Guid.Parse(strSplit[1]), strSplit[0]);
                    if (ds != null)
                    {
                        foreach (DataTable dt in ds.Tables)
                        {
                            foreach (DataRow drow in dt.Rows)
                            {
                                foreach (DataColumn dc in dt.Columns)
                                {
                                    richTextBoxSubject.AppendText(string.Format("{0} = {1}{2}", dc.ColumnName, drow[dc].ToString(), Environment.NewLine));
                                }
                            }
                        }
                    }
                    else
                    {
                        richTextBoxSubject.AppendText(string.Format("No Record found... {0}", Environment.NewLine));
                    }
                }
                else
                {
                    richTextBoxSubject.AppendText(string.Format("Subject {0}{1}", strSubject, Environment.NewLine));
                }
            }
            // Shutdown Brightstar processing threads.
            BrightstarDB.Client.BrightstarService.Shutdown();

            //dataForm.Close();
            //dataForm.Dispose();
        }