Example #1
0
        /// <summary>
        /// 导入客户数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public JsonResult ImportCusData(string data)
        {
            string jsonStr = string.Empty;
            bool   result  = false;
            string retmsg  = string.Empty;

            LogicBiz biz = new LogicBiz();

            RetMsg msg = biz.DataImport(customerUrl, data, SessionId);

            if (!msg.IsSysError)
            {
                ImportResponse <CustomerErrorDetail> response = DataJsonSerializer <ImportResponse <CustomerErrorDetail> > .JsonToEntity(msg.Message);

                if (response.Data.FalseCount == 0)
                {
                    result = true; //导入成功
                }
                else
                {
                    jsonStr = JsonConvert.SerializeObject(response.Data);
                }
            }
            else
            {
                retmsg = msg.Message;
            }

            return(Json(new { Result = result, Msg = retmsg, Data = jsonStr }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public RetMsg updateSiteUseFlag(string id, int flag)
        {
            RetMsg ret = new RetMsg();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    string[] idary = id.TrimEnd(',').Split(',');
                    foreach (string _id in idary)
                    {
                        Site site = db.Sites.Find(int.Parse(_id));

                        site.isuse          = flag;
                        site.lastUpdateDate = DateTime.Now;
                        db.SaveChanges();
                    }
                    scope.Complete();

                    ret.Result = true;
                }
                catch (Exception e)
                {
                    ret.Result = false;
                    ret.Msg    = e.Message;
                }
                finally
                {
                    scope.Dispose();
                }
            }
            return(ret);
        }
Example #3
0
        /// <summary>
        /// 分页查询,数据量小,使用同步
        /// </summary>
        ///
        private void SelectPage(string pageMethod = "SelectPage")
        {
            RetMsg msg = ExecControllerMethod(this.ControllerName, pageMethod, new object[] { this.QueryModel }) as RetMsg;

            if (msg.code == "0")
            {
                this.Model.TablePage.Rows.Clear();
                this.Model.TotalItemCount = msg.totalItemCount;
                FwUtilFunc.TransferDataTable(msg.result as DataTable, this.Model.TablePage);
                if (msg.result != null && (msg.result as DataTable).Columns.Contains("EXCUTE_RESULT"))
                {
                    foreach (DataRow row in Model.TablePage.Rows)
                    {
                        if (row["EXCUTE_RESULT"].ToString() == "0")
                        {
                            row["EXCUTE_RESULT"] = "成功";
                        }
                        else
                        {
                            row["EXCUTE_RESULT"] = "失败";
                        }
                    }
                }
            }
        }
Example #4
0
        public IHttpActionResult addOrupdate(JObject job)
        {
            RetMsg ret = new RetMsg();

            string sql = string.Empty;

            try
            {
                var id = job["id"]._ToInt32();

                if (id > 0)
                {
                    sql = Util.CreateSqlByJsonData(SQLEnum.UPDATE, "sys_menu", "id", job);
                }
                else
                {
                    sql = Util.CreateSqlByJsonData(SQLEnum.INSERT, "sys_menu", "id", job);
                }

                int effect = MySQLDB.ExecuteSql(sql);

                ret.flag = effect > 0;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (RetType != 0)
            {
                hash ^= RetType.GetHashCode();
            }
            if (RetMsg.Length != 0)
            {
                hash ^= RetMsg.GetHashCode();
            }
            if (ErrCode != 0)
            {
                hash ^= ErrCode.GetHashCode();
            }
            if (s2C_ != null)
            {
                hash ^= S2C.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #6
0
        public JsonResult Reject(string wfInstId)
        {
            var    engine  = new WFEngine();
            var    userDal = new UserDAL();
            User   user    = userDal.Get().Where(p => p.WorkflowInstId == Guid.Parse(wfInstId)).FirstOrDefault();
            string ret     = engine.ExecuteWF(user, true);
            RetMsg msg     = new RetMsg();

            if (string.IsNullOrEmpty(ret))
            {
                msg.Code = -1;
                msg.Msg  = "流程" + wfInstId + "驳回失败!";
            }
            else
            {
                msg.Code = 0;
                msg.Msg  = "流程" + wfInstId + "驳回成功!当前节点" + ret;
                msg.Tag  = ret;
                //WFinstanceDAL wfDal = new WFinstanceDAL();
                //WFInstance inst = new WFInstance();
                //inst.WfInstanceId = Guid.Parse(wfInstId);
                //inst.State = nodeName + ",驳回";
                //inst.ApproveTime = DateTime.Now;
                //inst.ApproveUser = "******";
                //wfDal.Update(inst);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        public static RetMsg CheckWebService(string url)
        {
            RetMsg ret = new RetMsg();

            try
            {
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
                using (HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse())
                {
                    ret.Msg    = "";
                    ret.Result = true;
                }
            }
            catch (WebException e)
            {
                string msg = string.Empty;
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    msg  = string.Format("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode);
                    msg += ";" + string.Format("Status Description : {0}",
                                               ((HttpWebResponse)e.Response).StatusDescription);
                }
                else
                {
                    msg = e.Message;
                }
                ret.Result = false;
                ret.Msg    = msg;
            }
            return(ret);
        }
Example #8
0
        public IHttpActionResult getLeftRoleTree(string userid)
        {
            RetMsg ret = new RetMsg();

            ret = new PermissionController().getLeftRoleTree(userid);

            return(Json(ret));
        }
Example #9
0
        public IHttpActionResult getTree()
        {
            RetMsg ret = new RetMsg();

            List <object> tree = new List <object>();

            try
            {
                string maintreesql = string.Format(@"select t1.id,t1.modulename,GROUP_CONCAT(CONCAT_WS('|',t2.modulename,t2.id) order by t2.id asc) as childs from sys_module t1 left join (SELECT id,modulename,parentid FROM `sys_module` where parentid!=0)t2 on t1.id=t2.parentid where t1.parentid=0 group by t2.parentid");

                DataTable treedt = MySQLDB.Query(maintreesql);

                string menusql = string.Format(@"select id,menuname,code,moduleid,`status` from sys_menu order by id asc");

                DataTable menudt = MySQLDB.Query(menusql);

                foreach (DataRow item in treedt.Rows)
                {
                    List <object> mts = new List <object>();
                    //第二级节点
                    var childs = item["childs"].ToString().Split(',');
                    for (int i = 0; i < childs.Count(); i++)
                    {
                        //模块编号
                        var child = childs[i].Split('|');
                        //第三级节点
                        //var menus = from m in menudt.AsEnumerable()
                        //            where m.Field<int>("moduleid")._ToInt32() == child[1]._ToInt32()
                        //            select new
                        //            {
                        //                title = m.Field<string>("menuname"),
                        //                value = m.Field<int>("id"),
                        //                @checked = false,
                        //                data = new object { }
                        //            };

                        mts.Add(new { title = child[0].ToString(), value = child[1]._ToInt32(), @checked = false, data = new object { } });
                    }
                    //第一级节点
                    var t = new { title = item["modulename"].ToString(), value = item["id"]._ToInt32(), data = mts };

                    tree.Add(t);
                }

                ret.flag = true;

                ret.data = tree;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #10
0
        /// <summary>
        /// 左侧菜单列表
        /// </summary>
        /// <returns></returns>
        public RetMsg getLeftRoleTree(string userid)
        {
            RetMsg ret = new RetMsg();

            string roles = string.Empty;

            string sql = string.Empty;

            DataTable r = new DataTable();

            List <object> listo = new List <object>();

            try
            {
                sql = string.Format(@"select roleid from sys_user where id={0}", userid);

                roles = MySQLDB.FirstValue(sql).ToString();

                if (roles != "")
                {
                    sql = string.Format(@"select GROUP_CONCAT(modules) from sys_role where id in ({0})", roles);

                    string modulesid = MySQLDB.FirstValue(sql).ToString();

                    sql = string.Format(@"select b.id,b.modulename text,b.url href,a.modulename as parentname,cast(a.id as char) as parentid,b.`status`,'' as icon from sys_module a inner join sys_module b on a.id=b.parentid where b.id in ({0}) order by b.id desc", modulesid);

                    r = MySQLDB.Query(sql);

                    var query = from g in r.AsEnumerable()
                                group g by new { t2 = g.Field <string>("parentname") } into modules
                        select new { parentname = modules.Key.t2, StallInfo = modules };

                    foreach (var moduleInfo in query)
                    {
                        DataTable dt = moduleInfo.StallInfo.ToList().CopyToDataTable();

                        object o = new { text = moduleInfo.parentname, icon = "", subset = dt };

                        listo.Add(o);
                    }
                    ret.flag = true;
                    ret.data = listo;
                }
            }
            catch (Exception ex)
            {
                ret.msg  = ex.Message;
                ret.flag = false;
            }

            return(ret);
        }
Example #11
0
        public string Get(string id)
        {
            DB db = null;

            if (Config.IsMulti)
            {
                db = new DbBranch();
            }
            else
            {
                db = new DB();
            }
            @operator o = new DB()[email protected](x => x.s_work_no == id);

            return(RetMsg.Success(o));
        }
Example #12
0
        public IHttpActionResult getByID(int id)
        {
            RetMsg ret = new RetMsg();

            try
            {
                sys_Menu r = MySQLDB.QueryById <sys_Menu, int>(id);

                ret.flag = true;
                ret.data = r;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #13
0
        public string UpdatePwd(string id)
        {
            DB db = null;

            if (Config.IsMulti)
            {
                db = new DbBranch();
            }
            else
            {
                db = new DB();
            }
            //var desid=CchMis.Common.Encryption.AESDecrypt(id);
            @operator op = new DB()[email protected](x => x.s_work_no == id);

            return(RetMsg.Success(op));
        }
Example #14
0
        public RetMsg Add(SiteStatus status)
        {
            RetMsg ret = new RetMsg();

            try
            {
                db.Status.Add(status);
                db.SaveChanges();
                ret.Result = true;
            }
            catch (Exception e)
            {
                ret.Result = false;
                ret.Msg    = e.Message;
            }
            return(ret);
        }
        public JsonResult Update()
        {
            RetMsg ret = new RetMsg();

            try
            {
                int    _Id    = int.Parse(Request["Id"]);
                int    _pId   = int.Parse(Request["pId"]);
                string _name  = Request["name"];
                string _desc  = Request["desc"];
                int    _type  = int.Parse(Request["type"]);
                string _url   = Request["url"];
                string _paras = Request["paras"];
                if (!string.IsNullOrWhiteSpace(_paras))
                {
                    _paras = HttpUtility.UrlDecode(_paras);
                }
                string _mails    = Request["mails"];
                int    _interval = int.Parse(Request["interval"]);
                int    _isuse    = int.Parse(Request["isuse"]);

                Site site = new Site();

                site.id               = _Id;
                site.pId              = _pId;
                site.name             = _name;
                site.description      = _desc;
                site.type             = _type;
                site.url              = _url;
                site.paras            = _paras;
                site.mailgroup        = _mails;
                site.interval         = _interval;
                site.isuse            = _isuse;
                site.lastUpdatePerson = userName;
                site.lastUpdateDate   = DateTime.Now;

                ret = ISite.Update(site);
                InitQuartzJob();
            }
            catch (Exception e)
            {
                ret.Result = false;
                ret.Msg    = e.Message;
            }
            return(Json(new { Result = ret.Result, Msg = ret.Msg }, JsonRequestBehavior.AllowGet));
        }
Example #16
0
        public string userlogin(string account, string pwd)
        {
            RetMsg ret = new RetMsg();

            ret.flag = true;
            string sql    = "";
            int    effect = 0;

            try
            {
                sql = string.Format(@"select count(0) from sys_user where logincode='{0}'", account);

                effect = MySQLDB.FirstValue(sql)._ToInt32();
                if (effect <= 0)
                {
                    ret.flag = false;
                    ret.msg  = "用户不存在!";
                    return(ret._ToJson());
                }

                sql = string.Format(@"select * from sys_user where logincode='{0}' and pwd=md5('{1}')", account, pwd);

                DataTable dt = MySQLDB.Query(sql);

                effect = dt.Rows.Count;

                if (effect <= 0)
                {
                    ret.flag = false;
                    ret.msg  = "用户密码错误!";
                    return(ret._ToJson());
                }

                Session["userid"] = dt.Rows[0]["id"]._ToInt32();
                Session["roleid"] = dt.Rows[0]["roleid"].ToString();
                Session["unitid"] = dt.Rows[0]["unitid"].ToString();
                Session["depid"]  = dt.Rows[0]["depid"].ToString();
                ret.data          = dt;
            }
            catch (Exception ex)
            {
                ret.flag = false;
                ret.msg  = ex.Message;
            }
            return(ret._ToJson());
        }
Example #17
0
        /// <summary>
        /// 调用数据导入接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public RetMsg DataImport(string url, string json, string sessionId)
        {
            RetMsg msg = new RetMsg();

            try
            {
                string responseStr = HttpClient.RequestPost(url, json, sessionId);

                msg.IsSysError = false;
                msg.Message    = responseStr;
            }
            catch (Exception ex)
            {
                msg.IsSysError = true;
                msg.Message    = ex.Message;
            }
            return(msg);
        }
Example #18
0
        public IHttpActionResult delmenu(JObject data)
        {
            RetMsg ret = new RetMsg();

            try
            {
                string ids = data["ids"].ToString();

                string sql = string.Format(@"delete from sys_menu where id in ({0})", ids == "" ? "0" : ids);

                ret.flag = MySQLDB.ExecuteSql(sql) > 0;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
        public JsonResult UpdateUseFlag()
        {
            RetMsg ret = new RetMsg();

            try
            {
                int    flag  = int.Parse(Request["flag"]);
                string idstr = Request["idstr"];
                ret = ISite.updateSiteUseFlag(idstr, flag);
                InitQuartzJob();
            }
            catch (Exception e)
            {
                ret.Result = false;
                ret.Msg    = e.Message;
            }
            return(Json(new { Result = ret.Result, Msg = ret.Msg }, JsonRequestBehavior.AllowGet));
        }
Example #20
0
        /// <summary>
        /// 获取登录用户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public RetMsg GetUserInfo(string url, UserRequestEntity request)
        {
            RetMsg msg = new RetMsg();

            try
            {
                string postData = DataJsonSerializer <UserRequestEntity> .EntityToJson(request);

                string responseStr = HttpClient.RequestPost(url, postData);

                msg.IsSysError = false;
                msg.Message    = responseStr;
            }
            catch (Exception ex)
            {
                msg.IsSysError = true;
                msg.Message    = ex.Message;
            }
            return(msg);
        }
Example #21
0
        public IHttpActionResult getdeps(string unitid)
        {
            RetMsg ret = new RetMsg();

            string sql = string.Empty;

            try
            {
                sql = "select id,depname from sys_dep where status=1 and pid=" + unitid._ToInt32();
                DataTable r = MySQLDB.Query(sql);

                ret.flag = true;
                ret.data = r;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #22
0
        public IHttpActionResult getunlitlist()
        {
            RetMsg ret = new RetMsg();

            string sql = string.Empty;

            try
            {
                sql = "select id,unitname from sys_unit where status=1";
                DataTable r = MySQLDB.Query(sql);

                ret.flag = true;
                ret.data = r;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #23
0
        public JsonResult Approve(string wfInstId)
        {
            var    engine   = new WFEngine();
            var    userDal  = new UserDAL();
            User   user     = userDal.Get().Where(p => p.WorkflowInstId == Guid.Parse(wfInstId)).FirstOrDefault();
            string nodeName = engine.ExecuteWF(user);
            RetMsg msg      = new RetMsg();

            if (string.IsNullOrEmpty(nodeName))
            {
                msg.Code = -1;
                msg.Msg  = "流程" + wfInstId + "执行失败!";
            }
            else
            {
                msg.Code = 0;
                msg.Msg  = "流程" + wfInstId + "执行成功!当前节点" + nodeName;
                msg.Tag  = nodeName;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Example #24
0
        public IHttpActionResult getroles()
        {
            RetMsg ret = new RetMsg();

            string sql = string.Empty;

            try
            {
                sql = "SELECT id,rolename,modules,menus,status,remark FROM sys_role";

                DataTable r = MySQLDB.Query(sql);

                ret.flag = true;
                ret.data = r;
            }
            catch (Exception ex)
            {
                ret.msg = ex.Message;
            }
            return(Json(ret));
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            JsonArray json = new JsonArray();
            Msg       msg  = PlanStatusModel.GetUnFillPlans();//获取未完成的项目

            if (msg.Status)
            {
                List <Tbl_Plan> list = msg.UserData as List <Tbl_Plan>;
                GsonHelper      gson = new GsonHelper();

                for (int i = 0; i < list.Count; i++)
                {
                    RetMsg ret = new RetMsg();
                    ret.planId      = list[i].PlanID;
                    ret.Time        = list[i].PlanDate.ToString();
                    ret.ProjectName = list[i].ProjectName;
                    json.Add(JsonValue.Parse(gson.GetSerializerString(ret)));
                }
            }
            this.Response.Write(json.ToString());
        }
Example #26
0
        public string Put()
        {
            if (Config.IsMulti)
            {
                db = new DbBranch();
            }
            else
            {
                db = new DB();
            }

            //更新数据,方法一
            try
            {
                @operator user = JsonConvert.DeserializeObject <@operator>(Request["data"]);
                db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                if (db.SaveChanges() > 0)
                {
                    return(RetMsg.Success(user));
                }
                return(RetMsg.UpdateFailed);
            }
            catch (Exception ex)
            {
                ex = ex.InnerException ?? ex;
                LogHelper.Error(ex);
                return(RetMsg.Error(ex.Message));
            }
            //更新数据,方法二
            //var query1 = (from q in context.Users
            //              where q.UserName == "Jone"
            //              select q).SingleOrDefault();

            ////判断query1是否为空,若不为空,则修改UserEmail。
            //if (query1 != null)
            //{
            //    query1.UserEmail = "*****@*****.**";
            //    context.SubmitChanges();
            //}
        }
Example #27
0
        public RetMsg Update(Site site)
        {
            RetMsg ret = new RetMsg();

            try
            {
                IQueryable <Site> siteList = db.Sites.Where(p => p.pId == site.pId && p.id != site.id && p.name == site.name);
                if (siteList.Count() == 0)
                {
                    Site s = db.Sites.Find(site.id);

                    s.name             = site.name;
                    s.description      = site.description;
                    s.type             = site.type;
                    s.url              = site.url;
                    s.paras            = site.paras;
                    s.mailgroup        = site.mailgroup;
                    s.interval         = site.interval;
                    s.isuse            = site.isuse;
                    s.lastUpdatePerson = site.lastUpdatePerson;
                    s.lastUpdateDate   = site.lastUpdateDate;

                    db.SaveChanges();

                    ret.Result = true;
                }
                else
                {
                    ret.Result = false;
                    ret.Msg    = "服务器名称已存在";
                }
            }
            catch (Exception e)
            {
                ret.Result = false;
                ret.Msg    = e.Message;
            }
            return(ret);
        }
Example #28
0
        /// <summary>
        /// Returns true if APIKeyBase instances are equal
        /// </summary>
        /// <param name="input">Instance of APIKeyBase to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(APIKeyBase input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     RetCode == input.RetCode ||
                     (RetCode != null &&
                      RetCode.Equals(input.RetCode))
                     ) &&
                 (
                     RetMsg == input.RetMsg ||
                     (RetMsg != null &&
                      RetMsg.Equals(input.RetMsg))
                 ) &&
                 (
                     ExtCode == input.ExtCode ||
                     (ExtCode != null &&
                      ExtCode.Equals(input.ExtCode))
                 ) &&
                 (
                     ExtInfo == input.ExtInfo ||
                     (ExtInfo != null &&
                      ExtInfo.Equals(input.ExtInfo))
                 ) &&
                 (
                     Result == input.Result ||
                     Result != null &&
                     Result.SequenceEqual(input.Result)
                 ) &&
                 (
                     TimeNow == input.TimeNow ||
                     (TimeNow != null &&
                      TimeNow.Equals(input.TimeNow))
                 ));
        }
Example #29
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (RetCode != null)
                {
                    hashCode = hashCode * 59 + RetCode.GetHashCode();
                }

                if (RetMsg != null)
                {
                    hashCode = hashCode * 59 + RetMsg.GetHashCode();
                }

                if (ExtCode != null)
                {
                    hashCode = hashCode * 59 + ExtCode.GetHashCode();
                }

                if (ExtInfo != null)
                {
                    hashCode = hashCode * 59 + ExtInfo.GetHashCode();
                }

                if (Result != null)
                {
                    hashCode = hashCode * 59 + Result.GetHashCode();
                }

                if (TimeNow != null)
                {
                    hashCode = hashCode * 59 + TimeNow.GetHashCode();
                }

                return(hashCode);
            }
        }
Example #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            JsonArray json = new JsonArray();

            string sPlanId = this.Request["planId"];
            Msg    msg     = ATrack.TrackStausByPlanId(int.Parse(sPlanId));

            if (msg.Status)
            {
                List <Tbl_ProductBatch> list = msg.UserData as List <Tbl_ProductBatch>;
                GsonHelper gson = new GsonHelper();

                for (int i = 0; i < list.Count; i++)
                {
                    RetMsg oPro = new RetMsg();
                    oPro.BuildBatchId = int.Parse(list[i].BuildBatchID.ToString());
                    oPro.BuildName    = list[i].BuildName;
                    oPro.Time         = list[i].NowAdmTime.ToString();

                    json.Add(JsonValue.Parse(gson.GetSerializerString(oPro)));
                }
            }
            this.Response.Write(json);
        }