コード例 #1
0
        public IActionResult DeleteFile(string fileName)
        {
            ViewBag.response = responseFromDeleteFileAPI(fileName).responseType;
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            ViewBag.isLogged          = true;
            return(View("Index"));
        }
コード例 #2
0
ファイル: FmMOExcuteQ.cs プロジェクト: hanxiaomeme/CERP
        private void RefOperation(object sender, EventArgs e)
        {
            IRefDAL2 dal = new OperationDAL(Information.UserInfo.ConnU8);
            RefForm2 frm = new RefForm2(dal);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                OperationId           = Convert.ToInt32(frm.rows[0]["operationId"]);
                this.txtr_OpName.Text = frm.rows[0]["OpName"].ToString();
            }
        }
コード例 #3
0
        private void btn_AddLine_Click(object sender, EventArgs e)
        {
            IRefDAL2 dal = new OperationDAL(Information.UserInfo.ConnU8);
            RefForm2 frm = new RefForm2(dal);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                var r = model.dtOperations.NewRow();
                r["operationId"] = frm.rows[0]["operationId"];
                r["OpCode"]      = frm.rows[0]["OpCode"];
                r["OpName"]      = frm.rows[0]["OpName"];
                r["cycleTime"]   = 0;
                model.dtOperations.Rows.Add(r);
            }
        }
コード例 #4
0
ファイル: FmWORouter.cs プロジェクト: hanxiaomeme/CERP
        private void AddLine(object sender, EventArgs e)
        {
            #region 增加行
            IRefDAL2 dal = new OperationDAL(Information.UserInfo.ConnU8);
            RefForm2 frm = new RefForm2(dal);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                var r = dvRouter.AddNew();
                r.BeginEdit();
                r["guid"]        = woGuid;
                r["operationId"] = frm.rows[0]["operationId"];
                r["OpName"]      = frm.rows[0]["OpName"];
                r["bQuality"]    = 0;
                r.EndEdit();

                this.ReSetOrder();
            }
            #endregion
        }
コード例 #5
0
        public IActionResult Index()
        {
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            return(View());
        }
コード例 #6
0
        public int operationDistance()
        {
            SqlHelper sh = new SqlHelper();

            sh.Open();

            OperationDAL opt = new OperationDAL(sh);

            opt.DeleteRecommend();  //删除推荐结果表中数据

            try {
                //1、取出所有老师的ID
                List <string> techIDs = opt.getAllTechID();

                //2、构造每个老师的评分表
                Dictionary <string, Dictionary <string, double> > dic = new Dictionary <string, Dictionary <string, double> >();
                dic = opt.makeMarkTable(techIDs);

                //3、计算距离(数据稀疏-->余弦相似度;分数膨胀-->皮尔逊;稀疏且膨胀-->修正余弦相似度)
                //(1).计算每个老师对资源打分的平均值   这部分存在问题
                //Dictionary<string, double> dicAveg = new Dictionary<string, double>();
                //foreach (string tID in dic.Keys)
                //{
                //    double sum = 0.0;
                //    //遍历教师tID对资源的评分
                //    foreach (string res in dic[tID].Keys)
                //    {
                //        sum = sum + dic[tID][res];
                //    }
                //    double aveg = sum / dic[tID].Count;

                //    dicAveg.Add(tID, aveg);
                //}


                //计算每个用户同其他用户的(曼哈顿)距离,并按远近排序
                Dictionary <string, Dictionary <string, double> > sortDic = new Dictionary <string, Dictionary <string, double> >();
                foreach (string tid in dic.Keys)
                {
                    Dictionary <string, double> neghborDic = nearestNeighbor(tid, dic);
                    sortDic.Add(tid, neghborDic);
                }

                //4.在排序后的评分字典中为每个取出最相近的K个,把这些用户评分高并且推荐目标没有用过的资源作为推荐项,把推荐结果保存(更新)到数据库
                foreach (string tid in sortDic.Keys)
                {
                    Dictionary <string, double> dicJuLi = sortDic[tid];
                    List <string> techList  = new List <string>();
                    int           K         = 5; //K近邻
                    List <string> recomlist = new List <string>();
                    for (int i = 0; i < K; i++)
                    {
                        KeyValuePair <string, double> kvp = dicJuLi.ElementAt(i);
                        foreach (string res in dic[kvp.Key].Keys)
                        {
                            if (dic[kvp.Key][res] > 2 && !recomlist.Contains(res))
                            { //评分大于3的加入推荐候选项列表
                                recomlist.Add(res);
                            }
                        }
                    }

                    //找出本用户已经用过的资源列表
                    List <string> usedlist = new List <string>();
                    foreach (string res in dic[tid].Keys)
                    {
                        usedlist.Add(res);
                    }

                    //recomlist和usedlist做差集
                    recomlist = recomlist.Except(usedlist).ToList <string>();

                    if (recomlist.Count < 5)
                    { //推荐项少于5,补充社会化属性标签推荐结果
                        BLL.Recommend_ResouceBLL bll        = new BLL.Recommend_ResouceBLL();
                        List <string>            recomlistB = bll.ListUnion(tid);
                        foreach (string res in recomlistB)
                        {
                            if (!recomlist.Contains(res) && recomlist.Count < 5)
                            {
                                recomlist.Add(res);
                            }
                        }
                    }

                    //把用户ID和推荐结果集作为参数调用插入数据库的方法
                    int temp = opt.saveResult(tid, recomlist);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
            return(1);
        }
コード例 #7
0
        public IActionResult Index(UserModel usuario)
        {
            int estadoUsuario = 0, estadoContraseña = 0; string antiguoUsuario = "";

            if (!isEmpty(usuario.email))
            {
                if (!isEmpty(usuario.password))
                {
                    usuario.typeAccess = 2;//2 for Employees
                    UserResponse response = responseFromLoginAPI(usuario);
                    if (response.responseType == 3)
                    {
                        //All OK
                        usuario.typeAccess = Convert.ToInt32(response.email);
                        HttpContext.Session.setObjectAsJson("actualUser", usuario);
                        List <ProjectModel> operations        = responseFromOperationAPI(response.id);
                        List <ProjectModel> runningOperations = new List <ProjectModel>();
                        List <ProjectModel> historyOperations = new List <ProjectModel>();
                        foreach (ProjectModel p in operations)
                        {
                            if (!isFinalizedOperation(p))
                            {
                                runningOperations.Add(p);
                            }
                            else
                            {
                                historyOperations.Add(p);
                            }
                        }
                        //This is for some operation's Timeline
                        ViewBag.runningOperations = runningOperations;
                        ViewBag.historyOperations = historyOperations;
                        ViewBag.allOperations     = OperationDAL.getAll();
                        ViewBag.isLogged          = true;
                        return(View());
                    }
                    else if (response.responseType == 2)
                    {
                        //CONTRASEÑA INCORRECTA
                        estadoContraseña = 1;
                        antiguoUsuario   = usuario.email;
                    }
                    else
                    {
                        //USUARIO NO EXISTE
                        estadoUsuario  = 1;
                        antiguoUsuario = usuario.email;
                    }
                }
                else
                {
                    //CONTRASEÑA NO INTRODUCIDA
                    estadoContraseña = 2;
                    antiguoUsuario   = usuario.email;
                }
            }
            else
            {
                //USUARIO NO INTRODUCIDO
                estadoUsuario = 2;
            }
            return(RedirectToAction("Login", "Home", new
            {
                estadoUsuario,
                estadoContraseña,
                antiguoUsuario
            }));
        }
コード例 #8
0
        public IActionResult UploadFile(string fileIds, IFormFile file)
        {
            string stringFile = "";

            string[] elements   = file.FileName.Split(".");
            string   formatFile = elements[elements.Length - 1];
            int      response   = 0;

            string[] datos     = fileIds.Split("#");
            string[] names     = datos[0].Split("*");
            string[] ids       = datos[1].Split("_");
            int      projectId = Convert.ToInt32(ids[2]);
            int      taskId    = Convert.ToInt32(ids[0]);

            if (file != null)
            {
                if (file.Length < getMegaBytes(5))
                {
                    using (var ms = new MemoryStream())
                    {
                        file.CopyTo(ms);
                        var fileBytes = ms.ToArray();
                        stringFile = Convert.ToBase64String(fileBytes);
                    }
                    string    taskFileName = $"{names[0]}-{names[1]}({projectId}{taskId}).{formatFile}";
                    FileModel newFileModel = new FileModel
                    {
                        idTask          = taskId,
                        idProject       = projectId,
                        documentContent = stringFile,
                        documentName    = taskFileName,
                        format          = formatFile
                    };
                    response = resonseFromUploadFileAPI(newFileModel).responseType;
                }
                else
                {
                    response = 3;
                }
            }
            ViewBag.response = response;
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            ViewBag.isLogged          = true;
            return(View("Index"));
        }