void Run(CmdArg Arg)
        {
            try
            {
                var pClass = SPCTypes.GetClassType(Arg.GetShortCutSegment(0));
                if (pClass != null)
                {
                    //Runable non UI command
                    if (pClass.GetInterfaces().Contains(typeof(IRunable)))
                    {
                        var Sample = BOFactory.CreateSample(pClass) as IRunable;

                        Task.Run(async() => await Sample.RunAsync(Arg));
                    }
                }
                else
                {
                    var prs = new ProcessStartInfo(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
                    prs.Arguments = Arg.Url.Replace(@" ", "%20");
                    Process.Start(prs);
                }
            }
            catch (Exception ex)
            {
                WaitingService.Done();
                AlertService.ShowError(ex);
            }
        }
Example #2
0
        private async static Task <string> TestNewEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test creating a new  BO");
                var obj = await BOFactory.NewBOAsync(pType.ToString(), Data);

                BOFactory.ApplyPreset(obj, Data);

                var saved = await(obj as SPC.Interfaces.IEditable).SaveBOAsync();

                Console.WriteLine("New object Saved: ");

                var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                Console.WriteLine(jsonstr);


                return(saved.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(string.Empty);
        }
Example #3
0
        private void LoadGrid()
        {
            m_bpList = (BOBP)BOFactory.GetBO(BOIDEnum.BP);
            List <BPMD> listObj = Utilities.ConvertList <BPMD>(m_bpList.GetDataList());

            objList.SetObjects(listObj);
        }
Example #4
0
 public FormEx(BOIDEnum boId)
 {
     InitializeComponent();
     m_boId     = boId;
     m_bo       = BOFactory.GetBO(m_boId);
     m_formMode = FormMode.Ok;
 }
Example #5
0
        private async static Task TestDeleteEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test deleting BO");

                var isExists = await BOFactory.IsBOExistsAsync(pType.ToString(), Data);

                if (isExists)
                {
                    var delete = await BOFactory.DeleteBOAsync(pType.ToString(), Data);

                    Console.WriteLine("Object has been deleted: ");

                    var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(delete);
                    Console.WriteLine(jsonstr);
                }
                else
                {
                    Console.WriteLine("Object you wnat to delete does not exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #6
0
 public FormBase(BOIDEnum boId)
 {
     InitializeComponent();
     m_boId            = boId;
     m_bo              = BOFactory.GetBO(m_boId);
     m_formMode        = FormMode.Ok;
     m_needCallRetProc = true;
 }
Example #7
0
        private void LoadGridData()
        {
            m_kwlBo = (BOKWList)BOFactory.GetBO(BOIDEnum.KeyWordList);
            List <KWListDetailMD> listObj = m_kwlBo.GetDetialedMD();

            objList.SetObjects(listObj);
            //objList.DataSourceType = typeof(KWListMD);
            //objList.AddEmptyRow();
        }
Example #8
0
        private void LoadGrid()
        {
            olvcTexture.DataSource = BOFactory.GetBO(BOIDEnum.Texture).GetValieValue("ID", "Name");
            olvcGroup.DataSource   = BOFactory.GetBO(BOIDEnum.ProductGroup).GetValieValue("ID", "Name");

            m_proList = (BOProduct)BOFactory.GetBO(BOIDEnum.Product);
            List <ProductMD> listObj = Utilities.ConvertList <ProductMD>(m_proList.GetDataList());

            objList.SetObjects(listObj);
        }
Example #9
0
        private void LoadGridData()
        {
            m_kwBo = (BOKeyWord)BOFactory.GetBO(BOIDEnum.KeyWord);
            List <KeyWordMD> listObj = Utilities.ConvertList <KeyWordMD>(m_kwBo.GetDataList());

            objList.SetObjects(listObj);
            objList.DataSourceType = typeof(KeyWordMD);
            KeyWordMD newKw = (KeyWordMD)objList.AddEmptyRow();

            newKw.ID = BusinessObject.GetBONextID(BOIDEnum.KeyWord);
        }
        public void Test_CreateBusinessObjectGenericViaInterface()
        {
            //---------------Set up test pack-------------------
            IBOFactory factory = new BOFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var businessObject = factory.CreateBusinessObject<FakeBO>();
            //---------------Test Result -----------------------
            Assert.IsNotNull(businessObject);
            Assert.IsInstanceOf<FakeBO>(businessObject);
        }
        public void Test_CreateBusinessObject()
        {
            //---------------Set up test pack-------------------
            var factory = new BOFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var businessObject = factory.CreateBusinessObject(typeof(FakeBO));
            //---------------Test Result -----------------------
            Assert.IsNotNull(businessObject);
            Assert.IsInstanceOf<FakeBO>(businessObject);
        }
Example #12
0
        public static string GetBOName(BOIDEnum boid)
        {
            string         name = string.Empty;
            BusinessObject bo   = BOFactory.GetBO(boid);
            var            attr = bo.GetType().GetCustomAttributes(typeof(BOAttribute), false).First();

            if (attr == null)
            {
                return(name);
            }
            return(((BOAttribute)attr).Name);
        }
Example #13
0
        private void frmBpList_Load(object sender, EventArgs e)
        {
            BusinessObject ctyBo = BOFactory.GetBO(BOIDEnum.Country);

            olvcCty.DataSource = ctyBo.GetValieValue("ID", "Name");

            BOBP bpBo = (BOBP)BOFactory.GetBO(BOIDEnum.BP);

            olvcType.DataSource = bpBo.GetBPTypeValidValue();

            LoadGrid();
        }
Example #14
0
        public void Test_CreateBusinessObjectViaInterface()
        {
            //---------------Set up test pack-------------------
            IBOFactory factory = new BOFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var businessObject = factory.CreateBusinessObject(typeof(FakeBO));

            //---------------Test Result -----------------------
            Assert.IsNotNull(businessObject);
            Assert.IsInstanceOf <FakeBO>(businessObject);
        }
Example #15
0
        public void Test_CreateBusinessObjectGeneric()
        {
            //---------------Set up test pack-------------------
            var factory = new BOFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var businessObject = factory.CreateBusinessObject <FakeBO>();

            //---------------Test Result -----------------------
            Assert.IsNotNull(businessObject);
            Assert.IsInstanceOf <FakeBO>(businessObject);
        }
Example #16
0
        private void LoadGridData()
        {
            try
            {
                m_mktBO = (BOMarket)BOFactory.GetBO(BOIDEnum.Market);
                List <MarketDetaiedlMD> listObj = m_mktBO.GetDetailedMarketMD();
                //MarketMD newMkt = new MarketMD();
                //newMkt.ID = BusinessObject.GetBONextID(m_boId);
                //MarketDetaiedlMD newObj = new MarketDetaiedlMD(newMkt);
                //listObj.Add(newObj);

                objList.SetObjects(listObj);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Example #17
0
        public void Test_CreateBusinessObject_WhenTypeNotIBO_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            IBOFactory factory = new BOFactory();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                factory.CreateBusinessObject(typeof(int));
                Assert.Fail("Expected to throw an HabaneroDeveloperException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains("The BOFactory.CreateBusinessObject was called with Type that does not implement IBusinessObject", ex.Message);
            }
        }
Example #18
0
        public string GetKetWordString()
        {
            string result = string.Empty;

            KWListMD tb = (KWListMD)m_boTable;

            foreach (int id in tb.KeyWrodIds)
            {
                BOKeyWord kwBo = (BOKeyWord)BOFactory.GetBO(BOIDEnum.KeyWord);
                kwBo.GetById(id);
                result += ((KeyWordMD)kwBo.GetBOTable()).Name + ", ";
            }
            if (result.Length > 0)
            {
                result = result.Substring(0, result.Length - 2);
            }

            return(result);
        }
Example #19
0
        private void LoadGridData()
        {
            try
            {
                m_proGrpBo = (BOProductGroup)BOFactory.GetBO(BOIDEnum.ProductGroup);
                IList list = m_proGrpBo.GetDataList();
                List <ProductGroupMD> listObj = Utilities.ConvertList <ProductGroupMD>(list);

                //ProductGroupMD newBo = new ProductGroupMD();
                //newBo.ID = BusinessObject.GetBONextID(BOIDEnum.ProductGroup);
                //listObj.Add(newBo);
                objList.SetObjects(listObj);
                objList.DataSourceType = typeof(ProductGroupMD);
                ProductGroupMD newObj = (ProductGroupMD)objList.AddEmptyRow();
                newObj.ID = BusinessObject.GetBONextID(BOIDEnum.ProductGroup);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Example #20
0
        public void InitSource()
        {
            if (DataSourceBO == BOIDEnum.Invalid)
            {
                return;
            }
            BusinessObject bo = BOFactory.GetBO(DataSourceBO);

            m_vv = bo.GetValieValue(KeyField, DesField);
            if (AddEmptyRow)
            {
                m_vv.Insert(0, new ValidValue("-1", ""));
            }
            if (AddDefineNew)
            {
                m_vv.Insert(m_vv.Count, new ValidValue("999999", "---添加新项---"));
            }
            this.DataSource    = m_vv;
            this.ValueMember   = "Value";
            this.DisplayMember = "Description";
        }
Example #21
0
        private async static Task TestSingleton(Type pType)
        {
            string editable = pType.ToString();
            var    filters  = new Dictionary <string, string>();
            object theobj   = null;

            if (await BOFactory.IsBOExistsAsync(editable, filters))
            {
                Console.WriteLine("Found runable {0} : {1}", editable, filters.ToParametersString());
                theobj = await BOFactory.GetBOAsync(editable, filters);
            }
            else
            {
                Console.WriteLine("object {0}:{1} does not exists", editable, filters.ToParametersString());
                theobj = await BOFactory.NewBOAsync(editable, filters);
            }


            var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(theobj);

            Console.WriteLine(jsonstr);
        }
Example #22
0
        private async static Task TestUpdateEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test update existing  BO");

                var obj = await BOFactory.GetBOAsync(pType.ToString(), Data);

                BOFactory.ApplyPreset(obj, Data);

                var saved = await(obj as SPC.Interfaces.IEditable).SaveBOAsync();

                Console.WriteLine("Object has been amended: ");

                var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                Console.WriteLine(jsonstr);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        async Task OnRowUpdating(CompanyUserInfo dataItem, IDictionary <string, object> newValue)
        {
            if (dataItem != null && newValue != null && newValue.Count > 0)
            {
                Status = $"Cập nhật tài khoản {dataItem.UserId}";

                StateHasChanged();

                var itm = await SPC.Cloud.Members.CompanyUser.GetCompanyUserAsync(dataItem.UserId, dataItem.CompanyId);

                Dictionary <string, string> dic = CreateStringDic(newValue);

                BOFactory.ApplyPreset(itm, dic);

                await itm.SaveAndMergeAsync();

                await CompanyUser.CreateSubscriberIfNotExistsAsync(itm.CompanyId, itm.UserId, dic);

                await SearchAsync();
            }
            //await ForecastService.Update(dataItem, newValue);
        }
Example #24
0
        protected override bool OnCheckData(object data, BOAction action = BOAction.Add)
        {
            bool result = true;

            if (action == BOAction.Delete)
            {
                CountryMD       delMd   = (CountryMD)data;
                BOMarket        mktBo   = (BOMarket)BOFactory.GetBO(BOIDEnum.Market);
                List <MarketMD> mktList = mktBo.GetDataList().Cast <JObject>().Select(x => x.ConvertToTarget <MarketMD>()).ToList();;
                MarketMD        find    = mktList.Find(x => x.CountryIds.Contains(delMd.ID));
                if (find != null)
                {
                    result = false;
                    ReportStatusMessage(new SatusMessageInfo(MessageType.Error, MessageCode.RefenenceError, this,
                                                             "删除失败!国家 \"" + delMd.Name + "\" 在市场区域 \"" + find.Name + "\" 中被引用!"));
                }
            }
            else
            {
            }
            return(result);
        }
Example #25
0
        public override bool OnIsValidBatch()
        {
            bool result = true;

            if (base.m_removedDataList != null && base.m_removedDataList.Count > 0)
            {
                BOKWList        kwlBo     = (BOKWList)BOFactory.GetBO(BOIDEnum.KeyWordList);
                List <KWListMD> kwlMdList = kwlBo.GetDataList().Cast <JObject>().Select(x => x.ConvertToTarget <KWListMD>()).ToList();
                foreach (var temp in m_removedDataList)
                {
                    KeyWordMD md    = (KeyWordMD)temp;
                    KWListMD  kwlMd = kwlMdList.Find(x => x.KeyWrodIds.Contains(md.ID));
                    if (kwlMd != null)
                    {
                        result = false;
                        ReportStatusMessage(new SatusMessageInfo(MessageType.Error, MessageCode.RefenenceError, this,
                                                                 "删除失败!关键字 \"" + md.Name + "\" 在关键字列表 \"" + kwlMd.Name + "\" 中被引用!"));
                        break;
                    }
                }
            }
            return(result);
        }
Example #26
0
        private async static Task TestEditable(Type pType)
        {
            string editable = pType.ToString();

            //await CommandRouter.RunCommand("SPC.HR.Commands.LRQ.Approve", param);
            Console.WriteLine($"InfoList {pType.ToString()}-------------");

            //IList list1 = await BOFactory.GetInfoListAsync(editable, new Dictionary<string, string> { ["SubscriberId"] = "*****@*****.**" }) as IList;

            IList list1 = await BOFactory.GetInfoListAsync(editable, null) as IList;

            var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(list1);

            Console.WriteLine(jsonstr);

            Console.WriteLine("Total {0} records", ((IEnumerable)list1).Count());

            Console.WriteLine("Editable. Enter the record index: ");

            var index = Console.ReadLine().ToInteger();

            var onerec = list1[index];

            var filters = BOFactory.GetObjectCriteria(onerec);

            if (await BOFactory.IsBOExistsAsync(editable, filters))
            {
                Console.WriteLine("Found editable {0} : {1}", editable, filters.ToParametersString());
                var theobj = await BOFactory.GetBOAsync(editable, filters);

                //((SPC.BO.HR.EAW) theobj).Concurrent = "Y";

                jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(theobj);
                Console.WriteLine(jsonstr);

                try
                {
                    var wf = theobj as PFD;
                    if (wf != null)
                    {
                        var theData = wf.Data.Decompress();

                        var formXele = XElement.Parse(theData);

                        var theMaster = formXele.Element("master");
                        Console.WriteLine("ClassName : {0} ", theMaster.GetStringAttribute("ClassName"));
                        //      Console.WriteLine("Data : {0} ", SPC.Services.Base64Serializer.DeserializeObject<object>( theMaster.Value.Decompress()));

                        var theProperties = formXele.Element("properties").Value;
                        var theDic        = theProperties.Base64DeSerializer() as Dictionary <string, string>;
                        jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(theDic);
                        Console.WriteLine(jsonstr);
                    }
                }
                catch (Exception)
                {
                }


                // Console.WriteLine("Convert ToXML: {0}", (theobj as DLS).ToXml().ToString());

                Console.WriteLine("Copying selected record . Enter the new ID: ");
                var newId = Console.ReadLine();

                if (!string.IsNullOrEmpty(newId) && newId != editable.ToString())
                {
                    var thecopy = await BOFactory.CopyBOAsync(theobj, newId);

                    Console.WriteLine($"Saving the copy of {theobj.GetType().ToString()} to database with new Id :{newId}");

                    var saved = await(thecopy as SPC.Interfaces.IEditable).SaveBOAsync();

                    Console.WriteLine("New object Saved: ");

                    jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                    Console.WriteLine(jsonstr);

                    Console.WriteLine($"Test deleting BO-------{saved.GetType().ToString()} : {saved.ToString()}--------");

                    var delete = await BOFactory.DeleteBOAsync(pType.ToString(), saved.ToString());

                    Console.WriteLine("Object has been deleted: ");

                    jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(delete);
                    Console.WriteLine(jsonstr);
                }
            }
            else
            {
                Console.WriteLine("object {0}:{1} does not exists", editable, filters.ToParametersString());
            }
        }
        private async Task RunTaskAsync(CmdArg Arg)
        {
            try
            {
                if (Arg.Action == Helper.Action._Help)
                {
                    SPC.Services.InternetChecker.OnlineGuard();

                    string Topic = Arg.ShortCut;
                    if (!string.IsNullOrEmpty(Topic))
                    {
                        WaitingService.Wait("Openning Online Help".Translate(), Arg.Url);

                        var theHelpUrl = await SPC.Cloud.HelpService.GetHelpTopicUrlAsync(Topic);

                        nav.NavigateTo(theHelpUrl);

                        WaitingService.Done();
                    }
                }

                else if (Arg.GetShortCutSegment(0).Equals("Debug", StringComparison.OrdinalIgnoreCase))
                {
                    var onoff = Arg.GetDefaultParameter();
                    if (string.IsNullOrEmpty(onoff))
                    {
                        Ctx.AppConfig.DebugMode = !Ctx.AppConfig.DebugMode;
                    }
                    else
                    {
                        Ctx.AppConfig.DebugMode = onoff.ToBoolean();
                    }

                    AlertService.Toast($"Debug Mode is : {(Ctx.AppConfig.DebugMode ? "ON" : "OFF")}");
                }

                else if (Arg.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) //Open online resources
                {
                    WaitingService.Wait("Openning browser", Arg.Url);

                    nav.NavigateTo(Arg.Url);

                    WaitingService.Done();
                }

                else if (Arg.Url.StartsWith(@"/", StringComparison.OrdinalIgnoreCase)) //Open Local files
                {
                    WaitingService.Done();
                }

                else if (Arg.Url.StartsWith(@"mailto://", StringComparison.OrdinalIgnoreCase))
                {
                    WaitingService.Wait("Composing mail ...", "");

                    nav.NavigateTo(Arg.Url);

                    WaitingService.Done();
                }

                else if (Arg.Url.MatchesRegExp(@"^[A-Za-z]+://")) //Open other apps "lyft://
                {
                    WaitingService.Done();
                }

                else if (Arg.Action.MatchesRegExp("^Insert$|^Update$|^InsertUpdate$|^UpdateAll$|^Delete$|^DeleteAll$"))
                //NON-UI Commands
                {
                    WaitingService.Wait(Arg.Action, Arg.Url);

                    await SPC.Commands.NonUIActionRunner.RunURLCommandAsync(Arg);

                    WaitingService.Done();
                }

                else
                {
                    var pClass = SPCTypes.GetClassType(Arg.GetShortCutSegment(0), true);

                    if (pClass != null)
                    {
                        //Runable non UI command if Action = Run or the command is not a mix of Editable and Runnable
                        if (pClass.GetInterfaces().Contains(typeof(IRunable)) && (Arg.Action == Helper.Action._Run || !pClass.GetInterfaces().Contains(typeof(IEditable))))
                        {
                            var Sample = BOFactory.CreateSample(pClass) as IRunable;

                            await Sample.RunAsync(Arg);
                        }
                        //Class is ISupportQueryInfoList and the Action = Select
                        else if (Arg.Action == Helper.Action._Select && pClass.GetInterfaces().Contains(typeof(SPC.Interfaces.ISupportQueryInfoList))) //Query BO
                        {
                            if (BOFactory.CreateSample(pClass) is ISupportQueryInfoList sample)
                            {
                                var theList = await sample.GetInfoListAsync(Arg.GetDictionary()) as IList;

                                await ValueSelector.SelectAsync(theList, "Info List");
                            }
                        }

                        else

                        {
                            AlertService.Toast($"Could not find any suitable Page for class : {Arg.ShortCut}");
                            WaitingService.Done();
                        }
                    }


                    else //Short Command is not a class
                    {
                        WaitingService.Done();
                        AlertService.Toast($"Could not find the class {Arg.GetShortCutSegment(0)}");
                    }
                }
            }
            catch (Exception ex)
            {
                WaitingService.Done();
                if (ex.GetType() == typeof(NullReferenceException)) //file extension is not support by ios
                {
                    try
                    {
                        AlertService.ShowError(ex);
                    }
                    catch (Exception ex1)
                    {
                        //ExceptionHandler.LogAndAlert(ex1);
                        // AlertService.ShowError(ex1);
                    }
                }
                //if (ex.GetType() == typeof(ExitScriptException)) //file extension is not support by ios
                //ExceptionHandler.LogAndToast(ex);
                //else
                //ExceptionHandler.LogAndAlert(ex);
                //AlertService.ShowError(ex);
            }
        }
        public void Test_CreateBusinessObject_WhenTypeNotIBO_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            IBOFactory factory = new BOFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                factory.CreateBusinessObject(typeof(int));
                Assert.Fail("Expected to throw an HabaneroDeveloperException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains("The BOFactory.CreateBusinessObject was called with Type that does not implement IBusinessObject", ex.Message);
            }
        }