Esempio n. 1
0
 public static List <Tuple <List <string>, Dictionary <String, String> > > GetMyWorkitem(string workerId, string rtid)
 {
     try
     {
         var argDict = new Dictionary <string, string>
         {
             { "signature", GlobalDataPackage.Signature },
             { "rtid", rtid }
         };
         NetClient.PostData(GlobalDataPackage.URL_GetAllWorkitem, argDict, out var retStr);
         var response     = JsonConvert.DeserializeObject <StdResponseEntity>(retStr);
         var workitemList = ReturnDataHelper.DecodeList(response);
         var retList      = new List <Tuple <List <string>, Dictionary <String, String> > >();
         retList.AddRange(
             from workitem
             in workitemList
             select ReturnDataHelper.DecodeDictionaryByString(workitem.ToString())
             into wd
             let workerIdListDesc = wd["WorkerIdList"]
                                    let workerIdList = JsonConvert.DeserializeObject <List <String> >(workerIdListDesc)
                                                       select new Tuple <List <string>, Dictionary <String, String> >(workerIdList, wd));
         return(retList.FindAll(t => t.Item1.Contains(workerId)));
     }
     catch (Exception ex)
     {
         LogUtils.LogLine("Get workitems, exception occurred" + ex, LogLevel.Error);
         return(null);
     }
 }
Esempio n. 2
0
        public static List <Tuple <String, String, String> > GetWorkitemNameIdOneHandlerInVector()
        {
            var retList = new List <Tuple <String, String, String> >();

            try
            {
                var argDict = new Dictionary <string, string>
                {
                    { "signature", Ren.transaction.Signature },
                    { "rtid", Ren.rtid }
                };
                NetClient.PostData(GlobalContext.LocationDict["GetAllWorkitem"], argDict, out var retStr);
                var response     = JsonConvert.DeserializeObject <StdResponseEntity>(retStr);
                var workitemList = ReturnDataHelper.DecodeList(response);
                foreach (var workitem in workitemList)
                {
                    var wd = ReturnDataHelper.DecodeDictionaryByString(workitem.ToString());
                    var workerIdListDesc = wd["WorkerIdList"].ToString();
                    var workerIdList     = JsonConvert.DeserializeObject <List <String> >(workerIdListDesc);
                    retList.Add(new Tuple <string, string, string>(workerIdList.Last(), wd["Wid"].ToString(), wd["TaskName"].ToString()));
                }
                return(retList);
            }
            catch (Exception ex)
            {
                LogUtils.LogLine("Get all workitems, exception occurred" + ex, LogLevel.Error);
                return(null);
            }
        }
Esempio n. 3
0
        public void RefreshList()
        {
            this.ListBox_Solver_Tasks.Items.Clear();
            var rtids = CSCore.GetAllActiveRTID();

            foreach (var rtid in rtids)
            {
                var workitems = InteractionManager.GetMyWorkitem(GlobalDataPackage.CurrentUserWorkerId, rtid);
                foreach (var workitem in workitems)
                {
                    var itemDict = workitem.Item2;
                    var request  = CSCore.GetRequestByRTID(rtid);
                    var retArgs  = ReturnDataHelper.DecodeDictionaryByString(itemDict["Argument"]);
                    var lbi      = new ListBoxItem
                    {
                        Content = String.Format("Task: {0} | From CrowdSourcing Request: {1} | By: {2}",
                                                itemDict["TaskName"], request.ItemArray[1], request.ItemArray[2]),
                        Tag = new Tuple <Dictionary <String, String>, Dictionary <String, String> >(itemDict, retArgs)
                    };
                    this.ListBox_Solver_Tasks.Items.Add(lbi);
                }
            }
        }
Esempio n. 4
0
        private void ListBox_Solver_Tasks_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (this.ListBox_Solver_Tasks.SelectedIndex == -1)
            {
                return;
            }
            var listItem = this.ListBox_Solver_Tasks.SelectedItem as ListBoxItem;
            var itemDict = (listItem.Tag as Tuple <Dictionary <String, String>, Dictionary <String, String> >).Item1;
            //var argDict = (listItem.Tag as Tuple<Dictionary<String, String>, Dictionary<String, String>>).Item2;
            //var request = CSCore.GetRequestByRTID(itemDict["Rtid"]);
            var passedArguments = ReturnDataHelper.DecodeDictionaryByString(itemDict["Argument"]);

            switch (itemDict["TaskName"])
            {
            case "judgeTask":
                new JudgeTaskWindow(passedArguments["taskName"], passedArguments["taskDescription"], itemDict["Wid"]).ShowDialog();
                break;

            case "decomposeTask":
                new DecomposeWindow(passedArguments["taskName"], passedArguments["taskDescription"], itemDict["Wid"], itemDict["Rtid"], itemDict["CallbackNodeId"]).ShowDialog();
                break;

            case "decomposeVoteTask":
                new DecomposeVoteWindow(passedArguments["taskName"], passedArguments["taskDescription"], itemDict["Wid"], itemDict["Rtid"], itemDict["CallbackNodeId"]).ShowDialog();
                break;

            case "solveTask":
                new SolveWindow(passedArguments["taskName"], passedArguments["taskDescription"], itemDict["Wid"], itemDict["Rtid"], itemDict["CallbackNodeId"]).ShowDialog();
                break;

            case "solveVoteTask":
                new SolveVoteWindow(passedArguments["taskName"], passedArguments["taskDescription"], itemDict["Wid"], itemDict["Rtid"], itemDict["CallbackNodeId"]).ShowDialog();
                break;
            }
            this.RefreshList();
        }