/// <summary>
        /// Saves a given CSV string of RapidLoader records to the temp directory and emails a link to the user
        /// </summary>
        public static void RLSaveData(ICswResources CswResources, CswNbtMobileReturn Return, RapidLoaderData.RapidLoaderDataRequest Request)
        {
            CswNbtResources _CswNbtResources = ( CswNbtResources )CswResources;

            Request.EmailAddress = _CswNbtResources.CurrentNbtUser.Email.Trim();
            CswNbtMobileRapidLoader _CswNbtMobileRapidLoader = new CswNbtMobileRapidLoader(_CswNbtResources);

            _CswNbtMobileRapidLoader.saveRapidLoaderData(Request);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CswResources"></param>
        /// <param name="ReturnObj"></param>
        /// <param name="LegacyFileData"></param>
        public static void performOperations(ICswResources CswResources, CswNbtMobileReturn ReturnObj, string LegacyFileData)
        {
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            Collection <CswNbtCISProNbtMobileData.MobileRequest.Operation> LegacyOperations = new Collection <CswNbtCISProNbtMobileData.MobileRequest.Operation>();

            // string filecontents = MPFDF.FileContents;
            string filecontents = LegacyFileData;

            //Convert string into an array of strings
            string[]      delimiters = new string[] { "\r\n", "\n" };
            List <string> ops        = new List <string>(filecontents.Split(delimiters, StringSplitOptions.RemoveEmptyEntries));

            //Grab the first line and store it as programname
            CswNbtCISProNbtMobileData.MobileRequest.Data LegacyData = new CswNbtCISProNbtMobileData.MobileRequest.Data();
            LegacyData.programname = ops[0];
            // We set the user to the user who is uploading the data
            LegacyData.username = CswResources.CurrentUser.Username;

            //What to do if the first line doesn't match with enum?
            DataFormat Format;

            if (Enum.TryParse(LegacyData.programname, out Format))
            {
                //remove the first line
                ops.RemoveAt(0);

                if (DataFormat.multi1 == Format)
                {
                    //iterate through operations and save as objects
                    foreach (string op in ops)
                    {
                        string[] currentOp = op.Split(',');
                        //create an operation object
                        CswNbtCISProNbtMobileData.MobileRequest.Operation NewOperation = new CswNbtCISProNbtMobileData.MobileRequest.Operation();
                        NewOperation.op = textInfo.ToTitleCase(currentOp[0].ToLower());
                        string barcodeIn = currentOp[3];
                        if (false == barcodeIn.StartsWith("C"))
                        {
                            barcodeIn = "C" + barcodeIn;
                        }
                        NewOperation.barcode = barcodeIn;
                        //create an update object
                        CswNbtCISProNbtMobileData.MobileRequest.Update NewUpdate = new CswNbtCISProNbtMobileData.MobileRequest.Update();
                        NewUpdate.user     = currentOp[1];
                        NewUpdate.location = currentOp[2];
                        //add update object to the operation object
                        NewOperation.update = NewUpdate;

                        //save the operation object to the collection of operations
                        LegacyOperations.Add(NewOperation);
                    }
                }
                else if (DataFormat.reconcilectrlctns == Format)
                {
                    //iterate through operations and save as objects
                    foreach (string op in ops)
                    {
                        string[] currentOp = op.Split(',');
                        //create an operation object
                        CswNbtCISProNbtMobileData.MobileRequest.Operation NewOperation = new CswNbtCISProNbtMobileData.MobileRequest.Operation();
                        NewOperation.op = "Reconcile";
                        string barcodeIn = currentOp[1];
                        if (false == barcodeIn.StartsWith("C"))
                        {
                            barcodeIn = "C" + barcodeIn;
                        }
                        NewOperation.barcode = barcodeIn;
                        //create an update object
                        CswNbtCISProNbtMobileData.MobileRequest.Update NewUpdate = new CswNbtCISProNbtMobileData.MobileRequest.Update();
                        NewUpdate.location = currentOp[0];
                        //add update object to the operation object
                        NewOperation.update = NewUpdate;

                        //save the operation object to the collection of operations
                        LegacyOperations.Add(NewOperation);
                    }
                }

                //Add the collection of operations to the data object
                LegacyData.MultiOpRows = LegacyOperations;

                //Create a new mobilerequest object and add the data object to it
                CswNbtCISProNbtMobileData.MobileRequest LegacyMobileDataObj = new CswNbtCISProNbtMobileData.MobileRequest();
                LegacyMobileDataObj.data = LegacyData;

                //Call the action class which makes the batch op
                CswNbtActUploadLegacyMobileData _CswNbtActUploadLegacyMobileData = new CswNbtActUploadLegacyMobileData((CswNbtResources)CswResources);
                CswNbtObjClassBatchOp           BatchNode = _CswNbtActUploadLegacyMobileData.makeNodesBatch(LegacyMobileDataObj);

                //Create a JObject to display the tree view in the last step of the wizard
                JObject ret = new JObject();

                if (null != BatchNode)
                {
                    ret["result"] = 1;

                    CswNbtView BatchOpsView = new CswNbtView((CswNbtResources)CswResources);
                    BatchOpsView.ViewName = "New Batch Operations";
                    BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                    CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(BatchNode.NodeType, false);
                    BatchRel.NodeIdsToFilterIn.Add(BatchNode.NodeId);

                    CswNbtWebServiceTree ws = new CswNbtWebServiceTree((CswNbtResources)CswResources, BatchOpsView);
                    ret["treedata"] = ws.runTree(null, null, false, true, string.Empty);

                    BatchOpsView.SaveToCache(true);
                    ret["sessionviewid"] = BatchOpsView.SessionViewId.ToString();
                    ret["viewmode"]      = BatchOpsView.ViewMode.ToString();
                }

                ReturnObj.Data.TreeData = ret.ToString();
            }
            else
            {
                ReturnObj.Data.Error = "The program name is invalid.";
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CswResources"></param>
        /// <param name="ReturnObj"></param>
        /// <param name="Stream"></param>
        public static void parseDataFile(ICswResources CswResources, CswNbtMobileReturn ReturnObj, Stream Stream)
        {
            CswTools.MultiPartFormDataFile MPFDF = new CswTools.MultiPartFormDataFile(Stream);

            ReturnObj.Data.FileContents = MPFDF.FileContents;
        }