コード例 #1
0
        public ActionResult AddTrainee(string snr, string trainingid)
        {
            var res = new TRes
            {
                data = 0,
                msg  = string.Empty
            };

            Guid gTrainingID = Guid.Empty;

            if (!Guid.TryParse(trainingid, out gTrainingID))
            {
                res.msg = "培训id无效";
                return(Json(res));
            }

            var         serr       = string.Empty;
            TPersonInfo personInfo = null;

            res.data = TraineeInfo.Add(snr, gTrainingID, out personInfo, out serr);
            res.msg  = serr;
            //var cnt = TraineeInfo.GetCountByTrainingID(gTrainingID);
            res.extra = new
            {
                //cnt = cnt,
                personInfo = personInfo
            };

            return(Json(res));
        }
コード例 #2
0
        public IEnumerable <TRes> Result <TRes>() where TRes : class
        {
            Ai.Guard.Check(proc != null && proc.Connection != null, "MultiResult proc error");
            if (numerator == null)
            {
                yield break;
            }
            if (typeof(TRes).Equals(typeof(object[])))
            {
                do
                {
                    var values = numerator.Current as object[]; // DbDataRecord;
                    yield return(values as TRes);
                } while (numerator.MoveNext());
            }

            var helper = new DbDataMapHelper <TRes>();

            var cycle = numerator;

            do
            {
                var rec = numerator.Current as object[]; // as DbDataRecord;
                if (rec == null)
                {
                    yield break;    // first error
                }
                var  objArray = DbRecord(reader.FieldCount);
                TRes obj      = helper.SetValues(objArray);
                yield return(obj);
            }while (cycle.MoveNext());
        }
コード例 #3
0
        public ActionResult ChangeRole(string userAD, string[] selRole)
        {
            var res = new TRes
            {
                bok = false
            };

            if (string.IsNullOrEmpty(userAD) || null == selRole || 0 == selRole.Length)
            {
                res.msg = "参数有误";
                return(Json(res));
            }
            if (!CommonInfo.HasRight(TRightID.ADMIN))
            {
                res.msg = "只有管理员才可以修改权限";
                return(Json(res));
            }

            string errmsg  = string.Empty;
            var    sRoleID = SysUserInfo.ChangeRole(userAD, selRole, out errmsg);

            res.bok  = true;
            res.data = sRoleID;
            return(Json(res));
        }
コード例 #4
0
        public ActionResult QueryHCDataAll(string date, string warehouse)
        {
            var obj = new TRes
            {
                bok = true
            };

            try
            {
                var dat = QueryHelper.QueryHCDataAll(date, warehouse);
                obj.data = dat;
                //if (0 == datWeek.Count)
                //{
                //    obj.bok = false;
                //    obj.msg = "没有查询到数据";
                //}
            }
            catch (Exception ex)
            {
                obj.bok = false;
                obj.msg = "数据有问题:" + ex.Message;
            }

            return(Json(obj));
        }
コード例 #5
0
        public ActionResult DoAddMail(string txtEnName, string txtCnName, string txtMailAddr, string txtMailAddrType)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            if (!ModelState.IsValid)
            {
                res.msg = "数据无效";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrEmpty(txtMailAddr))
            {
                res.msg = "邮件地址是必填项!";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            var sErr     = string.Empty;
            var mailType = TMailType.To;

            Enum.TryParse <TMailType>(txtMailAddrType, out mailType);
            res.bok = QueryHelper.MailAdd(txtEnName, txtCnName, txtMailAddr, mailType, out sErr);
            res.msg = sErr;
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public ActionResult SingleCondAdd(string txtCommodityCode, string txtCostItemNumber, string txtCommodityCodeDesc)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            if (!ModelState.IsValid)
            {
                res.msg = "数据无效";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrEmpty(txtCostItemNumber))
            {
                res.msg = "Cost Item Number是必填项!";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            var sErr = string.Empty;

            res.bok = QueryHelper.SingleCondAdd(txtCommodityCode, txtCostItemNumber, txtCommodityCodeDesc, out sErr);
            res.msg = sErr;
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public ActionResult GetTrainees(string training_id)
        {
            var res = new TRes
            {
                bok = false,
                msg = string.Empty
            };

            if (string.IsNullOrEmpty(training_id))
            {
                res.msg = "培训ID必须提供";
                return(Json(res));
            }
            Guid gTrainingID = Guid.Empty;

            if (!Guid.TryParse(training_id, out gTrainingID))
            {
                res.msg = "培训ID有问题";
                return(Json(res));
            }

            var trainees = TraineeInfo.LoadByTrainingID(gTrainingID, CommonInfo.PAGE_SIZE, -1);

            if (trainees != null)
            {
                //var cnt = TraineeInfo.GetCountByTrainingID(gTrainingID);
                res.data  = trainees.Count;
                res.extra = trainees;
            }
            res.bok = true;
            return(Json(res));
        }
コード例 #8
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsChanged)
            {
                FOutput.SliceCount = FInput.SliceCount;

                for (int i = 0; i < FInput.SliceCount; i++)
                {
                    var r = new TRes();
                    r.host     = FInput[i];
                    r.idx      = i;
                    r.Resolved = false;
                    var t = new Task <TRes>(() => _GetHostByName(r));
                    var c = t.ContinueWith((res) =>
                    {
                        if (res.Result.ips != null)
                        {
                            FOutput[res.Result.idx].SliceCount = res.Result.ips.Length;
                            for (int j = 0; j < res.Result.ips.Length; j++)
                            {
                                FOutput[res.Result.idx][j] = res.Result.ips[j];
                            }
                        }
                        else
                        {
                            FOutput[res.Result.idx].SliceCount = 0;
                        }
                    }, TaskContinuationOptions.OnlyOnRanToCompletion);
                    t.Start();
                }
            }


            //FLogger.Log(LogType.Debug, "Logging to Renderer (TTY)");
        }
コード例 #9
0
 private TRes _GetHostByName(TRes r)
 {
     r.ips = null;
     try
     {
         IPHostEntry hostname = Dns.GetHostEntry(r.host);
         if (hostname != null)
         {
             IPAddress[] ip = hostname.AddressList;
             if (ip.Length > 0)
             {
                 r.ips = new string[ip.Length];
                 for (int i = 0; i < ip.Length; i++)
                 {
                     r.ips[i] = (ip[i].ToString());
                 }
                 //FLogger.Log(LogType.Debug, ip.Length.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         FLogger.Log(LogType.Debug, "_GetHostByName: " + ex.ToString());
     }
     return(r);
 }
コード例 #10
0
        public ActionResult QueryWeekData(string bu, string startDate, string endDate)
        {
            var obj = new TRes
            {
                bok = true
            };

            try
            {
                var datWeek = QueryHelper.GetWeekData(bu, startDate, endDate);
                obj.data = datWeek;
                if (null == datWeek.data || 0 == datWeek.columns.Count)
                {
                    obj.bok = false;
                    obj.msg = "没有查询到数据";
                }
            }
            catch (Exception ex)
            {
                obj.bok = false;
                obj.msg = "数据有问题:" + ex.Message;
            }

            return(Json(obj));
        }
コード例 #11
0
        public ActionResult UploadCond(HttpPostedFileBase file)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            if (!ModelState.IsValid)
            {
                res.msg = "数据无效";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            if (file == null || file.ContentLength == 0)
            {
                res.msg = "文件有问题";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            var  sErrImp = string.Empty;
            bool bImp    = CommodityRecvHelper.ImpUpload(file, out sErrImp);

            res.bok = bImp;
            if (!bImp)
            {
                res.msg = sErrImp;
                ModelState.AddModelError("", res.msg);
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        public ActionResult CalcTrainingInfo(string training_id, bool need_timelen)
        {
            var res = new TRes
            {
                bok = false,
                msg = string.Empty
            };

            if (string.IsNullOrEmpty(training_id))
            {
                res.msg = "培训ID必须提供";
                return(Json(res));
            }
            Guid gTrainingID = Guid.Empty;

            if (!Guid.TryParse(training_id, out gTrainingID))
            {
                res.msg = "培训ID有问题";
                return(Json(res));
            }

            var          nTrainee = TraineeInfo.GetCountByTrainingID(gTrainingID);
            TCourseEntry courInfo = null;

            if (need_timelen)
            {
                courInfo = TrainingInfo.GetRefCourse(gTrainingID);
            }
            res.bok  = true;
            res.data = new {
                nTrainee    = nTrainee,
                courTimeLen = (null == courInfo) ? 0.0 : courInfo.timeLen
            };
            return(Json(res));
        }
コード例 #13
0
		//called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			if(FInput.IsChanged)
			{
				FOutput.SliceCount = FInput.SliceCount;
	
				for (int i = 0; i < FInput.SliceCount; i++) {
					
					var r = new TRes();
					r.host = FInput[i];
					r.idx = i;
					r.Resolved = false;
					var t = new Task<TRes>(() => _GetHostByName(r));
					var c = t.ContinueWith((res) =>
					{
					   if(res.Result.ips != null)
					   {
							FOutput[res.Result.idx].SliceCount = res.Result.ips.Length;
							for(int j = 0; j<res.Result.ips.Length;j++)
							{
								FOutput[res.Result.idx][j] = res.Result.ips[j];
							}
						} else FOutput[res.Result.idx].SliceCount = 0;
					},TaskContinuationOptions.OnlyOnRanToCompletion);
					t.Start();
					
					
				}
				
			}
			
			
			//FLogger.Log(LogType.Debug, "Logging to Renderer (TTY)");
		}
コード例 #14
0
        public ActionResult DelCondition(int id, string CostItemNumber)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            res.bok = QueryHelper.DelCondition(id, CostItemNumber);
            return(Json(res));
        }
コード例 #15
0
        public ActionResult DelMail(int id, string mailAddr)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            res.bok = QueryHelper.DelMail(id, mailAddr);
            return(Json(res));
        }
コード例 #16
0
        /// <summary>
        /// 转化为结果实例
        /// </summary>
        /// <typeparam name="TRes"></typeparam>
        /// <returns></returns>
        public TRes ConvertToReultInherit <TRes>()
            where TRes : ResultMo, new()
        {
            var res = new TRes
            {
                ret     = ret,
                sys_ret = sys_ret,
                msg     = msg
            };

            return(res);
        }
コード例 #17
0
        public ActionResult DeleteHCData(IEnumerable <int> ids)
        {
            var sErr = string.Empty;
            var bRet = QueryHelper.DeleteHCData(ids, out sErr);
            var obj  = new TRes
            {
                bok = bRet,
                msg = sErr
            };

            return(Json(obj));
        }
コード例 #18
0
        public ActionResult DoRegister(string inputad)
        {
            var res = new TRes
            {
                bok = false
            };
            string msg = string.Empty;

            res.bok = SysUserInfo.InsertUserInfo(inputad, ref msg);
            res.msg = msg;
            return(Json(res));
        }
コード例 #19
0
        public ActionResult ReSyncBaan()
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };
            var sErr = string.Empty;

            res.bok = QueryHelper.ReSyncBaan(out sErr);
            res.msg = sErr;
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #20
0
        public ActionResult DelTrainee(string sid)
        {
            var res = new TRes
            {
                bok = false,
                msg = string.Empty
            };

            var serr = string.Empty;

            res.bok = TraineeInfo.DeleteByID(sid, out serr);
            res.msg = serr;
            return(Json(res));
        }
コード例 #21
0
        public ActionResult EnableUser(int id, bool enable)
        {
            var res = new TRes
            {
                bok = false
            };

            string errmsg = string.Empty;
            bool   bRet   = QueryHelper.EnableUser(id, enable, out errmsg);

            res.bok = bRet;
            res.msg = errmsg;
            return(Json(res));
        }
コード例 #22
0
        public ActionResult ModifyRegister(int id, bool enable)
        {
            var res = new TRes
            {
                bok = false
            };

            string errmsg = string.Empty;
            bool   bRet   = SysUserInfo.EnableUser(id, enable, out errmsg);

            res.bok = bRet;
            res.msg = errmsg;
            return(Json(res));
        }
コード例 #23
0
        public ActionResult GetUserRole(string adName)
        {
            var res = new TRes
            {
                bok = false
            };

            string errmsg  = string.Empty;
            var    sRoleID = SysUserInfo.GetUserRoleID(adName);

            res.bok  = true;
            res.data = sRoleID;
            return(Json(res));
        }
コード例 #24
0
        public ActionResult GetWarehouseInfo()
        {
            var lstData = QueryHelper.GetWarehouseList();
            var obj     = new TRes
            {
                bok  = true,
                data = lstData
            };

            if (null == lstData || 0 == lstData.Count)
            {
                obj.bok = false;
                obj.msg = "没有查询到数据";
            }
            return(Json(obj));
        }
コード例 #25
0
        public ActionResult QueryHCRate(string selMonth, string warehouses)
        {
            var dat = QueryHelper.QueryHCRate(selMonth, warehouses);
            var obj = new TRes
            {
                bok  = true,
                data = dat
            };

            if (0 == dat.Count)
            {
                obj.bok = false;
                obj.msg = "没有查询到数据";
            }
            return(Json(obj));
        }
コード例 #26
0
        public ActionResult GetWeekDataInitInfo(string selYear)
        {
            var lstData = QueryHelper.GetWeekdateList(selYear);
            var obj     = new TRes
            {
                bok  = true,
                data = lstData
            };

            if (null == lstData || 0 == lstData.Count)
            {
                obj.bok = false;
                obj.msg = "没有查询到数据";
            }
            return(Json(obj));
        }
コード例 #27
0
        public ActionResult QueryMonthData(int selYear, string selKind)
        {
            var dat = QueryHelper.GetMonthData(selYear, selKind);
            var obj = new TRes
            {
                bok  = true,
                data = dat
            };

            if (null == dat.data || 0 == dat.columns.Count)
            {
                obj.bok = false;
                obj.msg = "没有查询到数据";
            }
            return(Json(obj));
        }
コード例 #28
0
        public ActionResult QueryYear(string dataType)
        {
            var warehouses = QueryHelper.GetWarehouseList();
            var lstData    = QueryHelper.QueryYear(dataType);
            var obj        = new TRes
            {
                bok   = true,
                data  = lstData,
                extra = warehouses
            };

            if (null == lstData || 0 == lstData.Count)
            {
                obj.bok = false;
                obj.msg = "没有查询到数据";
            }
            return(Json(obj));
        }
コード例 #29
0
        public ActionResult UploadData(string dataType, HttpPostedFileBase file)
        {
            var res = new TRes
            {
                bok = false,
                msg = ""
            };

            if (!ModelState.IsValid)
            {
                res.msg = "数据无效";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            if (!CommonInfo.HasRight(TRightID.UPLOAD))
            {
                res.msg = "没有上传权限";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(dataType))
            {
                res.msg = "请选择数据类型";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            if (file == null || file.ContentLength == 0)
            {
                res.msg = "文件有问题";
                ModelState.AddModelError("", res.msg);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            var  sErrImp = string.Empty;
            bool bImp    = BLLHelper.ImpUpload(dataType, file, out sErrImp);

            res.bok = bImp;
            if (!bImp)
            {
                res.msg = sErrImp;
                ModelState.AddModelError("", res.msg);
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #30
0
        public ActionResult CheckLector(string workid, string courseid)
        {
            var res = new TRes
            {
                data = -1,
                msg  = string.Empty
            };
            string      serr    = string.Empty;
            TPersonInfo lecInfo = null;
            int         nRet    = LectorInfo.CheckByWorkID(workid, courseid, out lecInfo, out serr);

            res.data = nRet;
            res.msg  = serr;
            if (nRet > 0)
            {
                res.extra = lecInfo;
            }
            return(Json(res));
        }
コード例 #31
0
        public ActionResult LoadMonthSummary(string mon, bool showEmpty)
        {
            var res = new TRes
            {
                bok = false,
                msg = string.Empty
            };

            if (string.IsNullOrEmpty(mon))
            {
                res.msg = "汇总月份有问题";
                return(Json(res));
            }

            string serr = string.Empty;

            res.data = TrainingInfo.LoadMonthSummary(mon, showEmpty);
            res.bok  = true;
            return(Json(res));
        }
コード例 #32
0
		private TRes _GetHostByName(TRes r)
		{
			r.ips = null;
			try
            {
                IPHostEntry hostname = Dns.GetHostEntry(r.host);
            	if(hostname != null)
            	{
                	IPAddress[] ip = hostname.AddressList;
            		if(ip.Length>0)
                	{
                		r.ips = new string[ip.Length];
                		for (int i = 0; i< ip.Length; i++)
                		{
                			r.ips[i] = (ip[i].ToString());
                		}
                		//FLogger.Log(LogType.Debug, ip.Length.ToString());
                	}
            	}
            }
            catch (Exception ex)
            {
            	FLogger.Log(LogType.Debug,"_GetHostByName: " + ex.ToString());
            
            	
            }
			return r;
		}