Exemple #1
0
        public override clsMsg exec(clsCmd cmd)
        {
            var msg = validate(cmd);

            if (msg.Validated == false)
            {
                return(msg);
            }

            if (!func.isEmpty())
            {
                NTier.Request.iRequest oReq = _assembly.createInstance(this.AssemblyName, this.classPath) as iRequest;
                oReq.setTier(_tier);
                object[] objParams = new object[] { cmd };
                var      m         = oReq.GetType().GetMethod(func);
                msg = (clsMsg)m.Invoke(oReq, objParams);
                return(msg);
            }
            else
            {
                NTier.Request.iCommand oCmd = _assembly.createInstance(this.AssemblyName, this.classPath) as iCommand;
                oCmd.setTier(_tier);
                return(oCmd.exec(cmd));
            }
        }
Exemple #2
0
        public override clsMsg getFileData(clsCmd cmd)
        {
            NTier.Request.iRequest oReq = _Assembly.createInstance(this.assemblyName, this.classPath) as iRequest;
            oReq.setTier(this._tier);

            object[] objParams = new object[] { cmd };
            var      m         = oReq.GetType().GetMethod(this.func);
            clsMsg   msg       = (clsMsg)m.Invoke(oReq, objParams);

            return(msg);
        }
            public clsMsg getFileData(clsCmd cmd
                                      , iBussinessTier oTier)
            {
                NTier.Request.iRequest oReq = _oAssembly.createInstance(this.AssemblyName, this.classPath) as iRequest;
                oReq.setTier(oTier);

                object[] objParams = new object[] { cmd };
                var      m         = oReq.GetType().GetMethod(this.functionName);
                clsMsg   msg       = (clsMsg)m.Invoke(oReq, objParams);

                return(msg);
            }
Exemple #4
0
        public Form getForm(string sKey, clsCmd cmd)
        {
            Form frm = null;

            //Control
            if (oForms.ContainsKey(sKey))
            {
                frm = oForms[sKey];
                if (frm.IsDisposed)
                {
                    oForms.Remove(sKey);
                }
                return(frm);
            }

            XmlNode el = xmlDoc.SelectSingleNode("//request/frm[@formKey='" + sKey + "']");

            string sAssemblyName  = el.getXmlAttributeValue("assemblyName");
            string sFormPath      = el.getXmlAttributeValue("formPath");
            string sFormClassPath = el.getXmlAttributeValue("formClassPath");

            if (sFormClassPath.isEmpty())
            {
                winui.iFormFactory oFormFactory = oAssembly.createInstance(sAssemblyName, sAssemblyName + ".formService") as winui.iFormFactory;
                oFormFactory.setTier(_Tier);
                frm = oFormFactory.getForm(sFormPath);
            }
            else
            {
                var frm1 = oAssembly.createInstance(sAssemblyName, sFormClassPath) as winui.frmBase;
                frm1.setTier(_Tier);
                frm = frm1;
            }

            if (frm == null)
            {
                throw new Exception(string.Format("[{0}] assembly name and class path [{1}] not found !", sAssemblyName, sFormPath));
            }
            return(frm);
        }
        public clsMsg exec(string sPath, clsCmd cmd)
        {
            XmlNode xNode = xDoc.SelectSingleNode("//appConfig/requestData[@type='cmd']/cmd[@name='" + sPath + "']");

            if (xNode == null)
            {
                throw new Exception("Command path " + sPath + " not found !");
            }

            string sCmdType = xNode.getXmlAttributeValue("type");

            if (sCmdType != "json")
            {
                var msg = validate(xNode, cmd);
                if (msg.Validated == false)
                {
                    return(msg);
                }
            }

            //Validation
            if (xNode != null)
            {
                //Declaration
                //string sCmdType = xNode.getXmlAttributeValue("type");
                string sCRUDName = xNode.getXmlAttributeValue("crudName");

                var oCRUD = getCRUD(sCRUDName);

                if (sCmdType == "save")
                {
                    try
                    {
                        return(oCRUD.save(cmd));
                    }
                    catch (Exception ex)
                    {
                        return(g.msg_exception(ex));
                    }
                }
                else if (sCmdType == "delete")
                {
                    try
                    {
                        oCRUD.delete(cmd);
                        return(g.msg(""));
                    }
                    catch (Exception ex)
                    {
                        return(g.msg_exception(ex));
                    }
                }
                else if (sCmdType == "other")
                {
                    string sAssemblyName = xNode.getXmlAttributeValue("assemblyName");
                    string sClassPath    = xNode.getXmlAttributeValue("classPath");
                    string sFunc         = xNode.getXmlAttributeValue("func");
                    //NTier.Request.iCommand iCmd = AppDomain.CurrentDomain.CreateInstance(sAssemblyName, sClassPath).Unwrap() as iCommand;
                    NTier.Request.iCommand iCmd = oAssembly.createInstance(sAssemblyName, sClassPath) as iCommand;

                    iCmd.setTier(this);

                    if (!sFunc.isEmpty())
                    {
                        object[] objParams = new object[] { cmd };
                        var      m         = iCmd.GetType().GetMethod(sFunc);
                        clsMsg   msg       = (clsMsg)m.Invoke(iCmd, objParams);
                        return(msg);
                    }
                    else
                    {
                        return(iCmd.exec(cmd));
                    }
                }
                else if (sCmdType == "cmd")
                {
                    string q = xNode.getXmlText("sql");
                    cmd.SQL = q;
                    try
                    {
                        _adapter.exec(cmd);
                        return(g.msg(""));
                    }
                    catch (Exception ex)
                    {
                        return(g.msg_exception(ex));
                    }
                }

                else if (sCmdType == "json")
                {
                    DataTable t = Newtonsoft.Json.JsonConvert.DeserializeObject <DataTable>(cmd.getStringValue("data"));

                    //validation start
                    int i = 0;
                    foreach (DataRow r in t.Rows)
                    {
                        i++;
                        var cmd2 = new clsCmd();
                        cmd2.AddValues(r);

                        var msg = validate(xNode, cmd2);
                        if (msg.Validated == false)
                        {
                            msg.Message = string.Format(" Row Number : {0} : {1} ", i, msg.Message);
                            return(msg);
                        }
                    }

                    //updation start

                    i = 0;
                    foreach (DataRow r in t.Rows)
                    {
                        i++;
                        var cmd2 = new clsCmd();
                        cmd2.AddValues(r);

                        string q = xNode.getXmlText("sql");
                        cmd2.SQL = q;

                        try
                        {
                            _adapter.exec(cmd2);
                            return(g.msg(""));
                        }
                        catch (Exception ex)
                        {
                            var msg = g.msg_exception(ex);
                            msg.Message = string.Format(" Row Number : {0} : {1} ", i, msg.Message);
                        }
                    }
                }
            }

            return(g.msg("Path not found !"));
        }