コード例 #1
0
 private bool SaveScoreCommentResult()
 {
     try
     {
         if (ScoreSheetItem == null ||
             mCurrentScoreSheet == null)
         {
             return(false);
         }
         List <ScoreObject> listScoreObjects = new List <ScoreObject>();
         mCurrentScoreSheet.GetAllScoreObject(ref listScoreObjects);
         List <BasicScoreCommentInfo> listCommentResults = new List <BasicScoreCommentInfo>();
         for (int i = 0; i < listScoreObjects.Count; i++)
         {
             var comment = listScoreObjects[i] as Comment;
             if (comment == null)
             {
                 continue;
             }
             var scoreItem = comment.ScoreItem;
             if (scoreItem == null)
             {
                 continue;
             }
             var temp =
                 mListScoreCommentResults.FirstOrDefault(s => s.ScoreResultID == ScoreSheetItem.ScoreResultID &&
                                                         s.ScoreSheetID == mCurrentScoreSheet.ID &&
                                                         s.ScoreItemID == scoreItem.ID &&
                                                         s.ScoreCommentID == comment.ID);
             if (temp == null)
             {
                 temp = new BasicScoreCommentInfo();
                 temp.ScoreResultID  = ScoreSheetItem.ScoreResultID;
                 temp.ScoreSheetID   = mCurrentScoreSheet.ID;
                 temp.ScoreItemID    = scoreItem.ID;
                 temp.ScoreCommentID = comment.ID;
             }
             var itemComment = comment as ItemComment;
             if (itemComment != null &&
                 itemComment.SelectItem != null)
             {
                 temp.CommentItemID      = itemComment.SelectItem.ID;
                 temp.CommentItemOrderID = itemComment.SelectItem.OrderID;
                 temp.CommentText        = itemComment.SelectItem.Text;
                 listCommentResults.Add(temp);
             }
             var textComment = comment as TextComment;
             if (textComment != null)
             {
                 temp.CommentText = textComment.Text;
                 listCommentResults.Add(temp);
             }
         }
         int count = listCommentResults.Count;
         if (count <= 0)
         {
             return(true);
         }
         WebRequest webRequest = new WebRequest();
         webRequest.Session = CurrentApp.Session;
         webRequest.Code    = (int)S3102Codes.SaveScoreCommentResultInfos;
         webRequest.ListData.Add(ScoreSheetItem.ScoreResultID.ToString());
         webRequest.ListData.Add(count.ToString());
         for (int i = 0; i < listCommentResults.Count; i++)
         {
             OperationReturn optReturn = XMLHelper.SeriallizeObject(listCommentResults[i]);
             if (!optReturn.Result)
             {
                 ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                 return(false);
             }
             webRequest.ListData.Add(optReturn.Data.ToString());
         }
         Service31021Client client = new Service31021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                            WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo,
                                                                                            "Service31021"));
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
         return(false);
     }
 }
コード例 #2
0
ファイル: SSMMainView.xaml.cs プロジェクト: chenmj201601/UMP
        private void ImportScoreSheet()
        {
            try
            {
                //读取zip文件位置
                System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
                fileDialog.Multiselect = true;
                //fileDialog.Title = "请选择文件";
                //fileDialog.Filter = "所有文件(*.*)|*.*";
                fileDialog.Title  = CurrentApp.GetLanguageInfo("3101N014", "Please Select");
                fileDialog.Filter = @"Zip file(*.zip)|*.zip";
                string file;
                if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    file = fileDialog.FileName;
                    //System.Windows.Forms.MessageBox.Show("已选择文件:" + file, "选择文件提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    return;
                }

                //这个是解压的位置
                string x = Path.GetDirectoryName(file);

                //解压zip文件获取xml 并获得xml文件的位置
                string temp = UnZipFile(file, x);

                OperationReturn optReturn = XMLHelper.DeserializeFile <ScoreSheet>(temp);

                //删除解压的xml文件
                File.Delete(temp);

                ScoreSheet tempScoreSheet = optReturn.Data as ScoreSheet;
                if (tempScoreSheet == null)
                {
                    return;
                }
                tempScoreSheet.ScoreSheet = tempScoreSheet;
                tempScoreSheet.Init();

                List <ScoreObject> listScoreObjectTemp = new List <ScoreObject>();
                tempScoreSheet.GetAllScoreObject(ref listScoreObjectTemp);
                for (int i = 0; i < listScoreObjectTemp.Count; i++)
                {
                    listScoreObjectTemp[i].ID = GetSerialID();
                }
                tempScoreSheet.UseTag = 0;
                tempScoreSheet.ID     = GetSerialID();
                tempScoreSheet.InitUseItemID();
                SaveScoreSheetData(tempScoreSheet);

                //刷新列表
                LoadScoreSheets();
                ShowInformation(CurrentApp.GetLanguageInfo("3101N007", "SECCESS"));
                string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO3101005")), tempScoreSheet.Display);
                CurrentApp.WriteOperationLog(S3101Consts.OPT_IMPORTSCORESHEET.ToString(),
                                             ConstValue.OPT_RESULT_SUCCESS, msg);
            }
            catch (Exception ex)
            {
                CurrentApp.WriteLog("ImportScoreSheet Fail--", ex.ToString());
                ShowInformation(CurrentApp.GetLanguageInfo("3101N008", "Fail"));
            }
        }